starpu_util.h 16 KB

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