8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-25 01:23:03 +01:00
firebird-mirror/src/jrd/isc.h

397 lines
7.2 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD access method
* MODULE: isc.h
* DESCRIPTION: Common descriptions for general-purpose but non-user routines
*
* 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): ______________________________________.
*
2002-06-29 15:03:13 +02:00
* 26-Sept-2001 Paul Beach - External File Directory Config. Parameter
* 17-Oct-2001 Mike Nordell - CPU affinity
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_ISC_H
#define JRD_ISC_H
2001-05-23 15:26:42 +02:00
// For AST_THREAD
#include "../jrd/common.h"
#include "../jrd/sch_proto.h"
2001-05-23 15:26:42 +02:00
// For AstInhibit
#include "../jrd/os/isc_i_proto.h"
2001-05-23 15:26:42 +02:00
/* Defines for semaphore and shared memory removal */
2004-05-03 23:43:56 +02:00
const USHORT ISC_SEM_REMOVE = 1;
const USHORT ISC_MEM_REMOVE = 2; // tested but never set
2001-05-23 15:26:42 +02:00
// Firebird platform-specific synchronization data structures
2001-05-23 15:26:42 +02:00
#ifdef VMS
2004-05-24 19:31:47 +02:00
struct itm {
2001-05-23 15:26:42 +02:00
SSHORT itm_length;
SSHORT itm_code;
SCHAR *itm_buffer;
SSHORT *itm_return_length;
2004-05-24 19:31:47 +02:00
};
typedef itm ITM;
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct event_t {
2001-05-23 15:26:42 +02:00
SLONG event_pid;
SLONG event_count;
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
2004-05-24 19:31:47 +02:00
struct wait {
2001-05-23 15:26:42 +02:00
USHORT wait_count;
2004-02-02 12:02:12 +01:00
event_t* wait_events;
2001-05-23 15:26:42 +02:00
SLONG *wait_values;
2004-05-24 19:31:47 +02:00
};
typedef wait WAIT;
2001-05-23 15:26:42 +02:00
/* Lock status block */
struct lock_status {
2001-05-23 15:26:42 +02:00
SSHORT lksb_status;
SSHORT lksb_reserved;
SLONG lksb_lock_id;
SLONG lksb_value[4];
};
2001-05-23 15:26:42 +02:00
/* Poke block (for asynchronous poking) */
2004-05-24 19:31:47 +02:00
struct poke {
2001-05-23 15:26:42 +02:00
struct poke *poke_next;
lock_status poke_lksb;
2001-05-23 15:26:42 +02:00
SLONG poke_parent_id;
USHORT poke_value;
USHORT poke_use_count;
2004-05-24 19:31:47 +02:00
};
typedef poke* POKE;
2001-05-23 15:26:42 +02:00
#define SH_MEM_STRUCTURE_DEFINED
2004-05-24 19:31:47 +02:00
struct sh_mem {
2001-05-23 15:26:42 +02:00
int sh_mem_system_flag;
UCHAR *sh_mem_address;
SLONG sh_mem_length_mapped;
SLONG sh_mem_mutex_arg;
SLONG sh_mem_handle;
SLONG sh_mem_retadr[2];
SLONG sh_mem_channel;
TEXT sh_mem_filename[MAXPATHLEN];
2004-05-24 19:31:47 +02:00
};
typedef struct sh_mem SH_MEM_T;
typedef struct sh_mem* SH_MEM;
#endif // VMS
2001-05-23 15:26:42 +02:00
#ifdef UNIX
#define MTX_STRUCTURE_DEFINED
// This is the only place where COND_STRUCT and MUTEX_STRUCT are used.
// Therefore it's definitions were moved here from thd.h in order
// to avoid circular dependencies in h-files.
// Alex Peshkov. Tue 08 Jun 2004 02:22:08 PM MSD.
#if defined(SOLARIS_MT)
#include <thread.h>
#define COND_STRUCT cond_t
#define MUTEX_STRUCT mutex_t
#endif
#ifdef USE_POSIX_THREADS
#include <pthread.h>
#define COND_STRUCT pthread_cond_t
#define MUTEX_STRUCT pthread_mutex_t
#endif
2001-05-23 15:26:42 +02:00
#ifndef COND_STRUCT
#define COND_STRUCT SCHAR
#endif
#ifndef MUTEX_STRUCT
#define MUTEX_STRUCT SCHAR
#endif
2001-05-23 15:26:42 +02:00
2006-05-01 06:12:30 +02:00
#ifdef MULTI_THREAD
2004-05-24 19:31:47 +02:00
struct mtx {
MUTEX_STRUCT mtx_mutex[1];
2004-05-24 19:31:47 +02:00
};
typedef mtx MTX_T;
typedef mtx* MTX;
2001-05-23 15:26:42 +02:00
#else
2004-05-24 19:31:47 +02:00
struct mtx {
2001-05-23 15:26:42 +02:00
SLONG mtx_semid;
SSHORT mtx_semnum;
SCHAR mtx_use_count;
SCHAR mtx_wait;
2004-05-24 19:31:47 +02:00
};
typedef mtx MTX_T;
typedef mtx* MTX;
2006-05-01 06:12:30 +02:00
#endif // MULTI_THREAD
2006-05-01 06:12:30 +02:00
#ifdef MULTI_THREAD
2004-02-02 12:02:12 +01:00
struct event_t
2001-05-23 15:26:42 +02:00
{
SLONG event_semid;
SLONG event_count;
MUTEX_STRUCT event_mutex[1];
COND_STRUCT event_semnum[1];
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
#else
2004-02-02 12:02:12 +01:00
struct event_t
2001-05-23 15:26:42 +02:00
{
SLONG event_semid;
SLONG event_count;
SSHORT event_semnum;
2004-02-02 12:02:12 +01:00
};
2006-05-01 06:12:30 +02:00
#endif // MULTI_THREAD
2001-05-23 15:26:42 +02:00
#define SH_MEM_STRUCTURE_DEFINED
2004-05-24 19:31:47 +02:00
struct sh_mem
2001-05-23 15:26:42 +02:00
{
int sh_mem_semaphores;
UCHAR *sh_mem_address;
SLONG sh_mem_length_mapped;
SLONG sh_mem_mutex_arg;
SLONG sh_mem_handle;
2004-05-24 19:31:47 +02:00
};
typedef sh_mem SH_MEM_T;
typedef sh_mem *SH_MEM;
#endif // UNIX
2001-05-23 15:26:42 +02:00
#ifdef WIN_NT
#define MTX_STRUCTURE_DEFINED
#include <windows.h>
typedef struct _FAST_MUTEX_SHARED_SECTION
{
SLONG fInitialized;
SLONG lSpinLock;
SLONG lThreadsWaiting;
SLONG lAvailable;
#ifdef _DEBUG
DWORD dwThreadId;
#endif
} FAST_MUTEX_SHARED_SECTION;
typedef struct _FAST_MUTEX
{
HANDLE hEvent;
HANDLE hFileMap;
SLONG lSpinCount;
volatile FAST_MUTEX_SHARED_SECTION* lpSharedInfo;
} FAST_MUTEX;
2004-05-24 19:31:47 +02:00
struct mtx
2001-05-23 15:26:42 +02:00
{
FAST_MUTEX mtx_fast;
2004-05-24 19:31:47 +02:00
};
typedef mtx MTX_T;
typedef mtx *MTX;
2001-05-23 15:26:42 +02:00
2004-02-02 12:02:12 +01:00
struct event_t
2001-05-23 15:26:42 +02:00
{
SLONG event_pid;
SLONG event_count;
SLONG event_type;
void* event_handle;
event_t* event_shared;
2004-02-02 12:02:12 +01:00
};
2001-05-23 15:26:42 +02:00
#define SH_MEM_STRUCTURE_DEFINED
2004-05-24 19:31:47 +02:00
struct sh_mem
2001-05-23 15:26:42 +02:00
{
UCHAR* sh_mem_address;
SLONG sh_mem_length_mapped;
SLONG sh_mem_mutex_arg;
void* sh_mem_handle;
void* sh_mem_object;
void* sh_mem_interest;
void* sh_mem_hdr_object;
SLONG* sh_mem_hdr_address;
TEXT sh_mem_name[MAXPATHLEN];
2004-05-24 19:31:47 +02:00
};
typedef sh_mem SH_MEM_T;
typedef sh_mem *SH_MEM;
2001-05-23 15:26:42 +02:00
#define THREAD_HANDLE_DEFINED
typedef void *THD_T;
#endif // WIN_NT
2001-05-23 15:26:42 +02:00
#ifndef MTX_STRUCTURE_DEFINED
#define MTX_STRUCTURE_DEFINED
2004-05-24 19:31:47 +02:00
struct mtx
2001-05-23 15:26:42 +02:00
{
SSHORT mtx_event_count[3];
SCHAR mtx_use_count;
SCHAR mtx_wait;
2004-05-24 19:31:47 +02:00
};
typedef mtx MTX_T;
typedef mtx *MTX;
2001-05-23 15:26:42 +02:00
#endif
#undef MTX_STRUCTURE_DEFINED
#ifndef SH_MEM_STRUCTURE_DEFINED
#define SH_MEM_STRUCTURE_DEFINED
2004-05-24 19:31:47 +02:00
struct sh_mem
2001-05-23 15:26:42 +02:00
{
UCHAR* sh_mem_address;
SLONG sh_mem_length_mapped;
SLONG sh_mem_mutex_arg;
SLONG sh_mem_handle;
2004-05-24 19:31:47 +02:00
};
typedef sh_mem SH_MEM_T;
typedef sh_mem *SH_MEM;
2001-05-23 15:26:42 +02:00
#endif
#undef SH_MEM_STRUCTURE_DEFINED
#ifndef THREAD_HANDLE_DEFINED
#define THREAD_HANDLE_DEFINED
typedef ULONG THD_T;
#endif
#undef THREAD_HANDLE_DEFINED
// Interprocess communication configuration structure
// This was used to read to and write from the Config dialog when the server
// or the guardian is showing an icon in the tray.
2001-05-23 15:26:42 +02:00
/*
2004-05-24 19:31:47 +02:00
struct ipccfg
2001-05-23 15:26:42 +02:00
{
const char* ipccfg_keyword;
SCHAR ipccfg_key;
SLONG* ipccfg_variable;
SSHORT ipccfg_parent_offset; // Relative offset of parent keyword
USHORT ipccfg_found; // TRUE when keyword has been set
2004-05-24 19:31:47 +02:00
};
typedef ipccfg *IPCCFG;
*/
2001-05-23 15:26:42 +02:00
/* AST thread scheduling macros */
#ifdef AST_THREAD
inline void AST_ALLOC() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_alloc);
}
inline void AST_INIT() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_init);
}
inline void AST_FINI() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_fini);
}
inline void AST_CHECK() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_check);
}
inline void AST_DISABLE() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_disable);
}
inline void AST_ENABLE() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_enable);
}
inline void AST_ENTER() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_enter);
}
inline void AST_EXIT() {
2004-05-17 12:22:34 +02:00
SCH_ast(AST_exit);
}
2001-05-23 15:26:42 +02:00
#else
inline void AST_ALLOC() {
2004-05-17 12:22:34 +02:00
}
inline void AST_INIT() {
2004-05-17 12:22:34 +02:00
}
inline void AST_FINI() {
2004-05-17 12:22:34 +02:00
}
inline void AST_CHECK() {
2004-05-17 12:22:34 +02:00
}
inline void AST_DISABLE() {
2004-05-17 12:22:34 +02:00
}
inline void AST_ENABLE() {
2004-05-17 12:22:34 +02:00
}
inline void AST_ENTER() {
2004-05-17 12:22:34 +02:00
}
inline void AST_EXIT() {
2004-05-17 12:22:34 +02:00
}
2001-05-23 15:26:42 +02:00
#endif
namespace Jrd {
#ifdef MULTI_THREAD
2007-02-23 06:55:37 +01:00
// This class inhibits AST processing.
2007-02-23 06:55:37 +01:00
class AstInhibit
{
public:
// Constructor inhibits processing.
AstInhibit() : enabled(false)
{
AST_DISABLE();
}
// Destructor re-enables processing.
~AstInhibit()
{
enable();
}
// Let one re-enable processing in advance.
void enable()
{
if (enabled)
return;
enabled = true;
AST_ENABLE();
}
private:
// Forbid copy constructor
AstInhibit(const AstInhibit&);
bool enabled;
};
2007-02-23 02:42:10 +01:00
#else // MULTI_THREAD
class AstInhibit : public SignalInhibit
//
// This class inhibits signals' processing.
//
{
public:
AstInhibit() { }
private:
// Forbid copy constructor
AstInhibit(const AstInhibit&);
};
2007-02-23 02:42:10 +01:00
#endif // MULTI_THREAD
} // namespace Jrd
2003-11-06 04:03:36 +01:00
2007-02-23 02:42:10 +01:00
#endif // JRD_ISC_H