8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-27 20:03:03 +01:00
firebird-mirror/src/jrd/common.h

866 lines
20 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD access method
* MODULE: common.h
* DESCRIPTION: Common descriptions for all GDS programs
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
* conditionals, as the engine now fully supports
* readonly databases.
*
* 2001.11.20 Ann Harrison - make 64bitio.h conditional on not windows.
*
2002-02-16 06:06:17 +01:00
* 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete ports:
* - MAC ("MAC", "MAC_AUX" and "MAC_CP" defines)
* - EPSON, XENIX, DELTA, IMP, NCR3000, M88K
* - NT Power PC and HP9000 s300
2002-02-16 03:21:35 +01:00
*
2002-06-29 15:03:13 +02:00
* 2002.04.16 Paul Beach - HP10 and unistd.h
*
* 2002.10.27 Sean Leyne - Completed removal of obsolete "DG_X86" port
* 2002.10.27 Sean Leyne - Code Cleanup, removed obsolete "UNIXWARE" port
* 2002.10.27 Sean Leyne - Code Cleanup, removed obsolete "Ultrix" port
*
2002-10-29 03:45:09 +01:00
* 2002.10.28 Sean Leyne - Completed removal of obsolete "DGUX" port
* 2002.10.28 Sean Leyne - Code cleanup, removed obsolete "DecOSF" port
* 2002.10.28 Sean Leyne - Code cleanup, removed obsolete "SGI" port
2002-10-29 03:45:09 +01:00
*
2002-10-30 07:40:58 +01:00
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
*
* 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
*
2001-05-23 15:26:42 +02:00
*/
#ifndef JRD_COMMON_H
#define JRD_COMMON_H
#include "firebird.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
2001-07-12 07:46:06 +02:00
2001-05-23 15:26:42 +02:00
#include "../include/fb_macros.h"
#include "../include/fb_types.h"
/*
do not use links in source code to maintain platform neutrality
2001-05-23 15:26:42 +02:00
*/
2008-01-16 09:31:31 +01:00
#ifdef SUPERSERVER
#define SWEEP_THREAD
#define GARBAGE_THREAD
2008-02-20 17:07:07 +01:00
#define CANCEL_OPERATION
#endif
2001-05-23 15:26:42 +02:00
#ifdef SUPERSERVER
2002-06-29 15:03:13 +02:00
#define FB_ARCHITECTURE isc_info_db_class_server_access
#else
#define FB_ARCHITECTURE isc_info_db_class_classic_access
2001-05-23 15:26:42 +02:00
#endif
2001-07-12 07:46:06 +02:00
/*****************************************************
2007-04-03 04:31:30 +02:00
* Linux platforms
*****************************************************/
2001-05-23 15:26:42 +02:00
#ifdef LINUX
#define QUADFORMAT "ll"
#define QUADCONST(n) (n##LL)
// SLONG is a 32-bit integer on 64-bit platforms
2004-05-19 01:38:37 +02:00
//#if SIZEOF_LONG == 4
//#define SLONGFORMAT "ld"
//#define ULONGFORMAT "lu"
//#define XLONGFORMAT "lX"
//#define xLONGFORMAT "lx"
//#endif
//format for __LINE__
#define LINEFORMAT "d"
2001-05-23 15:26:42 +02:00
//#define KILLER_SIGNALS
2001-05-23 15:26:42 +02:00
#define UNIX
#define IEEE
2001-05-23 15:26:42 +02:00
#ifdef AMD64
2006-10-24 17:13:57 +02:00
#define IMPLEMENTATION isc_info_db_impl_linux_amd64 /* 66 */
#endif
#ifdef PPC
#define IMPLEMENTATION isc_info_db_impl_linux_ppc /* 69 next higher unique number, See you later */
#endif
2001-05-23 15:26:42 +02:00
#ifdef i386
#define I386
2006-10-24 17:13:57 +02:00
#define IMPLEMENTATION isc_info_db_impl_i386 /* 60 */
2001-05-23 15:26:42 +02:00
#endif /* i386 */
2003-10-11 01:56:57 +02:00
#ifdef sparc
2003-10-12 16:21:14 +02:00
#define IMPLEMENTATION isc_info_db_impl_linux_sparc /* 65 */
#define RISC_ALIGNMENT
2003-10-11 01:56:57 +02:00
#endif /* sparc */
2007-04-01 12:04:28 +02:00
#ifdef MIPSEL
#define IMPLEMENTATION isc_info_db_impl_linux_mipsel /* 71 */
#endif /* mipsel */
#ifdef MIPS
#define IMPLEMENTATION isc_info_db_impl_linux_mips /* 72 */
#endif /* mips */
2001-05-23 15:26:42 +02:00
#endif /* LINUX */
2002-06-29 15:03:13 +02:00
/*****************************************************
* Darwin Platforms
*****************************************************/
#ifdef DARWIN
2004-05-19 01:38:37 +02:00
// EKU: obsolete, replaced by _FILE_OFFSET_BITS
//#ifndef UNIX_64_BIT_IO
//#define UNIX_64_BIT_IO
//#endif
//
//format for __LINE__
#define LINEFORMAT "d"
2004-05-19 01:38:37 +02:00
//#define SLONGFORMAT "ld"
//#define ULONGFORMAT "lu"
//#define XLONGFORMAT "lX"
//#define xLONGFORMAT "lx"
2003-04-09 10:57:09 +02:00
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 4
//#define DOUBLE_ALIGN 4
//#define BSD_UNIX
#define UNIX
2007-03-09 11:32:58 +01:00
#ifdef powerpc
#define IMPLEMENTATION isc_info_db_impl_darwin_ppc /* 63 */
#endif
#ifdef i386
#define I386
2007-06-11 16:21:33 +02:00
#define IMPLEMENTATION isc_info_db_impl_darwin_x86 /* 70 */
2007-03-09 11:32:58 +01:00
#endif
2008-01-18 15:12:26 +01:00
#ifdef __x86_64__
#define DARWIN64
#define IMPLEMENTATION isc_info_db_impl_darwin_x64 /* 73 */
#endif
2001-07-12 07:46:06 +02:00
#define IEEE
#define QUADCONST(n) (n##LL)
#define QUADFORMAT "q"
2007-12-27 12:56:04 +01:00
#define MAP_ANON
2001-07-12 07:46:06 +02:00
#endif /* Darwin Platforms */
/*****************************************************
* FreeBSD for Intel platforms
*****************************************************/
2001-05-23 15:26:42 +02:00
#ifdef FREEBSD
2004-05-19 01:38:37 +02:00
// EKU: obsolete, replaced by _FILE_OFFSET_BITS
//#ifndef UNIX_64_BIT_IO
//#define UNIX_64_BIT_IO
//#endif
//
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 4
//#define DOUBLE_ALIGN 4
2001-05-23 15:26:42 +02:00
#define UNIX
#define IEEE
#ifdef AMD64
#define IMPLEMENTATION isc_info_db_impl_freebsd_amd64 /* 67 */
#else
#define I386
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_freebsd /* 61 */
#endif
2001-05-23 15:26:42 +02:00
#define QUADFORMAT "ll"
#define QUADCONST(n) (n##LL)
//#define KILLER_SIGNALS
2001-05-23 15:26:42 +02:00
#define NO_NFS /* no MTAB_OPEN or MTAB_CLOSE in isc_file.c */
#endif /* FREEBSD */
/*****************************************************
* NetBSD
*****************************************************/
2001-05-23 15:26:42 +02:00
#ifdef NETBSD
#if defined(__i386__)
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 4
//#define DOUBLE_ALIGN 4
2001-05-23 15:26:42 +02:00
#define IEEE
#define I386
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_netbsd /* 62 */
2001-05-23 15:26:42 +02:00
#define QUADFORMAT "ll"
#define QUADCONST(n) (n##LL)
#else /* !__i386__ */
#error Please add support for other ports
#endif
#define UNIX
2001-05-23 15:26:42 +02:00
//#define KILLER_SIGNALS
2001-05-23 15:26:42 +02:00
#define NO_NFS /* no MTAB_OPEN or MTAB_CLOSE in isc_file.c */
#endif /* NETBSD */
/*****************************************************
2003-02-13 07:12:52 +01:00
* SUN platforms--the 386i is obsolete
*****************************************************/
2001-05-23 15:26:42 +02:00
#ifdef sun
/* Defined KILLER_SIGNALS for Sun - as we were getting lots of lockups
* using pipe server.
* 1995-February-24 David Schnepper
2001-05-23 15:26:42 +02:00
*/
//#define KILLER_SIGNALS
2001-05-23 15:26:42 +02:00
#ifdef SOLARIS
/* This is NOT defined when building the special shared-pipe library
* which customers can use to avoid the problems with signals & threads
* in Solaris
*/
#define SOLARIS_MT
2006-05-01 06:43:59 +02:00
2001-05-23 15:26:42 +02:00
/* Define the following only on platforms whose standard I/O
* implementation is so weak that we wouldn't be able to fopen
* a file whose underlying file descriptor would be > 255.
* Hey, we're not running on PDP-11's any more: would it kill you
* to use a short instead of a char to hold the fileno? :-(
*/
2002-09-25 08:22:43 +02:00
/* Why we (solarises) need to rewrite old BSD stdio
so many times I suggest stdIO from
http://www.research.att.com/sw/tools/sfio/
*/
/* Need to use full sfio not just stdio emulation to fix
file descriptor number limit. nmcc Dec2002
*/
#if (!defined(SFIO) && defined(SUPERSERVER))
#error "need to use SFIO"
2002-09-25 08:22:43 +02:00
#endif
2001-05-23 15:26:42 +02:00
/* The following define is the prefix to go in front of a "d" or "u"
2004-04-29 00:43:34 +02:00
format item in a printf() format string, to indicate that the argument
2007-11-12 15:26:44 +01:00
is an SINT64 or FB_UINT64. */
2001-05-23 15:26:42 +02:00
#define QUADFORMAT "ll"
/* The following macro creates a quad-sized constant, possibly one
which is too large to fit in a long int. */
#define QUADCONST(n) (n##LL)
//#else /* SOLARIS */
2001-05-23 15:26:42 +02:00
//#define BSD_UNIX
2001-05-23 15:26:42 +02:00
#endif /* SOLARIS */
#define UNIX
#define IEEE
2001-05-23 15:26:42 +02:00
#ifdef sparc
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 4
//#define DOUBLE_ALIGN 8
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_isc_sun4 /* 30 */
#define RISC_ALIGNMENT
2001-05-23 15:26:42 +02:00
#else /* sparc */
#ifdef i386
#define I386
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_isc_sun_386i /* 32 */
2001-05-23 15:26:42 +02:00
#else /* i386 */
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_isc_sun_68k /* 28 */
2001-05-23 15:26:42 +02:00
#endif /* i386 */
#endif /* sparc */
2001-05-23 15:26:42 +02:00
#endif /* sun */
/*****************************************************
* HP/UX platforms
*****************************************************/
2001-05-23 15:26:42 +02:00
#ifdef HPUX
2001-05-23 15:26:42 +02:00
//#define KILLER_SIGNALS
#define UNIX
//#define CURSES_KEYPAD
2001-05-23 15:26:42 +02:00
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 8
//#define DOUBLE_ALIGN 8
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_isc_hp_ux /* 31 */
2001-05-23 15:26:42 +02:00
#define IEEE
#pragma OPT_LEVEL 1
2002-06-29 15:03:13 +02:00
// 16-Apr-2002 HP10 in unistd.h Paul Beach
2004-11-24 10:22:07 +01:00
//#define setreuid(ruid, euid) setresuid (ruid, euid, -1)
//#define setregid(rgid, egid) setresgid (rgid, egid, -1)
2001-05-23 15:26:42 +02:00
/* The following define is the prefix to go in front of a "d" or "u"
2004-04-29 00:43:34 +02:00
format item in a printf() format string, to indicate that the argument
2007-11-12 15:26:44 +01:00
is an SINT64 or FB_UINT64. */
2001-05-23 15:26:42 +02:00
#define QUADFORMAT "ll"
/* The following macro creates a quad-sized constant, possibly one
which is too large to fit in a long int. */
#define QUADCONST(n) (n##LL)
#define RISC_ALIGNMENT
#endif /* HPUX */
2001-05-23 15:26:42 +02:00
/*****************************************************
* IBM AIX RS/6000 and IBM AIX PowerPC
*****************************************************/
2001-05-23 15:26:42 +02:00
#ifdef _AIX /* IBM AIX */
#ifndef _POWER /* IBM RS/6000 */
#define AIX
//#define KILLER_SIGNALS
#define UNIX
//#define CURSES_KEYPAD
2004-05-19 01:38:37 +02:00
//*#define ALIGNMENT 4
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_isc_rt_aix /* 35 */
#define IEEE
2001-05-23 15:26:42 +02:00
#define SYSCALL_INTERRUPTED(err) (((err) == EINTR) || ((err) == ERESTART)) /* pjpg 20001102 */
#else /* AIX PowerPC */
#define AIX_PPC
//#define KILLER_SIGNALS
#define UNIX
//#define CURSES_KEYPAD
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 4
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_isc_rt_aix /* 35 */
#define IEEE
2001-05-23 15:26:42 +02:00
#define SYSCALL_INTERRUPTED(err) (((err) == EINTR) || ((err) == ERESTART)) /* pjpg 20001102 */
#define QUADFORMAT "ll" /* TMC 081700 */
#define QUADCONST(n) (n##LL) /* TMC 081700 */
#endif /* IBM PowerPC */
2001-05-23 15:26:42 +02:00
#endif /* IBM AIX */
/*****************************************************
* Windows NT
*****************************************************/
2001-05-23 15:26:42 +02:00
2002-11-14 14:40:04 +01:00
#ifdef WIN_NT
2003-09-13 20:35:39 +02:00
2001-05-23 15:26:42 +02:00
#define NO_NFS
#define SYS_ARG isc_arg_win32
#define SYS_ERR isc_arg_win32
2004-05-19 01:38:37 +02:00
//#define SLONGFORMAT "ld"
//#define ULONGFORMAT "lu"
//#define XLONGFORMAT "lX"
//#define xLONGFORMAT "lx"
//format for __LINE__
#define LINEFORMAT "d"
2001-05-23 15:26:42 +02:00
typedef __int64 SINT64;
2007-11-12 15:26:44 +01:00
typedef unsigned __int64 FB_UINT64;
2001-05-23 15:26:42 +02:00
#define INT64_DEFINED
/* The following define is the prefix to go in front of a "d" or "u"
2004-04-29 00:43:34 +02:00
format item in a printf() format string, to indicate that the argument
2007-11-12 15:26:44 +01:00
is an SINT64 or FB_UINT64. */
2001-05-23 15:26:42 +02:00
#define QUADFORMAT "I64"
/* The following macro creates a quad-sized constant, possibly one
which is too large to fit in a long int. The Microsoft compiler does
not permit the LL suffix which some other platforms require, but it
handles numbers up to the largest 64-bit integer correctly without such
a suffix, so the macro definition is trivial. */
2007-02-28 12:21:43 +01:00
#ifdef __GNUC__ // needed for gcc 3.3.1
#define QUADCONST(n) (n##LL)
#else
2001-05-23 15:26:42 +02:00
#define QUADCONST(n) (n)
#endif
2001-05-23 15:26:42 +02:00
2006-10-30 13:40:24 +01:00
#ifdef AMD64
#define IMPLEMENTATION isc_info_db_impl_winnt_amd64 /* 68 */
#else
2001-05-23 15:26:42 +02:00
#ifndef I386
#define I386
#endif
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_isc_winnt_x86 /* 50 */
2001-05-23 15:26:42 +02:00
#endif
#define IEEE
2001-05-23 15:26:42 +02:00
#define API_ROUTINE __stdcall
#define API_ROUTINE_VARARG __cdecl
#define CLIB_ROUTINE __cdecl
#define INTERNAL_API_ROUTINE API_ROUTINE
#define SYNC_WRITE_DEFAULT
2002-06-29 15:03:13 +02:00
2002-11-14 14:40:04 +01:00
#ifndef MAXPATHLEN
#ifdef MAX_PATH
#define MAXPATHLEN MAX_PATH
#else
#define MAXPATHLEN 260
#endif
#endif
#define ERRNO GetLastError()
#define INET_ERRNO WSAGetLastError()
#define H_ERRNO WSAGetLastError()
2001-05-23 15:26:42 +02:00
#endif /* WIN_NT */
// 23 Sep 2002, skidder, ALLOC_LIB_MEMORY moved here,
// DEBUG_GDS_ALLOC definition removed because allocators
// do not (and can not) include this file,
// but use DEBUG_GDS_ALLOC. Hence DEBUG_GDS_ALLOC should be defined
// globally by now and moved to autoconf-generated header later
#ifdef DEBUG_GDS_ALLOC
2004-11-24 10:22:07 +01:00
#define ALLOC_LIB_MEMORY(size) gds__alloc_debug ((size), (TEXT *)__FILE__, (ULONG)__LINE__)
#endif
2001-05-23 15:26:42 +02:00
/*****************************************************
* SCO
*****************************************************/
#ifdef SCO_EV
2001-05-23 15:26:42 +02:00
2002-06-29 15:03:13 +02:00
#define QUADFORMAT "ll"
#define QUADCONST(n) (n##LL)
#define I386
#define UNIX
#define SCO_UNIX
#define IEEE
2004-05-19 01:38:37 +02:00
//
//#define KILLER_SIGNALS
//
2002-06-29 15:03:13 +02:00
#define IMPLEMENTATION isc_info_db_impl_sco_ev /* 59 */
2001-05-23 15:26:42 +02:00
2004-05-19 01:38:37 +02:00
// These functions are supported so we don't need the defines
2004-11-24 10:22:07 +01:00
//#define setreuid(ruid, euid) setuid(euid)
//#define setregid(rgid, egid) setgid(egid)
2004-05-19 01:38:37 +02:00
//
2001-05-23 15:26:42 +02:00
#endif /* SCO_EV */
2001-05-23 15:26:42 +02:00
/*****************************************************
2003-02-13 07:12:52 +01:00
* UNIX
*****************************************************/
2001-05-23 15:26:42 +02:00
#ifdef UNIX
#define NO_CHECKSUM
2001-05-23 15:26:42 +02:00
#define SYS_ARG isc_arg_unix
#define SYS_ERR isc_arg_unix
2001-05-23 15:26:42 +02:00
#endif /* UNIX */
#ifndef SYS_ERR
#define SYS_ERR isc_arg_unix
#endif
#ifndef ERRNO
#define ERRNO errno
#endif
#ifndef INET_ERRNO
#define INET_ERRNO errno
#endif
#ifndef H_ERRNO
#define H_ERRNO h_errno
#endif
2001-05-23 15:26:42 +02:00
/* various declaration modifiers */
#ifndef API_ROUTINE
#define API_ROUTINE
#define API_ROUTINE_VARARG
#define INTERNAL_API_ROUTINE API_ROUTINE
#endif
#ifndef CLIB_ROUTINE
#define CLIB_ROUTINE
#endif
/* alignment macros */
#ifndef OLD_ALIGNMENT
#ifdef I386
/* Using internal alignment optimal for 386 processor and above
*/
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 4
//#define DOUBLE_ALIGN 8
2001-05-23 15:26:42 +02:00
#endif
#endif
#ifndef ALIGNMENT
2004-05-19 01:38:37 +02:00
//#define ALIGNMENT 2
#error must define ALIGNMENT for your system
2001-05-23 15:26:42 +02:00
#endif
#ifndef SHIFTLONG
/* Number of shifts needed to convert between char and LONG */
#define SHIFTLONG 2
#define BITS_PER_LONG 32
#define LOG2_BITS_PER_LONG 5
#endif
#ifndef DOUBLE_ALIGN
2004-05-19 01:38:37 +02:00
//#define DOUBLE_ALIGN 4
#error must define DOUBLE_ALIGN for your system
2001-05-23 15:26:42 +02:00
#endif
/* common return values */
#ifndef FINI_OK
#define FINI_OK 0
#define FINI_ERROR 1
#define STARTUP_ERROR 2 /* this is also used in iscguard.h, make sure these match */
#endif
2001-07-12 07:46:06 +02:00
#ifndef TRUE
2001-05-23 15:26:42 +02:00
#define TRUE 1
2001-07-12 07:46:06 +02:00
#endif
#ifndef FALSE
2001-05-23 15:26:42 +02:00
#define FALSE 0
2001-07-12 07:46:06 +02:00
#endif
#define FB_SUCCESS 0
#define FB_FAILURE 1
2001-05-23 15:26:42 +02:00
/* sys/paramh.h : compatibility purposes */
#ifndef NOFILE
#define NOFILE 20
#endif
2001-05-23 15:26:42 +02:00
/* data type definitions */
#ifndef INT64_DEFINED /* 64 bit */
typedef long long int SINT64;
2007-11-12 15:26:44 +01:00
typedef unsigned long long int FB_UINT64;
2001-05-23 15:26:42 +02:00
#else
#undef INT64_DEFINED
#endif
#ifndef ATOM_DEFINED /* 32 or 64 bit */
typedef long SATOM;
typedef unsigned long UATOM;
#else
#undef ATOM_DEFINED
#endif
#ifndef ISC_TIMESTAMP_DEFINED
typedef SLONG ISC_DATE;
typedef ULONG ISC_TIME;
2004-05-24 19:31:47 +02:00
struct ISC_TIMESTAMP
2001-05-23 15:26:42 +02:00
{
ISC_DATE timestamp_date;
ISC_TIME timestamp_time;
2004-05-24 19:31:47 +02:00
};
2001-05-23 15:26:42 +02:00
#define ISC_TIMESTAMP_DEFINED
#endif /* ISC_TIMESTAMP_DEFINED */
#define GDS_DATE ISC_DATE
#define GDS_TIME ISC_TIME
#define GDS_TIMESTAMP ISC_TIMESTAMP
#ifndef BLOB_PTR
#define BLOB_PTR UCHAR
#endif
2001-12-24 03:51:06 +01:00
#ifndef SLONGFORMAT
#if SIZEOF_LONG == 4
#define SLONGFORMAT "ld"
#define ULONGFORMAT "lu"
#define XLONGFORMAT "lX"
#define xLONGFORMAT "lx"
#else
2001-12-24 03:51:06 +01:00
#define SLONGFORMAT "d"
2003-04-01 13:24:18 +02:00
#define ULONGFORMAT "u"
2003-04-09 10:57:09 +02:00
#define XLONGFORMAT "X"
#define xLONGFORMAT "x"
2001-12-24 03:51:06 +01:00
#endif
#endif
2001-12-24 03:51:06 +01:00
//format for __LINE__
#ifndef LINEFORMAT
#define LINEFORMAT "ld"
#endif
2001-05-23 15:26:42 +02:00
/* conditional compilation macros */
/* MAX and MIN for datatypes */
#define MAX_UCHAR ((UCHAR)0xFF)
#define MIN_UCHAR 0x00
#define MAX_SCHAR 0x7F
2004-12-08 06:58:41 +01:00
#define MIN_SCHAR (-MAX_SCHAR - 1)
2001-05-23 15:26:42 +02:00
#define MAX_USHORT ((USHORT)0xFFFF)
#define MIN_USHORT 0x0000
#define MAX_SSHORT 0x7FFF
2004-12-08 06:58:41 +01:00
#define MIN_SSHORT (-MAX_SSHORT - 1)
2001-05-23 15:26:42 +02:00
#define MAX_ULONG ((ULONG)0xFFFFFFFF)
#define MIN_ULONG 0x00000000
#define MAX_SLONG 0x7FFFFFFF
2004-12-08 06:58:41 +01:00
#define MIN_SLONG (-MAX_SLONG - 1)
2001-05-23 15:26:42 +02:00
2007-11-12 15:26:44 +01:00
#define MAX_UINT64 ((FB_UINT64) QUADCONST(0xFFFFFFFFFFFFFFFF))
2001-05-23 15:26:42 +02:00
#define MIN_UINT64 QUADCONST(0x0000000000000000)
#define MAX_SINT64 QUADCONST(0x7FFFFFFFFFFFFFFF)
2004-12-08 06:58:41 +01:00
#define MIN_SINT64 (-MAX_SINT64 - 1)
2001-05-23 15:26:42 +02:00
/* commonly used macros */
#ifndef MAX
2004-11-24 10:22:07 +01:00
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
2001-05-23 15:26:42 +02:00
#endif
#ifndef MIN
2004-11-24 10:22:07 +01:00
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
2001-05-23 15:26:42 +02:00
#endif
2004-12-25 10:44:03 +01:00
#define UPPER(c) (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c))
#define LOWWER(c) (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
2001-05-23 15:26:42 +02:00
/* UPPER7 & LOWWER7 are to be used when the data is known to
be 7-bit ASCII, eg: internal data, OS data. NOT user data. */
2004-12-25 10:44:03 +01:00
#define UPPER7(c) (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c))
#define LOWWER7(c) (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
2001-05-23 15:26:42 +02:00
#ifndef ROUNDUP
2004-11-24 10:22:07 +01:00
#define ROUNDUP(n, b) (((n) + (b) - 1) & ~((b) - 1))
2001-05-23 15:26:42 +02:00
#endif
#define ROUNDUP_LONG(len) ROUNDUP (len, sizeof (SLONG))
#define JRD_BUGCHK 15 /* facility code for bugcheck messages */
#ifndef OFFSET
2004-11-24 10:22:07 +01:00
#define OFFSET(struct, fld) ((size_t) &((struct) NULL)->fld)
#define OFFSETA(struct, fld) ((size_t) ((struct) NULL)->fld)
2001-05-23 15:26:42 +02:00
#endif
#ifndef ODS_ALIGNMENT
#define ODS_ALIGNMENT 4
#endif
#ifndef FORMAT_ALIGNMENT
// Alignment for items in record format. Used for databases after ODS11.
// Always 64-bit to ensure ODS compatibility with 64-bit versions of the engine
#define FORMAT_ALIGNMENT 8
#endif
2001-05-23 15:26:42 +02:00
#ifndef SYSCALL_INTERRUPTED
#define SYSCALL_INTERRUPTED(err) ((err) == EINTR)
#endif
/* data movement and allocation macros */
2008-01-16 09:31:31 +01:00
#define MOVE_CLEAR(to, length) memset(to, 0, (size_t) (length))
2001-05-23 15:26:42 +02:00
#ifndef ALLOC_LIB_MEMORY
#define ALLOC_LIB_MEMORY(size) gds__alloc (size)
#endif
#ifndef FREE_LIB_MEMORY
#define FREE_LIB_MEMORY(block) gds__free (block)
#endif
// This macros are used to workaround shortage of standard conformance
// in Microsoft compilers. They could be replaced with normal procedure
// and generic macro if MSVC would support C99-style __VA_ARGS__
#define DEFINE_TRACE_ROUTINE(routine) void routine(const char* message, ...)
2003-10-07 09:24:25 +02:00
#ifdef HAVE_VSNPRINTF
2004-11-24 10:22:07 +01:00
#define VSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
2003-10-07 09:24:25 +02:00
#else
2004-11-24 10:22:07 +01:00
#define VSNPRINTF(a, b, c, d) vsprintf(a, c, d)
2003-10-07 09:24:25 +02:00
#endif
#ifdef HAVE_SNPRINTF
#define SNPRINTF snprintf
#else
#define SNPRINTF(buffer, length, ...) sprintf(buffer, __VA_ARGS__)
#endif
#define IMPLEMENT_TRACE_ROUTINE(routine, subsystem) \
void routine(const char* message, ...) { \
static const char name_facility[] = subsystem ","; \
char buffer[1000]; \
strcpy(buffer, name_facility); \
2003-10-07 11:55:59 +02:00
char *ptr = buffer + sizeof(name_facility) - 1; \
va_list params; \
va_start(params, message); \
2003-10-07 11:55:59 +02:00
VSNPRINTF(ptr, sizeof(buffer) - sizeof(name_facility), message, params); \
va_end(params); \
gds__trace(buffer); \
}
2001-05-23 15:26:42 +02:00
// Shortcuts to make it easier to convert code using SLONGFORMAT/ULONGFORMAT
#define UQUADFORMAT QUADFORMAT"u"
#define SQUADFORMAT QUADFORMAT"d"
2001-05-23 15:26:42 +02:00
#ifdef DEV_BUILD
/* Define any debugging symbols and macros here. This
2001-05-23 15:26:42 +02:00
ifdef will be executed during development builds. */
#define TRACE(msg) gds__trace (msg)
2001-05-23 15:26:42 +02:00
#ifndef DEV_REPORT
#define DEV_REPORT(msg) gds__log (msg)
2001-05-23 15:26:42 +02:00
#endif
#ifndef BREAKPOINT
#define BREAKPOINT(x) GDS_breakpoint(x)
// fwd. decl. the function itself
#ifdef __cplusplus
extern "C" {
#endif
void GDS_breakpoint(int);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
#endif /* DEV_BUILD */
#ifndef DEV_BUILD
#ifndef DEV_REPORT
2001-05-23 15:26:42 +02:00
#define DEV_REPORT(msg) gds__log (msg)
#endif
#ifndef BREAKPOINT
2001-05-23 15:26:42 +02:00
#define BREAKPOINT(x) /* nothing */
#endif
#ifndef TRACE
2001-05-23 15:26:42 +02:00
#define TRACE(msg) /* nothing */
#endif
2001-05-23 15:26:42 +02:00
#endif
/* commonly used buffer sizes for dynamic buffer allocation */
#define BUFFER_XLARGE 2048
#define BUFFER_LARGE 1024
#define BUFFER_MEDIUM 512
#define BUFFER_SMALL 256
#define BUFFER_TINY 128
2002-06-29 15:03:13 +02:00
/* The default lseek offset type. Changed from nothing to (off_t) to correctly support 64 bit IO */
2001-07-12 07:46:06 +02:00
#ifndef LSEEK_OFFSET_CAST
2002-06-29 15:03:13 +02:00
#define LSEEK_OFFSET_CAST (off_t)
2001-07-12 07:46:06 +02:00
#endif
2001-05-23 15:26:42 +02:00
#ifndef DOUBLE_MULTIPLY
2004-11-24 10:22:07 +01:00
#define DOUBLE_MULTIPLY(a, b) (((double) (a)) * ((double) (b)))
2001-05-23 15:26:42 +02:00
#endif
#ifndef DOUBLE_DIVIDE
2004-11-24 10:22:07 +01:00
#define DOUBLE_DIVIDE(a, b) (((double) (a)) / ((double) (b)))
2001-05-23 15:26:42 +02:00
#endif
#define STRINGIZE_AUX(x) #x
#define STRINGIZE(x) STRINGIZE_AUX(x)
2007-04-19 11:19:11 +02:00
#ifdef _MSC_VER
#define CONST64(a) (a##i64)
#else
2007-04-25 16:03:45 +02:00
#define CONST64(a) (a##LL)
2007-04-19 11:19:11 +02:00
#endif
2001-05-23 15:26:42 +02:00
/* switch name and state table. This structure should be used in all
* command line tools to facilitate parsing options.*/
2003-12-31 06:36:12 +01:00
struct in_sw_tab_t {
2001-05-23 15:26:42 +02:00
int in_sw;
int in_spb_sw;
2003-12-31 06:36:12 +01:00
const TEXT* in_sw_name;
2001-05-23 15:26:42 +02:00
ULONG in_sw_value; /* alice specific field */
ULONG in_sw_requires; /* alice specific field */
ULONG in_sw_incompatibilities; /* alice specific field */
USHORT in_sw_state;
USHORT in_sw_msg;
USHORT in_sw_min_length;
const TEXT* in_sw_text;
2001-05-23 15:26:42 +02:00
2003-12-31 06:36:12 +01:00
};
2001-05-23 15:26:42 +02:00
#ifndef HAVE_WORKING_VFORK
#define vfork fork
#endif
2003-12-31 06:36:12 +01:00
static const TEXT FB_SHORT_MONTHS[][4] =
2003-12-31 06:36:12 +01:00
{
"Jan", "Feb", "Mar",
"Apr", "May", "Jun",
"Jul", "Aug", "Sep",
"Oct", "Nov", "Dec",
"\0"
2003-12-31 06:36:12 +01:00
};
static const TEXT* FB_LONG_MONTHS_UPPER[] =
{
"JANUARY",
"FEBRUARY",
"MARCH",
"APRIL",
"MAY",
"JUNE",
"JULY",
"AUGUST",
"SEPTEMBER",
"OCTOBER",
"NOVEMBER",
"DECEMBER",
0
};
#endif /* JRD_COMMON_H */
2003-12-31 06:36:12 +01:00