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;
28
30
31 static YoiIntAndIntObject *create(int64_t seconds, int64_t nanoseconds);
32};
33
34#define LIBTIME_EXPORT extern "C"
35#define LIBTIME_NOFFI
36#define LIBTIME_FFI
37
45
51LIBTIME_EXPORT LIBTIME_FFI void runtime_time_sleep(int64_t seconds, int64_t nanoseconds);
52
60LIBTIME_EXPORT LIBTIME_FFI char *runtime_time_strftime(const char *format, int64_t timestamp);
61
68
76
83
84#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
unsigned long long nanoseconds
Definition time.h:27
static void gc_refcount_decrease(YoiIntAndIntObject *obj)
Definition time.cpp:154
static YoiIntAndIntObject * create(int64_t seconds, int64_t nanoseconds)
Definition time.cpp:160
LIBTIME_EXPORT LIBTIME_NOFFI YoiIntAndIntObject * runtime_time_now()
Return the current time as a YoiIntAndIntObject.
Definition time.cpp:169
LIBTIME_EXPORT LIBTIME_NOFFI YoiIntAndIntObject * runtime_time_monotonic_now()
Get the current monotonic time as a YoiIntAndIntObject.
Definition time.cpp:200
LIBTIME_EXPORT LIBTIME_FFI void runtime_time_sleep(int64_t seconds, int64_t nanoseconds)
Sleep for a given number of seconds.
Definition time.cpp:177
#define LIBTIME_EXPORT
Definition time.h:34
#define LIBTIME_FFI
Definition time.h:36
LIBTIME_EXPORT LIBTIME_FFI int64_t runtime_time_localtimezone_offset()
Get the local timezone offset in seconds.
Definition time.cpp:193
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:184
#define LIBTIME_NOFFI
Definition time.h:35
LIBTIME_EXPORT LIBTIME_FFI void runtime_time_finalize(void *memory)
Finalize the memory created by the time module.
Definition time.cpp:208