hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
1//
2// Created by XIaokang00010 on 2025/11/23.
3//
4
5#ifndef HOSHI_LANG_TIME_H
6#define HOSHI_LANG_TIME_H
7
9#include <cstdint>
10#include <ctime>
11
12#ifdef _WIN32
13#define CLOCK_REALTIME 0
14#define CLOCK_MONOTONIC 1
15
16int clock_gettime(int clk_id, struct timespec *tp);
17int nanosleep(const struct timespec *req, struct timespec *rem);
18#endif
19
20#define MAX_TIME_STR_LEN 128
21
22
24 unsigned long long gc_refcount;
25 unsigned long long type_id;
26 unsigned long long seconds;
27 unsigned long long nanoseconds;
29
31
32 static YoiIntAndIntObject *create(int64_t seconds, int64_t nanoseconds);
33};
34
35#define LIBTIME_EXPORT extern "C"
36#define LIBTIME_NOFFI
37#define LIBTIME_FFI
38
46
52LIBTIME_EXPORT LIBTIME_FFI void runtime_time_sleep(int64_t seconds, int64_t nanoseconds);
53
61LIBTIME_EXPORT LIBTIME_FFI char *runtime_time_strftime(const char *format, int64_t timestamp);
62
69
77
84
85#endif //HOSHI_LANG_TIME_H
unsigned long long gc_refcount
Definition time.h:24
unsigned long long type_id
Definition time.h:25
unsigned long long seconds
Definition time.h:26
void * weak_slots_head
Definition time.h:28
unsigned long long nanoseconds
Definition time.h:27
static void gc_refcount_decrease(YoiIntAndIntObject *obj)
Definition time.cpp:155
static YoiIntAndIntObject * create(int64_t seconds, int64_t nanoseconds)
Definition time.cpp:162
LIBTIME_EXPORT LIBTIME_NOFFI YoiIntAndIntObject * runtime_time_now()
Return the current time as a YoiIntAndIntObject.
Definition time.cpp:172
LIBTIME_EXPORT LIBTIME_NOFFI YoiIntAndIntObject * runtime_time_monotonic_now()
Get the current monotonic time as a YoiIntAndIntObject.
Definition time.cpp:203
LIBTIME_EXPORT LIBTIME_FFI void runtime_time_sleep(int64_t seconds, int64_t nanoseconds)
Sleep for a given number of seconds.
Definition time.cpp:180
#define LIBTIME_EXPORT
Definition time.h:35
#define LIBTIME_FFI
Definition time.h:37
LIBTIME_EXPORT LIBTIME_FFI int64_t runtime_time_localtimezone_offset()
Get the local timezone offset in seconds.
Definition time.cpp:196
LIBTIME_EXPORT LIBTIME_FFI char * runtime_time_strftime(const char *format, int64_t timestamp)
Convert a timestamp to a string according to a given format.
Definition time.cpp:187
#define LIBTIME_NOFFI
Definition time.h:36
LIBTIME_EXPORT LIBTIME_FFI void runtime_time_finalize(void *memory)
Finalize the memory created by the time module.
Definition time.cpp:211