isomorfeus-ferret 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +612 -0
  3. data/README.md +44 -0
  4. data/ext/isomorfeus_ferret_ext/benchmark.c +223 -0
  5. data/ext/isomorfeus_ferret_ext/benchmark.h +45 -0
  6. data/ext/isomorfeus_ferret_ext/benchmarks_all.h +25 -0
  7. data/ext/isomorfeus_ferret_ext/bm_bitvector.c +123 -0
  8. data/ext/isomorfeus_ferret_ext/bm_hash.c +118 -0
  9. data/ext/isomorfeus_ferret_ext/bm_micro_string.c +40 -0
  10. data/ext/isomorfeus_ferret_ext/bm_store.c +93 -0
  11. data/ext/isomorfeus_ferret_ext/email.rl +21 -0
  12. data/ext/isomorfeus_ferret_ext/extconf.rb +5 -0
  13. data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -0
  14. data/ext/isomorfeus_ferret_ext/frb_analysis.c +2577 -0
  15. data/ext/isomorfeus_ferret_ext/frb_index.c +3457 -0
  16. data/ext/isomorfeus_ferret_ext/frb_lang.c +9 -0
  17. data/ext/isomorfeus_ferret_ext/frb_lang.h +17 -0
  18. data/ext/isomorfeus_ferret_ext/frb_qparser.c +629 -0
  19. data/ext/isomorfeus_ferret_ext/frb_search.c +4460 -0
  20. data/ext/isomorfeus_ferret_ext/frb_store.c +515 -0
  21. data/ext/isomorfeus_ferret_ext/frb_threading.h +30 -0
  22. data/ext/isomorfeus_ferret_ext/frb_utils.c +1127 -0
  23. data/ext/isomorfeus_ferret_ext/frt_analysis.c +1644 -0
  24. data/ext/isomorfeus_ferret_ext/frt_analysis.h +247 -0
  25. data/ext/isomorfeus_ferret_ext/frt_array.c +124 -0
  26. data/ext/isomorfeus_ferret_ext/frt_array.h +54 -0
  27. data/ext/isomorfeus_ferret_ext/frt_bitvector.c +95 -0
  28. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +586 -0
  29. data/ext/isomorfeus_ferret_ext/frt_compound_io.c +374 -0
  30. data/ext/isomorfeus_ferret_ext/frt_config.h +44 -0
  31. data/ext/isomorfeus_ferret_ext/frt_document.c +134 -0
  32. data/ext/isomorfeus_ferret_ext/frt_document.h +52 -0
  33. data/ext/isomorfeus_ferret_ext/frt_except.c +95 -0
  34. data/ext/isomorfeus_ferret_ext/frt_except.h +188 -0
  35. data/ext/isomorfeus_ferret_ext/frt_field_index.c +233 -0
  36. data/ext/isomorfeus_ferret_ext/frt_field_index.h +42 -0
  37. data/ext/isomorfeus_ferret_ext/frt_filter.c +157 -0
  38. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +502 -0
  39. data/ext/isomorfeus_ferret_ext/frt_global.c +427 -0
  40. data/ext/isomorfeus_ferret_ext/frt_global.h +290 -0
  41. data/ext/isomorfeus_ferret_ext/frt_hash.c +518 -0
  42. data/ext/isomorfeus_ferret_ext/frt_hash.h +466 -0
  43. data/ext/isomorfeus_ferret_ext/frt_hashset.c +191 -0
  44. data/ext/isomorfeus_ferret_ext/frt_hashset.h +206 -0
  45. data/ext/isomorfeus_ferret_ext/frt_helper.c +62 -0
  46. data/ext/isomorfeus_ferret_ext/frt_helper.h +13 -0
  47. data/ext/isomorfeus_ferret_ext/frt_ind.c +353 -0
  48. data/ext/isomorfeus_ferret_ext/frt_ind.h +54 -0
  49. data/ext/isomorfeus_ferret_ext/frt_index.c +6377 -0
  50. data/ext/isomorfeus_ferret_ext/frt_index.h +880 -0
  51. data/ext/isomorfeus_ferret_ext/frt_lang.c +104 -0
  52. data/ext/isomorfeus_ferret_ext/frt_lang.h +44 -0
  53. data/ext/isomorfeus_ferret_ext/frt_mempool.c +87 -0
  54. data/ext/isomorfeus_ferret_ext/frt_mempool.h +33 -0
  55. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +349 -0
  56. data/ext/isomorfeus_ferret_ext/frt_multimapper.h +52 -0
  57. data/ext/isomorfeus_ferret_ext/frt_posh.c +1006 -0
  58. data/ext/isomorfeus_ferret_ext/frt_posh.h +973 -0
  59. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.c +147 -0
  60. data/ext/isomorfeus_ferret_ext/frt_priorityqueue.h +147 -0
  61. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +1612 -0
  62. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +157 -0
  63. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +209 -0
  64. data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +281 -0
  65. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +147 -0
  66. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +672 -0
  67. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +3084 -0
  68. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +1182 -0
  69. data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +98 -0
  70. data/ext/isomorfeus_ferret_ext/frt_q_range.c +665 -0
  71. data/ext/isomorfeus_ferret_ext/frt_q_span.c +2386 -0
  72. data/ext/isomorfeus_ferret_ext/frt_q_term.c +311 -0
  73. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +166 -0
  74. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +460 -0
  75. data/ext/isomorfeus_ferret_ext/frt_scanner.c +899 -0
  76. data/ext/isomorfeus_ferret_ext/frt_scanner.h +28 -0
  77. data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +6705 -0
  78. data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +4419 -0
  79. data/ext/isomorfeus_ferret_ext/frt_search.c +1824 -0
  80. data/ext/isomorfeus_ferret_ext/frt_search.h +924 -0
  81. data/ext/isomorfeus_ferret_ext/frt_similarity.c +150 -0
  82. data/ext/isomorfeus_ferret_ext/frt_similarity.h +79 -0
  83. data/ext/isomorfeus_ferret_ext/frt_sort.c +796 -0
  84. data/ext/isomorfeus_ferret_ext/frt_stopwords.c +395 -0
  85. data/ext/isomorfeus_ferret_ext/frt_store.c +680 -0
  86. data/ext/isomorfeus_ferret_ext/frt_store.h +789 -0
  87. data/ext/isomorfeus_ferret_ext/frt_term_vectors.c +72 -0
  88. data/ext/isomorfeus_ferret_ext/frt_threading.h +23 -0
  89. data/ext/isomorfeus_ferret_ext/frt_win32.h +54 -0
  90. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +409 -0
  91. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +95 -0
  92. data/ext/isomorfeus_ferret_ext/libstemmer.c +93 -0
  93. data/ext/isomorfeus_ferret_ext/libstemmer.h +73 -0
  94. data/ext/isomorfeus_ferret_ext/q_parser.y +1366 -0
  95. data/ext/isomorfeus_ferret_ext/scanner.h +28 -0
  96. data/ext/isomorfeus_ferret_ext/scanner.in +43 -0
  97. data/ext/isomorfeus_ferret_ext/scanner.rl +84 -0
  98. data/ext/isomorfeus_ferret_ext/scanner_mb.rl +200 -0
  99. data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +85 -0
  100. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +324 -0
  101. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +7 -0
  102. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +610 -0
  103. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +6 -0
  104. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +1104 -0
  105. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +6 -0
  106. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +749 -0
  107. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +7 -0
  108. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +1233 -0
  109. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +6 -0
  110. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +490 -0
  111. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +6 -0
  112. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +1217 -0
  113. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +7 -0
  114. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +1052 -0
  115. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +6 -0
  116. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +283 -0
  117. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +6 -0
  118. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +735 -0
  119. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +6 -0
  120. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +1003 -0
  121. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +7 -0
  122. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +1079 -0
  123. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +6 -0
  124. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +293 -0
  125. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +6 -0
  126. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +984 -0
  127. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +6 -0
  128. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +686 -0
  129. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +6 -0
  130. data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.c +325 -0
  131. data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.h +6 -0
  132. data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.c +620 -0
  133. data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.h +6 -0
  134. data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.c +1111 -0
  135. data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.h +6 -0
  136. data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.c +754 -0
  137. data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.h +6 -0
  138. data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.c +1242 -0
  139. data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.h +6 -0
  140. data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.c +495 -0
  141. data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.h +6 -0
  142. data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.c +1220 -0
  143. data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.h +6 -0
  144. data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.c +1059 -0
  145. data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.h +6 -0
  146. data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.c +285 -0
  147. data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.h +6 -0
  148. data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.c +741 -0
  149. data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.h +6 -0
  150. data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.c +1009 -0
  151. data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.h +6 -0
  152. data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.c +990 -0
  153. data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.h +6 -0
  154. data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.c +680 -0
  155. data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.h +6 -0
  156. data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.c +1083 -0
  157. data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.h +6 -0
  158. data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.c +294 -0
  159. data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.h +6 -0
  160. data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.c +2191 -0
  161. data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.h +6 -0
  162. data/ext/isomorfeus_ferret_ext/stem_api.c +66 -0
  163. data/ext/isomorfeus_ferret_ext/stem_api.h +26 -0
  164. data/ext/isomorfeus_ferret_ext/stem_header.h +57 -0
  165. data/ext/isomorfeus_ferret_ext/stem_modules.h +190 -0
  166. data/ext/isomorfeus_ferret_ext/stem_modules.txt +50 -0
  167. data/ext/isomorfeus_ferret_ext/stem_utilities.c +478 -0
  168. data/ext/isomorfeus_ferret_ext/test.c +850 -0
  169. data/ext/isomorfeus_ferret_ext/test.h +416 -0
  170. data/ext/isomorfeus_ferret_ext/test_1710.c +63 -0
  171. data/ext/isomorfeus_ferret_ext/test_analysis.c +1221 -0
  172. data/ext/isomorfeus_ferret_ext/test_array.c +272 -0
  173. data/ext/isomorfeus_ferret_ext/test_bitvector.c +600 -0
  174. data/ext/isomorfeus_ferret_ext/test_compound_io.c +170 -0
  175. data/ext/isomorfeus_ferret_ext/test_document.c +156 -0
  176. data/ext/isomorfeus_ferret_ext/test_except.c +244 -0
  177. data/ext/isomorfeus_ferret_ext/test_fields.c +522 -0
  178. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +185 -0
  179. data/ext/isomorfeus_ferret_ext/test_filter.c +331 -0
  180. data/ext/isomorfeus_ferret_ext/test_fs_store.c +25 -0
  181. data/ext/isomorfeus_ferret_ext/test_global.c +299 -0
  182. data/ext/isomorfeus_ferret_ext/test_hash.c +485 -0
  183. data/ext/isomorfeus_ferret_ext/test_hashset.c +288 -0
  184. data/ext/isomorfeus_ferret_ext/test_helper.c +47 -0
  185. data/ext/isomorfeus_ferret_ext/test_highlighter.c +548 -0
  186. data/ext/isomorfeus_ferret_ext/test_index.c +2323 -0
  187. data/ext/isomorfeus_ferret_ext/test_lang.c +74 -0
  188. data/ext/isomorfeus_ferret_ext/test_mempool.c +102 -0
  189. data/ext/isomorfeus_ferret_ext/test_multimapper.c +64 -0
  190. data/ext/isomorfeus_ferret_ext/test_priorityqueue.c +213 -0
  191. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +84 -0
  192. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +61 -0
  193. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +241 -0
  194. data/ext/isomorfeus_ferret_ext/test_q_parser.c +464 -0
  195. data/ext/isomorfeus_ferret_ext/test_q_span.c +575 -0
  196. data/ext/isomorfeus_ferret_ext/test_ram_store.c +77 -0
  197. data/ext/isomorfeus_ferret_ext/test_search.c +1874 -0
  198. data/ext/isomorfeus_ferret_ext/test_segments.c +167 -0
  199. data/ext/isomorfeus_ferret_ext/test_similarity.c +25 -0
  200. data/ext/isomorfeus_ferret_ext/test_sort.c +333 -0
  201. data/ext/isomorfeus_ferret_ext/test_store.c +591 -0
  202. data/ext/isomorfeus_ferret_ext/test_store.h +3 -0
  203. data/ext/isomorfeus_ferret_ext/test_term.c +351 -0
  204. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +373 -0
  205. data/ext/isomorfeus_ferret_ext/test_test.c +83 -0
  206. data/ext/isomorfeus_ferret_ext/test_threading.c +188 -0
  207. data/ext/isomorfeus_ferret_ext/testhelper.c +561 -0
  208. data/ext/isomorfeus_ferret_ext/testhelper.h +25 -0
  209. data/ext/isomorfeus_ferret_ext/tests_all.h +87 -0
  210. data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +1854 -0
  211. data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +1999 -0
  212. data/ext/isomorfeus_ferret_ext/url.rl +27 -0
  213. data/ext/isomorfeus_ferret_ext/word_list.h +15156 -0
  214. data/lib/isomorfeus/ferret/document.rb +132 -0
  215. data/lib/isomorfeus/ferret/field_symbol.rb +85 -0
  216. data/lib/isomorfeus/ferret/index/field_infos.rb +48 -0
  217. data/lib/isomorfeus/ferret/index/index.rb +970 -0
  218. data/lib/isomorfeus/ferret/monitor.rb +323 -0
  219. data/lib/isomorfeus/ferret/stdlib_patches.rb +151 -0
  220. data/lib/isomorfeus/ferret/version.rb +5 -0
  221. data/lib/isomorfeus-ferret.rb +8 -0
  222. metadata +307 -0
@@ -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
+ # if defined _WIN64
312
+ # define POSH_OS_WIN64 1
313
+ # endif
314
+ #endif
315
+
316
+ #if (defined _WIN32 || defined WIN32 || defined __NT__ || defined __WIN32__) && !defined __MINGW32__
317
+ # define POSH_OS_WIN32 1
318
+ # if !defined POSH_OS_XBOX
319
+ # if defined _WIN64
320
+ # define POSH_OS_WIN64 1
321
+ # define POSH_OS_STRING "Win64"
322
+ # else
323
+ # if !defined POSH_OS_STRING
324
+ # define POSH_OS_STRING "Win32"
325
+ # endif
326
+ # endif
327
+ # endif
328
+ #endif
329
+
330
+ #if defined GO32 && defined DJGPP && defined __MSDOS__
331
+ # define POSH_OS_GO32 1
332
+ # define POSH_OS_STRING "GO32/MS-DOS"
333
+ #endif
334
+
335
+ /* NOTE: make sure you use /bt=DOS if compiling for 32-bit DOS,
336
+ otherwise Watcom assumes host=target */
337
+ #if defined __WATCOMC__ && defined __386__ && defined __DOS__
338
+ # define POSH_OS_DOS32 1
339
+ # define POSH_OS_STRING "DOS/32-bit"
340
+ #endif
341
+
342
+ #if defined _UNICOS
343
+ # define POSH_OS_UNICOS 1
344
+ # define POSH_OS_STRING "UNICOS"
345
+ #endif
346
+
347
+ #if ( defined __MWERKS__ && defined __powerc && !defined macintosh ) || defined __APPLE_CC__ || defined macosx
348
+ # define POSH_OS_OSX 1
349
+ # define POSH_OS_STRING "MacOS X"
350
+ #endif
351
+
352
+ #if defined __sun__ || defined sun || defined __sun || defined __solaris__
353
+ # if defined __SVR4 || defined __svr4__ || defined __solaris__
354
+ # define POSH_OS_STRING "Solaris"
355
+ # define POSH_OS_SOLARIS 1
356
+ # endif
357
+ # if !defined POSH_OS_STRING
358
+ # define POSH_OS_STRING "SunOS"
359
+ # define POSH_OS_SUNOS 1
360
+ # endif
361
+ #endif
362
+
363
+ #if defined __sgi__ || defined sgi || defined __sgi
364
+ # define POSH_OS_IRIX 1
365
+ # define POSH_OS_STRING "Irix"
366
+ #endif
367
+
368
+ #if defined __hpux__ || defined __hpux
369
+ # define POSH_OS_HPUX 1
370
+ # define POSH_OS_STRING "HP-UX"
371
+ #endif
372
+
373
+ #if defined _AIX
374
+ # define POSH_OS_AIX 1
375
+ # define POSH_OS_STRING "AIX"
376
+ #endif
377
+
378
+ #if ( defined __alpha && defined __osf__ )
379
+ # define POSH_OS_TRU64 1
380
+ # define POSH_OS_STRING "Tru64"
381
+ #endif
382
+
383
+ #if defined __BEOS__ || defined __beos__
384
+ # define POSH_OS_BEOS 1
385
+ # define POSH_OS_STRING "BeOS"
386
+ #endif
387
+
388
+ #if defined amiga || defined amigados || defined AMIGA || defined _AMIGA
389
+ # define POSH_OS_AMIGA 1
390
+ # define POSH_OS_STRING "Amiga"
391
+ #endif
392
+
393
+ #if defined __unix__
394
+ # define POSH_OS_UNIX 1
395
+ # if !defined POSH_OS_STRING
396
+ # define POSH_OS_STRING "Unix-like(generic)"
397
+ # endif
398
+ #endif
399
+
400
+ #if defined _WIN32_WCE
401
+ # define POSH_OS_WINCE 1
402
+ # define POSH_OS_STRING "Windows CE"
403
+ #endif
404
+
405
+ #if defined _XBOX
406
+ # define POSH_OS_XBOX 1
407
+ # define POSH_OS_STRING "XBOX"
408
+ #endif
409
+
410
+ #if defined __palmos__
411
+ # define POSH_OS_PALM 1
412
+ # define POSH_OS_STRING "PalmOS"
413
+ #endif
414
+
415
+ #if defined THINK_C || defined macintosh
416
+ # define POSH_OS_MACOS 1
417
+ # define POSH_OS_STRING "MacOS"
418
+ #endif
419
+
420
+ /*
421
+ ** -----------------------------------------------------------------------------
422
+ ** Determine target CPU
423
+ ** -----------------------------------------------------------------------------
424
+ */
425
+
426
+ #if defined GEKKO
427
+ # define POSH_CPU_PPC750 1
428
+ # define POSH_CPU_STRING "IBM PowerPC 750 (NGC)"
429
+ #endif
430
+
431
+ #if defined mc68000 || defined m68k || defined __MC68K__ || defined m68000
432
+ # define POSH_CPU_68K 1
433
+ # define POSH_CPU_STRING "MC68000"
434
+ #endif
435
+
436
+ #if defined __PPC__ || defined __POWERPC__ || defined powerpc || defined _POWER || defined __ppc__ || defined __powerpc__
437
+ # define POSH_CPU_PPC 1
438
+ # if !defined POSH_CPU_STRING
439
+ # if defined __powerpc64__
440
+ # define POSH_CPU_STRING "PowerPC64"
441
+ # else
442
+ # define POSH_CPU_STRING "PowerPC"
443
+ # endif
444
+ # endif
445
+ #endif
446
+
447
+ #if defined _CRAYT3E || defined _CRAYMPP
448
+ # define POSH_CPU_CRAYT3E 1 /* target processor is a DEC Alpha 21164 used in a Cray T3E*/
449
+ # define POSH_CPU_STRING "Cray T3E (Alpha 21164)"
450
+ #endif
451
+
452
+ #if defined CRAY || defined _CRAY && !defined _CRAYT3E
453
+ # error Non-AXP Cray systems not supported
454
+ #endif
455
+
456
+ #if defined _SH3
457
+ # define POSH_CPU_SH3 1
458
+ # define POSH_CPU_STRING "Hitachi SH-3"
459
+ #endif
460
+
461
+ #if defined __sh4__ || defined __SH4__
462
+ # define POSH_CPU_SH3 1
463
+ # define POSH_CPU_SH4 1
464
+ # define POSH_CPU_STRING "Hitachi SH-4"
465
+ #endif
466
+
467
+ #if defined __sparc__ || defined __sparc
468
+ # if defined __arch64__ || defined __sparcv9 || defined __sparc_v9__
469
+ # define POSH_CPU_SPARC64 1
470
+ # define POSH_CPU_STRING "Sparc/64"
471
+ # else
472
+ # define POSH_CPU_STRING "Sparc/32"
473
+ # endif
474
+ # define POSH_CPU_SPARC 1
475
+ #endif
476
+
477
+ #if defined ARM || defined __arm__ || defined _ARM
478
+ # define POSH_CPU_STRONGARM 1
479
+ # define POSH_CPU_STRING "ARM"
480
+ #endif
481
+
482
+ #if defined mips || defined __mips__ || defined __MIPS__ || defined _MIPS
483
+ # define POSH_CPU_MIPS 1
484
+ # if defined _R5900
485
+ # define POSH_CPU_STRING "MIPS R5900 (PS2)"
486
+ # else
487
+ # define POSH_CPU_STRING "MIPS"
488
+ # endif
489
+ #endif
490
+
491
+ #if defined __ia64 || defined _M_IA64 || defined __ia64__
492
+ # define POSH_CPU_IA64 1
493
+ # define POSH_CPU_STRING "IA64"
494
+ #endif
495
+
496
+ #if defined __X86__ || defined __i386__ || defined i386 || defined _M_IX86 || defined __386__ || defined __x86_64__ || defined _M_X64
497
+ # define POSH_CPU_X86 1
498
+ # if defined __x86_64__ || defined _M_X64
499
+ # define POSH_CPU_X86_64 1
500
+ # endif
501
+ # if defined POSH_CPU_X86_64
502
+ # define POSH_CPU_STRING "AMD x86-64"
503
+ # else
504
+ # define POSH_CPU_STRING "Intel 386+"
505
+ # endif
506
+ #endif
507
+
508
+ #if defined __alpha || defined alpha || defined _M_ALPHA || defined __alpha__
509
+ # define POSH_CPU_AXP 1
510
+ # define POSH_CPU_STRING "AXP"
511
+ #endif
512
+
513
+ #if defined __hppa || defined hppa
514
+ # define POSH_CPU_HPPA 1
515
+ # define POSH_CPU_STRING "PA-RISC"
516
+ #endif
517
+
518
+ #if !defined POSH_CPU_STRING
519
+ # error POSH cannot determine target CPU
520
+ # define POSH_CPU_STRING "Unknown" /* this is here for Doxygen's benefit */
521
+ #endif
522
+
523
+ /*
524
+ ** -----------------------------------------------------------------------------
525
+ ** Attempt to autodetect building for embedded on Sony PS2
526
+ ** -----------------------------------------------------------------------------
527
+ */
528
+ #if !defined POSH_OS_STRING
529
+ # define POSH_OS_EMBEDDED 1
530
+ # if defined _R5900
531
+ # define POSH_OS_STRING "Sony PS2(embedded)"
532
+ # else
533
+ # define POSH_OS_STRING "Embedded/Unknown"
534
+ # endif
535
+ #endif
536
+
537
+ /*
538
+ ** ---------------------------------------------------------------------------
539
+ ** Handle cdecl, stdcall, fastcall, etc.
540
+ ** ---------------------------------------------------------------------------
541
+ */
542
+ #if defined POSH_CPU_X86 && !defined POSH_CPU_X86_64
543
+ # if defined __GNUC__
544
+ # define POSH_CDECL __attribute__((cdecl))
545
+ # define POSH_STDCALL __attribute__((stdcall))
546
+ # define POSH_FASTCALL __attribute__((fastcall))
547
+ # elif ( defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ || defined __MWERKS__ )
548
+ # define POSH_CDECL __cdecl
549
+ # define POSH_STDCALL __stdcall
550
+ # define POSH_FASTCALL __fastcall
551
+ # endif
552
+ #else
553
+ # define POSH_CDECL
554
+ # define POSH_STDCALL
555
+ # define POSH_FASTCALL
556
+ #endif
557
+
558
+ /*
559
+ ** ---------------------------------------------------------------------------
560
+ ** Define POSH_IMPORTEXPORT signature based on POSH_DLL and POSH_BUILDING_LIB
561
+ ** ---------------------------------------------------------------------------
562
+ */
563
+
564
+ /*
565
+ ** We undefine this so that multiple inclusions will work
566
+ */
567
+ #if defined POSH_IMPORTEXPORT
568
+ # undef POSH_IMPORTEXPORT
569
+ #endif
570
+
571
+ #if defined POSH_DLL
572
+ # if defined POSH_OS_WIN32
573
+ # if defined _MSC_VER
574
+ # if ( _MSC_VER >= 800 )
575
+ # if defined POSH_BUILDING_LIB
576
+ # define POSH_IMPORTEXPORT __declspec( dllexport )
577
+ # else
578
+ # define POSH_IMPORTEXPORT __declspec( dllimport )
579
+ # endif
580
+ # else
581
+ # if defined POSH_BUILDING_LIB
582
+ # define POSH_IMPORTEXPORT __export
583
+ # else
584
+ # define POSH_IMPORTEXPORT
585
+ # endif
586
+ # endif
587
+ # endif /* defined _MSC_VER */
588
+ # if defined __BORLANDC__
589
+ # if ( __BORLANDC__ >= 0x500 )
590
+ # if defined POSH_BUILDING_LIB
591
+ # define POSH_IMPORTEXPORT __declspec( dllexport )
592
+ # else
593
+ # define POSH_IMPORTEXPORT __declspec( dllimport )
594
+ # endif
595
+ # else
596
+ # if defined POSH_BUILDING_LIB
597
+ # define POSH_IMPORTEXPORT __export
598
+ # else
599
+ # define POSH_IMPORTEXPORT
600
+ # endif
601
+ # endif
602
+ # endif /* defined __BORLANDC__ */
603
+ /* for all other compilers, we're just making a blanket assumption */
604
+ # if defined __GNUC__ || defined __WATCOMC__ || defined __MWERKS__
605
+ # if defined POSH_BUILDING_LIB
606
+ # define POSH_IMPORTEXPORT __declspec( dllexport )
607
+ # else
608
+ # define POSH_IMPORTEXPORT __declspec( dllimport )
609
+ # endif
610
+ # endif /* all other compilers */
611
+ # if !defined POSH_IMPORTEXPORT
612
+ # error Building DLLs not supported on this compiler (poshlib@poshlib.org if you know how)
613
+ # endif
614
+ # endif /* defined POSH_OS_WIN32 */
615
+ #endif
616
+
617
+ /* On pretty much everything else, we can thankfully just ignore this */
618
+ #if !defined POSH_IMPORTEXPORT
619
+ # define POSH_IMPORTEXPORT
620
+ #endif
621
+
622
+ /*
623
+ ** ----------------------------------------------------------------------------
624
+ ** (Re)define POSH_PUBLIC_API export signature
625
+ ** ----------------------------------------------------------------------------
626
+ */
627
+ #ifdef POSH_PUBLIC_API
628
+ # undef POSH_PUBLIC_API
629
+ #endif
630
+
631
+ #if ( ( defined _MSC_VER ) && ( _MSC_VER < 800 ) ) || ( defined __BORLANDC__ && ( __BORLANDC__ < 0x500 ) )
632
+ # define POSH_PUBLIC_API(rtype) extern rtype POSH_IMPORTEXPORT
633
+ #else
634
+ # define POSH_PUBLIC_API(rtype) extern POSH_IMPORTEXPORT rtype
635
+ #endif
636
+
637
+ /*
638
+ ** ----------------------------------------------------------------------------
639
+ ** Try to infer endianess. Basically we just go through the CPUs we know are
640
+ ** little endian, and assume anything that isn't one of those is big endian.
641
+ ** As a sanity check, we also do this with operating systems we know are
642
+ ** little endian, such as Windows. Some processors are bi-endian, such as
643
+ ** the MIPS series, so we have to be careful about those.
644
+ ** ----------------------------------------------------------------------------
645
+ */
646
+ #if defined POSH_CPU_X86 || defined POSH_CPU_AXP || defined POSH_CPU_STRONGARM || defined POSH_OS_WIN32 || defined POSH_OS_WIN64 || defined POSH_OS_WINCE || defined __MIPSEL__
647
+ # define POSH_ENDIAN_STRING "little"
648
+ # define POSH_LITTLE_ENDIAN 1
649
+ #else
650
+ # define POSH_ENDIAN_STRING "big"
651
+ # define POSH_BIG_ENDIAN 1
652
+ #endif
653
+
654
+ /*
655
+ ** ----------------------------------------------------------------------------
656
+ ** Cross-platform compile time assertion macro
657
+ ** ----------------------------------------------------------------------------
658
+ */
659
+ #define POSH_COMPILE_TIME_ASSERT(name, x) typedef int _POSH_dummy_ ## name[(x) ? 1 : -1 ]
660
+
661
+ /*
662
+ ** ----------------------------------------------------------------------------
663
+ ** 64-bit Integer
664
+ **
665
+ ** We don't require 64-bit support, nor do we emulate its functionality, we
666
+ ** simply export it if it's available. Since we can't count on <limits.h>
667
+ ** for 64-bit support, we ignore the POSH_USE_LIMITS_H directive.
668
+ ** ----------------------------------------------------------------------------
669
+ */
670
+ #if defined ( __LP64__ ) || defined ( __powerpc64__ ) || defined POSH_CPU_SPARC64
671
+ # define POSH_64BIT_INTEGER 1
672
+ typedef long posh_i64_t;
673
+ typedef unsigned long posh_u64_t;
674
+ # define POSH_I64( x ) ((posh_i64_t)x)
675
+ # define POSH_U64( x ) ((posh_u64_t)x)
676
+ # define POSH_I64_PRINTF_PREFIX "l"
677
+ #elif defined _MSC_VER || defined __BORLANDC__ || defined __WATCOMC__ || ( defined __alpha && defined __DECC )
678
+ # define POSH_64BIT_INTEGER 1
679
+ typedef __int64 posh_i64_t;
680
+ typedef unsigned __int64 posh_u64_t;
681
+ # define POSH_I64( x ) ((posh_i64_t)x)
682
+ # define POSH_U64( x ) ((posh_u64_t)x)
683
+ # define POSH_I64_PRINTF_PREFIX "I64"
684
+ #elif defined __GNUC__ || defined __MWERKS__ || defined __SUNPRO_C || defined __SUNPRO_CC || defined __APPLE_CC__ || defined POSH_OS_IRIX || defined _LONG_LONG || defined _CRAYC
685
+ # define POSH_64BIT_INTEGER 1
686
+ typedef long long posh_i64_t;
687
+ typedef unsigned long long posh_u64_t;
688
+ # define POSH_U64( x ) ((posh_u64_t)(x##LL))
689
+ # define POSH_I64( x ) ((posh_i64_t)(x##LL))
690
+ # define POSH_I64_PRINTF_PREFIX "ll"
691
+ #endif
692
+
693
+ /* hack */
694
+ #ifdef __MINGW32__
695
+ #undef POSH_I64
696
+ #undef POSH_U64
697
+ #undef POSH_I64_PRINTF_PREFIX
698
+ #define POSH_I64( x ) ((posh_i64_t)x)
699
+ #define POSH_U64( x ) ((posh_u64_t)x)
700
+ #define POSH_I64_PRINTF_PREFIX "I64"
701
+ #endif
702
+
703
+ /** Minimum value for a 64-bit signed integer */
704
+ #define POSH_I64_MIN POSH_I64(0x8000000000000000)
705
+ /** Maximum value for a 64-bit signed integer */
706
+ #define POSH_I64_MAX POSH_I64(0x7FFFFFFFFFFFFFFF)
707
+ /** Minimum value for a 64-bit unsigned integer */
708
+ #define POSH_U64_MIN POSH_U64(0)
709
+ /** Maximum value for a 64-bit unsigned integer */
710
+ #define POSH_U64_MAX POSH_U64(0xFFFFFFFFFFFFFFFF)
711
+
712
+ /* ----------------------------------------------------------------------------
713
+ ** Basic Sized Types
714
+ **
715
+ ** These types are expected to be EXACTLY sized so you can use them for
716
+ ** serialization.
717
+ ** ----------------------------------------------------------------------------
718
+ */
719
+ #define POSH_FALSE 0
720
+ #define POSH_TRUE 1
721
+
722
+ typedef int posh_bool_t;
723
+ typedef unsigned char posh_byte_t;
724
+
725
+ /* NOTE: These assume that CHAR_BIT is 8!! */
726
+ typedef unsigned char posh_u8_t;
727
+ typedef signed char posh_i8_t;
728
+
729
+ #if defined POSH_USE_LIMITS_H
730
+ # if CHAR_BITS > 8
731
+ # error This machine uses 9-bit characters. This is a warning, you can comment this out now.
732
+ # endif /* CHAR_BITS > 8 */
733
+
734
+ /* 16-bit */
735
+ # if ( USHRT_MAX == 65535 )
736
+ typedef unsigned short posh_u16_t;
737
+ typedef short posh_i16_t;
738
+ # else
739
+ /* Yes, in theory there could still be a 16-bit character type and shorts are
740
+ 32-bits in size...if you find such an architecture, let me know =P */
741
+ # error No 16-bit type found
742
+ # endif
743
+
744
+ /* 32-bit */
745
+ # if ( INT_MAX == 2147483647 )
746
+ typedef unsigned posh_u32_t;
747
+ typedef int posh_i32_t;
748
+ # elif ( LONG_MAX == 2147483647 )
749
+ typedef unsigned long posh_u32_t;
750
+ typedef long posh_i32_t;
751
+ # else
752
+ error No 32-bit type found
753
+ # endif
754
+
755
+ #else /* POSH_USE_LIMITS_H */
756
+
757
+ typedef unsigned short posh_u16_t;
758
+ typedef short posh_i16_t;
759
+
760
+ # if !defined POSH_OS_PALM
761
+ typedef unsigned posh_u32_t;
762
+ typedef int posh_i32_t;
763
+ # else
764
+ typedef unsigned long posh_u32_t;
765
+ typedef long posh_i32_t;
766
+ # endif
767
+ #endif
768
+
769
+ /** Minimum value for a byte */
770
+ #define POSH_BYTE_MIN 0
771
+ /** Maximum value for an 8-bit unsigned value */
772
+ #define POSH_BYTE_MAX 255
773
+ /** Minimum value for a byte */
774
+ #define POSH_I16_MIN ( ( posh_i16_t ) 0x8000 )
775
+ /** Maximum value for a 16-bit signed value */
776
+ #define POSH_I16_MAX ( ( posh_i16_t ) 0x7FFF )
777
+ /** Minimum value for a 16-bit unsigned value */
778
+ #define POSH_U16_MIN 0
779
+ /** Maximum value for a 16-bit unsigned value */
780
+ #define POSH_U16_MAX ( ( posh_u16_t ) 0xFFFF )
781
+ /** Minimum value for a 32-bit signed value */
782
+ #define POSH_I32_MIN ( ( posh_i32_t ) 0x80000000 )
783
+ /** Maximum value for a 32-bit signed value */
784
+ #define POSH_I32_MAX ( ( posh_i32_t ) 0x7FFFFFFF )
785
+ /** Minimum value for a 32-bit unsigned value */
786
+ #define POSH_U32_MIN 0
787
+ /** Maximum value for a 32-bit unsigned value */
788
+ #define POSH_U32_MAX ( ( posh_u32_t ) 0xFFFFFFFF )
789
+
790
+ /*
791
+ ** ----------------------------------------------------------------------------
792
+ ** Sanity checks on expected sizes
793
+ ** ----------------------------------------------------------------------------
794
+ */
795
+ POSH_COMPILE_TIME_ASSERT(posh_byte_t, sizeof(posh_byte_t) == 1);
796
+ POSH_COMPILE_TIME_ASSERT(posh_u8_t, sizeof(posh_u8_t) == 1);
797
+ POSH_COMPILE_TIME_ASSERT(posh_i8_t, sizeof(posh_i8_t) == 1);
798
+ POSH_COMPILE_TIME_ASSERT(posh_u16_t, sizeof(posh_u16_t) == 2);
799
+ POSH_COMPILE_TIME_ASSERT(posh_i16_t, sizeof(posh_i16_t) == 2);
800
+ POSH_COMPILE_TIME_ASSERT(posh_u32_t, sizeof(posh_u32_t) == 4);
801
+ POSH_COMPILE_TIME_ASSERT(posh_i32_t, sizeof(posh_i32_t) == 4);
802
+
803
+ #if !defined POSH_NO_FLOAT
804
+ POSH_COMPILE_TIME_ASSERT(posh_testfloat_t, sizeof(float)==4 );
805
+ POSH_COMPILE_TIME_ASSERT(posh_testdouble_t, sizeof(double)==8);
806
+ #endif
807
+
808
+ #if defined POSH_64BIT_INTEGER
809
+ POSH_COMPILE_TIME_ASSERT(posh_u64_t, sizeof(posh_u64_t) == 8);
810
+ POSH_COMPILE_TIME_ASSERT(posh_i64_t, sizeof(posh_i64_t) == 8);
811
+ #endif
812
+
813
+ /*
814
+ ** ----------------------------------------------------------------------------
815
+ ** 64-bit pointer support
816
+ ** ----------------------------------------------------------------------------
817
+ */
818
+ #if defined POSH_CPU_AXP && ( defined POSH_OS_TRU64 || defined POSH_OS_LINUX )
819
+ # define POSH_64BIT_POINTER 1
820
+ #endif
821
+
822
+ #if defined POSH_CPU_X86_64 && defined POSH_OS_LINUX
823
+ # define POSH_64BIT_POINTER 1
824
+ #endif
825
+
826
+ #if defined POSH_CPU_SPARC64 || defined POSH_OS_WIN64 || defined __64BIT__ || defined __LP64 || defined _LP64 || defined __LP64__ || defined _ADDR64 || defined _CRAYC
827
+ # define POSH_64BIT_POINTER 1
828
+ #endif
829
+
830
+ #if defined POSH_64BIT_POINTER
831
+ POSH_COMPILE_TIME_ASSERT( posh_64bit_pointer, sizeof( void * ) == 8 );
832
+ #else
833
+ /* if this assertion is hit then you're on a system that either has 64-bit
834
+ addressing and we didn't catch it, or you're on a system with 16-bit
835
+ pointers. In the latter case, POSH doesn't actually care, we're just
836
+ triggering this assertion to make sure you're aware of the situation,
837
+ so feel free to delete it.
838
+
839
+ If this assertion is triggered on a known 32 or 64-bit platform,
840
+ please let us know (poshlib@poshlib.org) */
841
+ POSH_COMPILE_TIME_ASSERT( posh_32bit_pointer, sizeof( void * ) == 4 );
842
+ #endif
843
+
844
+ /*
845
+ ** ----------------------------------------------------------------------------
846
+ ** POSH Utility Functions
847
+ **
848
+ ** These are optional POSH utility functions that are not required if you don't
849
+ ** need anything except static checking of your host and target environment.
850
+ **
851
+ ** These functions are NOT wrapped with POSH_PUBLIC_API because I didn't want
852
+ ** to enforce their export if your own library is only using them internally.
853
+ ** ----------------------------------------------------------------------------
854
+ */
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
+