1 /*
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
38 #include <stddef.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <wchar.h>
42
43 #include <math.h>
44 #include <time.h>
45 #include <fcntl.h>
46 #include <dlfcn.h>
47 #include <pthread.h>
48
49 #include <limits.h>
50 #include <errno.h>
51
52 #include <stdint.h>
53
54 // Use XLC compiler builtins instead of inline assembler
55 #define USE_XLC_BUILTINS
56 #ifdef USE_XLC_BUILTINS
57 #include <builtins.h>
58 #if __IBMCPP__ < 1000
59 // the funtion prototype for __dcbtst(void *) is missing in XLC V8.0
60 // I could compile a little test, where I provided the prototype.
61 // The generated code was correct there. This is the prototype:
62 // extern "builtin" void __dcbtst (void *);
63 // For now we don't make use of it when compiling with XLC V8.0
64 #else
65 // __IBMCPP__ >= 1000
66 // XLC V10 provides the prototype for __dcbtst (void *);
67 #define USE_XLC_PREFETCH_WRITE_BUILTIN
68 #endif
69 #endif // USE_XLC_BUILTINS
70
71 // NULL vs NULL_WORD:
72 // On Linux NULL is defined as a special type '__null'. Assigning __null to
73 // integer variable will cause gcc warning. Use NULL_WORD in places where a
74 // pointer is stored as integer value. On some platforms, sizeof(intptr_t) >
75 // sizeof(void*), so here we want something which is integer type, but has the
76 // same size as a pointer.
77 #ifdef __GNUC__
78 #error XLC and __GNUC__?
79 #else
80 #define NULL_WORD NULL
81 #endif
82
83 // AIX also needs a 64 bit NULL to work as a null address pointer.
84 // Most system includes on AIX would define it as an int 0 if not already defined with one
85 // exception: /usr/include/dirent.h will unconditionally redefine NULL to int 0 again.
86 // In this case you need to copy the following defines to a position after #include <dirent.h>
87 // (see jmv_aix.h).
88 #ifdef AIX
89 #include <dirent.h>
90 #ifdef _LP64
91 #undef NULL
92 #define NULL 0L
93 #else
94 #ifndef NULL
95 #define NULL 0
96 #endif
97 #endif
98 #endif // AIX
99
100 // Compiler-specific primitive types
101 // All defs of int (uint16_6 etc) are defined in AIX' /usr/include/stdint.h
|
1 /*
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2019 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
38 #include <stddef.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <wchar.h>
42
43 #include <math.h>
44 #include <time.h>
45 #include <fcntl.h>
46 #include <dlfcn.h>
47 #include <pthread.h>
48
49 #include <limits.h>
50 #include <errno.h>
51
52 #include <stdint.h>
53
54 // Use XLC compiler builtins instead of inline assembler
55 #define USE_XLC_BUILTINS
56 #ifdef USE_XLC_BUILTINS
57 #include <builtins.h>
58 // XLC V10 and higher provide the prototype for __dcbtst (void *);
59 #define USE_XLC_PREFETCH_WRITE_BUILTIN
60 #endif // USE_XLC_BUILTINS
61
62 // NULL vs NULL_WORD:
63 // Some platform/tool-chain combinations can't assign NULL to an integer
64 // type so we define NULL_WORD to use in those contexts. For xlc they are the same.
65 #define NULL_WORD NULL
66
67 // AIX also needs a 64 bit NULL to work as a null address pointer.
68 // Most system includes on AIX would define it as an int 0 if not already defined with one
69 // exception: /usr/include/dirent.h will unconditionally redefine NULL to int 0 again.
70 // In this case you need to copy the following defines to a position after #include <dirent.h>
71 // (see jmv_aix.h).
72 #ifdef AIX
73 #include <dirent.h>
74 #ifdef _LP64
75 #undef NULL
76 #define NULL 0L
77 #else
78 #ifndef NULL
79 #define NULL 0
80 #endif
81 #endif
82 #endif // AIX
83
84 // Compiler-specific primitive types
85 // All defs of int (uint16_6 etc) are defined in AIX' /usr/include/stdint.h
|