~ubuntu-branches/ubuntu/raring/firebird2.5/raring-proposed

« back to all changes in this revision

Viewing changes to .pc/fix-mipseb-detect.patch/src/jrd/common.h

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2011-09-24 14:12:19 UTC
  • mfrom: (15.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110924141219-pkxk7486f3d8ut9f
Tags: 2.5.1.26349-0~rc1.ds4-5
* Medium urgency for fixing a serious bug in testing

* Import a patch from upstream SVN fixing problems in poll() usage when
  process receives signals like SIGALRM.
  Closes: #642555 -- segfault in the remote interface when using alarm() in
  the client program

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *      PROGRAM:        JRD access method
3
 
 *      MODULE:         common.h
4
 
 *      DESCRIPTION:    Common descriptions for all GDS programs
5
 
 *
6
 
 * The contents of this file are subject to the Interbase Public
7
 
 * License Version 1.0 (the "License"); you may not use this file
8
 
 * except in compliance with the License. You may obtain a copy
9
 
 * of the License at http://www.Inprise.com/IPL.html
10
 
 *
11
 
 * Software distributed under the License is distributed on an
12
 
 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
13
 
 * or implied. See the License for the specific language governing
14
 
 * rights and limitations under the License.
15
 
 *
16
 
 * The Original Code was created by Inprise Corporation
17
 
 * and its predecessors. Portions created by Inprise Corporation are
18
 
 * Copyright (C) Inprise Corporation.
19
 
 *
20
 
 * All Rights Reserved.
21
 
 * Contributor(s): ______________________________________.
22
 
 *
23
 
 * 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
24
 
 *                         conditionals, as the engine now fully supports
25
 
 *                         readonly databases.
26
 
 *
27
 
 * 2001.11.20  Ann Harrison - make 64bitio.h conditional on not windows.
28
 
 *
29
 
 * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete ports:
30
 
 *                          - MAC ("MAC", "MAC_AUX" and "MAC_CP" defines)
31
 
 *                          - EPSON, XENIX, DELTA, IMP, NCR3000, M88K
32
 
 *                          - NT Power PC and HP9000 s300
33
 
 *
34
 
 * 2002.04.16  Paul Beach - HP10 and unistd.h
35
 
 *
36
 
 * 2002.10.27 Sean Leyne - Completed removal of obsolete "DG_X86" port
37
 
 * 2002.10.27 Sean Leyne - Code Cleanup, removed obsolete "UNIXWARE" port
38
 
 * 2002.10.27 Sean Leyne - Code Cleanup, removed obsolete "Ultrix" port
39
 
 *
40
 
 * 2002.10.28 Sean Leyne - Completed removal of obsolete "DGUX" port
41
 
 * 2002.10.28 Sean Leyne - Code cleanup, removed obsolete "DecOSF" port
42
 
 * 2002.10.28 Sean Leyne - Code cleanup, removed obsolete "SGI" port
43
 
 *
44
 
 * 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
45
 
 *
46
 
 * 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
47
 
 *
48
 
 */
49
 
 
50
 
#ifndef JRD_COMMON_H
51
 
#define JRD_COMMON_H
52
 
 
53
 
#include "firebird.h"
54
 
 
55
 
#ifdef HAVE_STDLIB_H
56
 
#include <stdlib.h>
57
 
#endif
58
 
 
59
 
#ifdef HAVE_SYS_PARAM_H
60
 
#include <sys/param.h>
61
 
#endif
62
 
 
63
 
#ifdef HAVE_UNISTD_H
64
 
// for _POSIX_THREADS test below
65
 
#include <unistd.h>
66
 
#endif
67
 
 
68
 
#if defined(_POSIX_THREADS) && _POSIX_THREADS >= 200112L
69
 
// above check is generally true. However, we use pthreads on some platforms
70
 
// where _POSIX_THREADS is defined to "1" or not even defined at all!
71
 
#define USE_POSIX_THREADS
72
 
#endif
73
 
 
74
 
#include "../include/fb_macros.h"
75
 
#include "../include/fb_types.h"
76
 
 
77
 
/*
78
 
  do not use links in source code to maintain platform neutrality
79
 
*/
80
 
 
81
 
#ifdef SUPERSERVER
82
 
#define SWEEP_THREAD
83
 
#define GARBAGE_THREAD
84
 
#endif
85
 
 
86
 
 
87
 
#ifdef SUPERSERVER
88
 
#define FB_ARCHITECTURE isc_info_db_class_server_access
89
 
#else
90
 
#define FB_ARCHITECTURE isc_info_db_class_classic_access
91
 
#endif
92
 
 
93
 
 
94
 
/*****************************************************
95
 
* Linux platforms
96
 
*****************************************************/
97
 
#ifdef LINUX
98
 
#define QUADFORMAT "ll"
99
 
#define QUADCONST(n) (n##LL)
100
 
 
101
 
// SLONG is a 32-bit integer on 64-bit platforms
102
 
//#if SIZEOF_LONG == 4
103
 
//#define SLONGFORMAT "ld"
104
 
//#define ULONGFORMAT "lu"
105
 
//#define XLONGFORMAT "lX"
106
 
//#define xLONGFORMAT "lx"
107
 
//#endif
108
 
 
109
 
// format for size_t
110
 
#ifndef SIZEFORMAT
111
 
#define SIZEFORMAT "zi"
112
 
#endif
113
 
 
114
 
//format for __LINE__
115
 
#define LINEFORMAT "d"
116
 
 
117
 
#define UNIX
118
 
#define IEEE
119
 
 
120
 
#ifdef AMD64
121
 
#define IMPLEMENTATION  isc_info_db_impl_linux_amd64 /* 66 */
122
 
 
123
 
// on buggy kernels ERESTARTNOHAND (==514) may be returned instead of EINTR
124
 
// use value '514' instead of ERESTARTNOHAND cause it's not present in std includes
125
 
// in theory such error codes should never be seen outside kernel
126
 
#define SYSCALL_INTERRUPTED(err) (((err) == EINTR) || ((err) == 514))   /* pjpg 20001102 */
127
 
 
128
 
#endif
129
 
 
130
 
#ifdef PPC
131
 
#define IMPLEMENTATION  isc_info_db_impl_linux_ppc /* 69  next higher unique number, See you later  */
132
 
#endif
133
 
 
134
 
#ifdef i386
135
 
#define I386
136
 
#define IMPLEMENTATION  isc_info_db_impl_i386 /* 60 */
137
 
#endif /* i386 */
138
 
 
139
 
#ifdef ARM
140
 
#define IMPLEMENTATION  isc_info_db_impl_linux_arm      // 75
141
 
#endif /* ARM */
142
 
 
143
 
#ifdef sparc
144
 
#define IMPLEMENTATION  isc_info_db_impl_linux_sparc /* 65  */
145
 
#define RISC_ALIGNMENT
146
 
#endif /* sparc */
147
 
 
148
 
#ifdef MIPSEL
149
 
#define IMPLEMENTATION  isc_info_db_impl_linux_mipsel /* 71  */
150
 
#endif /* mipsel */
151
 
 
152
 
#ifdef MIPS
153
 
#define IMPLEMENTATION  isc_info_db_impl_linux_mips /* 72  */
154
 
#endif /* mips */
155
 
 
156
 
#ifdef IA64
157
 
#define IMPLEMENTATION  isc_info_db_impl_linux_ia64     // 76
158
 
#define RISC_ALIGNMENT
159
 
#endif // IA64
160
 
 
161
 
#ifndef USE_POSIX_THREADS
162
 
// force pthread detection on Linux for distros that do not provide
163
 
// POSIX thread compatability
164
 
#define USE_POSIX_THREADS
165
 
#endif
166
 
 
167
 
#ifdef __s390__
168
 
#ifdef __s390x__
169
 
#define IMPLEMENTATION  isc_info_db_impl_linux_s390x    // 78
170
 
#else
171
 
#define IMPLEMENTATION  isc_info_db_impl_linux_s390             // 79
172
 
#endif  // __s390x__
173
 
#endif  // __s390__
174
 
 
175
 
#ifdef SH
176
 
#define IMPLEMENTATION  isc_info_db_impl_linux_sh /* 80  */
177
 
#define RISC_ALIGNMENT
178
 
#endif /* sh */
179
 
 
180
 
#ifdef SHEB
181
 
#define IMPLEMENTATION  isc_info_db_impl_linux_sheb /* 81  */
182
 
#define RISC_ALIGNMENT
183
 
#endif /* sheb */
184
 
 
185
 
#endif /* LINUX */
186
 
 
187
 
 
188
 
/*****************************************************
189
 
* Darwin Platforms
190
 
*****************************************************/
191
 
#ifdef DARWIN
192
 
// EKU: obsolete, replaced by _FILE_OFFSET_BITS
193
 
//#ifndef UNIX_64_BIT_IO
194
 
//#define UNIX_64_BIT_IO
195
 
//#endif
196
 
//
197
 
//format for __LINE__
198
 
#define LINEFORMAT "d"
199
 
 
200
 
//#define SLONGFORMAT   "ld"
201
 
//#define ULONGFORMAT "lu"
202
 
//#define XLONGFORMAT "lX"
203
 
//#define xLONGFORMAT "lx"
204
 
 
205
 
//#define FB_ALIGNMENT       4
206
 
//#define FB_DOUBLE_ALIGN    4
207
 
//#define BSD_UNIX
208
 
#define UNIX
209
 
#ifdef __ppc__
210
 
#define powerpc
211
 
#define IMPLEMENTATION isc_info_db_impl_darwin_ppc /* 63 */
212
 
#endif
213
 
#ifdef i386
214
 
#define I386
215
 
#define IMPLEMENTATION isc_info_db_impl_darwin_x86 /* 70 */
216
 
#endif
217
 
#ifdef __x86_64__
218
 
#define DARWIN64
219
 
#define IMPLEMENTATION isc_info_db_impl_darwin_x64 /* 73 */
220
 
#endif
221
 
#ifdef __ppc64__
222
 
#define DARWINPPC64
223
 
#define IMPLEMENTATION isc_info_db_impl_darwin_ppc64 /* 77 */
224
 
#endif
225
 
#define IEEE
226
 
#define QUADCONST(n) (n##LL)
227
 
#define QUADFORMAT "q"
228
 
#define MAP_ANON
229
 
 
230
 
#define API_ROUTINE __attribute__((visibility("default")))
231
 
#define API_ROUTINE_VARARG API_ROUTINE
232
 
#define INTERNAL_API_ROUTINE API_ROUTINE
233
 
#define FB_EXPORTED __attribute__((visibility("default")))
234
 
 
235
 
#define O_DIRECT F_NOCACHE
236
 
#endif /* Darwin Platforms */
237
 
 
238
 
 
239
 
/*****************************************************
240
 
* FreeBSD for Intel platforms
241
 
*****************************************************/
242
 
#ifdef FREEBSD
243
 
 
244
 
// EKU: obsolete, replaced by _FILE_OFFSET_BITS
245
 
//#ifndef UNIX_64_BIT_IO
246
 
//#define UNIX_64_BIT_IO
247
 
//#endif
248
 
//
249
 
 
250
 
//#define FB_ALIGNMENT     4
251
 
//#define FB_DOUBLE_ALIGN  4
252
 
 
253
 
#define UNIX
254
 
#define IEEE
255
 
 
256
 
#ifdef AMD64
257
 
#define IMPLEMENTATION  isc_info_db_impl_freebsd_amd64 /* 67 */
258
 
#else
259
 
#define I386
260
 
#define IMPLEMENTATION    isc_info_db_impl_freebsd   /* 61 */
261
 
#endif
262
 
 
263
 
#define QUADFORMAT "ll"
264
 
#define QUADCONST(n) (n##LL)
265
 
#define NO_NFS                                  /* no MTAB_OPEN or MTAB_CLOSE in isc_file.c */
266
 
 
267
 
#ifndef USE_POSIX_THREADS
268
 
// force pthread detection on FREEBSD
269
 
#define USE_POSIX_THREADS
270
 
#endif
271
 
 
272
 
#endif /* FREEBSD */
273
 
 
274
 
/*****************************************************
275
 
* NetBSD
276
 
*****************************************************/
277
 
#ifdef NETBSD
278
 
 
279
 
#if defined(__i386__)
280
 
//#define FB_ALIGNMENT     4
281
 
//#define FB_DOUBLE_ALIGN  4
282
 
 
283
 
#define IEEE
284
 
#define I386
285
 
#define IMPLEMENTATION        isc_info_db_impl_netbsd /* 62 */
286
 
 
287
 
#define QUADFORMAT "ll"
288
 
#define QUADCONST(n) (n##LL)
289
 
#else /* !__i386__ */
290
 
#error Please add support for other ports
291
 
#endif
292
 
 
293
 
#define UNIX
294
 
#define NO_NFS                                  /* no MTAB_OPEN or MTAB_CLOSE in isc_file.c */
295
 
 
296
 
#endif /* NETBSD */
297
 
 
298
 
 
299
 
 
300
 
/*****************************************************
301
 
 * SUN platforms--the 386i is obsolete
302
 
*****************************************************/
303
 
 
304
 
#ifdef __sun
305
 
 
306
 
#ifdef SOLARIS
307
 
 
308
 
/*  Define the following only on platforms whose standard I/O
309
 
 *  implementation is so weak that we wouldn't be able to fopen
310
 
 *  a file whose underlying file descriptor would be > 255.
311
 
 *  Hey, we're not running on PDP-11's any more: would it kill you
312
 
 *  to use a short instead of a char to hold the fileno?  :-(
313
 
 */
314
 
 
315
 
/* Why we (solarises) need to rewrite old BSD stdio
316
 
   so many times I suggest stdIO from
317
 
   http://www.research.att.com/sw/tools/sfio/
318
 
*/
319
 
/*      Need to use full sfio not just stdio emulation to fix
320
 
        file descriptor number limit. nmcc Dec2002
321
 
*/
322
 
 
323
 
/* Update for Solaris 10. The problem still exists pre Solaris 10,
324
 
however if you are using A version of Solaris 10 after 11/06 the 
325
 
problem with file descriptors has been solved and this define and
326
 
the following function can now be commented out.
327
 
If you are using Solaris 10 from 03/05 - 11/06 you need to patch
328
 
your operating system.
329
 
Earlier versions of Solaris still have the problem. pbeach Feb2010
330
 
*/
331
 
 
332
 
#if (!defined(__arch64__)) && (!defined(SFIO))
333
 
#error "need to use SFIO"
334
 
#endif
335
 
 
336
 
// this function is normally defined in stdio.h, but is missing in SFIO's h-file
337
 
extern "C" int remove(const char* path);
338
 
 
339
 
/* The following define is the prefix to go in front of a "d" or "u"
340
 
   format item in a printf() format string, to indicate that the argument
341
 
   is an SINT64 or FB_UINT64. */
342
 
#define QUADFORMAT "ll"
343
 
/* The following macro creates a quad-sized constant, possibly one
344
 
   which is too large to fit in a long int. */
345
 
#define QUADCONST(n) (n##LL)
346
 
 
347
 
#ifndef USE_POSIX_THREADS
348
 
#if defined(_POSIX_THREADS) && _POSIX_THREADS >= 1L
349
 
// Solaris 9 has _POSIX_THREADS = 1L
350
 
// Solaris 10 has _POSIX_THREADS >= 200112L
351
 
#define USE_POSIX_THREADS
352
 
#endif
353
 
#endif
354
 
 
355
 
#endif // SOLARIS
356
 
 
357
 
#define UNIX
358
 
#define IEEE
359
 
 
360
 
#ifdef __sparc
361
 
//#define FB_ALIGNMENT       4
362
 
//#define FB_DOUBLE_ALIGN    8
363
 
 
364
 
#define IMPLEMENTATION  isc_info_db_impl_isc_sun4 /* 30 */
365
 
#define RISC_ALIGNMENT
366
 
 
367
 
#elif defined (__i386)
368
 
#define IMPLEMENTATION  isc_info_db_impl_isc_sun_386i  /* 32 */
369
 
 
370
 
#elif defined (__amd64)
371
 
#define IMPLEMENTATION  isc_info_db_impl_sun_amd64 /* 74 */
372
 
 
373
 
#else
374
 
#error What is IMPLEMENTATION for this Solaris platform????
375
 
#endif
376
 
 
377
 
#endif // __sun
378
 
 
379
 
 
380
 
/*****************************************************
381
 
* HP/UX platforms
382
 
*****************************************************/
383
 
 
384
 
#ifdef HPUX
385
 
 
386
 
#define USE_SHMEM_EXT   // Looks like everyone else can ISC_remap
387
 
 
388
 
#define UNIX
389
 
//#define CURSES_KEYPAD
390
 
 
391
 
//#define FB_ALIGNMENT       8
392
 
//#define FB_DOUBLE_ALIGN    8
393
 
#define IMPLEMENTATION  isc_info_db_impl_isc_hp_ux /* 31 */
394
 
 
395
 
#if defined (__HP_aCC)
396
 
// aCC error, __thread can be used only with C-like structs
397
 
#undef HAVE___THREAD
398
 
#endif
399
 
 
400
 
#define IEEE
401
 
// 16-Apr-2002 HP10 in unistd.h Paul Beach
402
 
//#define setreuid(ruid, euid)     setresuid (ruid, euid, -1)
403
 
//#define setregid(rgid, egid)     setresgid (rgid, egid, -1)
404
 
 
405
 
/* The following define is the prefix to go in front of a "d" or "u"
406
 
   format item in a printf() format string, to indicate that the argument
407
 
   is an SINT64 or FB_UINT64. */
408
 
#define QUADFORMAT "ll"
409
 
/* The following macro creates a quad-sized constant, possibly one
410
 
   which is too large to fit in a long int. */
411
 
#define QUADCONST(n) (n)
412
 
 
413
 
#ifndef USE_POSIX_THREADS
414
 
// HPUX v B.11.23 does not have _POSIX_THREADS defined, their implementation
415
 
// is incomplete, but good enough for us
416
 
#define USE_POSIX_THREADS
417
 
#endif
418
 
 
419
 
#define RISC_ALIGNMENT
420
 
 
421
 
#endif /* HPUX */
422
 
 
423
 
 
424
 
/*****************************************************
425
 
* IBM AIX RS/6000 and IBM AIX PowerPC
426
 
*****************************************************/
427
 
 
428
 
#ifdef _AIX                                             /* IBM AIX */
429
 
#ifndef _POWER                                  /* IBM RS/6000 */
430
 
#define AIX
431
 
#define UNIX
432
 
//#define CURSES_KEYPAD
433
 
//*#define FB_ALIGNMENT       4
434
 
#define IMPLEMENTATION  isc_info_db_impl_isc_rt_aix /* 35 */
435
 
#define IEEE
436
 
#define SYSCALL_INTERRUPTED(err)        (((err) == EINTR) || ((err) == ERESTART))       /* pjpg 20001102 */
437
 
#else /* AIX PowerPC */
438
 
#define AIX_PPC
439
 
#define UNIX
440
 
//#define CURSES_KEYPAD
441
 
//#define FB_ALIGNMENT       4
442
 
#define IMPLEMENTATION  isc_info_db_impl_isc_rt_aix /* 35 */
443
 
#define IEEE
444
 
#define SYSCALL_INTERRUPTED(err)        (((err) == EINTR) || ((err) == ERESTART))       /* pjpg 20001102 */
445
 
 
446
 
#define QUADFORMAT "ll"                 /* TMC 081700 */
447
 
#define QUADCONST(n) (n##LL)    /* TMC 081700 */
448
 
 
449
 
#endif /* IBM PowerPC */
450
 
 
451
 
// AIX does not pass autoconf's test for mmap() correctness,
452
 
// but we do not use flag (MAP_FIXED) that fails.
453
 
#define HAVE_MMAP
454
 
 
455
 
// autoconf test AC_SYS_LARGEFILE defines _LARGE_FILES for AIX builds.
456
 
// But, in <standards.h>, _LARGE_FILE_API is defined, leading to conflict
457
 
// in 32-bit builds. Only one of these macros should be defined.
458
 
#undef _LARGE_FILE_API
459
 
 
460
 
#endif /* IBM AIX */
461
 
 
462
 
 
463
 
 
464
 
/*****************************************************
465
 
* Windows NT
466
 
*****************************************************/
467
 
 
468
 
#ifdef WIN_NT
469
 
 
470
 
#define NO_NFS
471
 
 
472
 
#define SYS_ERR         Arg::Windows
473
 
//#define SLONGFORMAT "ld"
474
 
//#define ULONGFORMAT "lu"
475
 
//#define XLONGFORMAT "lX"
476
 
//#define xLONGFORMAT "lx"
477
 
 
478
 
//format for __LINE__
479
 
#define LINEFORMAT "d"
480
 
 
481
 
/* The following define is the prefix to go in front of a "d" or "u"
482
 
   format item in a printf() format string, to indicate that the argument
483
 
   is an SINT64 or FB_UINT64. */
484
 
#define QUADFORMAT "I64"
485
 
/* The following macro creates a quad-sized constant, possibly one
486
 
   which is too large to fit in a long int.  The Microsoft compiler does
487
 
   not permit the LL suffix which some other platforms require, but it
488
 
   handles numbers up to the largest 64-bit integer correctly without such
489
 
   a suffix, so the macro definition is trivial. */
490
 
#ifdef __GNUC__ // needed for gcc 3.3.1
491
 
#define QUADCONST(n) (n##LL)
492
 
#else
493
 
#define QUADCONST(n) (n)
494
 
#endif
495
 
 
496
 
#ifdef AMD64
497
 
#define IMPLEMENTATION  isc_info_db_impl_winnt_amd64 /* 68 */
498
 
#else
499
 
#ifndef I386
500
 
#define I386
501
 
#endif
502
 
#define IMPLEMENTATION  isc_info_db_impl_isc_winnt_x86 /* 50 */
503
 
#endif
504
 
 
505
 
#define IEEE
506
 
#define API_ROUTINE     __stdcall
507
 
#define API_ROUTINE_VARARG      __cdecl
508
 
#define CLIB_ROUTINE    __cdecl
509
 
 
510
 
#ifndef MAXPATHLEN
511
 
#ifdef MAX_PATH
512
 
#define MAXPATHLEN MAX_PATH
513
 
#else
514
 
#define MAXPATHLEN 260
515
 
#endif
516
 
#endif
517
 
 
518
 
#define ERRNO           GetLastError()
519
 
#define INET_ERRNO      WSAGetLastError()
520
 
#define H_ERRNO         WSAGetLastError()
521
 
 
522
 
// For Visual Studio 2003 and earlier enable Windows 9X support
523
 
#if defined _MSC_VER && (_MSC_VER < 1400)
524
 
#define WIN9X_SUPPORT
525
 
#endif
526
 
 
527
 
#endif /* WIN_NT */
528
 
 
529
 
 
530
 
/*****************************************************
531
 
 * UNIX
532
 
*****************************************************/
533
 
#ifdef UNIX
534
 
#define NO_CHECKSUM
535
 
#define SYS_ERR         Arg::Unix
536
 
#endif /* UNIX */
537
 
 
538
 
#ifndef SYS_ERR
539
 
#define SYS_ERR         Arg::Unix
540
 
#endif
541
 
 
542
 
#ifndef ERRNO
543
 
#define ERRNO           errno
544
 
#endif
545
 
 
546
 
#ifndef INET_ERRNO
547
 
#define INET_ERRNO      errno
548
 
#endif
549
 
 
550
 
#ifndef H_ERRNO
551
 
#define H_ERRNO         h_errno
552
 
#endif
553
 
 
554
 
/* various declaration modifiers */
555
 
 
556
 
#ifndef API_ROUTINE
557
 
#define API_ROUTINE
558
 
#define API_ROUTINE_VARARG
559
 
#endif
560
 
 
561
 
#ifndef CLIB_ROUTINE
562
 
#define CLIB_ROUTINE
563
 
#endif
564
 
 
565
 
#ifndef FB_EXPORTED
566
 
#define FB_EXPORTED
567
 
#endif
568
 
 
569
 
 
570
 
/* alignment macros */
571
 
 
572
 
#ifndef OLD_ALIGNMENT
573
 
#ifdef I386
574
 
/* Using internal alignment optimal for 386 processor and above
575
 
 */
576
 
//#define FB_ALIGNMENT       4
577
 
//#define FB_DOUBLE_ALIGN    8
578
 
#endif
579
 
#endif
580
 
 
581
 
#ifndef FB_ALIGNMENT
582
 
//#define FB_ALIGNMENT       2
583
 
#error must define FB_ALIGNMENT for your system
584
 
#endif
585
 
 
586
 
#ifndef SHIFTLONG
587
 
/* Number of shifts needed to convert between char and LONG */
588
 
#define SHIFTLONG       2
589
 
#define BITS_PER_LONG   32
590
 
#endif
591
 
 
592
 
#ifndef FB_DOUBLE_ALIGN
593
 
//#define FB_DOUBLE_ALIGN    4
594
 
#error must define FB_DOUBLE_ALIGN for your system
595
 
#endif
596
 
 
597
 
 
598
 
 
599
 
/* common return values */
600
 
 
601
 
#ifndef FINI_OK
602
 
#define FINI_OK         0
603
 
#define FINI_ERROR      1
604
 
#define STARTUP_ERROR   2               /* this is also used in iscguard.h, make sure these match */
605
 
#endif
606
 
 
607
 
#ifndef TRUE
608
 
#define TRUE            1
609
 
#endif
610
 
#ifndef FALSE
611
 
#define FALSE           0
612
 
#endif
613
 
#define FB_SUCCESS         0
614
 
#define FB_FAILURE         1
615
 
 
616
 
/* sys/paramh.h : compatibility purposes */
617
 
#ifndef NOFILE
618
 
#define NOFILE      20
619
 
#endif
620
 
 
621
 
/* data type definitions */
622
 
 
623
 
#ifndef ISC_TIMESTAMP_DEFINED
624
 
typedef SLONG ISC_DATE;
625
 
typedef ULONG ISC_TIME;
626
 
struct ISC_TIMESTAMP
627
 
{
628
 
        ISC_DATE timestamp_date;
629
 
        ISC_TIME timestamp_time;
630
 
};
631
 
#define ISC_TIMESTAMP_DEFINED
632
 
#endif  /* ISC_TIMESTAMP_DEFINED */
633
 
 
634
 
#define GDS_DATE        ISC_DATE
635
 
#define GDS_TIME        ISC_TIME
636
 
#define GDS_TIMESTAMP   ISC_TIMESTAMP
637
 
 
638
 
 
639
 
#ifndef BLOB_PTR
640
 
#define BLOB_PTR        UCHAR
641
 
#endif
642
 
 
643
 
 
644
 
#ifndef SLONGFORMAT
645
 
#if SIZEOF_LONG == 4
646
 
#define SLONGFORMAT "ld"
647
 
#define ULONGFORMAT "lu"
648
 
#define XLONGFORMAT "lX"
649
 
#define xLONGFORMAT "lx"
650
 
#else
651
 
#define SLONGFORMAT     "d"
652
 
#define ULONGFORMAT     "u"
653
 
#define XLONGFORMAT "X"
654
 
#define xLONGFORMAT "x"
655
 
#endif
656
 
#endif
657
 
 
658
 
// Shortcuts to make it easier to convert code using SLONGFORMAT/ULONGFORMAT
659
 
#define UQUADFORMAT QUADFORMAT"u"
660
 
#define SQUADFORMAT QUADFORMAT"d"
661
 
 
662
 
// format for size_t
663
 
#ifndef SIZEFORMAT
664
 
#if (SIZEOF_SIZE_T == 8)
665
 
#define SIZEFORMAT UQUADFORMAT
666
 
#else
667
 
#define SIZEFORMAT ULONGFORMAT
668
 
#endif
669
 
#endif // SIZEFORMAT
670
 
 
671
 
// format for __LINE__
672
 
#ifndef LINEFORMAT
673
 
#ifdef __GNUC__
674
 
#define LINEFORMAT "d"
675
 
#else
676
 
#define LINEFORMAT "ld"
677
 
#endif // __GNUC__
678
 
#endif
679
 
 
680
 
// format for OS handles
681
 
#if defined(WIN_NT) && (SIZEOF_VOID_P == 8)
682
 
#define HANDLEFORMAT SQUADFORMAT
683
 
#else
684
 
#define HANDLEFORMAT SLONGFORMAT
685
 
#endif
686
 
 
687
 
 
688
 
/* conditional compilation macros */
689
 
 
690
 
/* MAX and MIN for datatypes */
691
 
 
692
 
#define MAX_UCHAR               ((UCHAR)0xFF)
693
 
#define MIN_UCHAR               0x00
694
 
 
695
 
#define MAX_SCHAR               0x7F
696
 
#define MIN_SCHAR               (-MAX_SCHAR - 1)
697
 
 
698
 
#define MAX_USHORT              ((USHORT)0xFFFF)
699
 
#define MIN_USHORT              0x0000
700
 
 
701
 
#define MAX_SSHORT              0x7FFF
702
 
#define MIN_SSHORT              (-MAX_SSHORT - 1)
703
 
 
704
 
#define MAX_ULONG               ((ULONG)0xFFFFFFFF)
705
 
#define MIN_ULONG               0x00000000
706
 
 
707
 
#define MAX_SLONG               0x7FFFFFFF
708
 
#define MIN_SLONG               (-MAX_SLONG - 1)
709
 
 
710
 
#define MAX_UINT64              ((FB_UINT64) QUADCONST(0xFFFFFFFFFFFFFFFF))
711
 
#define MIN_UINT64              QUADCONST(0x0000000000000000)
712
 
 
713
 
#define MAX_SINT64              QUADCONST(0x7FFFFFFFFFFFFFFF)
714
 
#define MIN_SINT64              (-MAX_SINT64 - 1)
715
 
 
716
 
 
717
 
 
718
 
/* commonly used macros */
719
 
 
720
 
#ifndef MAX
721
 
#define MAX(a, b)                (((a) > (b)) ? (a) : (b))
722
 
#endif
723
 
#ifndef MIN
724
 
#define MIN(a, b)                (((a) < (b)) ? (a) : (b))
725
 
#endif
726
 
 
727
 
#define UPPER(c)                (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c))
728
 
#define LOWWER(c)               (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
729
 
 
730
 
/* UPPER7 & LOWWER7 are to be used when the data is known to
731
 
   be 7-bit ASCII, eg: internal data, OS data.  NOT user data.  */
732
 
 
733
 
#define UPPER7(c)               (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c))
734
 
#define LOWWER7(c)              (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
735
 
 
736
 
#ifndef ROUNDUP
737
 
#define ROUNDUP(n, b)            (((n) + (b) - 1) & ~((b) - 1))
738
 
#endif
739
 
#define ROUNDUP_LONG(len)       ROUNDUP (len, sizeof (SLONG))
740
 
 
741
 
#define JRD_BUGCHK 15                   /* facility code for bugcheck messages */
742
 
#ifndef OFFSET
743
 
#define OFFSET(struct, fld)      ((size_t) &((struct) NULL)->fld)
744
 
#define OFFSETA(struct, fld)     ((size_t) ((struct) NULL)->fld)
745
 
#endif
746
 
 
747
 
#ifndef ODS_ALIGNMENT
748
 
#define ODS_ALIGNMENT           4
749
 
#endif
750
 
 
751
 
#ifndef FORMAT_ALIGNMENT
752
 
// Alignment for items in record format. Used for databases after ODS11.
753
 
// Always 64-bit to ensure ODS compatibility with 64-bit versions of the engine
754
 
#define FORMAT_ALIGNMENT           8
755
 
#endif
756
 
 
757
 
#ifndef SYSCALL_INTERRUPTED
758
 
#define SYSCALL_INTERRUPTED(err)        ((err) == EINTR)
759
 
#endif
760
 
 
761
 
 
762
 
/* data movement and allocation macros */
763
 
 
764
 
#define MOVE_CLEAR(to, length)                  memset(to, 0, (size_t) (length))
765
 
 
766
 
// This macros are used to workaround shortage of standard conformance
767
 
// in Microsoft compilers. They could be replaced with normal procedure
768
 
// and generic macro if MSVC would support C99-style __VA_ARGS__
769
 
#define DEFINE_TRACE_ROUTINE(routine) void routine(const char* message, ...)
770
 
 
771
 
#ifdef HAVE_VSNPRINTF
772
 
#define VSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
773
 
#else
774
 
#define VSNPRINTF(a, b, c, d) vsprintf(a, c, d)
775
 
#endif
776
 
 
777
 
#ifdef HAVE_SNPRINTF
778
 
#define SNPRINTF snprintf
779
 
#else
780
 
#define SNPRINTF(buffer, length, ...) sprintf(buffer, __VA_ARGS__)
781
 
#endif
782
 
 
783
 
#define IMPLEMENT_TRACE_ROUTINE(routine, subsystem) \
784
 
void routine(const char* message, ...) \
785
 
{ \
786
 
        static const char name_facility[] = subsystem ","; \
787
 
        char buffer[1000]; \
788
 
        strcpy(buffer, name_facility); \
789
 
        char *ptr = buffer + sizeof(name_facility) - 1; \
790
 
        va_list params; \
791
 
        va_start(params, message); \
792
 
        VSNPRINTF(ptr, sizeof(buffer) - sizeof(name_facility), message, params); \
793
 
        va_end(params); \
794
 
        gds__trace(buffer); \
795
 
}
796
 
 
797
 
#ifdef DEV_BUILD
798
 
 
799
 
/* Define any debugging symbols and macros here.  This
800
 
   ifdef will be executed during development builds. */
801
 
 
802
 
#define TRACE(msg)                              gds__trace (msg)
803
 
 
804
 
#ifndef DEV_REPORT
805
 
#define DEV_REPORT(msg)         gds__log (msg)
806
 
#endif
807
 
 
808
 
#ifndef BREAKPOINT
809
 
#define BREAKPOINT(x)           GDS_breakpoint(x)
810
 
// fwd. decl. the function itself
811
 
#ifdef __cplusplus
812
 
extern "C" {
813
 
#endif
814
 
void GDS_breakpoint(int);
815
 
#ifdef __cplusplus
816
 
} /* extern "C" */
817
 
#endif
818
 
#endif
819
 
 
820
 
#endif /* DEV_BUILD */
821
 
 
822
 
#ifndef DEV_BUILD
823
 
#ifndef DEV_REPORT
824
 
#define DEV_REPORT(msg)         gds__log (msg)
825
 
#endif
826
 
#ifndef BREAKPOINT
827
 
#define BREAKPOINT(x)                   /* nothing */
828
 
#endif
829
 
#ifndef TRACE
830
 
#define TRACE(msg)                              /* nothing */
831
 
#endif
832
 
#endif
833
 
 
834
 
 
835
 
/* commonly used buffer sizes for dynamic buffer allocation */
836
 
 
837
 
#define BUFFER_XLARGE   2048
838
 
#define BUFFER_LARGE    1024
839
 
#define BUFFER_MEDIUM   512
840
 
#define BUFFER_SMALL    256
841
 
#define BUFFER_TINY     128
842
 
 
843
 
/* The default lseek offset type.  Changed from nothing to (off_t) to correctly support 64 bit IO */
844
 
#ifndef LSEEK_OFFSET_CAST
845
 
#define LSEEK_OFFSET_CAST (off_t)
846
 
#endif
847
 
 
848
 
#define STRINGIZE_AUX(x)        #x
849
 
#define STRINGIZE(x)            STRINGIZE_AUX(x)
850
 
 
851
 
#ifdef _MSC_VER
852
 
#define CONST64(a) (a##i64)
853
 
#else
854
 
#define CONST64(a) (a##LL)
855
 
#endif
856
 
 
857
 
// 30 Dec 2002. Nickolay Samofatov
858
 
// This needs to be checked for all supported platforms
859
 
// The simpliest way to check it is to issue from correct client:
860
 
// declare external function abs2 double precision
861
 
//   returns double precision by value
862
 
//   entry_point 'IB_UDF_abs' module_name 'ib_udf';
863
 
// select abs2(2.0 / 3.0) from rdb$database;
864
 
// It will return big strange value in case of invalid define
865
 
 
866
 
// ASF: Currently, all little-endian are FB_SWAP_DOUBLE and big-endian aren't.
867
 
// AP: Define it for your hardware correctly in case your CPU do not follow mentioned rule.
868
 
//     The follwoing lines are kept for reference only.
869
 
//#if defined(i386) || defined(I386) || defined(_M_IX86) || defined(AMD64) || defined(ARM) || defined(MIPSEL) || defined(DARWIN64) || defined(IA64)
870
 
//#define               FB_SWAP_DOUBLE 1
871
 
//#elif defined(sparc) || defined(PowerPC) || defined(PPC) || defined(__ppc__) || defined(HPUX) || defined(MIPS) || defined(__ppc64__)
872
 
//#define               FB_SWAP_DOUBLE 0
873
 
//#else
874
 
//#error "Define FB_SWAP_DOUBLE for your platform correctly !"
875
 
//#endif
876
 
 
877
 
#ifndef FB_SWAP_DOUBLE
878
 
#ifdef WORDS_BIGENDIAN
879
 
#define FB_SWAP_DOUBLE 0
880
 
#else
881
 
#define FB_SWAP_DOUBLE 1
882
 
#endif
883
 
#endif
884
 
 
885
 
// Commonly used indices to access parts of double in correct order.
886
 
#if FB_SWAP_DOUBLE
887
 
#define FB_LONG_DOUBLE_FIRST 1
888
 
#define FB_LONG_DOUBLE_SECOND 0
889
 
#else
890
 
#define FB_LONG_DOUBLE_FIRST 0
891
 
#define FB_LONG_DOUBLE_SECOND 1
892
 
#endif
893
 
 
894
 
 
895
 
// switch name and state table.  This structure should be used in all
896
 
// command line tools to facilitate parsing options.
897
 
struct in_sw_tab_t
898
 
{
899
 
        int in_sw;
900
 
        int in_spb_sw;
901
 
        const TEXT* in_sw_name;
902
 
        SINT64 in_sw_value;                                     // alice specific field
903
 
        SINT64 in_sw_requires;                          // alice specific field
904
 
        SINT64 in_sw_incompatibilities;         // alice specific field
905
 
        bool in_sw_state;
906
 
        USHORT in_sw_msg;
907
 
        USHORT in_sw_min_length;
908
 
        const TEXT* in_sw_text;
909
 
        int in_sw_optype;                                       // burp specific field for now.
910
 
        // Some compilers may produce warnings because I only initialized this field in gbak
911
 
};
912
 
 
913
 
#ifndef HAVE_WORKING_VFORK
914
 
#define vfork fork
915
 
#endif
916
 
 
917
 
 
918
 
static const TEXT FB_SHORT_MONTHS[][4] =
919
 
{
920
 
        "Jan", "Feb", "Mar",
921
 
        "Apr", "May", "Jun",
922
 
        "Jul", "Aug", "Sep",
923
 
        "Oct", "Nov", "Dec",
924
 
        "\0"
925
 
};
926
 
 
927
 
static const TEXT* const FB_LONG_MONTHS_UPPER[] =
928
 
{
929
 
        "JANUARY",
930
 
        "FEBRUARY",
931
 
        "MARCH",
932
 
        "APRIL",
933
 
        "MAY",
934
 
        "JUNE",
935
 
        "JULY",
936
 
        "AUGUST",
937
 
        "SEPTEMBER",
938
 
        "OCTOBER",
939
 
        "NOVEMBER",
940
 
        "DECEMBER",
941
 
        0
942
 
};
943
 
 
944
 
#endif /* JRD_COMMON_H */
945