1 | /* |
2 | * Legal Notice |
3 | * |
4 | * This document and associated source code (the "Work") is a part of a |
5 | * benchmark specification maintained by the TPC. |
6 | * |
7 | * The TPC reserves all right, title, and interest to the Work as provided |
8 | * under U.S. and international laws, including without limitation all patent |
9 | * and trademark rights therein. |
10 | * |
11 | * No Warranty |
12 | * |
13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION |
14 | * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE |
15 | * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER |
16 | * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, |
17 | * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, |
18 | * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR |
19 | * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF |
20 | * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. |
21 | * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, |
22 | * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT |
23 | * WITH REGARD TO THE WORK. |
24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO |
25 | * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE |
26 | * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS |
27 | * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, |
28 | * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, |
29 | * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT |
30 | * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD |
31 | * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. |
32 | * |
33 | * Contributors: |
34 | * Gradient Systems |
35 | */ |
36 | #ifndef PORTING_H |
37 | #define PORTING_H |
38 | |
39 | #ifdef USE_STRING_H |
40 | #include <string.h> |
41 | #else |
42 | #include <strings.h> |
43 | #endif |
44 | |
45 | #ifdef USE_VALUES_H |
46 | #include <values.h> |
47 | #endif |
48 | |
49 | #ifdef USE_LIMITS_H |
50 | #include <limits.h> |
51 | #endif |
52 | |
53 | #ifdef USE_STDLIB_H |
54 | #include <stdlib.h> |
55 | #endif |
56 | |
57 | #ifndef WIN32 |
58 | #include <sys/types.h> |
59 | #else |
60 | #define int32_t __int32 |
61 | #define int64_t __int64 |
62 | #endif |
63 | |
64 | #ifdef WIN32 |
65 | #include <sys/timeb.h> |
66 | #define timeb _timeb |
67 | #define ftime _ftime |
68 | #else |
69 | #include <sys/time.h> |
70 | #endif |
71 | |
72 | typedef HUGE_TYPE ds_key_t; |
73 | |
74 | /* |
75 | * add some functions that are not strictly ANSI standard |
76 | */ |
77 | #ifndef strdup |
78 | char *strdup(const char *); |
79 | #endif |
80 | |
81 | #ifdef WIN32 |
82 | #include <windows.h> |
83 | #include <winbase.h> |
84 | #include <io.h> |
85 | #define random rand |
86 | #define strncasecmp _strnicmp |
87 | #define strcasecmp _stricmp |
88 | #define strdup _strdup |
89 | #define access _access |
90 | #define isatty _isatty |
91 | #define fileno _fileno |
92 | #define F_OK 0 |
93 | #define MAXINT INT_MAX |
94 | #define THREAD __declspec(thread) |
95 | #define MIN_MULTI_NODE_ROWS 100000 |
96 | #define MIN_MULTI_THREAD_ROWS 5000 |
97 | #define THREAD __declspec(thread) |
98 | /* Lines added by Chuck McDevitt for WIN32 support */ |
99 | #ifndef _POSIX_ |
100 | #ifndef S_ISREG |
101 | #define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG) |
102 | #define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO) |
103 | #endif |
104 | #endif |
105 | #endif /* WIN32 */ |
106 | |
107 | #ifdef INTERIX |
108 | #include <limits.h> |
109 | #define MAXINT INT_MAX |
110 | #endif /* INTERIX */ |
111 | |
112 | #ifdef AIX |
113 | #define MAXINT INT_MAX |
114 | #endif |
115 | |
116 | #ifdef MACOS |
117 | #include <limits.h> |
118 | #define MAXINT INT_MAX |
119 | #endif /* MACOS */ |
120 | |
121 | #define INTERNAL(m) \ |
122 | { fprintf(stderr, "ERROR: %s\n\tFile: %s\n\tLine: %d\n", m, __FILE__, __LINE__); } |
123 | |
124 | #define OPEN_CHECK(var, path) \ |
125 | if ((var) == NULL) { \ |
126 | fprintf(stderr, "Open failed for %s at %s:%d\n", path, __FILE__, __LINE__); \ |
127 | exit(1); \ |
128 | } |
129 | |
130 | #ifdef MEM_TEST |
131 | #define MALLOC_CHECK(v) \ |
132 | if (v == NULL) { \ |
133 | fprintf(stderr, "Malloc Failed at %d in %s\n", __LINE__, __FILE__); \ |
134 | exit(1); \ |
135 | } else { \ |
136 | fprintf(stderr, "Add (%x) %d at %d in %s\n", sizeof(*v), v, __LINE__, __FILE__); \ |
137 | } |
138 | #else |
139 | #define MALLOC_CHECK(v) \ |
140 | if (v == NULL) { \ |
141 | fprintf(stderr, "Malloc Failed at %d in %s\n", __LINE__, __FILE__); \ |
142 | exit(1); \ |
143 | } |
144 | #endif /* MEM_TEST */ |
145 | #endif |
146 | |