starpu_util.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2017 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 CNRS
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #ifndef __STARPU_UTIL_H__
  18. #define __STARPU_UTIL_H__
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <stdint.h>
  22. #include <string.h>
  23. #include <assert.h>
  24. #include <starpu_config.h>
  25. #ifdef __GLIBC__
  26. #include <execinfo.h>
  27. #endif
  28. #ifdef STARPU_SIMGRID_MC
  29. #include <simgrid/modelchecker.h>
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #endif
  35. #if defined __GNUC__ && defined __GNUC_MINOR__
  36. # define STARPU_GNUC_PREREQ(maj, min) \
  37. ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
  38. #else
  39. # define STARPU_GNUC_PREREQ(maj, min) 0
  40. #endif
  41. #ifdef __GNUC__
  42. # define STARPU_UNLIKELY(expr) (__builtin_expect(!!(expr),0))
  43. # define STARPU_LIKELY(expr) (__builtin_expect(!!(expr),1))
  44. # define STARPU_ATTRIBUTE_UNUSED __attribute__((unused))
  45. # define STARPU_ATTRIBUTE_NORETURN __attribute__((noreturn))
  46. # define STARPU_ATTRIBUTE_INTERNAL __attribute__ ((visibility ("internal")))
  47. # define STARPU_ATTRIBUTE_MALLOC __attribute__((malloc))
  48. # define STARPU_ATTRIBUTE_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  49. # define STARPU_ATTRIBUTE_PURE __attribute__((pure))
  50. # define STARPU_ATTRIBUTE_ALIGNED(size) __attribute__((aligned(size)))
  51. # define STARPU_ATTRIBUTE_FORMAT(type, string, first) __attribute__((format(type, string, first)))
  52. #else
  53. # define STARPU_UNLIKELY(expr) (expr)
  54. # define STARPU_LIKELY(expr) (expr)
  55. # define STARPU_ATTRIBUTE_UNUSED
  56. # define STARPU_ATTRIBUTE_NORETURN
  57. # define STARPU_ATTRIBUTE_INTERNAL
  58. # define STARPU_ATTRIBUTE_MALLOC
  59. # define STARPU_ATTRIBUTE_WARN_UNUSED_RESULT
  60. # define STARPU_ATTRIBUTE_PURE
  61. # define STARPU_ATTRIBUTE_ALIGNED(size)
  62. # define STARPU_ATTRIBUTE_FORMAT(type, string, first)
  63. #endif
  64. /* Note that if we're compiling C++, then just use the "inline"
  65. keyword, since it's part of C++ */
  66. #if defined(c_plusplus) || defined(__cplusplus)
  67. # define STARPU_INLINE inline
  68. #elif defined(_MSC_VER) || defined(__HP_cc)
  69. # define STARPU_INLINE __inline
  70. #else
  71. # define STARPU_INLINE __inline__
  72. #endif
  73. #if STARPU_GNUC_PREREQ(4, 3)
  74. # define STARPU_ATTRIBUTE_CALLOC_SIZE(num,size) __attribute__((alloc_size(num,size)))
  75. # define STARPU_ATTRIBUTE_ALLOC_SIZE(size) __attribute__((alloc_size(size)))
  76. #else
  77. # define STARPU_ATTRIBUTE_CALLOC_SIZE(num,size)
  78. # define STARPU_ATTRIBUTE_ALLOC_SIZE(size)
  79. #endif
  80. #if STARPU_GNUC_PREREQ(3, 1) && !defined(BUILDING_STARPU) && !defined(STARPU_USE_DEPRECATED_API) && !defined(STARPU_USE_DEPRECATED_ONE_ZERO_API)
  81. #define STARPU_DEPRECATED __attribute__((__deprecated__))
  82. #else
  83. #define STARPU_DEPRECATED
  84. #endif /* __GNUC__ */
  85. #if STARPU_GNUC_PREREQ(3,3)
  86. #define STARPU_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
  87. #else
  88. #define STARPU_WARN_UNUSED_RESULT
  89. #endif /* __GNUC__ */
  90. #define STARPU_POISON_PTR ((void *)0xdeadbeef)
  91. #define STARPU_MIN(a,b) ((a)<(b)?(a):(b))
  92. #define STARPU_MAX(a,b) ((a)<(b)?(b):(a))
  93. #define STARPU_BACKTRACE_LENGTH 32
  94. #ifdef __GLIBC__
  95. # define STARPU_DUMP_BACKTRACE() do { \
  96. void *__ptrs[STARPU_BACKTRACE_LENGTH]; \
  97. int __n = backtrace(__ptrs, STARPU_BACKTRACE_LENGTH); \
  98. backtrace_symbols_fd(__ptrs, __n, 2); \
  99. } while (0)
  100. #else
  101. # define STARPU_DUMP_BACKTRACE() do { } while (0)
  102. #endif
  103. #ifdef STARPU_SIMGRID_MC
  104. #define STARPU_SIMGRID_ASSERT(x) MC_assert(!!(x))
  105. #else
  106. #define STARPU_SIMGRID_ASSERT(x)
  107. #endif
  108. #ifdef STARPU_NO_ASSERT
  109. #define STARPU_ASSERT(x) do { if (0) { (void) (x); } } while(0)
  110. #define STARPU_ASSERT_ACCESSIBLE(x) do { if (0) { (void) (x); } } while(0)
  111. #define STARPU_ASSERT_MSG(x, msg, ...) do { if (0) { (void) (x); (void) msg; } } while(0)
  112. #else
  113. # if defined(__CUDACC__) || defined(STARPU_HAVE_WINDOWS)
  114. # define STARPU_ASSERT(x) do { if (STARPU_UNLIKELY(!(x))) { STARPU_DUMP_BACKTRACE(); STARPU_SIMGRID_ASSERT(x); *(int*)NULL = 0; } } while(0)
  115. # define STARPU_ASSERT_MSG(x, msg, ...) do { if (STARPU_UNLIKELY(!(x))) { STARPU_DUMP_BACKTRACE(); fprintf(stderr, "\n[starpu][%s][assert failure] " msg "\n\n", __starpu_func__, ## __VA_ARGS__); STARPU_SIMGRID_ASSERT(x); *(int*)NULL = 0; }} while(0)
  116. # else
  117. # define STARPU_ASSERT(x) do { if (STARPU_UNLIKELY(!(x))) { STARPU_DUMP_BACKTRACE(); STARPU_SIMGRID_ASSERT(x); assert(x); } } while (0)
  118. # define STARPU_ASSERT_MSG(x, msg, ...) do { if (STARPU_UNLIKELY(!(x))) { STARPU_DUMP_BACKTRACE(); fprintf(stderr, "\n[starpu][%s][assert failure] " msg "\n\n", __starpu_func__, ## __VA_ARGS__); STARPU_SIMGRID_ASSERT(x); assert(x); } } while(0)
  119. # endif
  120. # define STARPU_ASSERT_ACCESSIBLE(ptr) do { \
  121. volatile char __c STARPU_ATTRIBUTE_UNUSED = *(char*) (ptr); \
  122. } while(0)
  123. #endif
  124. #ifdef __APPLE_CC__
  125. # define _starpu_abort() *(volatile int*)NULL = 0
  126. #else
  127. # define _starpu_abort() abort()
  128. #endif
  129. #define STARPU_ABORT() do { \
  130. STARPU_DUMP_BACKTRACE(); \
  131. fprintf(stderr, "[starpu][abort][%s()@%s:%d]\n", __starpu_func__, __FILE__, __LINE__); \
  132. _starpu_abort(); \
  133. } while(0)
  134. #define STARPU_ABORT_MSG(msg, ...) do { \
  135. STARPU_DUMP_BACKTRACE(); \
  136. fprintf(stderr, "[starpu][abort][%s()@%s:%d] " msg "\n", __starpu_func__, __FILE__, __LINE__, ## __VA_ARGS__); \
  137. _starpu_abort(); \
  138. } while(0)
  139. #if defined(STARPU_HAVE_STRERROR_R)
  140. #if !__GLIBC__ || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)
  141. /* XSI-compliant version of strerror_r returns an int */
  142. #define starpu_strerror_r(errnum, buf, buflen) \
  143. do \
  144. { \
  145. int _ret = strerror_r((errnum), (buf), (buflen)); \
  146. STARPU_ASSERT(_ret == 0); \
  147. } \
  148. while (0)
  149. #else
  150. /* GNU-specific version of strerror_r returns a char * */
  151. #define starpu_strerror_r(errnum, buf, buflen) \
  152. do \
  153. { \
  154. char * const _user_buf = (buf); \
  155. const size_t _user_buflen = (buflen); \
  156. /* the GNU-specific behaviour when 'buf' == NULL cannot be emulated with the XSI-compliant version */ \
  157. STARPU_ASSERT((buf) != NULL); \
  158. char * _tmp_buf = strerror_r((errnum), _user_buf, _user_buflen); \
  159. if (_tmp_buf != _user_buf) \
  160. { \
  161. if (_user_buflen > 0) \
  162. { \
  163. strncpy(_user_buf, _tmp_buf, _user_buflen); \
  164. _user_buf[_user_buflen-1] = '\0'; \
  165. } \
  166. } \
  167. } \
  168. while (0)
  169. #endif /* strerror_r ABI version */
  170. # define STARPU_CHECK_RETURN_VALUE(err, message, ...) {if (STARPU_UNLIKELY(err != 0)) { \
  171. char xmessage[256]; starpu_strerror_r(-err, xmessage, 256); \
  172. fprintf(stderr, "[starpu] Unexpected value: <%d:%s> returned for " message "\n", err, xmessage, ## __VA_ARGS__); \
  173. STARPU_ABORT(); }}
  174. # define STARPU_CHECK_RETURN_VALUE_IS(err, value, message, ...) {if (STARPU_UNLIKELY(err != value)) { \
  175. char xmessage[256]; starpu_strerror_r(-err, xmessage, 256); \
  176. fprintf(stderr, "[starpu] Unexpected value: <%d!=%d:%s> returned for " message "\n", err, value, xmessage, ## __VA_ARGS__); \
  177. STARPU_ABORT(); }}
  178. #else
  179. # define STARPU_CHECK_RETURN_VALUE(err, message, ...) {if (STARPU_UNLIKELY(err != 0)) { \
  180. fprintf(stderr, "[starpu] Unexpected value: <%d> returned for " message "\n", err, ## __VA_ARGS__); \
  181. STARPU_ABORT(); }}
  182. # define STARPU_CHECK_RETURN_VALUE_IS(err, value, message, ...) {if (STARPU_UNLIKELY(err != value)) { \
  183. fprintf(stderr, "[starpu] Unexpected value: <%d != %d> returned for " message "\n", err, value, ## __VA_ARGS__); \
  184. STARPU_ABORT(); }}
  185. #endif /* STARPU_HAVE_STRERROR_R */
  186. #if defined(__i386__) || defined(__x86_64__)
  187. static __starpu_inline unsigned starpu_cmpxchg(unsigned *ptr, unsigned old, unsigned next)
  188. {
  189. __asm__ __volatile__("lock cmpxchgl %2,%1": "+a" (old), "+m" (*ptr) : "q" (next) : "memory");
  190. return old;
  191. }
  192. static __starpu_inline unsigned starpu_xchg(unsigned *ptr, unsigned next)
  193. {
  194. /* Note: xchg is always locked already */
  195. __asm__ __volatile__("xchgl %1,%0": "+m" (*ptr), "+q" (next) : : "memory");
  196. return next;
  197. }
  198. #define STARPU_HAVE_XCHG
  199. #if defined(__i386__)
  200. static __starpu_inline unsigned long starpu_cmpxchgl(unsigned long *ptr, unsigned long old, unsigned long next)
  201. {
  202. __asm__ __volatile__("lock cmpxchgl %2,%1": "+a" (old), "+m" (*ptr) : "q" (next) : "memory");
  203. return old;
  204. }
  205. static __starpu_inline unsigned long starpu_xchgl(unsigned long *ptr, unsigned long next)
  206. {
  207. /* Note: xchg is always locked already */
  208. __asm__ __volatile__("xchgl %1,%0": "+m" (*ptr), "+q" (next) : : "memory");
  209. return next;
  210. }
  211. #define STARPU_HAVE_XCHGL
  212. #endif
  213. #if defined(__x86_64__)
  214. static __starpu_inline unsigned long starpu_cmpxchgl(unsigned long *ptr, unsigned long old, unsigned long next)
  215. {
  216. __asm__ __volatile__("lock cmpxchgq %2,%1": "+a" (old), "+m" (*ptr) : "q" (next) : "memory");
  217. return old;
  218. }
  219. static __starpu_inline unsigned long starpu_xchgl(unsigned long *ptr, unsigned long next)
  220. {
  221. /* Note: xchg is always locked already */
  222. __asm__ __volatile__("xchgq %1,%0": "+m" (*ptr), "+q" (next) : : "memory");
  223. return next;
  224. }
  225. #define STARPU_HAVE_XCHGL
  226. #endif
  227. #endif
  228. #define STARPU_ATOMIC_SOMETHING(name,expr) \
  229. static __starpu_inline unsigned starpu_atomic_##name(unsigned *ptr, unsigned value) \
  230. { \
  231. unsigned old, next; \
  232. while (1) \
  233. { \
  234. old = *ptr; \
  235. next = expr; \
  236. if (starpu_cmpxchg(ptr, old, next) == old) \
  237. break; \
  238. }; \
  239. return expr; \
  240. }
  241. #define STARPU_ATOMIC_SOMETHINGL(name,expr) \
  242. static __starpu_inline unsigned long starpu_atomic_##name##l(unsigned long *ptr, unsigned long value) \
  243. { \
  244. unsigned long old, next; \
  245. while (1) \
  246. { \
  247. old = *ptr; \
  248. next = expr; \
  249. if (starpu_cmpxchgl(ptr, old, next) == old) \
  250. break; \
  251. }; \
  252. return expr; \
  253. }
  254. /* Returns the new value */
  255. #ifdef STARPU_HAVE_SYNC_FETCH_AND_ADD
  256. #define STARPU_ATOMIC_ADD(ptr, value) (__sync_fetch_and_add ((ptr), (value)) + (value))
  257. #define STARPU_ATOMIC_ADDL(ptr, value) (__sync_fetch_and_add ((ptr), (value)) + (value))
  258. #else
  259. #if defined(STARPU_HAVE_XCHG)
  260. STARPU_ATOMIC_SOMETHING(add, old + value)
  261. #define STARPU_ATOMIC_ADD(ptr, value) starpu_atomic_add(ptr, value)
  262. #endif
  263. #if defined(STARPU_HAVE_XCHGL)
  264. STARPU_ATOMIC_SOMETHINGL(add, old + value)
  265. #define STARPU_ATOMIC_ADDL(ptr, value) starpu_atomic_addl(ptr, value)
  266. #endif
  267. #endif
  268. #ifdef STARPU_HAVE_SYNC_FETCH_AND_OR
  269. #define STARPU_ATOMIC_OR(ptr, value) (__sync_fetch_and_or ((ptr), (value)))
  270. #define STARPU_ATOMIC_ORL(ptr, value) (__sync_fetch_and_or ((ptr), (value)))
  271. #else
  272. #if defined(STARPU_HAVE_XCHG)
  273. STARPU_ATOMIC_SOMETHING(or, old | value)
  274. #define STARPU_ATOMIC_OR(ptr, value) starpu_atomic_or(ptr, value)
  275. #endif
  276. #if defined(STARPU_HAVE_XCHGL)
  277. STARPU_ATOMIC_SOMETHINGL(or, old | value)
  278. #define STARPU_ATOMIC_ORL(ptr, value) starpu_atomic_orl(ptr, value)
  279. #endif
  280. #endif
  281. #ifdef STARPU_HAVE_SYNC_BOOL_COMPARE_AND_SWAP
  282. #define STARPU_BOOL_COMPARE_AND_SWAP(ptr, old, value) (__sync_bool_compare_and_swap ((ptr), (old), (value)))
  283. #elif defined(STARPU_HAVE_XCHG)
  284. #define STARPU_BOOL_COMPARE_AND_SWAP(ptr, old, value) (starpu_cmpxchg((ptr), (old), (value)) == (old))
  285. #endif
  286. #ifdef STARPU_HAVE_SYNC_VAL_COMPARE_AND_SWAP
  287. #define STARPU_VAL_COMPARE_AND_SWAP(ptr, old, value) (__sync_val_compare_and_swap ((ptr), (old), (value)))
  288. #elif defined(STARPU_HAVE_XCHG)
  289. #define STARPU_VAL_COMPARE_AND_SWAP(ptr, old, value) (starpu_cmpxchg((ptr), (old), (value)))
  290. #endif
  291. #ifdef STARPU_HAVE_SYNC_LOCK_TEST_AND_SET
  292. #define STARPU_TEST_AND_SET(ptr, value) (__sync_lock_test_and_set ((ptr), (value)))
  293. #define STARPU_RELEASE(ptr) (__sync_lock_release ((ptr)))
  294. #elif defined(STARPU_HAVE_XCHG)
  295. #define STARPU_TEST_AND_SET(ptr, value) (starpu_xchg((ptr), (value)))
  296. #define STARPU_RELEASE(ptr) (starpu_xchg((ptr), 0))
  297. #endif
  298. #ifdef STARPU_HAVE_SYNC_SYNCHRONIZE
  299. #define STARPU_SYNCHRONIZE() __sync_synchronize()
  300. #elif defined(__i386__)
  301. #define STARPU_SYNCHRONIZE() __asm__ __volatile__("lock; addl $0,0(%%esp)" ::: "memory")
  302. #elif defined(__KNC__) || defined(__KNF__)
  303. #define STARPU_SYNCHRONIZE() __asm__ __volatile__("lock; addl $0,0(%%rsp)" ::: "memory")
  304. #elif defined(__x86_64__)
  305. #define STARPU_SYNCHRONIZE() __asm__ __volatile__("mfence" ::: "memory")
  306. #elif defined(__ppc__) || defined(__ppc64__)
  307. #define STARPU_SYNCHRONIZE() __asm__ __volatile__("sync" ::: "memory")
  308. #endif
  309. #if defined(__i386__)
  310. #define STARPU_RMB() __asm__ __volatile__("lock; addl $0,0(%%esp)" ::: "memory")
  311. #define STARPU_WMB() __asm__ __volatile__("lock; addl $0,0(%%esp)" ::: "memory")
  312. #elif defined(__KNC__) || defined(__KNF__)
  313. #define STARPU_RMB() __asm__ __volatile__("lock; addl $0,0(%%rsp)" ::: "memory")
  314. #define STARPU_WMB() __asm__ __volatile__("lock; addl $0,0(%%rsp)" ::: "memory")
  315. #elif defined(__x86_64__)
  316. #define STARPU_RMB() __asm__ __volatile__("lfence" ::: "memory")
  317. #define STARPU_WMB() __asm__ __volatile__("sfence" ::: "memory")
  318. #elif defined(__ppc__) || defined(__ppc64__)
  319. #define STARPU_RMB() __asm__ __volatile__("sync" ::: "memory")
  320. #define STARPU_WMB() __asm__ __volatile__("sync" ::: "memory")
  321. #else
  322. #define STARPU_RMB() STARPU_SYNCHRONIZE()
  323. #define STARPU_WMB() STARPU_SYNCHRONIZE()
  324. #endif
  325. #ifdef __cplusplus
  326. }
  327. #endif
  328. #ifdef __cplusplus
  329. extern "C"
  330. {
  331. #endif
  332. extern int _starpu_silent;
  333. char *starpu_getenv(const char *str);
  334. static __starpu_inline int starpu_get_env_number(const char *str)
  335. {
  336. char *strval;
  337. strval = starpu_getenv(str);
  338. if (strval)
  339. {
  340. /* the env variable was actually set */
  341. long int val;
  342. char *check;
  343. val = strtol(strval, &check, 10);
  344. if (*check) {
  345. fprintf(stderr,"The %s environment variable must contain an integer\n", str);
  346. STARPU_ABORT();
  347. }
  348. /* fprintf(stderr, "ENV %s WAS %d\n", str, val); */
  349. STARPU_ASSERT_MSG(val >= 0, "The value for the environment variable '%s' cannot be negative", str);
  350. return (int)val;
  351. }
  352. else
  353. {
  354. /* there is no such env variable */
  355. /* fprintf("There was no %s ENV\n", str); */
  356. return -1;
  357. }
  358. }
  359. static __starpu_inline int starpu_get_env_number_default(const char *str, int defval)
  360. {
  361. int ret = starpu_get_env_number(str);
  362. if (ret == -1)
  363. ret = defval;
  364. return ret;
  365. }
  366. static __starpu_inline float starpu_get_env_float_default(const char *str, float defval)
  367. {
  368. char *strval;
  369. strval = starpu_getenv(str);
  370. if (strval)
  371. {
  372. /* the env variable was actually set */
  373. float val;
  374. char *check;
  375. val = strtof(strval, &check);
  376. if (*check) {
  377. fprintf(stderr,"The %s environment variable must contain a float\n", str);
  378. STARPU_ABORT();
  379. }
  380. /* fprintf(stderr, "ENV %s WAS %f\n", str, val); */
  381. return val;
  382. }
  383. else
  384. {
  385. /* there is no such env variable */
  386. /* fprintf("There was no %s ENV\n", str); */
  387. return defval;
  388. }
  389. }
  390. void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t where);
  391. void starpu_execute_on_each_worker_ex(void (*func)(void *), void *arg, uint32_t where, const char *name);
  392. void starpu_execute_on_specific_workers(void (*func)(void*), void *arg, unsigned num_workers, unsigned *workers, const char *name);
  393. double starpu_timing_now(void);
  394. #ifdef _WIN32
  395. /* Try to fetch the system definition of timespec */
  396. #include <sys/types.h>
  397. #include <sys/stat.h>
  398. #ifdef HAVE_UNISTD_H
  399. #include <unistd.h>
  400. #endif
  401. #include <time.h>
  402. #if !defined(_MSC_VER) || defined(BUILDING_STARPU)
  403. #include <pthread.h>
  404. #endif
  405. #if !defined(STARPU_HAVE_STRUCT_TIMESPEC) || (defined(_MSC_VER) && _MSC_VER < 1900)
  406. /* If it didn't get defined in the standard places, then define it ourself */
  407. #ifndef STARPU_TIMESPEC_DEFINED
  408. #define STARPU_TIMESPEC_DEFINED 1
  409. struct timespec
  410. {
  411. time_t tv_sec; /* Seconds */
  412. long tv_nsec; /* Nanoseconds */
  413. };
  414. #endif /* STARPU_TIMESPEC_DEFINED */
  415. #endif /* STARPU_HAVE_STRUCT_TIMESPEC */
  416. /* Fetch gettimeofday on mingw/cygwin */
  417. #if defined(__MINGW32__) || defined(__CYGWIN__)
  418. #include <sys/time.h>
  419. #endif
  420. #else
  421. #include <sys/time.h>
  422. #endif /* _WIN32 */
  423. #ifdef __cplusplus
  424. }
  425. #endif
  426. #endif /* __STARPU_UTIL_H__ */