1 #ifndef _system_time_h 2 #define _system_time_h 3 /* 4 Unix SMB/CIFS implementation. 5 6 time system include wrappers 7 8 Copyright (C) Andrew Tridgell 2004 9 10 ** NOTE! The following LGPL license applies to the replace 11 ** library. This does NOT imply that all of Samba is released 12 ** under the LGPL 13 14 This library is free software; you can redistribute it and/or 15 modify it under the terms of the GNU Lesser General Public 16 License as published by the Free Software Foundation; either 17 version 3 of the License, or (at your option) any later version. 18 19 This library is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 Lesser General Public License for more details. 23 24 You should have received a copy of the GNU Lesser General Public 25 License along with this library; if not, see <http://www.gnu.org/licenses/>. 26 27 */ 28 29 #ifdef TIME_WITH_SYS_TIME 30 #include <sys/time.h> 31 #include <time.h> 32 #else 33 #ifdef HAVE_SYS_TIME_H 34 #include <sys/time.h> 35 #else 36 #include <time.h> 37 #endif 38 #endif 39 40 #ifdef HAVE_UTIME_H 41 #include <utime.h> 42 #else 43 struct utimbuf { 44 time_t actime; /* access time */ 45 time_t modtime; /* modification time */ 46 }; 47 #endif 48 49 #ifndef HAVE_STRUCT_TIMESPEC 50 struct timespec { 51 time_t tv_sec; /* Seconds. */ 52 long tv_nsec; /* Nanoseconds. */ 53 }; 54 #endif 55 56 #ifndef HAVE_MKTIME 57 /* define is in "replace.h" */ 58 time_t rep_mktime(struct tm *t); 59 #endif 60 61 #ifndef HAVE_TIMEGM 62 /* define is in "replace.h" */ 63 time_t rep_timegm(struct tm *tm); 64 #endif 65 66 #ifndef HAVE_UTIME 67 /* define is in "replace.h" */ 68 int rep_utime(const char *filename, const struct utimbuf *buf); 69 #endif 70 71 #ifndef HAVE_UTIMES 72 /* define is in "replace.h" */ 73 int rep_utimes(const char *filename, const struct timeval tv[2]); 74 #endif 75 76 #ifndef HAVE_CLOCK_GETTIME 77 /* CLOCK_REALTIME is required by POSIX */ 78 #define CLOCK_REALTIME 0 79 typedef int clockid_t; 80 int rep_clock_gettime(clockid_t clk_id, struct timespec *tp); 81 #endif 82 /* make sure we have a best effort CUSTOM_CLOCK_MONOTONIC we can rely on. 83 * 84 * on AIX the values of CLOCK_* are cast expressions, not integer constants, 85 * this prevents them from being compared against in a preprocessor directive. 86 * The following ...IS_* macros can be used to check which clock is in use. 87 */ 88 #if defined(CLOCK_MONOTONIC) 89 #define CUSTOM_CLOCK_MONOTONIC CLOCK_MONOTONIC 90 #define CUSTOM_CLOCK_MONOTONIC_IS_MONOTONIC 91 #elif defined(CLOCK_HIGHRES) 92 #define CUSTOM_CLOCK_MONOTONIC CLOCK_HIGHRES 93 #define CUSTOM_CLOCK_MONOTONIC_IS_HIGHRES 94 #else 95 #define CUSTOM_CLOCK_MONOTONIC CLOCK_REALTIME 96 #define CUSTOM_CLOCK_MONOTONIC_IS_REALTIME 97 #endif 98 99 #endif 100