Remove useless LIKELY() and UNLIKELY() macros. Add a class flag for bytecode strictly older than 3.18.
[COMPILER] * NEW: Remove useless LIKELY() and UNLIKELY() macros. [INTERPRETER] * NEW: Remove useless LIKELY() and UNLIKELY() macros. * NEW: Add a class flag for bytecode strictly older than 3.18. [GB.DEBUG] * BUG: Fix incorrect 'printf' format on 32-bits architectures.
This commit is contained in:
parent
415de7b257
commit
0ec57295b7
16 changed files with 93 additions and 96 deletions
|
@ -72,7 +72,7 @@ static char *_const_buffer = NULL;
|
|||
|
||||
static const char *get_symbol_name(TABLE *table, int index, int *len)
|
||||
{
|
||||
if (UNLIKELY((index < 0) || (index >= ARRAY_count(table->symbol))))
|
||||
if (index < 0 || index >= ARRAY_count(table->symbol))
|
||||
{
|
||||
*len = 1;
|
||||
return "?";
|
||||
|
|
|
@ -412,7 +412,7 @@ static inline void add_pattern(int type, int index)
|
|||
|
||||
static PATTERN get_last_last_pattern()
|
||||
{
|
||||
if (LIKELY(comp->pattern_count > 1))
|
||||
if (comp->pattern_count > 1)
|
||||
return comp->pattern[comp->pattern_count - 2];
|
||||
else
|
||||
return NULL_PATTERN;
|
||||
|
|
|
@ -601,7 +601,7 @@ END_PROPERTY
|
|||
|
||||
static bool copy_remove(CARRAY *_object, int start, int length, bool copy, bool remove)
|
||||
{
|
||||
CARRAY *array;
|
||||
CARRAY *array = NULL;
|
||||
int count = THIS->count;
|
||||
void *data;
|
||||
int i, nsize;
|
||||
|
@ -1537,7 +1537,7 @@ BEGIN_METHOD(Array_String_join, GB_STRING sep; GB_STRING esc)
|
|||
uint lsep = 1;
|
||||
char *esc = "";
|
||||
uint lesc = 0;
|
||||
char escl, NO_WARNING(escr);
|
||||
char escl, escr;
|
||||
int i;
|
||||
char **data = (char **)THIS->data;
|
||||
char *p, *p2;
|
||||
|
|
|
@ -268,7 +268,7 @@ typedef
|
|||
unsigned loaded : 1; // Class is loaded
|
||||
unsigned ready : 1; // Class is loaded and ready
|
||||
unsigned debug : 1; // Debugging information ?
|
||||
unsigned _reserved : 1; //
|
||||
unsigned swap : 1; // Class endianness was swapped
|
||||
unsigned free_event : 1; // Must free class->event
|
||||
unsigned in_load : 1; // Class being loaded
|
||||
unsigned exit : 1; // Marker used by CLASS_exit
|
||||
|
@ -277,28 +277,28 @@ typedef
|
|||
unsigned quick_array : 2; // Array accessor optimization type
|
||||
unsigned no_create : 1; // Cannot instanciate this class
|
||||
unsigned is_virtual : 1; // Virtual class (name beginning with a dot)
|
||||
unsigned swap : 1; // Class endianness was swapped
|
||||
unsigned enum_static : 1; // If class enumeration is static
|
||||
unsigned is_stream : 1; // If the class inherits stream
|
||||
unsigned global : 1; // If the class is in the global table
|
||||
unsigned error : 1; // Loading or registering the class has failed
|
||||
|
||||
unsigned is_native : 1; // If the class is native (i.e. written in C/C++)
|
||||
unsigned error : 1; // Loading or registering the class has failed
|
||||
unsigned is_observer : 1; // This is the Observer class
|
||||
unsigned is_struct : 1; // This class is a structure
|
||||
unsigned is_array : 1; // This class is an array
|
||||
unsigned is_array_of_struct : 1; // This class is an array of struct
|
||||
unsigned init_dynamic : 1; // If there is a special function to call at instanciation
|
||||
unsigned must_check : 1; // The class has a check function
|
||||
|
||||
unsigned has_child : 1; // The class has an inherited child class
|
||||
|
||||
unsigned unknown_static : 1; // If _unknown is static
|
||||
unsigned property_static : 1; // If _property is static
|
||||
unsigned has_convert : 1; // If the _convert interface is implemented
|
||||
unsigned has_operators : 1; // If the _operators interface is implemented
|
||||
unsigned is_simple : 1; // Class has no parent, no child, is not virtual, and has no 'check' function.
|
||||
unsigned has_free : 1; // The class has a free function
|
||||
unsigned is_test : 1; // 24 36 The class is a test module
|
||||
unsigned is_test : 1; // The class is a test module
|
||||
unsigned not_3_18 : 1; // 24 36 If bytecode version is strictly older than 3.18
|
||||
|
||||
short n_desc; // 26 38 number of descriptions
|
||||
short n_event; // 28 40 number of events
|
||||
|
|
|
@ -172,6 +172,8 @@ static void check_version(CLASS *class, int loaded)
|
|||
THROW_CLASS(class, "Bytecode too recent. Please upgrade Gambas.", "");
|
||||
if (loaded < GAMBAS_PCODE_VERSION_MIN)
|
||||
THROW_CLASS(class, "Bytecode too old. Please recompile the project.", "");
|
||||
|
||||
class->not_3_18 = loaded < 0x3180000;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -504,7 +504,7 @@ void DEBUG_print_backtrace(STACK_BACKTRACE *bt)
|
|||
{
|
||||
int i, n;
|
||||
bool stop;
|
||||
STACK_BACKTRACE *NO_WARNING(end);
|
||||
STACK_BACKTRACE *end;
|
||||
//STACK_CONTEXT *sc = (STACK_CONTEXT *)(STACK_base + STACK_size) - err->bt_count;
|
||||
|
||||
//fprintf(stderr, "0: %s\n", DEBUG_get_position(err->cp, err->fp, err->pc));
|
||||
|
|
|
@ -149,7 +149,7 @@ void EXEC_unborrow(VALUE *value)
|
|||
|
||||
TYPE type = value->type;
|
||||
|
||||
if (UNLIKELY(TYPE_is_object(type)))
|
||||
if (TYPE_is_object(type))
|
||||
{
|
||||
OBJECT_UNREF_KEEP(value->_object.object);
|
||||
return;
|
||||
|
@ -219,7 +219,7 @@ void RELEASE_many(VALUE *value, int n)
|
|||
|
||||
type = value->type;
|
||||
|
||||
if (UNLIKELY(TYPE_is_object(type)))
|
||||
if (TYPE_is_object(type))
|
||||
{
|
||||
OBJECT_UNREF(value->_object.object);
|
||||
continue;
|
||||
|
@ -445,9 +445,9 @@ void EXEC_enter(void)
|
|||
|
||||
// Check number of arguments
|
||||
|
||||
if (UNLIKELY(nparam < func->npmin))
|
||||
if (nparam < func->npmin)
|
||||
THROW(E_NEPARAM);
|
||||
else if (UNLIKELY(nparam > func->n_param && !func->vararg))
|
||||
else if (nparam > func->n_param && !func->vararg)
|
||||
THROW(E_TMPARAM);
|
||||
|
||||
// Mandatory arguments
|
||||
|
@ -623,12 +623,12 @@ void EXEC_enter_quick(void)
|
|||
|
||||
/* local variables initialization */
|
||||
|
||||
if (LIKELY(func->n_local != 0))
|
||||
if (func->n_local != 0)
|
||||
init_local_var(class, func);
|
||||
|
||||
/* control variables initialization */
|
||||
|
||||
if (LIKELY(func->n_ctrl != 0))
|
||||
if (func->n_ctrl != 0)
|
||||
{
|
||||
for (i = 0; i < func->n_ctrl; i++)
|
||||
{
|
||||
|
@ -715,7 +715,7 @@ static int exec_leave_byref(ushort *pc, int nparam)
|
|||
nbyref = 1 + (*pc & 0xF); \
|
||||
pc_func = FP->code; \
|
||||
\
|
||||
if (LIKELY(!PCODE_is(*pc_func, C_BYREF))) \
|
||||
if (!PCODE_is(*pc_func, C_BYREF)) \
|
||||
goto __LEAVE_NORMAL; \
|
||||
\
|
||||
nbyref_func = 1 + (*pc_func & 0xF); \
|
||||
|
@ -898,7 +898,7 @@ void EXEC_function_loop()
|
|||
{
|
||||
bool retry = FALSE;
|
||||
|
||||
if (LIKELY(PC != NULL))
|
||||
if (PC != NULL)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -1177,7 +1177,7 @@ void EXEC_native_quick(void)
|
|||
EXEC_call_native_inline(desc->exec, EXEC.object, desc->type, &SP[-nparam]);
|
||||
COPY_VALUE(&ret, &TEMP);
|
||||
|
||||
if (UNLIKELY(error))
|
||||
if (error)
|
||||
{
|
||||
RELEASE_MANY(SP, nparam);
|
||||
POP();
|
||||
|
@ -1240,12 +1240,12 @@ void EXEC_native(void)
|
|||
n = desc->npmin;
|
||||
nm = desc->npmax;
|
||||
|
||||
if (UNLIKELY(nparam < n))
|
||||
if (nparam < n)
|
||||
THROW(E_NEPARAM);
|
||||
|
||||
if (LIKELY(!desc->npvar))
|
||||
if (!desc->npvar)
|
||||
{
|
||||
if (UNLIKELY(nparam > nm))
|
||||
if (nparam > nm)
|
||||
THROW(E_TMPARAM);
|
||||
|
||||
value = &SP[-nparam];
|
||||
|
@ -1254,7 +1254,7 @@ void EXEC_native(void)
|
|||
for (i = 0; i < n; i++, value++, sign++)
|
||||
VALUE_conv(value, *sign);
|
||||
|
||||
if (UNLIKELY(n < nm))
|
||||
if (n < nm)
|
||||
{
|
||||
for (; i < nparam; i++, value++, sign++)
|
||||
{
|
||||
|
@ -1264,7 +1264,7 @@ void EXEC_native(void)
|
|||
|
||||
n = nm - nparam;
|
||||
|
||||
/*if (UNLIKELY(STACK_check(n)))
|
||||
/*if (STACK_check(n))
|
||||
{
|
||||
STACK_RELOCATE(value);
|
||||
}*/
|
||||
|
@ -1285,9 +1285,9 @@ void EXEC_native(void)
|
|||
VALUE_conv(value, *sign);
|
||||
|
||||
nm = desc->npmax;
|
||||
if (UNLIKELY(n < nm))
|
||||
if (n < nm)
|
||||
{
|
||||
if (UNLIKELY(nparam < nm))
|
||||
if (nparam < nm)
|
||||
{
|
||||
for (; i < nparam; i++, value++, sign++)
|
||||
{
|
||||
|
@ -1297,7 +1297,7 @@ void EXEC_native(void)
|
|||
|
||||
n = nm - nparam;
|
||||
|
||||
/*if (UNLIKELY(STACK_check(n)))
|
||||
/*if (STACK_check(n))
|
||||
{
|
||||
STACK_RELOCATE(value);
|
||||
}*/
|
||||
|
@ -1332,7 +1332,7 @@ void EXEC_native(void)
|
|||
EXEC_call_native_inline(desc->exec, object, desc->type, &SP[-nparam]);
|
||||
COPY_VALUE(&ret, &TEMP);
|
||||
|
||||
if (UNLIKELY(error))
|
||||
if (error)
|
||||
{
|
||||
RELEASE_MANY(SP, nparam);
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ CLASS *EXEC_object_real(VALUE *val)
|
|||
|
||||
//CLASS_load(class); If we have an object, the class is necessarily loaded.
|
||||
|
||||
if (UNLIKELY(class->must_check && (*(class->check))(object)))
|
||||
if (class->must_check && (*(class->check))(object))
|
||||
THROW(E_IOBJECT);
|
||||
|
||||
__RETURN:
|
||||
|
@ -1462,7 +1462,7 @@ __CHECK:
|
|||
|
||||
//CLASS_load(class); //If we have an object, the class is not necessarily loaded?
|
||||
|
||||
if (UNLIKELY(class->must_check && (*(class->check))(object)))
|
||||
if (class->must_check && (*(class->check))(object))
|
||||
THROW(E_IOBJECT);
|
||||
|
||||
*pobject = object;
|
||||
|
@ -1486,7 +1486,7 @@ bool EXEC_object_other(VALUE *val, CLASS **pclass, OBJECT **pobject)
|
|||
|
||||
__FUNCTION:
|
||||
|
||||
if (LIKELY(val->_function.kind == FUNCTION_UNKNOWN))
|
||||
if (val->_function.kind == FUNCTION_UNKNOWN)
|
||||
{
|
||||
EXEC_unknown_property = TRUE;
|
||||
EXEC_unknown_name = CP->load->unknown[val->_function.index];
|
||||
|
@ -1515,7 +1515,7 @@ __CLASS:
|
|||
{
|
||||
EXEC_super = val->_class.super;
|
||||
//*class = (*class)->parent;
|
||||
if (UNLIKELY(class == NULL))
|
||||
if (class == NULL)
|
||||
THROW(E_PARENT);
|
||||
}
|
||||
|
||||
|
@ -1551,7 +1551,7 @@ __CHECK:
|
|||
|
||||
//CLASS_load(class); If we have an object, the class is necessarily loaded.
|
||||
|
||||
if (UNLIKELY(class->must_check && (*(class->check))(object)))
|
||||
if (class->must_check && (*(class->check))(object))
|
||||
THROW(E_IOBJECT);
|
||||
|
||||
__RETURN:
|
||||
|
@ -1595,7 +1595,7 @@ void EXEC_public(CLASS *class, void *object, const char *name, int nparam)
|
|||
|
||||
desc = CLASS_get_symbol_desc_kind(class, name, (object != NULL) ? CD_METHOD : CD_STATIC_METHOD, 0, T_VOID);
|
||||
|
||||
if (UNLIKELY(desc == NULL))
|
||||
if (desc == NULL)
|
||||
return;
|
||||
|
||||
EXEC_public_desc(class, object, &desc->method, nparam);
|
||||
|
@ -1728,7 +1728,7 @@ void EXEC_special_inheritance(int special, CLASS *class, OBJECT *object, int npa
|
|||
np += desc->method.npmin;
|
||||
}
|
||||
|
||||
if (UNLIKELY(np > nparam))
|
||||
if (np > nparam)
|
||||
THROW(E_NEPARAM);
|
||||
|
||||
save_nparam = nparam;
|
||||
|
@ -1817,7 +1817,7 @@ void *EXEC_create_object(CLASS *class, int np, char *event)
|
|||
|
||||
CLASS_load(class);
|
||||
|
||||
if (UNLIKELY(class->no_create))
|
||||
if (class->no_create)
|
||||
THROW(E_CSTATIC, CLASS_get_name(class));
|
||||
|
||||
object = OBJECT_new(class, event, ((OP == NULL) ? (OBJECT *)CP : (OBJECT *)OP));
|
||||
|
@ -1862,7 +1862,7 @@ void EXEC_new(ushort code)
|
|||
if (SP->type == T_CLASS)
|
||||
{
|
||||
class = SP->_class.class;
|
||||
//if (UNLIKELY(class->override != NULL))
|
||||
//if (class->override != NULL)
|
||||
// class = class->override;
|
||||
}
|
||||
else if (TYPE_is_string(SP->type))
|
||||
|
@ -1880,7 +1880,7 @@ void EXEC_new(ushort code)
|
|||
//printf("**** NEW %s\n", class->name);
|
||||
CLASS_load(class);
|
||||
|
||||
if (UNLIKELY(class->no_create))
|
||||
if (class->no_create)
|
||||
THROW(E_CSTATIC, CLASS_get_name(class));
|
||||
|
||||
if (event)
|
||||
|
@ -1956,7 +1956,7 @@ void *EXEC_auto_create(CLASS *class, bool ref)
|
|||
|
||||
object = CLASS_auto_create(class, 0); /* object is checked by CLASS_auto_create */
|
||||
|
||||
/*if (UNLIKELY(class->must_check && (*(class->check))(object)))
|
||||
/*if (class->must_check && (*(class->check))(object))
|
||||
THROW(E_IOBJECT);*/
|
||||
|
||||
if (ref)
|
||||
|
|
|
@ -188,7 +188,7 @@ void EXEC_loop(void);
|
|||
})
|
||||
|
||||
#define EXEC_object(_val, _pclass, _pobject) \
|
||||
((LIKELY(TYPE_is_pure_object((_val)->type))) ? EXEC_object_2(_val, _pclass, _pobject), TRUE : \
|
||||
((TYPE_is_pure_object((_val)->type)) ? EXEC_object_2(_val, _pclass, _pobject), TRUE : \
|
||||
TYPE_is_variant((_val)->type) ? (*(_pclass) = EXEC_object_variant(_val, _pobject)), FALSE : \
|
||||
EXEC_object_other(_val, _pclass, _pobject))
|
||||
|
||||
|
|
|
@ -684,7 +684,7 @@ _POP_OPTIONAL:
|
|||
{
|
||||
VALUE *val = &PP[GET_XX()];
|
||||
|
||||
if (LIKELY(val->type == T_VOID))
|
||||
if (val->type == T_VOID)
|
||||
{
|
||||
if (SP[-1].type == T_VOID)
|
||||
VALUE_default(&SP[-1], val->_void.ptype);
|
||||
|
@ -1915,7 +1915,7 @@ _QUIT:
|
|||
|
||||
_BYREF:
|
||||
|
||||
if (LIKELY(PC == FP->code))
|
||||
if (PC == FP->code)
|
||||
{
|
||||
PC += GET_UX() + 2;
|
||||
goto _MAIN;
|
||||
|
@ -4079,7 +4079,7 @@ void SUBR_left(ushort code)
|
|||
|
||||
SUBR_ENTER();
|
||||
|
||||
if (LIKELY(!SUBR_check_string(PARAM)))
|
||||
if (!SUBR_check_string(PARAM))
|
||||
{
|
||||
if (NPARAM == 1)
|
||||
val = 1;
|
||||
|
@ -4161,7 +4161,7 @@ void SUBR_right(ushort code)
|
|||
|
||||
SUBR_ENTER();
|
||||
|
||||
if (LIKELY(!SUBR_check_string(PARAM)))
|
||||
if (!SUBR_check_string(PARAM))
|
||||
{
|
||||
if (NPARAM == 1)
|
||||
val = 1;
|
||||
|
|
|
@ -280,9 +280,9 @@ bool JIT_exec(bool ret_on_stack)
|
|||
if (JIT_disabled)
|
||||
return TRUE;
|
||||
|
||||
if (UNLIKELY(nparam < func->npmin))
|
||||
if (nparam < func->npmin)
|
||||
THROW(E_NEPARAM);
|
||||
else if (UNLIKELY(nparam > func->n_param && !func->vararg))
|
||||
else if (nparam > func->n_param && !func->vararg)
|
||||
THROW(E_TMPARAM);
|
||||
|
||||
if (!func->fast_linked)
|
||||
|
|
|
@ -218,7 +218,7 @@ void STRING_make_dump();
|
|||
|
||||
#define STRING_make_char(_c) \
|
||||
({ \
|
||||
if (UNLIKELY(STRING_make_buffer.ntemp == STRING_MAKE_TEMP)) \
|
||||
if (STRING_make_buffer.ntemp == STRING_MAKE_TEMP) \
|
||||
STRING_make_dump(); \
|
||||
STRING_make_buffer.temp[STRING_make_buffer.ntemp++] = (_c); \
|
||||
})
|
||||
|
|
|
@ -276,7 +276,7 @@ void THROW_TYPE(TYPE wanted, TYPE got) NORETURN;
|
|||
#define VALUE_conv_boolean(_value) \
|
||||
({ \
|
||||
VALUE *v = _value; \
|
||||
if (UNLIKELY(v->type != T_BOOLEAN)) \
|
||||
if (v->type != T_BOOLEAN) \
|
||||
{ \
|
||||
VALUE_convert_boolean(v); \
|
||||
} \
|
||||
|
@ -285,7 +285,7 @@ void THROW_TYPE(TYPE wanted, TYPE got) NORETURN;
|
|||
#define VALUE_conv_integer(_value) \
|
||||
({ \
|
||||
VALUE *v = _value; \
|
||||
if (UNLIKELY(v->type != T_INTEGER)) \
|
||||
if (v->type != T_INTEGER) \
|
||||
{ \
|
||||
if (TYPE_is_object(v->type)) \
|
||||
THROW_TYPE_INTEGER(v->type); \
|
||||
|
@ -296,7 +296,7 @@ void THROW_TYPE(TYPE wanted, TYPE got) NORETURN;
|
|||
#define VALUE_conv_float(_value) \
|
||||
({ \
|
||||
VALUE *v = _value; \
|
||||
if (UNLIKELY(v->type != T_FLOAT)) \
|
||||
if (v->type != T_FLOAT) \
|
||||
{ \
|
||||
if (TYPE_is_object(v->type)) \
|
||||
THROW_TYPE_FLOAT(v->type); \
|
||||
|
@ -307,7 +307,7 @@ void THROW_TYPE(TYPE wanted, TYPE got) NORETURN;
|
|||
#define VALUE_conv_string(_value) \
|
||||
({ \
|
||||
VALUE *v = _value; \
|
||||
if (UNLIKELY(v->type != T_STRING && v->type != T_CSTRING)) \
|
||||
if (v->type != T_STRING && v->type != T_CSTRING) \
|
||||
{ \
|
||||
if (TYPE_is_object(v->type)) \
|
||||
THROW_TYPE_STRING(v->type); \
|
||||
|
@ -317,13 +317,13 @@ void THROW_TYPE(TYPE wanted, TYPE got) NORETURN;
|
|||
|
||||
#define VALUE_conv_variant(_value) \
|
||||
({ \
|
||||
if (UNLIKELY((_value)->type != T_VARIANT)) \
|
||||
if ((_value)->type != T_VARIANT) \
|
||||
VALUE_convert_variant(_value); \
|
||||
})
|
||||
|
||||
#define VALUE_conv_object(_value, _type) \
|
||||
({ \
|
||||
if (UNLIKELY((_value)->type != (_type))) \
|
||||
if ((_value)->type != (_type)) \
|
||||
VALUE_convert_object(_value, _type); \
|
||||
})
|
||||
|
||||
|
@ -331,19 +331,19 @@ void THROW_TYPE(TYPE wanted, TYPE got) NORETURN;
|
|||
|
||||
#define VALUE_conv_boolean(_value) \
|
||||
({ \
|
||||
if (UNLIKELY((_value)->type != T_BOOLEAN)) \
|
||||
if ((_value)->type != T_BOOLEAN) \
|
||||
VALUE_convert_boolean(_value); \
|
||||
})
|
||||
|
||||
#define VALUE_conv_float(_value) \
|
||||
({ \
|
||||
if (UNLIKELY((_value)->type != T_FLOAT)) \
|
||||
if ((_value)->type != T_FLOAT) \
|
||||
VALUE_convert_float(_value); \
|
||||
})
|
||||
|
||||
#define VALUE_conv_variant(_value) \
|
||||
({ \
|
||||
if (UNLIKELY((_value)->type != T_VARIANT)) \
|
||||
if ((_value)->type != T_VARIANT) \
|
||||
VALUE_convert_variant(_value); \
|
||||
})
|
||||
|
||||
|
@ -355,7 +355,7 @@ void THROW_TYPE(TYPE wanted, TYPE got) NORETURN;
|
|||
|
||||
#define VALUE_conv_string(_value) \
|
||||
({ \
|
||||
if (UNLIKELY((_value)->type != T_STRING && (_value)->type != T_CSTRING)) \
|
||||
if ((_value)->type != T_STRING && (_value)->type != T_CSTRING) \
|
||||
VALUE_conv(_value, T_STRING); \
|
||||
})
|
||||
|
||||
|
|
|
@ -111,9 +111,9 @@ static void print_object(void *object)
|
|||
CLASS *class = OBJECT_class(object);
|
||||
|
||||
if (*class->name == '$')
|
||||
fprintf(_where, "(Struct %s %p) [%ld]", &class->name[1], object, OBJECT_count(object));
|
||||
fprintf(_where, "(Struct %s %p) [%ld]", &class->name[1], object, (long)OBJECT_count(object));
|
||||
else
|
||||
fprintf(_where, "(%s %p) [%ld]", class->name, object, OBJECT_count(object));
|
||||
fprintf(_where, "(%s %p) [%ld]", class->name, object, (long)OBJECT_count(object));
|
||||
|
||||
/*
|
||||
if (GB.Is(object, GB.FindClass("Collection")))
|
||||
|
|
|
@ -194,11 +194,6 @@ typedef
|
|||
"published by the Free Software Foundation; either version 2, or \n" \
|
||||
"(at your option) any later version.\n\n"
|
||||
|
||||
//#define LIKELY(_x) __builtin_expect((_x), 1)
|
||||
//#define UNLIKELY(_x) __builtin_expect((_x), 0)
|
||||
#define LIKELY(_x) (_x)
|
||||
#define UNLIKELY(_x) (_x)
|
||||
|
||||
#define $(_x) _x
|
||||
|
||||
#define RESTART_SYSCALL(_code) \
|
||||
|
|
|
@ -274,7 +274,7 @@ void *HASH_TABLE_insert(HASH_TABLE *hash_table, const char *key, int len)
|
|||
|
||||
node = hash_table_lookup_node(hash_table, key, len);
|
||||
|
||||
if (UNLIKELY(*node != NULL))
|
||||
if (*node != NULL)
|
||||
return NODE_value(*node);
|
||||
|
||||
*node = hash_node_new(hash_table, key, len);
|
||||
|
@ -296,7 +296,7 @@ void HASH_TABLE_remove(HASH_TABLE *hash_table, const char *key, int len)
|
|||
|
||||
node = hash_table_lookup_node(hash_table, key, len);
|
||||
|
||||
if (LIKELY(*node != NULL))
|
||||
if (*node != NULL)
|
||||
{
|
||||
dest = *node;
|
||||
(*node) = dest->next;
|
||||
|
@ -462,7 +462,7 @@ static HASH_NODE *hash_node_new(HASH_TABLE *hash_table, const char *key, int len
|
|||
|
||||
#ifdef KEEP_ORDER
|
||||
|
||||
if (UNLIKELY(!hash_table->sfirst))
|
||||
if (!hash_table->sfirst)
|
||||
{
|
||||
hash_table->sfirst = hash_node;
|
||||
hash_table->slast = hash_node;
|
||||
|
@ -494,7 +494,7 @@ static void hash_nodes_destroy(HASH_NODE *hash_node)
|
|||
|
||||
for(;;)
|
||||
{
|
||||
if (UNLIKELY(node == NULL))
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
||||
next = node->next;
|
||||
|
@ -508,7 +508,7 @@ void HASH_TABLE_get_key(HASH_TABLE *hash_table, HASH_NODE *node, char **key, int
|
|||
{
|
||||
HASH_KEY *node_key;
|
||||
|
||||
if (LIKELY(node != NULL))
|
||||
if (node != NULL)
|
||||
{
|
||||
node_key = NODE_key(hash_table, node);
|
||||
*key = node_key->key;
|
||||
|
|
|
@ -87,13 +87,13 @@ char TABLE_compare(const char *s1, int len1, const char *s2, int len2)
|
|||
c1 = s1[i];
|
||||
c2 = s2[i];
|
||||
|
||||
if (LIKELY(c1 > c2)) return 1;
|
||||
if (LIKELY(c1 < c2)) return -1;
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
|
||||
if (LIKELY(len1 < len2))
|
||||
if (len1 < len2)
|
||||
return -1;
|
||||
else if (LIKELY(len1 > len2))
|
||||
else if (len1 > len2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
@ -108,14 +108,14 @@ char TABLE_compare_ignore_case(const char *s1, int len1, const char *s2, int len
|
|||
for (i = 0; len > 0; i++)
|
||||
{
|
||||
result = toupper(s1[i]) - toupper(s2[i]);
|
||||
if (LIKELY(result))
|
||||
if (result)
|
||||
return result; // < 0 ? -1 : 1;
|
||||
len--;
|
||||
}
|
||||
|
||||
if (LIKELY(len1 < len2))
|
||||
if (len1 < len2)
|
||||
return -1;
|
||||
else if (LIKELY(len1 > len2))
|
||||
else if (len1 > len2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
@ -125,15 +125,15 @@ char TABLE_compare_ignore_case_len(const char *s1, int len1, const char *s2, int
|
|||
{
|
||||
int result;
|
||||
|
||||
if (LIKELY(len1 < len2))
|
||||
if (len1 < len2)
|
||||
return -1;
|
||||
else if (LIKELY(len1 > len2))
|
||||
else if (len1 > len2)
|
||||
return 1;
|
||||
|
||||
while (len1)
|
||||
{
|
||||
result = tolower(*s1++) - tolower(*s2++);
|
||||
if (LIKELY(result))
|
||||
if (result)
|
||||
return result; // < 0 ? -1 : 1;
|
||||
--len1;
|
||||
}
|
||||
|
@ -159,16 +159,16 @@ static inline int search(void *symbol, ushort *sort, int n_symbol, size_t size,
|
|||
|
||||
for(;;)
|
||||
{
|
||||
if (UNLIKELY(deb >= fin))
|
||||
if (deb >= fin)
|
||||
return (-deb) - 1;
|
||||
|
||||
pos = (deb + fin) >> 1;
|
||||
|
||||
sym = SSYM(symbol, sort[pos], size);
|
||||
|
||||
if (LIKELY(len < sym->len))
|
||||
if (len < sym->len)
|
||||
goto __B_LOWER;
|
||||
else if (LIKELY(len > sym->len))
|
||||
else if (len > sym->len)
|
||||
goto __B_GREATER;
|
||||
|
||||
#if TABLE_USE_KEY
|
||||
|
@ -192,12 +192,12 @@ static inline int search(void *symbol, ushort *sort, int n_symbol, size_t size,
|
|||
{
|
||||
result = *s1 - *s2;
|
||||
|
||||
if (LIKELY(result < 0))
|
||||
if (result < 0)
|
||||
goto __B_LOWER;
|
||||
else if (LIKELY(result > 0))
|
||||
else if (result > 0)
|
||||
goto __B_GREATER;
|
||||
|
||||
if (UNLIKELY(--l == 0))
|
||||
if (--l == 0)
|
||||
break;
|
||||
|
||||
s1++;
|
||||
|
@ -231,7 +231,7 @@ static inline int search_ignore_case(void *symbol, ushort *sort, int n_symbol, s
|
|||
|
||||
for(;;)
|
||||
{
|
||||
if (UNLIKELY(deb >= fin))
|
||||
if (deb >= fin)
|
||||
{
|
||||
return -deb - 1;
|
||||
/**index = deb;
|
||||
|
@ -242,9 +242,9 @@ static inline int search_ignore_case(void *symbol, ushort *sort, int n_symbol, s
|
|||
|
||||
sym = SSYM(symbol, sort[pos], size);
|
||||
|
||||
if (LIKELY(len < sym->len))
|
||||
if (len < sym->len)
|
||||
goto __T_LOWER;
|
||||
else if (LIKELY(len > sym->len))
|
||||
else if (len > sym->len)
|
||||
goto __T_GREATER;
|
||||
|
||||
#if TABLE_USE_KEY
|
||||
|
@ -268,12 +268,12 @@ static inline int search_ignore_case(void *symbol, ushort *sort, int n_symbol, s
|
|||
{
|
||||
result = tolower(*s1) - tolower(*s2);
|
||||
|
||||
if (LIKELY(result < 0))
|
||||
if (result < 0)
|
||||
goto __T_LOWER;
|
||||
else if (LIKELY(result > 0))
|
||||
else if (result > 0)
|
||||
goto __T_GREATER;
|
||||
|
||||
if (UNLIKELY(--l == 0))
|
||||
if (--l == 0)
|
||||
break;
|
||||
|
||||
s1++;
|
||||
|
@ -293,7 +293,7 @@ static inline int search_ignore_case(void *symbol, ushort *sort, int n_symbol, s
|
|||
|
||||
const char *TABLE_get_symbol_name(TABLE *table, int index)
|
||||
{
|
||||
if (UNLIKELY((index < 0) || (index >= ARRAY_count(table->symbol))))
|
||||
if (index < 0 || index >= ARRAY_count(table->symbol))
|
||||
strcpy(_buffer, "?");
|
||||
else
|
||||
SYMBOL_get_name(SYM(table, index));
|
||||
|
@ -306,7 +306,7 @@ const char *TABLE_get_symbol_name_suffix(TABLE *table, int index, const char* su
|
|||
{
|
||||
SYMBOL *sym;
|
||||
|
||||
if (UNLIKELY((index < 0) || (index >= ARRAY_count(table->symbol))))
|
||||
if (index < 0 || index >= ARRAY_count(table->symbol))
|
||||
return "?";
|
||||
|
||||
sym = SYM(table, index);
|
||||
|
@ -514,7 +514,7 @@ int TABLE_copy_symbol_with_prefix(TABLE *table, int ind_src, char prefix)
|
|||
|
||||
ptr = (char *)sym->name - 1;
|
||||
|
||||
if (UNLIKELY(!isspace((unsigned char)*ptr)))
|
||||
if (!isspace((unsigned char)*ptr))
|
||||
ERROR_panic("Cannot add prefix to symbol");
|
||||
|
||||
*ptr = prefix;
|
||||
|
@ -535,11 +535,11 @@ int SYMBOL_find(void *symbol, ushort *sort, int n_symbol, size_t s_symbol, int f
|
|||
int index;
|
||||
int len_prefix;
|
||||
|
||||
if (UNLIKELY(prefix != NULL))
|
||||
if (prefix != NULL)
|
||||
{
|
||||
len_prefix = strlen(prefix);
|
||||
|
||||
if (UNLIKELY((len + len_prefix) > MAX_SYMBOL_LEN))
|
||||
if ((len + len_prefix) > MAX_SYMBOL_LEN)
|
||||
ERROR_panic("SYMBOL_find: prefixed symbol too long");
|
||||
|
||||
strcpy(_buffer, prefix);
|
||||
|
|
Loading…
Reference in a new issue