8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 08:43:03 +01:00

-Replace BOOLEAN, TRUE and FALSE

This commit is contained in:
brodsom 2003-09-04 21:26:15 +00:00
parent 1ee6d86019
commit a4416db52a
16 changed files with 2559 additions and 2534 deletions

View File

@ -125,12 +125,12 @@ static ISC_STATUS error();
static void execute_blob(DSQL_REQ, USHORT, UCHAR*, USHORT, UCHAR*, static void execute_blob(DSQL_REQ, USHORT, UCHAR*, USHORT, UCHAR*,
USHORT, UCHAR*, USHORT, UCHAR*); USHORT, UCHAR*, USHORT, UCHAR*);
static ISC_STATUS execute_request(DSQL_REQ, FRBRD**, USHORT, UCHAR*, USHORT, UCHAR*, static ISC_STATUS execute_request(DSQL_REQ, FRBRD**, USHORT, UCHAR*, USHORT, UCHAR*,
USHORT, UCHAR*, USHORT, UCHAR*, USHORT); USHORT, UCHAR*, USHORT, UCHAR*, bool);
static SSHORT filter_sub_type(DSQL_REQ, DSQL_NOD); static SSHORT filter_sub_type(DSQL_REQ, DSQL_NOD);
static BOOLEAN get_indices(SSHORT*, SCHAR**, SSHORT*, SCHAR**); static bool get_indices(SSHORT*, SCHAR**, SSHORT*, SCHAR**);
static USHORT get_plan_info(DSQL_REQ, SSHORT, SCHAR**); static USHORT get_plan_info(DSQL_REQ, SSHORT, SCHAR**);
static USHORT get_request_info(DSQL_REQ, SSHORT, SCHAR*); static USHORT get_request_info(DSQL_REQ, SSHORT, SCHAR*);
static BOOLEAN get_rsb_item(SSHORT*, SCHAR**, SSHORT*, SCHAR**, USHORT*, static bool get_rsb_item(SSHORT*, SCHAR**, SSHORT*, SCHAR**, USHORT*,
USHORT*); USHORT*);
static DBB init(FRBRD**); static DBB init(FRBRD**);
static void map_in_out(DSQL_REQ, DSQL_MSG, USHORT, UCHAR*, USHORT, UCHAR*); static void map_in_out(DSQL_REQ, DSQL_MSG, USHORT, UCHAR*, USHORT, UCHAR*);
@ -139,7 +139,7 @@ static USHORT parse_blr(USHORT, UCHAR*, USHORT, PAR);
static DSQL_REQ prepare(DSQL_REQ, USHORT, TEXT*, USHORT, USHORT); static DSQL_REQ prepare(DSQL_REQ, USHORT, TEXT*, USHORT, USHORT);
static void punt(void); static void punt(void);
static UCHAR* put_item(UCHAR, USHORT, UCHAR*, UCHAR*, UCHAR*); static UCHAR* put_item(UCHAR, USHORT, UCHAR*, UCHAR*, UCHAR*);
static void release_request(DSQL_REQ, USHORT); static void release_request(DSQL_REQ, bool);
static ISC_STATUS return_success(void); static ISC_STATUS return_success(void);
static UCHAR* var_info(DSQL_MSG, const UCHAR*, const UCHAR*, UCHAR*, UCHAR*, USHORT); static UCHAR* var_info(DSQL_MSG, const UCHAR*, const UCHAR*, UCHAR*, UCHAR*, USHORT);
@ -170,7 +170,7 @@ static const UCHAR sql_records_info[] = {
#ifdef ANY_THREADING #ifdef ANY_THREADING
static MUTX_T databases_mutex; static MUTX_T databases_mutex;
static MUTX_T cursors_mutex; static MUTX_T cursors_mutex;
static USHORT mutex_inited = 0; static bool mutex_inited = false;
#endif #endif
@ -537,7 +537,7 @@ ISC_STATUS DLL_EXPORT GDS_DSQL_EXECUTE_CPP(ISC_STATUS* user_status,
OPN open_cursor; OPN open_cursor;
ISC_STATUS_ARRAY local_status; ISC_STATUS_ARRAY local_status;
struct tsql thd_context, *tdsql; struct tsql thd_context, *tdsql;
USHORT singleton; bool singleton;
ISC_STATUS sing_status; ISC_STATUS sing_status;
SET_THREAD_DATA; SET_THREAD_DATA;
@ -584,25 +584,17 @@ ISC_STATUS DLL_EXPORT GDS_DSQL_EXECUTE_CPP(ISC_STATUS* user_status,
/* A select with a non zero output length is a singleton select */ /* A select with a non zero output length is a singleton select */
if (request->req_type == REQ_SELECT && out_msg_length != 0) { if (request->req_type == REQ_SELECT && out_msg_length != 0) {
singleton = TRUE; singleton = true;
} else { } else {
singleton = FALSE; singleton = false;
} }
if (request->req_type != REQ_EMBED_SELECT) if (request->req_type != REQ_EMBED_SELECT)
{ {
sing_status = sing_status = execute_request(request, trans_handle, in_blr_length,
execute_request(request, in_blr, in_msg_length, in_msg,
trans_handle, out_blr_length, out_blr,
in_blr_length, out_msg_length, out_msg, singleton);
in_blr,
in_msg_length,
in_msg,
out_blr_length,
out_blr,
out_msg_length,
out_msg,
singleton);
} }
/* If the output message length is zero on a REQ_SELECT then we must /* If the output message length is zero on a REQ_SELECT then we must
@ -753,23 +745,15 @@ static ISC_STATUS dsql8_execute_immediate_common(ISC_STATUS* user_status,
gds_arg_string, string, gds_arg_end); gds_arg_string, string, gds_arg_end);
} }
execute_request(request, execute_request(request, trans_handle, in_blr_length, in_blr,
trans_handle, in_msg_length, in_msg, out_blr_length, out_blr,
in_blr_length, out_msg_length, out_msg, false);
in_blr,
in_msg_length,
in_msg,
out_blr_length,
out_blr,
out_msg_length,
out_msg,
FALSE);
release_request(request, TRUE); release_request(request, true);
} // try } // try
catch (const std::exception&) { catch (const std::exception&) {
status = error(); status = error();
release_request(request, TRUE); release_request(request, true);
RESTORE_THREAD_DATA; RESTORE_THREAD_DATA;
return status; return status;
} }
@ -1219,7 +1203,7 @@ ISC_STATUS GDS_DSQL_FREE_CPP(ISC_STATUS* user_status,
if (option & DSQL_drop) { if (option & DSQL_drop) {
/* Release everything associate with the request. */ /* Release everything associate with the request. */
release_request(request, TRUE); release_request(request, true);
*req_handle = NULL; *req_handle = NULL;
} }
else if (option & DSQL_close) { else if (option & DSQL_close) {
@ -1459,7 +1443,7 @@ ISC_STATUS GDS_DSQL_PREPARE_CPP(ISC_STATUS* user_status,
/* Now that we know that the new request exists, zap the old one. */ /* Now that we know that the new request exists, zap the old one. */
tdsql->tsql_default = old_request->req_pool; tdsql->tsql_default = old_request->req_pool;
release_request(old_request, TRUE); release_request(old_request, true);
tdsql->tsql_default = NULL; tdsql->tsql_default = NULL;
/* The request was sucessfully prepared, and the old request was /* The request was sucessfully prepared, and the old request was
@ -1479,7 +1463,7 @@ ISC_STATUS GDS_DSQL_PREPARE_CPP(ISC_STATUS* user_status,
} // try } // try
catch(const std::exception&) { catch(const std::exception&) {
status = error(); status = error();
release_request(request, TRUE); release_request(request, true);
RESTORE_THREAD_DATA; RESTORE_THREAD_DATA;
return status; return status;
} }
@ -1722,19 +1706,20 @@ ISC_STATUS GDS_DSQL_SQL_INFO_CPP( ISC_STATUS* user_status,
} }
else if (item == isc_info_sql_batch_fetch) { else if (item == isc_info_sql_batch_fetch) {
if (request->req_flags & REQ_no_batch) if (request->req_flags & REQ_no_batch)
number = FALSE; number = 0;
else else
number = TRUE; number = 1;
length = convert((SLONG) number, buffer); length = convert((SLONG) number, buffer);
if (!(info = put_item(item, length, buffer, info, end_info))) { if (!(info = put_item(item, length, buffer, info, end_info))) {
return return_success(); return return_success();
} }
} }
else if (item == gds_info_sql_records) { else if (item == gds_info_sql_records) {
length = length = get_request_info(request, (SSHORT) sizeof(buffer),
get_request_info(request, (SSHORT) sizeof(buffer), reinterpret_cast<SCHAR*>(buffer)); reinterpret_cast<SCHAR*>(buffer));
if (length if (length && !(info = put_item(item, length, buffer, info,
&& !(info = put_item(item, length, buffer, info, end_info))) { end_info)))
{
return return_success(); return return_success();
} }
} }
@ -2870,7 +2855,7 @@ static ISC_STATUS execute_request(DSQL_REQ request,
UCHAR* out_blr, UCHAR* out_blr,
USHORT out_msg_length, USHORT out_msg_length,
UCHAR* out_msg, UCHAR* out_msg,
USHORT singleton) bool singleton)
{ {
DSQL_MSG message; DSQL_MSG message;
USHORT use_msg_length; USHORT use_msg_length;
@ -3002,7 +2987,7 @@ static ISC_STATUS execute_request(DSQL_REQ request,
default: default:
/* Catch invalid request types */ /* Catch invalid request types */
assert(FALSE); assert(false);
/* Fall into ... */ /* Fall into ... */
case REQ_SELECT: case REQ_SELECT:
@ -3203,7 +3188,7 @@ static SSHORT filter_sub_type( DSQL_REQ request, DSQL_NOD node)
@brief Retrieve the indices from the index tree in @brief Retrieve the indices from the index tree in
the request info buffer, and print them out the request info buffer, and print them out
in the plan buffer. in the plan buffer. Return false on success and true on failure
@param explain_length_ptr @param explain_length_ptr
@ -3212,7 +3197,7 @@ static SSHORT filter_sub_type( DSQL_REQ request, DSQL_NOD node)
@param plan_ptr @param plan_ptr
**/ **/
static BOOLEAN get_indices( static bool get_indices(
SSHORT * explain_length_ptr, SSHORT * explain_length_ptr,
SCHAR ** explain_ptr, SCHAR ** explain_ptr,
SSHORT * plan_length_ptr, SCHAR ** plan_ptr) SSHORT * plan_length_ptr, SCHAR ** plan_ptr)
@ -3234,9 +3219,9 @@ static BOOLEAN get_indices(
case gds_info_rsb_and: case gds_info_rsb_and:
case gds_info_rsb_or: case gds_info_rsb_or:
if (get_indices(&explain_length, &explain, &plan_length, &plan)) if (get_indices(&explain_length, &explain, &plan_length, &plan))
return FB_FAILURE; return true;
if (get_indices(&explain_length, &explain, &plan_length, &plan)) if (get_indices(&explain_length, &explain, &plan_length, &plan))
return FB_FAILURE; return true;
break; break;
case gds_info_rsb_dbkey: case gds_info_rsb_dbkey:
@ -3250,21 +3235,21 @@ static BOOLEAN get_indices(
if (plan[-1] != '(' && plan[-1] != ' ') { if (plan[-1] != '(' && plan[-1] != ' ') {
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
*plan++ = ','; *plan++ = ',';
} }
/* now put out the index name */ /* now put out the index name */
if ((plan_length -= length) < 0) if ((plan_length -= length) < 0)
return FB_FAILURE; return true;
explain_length -= length; explain_length -= length;
while (length--) while (length--)
*plan++ = *explain++; *plan++ = *explain++;
break; break;
default: default:
return FB_FAILURE; return true;
} }
*explain_length_ptr = explain_length; *explain_length_ptr = explain_length;
@ -3272,7 +3257,7 @@ static BOOLEAN get_indices(
*plan_length_ptr = plan_length; *plan_length_ptr = plan_length;
*plan_ptr = plan; *plan_ptr = plan;
return FB_SUCCESS; return false;
} }
@ -3466,7 +3451,8 @@ static USHORT get_request_info(
get_rsb_item get_rsb_item
@brief Use recursion to print out a reverse-polish @brief Use recursion to print out a reverse-polish
access plan of joins and join types. access plan of joins and join types. Return true on failure
and false if succeed
@param explain_length_ptr @param explain_length_ptr
@ -3477,7 +3463,7 @@ static USHORT get_request_info(
@param level_ptr @param level_ptr
**/ **/
static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, static bool get_rsb_item(SSHORT* explain_length_ptr,
SCHAR ** explain_ptr, SCHAR ** explain_ptr,
SSHORT* plan_length_ptr, SSHORT* plan_length_ptr,
SCHAR** plan_ptr, SCHAR** plan_ptr,
@ -3502,7 +3488,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
p = "\nPLAN "; p = "\nPLAN ";
if ((plan_length -= strlen(p)) < 0) if ((plan_length -= strlen(p)) < 0)
return FB_FAILURE; return true;
while (*p) while (*p)
*plan++ = *p++; *plan++ = *p++;
} }
@ -3524,7 +3510,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
if (!*parent_join_count) { if (!*parent_join_count) {
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
*plan++ = '('; *plan++ = '(';
} }
@ -3532,7 +3518,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
if (plan[-1] != '(') { if (plan[-1] != '(') {
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
*plan++ = ','; *plan++ = ',';
} }
@ -3541,7 +3527,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
explain_length--; explain_length--;
explain_length -= (length = (UCHAR) * explain++); explain_length -= (length = (UCHAR) * explain++);
if ((plan_length -= length) < 0) if ((plan_length -= length) < 0)
return FB_FAILURE; return true;
while (length--) while (length--)
*plan++ = *explain++; *plan++ = *explain++;
break; break;
@ -3564,10 +3550,12 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
union_level = *level_ptr; union_level = *level_ptr;
union_join_count = 0; union_join_count = 0;
while (TRUE) { while (true) {
if (get_rsb_item if (get_rsb_item(&explain_length, &explain, &plan_length, &plan,
(&explain_length, &explain, &plan_length, &plan, &union_join_count, &union_level))
&union_join_count, &union_level)) return FB_FAILURE; {
return true;
}
if (union_level == *level_ptr) if (union_level == *level_ptr)
break; break;
} }
@ -3578,10 +3566,12 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
while (union_count) { while (union_count) {
union_join_count = 0; union_join_count = 0;
union_level = 0; union_level = 0;
while (TRUE) { while (true) {
if (get_rsb_item if (get_rsb_item(&explain_length, &explain, &plan_length,
(&explain_length, &explain, &plan_length, &plan, &plan, &union_join_count, &union_level))
&union_join_count, &union_level)) return FB_FAILURE; {
return true;
}
if (!union_level) if (!union_level)
break; break;
} }
@ -3598,7 +3588,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
if (*parent_join_count && plan[-1] != '(') { if (*parent_join_count && plan[-1] != '(') {
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
*plan++ = ','; *plan++ = ',';
} }
@ -3613,7 +3603,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
} }
if ((plan_length -= strlen(p)) < 0) if ((plan_length -= strlen(p)) < 0)
return FB_FAILURE; return true;
while (*p) while (*p)
*plan++ = *p++; *plan++ = *p++;
@ -3624,7 +3614,9 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
while (join_count) { while (join_count) {
if (get_rsb_item(&explain_length, &explain, &plan_length, if (get_rsb_item(&explain_length, &explain, &plan_length,
&plan, &join_count, level_ptr)) &plan, &join_count, level_ptr))
return FB_FAILURE; {
return true;
}
/* CVC: Here's the additional stop condition. */ /* CVC: Here's the additional stop condition. */
if (!*level_ptr) { if (!*level_ptr) {
break; break;
@ -3635,7 +3627,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
/* put out the final parenthesis for the join */ /* put out the final parenthesis for the join */
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
else else
*plan++ = ')'; *plan++ = ')';
@ -3651,14 +3643,17 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
case gds_info_rsb_ext_sequential: case gds_info_rsb_ext_sequential:
case gds_info_rsb_ext_indexed: case gds_info_rsb_ext_indexed:
if (rsb_type == gds_info_rsb_indexed || if (rsb_type == gds_info_rsb_indexed ||
rsb_type == gds_info_rsb_ext_indexed) p = " INDEX ("; rsb_type == gds_info_rsb_ext_indexed)
{
p = " INDEX (";
}
else if (rsb_type == gds_info_rsb_navigate) else if (rsb_type == gds_info_rsb_navigate)
p = " ORDER "; p = " ORDER ";
else else
p = " NATURAL"; p = " NATURAL";
if ((plan_length -= strlen(p)) < 0) if ((plan_length -= strlen(p)) < 0)
return FB_FAILURE; return true;
while (*p) while (*p)
*plan++ = *p++; *plan++ = *p++;
@ -3667,15 +3662,14 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
if (rsb_type == gds_info_rsb_indexed || if (rsb_type == gds_info_rsb_indexed ||
rsb_type == gds_info_rsb_navigate || rsb_type == gds_info_rsb_navigate ||
rsb_type == gds_info_rsb_ext_indexed) { rsb_type == gds_info_rsb_ext_indexed) {
if (get_indices if (get_indices(&explain_length, &explain, &plan_length, &plan))
(&explain_length, &explain, &plan_length, return true;
&plan)) return FB_FAILURE;
} }
if (rsb_type == gds_info_rsb_indexed || if (rsb_type == gds_info_rsb_indexed ||
rsb_type == gds_info_rsb_ext_indexed) { rsb_type == gds_info_rsb_ext_indexed) {
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
*plan++ = ')'; *plan++ = ')';
} }
@ -3683,7 +3677,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
if (!*parent_join_count) if (!*parent_join_count)
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
else else
*plan++ = ')'; *plan++ = ')';
@ -3703,20 +3697,23 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
if (explain_length > 2 && if (explain_length > 2 &&
(explain[0] == gds_info_rsb_begin) && (explain[0] == gds_info_rsb_begin) &&
(explain[1] == gds_info_rsb_type) && (explain[1] == gds_info_rsb_type) &&
(explain[2] == gds_info_rsb_union)) break; (explain[2] == gds_info_rsb_union))
{
break;
}
/* if this isn't the first item in the list, put out a comma */ /* if this isn't the first item in the list, put out a comma */
if (*parent_join_count && plan[-1] != '(') { if (*parent_join_count && plan[-1] != '(') {
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
*plan++ = ','; *plan++ = ',';
} }
p = "SORT ("; p = "SORT (";
if ((plan_length -= strlen(p)) < 0) if ((plan_length -= strlen(p)) < 0)
return FB_FAILURE; return true;
while (*p) while (*p)
*plan++ = *p++; *plan++ = *p++;
@ -3727,13 +3724,13 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
while (explain_length > 0 && plan_length > 0) { while (explain_length > 0 && plan_length > 0) {
if (get_rsb_item(&explain_length, &explain, &plan_length, if (get_rsb_item(&explain_length, &explain, &plan_length,
&plan, parent_join_count, level_ptr)) &plan, parent_join_count, level_ptr))
return FB_FAILURE; return true;
if (*level_ptr == save_level) if (*level_ptr == save_level)
break; break;
} }
if (--plan_length < 0) if (--plan_length < 0)
return FB_FAILURE; return true;
*plan++ = ')'; *plan++ = ')';
break; break;
@ -3751,7 +3748,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr,
*plan_length_ptr = plan_length; *plan_length_ptr = plan_length;
*plan_ptr = plan; *plan_ptr = plan;
return FB_SUCCESS; return false;
} }
@ -3770,7 +3767,7 @@ static DBB init(FRBRD** db_handle)
#ifdef ANY_THREADING #ifdef ANY_THREADING
if (!mutex_inited) { if (!mutex_inited) {
mutex_inited = TRUE; mutex_inited = true;
THD_MUTEX_INIT(&databases_mutex); THD_MUTEX_INIT(&databases_mutex);
THD_MUTEX_INIT(&cursors_mutex); THD_MUTEX_INIT(&cursors_mutex);
} }
@ -3822,10 +3819,7 @@ static DBB init(FRBRD** db_handle)
ISC_STATUS_ARRAY user_status; ISC_STATUS_ARRAY user_status;
THREAD_EXIT; THREAD_EXIT;
gds__database_cleanup(user_status, gds__database_cleanup(user_status, db_handle, cleanup_database, (SLONG) 0);
db_handle,
cleanup_database,
(SLONG) FALSE);
THREAD_ENTER; THREAD_ENTER;
/* Determine if the database is V3 or V4 */ /* Determine if the database is V3 or V4 */
@ -4540,7 +4534,7 @@ static UCHAR* put_item( UCHAR item,
@param top_level @param top_level
**/ **/
static void release_request(DSQL_REQ request, USHORT top_level) static void release_request(DSQL_REQ request, bool top_level)
{ {
ISC_STATUS_ARRAY status_vector; ISC_STATUS_ARRAY status_vector;
@ -4555,7 +4549,7 @@ static void release_request(DSQL_REQ request, USHORT top_level)
child->req_parent = NULL; child->req_parent = NULL;
DsqlMemoryPool *save_default = tdsql->tsql_default; DsqlMemoryPool *save_default = tdsql->tsql_default;
tdsql->tsql_default = child->req_pool; tdsql->tsql_default = child->req_pool;
release_request(child, FALSE); release_request(child, false);
tdsql->tsql_default = save_default; tdsql->tsql_default = save_default;
} }

View File

@ -40,8 +40,8 @@ extern "C" {
ASSERT_FILENAME ASSERT_FILENAME
#define HASH_SIZE 211 #define HASH_SIZE 211
static SSHORT hash(SCHAR *, USHORT); static SSHORT hash(SCHAR *, USHORT);
static BOOLEAN remove_symbol(struct sym **, struct sym *); static bool remove_symbol(struct sym **, struct sym *);
static BOOLEAN scompare(TEXT *, USHORT, TEXT *, USHORT); static bool scompare(TEXT *, USHORT, TEXT *, USHORT);
static SYM *hash_table; static SYM *hash_table;
@ -240,7 +240,8 @@ void HSHD_insert(SYM symbol)
for (old = hash_table[h]; old; old = old->sym_collision) for (old = hash_table[h]; old; old = old->sym_collision)
if ((!database || (database == old->sym_dbb)) && if ((!database || (database == old->sym_dbb)) &&
scompare(symbol->sym_string, symbol->sym_length, old->sym_string, scompare(symbol->sym_string, symbol->sym_length, old->sym_string,
old->sym_length)) { old->sym_length))
{
symbol->sym_homonym = old->sym_homonym; symbol->sym_homonym = old->sym_homonym;
old->sym_homonym = symbol; old->sym_homonym = symbol;
UNLOCK_HASH; UNLOCK_HASH;
@ -327,11 +328,13 @@ void HSHD_remove( SYM symbol)
h = hash(symbol->sym_string, symbol->sym_length); h = hash(symbol->sym_string, symbol->sym_length);
for (collision = &hash_table[h]; *collision; for (collision = &hash_table[h]; *collision;
collision = collision = &(*collision)->sym_collision)
&(*collision)->sym_collision) if (remove_symbol(collision, symbol)) { {
if (remove_symbol(collision, symbol)) {
UNLOCK_HASH; UNLOCK_HASH;
return; return;
} }
}
UNLOCK_HASH; UNLOCK_HASH;
IBERROR(-1, "HSHD_remove failed"); IBERROR(-1, "HSHD_remove failed");
@ -462,7 +465,7 @@ static SSHORT hash(SCHAR * string, USHORT length)
@param symbol @param symbol
**/ **/
static BOOLEAN remove_symbol( SYM * collision, SYM symbol) static bool remove_symbol( SYM * collision, SYM symbol)
{ {
SYM *ptr, homonym; SYM *ptr, homonym;
@ -474,16 +477,16 @@ static BOOLEAN remove_symbol( SYM * collision, SYM symbol)
else else
*collision = symbol->sym_collision; *collision = symbol->sym_collision;
return TRUE; return true;
} }
for (ptr = &(*collision)->sym_homonym; *ptr; ptr = &(*ptr)->sym_homonym) for (ptr = &(*collision)->sym_homonym; *ptr; ptr = &(*ptr)->sym_homonym)
if (symbol == *ptr) { if (symbol == *ptr) {
*ptr = symbol->sym_homonym; *ptr = symbol->sym_homonym;
return TRUE; return true;
} }
return FALSE; return false;
} }
@ -504,20 +507,20 @@ static BOOLEAN remove_symbol( SYM * collision, SYM symbol)
@param length2 @param length2
**/ **/
static BOOLEAN scompare(TEXT * string1, static bool scompare(TEXT * string1,
USHORT length1, USHORT length1,
TEXT * string2, USHORT length2) TEXT * string2, USHORT length2)
{ {
if (length1 != length2) if (length1 != length2)
return FALSE; return false;
while (length1--) { while (length1--) {
if ((*string1++) != (*string2++)) if ((*string1++) != (*string2++))
return FALSE; return false;
} }
return TRUE; return true;
} }

View File

@ -175,7 +175,7 @@ static void yyerror (TEXT *);
static TEXT *lex_position (void); static TEXT *lex_position (void);
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN long_int (DSQL_NOD, SLONG *); static bool long_int(DSQL_NOD, SLONG *);
#endif #endif
static DSQL_FLD make_field (DSQL_NOD); static DSQL_FLD make_field (DSQL_NOD);
static FIL make_file (void); static FIL make_file (void);
@ -185,7 +185,7 @@ static DSQL_NOD make_parameter (void);
static DSQL_NOD make_flag_node (NOD_TYPE, SSHORT, int, ...); static DSQL_NOD make_flag_node (NOD_TYPE, SSHORT, int, ...);
static void prepare_console_debug (int, int *); static void prepare_console_debug (int, int *);
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN short_int (DSQL_NOD, SLONG *, SSHORT); static bool short_int(DSQL_NOD, SLONG *, SSHORT);
#endif #endif
static void stack_nodes (DSQL_NOD, DLLS *); static void stack_nodes (DSQL_NOD, DLLS *);
inline static int yylex (USHORT, USHORT, USHORT, BOOLEAN *); inline static int yylex (USHORT, USHORT, USHORT, BOOLEAN *);
@ -5245,13 +5245,12 @@ static TEXT *lex_position (void)
* *
**************************************/ **************************************/
return lex.ptr; return lex.ptr;
} }
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN long_int ( static bool long_int(DSQL_NOD string,
DSQL_NOD string,
SLONG *long_value) SLONG *long_value)
{ {
/************************************* /*************************************
@ -5269,18 +5268,17 @@ static BOOLEAN long_int (
for (const char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) for (const char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++)
{ {
if (!(classes [*p] & CHR_DIGIT)) { if (!(classes [*p] & CHR_DIGIT)) {
return FALSE; return false;
} }
} }
*long_value = atol ((char *)((STR) string)->str_data); *long_value = atol ((char *)((STR) string)->str_data);
return TRUE; return true;
} }
#endif #endif
static DSQL_FLD make_field ( static DSQL_FLD make_field (DSQL_NOD field_name)
DSQL_NOD field_name)
{ {
/************************************** /**************************************
* *
@ -5292,23 +5290,23 @@ static DSQL_FLD make_field (
* Make a field block of given name. * Make a field block of given name.
* *
**************************************/ **************************************/
DSQL_FLD field; DSQL_FLD field;
STR string; STR string;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
if (field_name == NULL) if (field_name == NULL)
{ {
field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld; field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld;
strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME); strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME);
return field; return field;
} }
string = (STR) field_name->nod_arg [1]; string = (STR) field_name->nod_arg [1];
field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld; field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld;
strcpy (field->fld_name, (TEXT*) string->str_data); strcpy (field->fld_name, (TEXT*) string->str_data);
return field; return field;
} }
@ -5324,19 +5322,18 @@ static FIL make_file (void)
* Make a file block * Make a file block
* *
**************************************/ **************************************/
FIL temp_file; FIL temp_file;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
temp_file = FB_NEW(*tdsql->tsql_default) fil; temp_file = FB_NEW(*tdsql->tsql_default) fil;
return temp_file; return temp_file;
} }
static DSQL_NOD make_list ( static DSQL_NOD make_list (DSQL_NOD node)
DSQL_NOD node)
{ {
/************************************** /**************************************
* *
@ -5348,33 +5345,33 @@ static DSQL_NOD make_list (
* Collapse nested list nodes into single list. * Collapse nested list nodes into single list.
* *
**************************************/ **************************************/
DSQL_NOD *ptr; DSQL_NOD *ptr;
DLLS stack, temp; DLLS stack, temp;
USHORT l; USHORT l;
DSQL_NOD old; DSQL_NOD old;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
if (!node) if (!node)
return node; return node;
stack = 0; stack = 0;
stack_nodes (node, &stack); stack_nodes (node, &stack);
for (l = 0, temp = stack; temp; temp = temp->lls_next) for (l = 0, temp = stack; temp; temp = temp->lls_next)
l++; l++;
old = node; old = node;
node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod;
node->nod_count = l; node->nod_count = l;
node->nod_type = nod_list; node->nod_type = nod_list;
node->nod_flags = old->nod_flags; node->nod_flags = old->nod_flags;
ptr = node->nod_arg + node->nod_count; ptr = node->nod_arg + node->nod_count;
while (stack) while (stack)
*--ptr = (DSQL_NOD) LLS_POP (&stack); *--ptr = (DSQL_NOD) LLS_POP (&stack);
return node; return node;
} }
@ -5391,24 +5388,23 @@ static DSQL_NOD make_parameter (void)
* Any change should also be made to function below * Any change should also be made to function below
* *
**************************************/ **************************************/
DSQL_NOD node; DSQL_NOD node;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod;
node->nod_type = nod_parameter; node->nod_type = nod_parameter;
node->nod_line = (USHORT) lex.lines_bk; node->nod_line = (USHORT) lex.lines_bk;
node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1);
node->nod_count = 1; node->nod_count = 1;
node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++; node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++;
return node; return node;
} }
static DSQL_NOD make_node ( static DSQL_NOD make_node (NOD_TYPE type,
NOD_TYPE type,
int count, int count,
...) ...)
{ {
@ -5423,29 +5419,28 @@ static DSQL_NOD make_node (
* Any change should also be made to function below * Any change should also be made to function below
* *
**************************************/ **************************************/
DSQL_NOD node, *p; DSQL_NOD node, *p;
va_list ptr; va_list ptr;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod;
node->nod_type = type; node->nod_type = type;
node->nod_line = (USHORT) lex.lines_bk; node->nod_line = (USHORT) lex.lines_bk;
node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1);
node->nod_count = count; node->nod_count = count;
p = node->nod_arg; p = node->nod_arg;
VA_START (ptr, count); VA_START (ptr, count);
while (--count >= 0) while (--count >= 0)
*p++ = va_arg (ptr, DSQL_NOD); *p++ = va_arg (ptr, DSQL_NOD);
return node; return node;
} }
static DSQL_NOD make_flag_node ( static DSQL_NOD make_flag_node (NOD_TYPE type,
NOD_TYPE type,
SSHORT flag, SSHORT flag,
int count, int count,
...) ...)
@ -5460,25 +5455,25 @@ static DSQL_NOD make_flag_node (
* Make a node of given type. Set flag field * Make a node of given type. Set flag field
* *
**************************************/ **************************************/
DSQL_NOD node, *p; DSQL_NOD node, *p;
va_list ptr; va_list ptr;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod;
node->nod_type = type; node->nod_type = type;
node->nod_flags = flag; node->nod_flags = flag;
node->nod_line = (USHORT) lex.lines_bk; node->nod_line = (USHORT) lex.lines_bk;
node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1);
node->nod_count = count; node->nod_count = count;
p = node->nod_arg; p = node->nod_arg;
VA_START (ptr, count); VA_START (ptr, count);
while (--count >= 0) while (--count >= 0)
*p++ = va_arg (ptr, DSQL_NOD); *p++ = va_arg (ptr, DSQL_NOD);
return node; return node;
} }
@ -5505,7 +5500,7 @@ static void prepare_console_debug (int level, int *yydeb)
operations that's generated in DEV build when DEBUG <n> is typed into isql.exe. operations that's generated in DEV build when DEBUG <n> is typed into isql.exe.
When n>0, the output console is activated; otherwise it's closed. */ When n>0, the output console is activated; otherwise it's closed. */
#if defined(DEV_BUILD) && defined(WIN_NT) && defined(SUPERSERVER) #if defined(DEV_BUILD) && defined(WIN_NT) && defined(SUPERSERVER)
static FILE* redirected_output; static FILE* redirected_output;
if (level > 0) { if (level > 0) {
/* Console debug code inside this scope */ /* Console debug code inside this scope */
if (AllocConsole()) { if (AllocConsole()) {
@ -5522,8 +5517,7 @@ static FILE* redirected_output;
} }
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN short_int ( static bool short_int(DSQL_NOD string,
DSQL_NOD string,
SLONG *long_value, SLONG *long_value,
SSHORT range) SSHORT range)
{ {
@ -5540,13 +5534,13 @@ static BOOLEAN short_int (
*************************************/ *************************************/
if (((STR) string)->str_length > 5) { if (((STR) string)->str_length > 5) {
return FALSE; return false;
} }
for (char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) for (char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++)
{ {
if (!(classes [*p] & CHR_DIGIT)) { if (!(classes [*p] & CHR_DIGIT)) {
return FALSE; return false;
} }
} }
@ -5563,7 +5557,7 @@ static BOOLEAN short_int (
*long_value = atoi (buf); *long_value = atoi (buf);
BOOLEAN return_value; bool return_value;
switch (range) switch (range)
{ {
@ -5581,8 +5575,7 @@ static BOOLEAN short_int (
} }
#endif #endif
static void stack_nodes ( static void stack_nodes (DSQL_NOD node,
DSQL_NOD node,
DLLS *stack) DLLS *stack)
{ {
/************************************** /**************************************
@ -5595,16 +5588,16 @@ static void stack_nodes (
* Assist in turning a tree of misc nodes into a clean list. * Assist in turning a tree of misc nodes into a clean list.
* *
**************************************/ **************************************/
DSQL_NOD *ptr, *end; DSQL_NOD *ptr, *end;
DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link; DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link;
if (node->nod_type != nod_list) if (node->nod_type != nod_list)
{ {
LLS_PUSH (node, stack); LLS_PUSH (node, stack);
return; return;
} }
/* To take care of cases where long lists of nodes are in a chain /* To take care of cases where long lists of nodes are in a chain
of list nodes with exactly one entry, this algorithm will look of list nodes with exactly one entry, this algorithm will look
for a pattern of repeated list nodes with two entries, the first for a pattern of repeated list nodes with two entries, the first
being a list node and the second being a non-list node. Such being a list node and the second being a non-list node. Such
@ -5612,11 +5605,11 @@ if (node->nod_type != nod_list)
non-list nodes in the process. The purpose of this is to avoid non-list nodes in the process. The purpose of this is to avoid
massive recursion of this function. */ massive recursion of this function. */
start_chain = node; start_chain = node;
end_chain = NULL; end_chain = NULL;
curr_node = node; curr_node = node;
next_node = node->nod_arg[0]; next_node = node->nod_arg[0];
while ( curr_node->nod_count == 2 && while ( curr_node->nod_count == 2 &&
curr_node->nod_arg[0]->nod_type == nod_list && curr_node->nod_arg[0]->nod_type == nod_list &&
curr_node->nod_arg[1]->nod_type != nod_list && curr_node->nod_arg[1]->nod_type != nod_list &&
next_node->nod_arg[0]->nod_type == nod_list && next_node->nod_arg[0]->nod_type == nod_list &&
@ -5632,9 +5625,9 @@ while ( curr_node->nod_count == 2 &&
end_chain = curr_node; end_chain = curr_node;
} }
/* see if any chain was found */ /* see if any chain was found */
if ( end_chain) if ( end_chain)
{ {
/* first, handle the rest of the nodes */ /* first, handle the rest of the nodes */
@ -5645,7 +5638,7 @@ if ( end_chain)
/* stack the non-list nodes and reverse the chain on the way back */ /* stack the non-list nodes and reverse the chain on the way back */
curr_node = end_chain; curr_node = end_chain;
while ( TRUE) while (true)
{ {
LLS_PUSH( curr_node->nod_arg[1], stack); LLS_PUSH( curr_node->nod_arg[1], stack);
if ( curr_node == start_chain) if ( curr_node == start_chain)
@ -5658,7 +5651,7 @@ if ( end_chain)
return; return;
} }
for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++) for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++)
stack_nodes (*ptr, stack); stack_nodes (*ptr, stack);
} }
@ -5689,21 +5682,21 @@ int LexerState::yylex (
* Functional description: lexer. * Functional description: lexer.
* *
**************************************/ **************************************/
UCHAR tok_class; UCHAR tok_class;
char string[MAX_TOKEN_LEN]; char string[MAX_TOKEN_LEN];
char* p; char* p;
char* buffer; char* buffer;
char* buffer_end; char* buffer_end;
char* new_buffer; char* new_buffer;
SYM sym; SYM sym;
SSHORT c; SSHORT c;
USHORT buffer_len; USHORT buffer_len;
STR delimited_id_str; STR delimited_id_str;
/* Find end of white space and skip comments */ /* Find end of white space and skip comments */
for (;;) for (;;)
{ {
if (ptr >= end) if (ptr >= end)
return -1; return -1;
@ -5762,11 +5755,11 @@ for (;;)
break; break;
} }
/* Depending on tok_class of token, parse token */ /* Depending on tok_class of token, parse token */
last_token = ptr - 1; last_token = ptr - 1;
if (tok_class & CHR_INTRODUCER) if (tok_class & CHR_INTRODUCER)
{ {
/* The Introducer (_) is skipped, all other idents are copied /* The Introducer (_) is skipped, all other idents are copied
* to become the name of the character set * to become the name of the character set
@ -5790,9 +5783,9 @@ if (tok_class & CHR_INTRODUCER)
return INTRODUCER; return INTRODUCER;
} }
/* parse a quoted string, being sure to look for double quotes */ /* parse a quoted string, being sure to look for double quotes */
if (tok_class & CHR_QUOTE) if (tok_class & CHR_QUOTE)
{ {
buffer = string; buffer = string;
buffer_len = sizeof (string); buffer_len = sizeof (string);
@ -5888,19 +5881,19 @@ if (tok_class & CHR_QUOTE)
* ptr points to the next character. * ptr points to the next character.
*/ */
assert(ptr <= end); assert(ptr <= end);
if ((tok_class & CHR_DIGIT) || if ((tok_class & CHR_DIGIT) ||
((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT))) ((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT)))
{ {
/* The following variables are used to recognize kinds of numbers. */ /* The following variables are used to recognize kinds of numbers. */
BOOLEAN have_error = FALSE; /* syntax error or value too large */ bool have_error = false; /* syntax error or value too large */
BOOLEAN have_digit = FALSE; /* we've seen a digit */ bool have_digit = false; /* we've seen a digit */
BOOLEAN have_decimal = FALSE; /* we've seen a '.' */ bool have_decimal = false; /* we've seen a '.' */
BOOLEAN have_exp = FALSE; /* digit ... [eE] */ bool have_exp = false; /* digit ... [eE] */
BOOLEAN have_exp_sign = FALSE; /* digit ... [eE] {+-] */ bool have_exp_sign = false; /* digit ... [eE] {+-] */
BOOLEAN have_exp_digit = FALSE; /* digit ... [eE] ... digit */ bool have_exp_digit = false; /* digit ... [eE] ... digit */
UINT64 number = 0; UINT64 number = 0;
UINT64 limit_by_10 = MAX_SINT64 / 10; UINT64 limit_by_10 = MAX_SINT64 / 10;
@ -5914,32 +5907,32 @@ if ((tok_class & CHR_DIGIT) ||
else if (have_exp_sign && (! (classes [c] & CHR_DIGIT))) else if (have_exp_sign && (! (classes [c] & CHR_DIGIT)))
{ {
/* only digits can be accepted after "1E-" */ /* only digits can be accepted after "1E-" */
have_error = TRUE; have_error = true;
break; break;
} }
else if (have_exp) else if (have_exp)
{ {
/* We've seen e or E, but nothing beyond that. */ /* We've seen e or E, but nothing beyond that. */
if ( ('-' == c) || ('+' == c) ) if ( ('-' == c) || ('+' == c) )
have_exp_sign = TRUE; have_exp_sign = true;
else if ( classes [c] & CHR_DIGIT ) else if ( classes [c] & CHR_DIGIT )
/* We have a digit: we haven't seen a sign yet, /* We have a digit: we haven't seen a sign yet,
but it's too late now. */ but it's too late now. */
have_exp_digit = have_exp_sign = TRUE; have_exp_digit = have_exp_sign = true;
else else
{ {
/* end of the token */ /* end of the token */
have_error = TRUE; have_error = true;
break; break;
} }
} }
else if ('.' == c) else if ('.' == c)
{ {
if (!have_decimal) if (!have_decimal)
have_decimal = TRUE; have_decimal = true;
else else
{ {
have_error = TRUE; have_error = true;
break; break;
} }
} }
@ -5948,19 +5941,19 @@ if ((tok_class & CHR_DIGIT) ||
/* Before computing the next value, make sure there will be /* Before computing the next value, make sure there will be
no overflow. */ no overflow. */
have_digit = TRUE; have_digit = true;
if (number >= limit_by_10) if (number >= limit_by_10)
/* possibility of an overflow */ /* possibility of an overflow */
if ((number > limit_by_10) || (c > '8')) if ((number > limit_by_10) || (c > '8'))
{ {
have_error = TRUE; have_error = true;
break; break;
} }
number = number * 10 + (c - '0'); number = number * 10 + (c - '0');
} }
else if ( (('E' == c) || ('e' == c)) && have_digit ) else if ( (('E' == c) || ('e' == c)) && have_digit )
have_exp = TRUE; have_exp = true;
else else
/* Unexpected character: this is the end of the number. */ /* Unexpected character: this is the end of the number. */
break; break;
@ -6039,17 +6032,17 @@ if ((tok_class & CHR_DIGIT) ||
*/ */
} }
/* Restore the status quo ante, before we started our unsuccessful /* Restore the status quo ante, before we started our unsuccessful
attempt to recognize a number. */ attempt to recognize a number. */
ptr = last_token; ptr = last_token;
c = *ptr++; c = *ptr++;
/* We never touched tok_class, so it doesn't need to be restored. */ /* We never touched tok_class, so it doesn't need to be restored. */
/* end of number-recognition code */ /* end of number-recognition code */
if (tok_class & CHR_LETTER) if (tok_class & CHR_LETTER)
{ {
p = string; p = string;
CHECK_COPY_INCR(p, UPPER (c)); CHECK_COPY_INCR(p, UPPER (c));
for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++)
@ -6136,11 +6129,11 @@ if (tok_class & CHR_LETTER)
line_start_bk = line_start; line_start_bk = line_start;
lines_bk = lines; lines_bk = lines;
return SYMBOL; return SYMBOL;
} }
/* Must be punctuation -- test for double character punctuation */ /* Must be punctuation -- test for double character punctuation */
if (last_token + 1 < end) if (last_token + 1 < end)
{ {
sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version); sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version);
if (sym) if (sym)
@ -6150,10 +6143,10 @@ if (last_token + 1 < end)
} }
} }
/* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */ /* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */
/* This algorithm is not perfect, but it is ok for now. /* This algorithm is not perfect, but it is ok for now.
It should be dropped when BOOLEAN datatype is introduced in Firebird */ It should be dropped when BOOLEAN datatype is introduced in Firebird */
if ( c == '(' && !brace_analysis && if ( c == '(' && !brace_analysis &&
/* 1) We need to swallow braces in all boolean expressions /* 1) We need to swallow braces in all boolean expressions
2) We may swallow braces in ordinary expressions 2) We may swallow braces in ordinary expressions
3) We should not swallow braces after special tokens 3) We should not swallow braces after special tokens
@ -6161,7 +6154,7 @@ if ( c == '(' && !brace_analysis &&
*/ */
(prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR || (prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR ||
prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) ) prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) )
{ {
LexerState savedState = lex; LexerState savedState = lex;
brace_analysis = true; brace_analysis = true;
int openCount = 0; int openCount = 0;
@ -6216,11 +6209,11 @@ if ( c == '(' && !brace_analysis &&
/* Restore status quo. */ /* Restore status quo. */
lex = savedState; lex = savedState;
} }
} }
/* Single character punctuation are simply passed on */ /* Single character punctuation are simply passed on */
return c; return c;
} }
@ -6238,11 +6231,11 @@ static void yyerror (
* *
**************************************/ **************************************/
if (DSQL_yychar < 1) if (DSQL_yychar < 1)
ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104,
gds_arg_gds, gds_command_end_err, /* Unexpected end of command */ gds_arg_gds, gds_command_end_err, /* Unexpected end of command */
0); 0);
else else
{ {
ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104,
gds_arg_gds, gds_dsql_token_unk_err, gds_arg_gds, gds_dsql_token_unk_err,
@ -6250,14 +6243,12 @@ else
gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/ gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/
/* Token unknown - line %d, char %d */ /* Token unknown - line %d, char %d */
gds_arg_gds, gds_random, gds_arg_gds, gds_random,
gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, 0);
0);
} }
} }
static void yyabandon ( static void yyabandon (SSHORT sql_code,
SSHORT sql_code,
ISC_STATUS error_symbol) ISC_STATUS error_symbol)
{ {
/************************************** /**************************************
@ -6271,7 +6262,7 @@ static void yyabandon (
* *
**************************************/ **************************************/
ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code, ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code,
gds_arg_gds, error_symbol, 0); gds_arg_gds, error_symbol, 0);
} }
#define YYABORT goto yyabort #define YYABORT goto yyabort

View File

@ -166,7 +166,7 @@ static void yyerror (TEXT *);
static TEXT *lex_position (void); static TEXT *lex_position (void);
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN long_int (DSQL_NOD, SLONG *); static bool long_int(DSQL_NOD, SLONG *);
#endif #endif
static DSQL_FLD make_field (DSQL_NOD); static DSQL_FLD make_field (DSQL_NOD);
static FIL make_file (void); static FIL make_file (void);
@ -176,7 +176,7 @@ static DSQL_NOD make_parameter (void);
static DSQL_NOD make_flag_node (NOD_TYPE, SSHORT, int, ...); static DSQL_NOD make_flag_node (NOD_TYPE, SSHORT, int, ...);
static void prepare_console_debug (int, int *); static void prepare_console_debug (int, int *);
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN short_int (DSQL_NOD, SLONG *, SSHORT); static bool short_int(DSQL_NOD, SLONG *, SSHORT);
#endif #endif
static void stack_nodes (DSQL_NOD, DLLS *); static void stack_nodes (DSQL_NOD, DLLS *);
inline static int yylex (USHORT, USHORT, USHORT, BOOLEAN *); inline static int yylex (USHORT, USHORT, USHORT, BOOLEAN *);
@ -4173,13 +4173,12 @@ static TEXT *lex_position (void)
* *
**************************************/ **************************************/
return lex.ptr; return lex.ptr;
} }
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN long_int ( static bool long_int(DSQL_NOD string,
DSQL_NOD string,
SLONG *long_value) SLONG *long_value)
{ {
/************************************* /*************************************
@ -4197,18 +4196,17 @@ static BOOLEAN long_int (
for (const char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) for (const char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++)
{ {
if (!(classes [*p] & CHR_DIGIT)) { if (!(classes [*p] & CHR_DIGIT)) {
return FALSE; return false;
} }
} }
*long_value = atol ((char *)((STR) string)->str_data); *long_value = atol ((char *)((STR) string)->str_data);
return TRUE; return true;
} }
#endif #endif
static DSQL_FLD make_field ( static DSQL_FLD make_field (DSQL_NOD field_name)
DSQL_NOD field_name)
{ {
/************************************** /**************************************
* *
@ -4220,23 +4218,23 @@ static DSQL_FLD make_field (
* Make a field block of given name. * Make a field block of given name.
* *
**************************************/ **************************************/
DSQL_FLD field; DSQL_FLD field;
STR string; STR string;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
if (field_name == NULL) if (field_name == NULL)
{ {
field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld; field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld;
strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME); strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME);
return field; return field;
} }
string = (STR) field_name->nod_arg [1]; string = (STR) field_name->nod_arg [1];
field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld; field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld;
strcpy (field->fld_name, (TEXT*) string->str_data); strcpy (field->fld_name, (TEXT*) string->str_data);
return field; return field;
} }
@ -4252,19 +4250,18 @@ static FIL make_file (void)
* Make a file block * Make a file block
* *
**************************************/ **************************************/
FIL temp_file; FIL temp_file;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
temp_file = FB_NEW(*tdsql->tsql_default) fil; temp_file = FB_NEW(*tdsql->tsql_default) fil;
return temp_file; return temp_file;
} }
static DSQL_NOD make_list ( static DSQL_NOD make_list (DSQL_NOD node)
DSQL_NOD node)
{ {
/************************************** /**************************************
* *
@ -4276,33 +4273,33 @@ static DSQL_NOD make_list (
* Collapse nested list nodes into single list. * Collapse nested list nodes into single list.
* *
**************************************/ **************************************/
DSQL_NOD *ptr; DSQL_NOD *ptr;
DLLS stack, temp; DLLS stack, temp;
USHORT l; USHORT l;
DSQL_NOD old; DSQL_NOD old;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
if (!node) if (!node)
return node; return node;
stack = 0; stack = 0;
stack_nodes (node, &stack); stack_nodes (node, &stack);
for (l = 0, temp = stack; temp; temp = temp->lls_next) for (l = 0, temp = stack; temp; temp = temp->lls_next)
l++; l++;
old = node; old = node;
node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod;
node->nod_count = l; node->nod_count = l;
node->nod_type = nod_list; node->nod_type = nod_list;
node->nod_flags = old->nod_flags; node->nod_flags = old->nod_flags;
ptr = node->nod_arg + node->nod_count; ptr = node->nod_arg + node->nod_count;
while (stack) while (stack)
*--ptr = (DSQL_NOD) LLS_POP (&stack); *--ptr = (DSQL_NOD) LLS_POP (&stack);
return node; return node;
} }
@ -4319,24 +4316,23 @@ static DSQL_NOD make_parameter (void)
* Any change should also be made to function below * Any change should also be made to function below
* *
**************************************/ **************************************/
DSQL_NOD node; DSQL_NOD node;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod;
node->nod_type = nod_parameter; node->nod_type = nod_parameter;
node->nod_line = (USHORT) lex.lines_bk; node->nod_line = (USHORT) lex.lines_bk;
node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1);
node->nod_count = 1; node->nod_count = 1;
node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++; node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++;
return node; return node;
} }
static DSQL_NOD make_node ( static DSQL_NOD make_node (NOD_TYPE type,
NOD_TYPE type,
int count, int count,
...) ...)
{ {
@ -4351,29 +4347,28 @@ static DSQL_NOD make_node (
* Any change should also be made to function below * Any change should also be made to function below
* *
**************************************/ **************************************/
DSQL_NOD node, *p; DSQL_NOD node, *p;
va_list ptr; va_list ptr;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod;
node->nod_type = type; node->nod_type = type;
node->nod_line = (USHORT) lex.lines_bk; node->nod_line = (USHORT) lex.lines_bk;
node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1);
node->nod_count = count; node->nod_count = count;
p = node->nod_arg; p = node->nod_arg;
VA_START (ptr, count); VA_START (ptr, count);
while (--count >= 0) while (--count >= 0)
*p++ = va_arg (ptr, DSQL_NOD); *p++ = va_arg (ptr, DSQL_NOD);
return node; return node;
} }
static DSQL_NOD make_flag_node ( static DSQL_NOD make_flag_node (NOD_TYPE type,
NOD_TYPE type,
SSHORT flag, SSHORT flag,
int count, int count,
...) ...)
@ -4388,25 +4383,25 @@ static DSQL_NOD make_flag_node (
* Make a node of given type. Set flag field * Make a node of given type. Set flag field
* *
**************************************/ **************************************/
DSQL_NOD node, *p; DSQL_NOD node, *p;
va_list ptr; va_list ptr;
TSQL tdsql; TSQL tdsql;
tdsql = GET_THREAD_DATA; tdsql = GET_THREAD_DATA;
node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod;
node->nod_type = type; node->nod_type = type;
node->nod_flags = flag; node->nod_flags = flag;
node->nod_line = (USHORT) lex.lines_bk; node->nod_line = (USHORT) lex.lines_bk;
node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1);
node->nod_count = count; node->nod_count = count;
p = node->nod_arg; p = node->nod_arg;
VA_START (ptr, count); VA_START (ptr, count);
while (--count >= 0) while (--count >= 0)
*p++ = va_arg (ptr, DSQL_NOD); *p++ = va_arg (ptr, DSQL_NOD);
return node; return node;
} }
@ -4433,7 +4428,7 @@ static void prepare_console_debug (int level, int *yydeb)
operations that's generated in DEV build when DEBUG <n> is typed into isql.exe. operations that's generated in DEV build when DEBUG <n> is typed into isql.exe.
When n>0, the output console is activated; otherwise it's closed. */ When n>0, the output console is activated; otherwise it's closed. */
#if defined(DEV_BUILD) && defined(WIN_NT) && defined(SUPERSERVER) #if defined(DEV_BUILD) && defined(WIN_NT) && defined(SUPERSERVER)
static FILE* redirected_output; static FILE* redirected_output;
if (level > 0) { if (level > 0) {
/* Console debug code inside this scope */ /* Console debug code inside this scope */
if (AllocConsole()) { if (AllocConsole()) {
@ -4450,8 +4445,7 @@ static FILE* redirected_output;
} }
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static BOOLEAN short_int ( static bool short_int(DSQL_NOD string,
DSQL_NOD string,
SLONG *long_value, SLONG *long_value,
SSHORT range) SSHORT range)
{ {
@ -4468,13 +4462,13 @@ static BOOLEAN short_int (
*************************************/ *************************************/
if (((STR) string)->str_length > 5) { if (((STR) string)->str_length > 5) {
return FALSE; return false;
} }
for (char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) for (char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++)
{ {
if (!(classes [*p] & CHR_DIGIT)) { if (!(classes [*p] & CHR_DIGIT)) {
return FALSE; return false;
} }
} }
@ -4491,7 +4485,7 @@ static BOOLEAN short_int (
*long_value = atoi (buf); *long_value = atoi (buf);
BOOLEAN return_value; bool return_value;
switch (range) switch (range)
{ {
@ -4509,8 +4503,7 @@ static BOOLEAN short_int (
} }
#endif #endif
static void stack_nodes ( static void stack_nodes (DSQL_NOD node,
DSQL_NOD node,
DLLS *stack) DLLS *stack)
{ {
/************************************** /**************************************
@ -4523,16 +4516,16 @@ static void stack_nodes (
* Assist in turning a tree of misc nodes into a clean list. * Assist in turning a tree of misc nodes into a clean list.
* *
**************************************/ **************************************/
DSQL_NOD *ptr, *end; DSQL_NOD *ptr, *end;
DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link; DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link;
if (node->nod_type != nod_list) if (node->nod_type != nod_list)
{ {
LLS_PUSH (node, stack); LLS_PUSH (node, stack);
return; return;
} }
/* To take care of cases where long lists of nodes are in a chain /* To take care of cases where long lists of nodes are in a chain
of list nodes with exactly one entry, this algorithm will look of list nodes with exactly one entry, this algorithm will look
for a pattern of repeated list nodes with two entries, the first for a pattern of repeated list nodes with two entries, the first
being a list node and the second being a non-list node. Such being a list node and the second being a non-list node. Such
@ -4540,11 +4533,11 @@ if (node->nod_type != nod_list)
non-list nodes in the process. The purpose of this is to avoid non-list nodes in the process. The purpose of this is to avoid
massive recursion of this function. */ massive recursion of this function. */
start_chain = node; start_chain = node;
end_chain = NULL; end_chain = NULL;
curr_node = node; curr_node = node;
next_node = node->nod_arg[0]; next_node = node->nod_arg[0];
while ( curr_node->nod_count == 2 && while ( curr_node->nod_count == 2 &&
curr_node->nod_arg[0]->nod_type == nod_list && curr_node->nod_arg[0]->nod_type == nod_list &&
curr_node->nod_arg[1]->nod_type != nod_list && curr_node->nod_arg[1]->nod_type != nod_list &&
next_node->nod_arg[0]->nod_type == nod_list && next_node->nod_arg[0]->nod_type == nod_list &&
@ -4560,9 +4553,9 @@ while ( curr_node->nod_count == 2 &&
end_chain = curr_node; end_chain = curr_node;
} }
/* see if any chain was found */ /* see if any chain was found */
if ( end_chain) if ( end_chain)
{ {
/* first, handle the rest of the nodes */ /* first, handle the rest of the nodes */
@ -4573,7 +4566,7 @@ if ( end_chain)
/* stack the non-list nodes and reverse the chain on the way back */ /* stack the non-list nodes and reverse the chain on the way back */
curr_node = end_chain; curr_node = end_chain;
while ( TRUE) while (true)
{ {
LLS_PUSH( curr_node->nod_arg[1], stack); LLS_PUSH( curr_node->nod_arg[1], stack);
if ( curr_node == start_chain) if ( curr_node == start_chain)
@ -4586,7 +4579,7 @@ if ( end_chain)
return; return;
} }
for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++) for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++)
stack_nodes (*ptr, stack); stack_nodes (*ptr, stack);
} }
@ -4617,21 +4610,21 @@ int LexerState::yylex (
* Functional description: lexer. * Functional description: lexer.
* *
**************************************/ **************************************/
UCHAR tok_class; UCHAR tok_class;
char string[MAX_TOKEN_LEN]; char string[MAX_TOKEN_LEN];
char* p; char* p;
char* buffer; char* buffer;
char* buffer_end; char* buffer_end;
char* new_buffer; char* new_buffer;
SYM sym; SYM sym;
SSHORT c; SSHORT c;
USHORT buffer_len; USHORT buffer_len;
STR delimited_id_str; STR delimited_id_str;
/* Find end of white space and skip comments */ /* Find end of white space and skip comments */
for (;;) for (;;)
{ {
if (ptr >= end) if (ptr >= end)
return -1; return -1;
@ -4690,11 +4683,11 @@ for (;;)
break; break;
} }
/* Depending on tok_class of token, parse token */ /* Depending on tok_class of token, parse token */
last_token = ptr - 1; last_token = ptr - 1;
if (tok_class & CHR_INTRODUCER) if (tok_class & CHR_INTRODUCER)
{ {
/* The Introducer (_) is skipped, all other idents are copied /* The Introducer (_) is skipped, all other idents are copied
* to become the name of the character set * to become the name of the character set
@ -4718,9 +4711,9 @@ if (tok_class & CHR_INTRODUCER)
return INTRODUCER; return INTRODUCER;
} }
/* parse a quoted string, being sure to look for double quotes */ /* parse a quoted string, being sure to look for double quotes */
if (tok_class & CHR_QUOTE) if (tok_class & CHR_QUOTE)
{ {
buffer = string; buffer = string;
buffer_len = sizeof (string); buffer_len = sizeof (string);
@ -4816,19 +4809,19 @@ if (tok_class & CHR_QUOTE)
* ptr points to the next character. * ptr points to the next character.
*/ */
assert(ptr <= end); assert(ptr <= end);
if ((tok_class & CHR_DIGIT) || if ((tok_class & CHR_DIGIT) ||
((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT))) ((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT)))
{ {
/* The following variables are used to recognize kinds of numbers. */ /* The following variables are used to recognize kinds of numbers. */
BOOLEAN have_error = FALSE; /* syntax error or value too large */ bool have_error = false; /* syntax error or value too large */
BOOLEAN have_digit = FALSE; /* we've seen a digit */ bool have_digit = false; /* we've seen a digit */
BOOLEAN have_decimal = FALSE; /* we've seen a '.' */ bool have_decimal = false; /* we've seen a '.' */
BOOLEAN have_exp = FALSE; /* digit ... [eE] */ bool have_exp = false; /* digit ... [eE] */
BOOLEAN have_exp_sign = FALSE; /* digit ... [eE] {+-] */ bool have_exp_sign = false; /* digit ... [eE] {+-] */
BOOLEAN have_exp_digit = FALSE; /* digit ... [eE] ... digit */ bool have_exp_digit = false; /* digit ... [eE] ... digit */
UINT64 number = 0; UINT64 number = 0;
UINT64 limit_by_10 = MAX_SINT64 / 10; UINT64 limit_by_10 = MAX_SINT64 / 10;
@ -4842,32 +4835,32 @@ if ((tok_class & CHR_DIGIT) ||
else if (have_exp_sign && (! (classes [c] & CHR_DIGIT))) else if (have_exp_sign && (! (classes [c] & CHR_DIGIT)))
{ {
/* only digits can be accepted after "1E-" */ /* only digits can be accepted after "1E-" */
have_error = TRUE; have_error = true;
break; break;
} }
else if (have_exp) else if (have_exp)
{ {
/* We've seen e or E, but nothing beyond that. */ /* We've seen e or E, but nothing beyond that. */
if ( ('-' == c) || ('+' == c) ) if ( ('-' == c) || ('+' == c) )
have_exp_sign = TRUE; have_exp_sign = true;
else if ( classes [c] & CHR_DIGIT ) else if ( classes [c] & CHR_DIGIT )
/* We have a digit: we haven't seen a sign yet, /* We have a digit: we haven't seen a sign yet,
but it's too late now. */ but it's too late now. */
have_exp_digit = have_exp_sign = TRUE; have_exp_digit = have_exp_sign = true;
else else
{ {
/* end of the token */ /* end of the token */
have_error = TRUE; have_error = true;
break; break;
} }
} }
else if ('.' == c) else if ('.' == c)
{ {
if (!have_decimal) if (!have_decimal)
have_decimal = TRUE; have_decimal = true;
else else
{ {
have_error = TRUE; have_error = true;
break; break;
} }
} }
@ -4876,19 +4869,19 @@ if ((tok_class & CHR_DIGIT) ||
/* Before computing the next value, make sure there will be /* Before computing the next value, make sure there will be
no overflow. */ no overflow. */
have_digit = TRUE; have_digit = true;
if (number >= limit_by_10) if (number >= limit_by_10)
/* possibility of an overflow */ /* possibility of an overflow */
if ((number > limit_by_10) || (c > '8')) if ((number > limit_by_10) || (c > '8'))
{ {
have_error = TRUE; have_error = true;
break; break;
} }
number = number * 10 + (c - '0'); number = number * 10 + (c - '0');
} }
else if ( (('E' == c) || ('e' == c)) && have_digit ) else if ( (('E' == c) || ('e' == c)) && have_digit )
have_exp = TRUE; have_exp = true;
else else
/* Unexpected character: this is the end of the number. */ /* Unexpected character: this is the end of the number. */
break; break;
@ -4967,17 +4960,17 @@ if ((tok_class & CHR_DIGIT) ||
*/ */
} }
/* Restore the status quo ante, before we started our unsuccessful /* Restore the status quo ante, before we started our unsuccessful
attempt to recognize a number. */ attempt to recognize a number. */
ptr = last_token; ptr = last_token;
c = *ptr++; c = *ptr++;
/* We never touched tok_class, so it doesn't need to be restored. */ /* We never touched tok_class, so it doesn't need to be restored. */
/* end of number-recognition code */ /* end of number-recognition code */
if (tok_class & CHR_LETTER) if (tok_class & CHR_LETTER)
{ {
p = string; p = string;
CHECK_COPY_INCR(p, UPPER (c)); CHECK_COPY_INCR(p, UPPER (c));
for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++)
@ -5064,11 +5057,11 @@ if (tok_class & CHR_LETTER)
line_start_bk = line_start; line_start_bk = line_start;
lines_bk = lines; lines_bk = lines;
return SYMBOL; return SYMBOL;
} }
/* Must be punctuation -- test for double character punctuation */ /* Must be punctuation -- test for double character punctuation */
if (last_token + 1 < end) if (last_token + 1 < end)
{ {
sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version); sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version);
if (sym) if (sym)
@ -5078,10 +5071,10 @@ if (last_token + 1 < end)
} }
} }
/* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */ /* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */
/* This algorithm is not perfect, but it is ok for now. /* This algorithm is not perfect, but it is ok for now.
It should be dropped when BOOLEAN datatype is introduced in Firebird */ It should be dropped when BOOLEAN datatype is introduced in Firebird */
if ( c == '(' && !brace_analysis && if ( c == '(' && !brace_analysis &&
/* 1) We need to swallow braces in all boolean expressions /* 1) We need to swallow braces in all boolean expressions
2) We may swallow braces in ordinary expressions 2) We may swallow braces in ordinary expressions
3) We should not swallow braces after special tokens 3) We should not swallow braces after special tokens
@ -5089,7 +5082,7 @@ if ( c == '(' && !brace_analysis &&
*/ */
(prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR || (prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR ||
prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) ) prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) )
{ {
LexerState savedState = lex; LexerState savedState = lex;
brace_analysis = true; brace_analysis = true;
int openCount = 0; int openCount = 0;
@ -5144,11 +5137,11 @@ if ( c == '(' && !brace_analysis &&
/* Restore status quo. */ /* Restore status quo. */
lex = savedState; lex = savedState;
} }
} }
/* Single character punctuation are simply passed on */ /* Single character punctuation are simply passed on */
return c; return c;
} }
@ -5166,11 +5159,11 @@ static void yyerror (
* *
**************************************/ **************************************/
if (yychar < 1) if (yychar < 1)
ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104,
gds_arg_gds, gds_command_end_err, /* Unexpected end of command */ gds_arg_gds, gds_command_end_err, /* Unexpected end of command */
0); 0);
else else
{ {
ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104,
gds_arg_gds, gds_dsql_token_unk_err, gds_arg_gds, gds_dsql_token_unk_err,
@ -5178,14 +5171,12 @@ else
gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/ gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/
/* Token unknown - line %d, char %d */ /* Token unknown - line %d, char %d */
gds_arg_gds, gds_random, gds_arg_gds, gds_random,
gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, 0);
0);
} }
} }
static void yyabandon ( static void yyabandon (SSHORT sql_code,
SSHORT sql_code,
ISC_STATUS error_symbol) ISC_STATUS error_symbol)
{ {
/************************************** /**************************************
@ -5199,6 +5190,6 @@ static void yyabandon (
* *
**************************************/ **************************************/
ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code, ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code,
gds_arg_gds, error_symbol, 0); gds_arg_gds, error_symbol, 0);
} }

View File

@ -1958,7 +1958,7 @@ static void explode_asterisk(DSQL_REQ request, DSQL_NOD node, DSQL_NOD aggregate
DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count); DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count);
derived_field->nod_arg[e_derived_field_value] = select_item->nod_arg[e_derived_field_value]; derived_field->nod_arg[e_derived_field_value] = select_item->nod_arg[e_derived_field_value];
derived_field->nod_arg[e_derived_field_name] = select_item->nod_arg[e_derived_field_name]; derived_field->nod_arg[e_derived_field_name] = select_item->nod_arg[e_derived_field_name];
derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level;
derived_field->nod_desc = select_item->nod_desc; derived_field->nod_desc = select_item->nod_desc;
LLS_PUSH(derived_field, stack); LLS_PUSH(derived_field, stack);
} }
@ -3424,7 +3424,7 @@ static DSQL_NOD pass1_derived_table(DSQL_REQ request, DSQL_NOD input)
derived_field = MAKE_node(nod_derived_field, e_derived_field_count); derived_field = MAKE_node(nod_derived_field, e_derived_field_count);
derived_field->nod_arg[e_derived_field_value] = select_item; derived_field->nod_arg[e_derived_field_value] = select_item;
derived_field->nod_arg[e_derived_field_name] = list->nod_arg[count]; derived_field->nod_arg[e_derived_field_name] = list->nod_arg[count];
derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level;
derived_field->nod_desc = select_item->nod_desc; derived_field->nod_desc = select_item->nod_desc;
rse->nod_arg[e_rse_items]->nod_arg[count] = derived_field; rse->nod_arg[e_rse_items]->nod_arg[count] = derived_field;
@ -4537,7 +4537,7 @@ static DSQL_NOD pass1_make_derived_field(DSQL_REQ request, TSQL tdsql, DSQL_NOD
DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count); DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count);
derived_field->nod_arg[e_derived_field_value] = select_item; derived_field->nod_arg[e_derived_field_value] = select_item;
derived_field->nod_arg[e_derived_field_name] = (DSQL_NOD) alias; derived_field->nod_arg[e_derived_field_name] = (DSQL_NOD) alias;
derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level;
derived_field->nod_desc = select_item->nod_desc; derived_field->nod_desc = select_item->nod_desc;
return derived_field; return derived_field;
} }
@ -4555,7 +4555,7 @@ static DSQL_NOD pass1_make_derived_field(DSQL_REQ request, TSQL tdsql, DSQL_NOD
DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count); DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count);
derived_field->nod_arg[e_derived_field_value] = select_item->nod_arg[e_alias_value]; derived_field->nod_arg[e_derived_field_value] = select_item->nod_arg[e_alias_value];
derived_field->nod_arg[e_derived_field_name] = (DSQL_NOD) alias; derived_field->nod_arg[e_derived_field_name] = (DSQL_NOD) alias;
derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level;
derived_field->nod_desc = select_item->nod_desc; derived_field->nod_desc = select_item->nod_desc;
return derived_field; return derived_field;
} }
@ -4570,7 +4570,7 @@ static DSQL_NOD pass1_make_derived_field(DSQL_REQ request, TSQL tdsql, DSQL_NOD
// with orginal map. // with orginal map.
if (derived_field->nod_type == nod_derived_field) { if (derived_field->nod_type == nod_derived_field) {
derived_field->nod_arg[e_derived_field_value] = select_item; derived_field->nod_arg[e_derived_field_value] = select_item;
derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level;
derived_field->nod_desc = select_item->nod_desc; derived_field->nod_desc = select_item->nod_desc;
return derived_field; return derived_field;
} }

View File

@ -60,7 +60,7 @@ extern "C" {
static void generate_error(ISC_STATUS *, SCHAR *, SSHORT, SSHORT); static void generate_error(ISC_STATUS *, SCHAR *, SSHORT, SSHORT);
static SSHORT get_next_token(SCHAR **, SCHAR *, SCHAR *, USHORT *); static SSHORT get_next_token(SCHAR **, SCHAR *, SCHAR *, USHORT *);
static SSHORT get_token(ISC_STATUS *, SSHORT, BOOLEAN, SCHAR **, SCHAR *, static SSHORT get_token(ISC_STATUS *, SSHORT, bool, SCHAR **, SCHAR *,
SCHAR *, USHORT *); SCHAR *, USHORT *);
typedef struct pp_table { typedef struct pp_table {
@ -111,18 +111,21 @@ static const PP_TABLE pp_symbols[] = {
@param dialect @param dialect
**/ **/
int DLL_EXPORT PREPARSE_execute( int DLL_EXPORT PREPARSE_execute(ISC_STATUS * user_status,
ISC_STATUS * user_status,
FRBRD ** db_handle, FRBRD ** db_handle,
FRBRD ** trans_handle, FRBRD ** trans_handle,
USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect) USHORT stmt_length,
SCHAR * stmt,
BOOLEAN * stmt_eaten,
USHORT dialect)
{ {
TEXT file_name[MAX_TOKEN_SIZE + 1]; TEXT file_name[MAX_TOKEN_SIZE + 1];
SCHAR *token, *dpb_array, *dpb, *ch, *stmt_end; SCHAR *token, *dpb_array, *dpb, *ch, *stmt_end;
SLONG page_size = 0; SLONG page_size = 0;
USHORT dpb_len = 0, token_length; USHORT dpb_len = 0, token_length;
SSHORT i, l, result; SSHORT i, l, result;
BOOLEAN matched, get_out; bool matched;
bool get_out;
ISC_STATUS_ARRAY temp_status; ISC_STATUS_ARRAY temp_status;
FRBRD *temp_db_handle = NULL; FRBRD *temp_db_handle = NULL;
@ -139,26 +142,29 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect)
stmt_length = strlen(stmt); stmt_length = strlen(stmt);
stmt_end = stmt + stmt_length; stmt_end = stmt + stmt_length;
if (get_token(user_status, SYMBOL, FALSE, &stmt, stmt_end, token, if (get_token(user_status, SYMBOL, false, &stmt, stmt_end, token,
&token_length) || &token_length) ||
token_length != pp_symbols[PP_CREATE].length || token_length != pp_symbols[PP_CREATE].length ||
strcmp(token, pp_symbols[PP_CREATE].symbol)) { strcmp(token, pp_symbols[PP_CREATE].symbol))
{
gds__free((SLONG *) token); gds__free((SLONG *) token);
return FALSE; return FALSE;
} }
if (get_token(user_status, SYMBOL, FALSE, &stmt, stmt_end, token, if (get_token(user_status, SYMBOL, false, &stmt, stmt_end, token,
&token_length) || &token_length) ||
(token_length != pp_symbols[PP_DATABASE].length && (token_length != pp_symbols[PP_DATABASE].length &&
token_length != pp_symbols[PP_SCHEMA].length) || token_length != pp_symbols[PP_SCHEMA].length) ||
(strcmp(token, pp_symbols[PP_DATABASE].symbol) && (strcmp(token, pp_symbols[PP_DATABASE].symbol) &&
strcmp(token, pp_symbols[PP_SCHEMA].symbol))) { strcmp(token, pp_symbols[PP_SCHEMA].symbol)))
{
gds__free((SLONG *) token); gds__free((SLONG *) token);
return FALSE; return FALSE;
} }
if (get_token(user_status, STRING, FALSE, &stmt, stmt_end, token, if (get_token(user_status, STRING, false, &stmt, stmt_end, token,
&token_length)) { &token_length))
{
gds__free((SLONG *) token); gds__free((SLONG *) token);
return TRUE; return TRUE;
} }
@ -191,33 +197,35 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect)
else if (result < 0) else if (result < 0)
break; break;
matched = FALSE; matched = false;
for (i = 3; pp_symbols[i].length && !matched; i++) { for (i = 3; pp_symbols[i].length && !matched; i++) {
if (token_length == pp_symbols[i].length && if (token_length == pp_symbols[i].length &&
!strcmp(token, pp_symbols[i].symbol)) { !strcmp(token, pp_symbols[i].symbol)) {
get_out = FALSE; get_out = false;
switch (pp_symbols[i].code) { switch (pp_symbols[i].code) {
case PP_PAGE_SIZE: case PP_PAGE_SIZE:
case PP_PAGESIZE: case PP_PAGESIZE:
if (get_token(user_status, '=', TRUE, &stmt, stmt_end, if (get_token(user_status, '=', true, &stmt, stmt_end,
token, &token_length) || token, &token_length) ||
get_token(user_status, NUMERIC, FALSE, &stmt, get_token(user_status, NUMERIC, false, &stmt,
stmt_end, token, &token_length)) { stmt_end, token, &token_length))
get_out = TRUE; {
get_out = true;
break; break;
} }
page_size = atol(token); page_size = atol(token);
STUFF_DPB(gds_dpb_page_size); STUFF_DPB(gds_dpb_page_size);
STUFF_DPB(4); STUFF_DPB(4);
STUFF_DPB_INT(page_size); STUFF_DPB_INT(page_size);
matched = TRUE; matched = true;
break; break;
case PP_USER: case PP_USER:
if (get_token(user_status, STRING, FALSE, &stmt, stmt_end, if (get_token(user_status, STRING, false, &stmt, stmt_end,
token, &token_length)) { token, &token_length))
get_out = TRUE; {
get_out = true;
break; break;
} }
@ -227,13 +235,14 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect)
ch = token; ch = token;
while (*ch) while (*ch)
STUFF_DPB(*ch++); STUFF_DPB(*ch++);
matched = TRUE; matched = true;
break; break;
case PP_PASSWORD: case PP_PASSWORD:
if (get_token(user_status, STRING, FALSE, &stmt, stmt_end, if (get_token(user_status, STRING, false, &stmt, stmt_end,
token, &token_length)) { token, &token_length))
get_out = TRUE; {
get_out = true;
break; break;
} }
@ -243,17 +252,18 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect)
ch = token; ch = token;
while (*ch) while (*ch)
STUFF_DPB(*ch++); STUFF_DPB(*ch++);
matched = TRUE; matched = true;
break; break;
case PP_SET: case PP_SET:
if (get_token(user_status, SYMBOL, FALSE, &stmt, stmt_end, if (get_token(user_status, SYMBOL, false, &stmt, stmt_end,
token, &token_length) || token, &token_length) ||
token_length != pp_symbols[PP_NAMES].length || token_length != pp_symbols[PP_NAMES].length ||
strcmp(token, pp_symbols[PP_NAMES].symbol) || strcmp(token, pp_symbols[PP_NAMES].symbol) ||
get_token(user_status, STRING, FALSE, &stmt, stmt_end, get_token(user_status, STRING, false, &stmt, stmt_end,
token, &token_length)) { token, &token_length))
get_out = TRUE; {
get_out = true;
break; break;
} }
@ -263,26 +273,27 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect)
ch = token; ch = token;
while (*ch) while (*ch)
STUFF_DPB(*ch++); STUFF_DPB(*ch++);
matched = TRUE; matched = true;
break; break;
case PP_LENGTH: case PP_LENGTH:
/* Skip a token for value */ /* Skip a token for value */
if (get_token(user_status, '=', TRUE, &stmt, stmt_end, if (get_token(user_status, '=', true, &stmt, stmt_end,
token, &token_length) || token, &token_length) ||
get_token(user_status, NUMERIC, FALSE, &stmt, get_token(user_status, NUMERIC, false, &stmt,
stmt_end, token, &token_length)) { stmt_end, token, &token_length))
get_out = TRUE; {
get_out = true;
break; break;
} }
matched = TRUE; matched = true;
break; break;
case PP_PAGE: case PP_PAGE:
case PP_PAGES: case PP_PAGES:
matched = TRUE; matched = true;
break; break;
} }
@ -531,12 +542,13 @@ static SSHORT get_next_token(
@param token_length @param token_length
**/ **/
static SSHORT get_token( static SSHORT get_token(ISC_STATUS * status,
ISC_STATUS * status,
SSHORT token_type, SSHORT token_type,
BOOLEAN optional, bool optional,
SCHAR ** stmt, SCHAR ** stmt,
SCHAR * stmt_end, SCHAR * token, USHORT * token_length) SCHAR * stmt_end,
SCHAR * token,
USHORT * token_length)
{ {
SSHORT result; SSHORT result;
SCHAR *temp_stmt; SCHAR *temp_stmt;

View File

@ -101,13 +101,13 @@ static void init(FRBRD**);
static NAME insert_name(SCHAR*, NAME *, STMT); static NAME insert_name(SCHAR*, NAME *, STMT);
static USHORT name_length(SCHAR *); static USHORT name_length(SCHAR *);
static void remove_name(NAME, NAME *); static void remove_name(NAME, NAME *);
static BOOLEAN scompare(SCHAR*, USHORT, SCHAR*, USHORT); static bool scompare(SCHAR*, USHORT, SCHAR*, USHORT);
/* declare the private data */ /* declare the private data */
#pragma FB_COMPILER_MESSAGE("Dragons ahead. Static data. Not thread safe!") #pragma FB_COMPILER_MESSAGE("Dragons ahead. Static data. Not thread safe!")
static BOOLEAN init_flag = FALSE; /* whether we've been initialized */ static bool init_flag = false; /* whether we've been initialized */
static ERR UDSQL_error = NULL; static ERR UDSQL_error = NULL;
static STMT statements = NULL; static STMT statements = NULL;
static NAME statement_names = NULL; static NAME statement_names = NULL;
@ -1339,7 +1339,7 @@ static void cleanup(void* arg)
return; return;
} }
init_flag = FALSE; init_flag = false;
gds__free(UDSQL_error); gds__free(UDSQL_error);
UDSQL_error = NULL; UDSQL_error = NULL;
@ -1500,7 +1500,7 @@ static void init(FRBRD** db_handle)
if (!UDSQL_error) { // NOMEM: if (!UDSQL_error) { // NOMEM:
return; // Don't set the init_flag return; // Don't set the init_flag
} }
init_flag = TRUE; init_flag = true;
gds__register_cleanup(cleanup, 0); gds__register_cleanup(cleanup, 0);
} }
@ -1527,10 +1527,7 @@ static void init(FRBRD** db_handle)
dbb->dbb_database_handle = *db_handle; dbb->dbb_database_handle = *db_handle;
ISC_STATUS_ARRAY local_status; ISC_STATUS_ARRAY local_status;
gds__database_cleanup(local_status, gds__database_cleanup(local_status, db_handle, cleanup_database, (SLONG) 0);
db_handle,
cleanup_database,
(SLONG) FALSE);
} }
@ -1671,7 +1668,7 @@ static void remove_name(NAME name, NAME* list_ptr)
} }
static BOOLEAN scompare(SCHAR* string1, static bool scompare(SCHAR* string1,
USHORT length1, USHORT length1,
SCHAR* string2, SCHAR* string2,
USHORT length2) USHORT length2)
@ -1688,7 +1685,7 @@ static BOOLEAN scompare(SCHAR* string1,
**************************************/ **************************************/
if (length1 != length2) { if (length1 != length2) {
return FALSE; return false;
} }
SCHAR c1, c2; SCHAR c1, c2;
@ -1698,11 +1695,11 @@ static BOOLEAN scompare(SCHAR* string1,
c2 = *string2++; c2 = *string2++;
if (c1 != c2 && UPPER7(c1) != UPPER7(c2)) if (c1 != c2 && UPPER7(c1) != UPPER7(c2))
{ {
return FALSE; return false;
} }
} }
return TRUE; return true;
} }

View File

@ -51,9 +51,9 @@ private:
static MemoryPool * pool; // where we should place our thps static MemoryPool * pool; // where we should place our thps
static ThreadPriorityScheduler * chain; // where starts thps chain static ThreadPriorityScheduler * chain; // where starts thps chain
static ThreadPriorityScheduler * news; // where starts new thps chain static ThreadPriorityScheduler * news; // where starts new thps chain
static BOOLEAN initialized; static bool initialized;
static DWORD specific_key; // for thread LS access static DWORD specific_key; // for thread LS access
static BOOLEAN shutdown; // server shutting down static bool shutdown; // server shutting down
ThreadPriorityScheduler * next; // next thread in list ThreadPriorityScheduler * next; // next thread in list
union { union {
@ -77,7 +77,7 @@ public:
static void Exit(void); static void Exit(void);
static thdd *Get(void); static thdd *Get(void);
static void Set(thdd *val); static void Set(thdd *val);
static BOOLEAN Boosted(void); static bool Boosted(void);
static void Cleanup(void); static void Cleanup(void);
static void Init(void); static void Init(void);
static void Attach(HANDLE tHandle, DWORD thread_id, int &p); static void Attach(HANDLE tHandle, DWORD thread_id, int &p);
@ -109,7 +109,7 @@ public:
#define THPS_INIT() #define THPS_INIT()
#define THPS_FINI() #define THPS_FINI()
#define THPS_ATTACH(handle, thread_id, priority) #define THPS_ATTACH(handle, thread_id, priority)
#define THPS_BOOSTDONE() FALSE #define THPS_BOOSTDONE() false
#endif // THREAD_PSCHED #endif // THREAD_PSCHED

View File

@ -48,18 +48,18 @@
static struct FAB fab; static struct FAB fab;
static struct RAB rab; static struct RAB rab;
static BOOLEAN check_sort(NOD, IDX *, USHORT); static bool check_sort(NOD, IDX *, USHORT);
static BOOLEAN compare(UCHAR *, UCHAR *, USHORT); static bool compare(UCHAR *, UCHAR *, USHORT);
static int compare_segment(NOD, UCHAR *, DSC *); static int compare_segment(NOD, UCHAR *, DSC *);
static int connect(EXT, USHORT); static int connect(EXT, USHORT);
static void disconnect(EXT); static void disconnect(EXT);
static void expand_format(FMT, FMT); static void expand_format(FMT, FMT);
static SLONG find_field(FMT, USHORT, USHORT, USHORT); static SLONG find_field(FMT, USHORT, USHORT, USHORT);
static int get_dbkey(RSB); static bool get_dbkey(RSB);
static int get_indexed(RSB); static bool get_indexed(RSB);
static USHORT get_key_segment(NOD, UCHAR *, DSC *); static USHORT get_key_segment(NOD, UCHAR *, DSC *);
static BOOLEAN get_sequential(RSB); static bool get_sequential(RSB);
static BOOLEAN match_index(FMT, struct XABKEY *, IDX *); static bool match_index(FMT, struct XABKEY *, IDX *);
static int open_indexed(RSB); static int open_indexed(RSB);
static int open_sequential(RSB); static int open_sequential(RSB);
static void position_by_rfa(EXT, USHORT *); static void position_by_rfa(EXT, USHORT *);
@ -314,13 +314,22 @@ int EXT_get(RSB rsb)
switch (rsb->rsb_type) { switch (rsb->rsb_type) {
case rsb_ext_sequential: case rsb_ext_sequential:
return get_sequential(rsb); if (get_sequential(rsb))
return TRUE;
else
return FALSE;
case rsb_ext_indexed: case rsb_ext_indexed:
return get_indexed(rsb); if (get_indexed(rsb))
return TRUE
else
return FALSE;
case rsb_ext_dbkey: case rsb_ext_dbkey:
return get_dbkey(rsb); if (get_dbkey(rsb))
return TRUE
else
return FALSE
default: default:
IBERROR(181); /* msg 181 external access type not implemented */ IBERROR(181); /* msg 181 external access type not implemented */
@ -641,7 +650,7 @@ void EXT_trans_start(TRA transaction)
} }
static BOOLEAN check_sort(NOD sort, IDX * index, USHORT stream) static bool check_sort(NOD sort, IDX * index, USHORT stream)
{ {
/************************************** /**************************************
* *
@ -661,7 +670,7 @@ static BOOLEAN check_sort(NOD sort, IDX * index, USHORT stream)
index segments, we obviously can optimize anything */ index segments, we obviously can optimize anything */
if (!sort || sort->nod_count > index->idx_count) if (!sort || sort->nod_count > index->idx_count)
return FALSE; return false;
/* For each sort key, make sure the key matches the index segment, /* For each sort key, make sure the key matches the index segment,
and that the sort is ascending */ and that the sort is ascending */
@ -672,14 +681,17 @@ static BOOLEAN check_sort(NOD sort, IDX * index, USHORT stream)
if (field->nod_type != nod_field || if (field->nod_type != nod_field ||
(USHORT) field->nod_arg[e_fld_stream] != stream || (USHORT) field->nod_arg[e_fld_stream] != stream ||
(USHORT) field->nod_arg[e_fld_id] != tail->idx_field || (USHORT) field->nod_arg[e_fld_id] != tail->idx_field ||
ptr[sort->nod_count]) return FALSE; ptr[sort->nod_count])
{
return false;
}
} }
return TRUE; return true;
} }
static BOOLEAN compare(UCHAR * string1, UCHAR * string2, USHORT length) static bool compare(UCHAR * string1, UCHAR * string2, USHORT length)
{ {
/************************************** /**************************************
* *
@ -694,10 +706,10 @@ static BOOLEAN compare(UCHAR * string1, UCHAR * string2, USHORT length)
do do
if (*string1++ != *string2++) if (*string1++ != *string2++)
return 1; return true;
while (--length); while (--length);
return 0; return false;
} }
@ -862,7 +874,7 @@ static SLONG find_field(
} }
static get_dbkey(RSB rsb) static bool get_dbkey(RSB rsb)
{ {
/************************************** /**************************************
* *
@ -903,7 +915,7 @@ static get_dbkey(RSB rsb)
/* If this isn't the first time thru its the last time thru */ /* If this isn't the first time thru its the last time thru */
if (!(impure->irsb_flags & irsb_first)) if (!(impure->irsb_flags & irsb_first))
return FALSE; return false;
/* Evaluate expression */ /* Evaluate expression */
@ -922,18 +934,18 @@ static get_dbkey(RSB rsb)
file->ext_flags &= ~EXT_eof; file->ext_flags &= ~EXT_eof;
if (status == RMS$_EOF) if (status == RMS$_EOF)
return FALSE; return false;
sys$free(&rab); sys$free(&rab);
set_flags(relation, record); set_flags(relation, record);
MOVE_FAST(rab.rab$w_rfa, &rpb->rpb_ext_dbkey, sizeof(rab.rab$w_rfa)); MOVE_FAST(rab.rab$w_rfa, &rpb->rpb_ext_dbkey, sizeof(rab.rab$w_rfa));
MOVE_FAST(rab.rab$w_rfa, file->ext_dbkey, sizeof(rab.rab$w_rfa)); MOVE_FAST(rab.rab$w_rfa, file->ext_dbkey, sizeof(rab.rab$w_rfa));
return TRUE; return true;
} }
static get_indexed(RSB rsb) static bool get_indexed(RSB rsb)
{ {
/************************************** /**************************************
* *
@ -999,7 +1011,7 @@ static get_indexed(RSB rsb)
status = sys$find(&rab); status = sys$find(&rab);
file->ext_flags &= ~EXT_eof; file->ext_flags &= ~EXT_eof;
if (status == RMS$_EOF || status == RMS$_RNF) if (status == RMS$_EOF || status == RMS$_RNF)
return FALSE; return false;
if (!(status & 1)) if (!(status & 1))
ERR_post(isc_io_error, ERR_post(isc_io_error,
gds_arg_string, "sys$find", gds_arg_string, "sys$find",
@ -1012,7 +1024,7 @@ static get_indexed(RSB rsb)
EOF, we're done */ EOF, we're done */
if (!get_sequential(rsb)) if (!get_sequential(rsb))
return FALSE; return false;
/* Check record against upper bound. If we pass it, we're done. /* Check record against upper bound. If we pass it, we're done.
Note: this code ignores issues of inclusive/exclusive upper Note: this code ignores issues of inclusive/exclusive upper
@ -1029,10 +1041,10 @@ static get_indexed(RSB rsb)
if (result < 0) if (result < 0)
break; break;
if (result > 0) if (result > 0)
return FALSE; return false;
} }
return TRUE; return true;
} }
@ -1062,7 +1074,7 @@ static USHORT get_key_segment(NOD node, UCHAR * buffer, DSC * target)
} }
static BOOLEAN get_sequential(RSB rsb) static bool get_sequential(RSB rsb)
{ {
/************************************** /**************************************
* *
@ -1106,7 +1118,9 @@ static BOOLEAN get_sequential(RSB rsb)
if (rpb->rpb_ext_isi == file->ext_isi && if (rpb->rpb_ext_isi == file->ext_isi &&
!(impure->irsb_flags & irsb_first) && !(impure->irsb_flags & irsb_first) &&
compare(file->ext_dbkey, &rpb->rpb_ext_dbkey, sizeof(rab.rab$w_rfa))) compare(file->ext_dbkey, &rpb->rpb_ext_dbkey, sizeof(rab.rab$w_rfa)))
{
position_by_rfa(file, &rpb->rpb_ext_dbkey); position_by_rfa(file, &rpb->rpb_ext_dbkey);
}
rab.rab$b_rac = RAB$C_SEQ; rab.rab$b_rac = RAB$C_SEQ;
status = sys$get(&rab); status = sys$get(&rab);
@ -1114,7 +1128,7 @@ static BOOLEAN get_sequential(RSB rsb)
file->ext_flags &= ~EXT_eof; file->ext_flags &= ~EXT_eof;
if (status == RMS$_EOF) if (status == RMS$_EOF)
return FALSE; return false;
if (!(status & 1)) if (!(status & 1))
ERR_post(isc_io_error, ERR_post(isc_io_error,
@ -1133,11 +1147,11 @@ static BOOLEAN get_sequential(RSB rsb)
if (rpb->rpb_ext_isi == file->ext_isi) if (rpb->rpb_ext_isi == file->ext_isi)
MOVE_FAST(rab.rab$w_rfa, file->ext_dbkey, sizeof(rab.rab$w_rfa)); MOVE_FAST(rab.rab$w_rfa, file->ext_dbkey, sizeof(rab.rab$w_rfa));
return TRUE; return true;
} }
static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx) static bool match_index(FMT format, struct XABKEY *xab, IDX * idx)
{ {
/************************************** /**************************************
* *
@ -1147,8 +1161,8 @@ static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx)
* *
* Functional description * Functional description
* Try to match RMS key against fields. If success, build * Try to match RMS key against fields. If success, build
* internal index description and return TRUE. Otherwise * internal index description and return true. Otherwise
* return FALSE. * return false.
* *
**************************************/ **************************************/
int n, dtype; int n, dtype;
@ -1163,7 +1177,7 @@ static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx)
for (; size < end; size++, position++, tail++) { for (; size < end; size++, position++, tail++) {
if ((n = find_field(format, xab->xab$b_dtp, *position, *size)) < 0) if ((n = find_field(format, xab->xab$b_dtp, *position, *size)) < 0)
return FALSE; return false;
tail->idx_field = n; tail->idx_field = n;
tail->idx_itype = xab->xab$b_dtp; tail->idx_itype = xab->xab$b_dtp;
} }
@ -1173,7 +1187,7 @@ static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx)
idx->idx_flags = 0; idx->idx_flags = 0;
idx->idx_id = xab->xab$b_ref; idx->idx_id = xab->xab$b_ref;
return TRUE; return true;
} }

View File

@ -55,7 +55,7 @@ typedef struct map_msg {
extern double MTH$CVT_D_G(), MTH$CVT_G_D(); extern double MTH$CVT_D_G(), MTH$CVT_G_D();
static void bugcheck(int); static void bugcheck(int);
static BOOLEAN check_message(UCHAR **); static bool check_message(UCHAR **);
static MAP_MSG rebuild_message(UCHAR **, UCHAR **); static MAP_MSG rebuild_message(UCHAR **, UCHAR **);
static int translate_status(ISC_STATUS *, ISC_STATUS *, SCHAR **); static int translate_status(ISC_STATUS *, ISC_STATUS *, SCHAR **);
@ -394,7 +394,8 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status)
**************************************/ **************************************/
ISC_STATUS code, number, length, gds_index, *tmp; ISC_STATUS code, number, length, gds_index, *tmp;
ISC_STATUS_ARRAY temp; ISC_STATUS_ARRAY temp;
USHORT shift, flag; USHORT shift;
bool flag;
SCHAR msgbuff[WRKBUF_SIZ], *p, *q, *pw1, *pw2, flags[4], part; SCHAR msgbuff[WRKBUF_SIZ], *p, *q, *pw1, *pw2, flags[4], part;
struct dsc$descriptor_s desc, *dsc_ptr; struct dsc$descriptor_s desc, *dsc_ptr;
// static const SCHAR * const messages[] = { // static const SCHAR * const messages[] = {
@ -432,7 +433,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status)
return gds__random; return gds__random;
} }
flag = FALSE; flag = false;
vms_status = vms_status + 3; vms_status = vms_status + 3;
if (*p == '%') if (*p == '%')
@ -455,7 +456,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status)
BUGCHECK(235); /* msg 235 Unimplemented conversion, FAO directive X,U */ BUGCHECK(235); /* msg 235 Unimplemented conversion, FAO directive X,U */
*tmp++ = gds_arg_number; *tmp++ = gds_arg_number;
number = *tmp++ = *vms_status++; number = *tmp++ = *vms_status++;
flag = (number == 1) ? FALSE : TRUE; flag = (number == 1) ? false : true;
sprintf(pw2, "%%x%x", number); sprintf(pw2, "%%x%x", number);
while (*pw2) while (*pw2)
++pw2; ++pw2;
@ -524,7 +525,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status)
p = messages[gds_index]; p = messages[gds_index];
tmp = temp; tmp = temp;
gds_status = gds_status + 2; gds_status = gds_status + 2;
flag = FALSE; flag = false;
while (*p) { while (*p) {
if (*p++ != '%') if (*p++ != '%')
@ -533,7 +534,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status)
case 's': case 's':
*gds_status++ = gds_arg_cstring; *gds_status++ = gds_arg_cstring;
if (*tmp++ != gds_arg_cstring || flag) { if (*tmp++ != gds_arg_cstring || flag) {
flag = TRUE; flag = true;
*gds_status++ = 3; *gds_status++ = 3;
*gds_status++ = pw2; *gds_status++ = pw2;
sprintf(pw2, "<?>"); sprintf(pw2, "<?>");
@ -548,7 +549,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status)
case 'd': case 'd':
*gds_status++ = gds_arg_number; *gds_status++ = gds_arg_number;
if (*tmp++ != gds_arg_number || flag) { if (*tmp++ != gds_arg_number || flag) {
flag = TRUE; flag = true;
*gds_status++ = -1; *gds_status++ = -1;
break; break;
} }
@ -632,7 +633,7 @@ static void bugcheck(int number)
} }
static BOOLEAN check_message(UCHAR ** org_ptr) static bool check_message(UCHAR ** org_ptr)
{ {
/************************************** /**************************************
* *
@ -642,7 +643,7 @@ static BOOLEAN check_message(UCHAR ** org_ptr)
* *
* Functional description * Functional description
* Parse a blr message. If the message contains a non-Rdb data type, * Parse a blr message. If the message contains a non-Rdb data type,
* return TRUE. Otherwise update the blr pointer and return FALSE. * return true. Otherwise update the blr pointer and return false.
* *
**************************************/ **************************************/
UCHAR *org, dtype; UCHAR *org, dtype;
@ -659,7 +660,7 @@ static BOOLEAN check_message(UCHAR ** org_ptr)
case blr_timestamp: case blr_timestamp:
case blr_cstring: case blr_cstring:
case blr_d_float: case blr_d_float:
return TRUE; return true;
case blr_text: case blr_text:
case blr_varying: case blr_varying:
@ -673,7 +674,7 @@ static BOOLEAN check_message(UCHAR ** org_ptr)
*org_ptr = org; *org_ptr = org;
return FALSE; return false;
} }

View File

@ -58,12 +58,12 @@ extern "C" {
extern gds__completion_ast(); extern gds__completion_ast();
static BOOLEAN extend_file(FIL, ISC_STATUS *); static bool extend_file(FIL, ISC_STATUS *);
static FIL seek_file(FIL, BDB, int *); static FIL seek_file(FIL, BDB, int *);
static FIL setup_file(DBB, TEXT *, USHORT, USHORT, struct NAM *); static FIL setup_file(DBB, TEXT *, USHORT, USHORT, struct NAM *);
static void setup_trace(FIL, SSHORT); static void setup_trace(FIL, SSHORT);
static void trace_event(FIL, SSHORT, SCHAR *, SSHORT); static void trace_event(FIL, SSHORT, SCHAR *, SSHORT);
static BOOLEAN vms_io_error(ISC_STATUS *, TEXT *, ISC_STATUS, int, FIL); static bool vms_io_error(ISC_STATUS *, TEXT *, ISC_STATUS, int, FIL);
#define DVI$_DEVLOCKNAM 240 #define DVI$_DEVLOCKNAM 240
@ -671,7 +671,7 @@ int PIO_write(FIL file, BDB bdb, PAG page, ISC_STATUS * status_vector)
} }
static BOOLEAN extend_file(FIL file, ISC_STATUS * status_vector) static bool extend_file(FIL file, ISC_STATUS * status_vector)
{ {
/************************************** /**************************************
* *
@ -757,7 +757,7 @@ static BOOLEAN extend_file(FIL file, ISC_STATUS * status_vector)
return vms_io_error(status_vector, "QIO IO$_MODIFY", return vms_io_error(status_vector, "QIO IO$_MODIFY",
isc_io_access_err, status, file); isc_io_access_err, status, file);
return TRUE; return true;
} }
@ -930,7 +930,7 @@ static void trace_event(FIL file, SSHORT type, SCHAR * ptr, SSHORT length)
#endif #endif
static BOOLEAN vms_io_error( static bool vms_io_error(
ISC_STATUS * status_vector, ISC_STATUS * status_vector,
TEXT * string, TEXT * string,
ISC_STATUS operation, int code, FIL file) ISC_STATUS operation, int code, FIL file)
@ -959,7 +959,7 @@ static BOOLEAN vms_io_error(
*status_vector++ = code; *status_vector++ = code;
*status_vector++ = gds_arg_end; *status_vector++ = gds_arg_end;
return FALSE; return false;
} }

View File

@ -91,7 +91,8 @@ static SES sessions;
static EVNT parent_events; static EVNT parent_events;
static SLONG request_id; static SLONG request_id;
static POKE pokes; static POKE pokes;
static USHORT thread_started, delivery_flag; static bool thread_started;
static bool delivery_flag;
static UCHAR *alloc(USHORT); static UCHAR *alloc(USHORT);
static void blocking_ast(EVNT); static void blocking_ast(EVNT);
@ -100,14 +101,13 @@ static void delete_request(VMS_REQ);
static void deliver(EVNT); static void deliver(EVNT);
static void deliver_request(VMS_REQ); static void deliver_request(VMS_REQ);
static void delivery_thread(void); static void delivery_thread(void);
static int delivery_wait(void);
static ISC_STATUS error(ISC_STATUS *, TEXT *, ISC_STATUS); static ISC_STATUS error(ISC_STATUS *, TEXT *, ISC_STATUS);
static EVNT find_event(USHORT, TEXT *, EVNT); static EVNT find_event(USHORT, TEXT *, EVNT);
static void free(SCHAR *); static void free(SCHAR *);
static RINT historical_interest(SES, EVNT); static RINT historical_interest(SES, EVNT);
static EVNT make_event(USHORT, TEXT *, EVNT); static EVNT make_event(USHORT, TEXT *, EVNT);
static void poke_ast(POKE); static void poke_ast(POKE);
static BOOLEAN request_completed(VMS_REQ); static bool request_completed(VMS_REQ);
static int return_ok(ISC_STATUS *); static int return_ok(ISC_STATUS *);
@ -153,7 +153,7 @@ SLONG EVENT_create_session(ISC_STATUS status_vector)
session = (SES) alloc(sizeof(struct ses)); session = (SES) alloc(sizeof(struct ses));
if (!session) { if (!session) {
assert(FALSE); /* No error handling */ assert(false); /* No error handling */
return 0L; return 0L;
} }
session->ses_next = sessions; session->ses_next = sessions;
@ -325,7 +325,9 @@ SLONG EVENT_que(ISC_STATUS * status_vector,
USHORT string_length, USHORT string_length,
TEXT * string, TEXT * string,
USHORT events_length, USHORT events_length,
UCHAR * events, void (*ast_routine) (), void *ast_arg) UCHAR * events,
void (*ast_routine) (),
void *ast_arg)
{ {
/************************************** /**************************************
* *
@ -339,7 +341,9 @@ SLONG EVENT_que(ISC_STATUS * status_vector,
**************************************/ **************************************/
SES session; SES session;
UCHAR *p, *end, *find_end; UCHAR *p, *end, *find_end;
USHORT count, flag, len; USHORT count;
bool flag;
USHORT len;
VMS_REQ request, next; VMS_REQ request, next;
EVNT event, parent; EVNT event, parent;
RINT interest, *ptr, *ptr2; RINT interest, *ptr, *ptr2;
@ -348,7 +352,7 @@ SLONG EVENT_que(ISC_STATUS * status_vector,
session = (SES) session_id; session = (SES) session_id;
if (!thread_started) { if (!thread_started) {
thread_started = TRUE; thread_started = true;
gds__thread_start(delivery_thread, 0, THREAD_high, THREAD_ast); gds__thread_start(delivery_thread, 0, THREAD_high, THREAD_ast);
} }
@ -388,7 +392,7 @@ SLONG EVENT_que(ISC_STATUS * status_vector,
ptr = &request->req_interests; ptr = &request->req_interests;
p = events + 1; p = events + 1;
end = events + events_length; end = events + events_length;
flag = FALSE; flag = false;
while (p < end) { while (p < end) {
count = *p++; count = *p++;
@ -422,7 +426,7 @@ SLONG EVENT_que(ISC_STATUS * status_vector,
interest->rint_count = gds__vax_integer(p, 4); interest->rint_count = gds__vax_integer(p, 4);
p += 4; p += 4;
if (interest->rint_count <= event->evnt_count) if (interest->rint_count <= event->evnt_count)
flag = TRUE; flag = true;
} }
if (flag) if (flag)
@ -613,10 +617,12 @@ static void deliver(EVNT event)
event->evnt_count = event->evnt_lksb.lksb_value[0]; event->evnt_count = event->evnt_lksb.lksb_value[0];
for (interest = event->evnt_interests; interest; for (interest = event->evnt_interests; interest;
interest = interest->rint_evnt_interests) if (request = interest = interest->rint_evnt_interests)
interest->rint_request) {
if (request = interest->rint_request)
if (request->req_ast && request_completed(request)) if (request->req_ast && request_completed(request))
delivery_flag = TRUE; delivery_flag = true;
}
gds__completion_ast(); gds__completion_ast();
} }
@ -701,39 +707,28 @@ static void delivery_thread(void)
SES session; SES session;
for (;;) { for (;;) {
delivery_flag = FALSE; delivery_flag = false;
for (session = sessions; session; session = session->ses_next) for (session = sessions; session; session = session->ses_next)
for (request = session->ses_requests; request; for (request = session->ses_requests; request;
request = request->req_next) request = request->req_next)
if (request->req_ast && request_completed(request)) { {
if (request->req_ast && request_completed(request))
{
deliver_request(request); deliver_request(request);
request->req_ast = NULL; request->req_ast = NULL;
} }
gds__thread_wait(delivery_wait, 0); }
if (delivery_flag)
gds__thread_wait(TRUE, 0);
else
gds__thread_wait(FALSE, 0);
} }
} }
static ISC_STATUS error(ISC_STATUS * status_vector,
static int delivery_wait(void) TEXT * string,
ISC_STATUS status)
{ {
/**************************************
*
* d e l i v e r y _ w a i t
*
**************************************
*
* Functional description
* See if the deliver thread should wake up.
*
**************************************/
return delivery_flag;
}
static ISC_STATUS error(ISC_STATUS * status_vector;
TEXT * string;
ISC_STATUS status; {
/************************************** /**************************************
* *
* e r r o r * e r r o r
@ -752,11 +747,13 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
*status_vector++ = gds_arg_vms; *status_vector++ = gds_arg_vms;
*status_vector++ = status; *status_vector++ = gds_arg_end; *status_vector++ = status; *status_vector++ = gds_arg_end;
return gds__sys_request; return gds__sys_request;
} }
static EVNT find_event(USHORT length, static EVNT find_event(USHORT length,
TEXT * string, EVNT parent) { TEXT * string,
EVNT parent)
{
/************************************** /**************************************
* *
* f i n d _ e v e n t * f i n d _ e v e n t
@ -772,10 +769,14 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
for (; event; event = event->evnt_next) for (; event; event = event->evnt_next)
if (event->evnt_length == length && if (event->evnt_length == length &&
!strncmp(string, event->evnt_name, length)) !strncmp(string, event->evnt_name, length))
return event; return NULL;} {
return event;
}
return NULL;
}
static void free(SCHAR * block) { static void free(SCHAR * block) {
/************************************** /**************************************
* *
* f r e e * f r e e
@ -787,10 +788,13 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
* *
**************************************/ **************************************/
gds__free(block);} gds__free(block);
}
static RINT historical_interest(SES session, EVNT event) { static RINT historical_interest(SES session,
EVNT event)
{
/************************************** /**************************************
* *
* h i s t o r i c a l _ i n t e r e s t * h i s t o r i c a l _ i n t e r e s t
@ -804,12 +808,18 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
RINT interest, *ptr; RINT interest, *ptr;
for (ptr = &session->ses_interests; interest = *ptr; for (ptr = &session->ses_interests; interest = *ptr;
ptr = &(*ptr)->rint_req_interests) ptr = &(*ptr)->rint_req_interests)
{
if (interest->rint_event == event) if (interest->rint_event == event)
return interest; return NULL;} return interest;
}
return NULL;
}
static EVNT make_event(USHORT length, static EVNT make_event(USHORT length,
TEXT * string, EVNT parent) { TEXT * string,
EVNT parent)
{
/************************************** /**************************************
* *
* m a k e _ e v e n t * m a k e _ e v e n t
@ -879,10 +889,12 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
0, /* access mode */ 0, /* access mode */
0);} 0);}
return event;} return event;
}
static void poke_ast(POKE poke) { static void poke_ast(POKE poke)
{
/************************************** /**************************************
* *
* p o k e _ a s t * p o k e _ a s t
@ -898,13 +910,14 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
LKSB * lksb; LKSB * lksb;
lksb = &poke->poke_lksb; lksb = &poke->poke_lksb;
lksb->lksb_value[0] += poke->poke_value; lksb->lksb_value[0] += poke->poke_value;
status = status = sys$deq(lksb->lksb_lock_id, lksb->lksb_value, 0, 0);
sys$deq(lksb->lksb_lock_id, lksb->lksb_value, 0, 0);
status = sys$deq(poke->poke_parent_id, 0, 0, 0); status = sys$deq(poke->poke_parent_id, 0, 0, 0);
--poke->poke_use_count;} --poke->poke_use_count;
}
static BOOLEAN request_completed(VMS_REQ request) { static bool request_completed(VMS_REQ request)
{
/************************************** /**************************************
* *
* r e q u e s t _ c o m p l e t e d * r e q u e s t _ c o m p l e t e d
@ -918,15 +931,19 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
RINT interest; RINT interest;
EVNT event; EVNT event;
for (interest = request->req_interests; interest; for (interest = request->req_interests; interest;
interest = interest->rint_req_interests) { interest = interest->rint_req_interests)
{
event = interest->rint_event; event = interest->rint_event;
if (interest->rint_count <= if (interest->rint_count <= event->evnt_count)
event->evnt_count) return TRUE;} return true;
}
return FALSE;} return false;
}
static int return_ok(ISC_STATUS * status_vector) { static int return_ok(ISC_STATUS * status_vector)
{
/************************************** /**************************************
* *
* r e t u r n _ o k * r e t u r n _ o k
@ -940,4 +957,6 @@ static ISC_STATUS error(ISC_STATUS * status_vector;
*status_vector++ = gds_arg_gds; *status_vector++ = gds_arg_gds;
*status_vector++ = 0; *status_vector++ = 0;
*status_vector = gds_arg_end; return 0;} *status_vector = gds_arg_end;
return 0;
}

View File

@ -49,9 +49,9 @@ MUTX_T ThreadPriorityScheduler::mutex;
MemoryPool * ThreadPriorityScheduler::pool = 0; MemoryPool * ThreadPriorityScheduler::pool = 0;
ThreadPriorityScheduler * ThreadPriorityScheduler::chain = 0; ThreadPriorityScheduler * ThreadPriorityScheduler::chain = 0;
ThreadPriorityScheduler * ThreadPriorityScheduler::news = 0; ThreadPriorityScheduler * ThreadPriorityScheduler::news = 0;
BOOLEAN ThreadPriorityScheduler::initialized = FALSE; bool ThreadPriorityScheduler::initialized = false;
DWORD ThreadPriorityScheduler::specific_key = (DWORD) -1; DWORD ThreadPriorityScheduler::specific_key = (DWORD) -1;
BOOLEAN ThreadPriorityScheduler::shutdown = FALSE; bool ThreadPriorityScheduler::shutdown = false;
//____________________________________________________________ //____________________________________________________________
// //
@ -60,8 +60,8 @@ BOOLEAN ThreadPriorityScheduler::shutdown = FALSE;
void ThreadPriorityScheduler::Cleanup(void) { void ThreadPriorityScheduler::Cleanup(void) {
if (initialized) if (initialized)
{ {
initialized = FALSE; initialized = false;
shutdown = TRUE; shutdown = true;
} }
} }
@ -102,7 +102,7 @@ void ThreadPriorityScheduler::Init(void)
if (initialized) if (initialized)
return; return;
initialized = TRUE; initialized = true;
specific_key = TlsAlloc(); specific_key = TlsAlloc();
// memory pool for thps allocation // memory pool for thps allocation
@ -224,8 +224,8 @@ void ThreadPriorityScheduler::Exit(void) {
// //
// Check whether current thread has high priority // Check whether current thread has high priority
// //
BOOLEAN ThreadPriorityScheduler::Boosted(void) { bool ThreadPriorityScheduler::Boosted(void) {
return InternalGet()->flags & THPS_BOOSTED ? TRUE : FALSE; return InternalGet()->flags & THPS_BOOSTED ? true : false;
} }
//____________________________________________________________ //____________________________________________________________

View File

@ -39,7 +39,7 @@
*/ */
/* /*
$Id: lock.cpp,v 1.67 2003-09-01 07:51:50 brodsom Exp $ $Id: lock.cpp,v 1.68 2003-09-04 21:22:22 brodsom Exp $
*/ */
#include "firebird.h" #include "firebird.h"
@ -108,12 +108,12 @@ $Id: lock.cpp,v 1.67 2003-09-01 07:51:50 brodsom Exp $
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/file.h> #include <sys/file.h>
#define statistics stat #define statistics stat
static BOOLEAN LOCK_post_manager; static bool LOCK_post_manager;
#endif #endif
#ifdef DEV_BUILD #ifdef DEV_BUILD
#define ASSERT_ACQUIRED current_is_active_owner (TRUE, __LINE__) #define ASSERT_ACQUIRED current_is_active_owner (true, __LINE__)
#define ASSERT_RELEASED current_is_active_owner (FALSE, __LINE__) #define ASSERT_RELEASED current_is_active_owner (false, __LINE__)
#define VALIDATE_LOCK_TABLE #define VALIDATE_LOCK_TABLE
#if ((defined HAVE_MMAP) && !(defined SUPERSERVER)) #if ((defined HAVE_MMAP) && !(defined SUPERSERVER))
#define LOCK_DEBUG_ACQUIRE #define LOCK_DEBUG_ACQUIRE
@ -212,14 +212,14 @@ static void bug(ISC_STATUS *, const TEXT *);
#ifdef DEV_BUILD #ifdef DEV_BUILD
static void bug_assert(const TEXT *, ULONG); static void bug_assert(const TEXT *, ULONG);
#endif #endif
static BOOLEAN convert(PTR, UCHAR, SSHORT, lock_ast_t, void *, ISC_STATUS *); static bool convert(PTR, UCHAR, SSHORT, lock_ast_t, void *, ISC_STATUS *);
static USHORT create_owner(ISC_STATUS *, SLONG, UCHAR, SLONG *); static USHORT create_owner(ISC_STATUS *, SLONG, UCHAR, SLONG *);
#ifdef DEV_BUILD #ifdef DEV_BUILD
static void current_is_active_owner(BOOLEAN, ULONG); static void current_is_active_owner(bool, ULONG);
#endif #endif
static void deadlock_clear(void); static void deadlock_clear(void);
static LRQ deadlock_scan(OWN, LRQ); static LRQ deadlock_scan(OWN, LRQ);
static LRQ deadlock_walk(LRQ, BOOLEAN *); static LRQ deadlock_walk(LRQ, bool *);
static void dequeue(PTR); static void dequeue(PTR);
#ifdef DEBUG #ifdef DEBUG
static void debug_delay(ULONG); static void debug_delay(ULONG);
@ -227,8 +227,8 @@ static void debug_delay(ULONG);
static void exit_handler(void *); static void exit_handler(void *);
static LBL find_lock(PTR, USHORT, UCHAR *, USHORT, USHORT *); static LBL find_lock(PTR, USHORT, UCHAR *, USHORT, USHORT *);
#ifdef MANAGER_PROCESS #ifdef MANAGER_PROCESS
static USHORT fork_lock_manager(ISC_STATUS *); static bool fork_lock_manager(ISC_STATUS *);
static OWN get_manager(BOOLEAN); static OWN get_manager(bool);
#endif #endif
static LRQ get_request(PTR); static LRQ get_request(PTR);
static void grant(LRQ, LBL); static void grant(LRQ, LBL);
@ -243,12 +243,12 @@ static void insert_data_que(LBL);
static void insert_tail(SRQ, SRQ); static void insert_tail(SRQ, SRQ);
static USHORT lock_state(LBL); static USHORT lock_state(LBL);
//static void port_waker(PTR *); //static void port_waker(PTR *);
static void post_blockage(LRQ, LBL, BOOLEAN); static void post_blockage(LRQ, LBL, bool);
static void post_history(USHORT, PTR, PTR, PTR, BOOLEAN); static void post_history(USHORT, PTR, PTR, PTR, bool);
static void post_pending(LBL); static void post_pending(LBL);
static void post_wakeup(OWN); static void post_wakeup(OWN);
#ifndef SUPERSERVER #ifndef SUPERSERVER
static BOOLEAN probe_owners(PTR); static bool probe_owners(PTR);
#endif #endif
static void purge_owner(PTR, OWN); static void purge_owner(PTR, OWN);
static void remove_que(SRQ); static void remove_que(SRQ);
@ -300,7 +300,7 @@ static SLONG LOCK_hash_slots;
static SLONG LOCK_scan_interval; static SLONG LOCK_scan_interval;
static SLONG LOCK_acquire_spins; static SLONG LOCK_acquire_spins;
static SH_MEM_T LOCK_data; static SH_MEM_T LOCK_data;
static BOOLEAN start_manager = FALSE; static bool start_manager = false;
static TEXT LOCK_bug_buffer[128]; static TEXT LOCK_bug_buffer[128];
@ -410,12 +410,11 @@ int LOCK_convert(PTR request_offset,
else else
++LOCK_header->lhb_operations[0]; ++LOCK_header->lhb_operations[0];
return convert(request_offset, if (convert(request_offset, type, lck_wait, ast_routine, ast_argument,
type, status_vector))
lck_wait, return TRUE;
ast_routine, else
ast_argument, return FALSE;
status_vector);
} }
@ -604,7 +603,7 @@ SLONG LOCK_enq( PTR prior_request,
} }
owner = (OWN) ABS_PTR(owner_offset); /* Re-init after a potential remap */ owner = (OWN) ABS_PTR(owner_offset); /* Re-init after a potential remap */
post_history(his_enq, owner_offset, (PTR)0, REL_PTR(request), TRUE); post_history(his_enq, owner_offset, (PTR)0, REL_PTR(request), true);
request->lrq_type = type_lrq; request->lrq_type = type_lrq;
request->lrq_flags = 0; request->lrq_flags = 0;
@ -798,7 +797,7 @@ int LOCK_init(
if (!LOCK_header) { if (!LOCK_header) {
/* We haven't yet mapped the shared region. Do so now. */ /* We haven't yet mapped the shared region. Do so now. */
start_manager = FALSE; start_manager = false;
if (init_lock_table(status_vector) != FB_SUCCESS) { if (init_lock_table(status_vector) != FB_SUCCESS) {
return FB_FAILURE; return FB_FAILURE;
} }
@ -828,8 +827,7 @@ int LOCK_init(
#if !defined SUPERSERVER && defined WIN_NT #if !defined SUPERSERVER && defined WIN_NT
owner = (OWN) ABS_PTR(*owner_handle); owner = (OWN) ABS_PTR(*owner_handle);
wakeup_event[0] = owner->own_wakeup_hndl; wakeup_event[0] = owner->own_wakeup_hndl;
blocking_event[0] = blocking_event[0] = ISC_make_signal(TRUE, FALSE, LOCK_pid, LOCK_block_signal);
ISC_make_signal(TRUE, FALSE, LOCK_pid, LOCK_block_signal);
owner->own_blocking_hndl = blocking_event[0]; owner->own_blocking_hndl = blocking_event[0];
AST_ALLOC; AST_ALLOC;
if (gds__thread_start if (gds__thread_start
@ -881,7 +879,7 @@ int LOCK_init(
#ifdef MANAGER_PROCESS #ifdef MANAGER_PROCESS
if (start_manager) { if (start_manager) {
start_manager = FALSE; start_manager = false;
if (!fork_lock_manager(status_vector)) if (!fork_lock_manager(status_vector))
return FB_FAILURE; return FB_FAILURE;
} }
@ -934,7 +932,7 @@ void LOCK_manager( PTR manager_owner_offset)
/* If there already is a lock manager running, quietly return */ /* If there already is a lock manager running, quietly return */
while (owner = get_manager(FALSE)) while (owner = get_manager(false))
if (signal_owner(owner, (PTR) NULL)) if (signal_owner(owner, (PTR) NULL))
purge_owner(manager_owner_offset, owner); purge_owner(manager_owner_offset, owner);
else { else {
@ -1070,7 +1068,7 @@ SLONG LOCK_query_data(PTR parent_request, USHORT series, USHORT aggregate)
if (parent_request && series < LCK_MAX_SERIES) if (parent_request && series < LCK_MAX_SERIES)
parent = get_request(parent_request); parent = get_request(parent_request);
else { else {
CHECK(FALSE); CHECK(false);
return 0; return 0;
} }
@ -1139,7 +1137,7 @@ SLONG LOCK_query_data(PTR parent_request, USHORT series, USHORT aggregate)
break; break;
default: default:
CHECK(FALSE); CHECK(false);
} }
release(parent->lrq_owner); release(parent->lrq_owner);
@ -1301,7 +1299,7 @@ void LOCK_re_post( lock_ast_t ast, void *arg, PTR owner_offset)
} }
BOOLEAN LOCK_shut_manager(void) bool LOCK_shut_manager(void)
{ {
/************************************** /**************************************
* *
@ -1318,20 +1316,20 @@ BOOLEAN LOCK_shut_manager(void)
OWN manager; OWN manager;
acquire(DUMMY_OWNER_SHUTDOWN); acquire(DUMMY_OWNER_SHUTDOWN);
if (manager = get_manager(FALSE)) { if (manager = get_manager(false)) {
LOCK_header->lhb_flags |= LHB_shut_manager; LOCK_header->lhb_flags |= LHB_shut_manager;
post_wakeup(manager); post_wakeup(manager);
release_mutex(); release_mutex();
sleep(5); sleep(5);
acquire(DUMMY_OWNER_SHUTDOWN); acquire(DUMMY_OWNER_SHUTDOWN);
LOCK_header->lhb_flags &= ~LHB_shut_manager; LOCK_header->lhb_flags &= ~LHB_shut_manager;
manager = get_manager(FALSE); manager = get_manager(false);
} }
release_mutex(); release_mutex();
return (manager ? FALSE : TRUE); return (manager ? false : true);
#else #else
return TRUE; return true;
#endif #endif
} }
@ -1462,7 +1460,7 @@ static void acquire( PTR owner_offset)
LOCK_header->lhb_active_owner = owner_offset; LOCK_header->lhb_active_owner = owner_offset;
#ifdef MANAGER_PROCESS #ifdef MANAGER_PROCESS
LOCK_post_manager = FALSE; LOCK_post_manager = false;
#endif #endif
#ifndef SUPERSERVER #ifndef SUPERSERVER
@ -1510,7 +1508,7 @@ static void acquire( PTR owner_offset)
SHB recover; SHB recover;
SRQ que; SRQ que;
post_history(his_active, owner_offset, prior_active, (PTR) 0, FALSE); post_history(his_active, owner_offset, prior_active, (PTR) 0, false);
recover = (SHB) ABS_PTR(LOCK_header->lhb_secondary); recover = (SHB) ABS_PTR(LOCK_header->lhb_secondary);
if (recover->shb_remove_node) { if (recover->shb_remove_node) {
/* There was a remove_que operation in progress when the prior_owner died */ /* There was a remove_que operation in progress when the prior_owner died */
@ -1616,8 +1614,7 @@ static UCHAR *alloc( SSHORT size, ISC_STATUS * status_vector)
*/ */
#if (defined WIN_NT && defined SUPERSERVER) || (!defined SUPERSERVER && defined HAVE_MMAP) #if (defined WIN_NT && defined SUPERSERVER) || (!defined SUPERSERVER && defined HAVE_MMAP)
ULONG length = LOCK_data.sh_mem_length_mapped + EXTEND_SIZE; ULONG length = LOCK_data.sh_mem_length_mapped + EXTEND_SIZE;
LHB header = LHB header = (LHB) ISC_remap_file(status_vector, &LOCK_data, length, TRUE);
(LHB) ISC_remap_file(status_vector, &LOCK_data, length, TRUE);
if (header) { if (header) {
LOCK_header = header; LOCK_header = header;
#ifdef WIN_NT #ifdef WIN_NT
@ -1865,7 +1862,7 @@ static void blocking_action2(
* signaled" flag and start winding out of here * signaled" flag and start winding out of here
*/ */
owner->own_ast_flags &= ~OWN_signaled; owner->own_ast_flags &= ~OWN_signaled;
/*post_history (his_leave_ast, blocking_owner_offset, 0, 0, TRUE); */ /*post_history (his_leave_ast, blocking_owner_offset, 0, 0, true); */
break; break;
} }
request = (LRQ) ((UCHAR *) que - OFFSET(LRQ, lrq_own_blocks)); request = (LRQ) ((UCHAR *) que - OFFSET(LRQ, lrq_own_blocks));
@ -1877,7 +1874,7 @@ static void blocking_action2(
request->lrq_flags |= LRQ_blocking_seen; request->lrq_flags |= LRQ_blocking_seen;
++LOCK_header->lhb_blocks; ++LOCK_header->lhb_blocks;
post_history(his_post_ast, blocking_owner_offset, post_history(his_post_ast, blocking_owner_offset,
request->lrq_lock, REL_PTR(request), TRUE); request->lrq_lock, REL_PTR(request), true);
} }
else if (request->lrq_flags & LRQ_repost) { else if (request->lrq_flags & LRQ_repost) {
request->lrq_type = type_null; request->lrq_type = type_null;
@ -1914,7 +1911,7 @@ static void THREAD_ROUTINE blocking_action_thread( PTR * owner_offset_ptr)
AST_INIT; /* Check into scheduler as AST thread */ AST_INIT; /* Check into scheduler as AST thread */
while (TRUE) { while (true) {
ret = WaitForSingleObject(blocking_event[0], INFINITE); ret = WaitForSingleObject(blocking_event[0], INFINITE);
AST_ENTER; AST_ENTER;
owner = (OWN) ABS_PTR(*owner_offset_ptr); owner = (OWN) ABS_PTR(*owner_offset_ptr);
@ -1949,7 +1946,7 @@ static void THREAD_ROUTINE blocking_action_thread( PTR * owner_offset_ptr)
AST_INIT; /* Check into scheduler as AST thread */ AST_INIT; /* Check into scheduler as AST thread */
while (TRUE) { while (true) {
AST_ENTER; AST_ENTER;
/* See if main thread has requested us to go away */ /* See if main thread has requested us to go away */
@ -2086,7 +2083,7 @@ static void bug( ISC_STATUS * status_vector, const TEXT * string)
} }
static BOOLEAN convert(PTR request_offset, static bool convert(PTR request_offset,
UCHAR type, UCHAR type,
SSHORT lck_wait, SSHORT lck_wait,
lock_ast_t ast_routine, lock_ast_t ast_routine,
@ -2102,15 +2099,15 @@ static BOOLEAN convert(PTR request_offset,
* Functional description * Functional description
* Perform a lock conversion, if possible. If the lock cannot be * Perform a lock conversion, if possible. If the lock cannot be
* granted immediately, either return immediately or wait depending * granted immediately, either return immediately or wait depending
* on a wait flag. If the lock is granted return TRUE, otherwise * on a wait flag. If the lock is granted return true, otherwise
* return FALSE. Note: if the conversion would cause a deadlock, * return false. Note: if the conversion would cause a deadlock,
* FALSE is returned even if wait was requested. * FALSE is returned even if wait was requested.
* *
**************************************/ **************************************/
LBL lock; LBL lock;
LRQ request; LRQ request;
UCHAR temp; UCHAR temp;
BOOLEAN new_ast; bool new_ast;
PTR owner_offset; PTR owner_offset;
ASSERT_ACQUIRED; ASSERT_ACQUIRED;
@ -2118,7 +2115,7 @@ static BOOLEAN convert(PTR request_offset,
lock = (LBL) ABS_PTR(request->lrq_lock); lock = (LBL) ABS_PTR(request->lrq_lock);
owner_offset = request->lrq_owner; owner_offset = request->lrq_owner;
post_history(his_convert, owner_offset, request->lrq_lock, request_offset, post_history(his_convert, owner_offset, request->lrq_lock, request_offset,
TRUE); true);
request->lrq_requested = type; request->lrq_requested = type;
request->lrq_flags &= ~LRQ_blocking_seen; request->lrq_flags &= ~LRQ_blocking_seen;
@ -2137,7 +2134,7 @@ static BOOLEAN convert(PTR request_offset,
grant(request, lock); grant(request, lock);
post_pending(lock); post_pending(lock);
release(owner_offset); release(owner_offset);
return TRUE; return true;
} }
++lock->lbl_counts[request->lrq_state]; ++lock->lbl_counts[request->lrq_state];
@ -2148,13 +2145,13 @@ static BOOLEAN convert(PTR request_offset,
if (lck_wait) { if (lck_wait) {
if (request->lrq_ast_routine != ast_routine || if (request->lrq_ast_routine != ast_routine ||
request->lrq_ast_argument != ast_argument) request->lrq_ast_argument != ast_argument)
new_ast = TRUE; new_ast = true;
else else
new_ast = FALSE; new_ast = false;
if (wait_for_request(request, lck_wait, status_vector)) { if (wait_for_request(request, lck_wait, status_vector)) {
ASSERT_RELEASED; ASSERT_RELEASED;
return FALSE; return false;
} }
request = (LRQ) ABS_PTR(request_offset); request = (LRQ) ABS_PTR(request_offset);
if (!(request->lrq_flags & LRQ_rejected)) { if (!(request->lrq_flags & LRQ_rejected)) {
@ -2166,7 +2163,7 @@ static BOOLEAN convert(PTR request_offset,
release(owner_offset); release(owner_offset);
} }
ASSERT_RELEASED; ASSERT_RELEASED;
return TRUE; return true;
} }
acquire(owner_offset); acquire(owner_offset);
request = get_request(request_offset); request = get_request(request_offset);
@ -2186,7 +2183,7 @@ static BOOLEAN convert(PTR request_offset,
((lck_wait < 0) ? gds_lock_timeout : gds_lock_conflict); ((lck_wait < 0) ? gds_lock_timeout : gds_lock_conflict);
*status_vector++ = gds_arg_end; *status_vector++ = gds_arg_end;
return FALSE; return false;
} }
@ -2277,7 +2274,7 @@ static USHORT create_owner(ISC_STATUS* status_vector,
#ifdef DEV_BUILD #ifdef DEV_BUILD
static void current_is_active_owner( BOOLEAN expect_acquired, ULONG line) static void current_is_active_owner(bool expect_acquired, ULONG line)
{ {
/************************************** /**************************************
* *
@ -2300,7 +2297,7 @@ static void current_is_active_owner( BOOLEAN expect_acquired, ULONG line)
return; return;
/* Use a local copy of lhb_active_owner. We're viewing the lock table /* Use a local copy of lhb_active_owner. We're viewing the lock table
without being acquired in the "expect_acquired FALSE" case, so it without being acquired in the "expect_acquired false" case, so it
can change out from under us. We don't care that it changes, but can change out from under us. We don't care that it changes, but
if it gets set to DUMMY_OWNER_SHUTDOWN, DUMMY_OWNER_CREATE or if it gets set to DUMMY_OWNER_SHUTDOWN, DUMMY_OWNER_CREATE or
DUMMY_OWNER_DELETE it can lead to a core drop when we try to map DUMMY_OWNER_DELETE it can lead to a core drop when we try to map
@ -2394,7 +2391,8 @@ static void deadlock_clear(void)
} }
static LRQ deadlock_scan( OWN owner, LRQ request) static LRQ deadlock_scan(OWN owner,
LRQ request)
{ {
/************************************** /**************************************
* *
@ -2410,7 +2408,7 @@ static LRQ deadlock_scan( OWN owner, LRQ request)
* *
**************************************/ **************************************/
LRQ victim; LRQ victim;
BOOLEAN maybe_deadlock = FALSE; bool maybe_deadlock = false;
LOCK_TRACE( LOCK_TRACE(
("deadlock_scan: owner %ld request %ld\n", REL_PTR(owner), ("deadlock_scan: owner %ld request %ld\n", REL_PTR(owner),
@ -2419,7 +2417,7 @@ static LRQ deadlock_scan( OWN owner, LRQ request)
ASSERT_ACQUIRED; ASSERT_ACQUIRED;
++LOCK_header->lhb_scans; ++LOCK_header->lhb_scans;
post_history(his_scan, request->lrq_owner, request->lrq_lock, post_history(his_scan, request->lrq_owner, request->lrq_lock,
REL_PTR(request), TRUE); REL_PTR(request), true);
deadlock_clear(); deadlock_clear();
#ifdef VALIDATE_LOCK_TABLE #ifdef VALIDATE_LOCK_TABLE
@ -2443,7 +2441,8 @@ static LRQ deadlock_scan( OWN owner, LRQ request)
} }
static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock) static LRQ deadlock_walk(LRQ request,
bool * maybe_deadlock)
{ {
/************************************** /**************************************
* *
@ -2461,7 +2460,7 @@ static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock)
LBL lock; LBL lock;
OWN owner; OWN owner;
PTR pending_offset; PTR pending_offset;
BOOLEAN conversion; bool conversion;
/* If this request was scanned for deadlock earlier than don't /* If this request was scanned for deadlock earlier than don't
visit it again. */ visit it again. */
@ -2481,7 +2480,7 @@ static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock)
/* Check if this is a conversion request. */ /* Check if this is a conversion request. */
conversion = (request->lrq_state > LCK_null) ? TRUE : FALSE; conversion = (request->lrq_state > LCK_null) ? true : false;
/* Find the parent lock of the request */ /* Find the parent lock of the request */
@ -2538,7 +2537,7 @@ static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock)
if (owner->own_ast_flags & OWN_signaled || if (owner->own_ast_flags & OWN_signaled ||
!QUE_EMPTY((owner->own_blocks))) { !QUE_EMPTY((owner->own_blocks))) {
*maybe_deadlock = TRUE; *maybe_deadlock = true;
continue; continue;
} }
@ -2597,7 +2596,7 @@ static void dequeue( PTR request_offset)
request = get_request(request_offset); request = get_request(request_offset);
post_history(his_deq, request->lrq_owner, request->lrq_lock, post_history(his_deq, request->lrq_owner, request->lrq_lock,
request_offset, TRUE); request_offset, true);
request->lrq_ast_routine = NULL; request->lrq_ast_routine = NULL;
release_request(request); release_request(request);
} }
@ -2785,7 +2784,7 @@ static LBL find_lock(
#ifdef MANAGER_PROCESS #ifdef MANAGER_PROCESS
static USHORT fork_lock_manager( ISC_STATUS * status_vector) static bool fork_lock_manager( ISC_STATUS * status_vector)
{ {
/************************************** /**************************************
* *
@ -2812,7 +2811,7 @@ static USHORT fork_lock_manager( ISC_STATUS * status_vector)
if (statistics(string, &stat_buf) == -1) { if (statistics(string, &stat_buf) == -1) {
sprintf (errorstring, "can't start lock manager: %s", string); sprintf (errorstring, "can't start lock manager: %s", string);
bug(status_vector, errorstring); bug(status_vector, errorstring);
return FALSE; return false;
} }
if (!(pid = vfork())) { if (!(pid = vfork())) {
@ -2825,19 +2824,19 @@ static USHORT fork_lock_manager( ISC_STATUS * status_vector)
if (pid == -1) { if (pid == -1) {
bug(status_vector, "can't start lock manager"); bug(status_vector, "can't start lock manager");
return FALSE; return false;
} }
while (waitpid(pid, NULL, 0) == -1 && SYSCALL_INTERRUPTED(errno)) while (waitpid(pid, NULL, 0) == -1 && SYSCALL_INTERRUPTED(errno))
/* do nothing */ ; /* do nothing */ ;
return TRUE; return true;
} }
#endif #endif
#ifdef MANAGER_PROCESS #ifdef MANAGER_PROCESS
static OWN get_manager( BOOLEAN flag) static OWN get_manager(bool flag)
{ {
/************************************** /**************************************
* *
@ -2934,7 +2933,7 @@ static void grant( LRQ request, LBL lock)
CHECK(REL_PTR(lock) == request->lrq_lock); CHECK(REL_PTR(lock) == request->lrq_lock);
post_history(his_grant, request->lrq_owner, request->lrq_lock, post_history(his_grant, request->lrq_owner, request->lrq_lock,
REL_PTR(request), TRUE); REL_PTR(request), true);
++lock->lbl_counts[request->lrq_requested]; ++lock->lbl_counts[request->lrq_requested];
request->lrq_state = request->lrq_requested; request->lrq_state = request->lrq_requested;
@ -3015,7 +3014,7 @@ static PTR grant_or_que( LRQ request, LBL lock, SSHORT lck_wait)
request = (LRQ) ABS_PTR(request_offset); request = (LRQ) ABS_PTR(request_offset);
post_history(his_deny, request->lrq_owner, request->lrq_lock, post_history(his_deny, request->lrq_owner, request->lrq_lock,
REL_PTR(request), TRUE); REL_PTR(request), true);
ASSERT_ACQUIRED; ASSERT_ACQUIRED;
++LOCK_header->lhb_denies; ++LOCK_header->lhb_denies;
if (lck_wait < 0) if (lck_wait < 0)
@ -3101,8 +3100,7 @@ static ISC_STATUS init_lock_table( ISC_STATUS * status_vector)
/* Now get the globally consistent value of LOCK_ordering from the /* Now get the globally consistent value of LOCK_ordering from the
shared lock table. */ shared lock table. */
LOCK_ordering = LOCK_ordering = (LOCK_header->lhb_flags & LHB_lock_ordering) ? TRUE : FALSE;
(LOCK_header->lhb_flags & LHB_lock_ordering) ? TRUE : FALSE;
gds__register_cleanup(exit_handler, 0); gds__register_cleanup(exit_handler, 0);
@ -3158,16 +3156,15 @@ static void init_owner_block(
#if defined(WIN_NT) && !defined(SUPERSERVER) #if defined(WIN_NT) && !defined(SUPERSERVER)
// Skidder: This Win32 EVENT is deleted when our process is closing // Skidder: This Win32 EVENT is deleted when our process is closing
if (new_block != OWN_BLOCK_dummy) if (new_block != OWN_BLOCK_dummy)
owner->own_wakeup_hndl = owner->own_wakeup_hndl = ISC_make_signal(TRUE, TRUE, LOCK_pid,
ISC_make_signal(TRUE, TRUE, LOCK_pid, LOCK_wakeup_signal); LOCK_wakeup_signal);
#endif #endif
if (new_block == OWN_BLOCK_new) if (new_block == OWN_BLOCK_new)
{ {
#if defined WIN_NT && defined SUPERSERVER #if defined WIN_NT && defined SUPERSERVER
// TMN: This Win32 EVENT is never deleted! // TMN: This Win32 EVENT is never deleted!
// Skidder: But it may be reused along with the owner block // Skidder: But it may be reused along with the owner block
owner->own_wakeup_hndl = owner->own_wakeup_hndl = ISC_make_signal(TRUE, TRUE, LOCK_pid, 0);
ISC_make_signal(TRUE, TRUE, LOCK_pid, 0);
#endif #endif
#ifdef USE_WAKEUP_EVENTS #ifdef USE_WAKEUP_EVENTS
#if (defined WIN_NT && defined SUPERSERVER) #if (defined WIN_NT && defined SUPERSERVER)
@ -3259,7 +3256,7 @@ static void lock_initialize( void *arg, SH_MEM shmem_data, int initialize)
return; return;
} }
start_manager = TRUE; start_manager = true;
memset(LOCK_header, 0, sizeof(struct lhb)); memset(LOCK_header, 0, sizeof(struct lhb));
LOCK_header->lhb_type = type_lhb; LOCK_header->lhb_type = type_lhb;
@ -3495,7 +3492,9 @@ static USHORT lock_state( LBL lock)
} }
static void post_blockage( LRQ request, LBL lock, BOOLEAN force) static void post_blockage(LRQ request,
LBL lock,
bool force)
{ {
/************************************** /**************************************
* *
@ -3566,10 +3565,11 @@ static void post_blockage( LRQ request, LBL lock, BOOLEAN force)
} }
static void post_history( static void post_history(USHORT operation,
USHORT operation,
PTR process, PTR process,
PTR lock, PTR request, BOOLEAN old_version) PTR lock,
PTR request,
bool old_version)
{ {
/************************************** /**************************************
* *
@ -3736,7 +3736,7 @@ static void post_wakeup( OWN owner)
#ifndef SUPERSERVER #ifndef SUPERSERVER
static BOOLEAN probe_owners( PTR probing_owner_offset) static bool probe_owners( PTR probing_owner_offset)
{ {
/************************************** /**************************************
* *
@ -3751,9 +3751,9 @@ static BOOLEAN probe_owners( PTR probing_owner_offset)
**************************************/ **************************************/
SRQ que; SRQ que;
OWN owner; OWN owner;
BOOLEAN purged; bool purged;
purged = FALSE; purged = false;
ASSERT_ACQUIRED; ASSERT_ACQUIRED;
QUE_LOOP(LOCK_header->lhb_owners, que) { QUE_LOOP(LOCK_header->lhb_owners, que) {
@ -3765,7 +3765,7 @@ static BOOLEAN probe_owners( PTR probing_owner_offset)
owner->own_process_uid, FALSE)) { owner->own_process_uid, FALSE)) {
que = (SRQ) ABS_PTR(que->srq_backward); que = (SRQ) ABS_PTR(que->srq_backward);
purge_owner(probing_owner_offset, owner); purge_owner(probing_owner_offset, owner);
purged = TRUE; purged = true;
} }
} }
@ -3792,7 +3792,7 @@ static void purge_owner(PTR purging_owner_offset, OWN owner)
LOCK_TRACE(("purge_owner (%ld)\n", purging_owner_offset)); LOCK_TRACE(("purge_owner (%ld)\n", purging_owner_offset));
post_history(his_del_owner, purging_owner_offset, REL_PTR(owner), 0, post_history(his_del_owner, purging_owner_offset, REL_PTR(owner), 0,
FALSE); false);
#ifdef USE_STATIC_SEMAPHORES #ifdef USE_STATIC_SEMAPHORES
release_semaphore(owner); release_semaphore(owner);
@ -3935,7 +3935,7 @@ static void release( PTR owner_offset)
bug(NULL, "release when not owner"); bug(NULL, "release when not owner");
#ifdef MANAGER_PROCESS #ifdef MANAGER_PROCESS
if (LOCK_post_manager && (owner = get_manager(TRUE))) if (LOCK_post_manager && (owner = get_manager(true)))
post_wakeup(owner); post_wakeup(owner);
#endif #endif
@ -4212,7 +4212,7 @@ static int signal_owner( OWN blocking_owner, PTR blocked_owner_offset)
* *
**************************************/ **************************************/
/*post_history (his_signal, LOCK_header->lhb_iactive_owner, REL_PTR (blocking_owner), 0, TRUE);*/ /*post_history (his_signal, LOCK_header->lhb_iactive_owner, REL_PTR (blocking_owner), 0, true);*/
ASSERT_ACQUIRED; ASSERT_ACQUIRED;
@ -4298,7 +4298,7 @@ static int signal_owner( OWN blocking_owner, PTR blocked_owner_offset)
process for delivery. */ process for delivery. */
if (!(LOCK_process_owner.own_flags & OWN_manager)) { if (!(LOCK_process_owner.own_flags & OWN_manager)) {
LOCK_post_manager = TRUE; LOCK_post_manager = true;
return FB_SUCCESS; return FB_SUCCESS;
} }
#endif #endif
@ -4334,7 +4334,7 @@ static void validate_history( PTR history_header)
LOCK_TRACE(("validate_history: %ld\n", history_header)); LOCK_TRACE(("validate_history: %ld\n", history_header));
for (history = (HIS) ABS_PTR(history_header); TRUE; for (history = (HIS) ABS_PTR(history_header); true;
history = (HIS) ABS_PTR(history->his_next)) { history = (HIS) ABS_PTR(history->his_next)) {
count++; count++;
CHECK(history->his_type == type_his); CHECK(history->his_type == type_his);
@ -4710,7 +4710,7 @@ static void validate_owner( PTR own_ptr, USHORT freed)
* exists in the queue for the lock. * exists in the queue for the lock.
*/ */
if (owner_own_pending_request && (freed == EXPECT_inuse)) { if (owner_own_pending_request && (freed == EXPECT_inuse)) {
BOOLEAN found_pending; bool found_pending;
LRQ request; LRQ request;
LBL lock; LBL lock;
LRQ pending; LRQ pending;
@ -4727,13 +4727,13 @@ static void validate_owner( PTR own_ptr, USHORT freed)
/* Make sure the pending request is on the list of requests for the lock */ /* Make sure the pending request is on the list of requests for the lock */
found_pending = FALSE; found_pending = false;
QUE_LOOP(lock->lbl_requests, que_of_lbl_requests) { QUE_LOOP(lock->lbl_requests, que_of_lbl_requests) {
pending = pending =
(LRQ) ((UCHAR *) que_of_lbl_requests - (LRQ) ((UCHAR *) que_of_lbl_requests -
OFFSET(LRQ, lrq_lbl_requests)); OFFSET(LRQ, lrq_lbl_requests));
if (REL_PTR(pending) == owner_own_pending_request) { if (REL_PTR(pending) == owner_own_pending_request) {
found_pending = TRUE; found_pending = true;
break; break;
} }
} }
@ -4947,8 +4947,8 @@ static USHORT wait_for_request(
/* Post blockage. If the blocking owner has disappeared, the blockage /* Post blockage. If the blocking owner has disappeared, the blockage
may clear spontaneously. */ may clear spontaneously. */
post_blockage(request, lock, FALSE); post_blockage(request, lock, false);
post_history(his_wait, owner_offset, lock_offset, REL_PTR(request), TRUE); post_history(his_wait, owner_offset, lock_offset, REL_PTR(request), true);
release(owner_offset); release(owner_offset);
current_time = GET_TIME; current_time = GET_TIME;
@ -4962,7 +4962,7 @@ static USHORT wait_for_request(
/* Wait in a loop until the lock becomes available */ /* Wait in a loop until the lock becomes available */
while (TRUE) { while (true) {
/* NOTE: Many operations in this loop are done without having /* NOTE: Many operations in this loop are done without having
* the lock table acquired - for performance reasons * the lock table acquired - for performance reasons
*/ */
@ -5176,7 +5176,7 @@ static USHORT wait_for_request(
This could happen if the lock was granted to a different request, This could happen if the lock was granted to a different request,
we have to tell the new owner of the lock that they are blocking us. */ we have to tell the new owner of the lock that they are blocking us. */
post_blockage(request, lock, FALSE); post_blockage(request, lock, false);
release(owner_offset); release(owner_offset);
continue; continue;
} }
@ -5237,7 +5237,7 @@ static USHORT wait_for_request(
We need to inform the new owner. */ We need to inform the new owner. */
DEBUG_MSG(0, ("wait_for_request: forcing a resignal of blockers\n")); DEBUG_MSG(0, ("wait_for_request: forcing a resignal of blockers\n"));
post_blockage(request, lock, FALSE); post_blockage(request, lock, false);
#ifdef DEV_BUILD #ifdef DEV_BUILD
repost_counter++; repost_counter++;
if (repost_counter % 50 == 0) { if (repost_counter % 50 == 0) {

View File

@ -38,7 +38,7 @@ SLONG LOCK_query_data(SLONG, USHORT, USHORT);
SLONG LOCK_read_data(SLONG); SLONG LOCK_read_data(SLONG);
SLONG LOCK_read_data2(SLONG, USHORT, UCHAR *, USHORT, SLONG); SLONG LOCK_read_data2(SLONG, USHORT, UCHAR *, USHORT, SLONG);
void LOCK_re_post(int (*)(void *), void *, SLONG); void LOCK_re_post(int (*)(void *), void *, SLONG);
BOOLEAN LOCK_shut_manager(void); bool LOCK_shut_manager(void);
SLONG LOCK_write_data(SLONG, SLONG); SLONG LOCK_write_data(SLONG, SLONG);
#endif /* _LOCK_LOCK_PROTO_H_ */ #endif /* _LOCK_LOCK_PROTO_H_ */

View File

@ -80,7 +80,7 @@ static void prt_lock_activity(OUTFILE, LHB, USHORT, USHORT, USHORT);
static void prt_lock_init(void); static void prt_lock_init(void);
static void prt_history(OUTFILE, LHB, PTR, SCHAR *); static void prt_history(OUTFILE, LHB, PTR, SCHAR *);
static void prt_lock(OUTFILE, LHB, LBL, USHORT); static void prt_lock(OUTFILE, LHB, LBL, USHORT);
static void prt_owner(OUTFILE, LHB, OWN, BOOLEAN, BOOLEAN); static void prt_owner(OUTFILE, LHB, OWN, bool, bool);
static void prt_owner_wait_cycle(OUTFILE, LHB, OWN, USHORT, struct waitque *); static void prt_owner_wait_cycle(OUTFILE, LHB, OWN, USHORT, struct waitque *);
static void prt_request(OUTFILE, LHB, LRQ); static void prt_request(OUTFILE, LHB, LRQ);
static void prt_que(OUTFILE, LHB, SCHAR *, SRQ, USHORT); static void prt_que(OUTFILE, LHB, SCHAR *, SRQ, USHORT);
@ -123,11 +123,15 @@ void CLIB_ROUTINE main( int argc, char *argv[])
* to ib_stdout. * to ib_stdout.
* *
**************************************/ **************************************/
BOOLEAN sw_requests, sw_owners, sw_locks, sw_history, sw_nobridge; bool sw_requests;
bool sw_owners;
bool sw_locks;
bool sw_history;
bool sw_nobridge;
USHORT sw_series, sw_interactive, sw_intervals, sw_seconds; USHORT sw_series, sw_interactive, sw_intervals, sw_seconds;
BOOLEAN sw_consistency; bool sw_consistency;
BOOLEAN sw_waitlist; bool sw_waitlist;
BOOLEAN sw_file; bool sw_file;
LHB LOCK_header, header = NULL; LHB LOCK_header, header = NULL;
SLONG LOCK_size_mapped = DEFAULT_SIZE; SLONG LOCK_size_mapped = DEFAULT_SIZE;
int orig_argc; int orig_argc;
@ -188,11 +192,11 @@ void CLIB_ROUTINE main( int argc, char *argv[])
/* Handle switches, etc. */ /* Handle switches, etc. */
argv++; argv++;
sw_consistency = FALSE; sw_consistency = false;
sw_waitlist = FALSE; sw_waitlist = false;
sw_file = FALSE; sw_file = false;
sw_requests = sw_locks = sw_history = sw_nobridge = FALSE; sw_requests = sw_locks = sw_history = sw_nobridge = false;
sw_owners = TRUE; sw_owners = true;
sw_series = sw_interactive = sw_intervals = sw_seconds = 0; sw_series = sw_interactive = sw_intervals = sw_seconds = 0;
while (--argc) { while (--argc) {
@ -206,31 +210,31 @@ void CLIB_ROUTINE main( int argc, char *argv[])
switch (c) { switch (c) {
case 'o': case 'o':
case 'p': case 'p':
sw_owners = TRUE; sw_owners = true;
break; break;
case 'c': case 'c':
sw_nobridge = TRUE; sw_nobridge = true;
sw_consistency = TRUE; sw_consistency = true;
break; break;
case 'l': case 'l':
sw_locks = TRUE; sw_locks = true;
break; break;
case 'r': case 'r':
sw_requests = TRUE; sw_requests = true;
break; break;
case 'a': case 'a':
sw_locks = TRUE; sw_locks = true;
sw_owners = TRUE; sw_owners = true;
sw_requests = TRUE; sw_requests = true;
sw_history = TRUE; sw_history = true;
break; break;
case 'h': case 'h':
sw_history = TRUE; sw_history = true;
break; break;
case 's': case 's':
@ -245,7 +249,7 @@ void CLIB_ROUTINE main( int argc, char *argv[])
break; break;
case 'n': case 'n':
sw_nobridge = TRUE; sw_nobridge = true;
break; break;
case 'i': case 'i':
@ -277,7 +281,7 @@ void CLIB_ROUTINE main( int argc, char *argv[])
sw_interactive = sw_interactive =
(SW_I_ACQUIRE | SW_I_OPERATION | SW_I_TYPE | (SW_I_ACQUIRE | SW_I_OPERATION | SW_I_TYPE |
SW_I_WAIT); SW_I_WAIT);
sw_nobridge = TRUE; sw_nobridge = true;
sw_seconds = sw_intervals = 1; sw_seconds = sw_intervals = 1;
if (argc > 1) { if (argc > 1) {
sw_seconds = atoi(*argv++); sw_seconds = atoi(*argv++);
@ -296,13 +300,13 @@ void CLIB_ROUTINE main( int argc, char *argv[])
break; break;
case 'w': case 'w':
sw_nobridge = TRUE; sw_nobridge = true;
sw_waitlist = TRUE; sw_waitlist = true;
break; break;
case 'f': case 'f':
sw_nobridge = TRUE; sw_nobridge = true;
sw_file = TRUE; sw_file = true;
if (argc > 1) { if (argc > 1) {
lock_file = *argv++; lock_file = *argv++;
--argc; --argc;
@ -358,8 +362,8 @@ void CLIB_ROUTINE main( int argc, char *argv[])
&& LOCK_header->lhb_length > shmem_data.sh_mem_length_mapped) { && LOCK_header->lhb_length > shmem_data.sh_mem_length_mapped) {
length = LOCK_header->lhb_length; length = LOCK_header->lhb_length;
#if (!(defined UNIX) || (defined HAVE_MMAP)) #if (!(defined UNIX) || (defined HAVE_MMAP))
LOCK_header = LOCK_header = (LHB) ISC_remap_file(status_vector, &shmem_data, length,
(LHB) ISC_remap_file(status_vector, &shmem_data, length, FALSE); FALSE);
#endif #endif
} }
@ -832,7 +836,7 @@ static void prt_history(
FPRINTF(outfile, "%s:\n", title); FPRINTF(outfile, "%s:\n", title);
for (history = (HIS) ABS_PTR(history_header); TRUE; for (history = (HIS) ABS_PTR(history_header); true;
history = (HIS) ABS_PTR(history->his_next)) { history = (HIS) ABS_PTR(history->his_next)) {
if (history->his_operation) if (history->his_operation)
FPRINTF(outfile, FPRINTF(outfile,
@ -920,10 +924,11 @@ static void prt_lock(
} }
static void prt_owner( static void prt_owner(OUTFILE outfile,
OUTFILE outfile,
LHB LOCK_header, LHB LOCK_header,
OWN owner, BOOLEAN sw_requests, BOOLEAN sw_waitlist) OWN owner,
bool sw_requests,
bool sw_waitlist)
{ {
/************************************** /**************************************
* *
@ -1043,7 +1048,7 @@ static void prt_owner_wait_cycle(
LRQ owner_request; LRQ owner_request;
LBL lock; LBL lock;
USHORT counter; USHORT counter;
BOOLEAN owner_conversion; bool owner_conversion;
if (waiters->waitque_depth > FB_NELEM(waiters->waitque_entry)) { if (waiters->waitque_depth > FB_NELEM(waiters->waitque_entry)) {
FPRINTF(outfile, "Dependency too deep\n"); FPRINTF(outfile, "Dependency too deep\n");
@ -1055,8 +1060,7 @@ static void prt_owner_wait_cycle(
FPRINTF(outfile, "\n"); FPRINTF(outfile, "\n");
owner_request = (LRQ) ABS_PTR(owner->own_pending_request); owner_request = (LRQ) ABS_PTR(owner->own_pending_request);
assert(owner_request->lrq_type == type_lrq); assert(owner_request->lrq_type == type_lrq);
owner_conversion = owner_conversion = (owner_request->lrq_state > LCK_null) ? true : false;
(owner_request->lrq_state > LCK_null) ? TRUE : FALSE;
lock = (LBL) ABS_PTR(owner_request->lrq_lock); lock = (LBL) ABS_PTR(owner_request->lrq_lock);
assert(lock->lbl_type == type_lbl); assert(lock->lbl_type == type_lbl);
@ -1079,8 +1083,7 @@ static void prt_owner_wait_cycle(
assert(lock_request->lrq_type == type_lrq); assert(lock_request->lrq_type == type_lrq);
if (LOCK_header->lhb_flags & LHB_lock_ordering if (LOCK_header->lhb_flags & LHB_lock_ordering && !owner_conversion) {
&& !owner_conversion) {
/* Requests AFTER our request can't block us */ /* Requests AFTER our request can't block us */
if (owner_request == lock_request) if (owner_request == lock_request)