sdsykes-ferret 0.11.6.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. data/CHANGELOG +24 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +102 -0
  4. data/Rakefile +338 -0
  5. data/TODO +17 -0
  6. data/TUTORIAL +231 -0
  7. data/bin/ferret-browser +79 -0
  8. data/ext/analysis.c +1555 -0
  9. data/ext/analysis.h +219 -0
  10. data/ext/api.c +69 -0
  11. data/ext/api.h +27 -0
  12. data/ext/array.c +123 -0
  13. data/ext/array.h +53 -0
  14. data/ext/bitvector.c +540 -0
  15. data/ext/bitvector.h +272 -0
  16. data/ext/compound_io.c +383 -0
  17. data/ext/config.h +42 -0
  18. data/ext/document.c +156 -0
  19. data/ext/document.h +53 -0
  20. data/ext/except.c +120 -0
  21. data/ext/except.h +168 -0
  22. data/ext/extconf.rb +14 -0
  23. data/ext/ferret.c +402 -0
  24. data/ext/ferret.h +91 -0
  25. data/ext/filter.c +156 -0
  26. data/ext/fs_store.c +483 -0
  27. data/ext/global.c +418 -0
  28. data/ext/global.h +117 -0
  29. data/ext/hash.c +567 -0
  30. data/ext/hash.h +473 -0
  31. data/ext/hashset.c +170 -0
  32. data/ext/hashset.h +187 -0
  33. data/ext/header.h +58 -0
  34. data/ext/helper.c +62 -0
  35. data/ext/helper.h +13 -0
  36. data/ext/inc/lang.h +48 -0
  37. data/ext/inc/threading.h +31 -0
  38. data/ext/index.c +6425 -0
  39. data/ext/index.h +961 -0
  40. data/ext/lang.h +66 -0
  41. data/ext/libstemmer.c +92 -0
  42. data/ext/libstemmer.h +79 -0
  43. data/ext/mempool.c +87 -0
  44. data/ext/mempool.h +35 -0
  45. data/ext/modules.h +162 -0
  46. data/ext/multimapper.c +310 -0
  47. data/ext/multimapper.h +51 -0
  48. data/ext/posh.c +1006 -0
  49. data/ext/posh.h +1007 -0
  50. data/ext/priorityqueue.c +151 -0
  51. data/ext/priorityqueue.h +143 -0
  52. data/ext/q_boolean.c +1608 -0
  53. data/ext/q_const_score.c +161 -0
  54. data/ext/q_filtered_query.c +209 -0
  55. data/ext/q_fuzzy.c +268 -0
  56. data/ext/q_match_all.c +148 -0
  57. data/ext/q_multi_term.c +677 -0
  58. data/ext/q_parser.c +2825 -0
  59. data/ext/q_phrase.c +1126 -0
  60. data/ext/q_prefix.c +100 -0
  61. data/ext/q_range.c +350 -0
  62. data/ext/q_span.c +2402 -0
  63. data/ext/q_term.c +337 -0
  64. data/ext/q_wildcard.c +171 -0
  65. data/ext/r_analysis.c +2575 -0
  66. data/ext/r_index.c +3472 -0
  67. data/ext/r_qparser.c +585 -0
  68. data/ext/r_search.c +4105 -0
  69. data/ext/r_store.c +513 -0
  70. data/ext/r_utils.c +963 -0
  71. data/ext/ram_store.c +471 -0
  72. data/ext/search.c +1741 -0
  73. data/ext/search.h +885 -0
  74. data/ext/similarity.c +150 -0
  75. data/ext/similarity.h +82 -0
  76. data/ext/sort.c +983 -0
  77. data/ext/stem_ISO_8859_1_danish.c +338 -0
  78. data/ext/stem_ISO_8859_1_danish.h +16 -0
  79. data/ext/stem_ISO_8859_1_dutch.c +635 -0
  80. data/ext/stem_ISO_8859_1_dutch.h +16 -0
  81. data/ext/stem_ISO_8859_1_english.c +1156 -0
  82. data/ext/stem_ISO_8859_1_english.h +16 -0
  83. data/ext/stem_ISO_8859_1_finnish.c +792 -0
  84. data/ext/stem_ISO_8859_1_finnish.h +16 -0
  85. data/ext/stem_ISO_8859_1_french.c +1276 -0
  86. data/ext/stem_ISO_8859_1_french.h +16 -0
  87. data/ext/stem_ISO_8859_1_german.c +512 -0
  88. data/ext/stem_ISO_8859_1_german.h +16 -0
  89. data/ext/stem_ISO_8859_1_italian.c +1091 -0
  90. data/ext/stem_ISO_8859_1_italian.h +16 -0
  91. data/ext/stem_ISO_8859_1_norwegian.c +296 -0
  92. data/ext/stem_ISO_8859_1_norwegian.h +16 -0
  93. data/ext/stem_ISO_8859_1_porter.c +776 -0
  94. data/ext/stem_ISO_8859_1_porter.h +16 -0
  95. data/ext/stem_ISO_8859_1_portuguese.c +1035 -0
  96. data/ext/stem_ISO_8859_1_portuguese.h +16 -0
  97. data/ext/stem_ISO_8859_1_spanish.c +1119 -0
  98. data/ext/stem_ISO_8859_1_spanish.h +16 -0
  99. data/ext/stem_ISO_8859_1_swedish.c +307 -0
  100. data/ext/stem_ISO_8859_1_swedish.h +16 -0
  101. data/ext/stem_KOI8_R_russian.c +701 -0
  102. data/ext/stem_KOI8_R_russian.h +16 -0
  103. data/ext/stem_UTF_8_danish.c +344 -0
  104. data/ext/stem_UTF_8_danish.h +16 -0
  105. data/ext/stem_UTF_8_dutch.c +653 -0
  106. data/ext/stem_UTF_8_dutch.h +16 -0
  107. data/ext/stem_UTF_8_english.c +1176 -0
  108. data/ext/stem_UTF_8_english.h +16 -0
  109. data/ext/stem_UTF_8_finnish.c +808 -0
  110. data/ext/stem_UTF_8_finnish.h +16 -0
  111. data/ext/stem_UTF_8_french.c +1296 -0
  112. data/ext/stem_UTF_8_french.h +16 -0
  113. data/ext/stem_UTF_8_german.c +526 -0
  114. data/ext/stem_UTF_8_german.h +16 -0
  115. data/ext/stem_UTF_8_italian.c +1113 -0
  116. data/ext/stem_UTF_8_italian.h +16 -0
  117. data/ext/stem_UTF_8_norwegian.c +302 -0
  118. data/ext/stem_UTF_8_norwegian.h +16 -0
  119. data/ext/stem_UTF_8_porter.c +794 -0
  120. data/ext/stem_UTF_8_porter.h +16 -0
  121. data/ext/stem_UTF_8_portuguese.c +1055 -0
  122. data/ext/stem_UTF_8_portuguese.h +16 -0
  123. data/ext/stem_UTF_8_russian.c +709 -0
  124. data/ext/stem_UTF_8_russian.h +16 -0
  125. data/ext/stem_UTF_8_spanish.c +1137 -0
  126. data/ext/stem_UTF_8_spanish.h +16 -0
  127. data/ext/stem_UTF_8_swedish.c +313 -0
  128. data/ext/stem_UTF_8_swedish.h +16 -0
  129. data/ext/stopwords.c +401 -0
  130. data/ext/store.c +692 -0
  131. data/ext/store.h +777 -0
  132. data/ext/term_vectors.c +352 -0
  133. data/ext/threading.h +31 -0
  134. data/ext/utilities.c +446 -0
  135. data/ext/win32.h +54 -0
  136. data/lib/ferret.rb +29 -0
  137. data/lib/ferret/browser.rb +246 -0
  138. data/lib/ferret/browser/s/global.js +192 -0
  139. data/lib/ferret/browser/s/style.css +148 -0
  140. data/lib/ferret/browser/views/document/list.rhtml +49 -0
  141. data/lib/ferret/browser/views/document/show.rhtml +27 -0
  142. data/lib/ferret/browser/views/error/index.rhtml +7 -0
  143. data/lib/ferret/browser/views/help/index.rhtml +8 -0
  144. data/lib/ferret/browser/views/home/index.rhtml +29 -0
  145. data/lib/ferret/browser/views/layout.rhtml +22 -0
  146. data/lib/ferret/browser/views/term-vector/index.rhtml +4 -0
  147. data/lib/ferret/browser/views/term/index.rhtml +199 -0
  148. data/lib/ferret/browser/views/term/termdocs.rhtml +1 -0
  149. data/lib/ferret/browser/webrick.rb +14 -0
  150. data/lib/ferret/document.rb +130 -0
  151. data/lib/ferret/field_infos.rb +44 -0
  152. data/lib/ferret/index.rb +786 -0
  153. data/lib/ferret/number_tools.rb +157 -0
  154. data/lib/ferret_version.rb +3 -0
  155. data/setup.rb +1555 -0
  156. data/test/test_all.rb +5 -0
  157. data/test/test_helper.rb +24 -0
  158. data/test/threading/number_to_spoken.rb +132 -0
  159. data/test/threading/thread_safety_index_test.rb +79 -0
  160. data/test/threading/thread_safety_read_write_test.rb +76 -0
  161. data/test/threading/thread_safety_test.rb +133 -0
  162. data/test/unit/analysis/tc_analyzer.rb +548 -0
  163. data/test/unit/analysis/tc_token_stream.rb +646 -0
  164. data/test/unit/index/tc_index.rb +762 -0
  165. data/test/unit/index/tc_index_reader.rb +699 -0
  166. data/test/unit/index/tc_index_writer.rb +437 -0
  167. data/test/unit/index/th_doc.rb +315 -0
  168. data/test/unit/largefile/tc_largefile.rb +46 -0
  169. data/test/unit/query_parser/tc_query_parser.rb +238 -0
  170. data/test/unit/search/tc_filter.rb +135 -0
  171. data/test/unit/search/tc_fuzzy_query.rb +147 -0
  172. data/test/unit/search/tc_index_searcher.rb +61 -0
  173. data/test/unit/search/tc_multi_searcher.rb +128 -0
  174. data/test/unit/search/tc_multiple_search_requests.rb +58 -0
  175. data/test/unit/search/tc_search_and_sort.rb +179 -0
  176. data/test/unit/search/tc_sort.rb +49 -0
  177. data/test/unit/search/tc_sort_field.rb +27 -0
  178. data/test/unit/search/tc_spans.rb +190 -0
  179. data/test/unit/search/tm_searcher.rb +384 -0
  180. data/test/unit/store/tc_fs_store.rb +77 -0
  181. data/test/unit/store/tc_ram_store.rb +35 -0
  182. data/test/unit/store/tm_store.rb +34 -0
  183. data/test/unit/store/tm_store_lock.rb +68 -0
  184. data/test/unit/tc_document.rb +81 -0
  185. data/test/unit/ts_analysis.rb +2 -0
  186. data/test/unit/ts_index.rb +2 -0
  187. data/test/unit/ts_largefile.rb +4 -0
  188. data/test/unit/ts_query_parser.rb +2 -0
  189. data/test/unit/ts_search.rb +2 -0
  190. data/test/unit/ts_store.rb +2 -0
  191. data/test/unit/ts_utils.rb +2 -0
  192. data/test/unit/utils/tc_bit_vector.rb +295 -0
  193. data/test/unit/utils/tc_number_tools.rb +117 -0
  194. data/test/unit/utils/tc_priority_queue.rb +106 -0
  195. metadata +285 -0
@@ -0,0 +1,1007 @@
1
+ /**
2
+ @file posh.h
3
+ @author Brian Hook
4
+ @version 1.3.001
5
+
6
+ Header file for POSH, the Portable Open Source Harness project.
7
+
8
+ NOTE: Unlike most header files, this one is designed to be included
9
+ multiple times, which is why it does not have the @#ifndef/@#define
10
+ preamble.
11
+
12
+ POSH relies on environment specified preprocessor symbols in order
13
+ to infer as much as possible about the target OS/architecture and
14
+ the host compiler capabilities.
15
+
16
+ NOTE: POSH is simple and focused. It attempts to provide basic
17
+ functionality and information, but it does NOT attempt to emulate
18
+ missing functionality. I am also not willing to make POSH dirty
19
+ and hackish to support truly ancient and/or outmoded and/or bizarre
20
+ technologies such as non-ANSI compilers, systems with non-IEEE
21
+ floating point formats, segmented 16-bit operating systems, etc.
22
+
23
+ Please refer to the accompanying HTML documentation or visit
24
+ http://www.poshlib.org for more information on how to use POSH.
25
+
26
+ LICENSE:
27
+
28
+ Copyright (c) 2004, Brian Hook
29
+ All rights reserved.
30
+
31
+ Redistribution and use in source and binary forms, with or without
32
+ modification, are permitted provided that the following conditions are
33
+ met:
34
+
35
+ * Redistributions of source code must retain the above copyright
36
+ notice, this list of conditions and the following disclaimer.
37
+
38
+ * Redistributions in binary form must reproduce the above
39
+ copyright notice, this list of conditions and the following
40
+ disclaimer in the documentation and/or other materials provided
41
+ with the distribution.
42
+
43
+ * The names of this package'ss contributors contributors may not
44
+ be used to endorse or promote products derived from this
45
+ software without specific prior written permission.
46
+
47
+
48
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
51
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
52
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
53
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
54
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
58
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59
+
60
+ REVISION:
61
+
62
+ I've been lax about revision histories, so this starts at, um, 1.3.001.
63
+ Sorry for any inconveniences.
64
+
65
+ 1.3.001 - 2/23/2006 - Incorporated fix for bug reported by Bill Cary,
66
+ where I was not detecting Visual Studio
67
+ compilation on x86-64 systems. Added check for
68
+ _M_X64 which should fix that.
69
+
70
+ */
71
+ /*
72
+ I have yet to find an authoritative reference on preprocessor
73
+ symbols, but so far this is what I've gleaned:
74
+
75
+ GNU GCC/G++:
76
+ - __GNUC__: GNU C version
77
+ - __GNUG__: GNU C++ compiler
78
+ - __sun__ : on Sun platforms
79
+ - __svr4__: on Solaris and other SysV R4 platforms
80
+ - __mips__: on MIPS processor platforms
81
+ - __sparc_v9__: on Sparc 64-bit CPUs
82
+ - __sparcv9: 64-bit Solaris
83
+ - __MIPSEL__: mips processor, compiled for little endian
84
+ - __MIPSEB__: mips processor, compiled for big endian
85
+ - _R5900: MIPS/Sony/Toshiba R5900 (PS2)
86
+ - mc68000: 68K
87
+ - m68000: 68K
88
+ - m68k: 68K
89
+ - __palmos__: PalmOS
90
+
91
+ Intel C/C++ Compiler:
92
+ - __ECC : compiler version, IA64 only
93
+ - __EDG__
94
+ - __ELF__
95
+ - __GXX_ABI_VERSION
96
+ - __i386 : IA-32 only
97
+ - __i386__ : IA-32 only
98
+ - i386 : IA-32 only
99
+ - __ia64 : IA-64 only
100
+ - __ia64__ : IA-64 only
101
+ - ia64 : IA-64 only
102
+ - __ICC : IA-32 only
103
+ - __INTEL_COMPILER : IA-32 or IA-64, newer versions only
104
+
105
+ Apple's C/C++ Compiler for OS X:
106
+ - __APPLE_CC__
107
+ - __APPLE__
108
+ - __BIG_ENDIAN__
109
+ - __APPLE__
110
+ - __ppc__
111
+ - __MACH__
112
+
113
+ DJGPP:
114
+ - __MSDOS__
115
+ - __unix__
116
+ - __unix
117
+ - __GNUC__
118
+ - __GO32
119
+ - DJGPP
120
+ - __i386, __i386, i386
121
+
122
+ Cray's C compiler:
123
+ - _ADDR64: if 64-bit pointers
124
+ - _UNICOS:
125
+ - __unix:
126
+
127
+ SGI's CC compiler predefines the following (and more) with -ansi:
128
+ - __sgi
129
+ - __unix
130
+ - __host_mips
131
+ - _SYSTYPE_SVR4
132
+ - __mips
133
+ - _MIPSEB
134
+ - anyone know if there is a predefined symbol for the compiler?!
135
+
136
+ MinGW:
137
+ - as GnuC but also defines _WIN32, __WIN32, WIN32, _X86_, __i386, __i386__, and several others
138
+ - __MINGW32__
139
+
140
+ Cygwin:
141
+ - as Gnu C, but also
142
+ - __unix__
143
+ - __CYGWIN32__
144
+
145
+ Microsoft Visual Studio predefines the following:
146
+ - _MSC_VER
147
+ - _WIN32: on Win32
148
+ - _M_IX6 (on x86 systems)
149
+ - _M_X64: on x86-64 systems
150
+ - _M_ALPHA (on DEC AXP systems)
151
+ - _SH3: WinCE, Hitachi SH-3
152
+ - _MIPS: WinCE, MIPS
153
+ - _ARM: WinCE, ARM
154
+
155
+ Sun's C Compiler:
156
+ - sun and _sun
157
+ - unix and _unix
158
+ - sparc and _sparc (SPARC systems only)
159
+ - i386 and _i386 (x86 systems only)
160
+ - __SVR4 (Solaris only)
161
+ - __sparcv9: 64-bit solaris
162
+ - __SUNPRO_C
163
+ - _LP64: defined in 64-bit LP64 mode, but only if <sys/types.h> is included
164
+
165
+ Borland C/C++ predefines the following:
166
+ - __BORLANDC__:
167
+
168
+ DEC/Compaq C/C++ on Alpha:
169
+ - __alpha
170
+ - __arch64__
171
+ - __unix__ (on Tru64 Unix)
172
+ - __osf__
173
+ - __DECC
174
+ - __DECCXX (C++ compilation)
175
+ - __DECC_VER
176
+ - __DECCXX_VER
177
+
178
+ IBM's AIX compiler:
179
+ - __64BIT__ if 64-bit mode
180
+ - _AIX
181
+ - __IBMC__: C compiler version
182
+ - __IBMCPP__: C++ compiler version
183
+ - _LONG_LONG: compiler allows long long
184
+
185
+ Watcom:
186
+ - __WATCOMC__
187
+ - __DOS__ : if targeting DOS
188
+ - __386__ : if 32-bit support
189
+ - __WIN32__ : if targetin 32-bit Windows
190
+
191
+ HP-UX C/C++ Compiler:
192
+ - __hpux
193
+ - __unix
194
+ - __hppa (on PA-RISC)
195
+ - __LP64__: if compiled in 64-bit mode
196
+
197
+ Metrowerks:
198
+ - __MWERKS__
199
+ - __powerpc__
200
+ - _powerc
201
+ - __MC68K__
202
+ - macintosh when compiling for MacOS
203
+ - __INTEL__ for x86 targets
204
+ - __POWERPC__
205
+
206
+ */
207
+
208
+ /*
209
+ ** ----------------------------------------------------------------------------
210
+ ** Include <limits.h> optionally
211
+ ** ----------------------------------------------------------------------------
212
+ */
213
+ #ifdef POSH_USE_LIMITS_H
214
+ # include <limits.h>
215
+ #endif
216
+
217
+ /*
218
+ ** ----------------------------------------------------------------------------
219
+ ** Determine compilation environment
220
+ ** ----------------------------------------------------------------------------
221
+ */
222
+ #if defined __ECC || defined __ICC || defined __INTEL_COMPILER
223
+ # define POSH_COMPILER_STRING "Intel C/C++"
224
+ # define POSH_COMPILER_INTEL 1
225
+ #endif
226
+
227
+ #if ( defined __host_mips || defined __sgi ) && !defined __GNUC__
228
+ # define POSH_COMPILER_STRING "MIPSpro C/C++"
229
+ # define POSH_COMPILER_MIPSPRO 1
230
+ #endif
231
+
232
+ #if defined __hpux && !defined __GNUC__
233
+ # define POSH_COMPILER_STRING "HP-UX CC"
234
+ # define POSH_COMPILER_HPCC 1
235
+ #endif
236
+
237
+ #if defined __GNUC__
238
+ # define POSH_COMPILER_STRING "Gnu GCC"
239
+ # define POSH_COMPILER_GCC 1
240
+ #endif
241
+
242
+ #if defined __APPLE_CC__
243
+ /* we don't define the compiler string here, let it be GNU */
244
+ # define POSH_COMPILER_APPLECC 1
245
+ #endif
246
+
247
+ #if defined __IBMC__ || defined __IBMCPP__
248
+ # define POSH_COMPILER_STRING "IBM C/C++"
249
+ # define POSH_COMPILER_IBM 1
250
+ #endif
251
+
252
+ #if defined _MSC_VER
253
+ # define POSH_COMPILER_STRING "Microsoft Visual C++"
254
+ # define POSH_COMPILER_MSVC 1
255
+ #endif
256
+
257
+ #if defined __SUNPRO_C
258
+ # define POSH_COMPILER_STRING "Sun Pro"
259
+ # define POSH_COMPILER_SUN 1
260
+ #endif
261
+
262
+ #if defined __BORLANDC__
263
+ # define POSH_COMPILER_STRING "Borland C/C++"
264
+ # define POSH_COMPILER_BORLAND 1
265
+ #endif
266
+
267
+ #if defined __MWERKS__
268
+ # define POSH_COMPILER_STRING "MetroWerks CodeWarrior"
269
+ # define POSH_COMPILER_METROWERKS 1
270
+ #endif
271
+
272
+ #if defined __DECC || defined __DECCXX
273
+ # define POSH_COMPILER_STRING "Compaq/DEC C/C++"
274
+ # define POSH_COMPILER_DEC 1
275
+ #endif
276
+
277
+ #if defined __WATCOMC__
278
+ # define POSH_COMPILER_STRING "Watcom C/C++"
279
+ # define POSH_COMPILER_WATCOM 1
280
+ #endif
281
+
282
+ #if !defined POSH_COMPILER_STRING
283
+ # define POSH_COMPILER_STRING "Unknown compiler"
284
+ #endif
285
+
286
+ /*
287
+ ** ----------------------------------------------------------------------------
288
+ ** Determine target operating system
289
+ ** ----------------------------------------------------------------------------
290
+ */
291
+ #if defined linux || defined __linux__
292
+ # define POSH_OS_LINUX 1
293
+ # define POSH_OS_STRING "Linux"
294
+ #endif
295
+
296
+ #if defined __CYGWIN32__
297
+ # define POSH_OS_CYGWIN32 1
298
+ # define POSH_OS_STRING "Cygwin"
299
+ #endif
300
+
301
+ #if defined GEKKO
302
+ # define POSH_OS_GAMECUBE
303
+ # define __powerpc__
304
+ # define POSH_OS_STRING "GameCube"
305
+ #endif
306
+
307
+ #if defined __MINGW32__
308
+ # define POSH_OS_MINGW 1
309
+ # define POSH_OS_STRING "MinGW"
310
+ #endif
311
+
312
+ #if defined GO32 && defined DJGPP && defined __MSDOS__
313
+ # define POSH_OS_GO32 1
314
+ # define POSH_OS_STRING "GO32/MS-DOS"
315
+ #endif
316
+
317
+ /* NOTE: make sure you use /bt=DOS if compiling for 32-bit DOS,
318
+ otherwise Watcom assumes host=target */
319
+ #if defined __WATCOMC__ && defined __386__ && defined __DOS__
320
+ # define POSH_OS_DOS32 1
321
+ # define POSH_OS_STRING "DOS/32-bit"
322
+ #endif
323
+
324
+ #if defined _UNICOS
325
+ # define POSH_OS_UNICOS 1
326
+ # define POSH_OS_STRING "UNICOS"
327
+ #endif
328
+
329
+ #if ( defined __MWERKS__ && defined __powerc && !defined macintosh ) || defined __APPLE_CC__ || defined macosx
330
+ # define POSH_OS_OSX 1
331
+ # define POSH_OS_STRING "MacOS X"
332
+ #endif
333
+
334
+ #if defined __sun__ || defined sun || defined __sun || defined __solaris__
335
+ # if defined __SVR4 || defined __svr4__ || defined __solaris__
336
+ # define POSH_OS_STRING "Solaris"
337
+ # define POSH_OS_SOLARIS 1
338
+ # endif
339
+ # if !defined POSH_OS_STRING
340
+ # define POSH_OS_STRING "SunOS"
341
+ # define POSH_OS_SUNOS 1
342
+ # endif
343
+ #endif
344
+
345
+ #if defined __sgi__ || defined sgi || defined __sgi
346
+ # define POSH_OS_IRIX 1
347
+ # define POSH_OS_STRING "Irix"
348
+ #endif
349
+
350
+ #if defined __hpux__ || defined __hpux
351
+ # define POSH_OS_HPUX 1
352
+ # define POSH_OS_STRING "HP-UX"
353
+ #endif
354
+
355
+ #if defined _AIX
356
+ # define POSH_OS_AIX 1
357
+ # define POSH_OS_STRING "AIX"
358
+ #endif
359
+
360
+ #if ( defined __alpha && defined __osf__ )
361
+ # define POSH_OS_TRU64 1
362
+ # define POSH_OS_STRING "Tru64"
363
+ #endif
364
+
365
+ #if defined __BEOS__ || defined __beos__
366
+ # define POSH_OS_BEOS 1
367
+ # define POSH_OS_STRING "BeOS"
368
+ #endif
369
+
370
+ #if defined amiga || defined amigados || defined AMIGA || defined _AMIGA
371
+ # define POSH_OS_AMIGA 1
372
+ # define POSH_OS_STRING "Amiga"
373
+ #endif
374
+
375
+ #if defined __unix__
376
+ # define POSH_OS_UNIX 1
377
+ # if !defined POSH_OS_STRING
378
+ # define POSH_OS_STRING "Unix-like(generic)"
379
+ # endif
380
+ #endif
381
+
382
+ #if defined _WIN32_WCE
383
+ # define POSH_OS_WINCE 1
384
+ # define POSH_OS_STRING "Windows CE"
385
+ #endif
386
+
387
+ #if defined _XBOX
388
+ # define POSH_OS_XBOX 1
389
+ # define POSH_OS_STRING "XBOX"
390
+ #endif
391
+
392
+ #if defined _WIN32 || defined WIN32 || defined __NT__ || defined __WIN32__
393
+ # define POSH_OS_WIN32 1
394
+ # if !defined POSH_OS_XBOX
395
+ # if defined _WIN64
396
+ # define POSH_OS_WIN64 1
397
+ # define POSH_OS_STRING "Win64"
398
+ # else
399
+ # if !defined POSH_OS_STRING
400
+ # define POSH_OS_STRING "Win32"
401
+ # endif
402
+ # endif
403
+ # endif
404
+ #endif
405
+
406
+ #if defined __palmos__
407
+ # define POSH_OS_PALM 1
408
+ # define POSH_OS_STRING "PalmOS"
409
+ #endif
410
+
411
+ #if defined THINK_C || defined macintosh
412
+ # define POSH_OS_MACOS 1
413
+ # define POSH_OS_STRING "MacOS"
414
+ #endif
415
+
416
+ /*
417
+ ** -----------------------------------------------------------------------------
418
+ ** Determine target CPU
419
+ ** -----------------------------------------------------------------------------
420
+ */
421
+
422
+ #if defined GEKKO
423
+ # define POSH_CPU_PPC750 1
424
+ # define POSH_CPU_STRING "IBM PowerPC 750 (NGC)"
425
+ #endif
426
+
427
+ #if defined mc68000 || defined m68k || defined __MC68K__ || defined m68000
428
+ # define POSH_CPU_68K 1
429
+ # define POSH_CPU_STRING "MC68000"
430
+ #endif
431
+
432
+ #if defined __PPC__ || defined __POWERPC__ || defined powerpc || defined _POWER || defined __ppc__ || defined __powerpc__
433
+ # define POSH_CPU_PPC 1
434
+ # if !defined POSH_CPU_STRING
435
+ # if defined __powerpc64__
436
+ # define POSH_CPU_STRING "PowerPC64"
437
+ # else
438
+ # define POSH_CPU_STRING "PowerPC"
439
+ # endif
440
+ # endif
441
+ #endif
442
+
443
+ #if defined _CRAYT3E || defined _CRAYMPP
444
+ # define POSH_CPU_CRAYT3E 1 /* target processor is a DEC Alpha 21164 used in a Cray T3E*/
445
+ # define POSH_CPU_STRING "Cray T3E (Alpha 21164)"
446
+ #endif
447
+
448
+ #if defined CRAY || defined _CRAY && !defined _CRAYT3E
449
+ # error Non-AXP Cray systems not supported
450
+ #endif
451
+
452
+ #if defined _SH3
453
+ # define POSH_CPU_SH3 1
454
+ # define POSH_CPU_STRING "Hitachi SH-3"
455
+ #endif
456
+
457
+ #if defined __sh4__ || defined __SH4__
458
+ # define POSH_CPU_SH3 1
459
+ # define POSH_CPU_SH4 1
460
+ # define POSH_CPU_STRING "Hitachi SH-4"
461
+ #endif
462
+
463
+ #if defined __sparc__ || defined __sparc
464
+ # if defined __arch64__ || defined __sparcv9 || defined __sparc_v9__
465
+ # define POSH_CPU_SPARC64 1
466
+ # define POSH_CPU_STRING "Sparc/64"
467
+ # else
468
+ # define POSH_CPU_STRING "Sparc/32"
469
+ # endif
470
+ # define POSH_CPU_SPARC 1
471
+ #endif
472
+
473
+ #if defined ARM || defined __arm__ || defined _ARM
474
+ # define POSH_CPU_STRONGARM 1
475
+ # define POSH_CPU_STRING "ARM"
476
+ #endif
477
+
478
+ #if defined mips || defined __mips__ || defined __MIPS__ || defined _MIPS
479
+ # define POSH_CPU_MIPS 1
480
+ # if defined _R5900
481
+ # define POSH_CPU_STRING "MIPS R5900 (PS2)"
482
+ # else
483
+ # define POSH_CPU_STRING "MIPS"
484
+ # endif
485
+ #endif
486
+
487
+ #if defined __ia64 || defined _M_IA64 || defined __ia64__
488
+ # define POSH_CPU_IA64 1
489
+ # define POSH_CPU_STRING "IA64"
490
+ #endif
491
+
492
+ #if defined __X86__ || defined __i386__ || defined i386 || defined _M_IX86 || defined __386__ || defined __x86_64__ || defined _M_X64
493
+ # define POSH_CPU_X86 1
494
+ # if defined __x86_64__ || defined _M_X64
495
+ # define POSH_CPU_X86_64 1
496
+ # endif
497
+ # if defined POSH_CPU_X86_64
498
+ # define POSH_CPU_STRING "AMD x86-64"
499
+ # else
500
+ # define POSH_CPU_STRING "Intel 386+"
501
+ # endif
502
+ #endif
503
+
504
+ #if defined __alpha || defined alpha || defined _M_ALPHA || defined __alpha__
505
+ # define POSH_CPU_AXP 1
506
+ # define POSH_CPU_STRING "AXP"
507
+ #endif
508
+
509
+ #if defined __hppa || defined hppa
510
+ # define POSH_CPU_HPPA 1
511
+ # define POSH_CPU_STRING "PA-RISC"
512
+ #endif
513
+
514
+ #if !defined POSH_CPU_STRING
515
+ # error POSH cannot determine target CPU
516
+ # define POSH_CPU_STRING "Unknown" /* this is here for Doxygen's benefit */
517
+ #endif
518
+
519
+ /*
520
+ ** -----------------------------------------------------------------------------
521
+ ** Attempt to autodetect building for embedded on Sony PS2
522
+ ** -----------------------------------------------------------------------------
523
+ */
524
+ #if !defined POSH_OS_STRING
525
+ # if !defined FORCE_DOXYGEN
526
+ # define POSH_OS_EMBEDDED 1
527
+ # endif
528
+ # if defined _R5900
529
+ # define POSH_OS_STRING "Sony PS2(embedded)"
530
+ # else
531
+ # define POSH_OS_STRING "Embedded/Unknown"
532
+ # endif
533
+ #endif
534
+
535
+ /*
536
+ ** ---------------------------------------------------------------------------
537
+ ** Handle cdecl, stdcall, fastcall, etc.
538
+ ** ---------------------------------------------------------------------------
539
+ */
540
+ #if defined POSH_CPU_X86 && !defined POSH_CPU_X86_64
541
+ # if defined __GNUC__
542
+ # define POSH_CDECL __attribute__((cdecl))
543
+ # define POSH_STDCALL __attribute__((stdcall))
544
+ # define POSH_FASTCALL __attribute__((fastcall))
545
+ # elif ( defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ || defined __MWERKS__ )
546
+ # define POSH_CDECL __cdecl
547
+ # define POSH_STDCALL __stdcall
548
+ # define POSH_FASTCALL __fastcall
549
+ # endif
550
+ #else
551
+ # define POSH_CDECL
552
+ # define POSH_STDCALL
553
+ # define POSH_FASTCALL
554
+ #endif
555
+
556
+ /*
557
+ ** ---------------------------------------------------------------------------
558
+ ** Define POSH_IMPORTEXPORT signature based on POSH_DLL and POSH_BUILDING_LIB
559
+ ** ---------------------------------------------------------------------------
560
+ */
561
+
562
+ /*
563
+ ** We undefine this so that multiple inclusions will work
564
+ */
565
+ #if defined POSH_IMPORTEXPORT
566
+ # undef POSH_IMPORTEXPORT
567
+ #endif
568
+
569
+ #if defined POSH_DLL
570
+ # if defined POSH_OS_WIN32
571
+ # if defined _MSC_VER
572
+ # if ( _MSC_VER >= 800 )
573
+ # if defined POSH_BUILDING_LIB
574
+ # define POSH_IMPORTEXPORT __declspec( dllexport )
575
+ # else
576
+ # define POSH_IMPORTEXPORT __declspec( dllimport )
577
+ # endif
578
+ # else
579
+ # if defined POSH_BUILDING_LIB
580
+ # define POSH_IMPORTEXPORT __export
581
+ # else
582
+ # define POSH_IMPORTEXPORT
583
+ # endif
584
+ # endif
585
+ # endif /* defined _MSC_VER */
586
+ # if defined __BORLANDC__
587
+ # if ( __BORLANDC__ >= 0x500 )
588
+ # if defined POSH_BUILDING_LIB
589
+ # define POSH_IMPORTEXPORT __declspec( dllexport )
590
+ # else
591
+ # define POSH_IMPORTEXPORT __declspec( dllimport )
592
+ # endif
593
+ # else
594
+ # if defined POSH_BUILDING_LIB
595
+ # define POSH_IMPORTEXPORT __export
596
+ # else
597
+ # define POSH_IMPORTEXPORT
598
+ # endif
599
+ # endif
600
+ # endif /* defined __BORLANDC__ */
601
+ /* for all other compilers, we're just making a blanket assumption */
602
+ # if defined __GNUC__ || defined __WATCOMC__ || defined __MWERKS__
603
+ # if defined POSH_BUILDING_LIB
604
+ # define POSH_IMPORTEXPORT __declspec( dllexport )
605
+ # else
606
+ # define POSH_IMPORTEXPORT __declspec( dllimport )
607
+ # endif
608
+ # endif /* all other compilers */
609
+ # if !defined POSH_IMPORTEXPORT
610
+ # error Building DLLs not supported on this compiler (poshlib@poshlib.org if you know how)
611
+ # endif
612
+ # endif /* defined POSH_OS_WIN32 */
613
+ #endif
614
+
615
+ /* On pretty much everything else, we can thankfully just ignore this */
616
+ #if !defined POSH_IMPORTEXPORT
617
+ # define POSH_IMPORTEXPORT
618
+ #endif
619
+
620
+ #if defined FORCE_DOXYGEN
621
+ # define POSH_DLL
622
+ # define POSH_BUILDING_LIB
623
+ # undef POSH_DLL
624
+ # undef POSH_BUILDING_LIB
625
+ #endif
626
+
627
+ /*
628
+ ** ----------------------------------------------------------------------------
629
+ ** (Re)define POSH_PUBLIC_API export signature
630
+ ** ----------------------------------------------------------------------------
631
+ */
632
+ #ifdef POSH_PUBLIC_API
633
+ # undef POSH_PUBLIC_API
634
+ #endif
635
+
636
+ #if ( ( defined _MSC_VER ) && ( _MSC_VER < 800 ) ) || ( defined __BORLANDC__ && ( __BORLANDC__ < 0x500 ) )
637
+ # define POSH_PUBLIC_API(rtype) extern rtype POSH_IMPORTEXPORT
638
+ #else
639
+ # define POSH_PUBLIC_API(rtype) extern POSH_IMPORTEXPORT rtype
640
+ #endif
641
+
642
+ /*
643
+ ** ----------------------------------------------------------------------------
644
+ ** Try to infer endianess. Basically we just go through the CPUs we know are
645
+ ** little endian, and assume anything that isn't one of those is big endian.
646
+ ** As a sanity check, we also do this with operating systems we know are
647
+ ** little endian, such as Windows. Some processors are bi-endian, such as
648
+ ** the MIPS series, so we have to be careful about those.
649
+ ** ----------------------------------------------------------------------------
650
+ */
651
+ #if defined POSH_CPU_X86 || defined POSH_CPU_AXP || defined POSH_CPU_STRONGARM || defined POSH_OS_WIN32 || defined POSH_OS_WINCE || defined __MIPSEL__
652
+ # define POSH_ENDIAN_STRING "little"
653
+ # define POSH_LITTLE_ENDIAN 1
654
+ #else
655
+ # define POSH_ENDIAN_STRING "big"
656
+ # define POSH_BIG_ENDIAN 1
657
+ #endif
658
+
659
+ #if defined FORCE_DOXYGEN
660
+ # define POSH_LITTLE_ENDIAN
661
+ #endif
662
+
663
+ /*
664
+ ** ----------------------------------------------------------------------------
665
+ ** Cross-platform compile time assertion macro
666
+ ** ----------------------------------------------------------------------------
667
+ */
668
+ #define POSH_COMPILE_TIME_ASSERT(name, x) typedef int _POSH_dummy_ ## name[(x) ? 1 : -1 ]
669
+
670
+ /*
671
+ ** ----------------------------------------------------------------------------
672
+ ** 64-bit Integer
673
+ **
674
+ ** We don't require 64-bit support, nor do we emulate its functionality, we
675
+ ** simply export it if it's available. Since we can't count on <limits.h>
676
+ ** for 64-bit support, we ignore the POSH_USE_LIMITS_H directive.
677
+ ** ----------------------------------------------------------------------------
678
+ */
679
+ #if defined ( __LP64__ ) || defined ( __powerpc64__ ) || defined POSH_CPU_SPARC64
680
+ # define POSH_64BIT_INTEGER 1
681
+ typedef long posh_i64_t;
682
+ typedef unsigned long posh_u64_t;
683
+ # define POSH_I64( x ) ((posh_i64_t)x)
684
+ # define POSH_U64( x ) ((posh_u64_t)x)
685
+ # define POSH_I64_PRINTF_PREFIX "l"
686
+ #elif defined _MSC_VER || defined __BORLANDC__ || defined __WATCOMC__ || ( defined __alpha && defined __DECC )
687
+ # define POSH_64BIT_INTEGER 1
688
+ typedef __int64 posh_i64_t;
689
+ typedef unsigned __int64 posh_u64_t;
690
+ # define POSH_I64( x ) ((posh_i64_t)x)
691
+ # define POSH_U64( x ) ((posh_u64_t)x)
692
+ # define POSH_I64_PRINTF_PREFIX "I64"
693
+ #elif defined __GNUC__ || defined __MWERKS__ || defined __SUNPRO_C || defined __SUNPRO_CC || defined __APPLE_CC__ || defined POSH_OS_IRIX || defined _LONG_LONG || defined _CRAYC
694
+ # define POSH_64BIT_INTEGER 1
695
+ typedef long long posh_i64_t;
696
+ typedef unsigned long long posh_u64_t;
697
+ # define POSH_U64( x ) ((posh_u64_t)(x##LL))
698
+ # define POSH_I64( x ) ((posh_i64_t)(x##LL))
699
+ # define POSH_I64_PRINTF_PREFIX "ll"
700
+ #endif
701
+
702
+ /* hack */
703
+ #ifdef __MINGW32__
704
+ #undef POSH_I64
705
+ #undef POSH_U64
706
+ #undef POSH_I64_PRINTF_PREFIX
707
+ #define POSH_I64( x ) ((posh_i64_t)x)
708
+ #define POSH_U64( x ) ((posh_u64_t)x)
709
+ #define POSH_I64_PRINTF_PREFIX "I64"
710
+ #endif
711
+
712
+ #ifdef FORCE_DOXYGEN
713
+ typedef long long posh_i64_t;
714
+ typedef unsigned long posh_u64_t;
715
+ # define POSH_64BIT_INTEGER
716
+ # define POSH_I64_PRINTF_PREFIX
717
+ # define POSH_I64(x)
718
+ # define POSH_U64(x)
719
+ #endif
720
+
721
+ /** Minimum value for a 64-bit signed integer */
722
+ #define POSH_I64_MIN POSH_I64(0x8000000000000000)
723
+ /** Maximum value for a 64-bit signed integer */
724
+ #define POSH_I64_MAX POSH_I64(0x7FFFFFFFFFFFFFFF)
725
+ /** Minimum value for a 64-bit unsigned integer */
726
+ #define POSH_U64_MIN POSH_U64(0)
727
+ /** Maximum value for a 64-bit unsigned integer */
728
+ #define POSH_U64_MAX POSH_U64(0xFFFFFFFFFFFFFFFF)
729
+
730
+ /* ----------------------------------------------------------------------------
731
+ ** Basic Sized Types
732
+ **
733
+ ** These types are expected to be EXACTLY sized so you can use them for
734
+ ** serialization.
735
+ ** ----------------------------------------------------------------------------
736
+ */
737
+ #define POSH_FALSE 0
738
+ #define POSH_TRUE 1
739
+
740
+ typedef int posh_bool_t;
741
+ typedef unsigned char posh_byte_t;
742
+
743
+ /* NOTE: These assume that CHAR_BIT is 8!! */
744
+ typedef unsigned char posh_u8_t;
745
+ typedef signed char posh_i8_t;
746
+
747
+ #if defined POSH_USE_LIMITS_H
748
+ # if CHAR_BITS > 8
749
+ # error This machine uses 9-bit characters. This is a warning, you can comment this out now.
750
+ # endif /* CHAR_BITS > 8 */
751
+
752
+ /* 16-bit */
753
+ # if ( USHRT_MAX == 65535 )
754
+ typedef unsigned short posh_u16_t;
755
+ typedef short posh_i16_t;
756
+ # else
757
+ /* Yes, in theory there could still be a 16-bit character type and shorts are
758
+ 32-bits in size...if you find such an architecture, let me know =P */
759
+ # error No 16-bit type found
760
+ # endif
761
+
762
+ /* 32-bit */
763
+ # if ( INT_MAX == 2147483647 )
764
+ typedef unsigned posh_u32_t;
765
+ typedef int posh_i32_t;
766
+ # elif ( LONG_MAX == 2147483647 )
767
+ typedef unsigned long posh_u32_t;
768
+ typedef long posh_i32_t;
769
+ # else
770
+ error No 32-bit type found
771
+ # endif
772
+
773
+ #else /* POSH_USE_LIMITS_H */
774
+
775
+ typedef unsigned short posh_u16_t;
776
+ typedef short posh_i16_t;
777
+
778
+ # if !defined POSH_OS_PALM
779
+ typedef unsigned posh_u32_t;
780
+ typedef int posh_i32_t;
781
+ # else
782
+ typedef unsigned long posh_u32_t;
783
+ typedef long posh_i32_t;
784
+ # endif
785
+ #endif
786
+
787
+ /** Minimum value for a byte */
788
+ #define POSH_BYTE_MIN 0
789
+ /** Maximum value for an 8-bit unsigned value */
790
+ #define POSH_BYTE_MAX 255
791
+ /** Minimum value for a byte */
792
+ #define POSH_I16_MIN ( ( posh_i16_t ) 0x8000 )
793
+ /** Maximum value for a 16-bit signed value */
794
+ #define POSH_I16_MAX ( ( posh_i16_t ) 0x7FFF )
795
+ /** Minimum value for a 16-bit unsigned value */
796
+ #define POSH_U16_MIN 0
797
+ /** Maximum value for a 16-bit unsigned value */
798
+ #define POSH_U16_MAX ( ( posh_u16_t ) 0xFFFF )
799
+ /** Minimum value for a 32-bit signed value */
800
+ #define POSH_I32_MIN ( ( posh_i32_t ) 0x80000000 )
801
+ /** Maximum value for a 32-bit signed value */
802
+ #define POSH_I32_MAX ( ( posh_i32_t ) 0x7FFFFFFF )
803
+ /** Minimum value for a 32-bit unsigned value */
804
+ #define POSH_U32_MIN 0
805
+ /** Maximum value for a 32-bit unsigned value */
806
+ #define POSH_U32_MAX ( ( posh_u32_t ) 0xFFFFFFFF )
807
+
808
+ /*
809
+ ** ----------------------------------------------------------------------------
810
+ ** Sanity checks on expected sizes
811
+ ** ----------------------------------------------------------------------------
812
+ */
813
+ #if !defined FORCE_DOXYGEN
814
+
815
+ POSH_COMPILE_TIME_ASSERT(posh_byte_t, sizeof(posh_byte_t) == 1);
816
+ POSH_COMPILE_TIME_ASSERT(posh_u8_t, sizeof(posh_u8_t) == 1);
817
+ POSH_COMPILE_TIME_ASSERT(posh_i8_t, sizeof(posh_i8_t) == 1);
818
+ POSH_COMPILE_TIME_ASSERT(posh_u16_t, sizeof(posh_u16_t) == 2);
819
+ POSH_COMPILE_TIME_ASSERT(posh_i16_t, sizeof(posh_i16_t) == 2);
820
+ POSH_COMPILE_TIME_ASSERT(posh_u32_t, sizeof(posh_u32_t) == 4);
821
+ POSH_COMPILE_TIME_ASSERT(posh_i32_t, sizeof(posh_i32_t) == 4);
822
+
823
+ #if !defined POSH_NO_FLOAT
824
+ POSH_COMPILE_TIME_ASSERT(posh_testfloat_t, sizeof(float)==4 );
825
+ POSH_COMPILE_TIME_ASSERT(posh_testdouble_t, sizeof(double)==8);
826
+ #endif
827
+
828
+ #if defined POSH_64BIT_INTEGER
829
+ POSH_COMPILE_TIME_ASSERT(posh_u64_t, sizeof(posh_u64_t) == 8);
830
+ POSH_COMPILE_TIME_ASSERT(posh_i64_t, sizeof(posh_i64_t) == 8);
831
+ #endif
832
+
833
+ #endif
834
+
835
+ /*
836
+ ** ----------------------------------------------------------------------------
837
+ ** 64-bit pointer support
838
+ ** ----------------------------------------------------------------------------
839
+ */
840
+ #if defined POSH_CPU_AXP && ( defined POSH_OS_TRU64 || defined POSH_OS_LINUX )
841
+ # define POSH_64BIT_POINTER 1
842
+ #endif
843
+
844
+ #if defined POSH_CPU_X86_64 && defined POSH_OS_LINUX
845
+ # define POSH_64BIT_POINTER 1
846
+ #endif
847
+
848
+ #if defined POSH_CPU_SPARC64 || defined POSH_OS_WIN64 || defined __64BIT__ || defined __LP64 || defined _LP64 || defined __LP64__ || defined _ADDR64 || defined _CRAYC
849
+ # define POSH_64BIT_POINTER 1
850
+ #endif
851
+
852
+ #if defined POSH_64BIT_POINTER
853
+ POSH_COMPILE_TIME_ASSERT( posh_64bit_pointer, sizeof( void * ) == 8 );
854
+ #elif !defined FORCE_DOXYGEN
855
+ /* if this assertion is hit then you're on a system that either has 64-bit
856
+ addressing and we didn't catch it, or you're on a system with 16-bit
857
+ pointers. In the latter case, POSH doesn't actually care, we're just
858
+ triggering this assertion to make sure you're aware of the situation,
859
+ so feel free to delete it.
860
+
861
+ If this assertion is triggered on a known 32 or 64-bit platform,
862
+ please let us know (poshlib@poshlib.org) */
863
+ POSH_COMPILE_TIME_ASSERT( posh_32bit_pointer, sizeof( void * ) == 4 );
864
+ #endif
865
+
866
+ #if defined FORCE_DOXYGEN
867
+ # define POSH_64BIT_POINTER
868
+ #endif
869
+
870
+ /*
871
+ ** ----------------------------------------------------------------------------
872
+ ** POSH Utility Functions
873
+ **
874
+ ** These are optional POSH utility functions that are not required if you don't
875
+ ** need anything except static checking of your host and target environment.
876
+ **
877
+ ** These functions are NOT wrapped with POSH_PUBLIC_API because I didn't want
878
+ ** to enforce their export if your own library is only using them internally.
879
+ ** ----------------------------------------------------------------------------
880
+ */
881
+ #ifdef __cplusplus
882
+ extern "C" {
883
+ #endif
884
+
885
+ const char *POSH_GetArchString( void );
886
+
887
+ #if !defined POSH_NO_FLOAT
888
+
889
+ posh_u32_t POSH_LittleFloatBits( float f );
890
+ posh_u32_t POSH_BigFloatBits( float f );
891
+ float POSH_FloatFromLittleBits( posh_u32_t bits );
892
+ float POSH_FloatFromBigBits( posh_u32_t bits );
893
+
894
+ void POSH_DoubleBits( double d, posh_byte_t dst[ 8 ] );
895
+ double POSH_DoubleFromBits( const posh_byte_t src[ 8 ] );
896
+
897
+ /* unimplemented
898
+ float *POSH_WriteFloatToLittle( void *dst, float f );
899
+ float *POSH_WriteFloatToBig( void *dst, float f );
900
+ float POSH_ReadFloatFromLittle( const void *src );
901
+ float POSH_ReadFloatFromBig( const void *src );
902
+
903
+ double *POSH_WriteDoubleToLittle( void *dst, double d );
904
+ double *POSH_WriteDoubleToBig( void *dst, double d );
905
+ double POSH_ReadDoubleFromLittle( const void *src );
906
+ double POSH_ReadDoubleFromBig( const void *src );
907
+ */
908
+ #endif /* !defined POSH_NO_FLOAT */
909
+
910
+ #if defined FORCE_DOXYGEN
911
+ # define POSH_NO_FLOAT
912
+ # undef POSH_NO_FLOAT
913
+ #endif
914
+
915
+ extern posh_u16_t POSH_SwapU16( posh_u16_t u );
916
+ extern posh_i16_t POSH_SwapI16( posh_i16_t u );
917
+ extern posh_u32_t POSH_SwapU32( posh_u32_t u );
918
+ extern posh_i32_t POSH_SwapI32( posh_i32_t u );
919
+
920
+ #if defined POSH_64BIT_INTEGER
921
+
922
+ extern posh_u64_t POSH_SwapU64( posh_u64_t u );
923
+ extern posh_i64_t POSH_SwapI64( posh_i64_t u );
924
+
925
+ #endif /*POSH_64BIT_INTEGER */
926
+
927
+ extern posh_u16_t *POSH_WriteU16ToLittle( void *dst, posh_u16_t value );
928
+ extern posh_i16_t *POSH_WriteI16ToLittle( void *dst, posh_i16_t value );
929
+ extern posh_u32_t *POSH_WriteU32ToLittle( void *dst, posh_u32_t value );
930
+ extern posh_i32_t *POSH_WriteI32ToLittle( void *dst, posh_i32_t value );
931
+
932
+ extern posh_u16_t *POSH_WriteU16ToBig( void *dst, posh_u16_t value );
933
+ extern posh_i16_t *POSH_WriteI16ToBig( void *dst, posh_i16_t value );
934
+ extern posh_u32_t *POSH_WriteU32ToBig( void *dst, posh_u32_t value );
935
+ extern posh_i32_t *POSH_WriteI32ToBig( void *dst, posh_i32_t value );
936
+
937
+ extern posh_u16_t POSH_ReadU16FromLittle( const void *src );
938
+ extern posh_i16_t POSH_ReadI16FromLittle( const void *src );
939
+ extern posh_u32_t POSH_ReadU32FromLittle( const void *src );
940
+ extern posh_i32_t POSH_ReadI32FromLittle( const void *src );
941
+
942
+ extern posh_u16_t POSH_ReadU16FromBig( const void *src );
943
+ extern posh_i16_t POSH_ReadI16FromBig( const void *src );
944
+ extern posh_u32_t POSH_ReadU32FromBig( const void *src );
945
+ extern posh_i32_t POSH_ReadI32FromBig( const void *src );
946
+
947
+ #if defined POSH_64BIT_INTEGER
948
+ extern posh_u64_t *POSH_WriteU64ToLittle( void *dst, posh_u64_t value );
949
+ extern posh_i64_t *POSH_WriteI64ToLittle( void *dst, posh_i64_t value );
950
+ extern posh_u64_t *POSH_WriteU64ToBig( void *dst, posh_u64_t value );
951
+ extern posh_i64_t *POSH_WriteI64ToBig( void *dst, posh_i64_t value );
952
+
953
+ extern posh_u64_t POSH_ReadU64FromLittle( const void *src );
954
+ extern posh_i64_t POSH_ReadI64FromLittle( const void *src );
955
+ extern posh_u64_t POSH_ReadU64FromBig( const void *src );
956
+ extern posh_i64_t POSH_ReadI64FromBig( const void *src );
957
+ #endif /* POSH_64BIT_INTEGER */
958
+
959
+ #if defined POSH_LITTLE_ENDIAN
960
+
961
+ # define POSH_LittleU16(x) (x)
962
+ # define POSH_LittleU32(x) (x)
963
+ # define POSH_LittleI16(x) (x)
964
+ # define POSH_LittleI32(x) (x)
965
+ # if defined POSH_64BIT_INTEGER
966
+ # define POSH_LittleU64(x) (x)
967
+ # define POSH_LittleI64(x) (x)
968
+ # endif /* defined POSH_64BIT_INTEGER */
969
+
970
+ # define POSH_BigU16(x) POSH_SwapU16(x)
971
+ # define POSH_BigU32(x) POSH_SwapU32(x)
972
+ # define POSH_BigI16(x) POSH_SwapI16(x)
973
+ # define POSH_BigI32(x) POSH_SwapI32(x)
974
+ # if defined POSH_64BIT_INTEGER
975
+ # define POSH_BigU64(x) POSH_SwapU64(x)
976
+ # define POSH_BigI64(x) POSH_SwapI64(x)
977
+ # endif /* defined POSH_64BIT_INTEGER */
978
+
979
+ #else
980
+
981
+ # define POSH_BigU16(x) (x)
982
+ # define POSH_BigU32(x) (x)
983
+ # define POSH_BigI16(x) (x)
984
+ # define POSH_BigI32(x) (x)
985
+
986
+ # if defined POSH_64BIT_INTEGER
987
+ # define POSH_BigU64(x) (x)
988
+ # define POSH_BigI64(x) (x)
989
+ # endif /* POSH_64BIT_INTEGER */
990
+
991
+ # define POSH_LittleU16(x) POSH_SwapU16(x)
992
+ # define POSH_LittleU32(x) POSH_SwapU32(x)
993
+ # define POSH_LittleI16(x) POSH_SwapI16(x)
994
+ # define POSH_LittleI32(x) POSH_SwapI32(x)
995
+
996
+ # if defined POSH_64BIT_INTEGER
997
+ # define POSH_LittleU64(x) POSH_SwapU64(x)
998
+ # define POSH_LittleI64(x) POSH_SwapI64(x)
999
+ # endif /* POSH_64BIT_INTEGER */
1000
+
1001
+ #endif
1002
+
1003
+ #ifdef __cplusplus
1004
+ }
1005
+ #endif
1006
+
1007
+