8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 17:23:04 +01:00

-Replace *_thread_data macros with inline functions (jrd step 2)

This commit is contained in:
brodsom 2004-05-23 03:18:10 +00:00
parent ae07959c53
commit bed146ad19
22 changed files with 165 additions and 210 deletions

View File

@ -63,7 +63,7 @@ void ALL_check_memory()
* executed.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
#ifdef V4_THREADING
V4_RW_LOCK_LOCK(dbb->dbb_rw_locks + DBB_WLCK_pools, WLCK_read);
@ -97,7 +97,7 @@ JrdMemoryPool *JrdMemoryPool::createDbPool(Firebird::MemoryStats &stats) {
}
JrdMemoryPool *JrdMemoryPool::createPool() {
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
fb_assert(dbb);
#ifdef SUPERSERVER
@ -114,7 +114,7 @@ JrdMemoryPool *JrdMemoryPool::createPool() {
}
void JrdMemoryPool::deletePool(JrdMemoryPool* pool) {
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
Database::pool_vec_type::iterator itr =
std::find(dbb->dbb_pools.begin(), dbb->dbb_pools.end(), pool);
if (itr != dbb->dbb_pools.end()) dbb->dbb_pools.erase(itr);
@ -178,7 +178,7 @@ void ALL_fini(void)
* released at the top of this routine.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
/* Don't know if we even need to do this, so it is commented out */
//delete dbb;

View File

@ -33,7 +33,7 @@
*
*/
/*
$Id: blb.cpp,v 1.78 2004-05-22 14:24:52 brodsom Exp $
$Id: blb.cpp,v 1.79 2004-05-23 03:18:08 brodsom Exp $
*/
#include "firebird.h"
@ -661,7 +661,7 @@ SLONG BLB_get_slice(thread_db* tdbb,
ISC_STATUS status;
SET_TDBB(tdbb);
Database* database = GET_DBB;
Database* database = GET_DBB();
tdbb->tdbb_default = transaction->tra_pool;
/* Checkout slice description language */
@ -1590,7 +1590,7 @@ static ArrayField* alloc_array(jrd_tra* transaction, internal_array_desc* proto_
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
// Compute size and allocate block

View File

@ -344,7 +344,7 @@ bool BTR_description(jrd_rel* relation, index_root_page* root, index_desc* idx,
* Index id's must fit in a short - formerly a UCHAR.
*
**************************************/
const Database* dbb = GET_DBB;
const Database* dbb = GET_DBB();
if (id >= root->irt_count) {
return false;
@ -5931,7 +5931,7 @@ void update_selectivity(index_root_page* root, USHORT id,
* Update selectivity on the index root page.
*
**************************************/
const Database* dbb = GET_DBB;
const Database* dbb = GET_DBB();
index_root_page::irt_repeat* irt_desc = &root->irt_rpt[id];
const USHORT idx_count = irt_desc->irt_keys;

View File

@ -3,16 +3,16 @@
*** DO NOT EDIT ***
TO CHANGE ANY INFORMATION IN HERE PLEASE
EDIT src/misc/writeBuildNum.sh
FORMAL BUILD NUMBER:7616
FORMAL BUILD NUMBER:7609
*/
#define PRODUCT_VER_STRING "2.0.0.7616"
#define FILE_VER_STRING "WI-T2.0.0.7616"
#define LICENSE_VER_STRING "WI-T2.0.0.7616"
#define FILE_VER_NUMBER 2, 0, 0, 7616
#define PRODUCT_VER_STRING "2.0.0.7609"
#define FILE_VER_STRING "WI-T2.0.0.7609"
#define LICENSE_VER_STRING "WI-T2.0.0.7609"
#define FILE_VER_NUMBER 2, 0, 0, 7609
#define FB_MAJOR_VER "2"
#define FB_MINOR_VER "0"
#define FB_REV_NO "0"
#define FB_BUILD_NO "7616"
#define FB_BUILD_NO "7609"
#define FB_BUILD_TYPE "T"
#define FB_BUILD_SUFFIX "Firebird 2.0 UNSTABLE"

View File

@ -424,14 +424,14 @@ int CCH_down_grade_dbb(void* ast_object)
if (SHUT_blocking_ast(dbb)) {
dbb->dbb_ast_flags &= ~DBB_blocking;
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}
/*
if (dbb->dbb_use_count)
{
JRD_restore_thread_data;
JRD_restore_thread_data();
return;
}
*/
@ -441,21 +441,21 @@ if (dbb->dbb_use_count)
and we can't give it anyway */
if ((lock->lck_logical == LCK_SW) || (lock->lck_logical == LCK_SR)) {
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}
if (dbb->dbb_flags & DBB_bugcheck) {
LCK_convert(tdbb, lock, LCK_SW, LCK_WAIT);
dbb->dbb_ast_flags &= ~DBB_blocking;
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}
/* If we are supposed to be exclusive, stay exclusive */
if ((dbb->dbb_flags & DBB_exclusive) || (dbb->dbb_ast_flags & DBB_shutdown_single)) {
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}
@ -492,7 +492,7 @@ if (dbb->dbb_use_count)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}
@ -2741,7 +2741,7 @@ static int blocking_ast_bdb(void* ast_object)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
ISC_ast_exit();

View File

@ -144,7 +144,7 @@ int DBG_all(void)
* Print all known blocks.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
if (!dbg_file) {
dbg_file = fopen("tt:", "w");
@ -190,7 +190,7 @@ int DBG_analyze(int pool_id)
SLONG sum_length;
} blocks[type_MAX], nodes[nod_MAX], *p, *end;
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
VEC vector = dbb->dbb_pools;
if (!vector)
@ -307,7 +307,7 @@ int DBG_bdbs(void)
* Functional description
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
BufferControl* bcb = dbb->dbb_bcb;
for (unsigned int i = 0; i < bcb->bcb_count; i++)
@ -333,7 +333,7 @@ int DBG_precedence(void)
BufferDesc* hi_bdb;
BufferDesc* lo_bdb;
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
BufferControl* bcb = dbb->dbb_bcb;
for (unsigned int i = 0; i < bcb->bcb_count; i++) {
@ -536,7 +536,7 @@ int DBG_check(int pool_id)
* Check pool for integrity.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
int corrupt = 0;
@ -960,7 +960,7 @@ int DBG_verify(void)
* Verify integrity of all pools.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
if (!dbg_file)
dbg_file = fopen("tt:", "w");
@ -1006,7 +1006,7 @@ int DBG_memory(void)
* Print memory usage
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
fprintf(dbg_file, "MEMORY UTILIZATION for database\n\n");
#ifdef V4_THREADING

View File

@ -441,7 +441,7 @@ void DFW_perform_system_work(void)
* system transaction.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
DFW_perform_work(dbb->dbb_sys_trans);
}
@ -575,7 +575,7 @@ void DFW_perform_post_commit_work(jrd_tra* transaction)
bool pending_events = false;
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
Lock* lock = dbb->dbb_lock;
DeferredWork* work;

View File

@ -86,7 +86,7 @@ void DMP_active(void)
* Dump all buffers that are active.
*
**************************************/
const Database* dbb = GET_DBB;
const Database* dbb = GET_DBB();
const BufferControl* bcb = dbb->dbb_bcb;
for (USHORT i = 0; i < bcb->bcb_count; i++)
@ -118,7 +118,7 @@ void DMP_btc(void)
**************************************/
SCHAR buffer[250];
const Database* dbb = GET_DBB;
const Database* dbb = GET_DBB();
SLONG level = 0;
const BufferDesc* bdb = dbb->dbb_bcb->bcb_btree;
@ -146,7 +146,7 @@ void DMP_btc_errors(void)
**************************************/
SCHAR buffer[250];
const Database* dbb = GET_DBB;
const Database* dbb = GET_DBB();
SLONG level = 0;
const BufferDesc* bdb = dbb->dbb_bcb->bcb_btree;
@ -167,7 +167,7 @@ void DMP_btc_ordered(void)
* Dump the dirty page b-tree.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
/* Pick starting place at leftmost node */
@ -231,7 +231,7 @@ void DMP_dirty(void)
* Dump all buffers that are dirty.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
const BufferControl* bcb = dbb->dbb_bcb;
for (USHORT i = 0; i < bcb->bcb_count; i++)
@ -882,7 +882,7 @@ static void dmp_pip(const page_inv_page* page, ULONG sequence)
* Print a page inventory page.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
PageControl* control = dbb->dbb_pcontrol;
fprintf(dbg_file,
@ -922,7 +922,7 @@ static void dmp_pointer(const pointer_page* page)
* Functional description
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
fprintf(dbg_file,
"POINTER PAGE\t checksum %d\t generation %ld\n\tRelation: %d, Flags: %x, Sequence: %ld, Next: %ld, Count: %d\n",

View File

@ -75,7 +75,7 @@ void ERR_bugcheck(int number)
* Things seem to be going poorly today.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
dbb->dbb_flags |= DBB_bugcheck;
CCH_shutdown_database(dbb);
@ -98,7 +98,7 @@ void ERR_bugcheck_msg(const TEXT* msg)
* Things seem to be going poorly today.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
dbb->dbb_flags |= DBB_bugcheck;
DEBUG;

View File

@ -143,7 +143,7 @@ ExternalFile* EXT_file(jrd_rel* relation, const TEXT* file_name, bid* descriptio
* Create a file block for external file access.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
CHECK_DBB(dbb);
/* if we already have a external file associated with this relation just
@ -452,7 +452,7 @@ void EXT_store(record_param* rpb, int* transaction)
/* check if file is read only if read only then
post error we cannot write to this file */
if (file->ext_flags & EXT_readonly) {
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
CHECK_DBB(dbb);
/* Distinguish error message for a ReadOnly database */
if (dbb->dbb_flags & DBB_read_only)

View File

@ -1249,7 +1249,7 @@ static int index_block_flush(void* ast_object)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}

View File

@ -425,7 +425,7 @@ inline static void api_entry_point_init(ISC_STATUS* user_status)
user_status[2] = isc_arg_end;
}
inline static thread_db* set_thread_data(thread_db& thd_context)
inline static thread_db* JRD_MAIN_set_thread_data(thread_db& thd_context)
{
thread_db* tdbb = &thd_context;
MOVE_CLEAR(tdbb, sizeof(thread_db));
@ -433,61 +433,6 @@ inline static thread_db* set_thread_data(thread_db& thd_context)
return tdbb;
}
#undef JRD_get_thread_data
#undef CHECK_DBB
#undef GET_DBB
#undef SET_TDBB
static thread_db* get_thread_data()
{
THDD p1 = THD_get_specific();
#ifdef DEV_BUILD
if (p1 && p1->thdd_type == THDD_TYPE_TDBB)
{
thread_db* p2 = (thread_db*)p1;
if (p2->tdbb_database &&
MemoryPool::blk_type(p2->tdbb_database) != type_dbb)
{
BUGCHECK(147);
}
}
#endif // DEV_BUILD
return (thread_db*) p1;
}
inline static void CHECK_DBB(Database* dbb)
{
#ifdef DEV_BUILD
fb_assert(dbb && MemoryPool::blk_type(dbb) == type_dbb);
#endif // DEV_BUILD
}
inline static void check_tdbb(thread_db* tdbb)
{
#ifdef DEV_BUILD
fb_assert(tdbb &&
(reinterpret_cast<THDD>(tdbb)->thdd_type == THDD_TYPE_TDBB) &&
(!tdbb->tdbb_database ||
MemoryPool::blk_type(tdbb->tdbb_database) == type_dbb));
#endif // DEV_BUILD
}
inline static Database* get_dbb()
{
return get_thread_data()->tdbb_database;
}
static void SET_TDBB(thread_db*& tdbb)
{
if (tdbb == NULL) {
tdbb = get_thread_data();
}
check_tdbb(tdbb);
}
#define CHECK_HANDLE(blk,type,error) \
if (!blk || MemoryPool::blk_type(blk) != type) \
return handle_error (user_status, error, tdbb)
@ -624,7 +569,7 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
expanded_name = expanded_filename;
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
/* If database name is not alias, check it against conf file */
if (!is_alias && !verify_database_name(expanded_filename, user_status)) {
@ -1349,7 +1294,7 @@ ISC_STATUS GDS_BLOB_INFO(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
const blb* blob = check_blob(tdbb, user_status, blob_handle);
if (!blob) {
@ -1389,7 +1334,7 @@ ISC_STATUS GDS_CANCEL_BLOB(ISC_STATUS * user_status, blb** blob_handle)
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
if (*blob_handle) {
blb* blob = check_blob(tdbb, user_status, blob_handle);
@ -1433,7 +1378,7 @@ ISC_STATUS GDS_CANCEL_EVENTS(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
if (check_database(tdbb, *handle, user_status)) {
return user_status[1];
@ -1536,7 +1481,7 @@ ISC_STATUS GDS_CLOSE_BLOB(ISC_STATUS * user_status, blb** blob_handle)
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
blb* blob = check_blob(tdbb, user_status, blob_handle);
if (!blob)
@ -1624,7 +1569,7 @@ ISC_STATUS GDS_COMPILE(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
NULL_CHECK(req_handle, isc_bad_req_handle);
Attachment* attachment = *db_handle;
@ -1682,7 +1627,7 @@ ISC_STATUS GDS_CREATE_BLOB2(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
NULL_CHECK(blob_handle, isc_bad_segstr_handle);
@ -1754,7 +1699,7 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
expanded_name = expanded_filename;
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Database* dbb = init(tdbb, user_status, expanded_name, false);
if (!dbb) {
@ -2095,7 +2040,7 @@ ISC_STATUS GDS_DATABASE_INFO(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
if (check_database(tdbb, *handle, user_status))
return user_status[1];
@ -2137,7 +2082,7 @@ ISC_STATUS GDS_DDL(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Attachment* attachment = *db_handle;
if (check_database(tdbb, attachment, user_status))
@ -2217,7 +2162,7 @@ ISC_STATUS GDS_DETACH(ISC_STATUS* user_status, Attachment** handle)
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Attachment* attachment = *handle;
@ -2343,7 +2288,7 @@ ISC_STATUS GDS_DROP_DATABASE(ISC_STATUS* user_status, Attachment** handle)
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Attachment* attachment = *handle;
@ -2536,7 +2481,7 @@ ISC_STATUS GDS_GET_SEGMENT(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
blb* blob = check_blob(tdbb, user_status, blob_handle);
if (!blob)
@ -2600,7 +2545,7 @@ ISC_STATUS GDS_GET_SLICE(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
if (check_database(tdbb, *db_handle, user_status))
return user_status[1];
@ -2660,7 +2605,7 @@ ISC_STATUS GDS_OPEN_BLOB2(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
NULL_CHECK(blob_handle, isc_bad_segstr_handle);
@ -2713,7 +2658,7 @@ ISC_STATUS GDS_PREPARE(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
CHECK_HANDLE((*tra_handle), type_tra, isc_bad_trans_handle);
jrd_tra* transaction = *tra_handle;
@ -2750,7 +2695,7 @@ ISC_STATUS GDS_PUT_SEGMENT(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
blb* blob = check_blob(tdbb, user_status, blob_handle);
if (!blob)
@ -2798,7 +2743,7 @@ ISC_STATUS GDS_PUT_SLICE(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
if (check_database(tdbb, *db_handle, user_status))
return user_status[1];
@ -2850,7 +2795,7 @@ ISC_STATUS GDS_QUE_EVENTS(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
if (check_database(tdbb, *handle, user_status))
return user_status[1];
@ -2915,7 +2860,7 @@ ISC_STATUS GDS_RECEIVE(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
CHECK_HANDLE((*req_handle), type_req, isc_bad_req_handle);
jrd_req* request = *req_handle;
@ -2975,7 +2920,7 @@ ISC_STATUS GDS_RECONNECT(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
NULL_CHECK(tra_handle, isc_bad_trans_handle);
Attachment* attachment = *db_handle;
@ -3021,7 +2966,7 @@ ISC_STATUS GDS_RELEASE_REQUEST(ISC_STATUS * user_status, jrd_req** req_handle)
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
CHECK_HANDLE((*req_handle), type_req, isc_bad_req_handle);
jrd_req* request = *req_handle;
@ -3070,7 +3015,7 @@ ISC_STATUS GDS_REQUEST_INFO(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
jrd_req* request = *req_handle;
CHECK_HANDLE(request, type_req, isc_bad_req_handle);
@ -3115,7 +3060,7 @@ ISC_STATUS GDS_ROLLBACK_RETAINING(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
jrd_tra* transaction = *tra_handle;
CHECK_HANDLE(transaction, type_tra, isc_bad_trans_handle);
@ -3149,7 +3094,7 @@ ISC_STATUS GDS_ROLLBACK(ISC_STATUS * user_status, jrd_tra** tra_handle)
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
jrd_tra* transaction = *tra_handle;
CHECK_HANDLE(transaction, type_tra, isc_bad_trans_handle);
@ -3188,7 +3133,7 @@ ISC_STATUS GDS_SEEK_BLOB(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
blb* blob = check_blob(tdbb, user_status, blob_handle);
if (!blob)
@ -3232,7 +3177,7 @@ ISC_STATUS GDS_SEND(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
CHECK_HANDLE((*req_handle), type_req, isc_bad_req_handle);
jrd_req* request = *req_handle;
@ -3291,7 +3236,7 @@ ISC_STATUS GDS_SERVICE_ATTACH(ISC_STATUS* user_status,
return handle_error(user_status, isc_bad_svc_handle, 0);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
tdbb->tdbb_status_vector = user_status;
try
@ -3324,7 +3269,7 @@ ISC_STATUS GDS_SERVICE_DETACH(ISC_STATUS* user_status, Service** svc_handle)
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Service* service = *svc_handle;
CHECK_HANDLE(service, type_svc, isc_bad_svc_handle);
@ -3376,7 +3321,7 @@ ISC_STATUS GDS_SERVICE_QUERY(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Service* service = *svc_handle;
CHECK_HANDLE(service, type_svc, isc_bad_svc_handle);
@ -3446,7 +3391,7 @@ ISC_STATUS GDS_SERVICE_START(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Service* service = *svc_handle;
CHECK_HANDLE(service, type_svc, isc_bad_svc_handle);
@ -3502,7 +3447,7 @@ ISC_STATUS GDS_START_AND_SEND(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
jrd_req* request = *req_handle;
CHECK_HANDLE(request, type_req, isc_bad_req_handle);
@ -3562,7 +3507,7 @@ ISC_STATUS GDS_START(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
jrd_req* request = *req_handle;
CHECK_HANDLE(request, type_req, isc_bad_req_handle);
@ -3622,7 +3567,7 @@ ISC_STATUS GDS_START_MULTIPLE(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
NULL_CHECK(tra_handle, isc_bad_trans_handle);
const TEB* const end = vector + count;
@ -3737,7 +3682,7 @@ ISC_STATUS GDS_TRANSACT_REQUEST(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
Attachment* attachment = *db_handle;
if (check_database(tdbb, attachment, user_status))
@ -3888,7 +3833,7 @@ ISC_STATUS GDS_TRANSACTION_INFO(ISC_STATUS* user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
jrd_tra* transaction = *tra_handle;
CHECK_HANDLE(transaction, type_tra, isc_bad_trans_handle);
@ -3934,7 +3879,7 @@ ISC_STATUS GDS_UNWIND(ISC_STATUS * user_status,
api_entry_point_init(user_status);
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
CHECK_HANDLE((*req_handle), type_req, isc_bad_req_handle);
jrd_req* request = *req_handle;
@ -4021,7 +3966,7 @@ void JRD_blocked(Attachment* blocking, BlockingThread** bt_que)
* wake us up.
*
**************************************/
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
Database* dbb = tdbb->tdbb_database;
/* Check for deadlock. If there is one, complain */
@ -4095,7 +4040,7 @@ bool JRD_getdir(Firebird::PathName& buf)
}
else
{
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
/** If the server has not done a JRD_set_thread_data prior to this call
(which will be the case when connecting via IPC), thread_db will
@ -4146,7 +4091,7 @@ void JRD_mutex_lock(MUTX mutex)
* in the thread context block.
*
**************************************/
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
INUSE_insert(&tdbb->tdbb_mutexes, (void *) mutex, true);
THD_MUTEX_LOCK(mutex);
}
@ -4165,7 +4110,7 @@ void JRD_mutex_unlock(MUTX mutex)
* in the thread context block.
*
**************************************/
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
INUSE_remove(&tdbb->tdbb_mutexes, (void *) mutex, false);
THD_MUTEX_UNLOCK(mutex);
}
@ -4360,7 +4305,7 @@ void JRD_restore_context(void)
* and cleanup and objects that remain in use.
*
**************************************/
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
bool cleaned_up =
INUSE_cleanup(&tdbb->tdbb_mutexes, (FPTR_VOID) THD_mutex_unlock);
@ -4423,7 +4368,7 @@ void JRD_unblock(BlockingThread** bt_que)
* than worrying about which, let 'em all loose.
*
**************************************/
Database* dbb = get_dbb();
Database* dbb = GET_DBB();
BlockingThread* block;
while (block = *bt_que) {
@ -4640,7 +4585,7 @@ static ISC_STATUS commit(
*
**************************************/
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
CHECK_HANDLE((*tra_handle), type_tra, isc_bad_trans_handle);
jrd_tra* transaction = *tra_handle;
@ -4712,7 +4657,7 @@ static bool drop_files(const jrd_file* file)
isc_arg_gds, isc_io_delete_err,
SYS_ERR, errno,
0);
Database* dbb = get_dbb();
Database* dbb = GET_DBB();
gds__log_status(dbb->dbb_file->fil_string, status);
}
}
@ -4779,7 +4724,7 @@ static ISC_STATUS error(ISC_STATUS* user_status)
* An error returned has been trapped. Return a status code.
*
**************************************/
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
/* Decrement count of active threads in database */
Database* dbb = tdbb->tdbb_database;
@ -4877,7 +4822,7 @@ static void get_options(const UCHAR* dpb,
USHORT l;
SSHORT num_old_files = 0;
Database* dbb = get_dbb();
Database* dbb = GET_DBB();
MOVE_CLEAR(options, (SLONG) sizeof(struct dpb));
@ -5598,7 +5543,7 @@ static void release_attachment(Attachment* attachment)
* responsibility of the caller to unlock it.
*
**************************************/
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
Database* dbb = tdbb->tdbb_database;
CHECK_DBB(dbb);
@ -5835,7 +5780,7 @@ static void shutdown_database(Database* dbb, const bool release_pools)
* mutex databases_mutex will be locked.
*
**************************************/
thread_db* tdbb = get_thread_data();
thread_db* tdbb = JRD_get_thread_data();
/* Shutdown file and/or remote connection */
@ -6225,7 +6170,7 @@ ULONG JRD_shutdown_all()
*
**************************************/
thread_db thd_context;
thread_db* tdbb = set_thread_data(thd_context);
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
if (initialized) {
JRD_SS_MUTEX_LOCK;

View File

@ -836,8 +836,8 @@ private:
};
typedef vcl* VCL;
#define TEST_VECTOR(vector,number) ((vector && number < vector->vec_count) ? \
vector->vec_object [number] : NULL)
//#define TEST_VECTOR(vector,number) ((vector && number < vector->vec_count) ?
// vector->vec_object [number] : NULL)
//
@ -994,7 +994,7 @@ typedef str *STR;
#ifdef DEV_BUILD
#include "../jrd/err_proto.h"
inline Jrd::thread_db* JRD_get_thread_data(){
inline Jrd::thread_db* JRD_get_thread_data() {
THDD p1 = THD_get_specific();
if (p1 && p1->thdd_type == THDD_TYPE_TDBB)
{
@ -1006,39 +1006,47 @@ inline Jrd::thread_db* JRD_get_thread_data(){
}
return (Jrd::thread_db*) p1;
}
// (((THD_get_specific()) &&
// (((THDD)(THD_get_specific()))->thdd_type == THDD_TYPE_TDBB) &&
// (((thread_db*)(THD_get_specific()))->tdbb_database))
// ? ((MemoryPool::blk_type(((thread_db*)(THD_get_specific()))->tdbb_database) == type_dbb)
// ? (THD_get_specific())
// : (BUGCHECK (147), (THD_get_specific())))
// : ((thread_db*) THD_get_specific()))
//#define CHECK_DBB(dbb) fb_assert ((dbb) && (MemoryPool::blk_type(dbb) == type_dbb) && ((dbb)->dbb_permanent->verify_pool()))
#define CHECK_DBB(dbb) fb_assert ((dbb) && (MemoryPool::blk_type(dbb) == type_dbb))
#define CHECK_TDBB(tdbb) fb_assert ((tdbb) && \
(((THDD)(tdbb))->thdd_type == THDD_TYPE_TDBB) && \
((!(tdbb)->tdbb_database)||MemoryPool::blk_type((tdbb)->tdbb_database) == type_dbb))
#else
/* PROD_BUILD */
inline Jrd::thread_db* JRD_get_thread_data(){
return (Jrd::thread_db*) THD_get_specific();
inline void CHECK_TDBB(const Jrd::thread_db* tdbb) {
fb_assert(tdbb &&
(((THDD)tdbb)->thdd_type == THDD_TYPE_TDBB) &&
(!tdbb->tdbb_database ||
MemoryPool::blk_type(tdbb->tdbb_database) == type_dbb));
}
inline void CHECK_DBB(const Jrd::Database* dbb) {
fb_assert(dbb && MemoryPool::blk_type(dbb) == type_dbb);
}
#else
/* PROD_BUILD */
inline Jrd::thread_db* JRD_get_thread_data() {
return (Jrd::thread_db*) THD_get_specific();
}
inline void CHECK_DBB(const Database* dbb) {
}
inline void CHECK_TDBB(const Jrd::thread_db* tdbb) {
}
//#define JRD_get_thread_data (((thread_db*) THD_get_specific())
#define CHECK_TDBB(tdbb) /* nothing */
#define CHECK_DBB(dbb) /* nothing */
#endif
#define GET_DBB (((thread_db*) (JRD_get_thread_data()))->tdbb_database)
inline Jrd::Database* GET_DBB() {
return JRD_get_thread_data()->tdbb_database;
}
/*-------------------------------------------------------------------------*
* macros used to set thread_db and Database pointers when there are not set already *
*-------------------------------------------------------------------------*/
#define SET_TDBB(tdbb) if ((tdbb) == NULL) { (tdbb) = (thread_db*) JRD_get_thread_data(); }; CHECK_TDBB (tdbb)
#define SET_DBB(dbb) if ((dbb) == NULL) { (dbb) = GET_DBB; }; CHECK_DBB(dbb);
inline void SET_TDBB(Jrd::thread_db* &tdbb) {
if (tdbb == NULL) {
tdbb = JRD_get_thread_data();
}
CHECK_TDBB(tdbb);
}
inline void SET_DBB(Jrd::Database* &dbb) {
if (dbb == NULL) {
dbb = GET_DBB();
}
CHECK_DBB(dbb);
}
#ifdef V4_THREADING
#define V4_JRD_MUTEX_LOCK(mutx) JRD_mutex_lock (mutx)
@ -1084,7 +1092,9 @@ extern int debug;
THD_put_specific (reinterpret_cast<struct thdd*>(tdbb));\
tdbb->tdbb_thd_data.thdd_type = THDD_TYPE_TDBB
#define JRD_restore_thread_data THD_restore_specific()
inline void JRD_restore_thread_data(){
THD_restore_specific();
}

View File

@ -203,7 +203,7 @@ void LOG_call(enum log_t call_type, ...)
SLONG *long_pointer;
va_list ptr;
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
if (!dbb || !dbb->dbb_log || !dbb->dbb_log->log_file)
return;
@ -287,7 +287,7 @@ void LOG_disable(void)
* Disable logging.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
/* Get header page and look for logging entry */
@ -312,7 +312,7 @@ void LOG_enable(const TEXT* log_file_name, USHORT l_length)
* Enable replay logging for the database.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
/* if we are already enabled for another file, get rid of it */
@ -349,7 +349,7 @@ void LOG_fini(void)
* Close down the log file for replay logging.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
fblog* log;
if (dbb && (log = dbb->dbb_log)) {
if (log->log_file) {
@ -403,7 +403,7 @@ static void error(const TEXT* error_string)
* both to the terminal and to the log.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
printf("ERROR in logging system: %s\n", error_string);
@ -428,7 +428,7 @@ static void log_char(SCHAR c)
* for later flushing to the log.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
fblog* log = dbb->dbb_log;
*log->log_ptr++ = c;
@ -458,7 +458,7 @@ static void log_flush(void)
* at it.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
fblog* log = dbb->dbb_log;
if (!(log->log_ptr - log->log_buffer))
@ -579,7 +579,7 @@ static void open_log(const TEXT* file_name, SSHORT file_length,
* Open the log file.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
if (dbb->dbb_log)
LOG_fini();

View File

@ -37,7 +37,7 @@
* 2004.01.16 Vlad Horsun: added support for default parameters
*/
/*
$Id: met.epp,v 1.123 2004-05-21 06:15:41 robocop Exp $
$Id: met.epp,v 1.124 2004-05-23 03:18:09 brodsom Exp $
*/
// This MUST be at the top of the file
#ifdef DARWIN
@ -3684,7 +3684,7 @@ static int blocking_ast_procedure(void* ast_object)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}
@ -3732,7 +3732,7 @@ static int blocking_ast_relation(void* ast_object)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}

View File

@ -32,7 +32,7 @@
* Contributor(s):
*
*
* $Id: nbak.cpp,v 1.35 2004-05-22 14:26:13 brodsom Exp $
* $Id: nbak.cpp,v 1.36 2004-05-23 03:18:09 brodsom Exp $
*
*/
@ -416,7 +416,7 @@ int BackupManager::backup_state_ast(void *ast_object) throw()
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
ISC_ast_exit();
return 0;
@ -466,7 +466,7 @@ int BackupManager::alloc_table_ast(void *ast_object) throw()
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
ISC_ast_exit();
return 0;
@ -520,7 +520,7 @@ int BackupManager::backup_database_ast(void *ast_object) throw()
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
ISC_ast_exit();
return 0;

View File

@ -290,7 +290,7 @@ Lock* RLCK_record_locking(jrd_rel* relation)
return relation->rel_record_locking;
thread_db* tdbb = JRD_get_thread_data();
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
Lock* lock = FB_NEW_RPT(*dbb->dbb_permanent, sizeof(SLONG)) Lock();
lock->lck_parent = dbb->dbb_lock;

View File

@ -645,7 +645,7 @@ void RNG_release_ranges(jrd_req* request)
* Release the locks for all ranges in a request.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
VEC refresh_ranges = request->req_refresh_ranges;
if (refresh_ranges) {
@ -770,7 +770,7 @@ static void post_event(RefreshRange* refresh_range)
* refresh range.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
Lock* dbb_lock = dbb->dbb_lock;
/* detect duplicate posts and filter them out */
@ -823,7 +823,7 @@ static int post_event_ast(void* refresh_range_void)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
return 0;
}
#endif

View File

@ -80,7 +80,7 @@ void SDW_add(const TEXT* file_name, USHORT shadow_number, USHORT file_flags)
*
**************************************/
thread_db* tdbb = JRD_get_thread_data();
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
// Verify database file path against DatabaseAccess entry of firebird.conf
if (!ISC_verify_database_access(file_name)) {
@ -297,7 +297,7 @@ void SDW_check(void)
* be deleted or shut down.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
thread_db* tdbb = JRD_get_thread_data();
/* first get rid of any shadows that need to be
@ -428,7 +428,7 @@ void SDW_close(void)
* a database.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
for (Shadow* shadow = dbb->dbb_shadow; shadow; shadow = shadow->sdw_next)
PIO_close(shadow->sdw_file);
@ -635,7 +635,7 @@ bool SDW_lck_update(SLONG sdw_update_flags)
* Update the data with sdw_update_flag passed to the function
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
Lock* lock = dbb->dbb_shadow_lock;
if (!lock)
return false;
@ -729,7 +729,7 @@ bool SDW_rollover_to_shadow(jrd_file* file, const bool inAst)
*
**************************************/
thread_db* tdbb = JRD_get_thread_data();
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
if (file != dbb->dbb_file)
return true;
@ -848,7 +848,7 @@ void SDW_shutdown_shadow(Shadow* shadow)
* Stop shadowing to a given shadow number.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
/* find the shadow block and delete it from linked list */
@ -1110,7 +1110,7 @@ int SDW_start_shadowing(void* ast_object)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
ISC_ast_exit();
return 0;
@ -1163,7 +1163,7 @@ static Shadow* allocate_shadow(
* the fields properly.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
Shadow* shadow = FB_NEW(*dbb->dbb_permanent) Shadow();
shadow->sdw_file = shadow_file;

View File

@ -49,7 +49,7 @@ void Symbol::insert()
* Insert a symbol into the hash table.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
const int h = hash_func(sym_string);
@ -80,7 +80,7 @@ Symbol* Symbol::lookup(const Firebird::string& string)
* Perform a string lookup against hash table.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
for (Symbol* symbol = dbb->dbb_hash_table[hash_func(string)]; symbol;
symbol = symbol->sym_collision)
@ -105,7 +105,7 @@ void Symbol::remove()
* Remove a symbol from the hash table.
*
**************************************/
Database* dbb = GET_DBB;
Database* dbb = GET_DBB();
const int h = hash_func(sym_string);

View File

@ -2255,7 +2255,7 @@ static int downgrade_lock(void* transaction_void)
/* Restore the prior thread context */
JRD_restore_thread_data;
JRD_restore_thread_data();
ISC_ast_exit();
return 0;

View File

@ -3804,7 +3804,7 @@ gc_exit:
ISC_event_post(dbb->dbb_gc_event_fini);
ISC_event_fini(gc_event);
JRD_restore_thread_data;
JRD_restore_thread_data();
THREAD_EXIT();
} // try