1 /* 2 * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this list of 8 * conditions and the following disclaimer. 9 * 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 * of conditions and the following disclaimer in the documentation and/or other materials 12 * provided with the distribution. 13 * 14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef _ADAPT_TIME_H 32 #define _ADAPT_TIME_H 33 34 #if !defined(_DLIB_TIME_USES_64) || !defined(_DLIB_TIME_USES_LONG) || (_DLIB_TIME_USES_64 == 0) || (_DLIB_TIME_USES_LONG == 0) 35 #error "_DLIB_TIME_USES_64=1 and _DLIB_TIME_USES_LONG=1 should be defined in IAR project(C/C++ Compiler->Preprocessor->Defined symbols)." 36 #endif 37 38 #ifndef tm_isdst 39 #define tm_isdst tm_isdst; \ 40 long __tm_gmtoff; \ 41 const char *__tm_zone 42 43 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 44 #define __tm_gmtoff tm_gmtoff 45 #define __tm_zone tm_zone 46 #endif 47 48 #include_next <time.h> 49 #undef tm_isdst 50 51 #else /* tm_isdst */ 52 53 #include_next <time.h> 54 55 #endif /* tm_isdst */ 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 61 #define __NEED_timer_t 62 #define __NEED_clockid_t 63 64 #include <bits/alltypes.h> 65 66 struct itimerspec { 67 struct timespec it_interval; 68 struct timespec it_value; 69 }; 70 71 #define CLOCK_REALTIME 0 72 #define CLOCK_MONOTONIC 1 73 #define CLOCK_PROCESS_CPUTIME_ID 2 74 #define CLOCK_THREAD_CPUTIME_ID 3 75 #define CLOCK_MONOTONIC_RAW 4 76 #define CLOCK_REALTIME_COARSE 5 77 #define CLOCK_MONOTONIC_COARSE 6 78 #define CLOCK_BOOTTIME 7 79 #define CLOCK_REALTIME_ALARM 8 80 #define CLOCK_BOOTTIME_ALARM 9 81 #define CLOCK_SGI_CYCLE 10 82 #define CLOCK_TAI 11 83 84 #define TIMER_ABSTIME 1 85 86 struct tm *gmtime_r(const time_t *__restrict, struct tm *__restrict); 87 struct tm *localtime_r(const time_t *__restrict, struct tm *__restrict); 88 89 int nanosleep(const struct timespec *, struct timespec *); 90 int clock_getres(clockid_t, struct timespec *); 91 int clock_gettime(clockid_t, struct timespec *); 92 int clock_settime(clockid_t, const struct timespec *); 93 int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); 94 95 struct sigevent; 96 int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); 97 int timer_delete(timer_t); 98 int timer_settime(timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); 99 int timer_gettime(timer_t, struct itimerspec *); 100 int timer_getoverrun(timer_t); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* _ADAPT_TIME_H */ 107