1 /* ---------------------------------------------------------------------------- 2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. 3 * Description: TIME64 HEAD FILE 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice,this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice,this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holder nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * --------------------------------------------------------------------------- */ 29 30 #ifndef _HW_TIME64_H_ 31 #define _HW_TIME64_H_ 32 33 #if defined(__LP64__) 34 35 #error Your time_t is already 64-bit. 36 37 #else 38 #include <sys/time.h> 39 #include <time.h> 40 #include <stdint.h> 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 #if defined(__LITEOS__) && !defined(__LP64___) 47 #define __NEED_int64_t 48 #include <bits/alltypes.h> 49 50 struct timeval64 { 51 int64_t tv_sec; 52 int64_t tv_usec; 53 }; 54 55 struct timespec64 { 56 int64_t tv_sec; 57 int64_t tv_nsec; 58 }; 59 60 /** 61 * @ingroup time 62 * @par Description: 63 * This function sets the time as well as a timezone in 32-bit system. 64 * 65 * @attention 66 * <ul> 67 * <li>The function is not supported to set timezone,So the second parameter is unused</li> 68 * </ul> 69 * 70 * @retval #0 The function is executed successfully. 71 * @retval #-1 The function failed to execute, and corresponding error code is set. 72 * 73 * @par Errors 74 * <ul> 75 * <li><b>EINVAL</b>: An invalid Input.</li> 76 * </ul> 77 * 78 * @par Dependency: 79 * <ul><li>time64.h</li></ul> 80 * 81 * @see clock_gettime | time | ctime 82 * 83 */ 84 int settimeofday64(const struct timeval64 *, const struct timezone *); 85 86 /** 87 * @ingroup time 88 * @par Description: 89 * This function gets the time as well as a timezone in 32-bit system. 90 * 91 * @attention 92 * <ul> 93 * <li>The function is not supported to get timezone,So the second parameter is unused</li> 94 * </ul> 95 * 96 * @retval #0 The function is executed successfully. 97 * @retval #-1 The function failed to execute, and corresponding error code is set. 98 * 99 * @par Errors 100 * <ul> 101 * <li><b>EINVAL</b>: An invalid Input.</li> 102 * </ul> 103 * 104 * @par Dependency: 105 * <ul><li>time64.h</li></ul> 106 * 107 * @see clock_gettime | time | ctime 108 * 109 */ 110 111 int gettimeofday64(struct timeval64 *, struct timezone *); 112 #endif 113 114 typedef int64_t time64_t; 115 116 char *asctime64(const struct tm *); 117 char *asctime64_r(const struct tm *, char *); 118 char *ctime64(const time64_t *); 119 char *ctime64_r(const time64_t *, char *); 120 struct tm *gmtime64(const time64_t *); 121 struct tm *gmtime64_r(const time64_t *, struct tm *); 122 struct tm *localtime64(const time64_t *); 123 struct tm *localtime64_r(const time64_t *, struct tm *); 124 time64_t mktime64(struct tm *); 125 time64_t timegm64(const struct tm *); 126 time64_t timelocal64(const struct tm *); 127 128 #ifdef __cplusplus 129 } 130 #endif 131 #endif 132 #endif 133