Luna/libc/include/time.h

81 lines
2.4 KiB
C
Raw Normal View History

2023-01-08 14:29:30 +00:00
/* time.h: Time management. */
2023-01-07 10:21:53 +00:00
#ifndef _TIME_H
#define _TIME_H
2023-01-06 23:21:08 +00:00
#include <bits/clockid.h>
2024-01-05 21:15:06 +00:00
#include <bits/itimer.h>
#include <bits/sigevent.h>
#include <bits/struct_tm.h>
2023-01-06 23:21:08 +00:00
#include <bits/timespec.h>
2024-01-05 21:15:06 +00:00
#include <sys/types.h>
2023-01-06 23:21:08 +00:00
typedef long int clock_t;
#define CLOCKS_PER_SEC 1000000
2023-01-06 23:21:08 +00:00
#ifdef __cplusplus
extern "C"
{
#endif
/* Get the current value of a system clock. */
int clock_gettime(clockid_t id, struct timespec* ts);
/* Get the current wall clock time. */
time_t time(time_t* tp);
/* Get the broken-down time representation of UNIX time, in local time. */
struct tm* localtime(const time_t* tp);
/* Get the broken-down time representation of UNIX time, in local time. */
struct tm* localtime_r(const time_t* tp, struct tm* out);
/* Get the broken-down time representation of UNIX time, in UTC time. */
struct tm* gmtime(const time_t* tp);
/* Get the broken-down time representation of UNIX time, in UTC time. */
struct tm* gmtime_r(const time_t* tp, struct tm* out);
/* Build a string representation of broken-down time. */
char* asctime(const struct tm* tm);
/* Build a string representation of broken-down time. */
char* asctime_r(const struct tm* tm, char buf[26]);
/* Build a string representation of UNIX time. */
char* ctime(const time_t* tp);
/* Build a string representation of UNIX time. */
char* ctime_r(const time_t* tp, char buf[26]);
/* Convert broken-down time back into UNIX time. */
time_t mktime(struct tm* tm);
2023-04-13 19:09:27 +00:00
/* Format a string representation of broken-down time using a format string. */
size_t strftime(char* buf, size_t max, const char* format, const struct tm* tm);
/* Return the difference in seconds between two times. */
double difftime(time_t a, time_t b);
/* Estimate the CPU time used by a process. */
clock_t clock(void);
2024-01-05 21:15:06 +00:00
/* Create a new POSIX timer. */
int timer_create(clockid_t clockid, struct sigevent* sevp, timer_t* timerid);
/* Get the current time remaining for a POSIX timer. */
int timer_gettime(timer_t timerid, struct itimerspec* value);
/* Set the time remaining and interval for a POSIX timer. */
int timer_settime(timer_t timerid, int flags, const struct itimerspec* new_value, struct itimerspec* old_value);
/* Delete an existing POSIX timer. */
int timer_delete(timer_t timerid);
2023-01-06 23:21:08 +00:00
#ifdef __cplusplus
}
#endif
#endif