From 8162011b5dc76902334a0912401f19234d20acad Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 13 Oct 2013 23:37:06 +0200 Subject: [PATCH] Add header forward declarations. Note that many of the functions are not yet implemented. --- libc/decl/timer_t.h | 4 ++ libc/include/time.h | 88 +++++++++++++++++++++++--------- sortix/include/sortix/__/types.h | 1 + sortix/include/sortix/clock.h | 2 + sortix/include/sortix/x64/bits.h | 1 + sortix/include/sortix/x86/bits.h | 1 + 6 files changed, 73 insertions(+), 24 deletions(-) create mode 100644 libc/decl/timer_t.h diff --git a/libc/decl/timer_t.h b/libc/decl/timer_t.h new file mode 100644 index 00000000..c626d67a --- /dev/null +++ b/libc/decl/timer_t.h @@ -0,0 +1,4 @@ +#ifndef _TIMER_T_DECL +#define _TIMER_T_DECL +typedef __timer_t timer_t; +#endif diff --git a/libc/include/time.h b/libc/include/time.h index 0d7beb43..2f733ce9 100644 --- a/libc/include/time.h +++ b/libc/include/time.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. This file is part of the Sortix C Library. @@ -22,26 +22,22 @@ *******************************************************************************/ -#ifndef _TIME_H -#define _TIME_H 1 +#ifndef INCLUDE_TIME_H +#define INCLUDE_TIME_H #include __BEGIN_DECLS @include(clock_t.h) -@include(clockid_t.h) @include(size_t.h) -@include(pid_t.h) @include(time_t.h) -@include(NULL.h) +@include(clockid_t.h) +@include(timer_t.h) +@include(locale_t.h) +@include(pid_t.h) -__END_DECLS -#include -#include -__BEGIN_DECLS - -#define CLOCKS_PER_SEC 1000000 +struct sigevent; struct tm { @@ -56,22 +52,66 @@ struct tm int tm_isdst; }; -struct utimbuf +__END_DECLS +#include +__BEGIN_DECLS + +/* TODO: This itimer stuff is replaced with another interface IIRC. */ +struct itimerspec { - time_t actime; - time_t modtime; + struct timespec it_interval; + struct timespec it_value; }; +@include(NULL.h) + +#define CLOCKS_PER_SEC ((clock_t) 1000000) + +__END_DECLS +#include +__BEGIN_DECLS + +#define TIMER_ABSTIME (1<<0) + +/* getdate_err is omitted, use strptime */ + +char* asctime(const struct tm*); +char* asctime_r(const struct tm* restrict, char* restrict); clock_t clock(void); -time_t time(time_t* t); -char* ctime(const time_t* timep); -struct tm* localtime_r(const time_t* timer, struct tm* ret); -struct tm* gmtime_r(const time_t* timer, struct tm* ret); -#if !defined(_SORTIX_SOURCE) -struct tm* localtime(const time_t* timer); -struct tm* gmtime(const time_t* timer); -#endif -int utime(const char* filepath, const struct utimbuf* times); +/* TODO: clock_getcpuclockid */ +int clock_getres(clockid_t, struct timespec*); +int clock_gettime(clockid_t, struct timespec*); +int clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*); +int clock_settime(clockid_t, const struct timespec*); +char* ctime(const time_t* clock); +char* ctime_r(const time_t* clock, char* buf); +/* ctime_r is obsolescent */ +double difftime(time_t, time_t); +/* getdate is omitted, use strptime */ +struct tm* gmtime(const time_t*); +struct tm* gmtime_r(const time_t* restrict, struct tm* restrict); +struct tm* localtime(const time_t*); +struct tm* localtime_r(const time_t* restrict, struct tm* restrict); +time_t mktime(struct tm*); +int nanosleep(const struct timespec*, struct timespec*); +size_t strftime(char* restrict, size_t, const char* restrict, + const struct tm* restrict); +size_t strftime_l(char* restrict, size_t, const char* restrict, + const struct tm* restrict, locale_t); +char* strptime(const char* restrict, const char* restrict, + struct tm* restrict); +time_t time(time_t*); +int timer_create(clockid_t, struct sigevent* restrict, time_t* restrict); +int timer_delete(timer_t); +int timer_getoverrun(timer_t); +int timer_gettime(timer_t, struct itimerspec*); +int timer_settime(timer_t, int, const struct itimerspec* restrict, + struct itimerspec* restrict); +void tzset(void); + +extern int daylight; +extern long timezone; +extern char* tzname[]; __END_DECLS diff --git a/sortix/include/sortix/__/types.h b/sortix/include/sortix/__/types.h index 27510670..1aada414 100644 --- a/sortix/include/sortix/__/types.h +++ b/sortix/include/sortix/__/types.h @@ -54,6 +54,7 @@ typedef long int __ssize_t; #else typedef int __ssize_t; #endif +typedef void* __timer_t; #if defined(SORTIX_KERNEL) || defined(LIBC_LIBRARY) #define OFF_MIN __OFF_MIN diff --git a/sortix/include/sortix/clock.h b/sortix/include/sortix/clock.h index 181b8ba3..9c8b4795 100644 --- a/sortix/include/sortix/clock.h +++ b/sortix/include/sortix/clock.h @@ -33,6 +33,8 @@ __BEGIN_DECLS #define CLOCK_MONOTONIC 1 /* Always increasing time. */ #define CLOCK_BOOT 2 /* Time since system boot (uptime). */ #define CLOCK_INIT 3 /* Time since 'init' process began. */ +#define CLOCK_PROCESS_CPUTIME_ID 4 +#define CLOCK_THREAD_CPUTIME_ID 5 __END_DECLS diff --git a/sortix/include/sortix/x64/bits.h b/sortix/include/sortix/x64/bits.h index c73cd29e..dc6b6735 100644 --- a/sortix/include/sortix/x64/bits.h +++ b/sortix/include/sortix/x64/bits.h @@ -151,5 +151,6 @@ typedef __intmax_t __clock_t; typedef int __clockid_t; typedef long __time_t; typedef long __suseconds_t; +typedef void* __timer_t; #endif diff --git a/sortix/include/sortix/x86/bits.h b/sortix/include/sortix/x86/bits.h index d8c0f49d..6f0692fb 100644 --- a/sortix/include/sortix/x86/bits.h +++ b/sortix/include/sortix/x86/bits.h @@ -151,5 +151,6 @@ typedef __intmax_t __clock_t; typedef int __clockid_t; typedef long __time_t; typedef long __suseconds_t; +typedef void* __timer_t; #endif