1 /* 2 * time() for uClibc 3 * 4 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> 5 * 6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. 7 */ 8 9 #include <sys/syscall.h> 10 #include <time.h> 11 12 #if defined(__NR_time) && !defined(__UCLIBC_USE_TIME64__) 13 _syscall_noerr1(time_t, time, time_t *, t) 14 #else 15 # include <sys/time.h> 16 time_t time(time_t * t) 17 { 18 time_t result; 19 struct timeval tv; 20 21 /* In Linux, gettimeofday fails only on bad parameter. 22 * We know that here parameter isn't bad. 23 */ 24 gettimeofday(&tv, NULL); 25 result = (time_t) tv.tv_sec; 26 if (t != NULL) 27 *t = result; 28 return result; 29 } 30 #endif 31 libc_hidden_def(time) 32