jk-ferret 0.11.8.2

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