Changeset 35554
- Timestamp:
- 2021-10-12T14:55:23+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/packages/javagdbm/jni/gdbmjava.c
r26674 r35554 41 41 #define GDBM_FILE gdbm_file_info * 42 42 extern char* gdbm_version; 43 extern char *gdbm_strerror(gdbm_error); 43 44 #else 44 45 #include <gdbm.h> … … 90 91 jbyteArray datumToArray(JNIEnv *env, datum *fromDatum); 91 92 93 /* 94 The macros defined below for DBF_TO_JLONG(x) and JLONG_TO_DBF(x) 95 expect SIZEOF_VOID_P and SIZEOF_LONG to be defined. 96 97 It's possible for autoconf to determine these, but: 98 (a) This currently doesn't appear to be bound into JAVAGDBM 99 compilation sequence (config.h would need to be #included) 100 (b) Even if this was done for Unix system, there would still 101 need to be a way to do this for Windows: both 32-bit and 102 64-bit as the values would be differnt 103 104 In the event SIZEOF_VOID_P and SIZEON_LONG are not already set, 105 the solution taken here is to test for various #ifdef values 106 known to be set by Unix/Windows *compilers* that indicate 107 the type sizes they use for int, long, pointer, and 108 from that information explicitly set the values used in 109 the macro definition tests below. 110 111 For more details on what these sizes are, two useful references are: 112 113 https://en.cppreference.com/w/cpp/language/types 114 https://unix.org/version2/whatsnew/lp64_wp.html 115 */ 116 117 #ifndef SIZEOF_VOID_P 118 # if defined ( _MSC_VER ) /* i.e., Microsoft Visual Studio, not a Mingw based GCC */ 119 # if defined( _WIN64 ) 120 # define SIZEOF_VOID_P 8 121 122 # elif defined( _WIN32 ) 123 # define SIZEOF_VOID_P 4 124 125 # else 126 # error Windows OS neither 32-bit nor 64-bit. SIZEOF_VOID_P not specified 127 # endif 128 129 # else /* Presumably Unix */ 130 # if defined( __ILP32 ) /* i.e., int, long and pointer are all 32-bits */ 131 # define SIZEOF_VOID_P 4 132 133 # elif defined( __LP64 ) /* i.e., long, and pointer are both 64-bits */ 134 # define SIZEOF_VOID_P 8 135 136 # else 137 # error Compiler's 'sizeof' model not matched as either IILP32 or LP64. SIZEOF_VOID_P not specified 138 # endif 139 # endif 140 #endif 141 142 143 144 #ifndef SIZEOF_LONG 145 # if defined ( _MSC_VER ) /* i.e., Microsoft Visual Studio, not a Mingw based GCC */ 146 # if defined( _WIN64 ) 147 # define SIZEOF_LONG 4 /* but note that SIZEOF_VOID_P above is 8 ! */ 148 149 # elif defined( _WIN32 ) 150 # define SIZEOF_LONG 4 151 152 # else 153 # error Windows OS neither 32-bit nor 64-bit. SIZEOF_LONG not specified 154 # endif 155 156 # else /* Presumably Unix */ 157 # if defined( __ILP32 ) 158 # define SIZEOF_LONG 4 159 160 # elif defined( __LP64 ) 161 # define SIZEOF_LONG 8 162 163 # else 164 # error Compiler's 'sizeof' model not matched as either IILP32 or LP64. SIZEOF_LONG not specified 165 # endif 166 # endif 167 #endif 168 169 170 92 171 /* Convert between a jlong and a void ptr using a well-defined cast. 93 172 * (Casting between a pointer and an integer of different sizes spooks 94 173 * both gcc and mbp. */ 174 95 175 #if (SIZEOF_VOID_P == SIZEOF_LONG) 96 176 # define DBF_TO_JLONG(x) ((jlong)((long) x))
Note:
See TracChangeset
for help on using the changeset viewer.