This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.h.in
108 lines (88 loc) · 3.09 KB
/
config.h.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#pragma once
//////////////////////////////////////////////////////////////////////
// ** Generating file **
// config.h.in is transformed into config.h by CMake's config system
// Edit config.h.in rather than config.h if any changes must be made.
//////////////////////////////////////////////////////////////////////
#pragma warning(disable: 4996 95 4800) // MSVC deprication warnings
//////////////////////////////////////////////////////////////////////
// Line endiings
//////////////////////////////////////////////////////////////////////
#ifdef _MSC_VER
#define ENDL "\r\n"
#else
#define ENDL "\n"
#endif
//////////////////////////////////////////////////////////////////////
// inline
//////////////////////////////////////////////////////////////////////
#ifndef __cplusplus
#ifdef __GCC__
#define inline __inline__
#endif
#ifdef _MSC_VER
#define inline __inline
#endif
#endif
//////////////////////////////////////////////////////////////////////
// sleep, usleep, etc...
// - prefer the *nix syntax
//////////////////////////////////////////////////////////////////////
#cmakedefine HAVE_USLEEP
#ifndef HAVE_USLEEP
#ifdef _MSC_VER
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define usleep(e) Sleep((unsigned long)((e)/1000.0)) // us -> ms
#define sleep(e) Sleep((unsigned long)((e)*1000.0)) // s -> ms
#else
// Not windows and missing usleep (not *nix?)
#error "Can't find replacement for usleep(), etc.."
#endif
#endif //HAVE_USLEEP not defined
//////////////////////////////////////////////////////////////////////
// Random number generator
// - prefer the drand48 syntax
//////////////////////////////////////////////////////////////////////
#cmakedefine HAVE_UNISTD
#ifdef HAVE_UNISTD
#include <unistd.h>
#else
#ifdef _MSC_VER
#define seed48(e) srand(*(e))
#define drand48() (( (double)rand() )/RAND_MAX)
#else
#error "Don't know how to choose a random number generator"
#endif
#endif // HAVE_UNISTD not defined
//////////////////////////////////////////////////////////////////////
// Threading
//////////////////////////////////////////////////////////////////////
#cmakedefine USE_PTHREAD
#cmakedefine USE_WIN32_THREADS
#if !defined(USE_WIN32_THREADS) && !defined(USE_PTHREAD)
#error "No threading library found. pthreads or win32 supported."
#endif
//////////////////////////////////////////////////////////////////////
// Atomic intrinsics
// - prefer the windows syntax
//////////////////////////////////////////////////////////////////////
#cmakedefine HAVE_ATOMIC_INTRINSICS_GCC
#cmakedefine HAVE_ATOMIC_INTRINSICS_MSVC
#if !defined(HAVE_ATOMIC_INTRINSICS_GCC) && !defined(HAVE_ATOMIC_INTRINSICS_MSVC)
#error "Don't know how to choose atomic intrinsics"
#endif
#ifdef HAVE_ATOMIC_INTRINSICS_GCC
#define InterlockedIncrement(e) __sync_add_and_fetch((e),1)
#define InterlockedDecrement(e) __sync_sub_and_fetch((e),1)
#endif
//////////////////////////////////////////////////////////////////////
// Types
//////////////////////////////////////////////////////////////////////
@SIZET_BYTES_CODE@
#cmakedefine HAVE_STDINT
#ifdef HAVE_STDINT
#include <stdint.h>
#else
#error "No stdint. what to do?"
#endif