~ubuntu-branches/ubuntu/saucy/ruby-ferret/saucy

« back to all changes in this revision

Viewing changes to .pc/fix_typos_in_source_code.patch/ext/posh.h

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2012-06-14 23:04:48 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20120614230448-wd5se4ia1yz7dvms
Tags: 0.11.8.4+debian-1
* New upstream version from a new source
  + the new code fixes format security issues (Closes: #672069)
  + change homepage to https://github.com/jkraemer/ferret/
* Build for all Ruby versions (Closes: #655636)
  + change depends accordingly
  + do not set shebang of bin/ferret to ruby1.8
* Repack source to remove convenience copy of bzlib
  + build-dep on libbz2-dev
  + dversionmangle in debian/watch
  + add debian/README.source explaining how to clean the source
* debian/patches:
  + disable_load_path_manipulation.patch: do not override $LOAD_PATH
  + disable_test_causing_segfault.patch: temporarily disable a test known to
    cause segfaults
  + fix_compatibility_with_minitest.patch: fix a failing test with Ruby1.9
  + use_system_bzlib.patch: adapt the source to use system libbz2
  + fix_typos_in_source_code.patch: correct some spelling errors in the
    source code
  + block_variables_have_local_scopes.patch: fix syntax in
    bin/ferret-browser
* Override dh_auto_clean to remove test/temp when cleaning
* Bump Standards-Version to 3.9.3 (no changes needed)
* Set priority of transitional packages to extra
* Add myself to Uploaders:
* Update copyright to DEP-5 copyright-format/1.0
* Add TUTORIAL and debian/README.source to documents
* Override lintian warnings about duplicate descriptions of transitional
  packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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