From: Martin Baute Date: Sun, 27 Mar 2016 11:48:56 +0000 (+0200) Subject: time.h stubs. X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=18dee35aba1ae0fcdecb0cd11d4f3c1a0d94b51e time.h stubs. --- diff --git a/functions/time/asctime.c b/functions/time/asctime.c new file mode 100644 index 0000000..d966574 --- /dev/null +++ b/functions/time/asctime.c @@ -0,0 +1,27 @@ +/* asctime( const struct tm * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +char * asctime( const struct tm * timeptr ) +{ + return NULL; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/clock.c b/functions/time/clock.c new file mode 100644 index 0000000..e4cca24 --- /dev/null +++ b/functions/time/clock.c @@ -0,0 +1,27 @@ +/* clock( void ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +clock_t clock( void ) +{ + return -1; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/ctime.c b/functions/time/ctime.c new file mode 100644 index 0000000..e9c37c9 --- /dev/null +++ b/functions/time/ctime.c @@ -0,0 +1,27 @@ +/* ctime( const time_t * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +char * ctime( const time_t * timer ) +{ + return NULL; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/difftime.c b/functions/time/difftime.c new file mode 100644 index 0000000..858ff39 --- /dev/null +++ b/functions/time/difftime.c @@ -0,0 +1,27 @@ +/* difftime( time_t, time_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +double difftime( time_t time1, time_t time0 ) +{ + return 0.0; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/gmtime.c b/functions/time/gmtime.c new file mode 100644 index 0000000..7c4c6e3 --- /dev/null +++ b/functions/time/gmtime.c @@ -0,0 +1,27 @@ +/* gmtime( const time_t * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +struct tm * gmtime( const time_t * timer ) +{ + return NULL; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/localtime.c b/functions/time/localtime.c new file mode 100644 index 0000000..6fda174 --- /dev/null +++ b/functions/time/localtime.c @@ -0,0 +1,27 @@ +/* localtime( const time_t * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +struct tm * localtime( const time_t * timer ) +{ + return NULL; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/mktime.c b/functions/time/mktime.c new file mode 100644 index 0000000..fc3759e --- /dev/null +++ b/functions/time/mktime.c @@ -0,0 +1,27 @@ +/* mktime( struct tm * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +time_t mktime( struct tm * timeptr ) +{ + return -1; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/strftime.c b/functions/time/strftime.c new file mode 100644 index 0000000..2402f8c --- /dev/null +++ b/functions/time/strftime.c @@ -0,0 +1,27 @@ +/* strftime( char * restrict, size_t, const char * restrict, const struct tm * restrict ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +size_t strftime( char * restrict s, size_t maxsize, const char * restrict format, const struct tm * restrict timeptr ) +{ + return 0; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/time.c b/functions/time/time.c new file mode 100644 index 0000000..ec67f50 --- /dev/null +++ b/functions/time/time.c @@ -0,0 +1,27 @@ +/* time( time_t * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +time_t time( time_t * timer ) +{ + return -1; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/functions/time/timespec.c b/functions/time/timespec.c new file mode 100644 index 0000000..2781e6c --- /dev/null +++ b/functions/time/timespec.c @@ -0,0 +1,27 @@ +/* timespec_get( struct timespec *, int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int timespec_get( struct timespec * ts, int base ) +{ + return 0; +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + return NO_TESTDRIVER; +} + +#endif diff --git a/includes/time.h b/includes/time.h new file mode 100644 index 0000000..216150f --- /dev/null +++ b/includes/time.h @@ -0,0 +1,103 @@ +/* Date and time + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#ifndef _PDCLIB_TIME_H +#define _PDCLIB_TIME_H _PDCLIB_TIMEH + +#include "_PDCLIB_int.h" + +#ifndef _PDCLIB_SIZE_T_DEFINED +#define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED +typedef _PDCLIB_size_t size_t; +#endif + +#ifndef _PDCLIB_NULL_DEFINED +#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED +#define NULL _PDCLIB_NULL +#endif + +typedef _PDCLIB_time_t time_t; +typedef _PDCLIB_clock_t clock_t; + +#define CLOCKS_PER_SEC _PDCLIB_CLOCKS_PER_SEC +#define TIME_UTC _PDCLIB_TIME_UTC + +struct timespec +{ + time_t tv_sec; + long tv_nsec; +}; + +struct tm +{ + int tm_sec; /* 0-60 */ + int tm_min; /* 0-59 */ + int tm_hour; /* 0-23 */ + int tm_mday; /* 1-31 */ + int tm_mon; /* 0-11 */ + int tm_year; /* years since 1900 */ + int tm_wday; /* 0-6 */ + int tm_yday; /* 0-365 */ + int tm_isdst; /* >0 DST, 0 no DST, <0 information unavailable */ +}; + +/* Returns the number of "clocks" in processor time since the invocation + of the program. Divide by CLOCKS_PER_SEC to get the value in seconds. + Returns -1 if the value cannot be represented in the return type or is + not available. +*/ +clock_t clock( void ) _PDCLIB_nothrow; + +/* Returns the difference between two calendar times in seconds. */ +double difftime( time_t time1, time_t time0 ) _PDCLIB_nothrow; + +/* Normalizes the values in the broken-down time pointed to by timeptr. + Returns the calender time specified by the broken-down time. +*/ +time_t mktime( struct tm * timeptr ) _PDCLIB_nothrow; + +/* Returns the current calender time. If timer is not a NULL pointer, stores + the current calender time at that address as well. +*/ +time_t time( time_t * timer ) _PDCLIB_nothrow; + +/* Sets the interval pointed to by ts to the current calender time, based + on the specified base. + Returns base, if successful, otherwise zero. +*/ +int timespec_get( struct timespec * ts, int base ) _PDCLIB_nothrow; + +/* Converts the broken-down time pointed to by timeptr into a string in the + form "Sun Sep 16 01:03:52 1973\n\0". +*/ +char * asctime( const struct tm * timeptr ) _PDCLIB_nothrow; + +/* Equivalent to asctime( localtime( timer ) ). */ +char * ctime( const time_t * timer ) _PDCLIB_nothrow; + +/* Converts the calender time pointed to by timer into a broken-down time + expressed as UTC. + Returns a pointer to the broken-down time, or a NULL pointer if it + cannot be represented. +*/ +struct tm * gmtime( const time_t * timer ) _PDCLIB_nothrow; + +/* Converts the calender time pointed to by timer into a broken-down time + expressed as local time. + Returns a pointer to the broken-down time, or a NULL pointer if if + cannot be represented. +*/ +struct tm * localtime( const time_t * timer ) _PDCLIB_nothrow; + +/* Writes the broken-down time pointed to by timeptr into the character + array pointed to by s. The string pointed to by format controls the + exact output. No more than maxsize charactrs will be written. + Returns the number of characters written (excluding the terminating + null character), or zero on failure. +*/ +size_t strftime( char * _PDCLIB_restrict s, size_t maxsize, const char * _PDCLIB_restrict format, const struct tm * _PDCLIB_restrict timeptr ); + +#endif