• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @defgroup time Time
3  * @ingroup libc
4  */
5 
6 #ifndef	_TIME_H
7 #define _TIME_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #ifdef __LITEOS__
14 #include "sys/time.h"
15 #endif
16 
17 #include <features.h>
18 
19 #ifdef __cplusplus
20 #define NULL 0L
21 #else
22 #ifndef NULL
23 #define NULL ((void*)0)
24 #endif
25 #endif
26 
27 
28 #define __NEED_size_t
29 #define __NEED_time_t
30 #define __NEED_clock_t
31 #define __NEED_struct_timespec
32 #ifdef __LITEOS__
33 #define __NEED_suseconds_t
34 #define __NEED_struct_timeval
35 #endif
36 
37 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
38  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
39  || defined(_BSD_SOURCE)
40 #define __NEED_clockid_t
41 #define __NEED_timer_t
42 #define __NEED_pid_t
43 #define __NEED_locale_t
44 #endif
45 
46 #include <bits/alltypes.h>
47 
48 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
49 #define __tm_gmtoff tm_gmtoff
50 #define __tm_zone tm_zone
51 #endif
52 
53 struct tm {
54 	int tm_sec;
55 	int tm_min;
56 	int tm_hour;
57 	int tm_mday;
58 	int tm_mon;
59 	int tm_year;
60 	int tm_wday;
61 	int tm_yday;
62 	int tm_isdst;
63 	long __tm_gmtoff;
64 	const char *__tm_zone;
65 };
66 
67 /**
68  * @ingroup  time
69  * @par Description:
70  * This function gets the current time as an integer number of microseconds.
71  *
72  * @attention
73  * <ul>
74  * <li>None.</li>
75  * </ul>
76  *
77  * @retval
78  * #clock_t This function returns the current time as an integer number of microseconds.
79  *
80  * @par Dependency:
81  * <ul><li>time.h</li></ul>
82  *
83  * @see  asctime | clock_getres | ctime | difftime | gmtime | localtime | mktime | strftime |
84  * strptime | time | times | utime
85  *
86  */
87 clock_t clock (void);
88 
89 /**
90  * @ingroup  time
91  * @par Description:
92  * This function gets the value of time in seconds since the Epoch(1970-01-01 00:00:00 UTC).
93  *
94  * @attention
95  * <ul>
96  * <li>None.</li>
97  * </ul>
98  *
99  * @retval
100  * #time_t On success, this function shall return the value of time in seconds since the Epoch.
101  * the argument points to an area where the return value is also stored. If the argument is a null pointer,
102  * no value is stored.On failure, this function shall return (time_t)-1.
103  *
104  * @par Dependency:
105  * <ul><li>time.h</li></ul>
106  *
107  * @see  asctime | clock | clock_getres | ctime | difftime | gettimeofday | gmtime | localtime | mktime | strftime | strptime | times | utime
108  *
109  */
110 time_t time (time_t *);
111 
112 /**
113  * @ingroup  time
114  * @par Description:
115  * This function shall compute the difference between two calendar times (as returned by time()).
116  *
117  * @attention
118  * <ul>
119  * <li>None.</li>
120  * </ul>
121  *
122  * @retval
123  * #double This function return the difference expressed in seconds as a type double.
124  *
125  * @par Dependency:
126  * <ul><li>time.h</li></ul>
127  *
128  * @see  clock | ctime | asctime | gmtime | localtime | mktime | strftime | strptime | times | utime
129  *
130  */
131 double difftime (time_t, time_t);
132 
133 /**
134  * @ingroup  time
135  * @par Description:
136  * This function shall convert the broken-down time, expressed as local time, in the structure pointed
137  * to by the argument,into a time since the Epoch value with the same encoding as that of the values
138  * returned by time(). The original values of the tm_wday and tm_yday components of the structure shall
139  * be ignored, and the original values of the other components shall not be restricted to the ranges
140  * described in <time.h>.
141  *
142  * @attention
143  * <ul>
144  * <li>None.</li>
145  * </ul>
146  *
147  * @retval
148  * #time_t On success, shall return the specified time since the Epoch encoded as a value of type time_t.
149  * On failure, If the time since the Epoch cannot be represented, the function shall return the value (time_t)-1.
150  *
151  * @par Errors
152  * <ul>
153  * <li><b>EINVAL</b>: An invalid input.</li>
154  * </ul>
155  *
156  * @par Dependency:
157  * <ul><li>time.h</li></ul>
158  *
159  * @see  asctime | clock | ctime | difftime | gmtime | localtime | strftime | strptime | time | tzset | utime
160  *
161  */
162 time_t mktime (struct tm *);
163 
164 /**
165  * @ingroup  time
166  * @par Description:
167  * This function formats the broken-down time tm according to the format specification format and places the result in the character
168  * array s of size the second.
169  *
170  * @attention
171  * <ul>
172  * <li>None.</li>
173  * </ul>
174  *
175  * @retval
176  * #size_t Provided  that  the  result  string, including the terminating null byte, does not exceed max bytes,
177  * it returns the number of bytes (excluding the terminating null byte) placed in the array s.
178  * If the length of the result string  (including  the  terminating  null  byte) would exceed max bytes,
179  * then it returns 0, and the contents of the array are undefined.
180  *
181  * @par Dependency:
182  * <ul><li>time.h</li></ul>
183  *
184  * @see  asctime | clock | clock_getres | ctime | difftime | gettimeofday | gmtime | localtime | mktime | strptime | times | utime | tzset
185  *
186  */
187 size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
188 
189 /**
190  * @ingroup  time
191  * @par Description:
192  * This function convert the time in seconds since the Epoch pointed to by the argument into
193  * a broken-down time, expressed as Coordinated Universal Time (UTC).
194  *
195  * @attention
196  * <ul>
197  * <li>None.</li>
198  * </ul>
199  *
200  * @retval
201  * "struct tm*" On success, this function returns a pointer to a struct tm.
202  * On failure, it shall return a null pointer.
203  *
204  * @par Dependency:
205  * <ul><li>time.h</li></ul>
206  *
207  * @see  asctime | clock | ctime | difftime | localtime | mktime | strftime | strptime | time | utime
208  *
209  */
210 struct tm *gmtime (const time_t *);
211 
212 /**
213  * @ingroup  time
214  * @par Description:
215  * This function shall convert the time in seconds since the Epoch pointed to by the argument
216  * into a broken-down time, expressed as a local time.
217  *
218  * @attention
219  * <ul>
220  * <li>Failure compared with standard, the error code is not seted.</li>
221  * </ul>
222  *
223  * @retval
224  * "struct tm*" On success, the function shall return a pointer to the broken-down time structure.
225  * On failure, this shall return a null pointer.
226  *
227  * @par Dependency:
228  * <ul><li>time.h</li></ul>
229  *
230  * @see  asctime | clock | ctime | difftime | gmtime | mktime | strftime | strptime | time | tzset | utime
231  *
232  */
233 struct tm *localtime (const time_t *);
234 
235 /**
236  * @ingroup  time
237  * @par Description:
238  * This function shall convert the broken-down time in the structure pointed to by the argument into a string in the form:\n
239  * Sun Sep 16 01:03:52 1973\n\0.
240  *
241  * @attention
242  * <ul>
243  * <li>None.</li>
244  * </ul>
245  *
246  * @retval
247  * #char* On success, this function shall return a pointer to the string. On failure, it shall return NULL.
248  *
249  * @par Dependency:
250  * <ul><li>time.h</li></ul>
251  *
252  * @see  clock | ctime | difftime | gmtime | localtime | mktime | strftime | strptime | times | utime
253  *
254  */
255 char *asctime (const struct tm *);
256 
257 /**
258  * @ingroup  time
259  * @par Description:
260  * This function shall convert the time pointed to by the first argument, representing time in seconds since the Epoch,
261  * to local time in the form of a string.
262  *
263  * @attention
264  * <ul>
265  * <li>None.</li>
266  * </ul>
267  *
268  * @retval
269  * #char* The function returns the pointer returned by asctime() with that broken-down time as an argument.
270  *
271  * @par Dependency:
272  * <ul><li>time.h</li></ul>
273  *
274  * @see  asctime | clock | difftime | gmtime | localtime | mktime | strftime | strptime | time | utime
275  *
276  */
277 char *ctime (const time_t *);
278 int timespec_get(struct timespec *, int);
279 
280 /**
281  * @ingroup localtime
282  * @brief Set Time Zone.
283  *
284  * @par Description:
285  * This API is used to set the time zone.
286  *
287  * @attention
288  * <ul>
289  * <li>When setting time zones, format is required to be "tzn[+/-]hh[:mm[:ss]][dzn]" .</li>
290  * </ul>
291  *
292  * @param buff The string point to the time zone going to be setting.
293  *
294  * @retval   None
295  */
296 void settimezone(const char *);
297 
298 /**
299  * @ingroup localtime
300  * @brief Disable daylight saving time.
301  *
302  * @par Description:
303  * This API is used to make daylight saving time useless.
304  *
305  * @param None.
306  *
307  * @retval   None
308  */
309 int dst_disable(VOID);
310 
311 /**
312  * @ingroup localtime
313  * @brief Enable daylight saving time..
314  *
315  * @par Description:
316  * This API is used to configure daylight saving time.
317  *
318  * @attention
319  * <ul>
320  * <li>When config dst, The configuration format has strict requirements.</li>
321  * <li>The first configuration format for example "Feb-03 03:00:00"</li>
322  * <li>The second configuration format for example "Oct-1st-Fri 03:00:00"</li>
323  * <li>The abbreviations for the months are "Jan",  "Feb", "Mar",  "Apr", "May", "Jun", "Jul", "Aug",
324  * "Sep", "Oct", "Nov", and "Dec".</li>
325  * <li>The abbreviations for the days of the week are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat".</li>
326  * <li>The abbreviations for the weeks of the month are "1st", "2nd", "3rd", "4th", "5th"</li>
327  * <li>When it's only four weekdays this month, the effect of "5th" is the same as "Last"</li>
328  * </ul>
329  *
330  * @param dstStartTime   The string point to the DST start going to be setting.
331  * @param dstEndTime     The string point to the DST end going to be setting.
332  * @param forwardSeconds Indicates the number of seconds that time is allocated when entering DST interval.
333  *
334  * @retval   0 Succeed.
335  * @retval  -1 Failed.
336  */
337 int dst_enable(const char *dstStartTime, const char *dstEndTime, int forwardSeconds);
338 
339 /**
340  * @ingroup localtime
341  * @brief Inquire daylight saving time.
342  *
343  * @par Description:
344  * This API is used to inquire daylight saving time.
345  *
346  * @param year      Represents the year to query start from 1900.
347  * @param dstStart  Used to store daylight savings time start time
348  * @param dstEnd    Used to store daylight savings time end time
349  *
350  * @retval   0 Succeed.
351  * @retval  -1 Failed.
352  */
353 int dst_inquire(int year, struct tm *dstStart, struct tm *dstEnd);
354 
355 
356 #define CLOCKS_PER_SEC 1000000L
357 
358 #define TIME_UTC 1
359 
360 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
361  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
362  || defined(_BSD_SOURCE)
363 
364 size_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const struct tm *  __restrict, locale_t);
365 
366 /**
367  * @ingroup  time
368  * @par Description:
369  * This function convert the time in seconds since the Epoch pointed to by the first argument into
370  * a broken-down time expressed as Coordinated Universal Time (UTC). The broken-down time is stored
371  * in the structure referred to by the second argument.
372  *
373  * @attention
374  * <ul>
375  * <li>None.</li>
376  * </ul>
377  *
378  * @retval
379  * "struct tm*" On success, this function returns the address of the structure pointed to by the second argument.
380  * On failure, it shall return a null pointer.
381  *
382  * @par Dependency:
383  * <ul><li>time.h</li></ul>
384  *
385  * @see  asctime | clock | ctime | difftime | localtime | mktime | strftime | strptime | time | utime
386  *
387  */
388 struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
389 
390 /**
391  * @ingroup  time
392  * @par Description:
393  * This function shall convert the time in seconds since the Epoch pointed to by timer into
394  * a broken-down time stored in the structure to which the second argument points.
395  *
396  * @attention
397  * <ul>
398  * <li>Failure compared with standard, the error code is not seted. </li>
399  * </ul>
400  *
401  * @retval
402  * "struct tm*" On success, the function shall return a pointer to the structure pointed to by the second argument.
403  * On failure, this shall return a null pointer.
404  *
405  * @par Dependency:
406  * <ul><li>time.h</li></ul>
407  *
408  * @see  asctime | clock | ctime | difftime | gmtime | mktime | strftime | strptime | time | tzset | utime
409  *
410  */
411 struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
412 
413 /**
414  * @ingroup  time
415  * @par Description:
416  * This function shall convert the broken-down time in the structure pointed to by first argument into a string.
417  *
418  * @attention
419  * <ul>
420  * <li>None.</li>
421  * </ul>
422  *
423  * @retval
424  * #char* On success, this function shall return a pointer to a character string containing the date and time.
425  * This string is pointed to by the second argument. On failure, it shall return NULL.
426  *
427  * @par Dependency:
428  * <ul><li>time.h</li></ul>
429  *
430  * @see  clock | ctime | difftime | gmtime | localtime | mktime | strftime | strptime | times | utime
431  *
432  */
433 char *asctime_r (const struct tm *__restrict, char *__restrict);
434 
435 /**
436  * @ingroup  time
437  * @par Description:
438  * This function shall convert the calendar time pointed to by the first argument to local time in
439  * exactly the same form as ctime() and put the string into the array pointed to by the second argument
440  * (which shall be at least 26 bytes in size).
441  *
442  * @attention
443  * <ul>
444  * <li>None.</li>
445  * </ul>
446  *
447  * @retval
448  * #char* On success, the function returns a pointer to the string pointed to by second argument.
449  * On failure, a null pointer shall be returned.
450  *
451  * @par Dependency:
452  * <ul><li>time.h</li></ul>
453  *
454  * @see  asctime | clock | difftime | gmtime | localtime | mktime | strftime | strptime | time | utime
455  *
456  */
457 char *ctime_r (const time_t *, char *);
458 
459 /**
460  * @ingroup  time
461  * @par Description:
462  * This function uses the value of the environment variable TZ to set time conversion information used
463  * by ctime, localtime, mktime, and strftime. If TZ is absent from the environment, implementation-defined default
464  * timezone information shall be used..
465  *
466  * @attention
467  * <ul>
468  * <li>None.</li>
469  * </ul>
470  *
471  * @retval
472  * None
473  *
474  * @par Dependency:
475  * <ul><li>time.h</li></ul>
476  *
477  * @see  ctime | localtime | mktime | strftime
478  *
479  */
480 void tzset (void);
481 
482 struct itimerspec {
483 	struct timespec it_interval;
484 	struct timespec it_value;
485 };
486 
487 #ifdef __LITEOS__
488 #define MAX_CLOCKS              16
489 #endif
490 #define CLOCK_REALTIME           0
491 #define CLOCK_MONOTONIC          1
492 #define CLOCK_PROCESS_CPUTIME_ID 2
493 #define CLOCK_THREAD_CPUTIME_ID  3
494 #define CLOCK_MONOTONIC_RAW      4
495 #define CLOCK_REALTIME_COARSE    5
496 #define CLOCK_MONOTONIC_COARSE   6
497 #define CLOCK_BOOTTIME           7
498 #define CLOCK_REALTIME_ALARM     8
499 #define CLOCK_BOOTTIME_ALARM     9
500 #define CLOCK_SGI_CYCLE         10
501 #define CLOCK_TAI               11
502 
503 #define TIMER_ABSTIME 1
504 
505 /**
506  * @ingroup  time
507  * @par Description:
508  * This function shall cause the current thread to be suspended from execution
509  * until either the time interval specified by the first argument has elapsed.
510  *
511  * @attention
512  * <ul>
513  * <li>The second argument is unused.</li>
514  * <li>Tasks will not be awakened, if the requested time does not has elapsed </li>
515  * </ul>
516  *
517  * @retval #0  The function is executed successfully.
518  * @retval #-1 The function failed to execute, and corresponding error code is set.
519  *
520  * @par Errors
521  * <ul>
522  * <li><b>EINVAL</b>: An invalid input.</li>
523  * </ul>
524  *
525  * @par Dependency:
526  * <ul><li>time.h</li></ul>
527  *
528  * @see  sleep
529  *
530  */
531 int nanosleep (const struct timespec *, struct timespec *);
532 
533 /**
534  * @ingroup  time
535  * @par Description:
536  * This function finds  the  resolution  (precision) of the specified clock, and, if the second argument is non-NULL, stores it in the
537  * struct timespec pointed to by the second argument.
538  *
539  * @attention
540  * <ul>
541  * <li>The first argument of value only supports CLOCK_REALTIME.</li>
542  * </ul>
543  *
544  * @retval #0  The function is executed successfully.
545  * @retval #-1 The function failed to execute, and corresponding error code is set.
546  *
547  * @par Errors
548  * <ul>
549  * <li><b>EINVAL</b>: An invalid input.</li>
550  * </ul>
551  *
552  * @par Dependency:
553  * <ul><li>time.h</li></ul>
554  *
555  * @see  gettimeofday | settimeofday | time | adjtime | ctime
556  *
557  */
558 int clock_getres (clockid_t, struct timespec *);
559 
560 /**
561  * @ingroup  time
562  * @par Description:
563  * This function retrieves the time of the specified clock.
564  *
565  * @attention
566  * <ul>
567  * <li>The first argument of value only supports CLOCK_REALTIME.</li>
568  * </ul>
569  *
570  * @retval #0  The function is executed successfully.
571  * @retval #-1 The function failed to execute, and corresponding error code is set.
572  *
573  * @par Errors
574  * <ul>
575  * <li><b>EINVAL</b>: An invalid input.</li>
576  * </ul>
577  *
578  * @par Dependency:
579  * <ul><li>time.h</li></ul>
580  *
581  * @see  gettimeofday | settimeofday | time | adjtime | ctime
582  *
583  */
584 int clock_gettime (clockid_t, struct timespec *);
585 
586 /**
587  * @ingroup  time
588  * @par Description:
589  * This function sets the time of the specified clock clk_id.
590  *
591  * @attention
592  * <ul>
593  * <li>The first argument of value only supports CLOCK_REALTIME.</li>
594  * </ul>
595  *
596  * @retval #0  The function is executed successfully.
597  * @retval #-1 The function failed to execute, and corresponding error code is set.
598  *
599  * @par Errors
600  * <ul>
601  * <li><b>EINVAL</b>: An invalid input.</li>
602  * </ul>
603  *
604  * @par Dependency:
605  * <ul><li>time.h</li></ul>
606  *
607  * @see  gettimeofday | settimeofday | time | adjtime | ctime
608  *
609  */
610 int clock_settime (clockid_t, const struct timespec *);
611 int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
612 int clock_getcpuclockid (pid_t, clockid_t *);
613 
614 struct sigevent;
615 
616 
617 /**
618  * @ingroup  time
619  * @par Description:
620  * This function creates a per-process timer using the specified clock, as the timing base.
621  * The function shall return, in the location referenced by the third argument, a timer ID
622  * of type timer_t used to identify the timer in timer requests.
623  *
624  * @attention
625  * <ul>
626  * <li>None.</li>
627  * </ul>
628  *
629  * @retval #0  The function is executed successfully.
630  * @retval #-1 The function failed to execute, and corresponding error code is set.
631  *
632  * @par Errors
633  * <ul>
634  * <li><b>EINVAL</b>: An invalid input.</li>
635  * <li><b>EAGAIN</b>: Duplicate creation.</li>
636  * </ul>
637  *
638  * @par Dependency:
639  * <ul><li>time.h</li></ul>
640  *
641  * @see  clock_getres | timer_delete | timer_getoverrun
642  *
643  */
644 int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
645 
646 /**
647  * @ingroup  time
648  * @par Description:
649  * This function deletes the specified timer,previously created by the timer_create() function.
650  *
651  * @attention
652  * <ul>
653  * <li>None.</li>
654  * </ul>
655  *
656  * @retval #0  The function is executed successfully.
657  * @retval #-1 The function failed to execute, and corresponding error code is set.
658  *
659  * @par Errors
660  * <ul>
661  * <li><b>EINVAL</b>: An invalid input.</li>
662  * </ul>
663  *
664  * @par Dependency:
665  * <ul><li>time.h</li></ul>
666  *
667  * @see  timer_create
668  *
669  */
670 int timer_delete (timer_t);
671 
672 /**
673  * @ingroup  time
674  * @par Description:
675  * This function set the time until the next expiration of the timer specified by timerid from
676  * the it_value member of the third argument and arm the timer if the it_value member of value is non-zero.
677  *
678  * @attention
679  * <ul>
680  * <li>the second parameter is unused</li>
681  * </ul>
682  *
683  * @retval #0  The function is executed successfully.
684  * @retval #-1 The function failed to execute, and corresponding error code is set.
685  *
686  * @par Errors
687  * <ul>
688  * <li><b>EINVAL</b>: An invalid input.</li>
689  * </ul>
690  *
691  * @par Dependency:
692  * <ul><li>time.h</li></ul>
693  *
694  * @see  clock_getres | timer_create
695  *
696  */
697 int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
698 
699 /**
700  * @ingroup  time
701  * @par Description:
702  * This function shall store the amount of time until the specified timer,
703  * expires and the reload value of the timer into the space pointed to by the second argument.
704  *
705  * @attention
706  * <ul>
707  * <li>None.</li>
708  * </ul>
709  *
710  * @retval #0  The function is executed successfully.
711  * @retval #-1 The function failed to execute, and corresponding error code is set.
712  *
713  * @par Errors
714  * <ul>
715  * <li><b>EINVAL</b>: An invalid input.</li>
716  * </ul>
717  *
718  * @par Dependency:
719  * <ul><li>time.h</li></ul>
720  *
721  * @see  clock_getres | timer_create
722  *
723  */
724 int timer_gettime (timer_t, struct itimerspec *);
725 
726 /**
727  * @ingroup  time
728  * @par Description:
729  * This function shall get the timer expiration overrun count for the specified timer.
730  *
731  * @attention
732  * <ul>
733  * <li>None.</li>
734  * </ul>
735  *
736  * @retval
737  * #int On success, this function returns the timer expiration overrun count as explained above.
738  * On failure, -1 is returned.
739  *
740  * @par Errors
741  * <ul>
742  * <li><b>EINVAL</b>: An invalid input.</li>
743  * </ul>
744  *
745  * @par Dependency:
746  * <ul><li>time.h</li></ul>
747  *
748  * @see  clock_getres | timer_create
749  *
750  */
751 int timer_getoverrun (timer_t);
752 
753 extern char *tzname[2];
754 
755 #endif
756 
757 
758 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
759 
760 /**
761  * @ingroup  time
762  * @par Description:
763  * This function converts the character string pointed to by the first argument to values which are stored in
764  * the tm structure pointed to by the third argument, using the format specified by the second argument.
765  *
766  * @attention
767  * <ul>
768  * <li>None.</li>
769  * </ul>
770  *
771  * @retval
772  * #char* On success, this function returns a pointer to the character following the last character parsed.
773  * On failure, a null pointer shall be returned.
774  *
775  * @par Dependency:
776  * <ul><li>time.h</li></ul>
777  *
778  * @see  fprintf | fscanf | strftime | time
779  *
780  */
781 char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
782 extern int daylight;
783 extern long timezone;
784 extern int getdate_err;
785 struct tm *getdate (const char *);
786 #endif
787 
788 
789 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
790 
791 /**
792  * @ingroup  time
793  * @par Description:
794  * This function  sets  the  system's  idea  of  the  time  and date.  The time, pointed to by t, is measured in seconds since the Epoch.
795  *
796  * @attention
797  * <ul>
798  * <li>There are no restrictions on the use of superusers.</li>
799  * </ul>
800  *
801  * @retval #0  The function is executed successfully.
802  * @retval #-1 The function failed to execute, and corresponding error code is set.
803  *
804  * @par Errors
805  * <ul>
806  * <li><b>EINVAL</b>: An invalid input.</li>
807  * </ul>
808  *
809  * @par Dependency:
810  * <ul><li>time.h</li></ul>
811  *
812  * @see  settimeofday
813  *
814  */
815 int stime(const time_t *);
816 time_t timegm(struct tm *);
817 #endif
818 
819 #ifndef __LITEOS__
820 #if _REDIR_TIME64
821 __REDIR(time, __time64);
822 __REDIR(difftime, __difftime64);
823 __REDIR(mktime, __mktime64);
824 __REDIR(gmtime, __gmtime64);
825 __REDIR(localtime, __localtime64);
826 __REDIR(ctime, __ctime64);
827 __REDIR(timespec_get, __timespec_get_time64);
828 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
829  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
830  || defined(_BSD_SOURCE)
831 __REDIR(gmtime_r, __gmtime64_r);
832 __REDIR(localtime_r, __localtime64_r);
833 __REDIR(ctime_r, __ctime64_r);
834 __REDIR(nanosleep, __nanosleep_time64);
835 __REDIR(clock_getres, __clock_getres_time64);
836 __REDIR(clock_gettime, __clock_gettime64);
837 __REDIR(clock_settime, __clock_settime64);
838 __REDIR(clock_nanosleep, __clock_nanosleep_time64);
839 __REDIR(timer_settime, __timer_settime64);
840 __REDIR(timer_gettime, __timer_gettime64);
841 #endif
842 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
843 __REDIR(stime, __stime64);
844 __REDIR(timegm, __timegm_time64);
845 #endif
846 #endif
847 #endif
848 
849 #ifdef __cplusplus
850 }
851 #endif
852 
853 
854 #endif
855