Debian Codegraph @

src/posix_cgreen_time.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/posix_cgreen_time.c`/include "cgreen/internal/cgreen_time.h"cxx . . $ `<file>/include/cgreen/internal/cgreen_time.h`/
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <unistd.h>
5
6 #ifdef __ANDROID__
7 #include "cgreen/internal/android_headers/androidcompat.h"
8 #endif // #ifdef __ANDROID__
9
10 /* TODO: this should really be handle by CMake config... */
11 #if defined(__FreeBSD__) || defined(__linux__cxx . . $ `<built-in>:397:9`!) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__OpenBSD__)
12 # include <sys/time.h>
13 # define HAVE_GETTIMEOFDAYcxx . . $ `src/posix_cgreen_time.c:13:11`! 1
14 #else
15 # error "Your POSIX platform does not support gettimeofday(). Please report a bug to http://github.com/cgreen-devs/cgreen/issues"
16 #endif
17
18 #if defined(HAVE_GETTIMEOFDAYcxx . . $ `src/posix_cgreen_time.c:13:11`!)
19 uint32_tcxx . . $ uint32_t# cgreen_time_get_current_millisecondscxx . . $ cgreen_time_get_current_milliseconds(db52760e79bf9054).(void) {
20 #ifdef __CYGWIN__
21 /* TODO: This is actually the POSIX recommended way to do this */
22 struct timespec ts;
23 if (clock_gettime(CLOCK_REALTIME, &ts) != 0) {
24 fprintf(stderr, "cgreen error: could not get time\n");
25 return 0;
26 }
27
28 return ts.tv_sec * 1000u + ts.tv_nsec / 1000000u;
29 #else
30 struct timevalcxx . . $ timeval# tv;
31 if (gettimeofdaycxx . . $ gettimeofday(ee8865a94200b3d6).(&tv, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) != 0) {
32 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "cgreen error: could not get time of day\n");
33 return 0;
34 }
35 return tv.tv_seccxx . . $ timeval#tv_sec. * 1000u + tv.tv_useccxx . . $ timeval#tv_usec. / 1000u;
36 #endif
37 }
38 #endif
39
40 /* vim: set ts=4 sw=4 et cindent: */