Tag many error checks using ecl_unlikely

This commit is contained in:
Juan Jose Garcia Ripoll 2010-02-26 10:43:37 +01:00
parent 53a1d16b4d
commit 6e4d572bfb
23 changed files with 217 additions and 194 deletions

View file

@ -1384,7 +1384,7 @@ cl_object
si_weak_pointer_value(cl_object o)
{
cl_object value;
if (type_of(o) != t_weak_pointer)
if (ecl_unlikely(type_of(o) != t_weak_pointer))
FEwrong_type_only_arg(@'ext::weak-pointer-value', o,
@'ext::weak-pointer');
value = (cl_object)GC_call_with_alloc_lock((GC_fn_type)ecl_weak_pointer_value, o);

View file

@ -237,25 +237,25 @@ ecl_aref_unsafe(cl_object x, cl_index index)
cl_object
ecl_aref(cl_object x, cl_index index)
{
if (ECL_ARRAYP(x)) {
if (index < x->array.dim) {
return ecl_aref_unsafe(x, index);
}
out_of_bounds_error(index, x);
if (ecl_unlikely(!ECL_ARRAYP(x))) {
FEwrong_type_nth_arg(@'aref', 1, x, @'array');
}
FEwrong_type_nth_arg(@'aref', 1, x, @'array');
if (ecl_unlikely(index >= x->array.dim)) {
out_of_bounds_error(index, x);
}
return ecl_aref_unsafe(x, index);
}
cl_object
ecl_aref1(cl_object x, cl_index index)
{
if (ECL_VECTORP(x)) {
if (index < x->array.dim) {
return ecl_aref_unsafe(x, index);
}
if (ecl_unlikely(!ECL_VECTORP(x))) {
FEwrong_type_nth_arg(@'aref', 1, x, @'array');
}
if (ecl_unlikely(index >= x->array.dim)) {
out_of_bounds_error(index, x);
}
FEwrong_type_nth_arg(@'aref', 1, x, @'array');
return ecl_aref_unsafe(x, index);
}
/*
@ -269,7 +269,7 @@ ecl_aref1(cl_object x, cl_index index)
cl_index r = narg - 2;
switch (type_of(x)) {
case t_array:
if (r != x->array.rank)
if (ecl_unlikely(r != x->array.rank))
FEerror("Wrong number of indices.", 0);
for (i = j = 0; i < r; i++) {
cl_index s =
@ -284,7 +284,7 @@ ecl_aref1(cl_object x, cl_index index)
#endif
case t_base_string:
case t_bitvector:
if (r != 1)
if (ecl_unlikely(r != 1))
FEerror("Wrong number of indices.", 0);
j = ecl_fixnum_in_range(@'si::aset',"index",cl_va_arg(dims),
0, (cl_fixnum)x->vector.dim - 1);
@ -369,23 +369,25 @@ ecl_aset_unsafe(cl_object x, cl_index index, cl_object value)
cl_object
ecl_aset(cl_object x, cl_index index, cl_object value)
{
if (ECL_ARRAYP(x)) {
if (index < x->array.dim)
return ecl_aset_unsafe(x, index, value);
if (ecl_unlikely(!ECL_ARRAYP(x))) {
FEwrong_type_nth_arg(@'si::aset', 1, x, @'array');
}
if (ecl_unlikely(index >= x->array.dim)) {
out_of_bounds_error(index, x);
}
FEwrong_type_nth_arg(@'si::aset', 1, x, @'array');
return ecl_aset_unsafe(x, index, value);
}
cl_object
ecl_aset1(cl_object x, cl_index index, cl_object value)
{
if (ECL_VECTORP(x)) {
if (index < x->array.dim)
return ecl_aset_unsafe(x, index, value);
if (ecl_unlikely(!ECL_VECTORP(x))) {
FEwrong_type_nth_arg(@'si::aset', 1, x, @'array');
}
if (ecl_unlikely(index >= x->array.dim)) {
out_of_bounds_error(index, x);
}
FEwrong_type_nth_arg(@'si::aset', 1, x, @'array');
return ecl_aset_unsafe(x, index, value);
}
/*
@ -404,12 +406,12 @@ si_make_pure_array(cl_object etype, cl_object dims, cl_object adj,
return si_make_vector(etype, dims, adj, fillp, displ, disploff);
}
r = ecl_length(dims);
if (r >= ARANKLIM) {
if (ecl_unlikely(r >= ARANKLIM)) {
FEerror("The array rank, ~R, is too large.", 1, MAKE_FIXNUM(r));
} else if (r == 1) {
return si_make_vector(etype, ECL_CONS_CAR(dims), adj, fillp,
displ, disploff);
} else if (!Null(fillp)) {
} else if (ecl_unlikely(!Null(fillp))) {
FEerror(":FILL-POINTER may not be specified for an array of rank ~D",
1, MAKE_FIXNUM(r));
}
@ -790,7 +792,7 @@ si_array_raw_data(cl_object x)
cl_elttype
ecl_array_elttype(cl_object x)
{
if (!ECL_ARRAYP(x))
if (ecl_unlikely(!ECL_ARRAYP(x)))
FEwrong_type_argument(@'array', x);
return x->array.elttype;
}
@ -798,7 +800,7 @@ ecl_array_elttype(cl_object x)
cl_object
cl_array_rank(cl_object a)
{
if (!ECL_ARRAYP(a))
if (ecl_unlikely(!ECL_ARRAYP(a)))
FEwrong_type_only_arg(@'array-rank', a, @'array');
@(return ((type_of(a) == t_array) ? MAKE_FIXNUM(a->array.rank)
: MAKE_FIXNUM(1)))
@ -815,7 +817,8 @@ ecl_array_dimension(cl_object a, cl_index index)
{
switch (type_of(a)) {
case t_array: {
if (index > a->array.rank) FEwrong_dimensions(a, index+1);
if (ecl_unlikely(index > a->array.rank))
FEwrong_dimensions(a, index+1);
return a->array.dims[index];
}
#ifdef ECL_UNICODE
@ -824,7 +827,8 @@ ecl_array_dimension(cl_object a, cl_index index)
case t_base_string:
case t_vector:
case t_bitvector:
if (index) FEwrong_dimensions(a, index+1);
if (ecl_unlikely(index))
FEwrong_dimensions(a, index+1);
return a->vector.dim;
default:
FEwrong_type_only_arg(@'array-dimension', a, @'array');
@ -834,7 +838,7 @@ ecl_array_dimension(cl_object a, cl_index index)
cl_object
cl_array_total_size(cl_object a)
{
if (!ECL_ARRAYP(a))
if (ecl_unlikely(!ECL_ARRAYP(a)))
FEwrong_type_only_arg(@'array-total-size', a, @'array');
@(return MAKE_FIXNUM(a->array.dim))
}
@ -842,7 +846,7 @@ cl_array_total_size(cl_object a)
cl_object
cl_adjustable_array_p(cl_object a)
{
if (!ECL_ARRAYP(a))
if (ecl_unlikely(!ECL_ARRAYP(a)))
FEwrong_type_only_arg(@'adjustable-array-p', a, @'array');
@(return (ECL_ADJUSTABLE_ARRAY_P(a) ? Ct : Cnil))
}
@ -857,7 +861,7 @@ cl_array_displacement(cl_object a)
cl_object to_array;
cl_index offset;
if (!ECL_ARRAYP(a))
if (ecl_unlikely(!ECL_ARRAYP(a)))
FEwrong_type_only_arg(@'array-displacement', a, @'array');
to_array = a->array.displaced;
if (Null(to_array)) {
@ -929,10 +933,10 @@ cl_svref(cl_object x, cl_object index)
const cl_env_ptr the_env = ecl_process_env();
cl_index i;
if (type_of(x) != t_vector ||
(x->vector.flags & (ECL_FLAG_ADJUSTABLE | ECL_FLAG_HAS_FILL_POINTER)) ||
CAR(x->vector.displaced) != Cnil ||
(cl_elttype)x->vector.elttype != aet_object)
if (ecl_unlikely(type_of(x) != t_vector ||
(x->vector.flags & (ECL_FLAG_ADJUSTABLE | ECL_FLAG_HAS_FILL_POINTER)) ||
CAR(x->vector.displaced) != Cnil ||
(cl_elttype)x->vector.elttype != aet_object))
{
FEwrong_type_nth_arg(@'svref',1,x,@'simple-vector');
}
@ -946,10 +950,10 @@ si_svset(cl_object x, cl_object index, cl_object v)
const cl_env_ptr the_env = ecl_process_env();
cl_index i;
if (type_of(x) != t_vector ||
(x->vector.flags & (ECL_FLAG_ADJUSTABLE | ECL_FLAG_HAS_FILL_POINTER)) ||
CAR(x->vector.displaced) != Cnil ||
(cl_elttype)x->vector.elttype != aet_object)
if (ecl_unlikely(type_of(x) != t_vector ||
(x->vector.flags & (ECL_FLAG_ADJUSTABLE | ECL_FLAG_HAS_FILL_POINTER)) ||
CAR(x->vector.displaced) != Cnil ||
(cl_elttype)x->vector.elttype != aet_object))
{
FEwrong_type_nth_arg(@'si::svset',1,x,@'simple-vector');
}
@ -983,9 +987,9 @@ cl_object
cl_fill_pointer(cl_object a)
{
const cl_env_ptr the_env = ecl_process_env();
if (!ECL_VECTORP(a))
if (ecl_unlikely(!ECL_VECTORP(a)))
FEwrong_type_only_arg(@'fill-pointer', a, @'vector');
if (!ECL_ARRAY_HAS_FILL_POINTER_P(a)) {
if (ecl_unlikely(!ECL_ARRAY_HAS_FILL_POINTER_P(a))) {
const char *type = "(AND VECTOR (SATISFIES ARRAY-HAS-FILL-POINTER-P))";
FEwrong_type_nth_arg(@'fill-pointer', 1, a, ecl_read_from_cstring(type));
}
@ -999,7 +1003,7 @@ cl_object
si_fill_pointer_set(cl_object a, cl_object fp)
{
const cl_env_ptr the_env = ecl_process_env();
if (!ECL_VECTORP(a) || !ECL_ARRAY_HAS_FILL_POINTER_P(a)) {
if (ecl_unlikely(!ECL_VECTORP(a) || !ECL_ARRAY_HAS_FILL_POINTER_P(a))) {
const char *type = "(AND VECTOR (SATISFIES ARRAY-HAS-FILL-POINTER-P))";
FEwrong_type_nth_arg(@'si::fill-pointer-set', 1, a,
ecl_read_from_cstring(type));

View file

@ -22,9 +22,9 @@
ecl_character
ecl_char_code(cl_object c)
{
if (CHARACTERP(c))
return CHAR_CODE(c);
FEwrong_type_only_arg(@'char-code', c, @'character');
if (ecl_unlikely(!CHARACTERP(c)))
FEwrong_type_only_arg(@'char-code', c, @'character');
return CHAR_CODE(c);
}
ecl_base_char

View file

@ -186,9 +186,10 @@ ecl_allocate_foreign_data(cl_object tag, cl_index size)
void *
ecl_foreign_data_pointer_safe(cl_object f)
{
if (type_of(f) != t_foreign)
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_only_arg(@'si::foreign-data-pointer', f,
@'si::foreign-data');
}
return f->foreign.data;
}
@ -199,7 +200,8 @@ ecl_base_string_pointer_safe(cl_object f)
/* FIXME! Is there a better function name? */
f = ecl_check_cl_type(@'si::make-foreign-data-from-array', f, t_base_string);
s = f->base_string.self;
if (ECL_ARRAY_HAS_FILL_POINTER_P(f) && s[f->base_string.fillp] != 0) {
if (ecl_unlikely(ECL_ARRAY_HAS_FILL_POINTER_P(f) &&
s[f->base_string.fillp] != 0)) {
FEerror("Cannot coerce a string with fill pointer to (char *)", 0);
}
return (char *)s;
@ -235,7 +237,7 @@ si_allocate_foreign_data(cl_object tag, cl_object size)
cl_object
si_free_foreign_data(cl_object f)
{
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_only_arg(@'si::free-foreign-data', f,
@'si::foreign-data');
}
@ -251,7 +253,7 @@ cl_object
si_make_foreign_data_from_array(cl_object array)
{
cl_object tag = Cnil;
if (type_of(array) != t_array && type_of(array) != t_vector) {
if (ecl_unlikely(type_of(array) != t_array && type_of(array) != t_vector)) {
FEwrong_type_only_arg(@'si::make-foreign-data-from-array', array,
@'array');
}
@ -270,7 +272,7 @@ si_make_foreign_data_from_array(cl_object array)
cl_object
si_foreign_data_address(cl_object f)
{
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_only_arg(@'si::foreign-data-address', f,
@'si::foreign-data');
}
@ -280,7 +282,7 @@ si_foreign_data_address(cl_object f)
cl_object
si_foreign_data_tag(cl_object f)
{
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_only_arg(@'si::foreign-data-tag', f,
@'si::foreign-data');
}
@ -295,11 +297,11 @@ si_foreign_data_pointer(cl_object f, cl_object andx, cl_object asize,
cl_index size = fixnnint(asize);
cl_object output;
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_only_arg(@'si::foreign-data-pointer', f,
@'si::foreign-data');
}
if (ndx >= f->foreign.size || (f->foreign.size - ndx) < size) {
if (ecl_unlikely(ndx >= f->foreign.size || (f->foreign.size - ndx) < size)) {
FEerror("Out of bounds reference into foreign data type ~A.", 1, f);
}
output = ecl_alloc_object(t_foreign);
@ -316,11 +318,11 @@ si_foreign_data_ref(cl_object f, cl_object andx, cl_object asize, cl_object tag)
cl_index size = fixnnint(asize);
cl_object output;
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_nth_arg(@'si::foreign-data-ref', 1, f,
@'si::foreign-data');
}
if (ndx >= f->foreign.size || (f->foreign.size - ndx) < size) {
if (ecl_unlikely(ndx >= f->foreign.size || (f->foreign.size - ndx) < size)) {
FEerror("Out of bounds reference into foreign data type ~A.", 1, f);
}
output = ecl_allocate_foreign_data(tag, size);
@ -334,17 +336,17 @@ si_foreign_data_set(cl_object f, cl_object andx, cl_object value)
cl_index ndx = fixnnint(andx);
cl_index size, limit;
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_nth_arg(@'si::foreign-data-set', 1, f,
@'si::foreign-data');
}
if (type_of(value) != t_foreign) {
if (ecl_unlikely(type_of(value) != t_foreign)) {
FEwrong_type_nth_arg(@'si::foreign-data-set', 3, value,
@'si::foreign-data');
}
size = value->foreign.size;
limit = f->foreign.size;
if (ndx >= limit || (limit - ndx) < size) {
if (ecl_unlikely(ndx >= limit || (limit - ndx) < size)) {
FEerror("Out of bounds reference into foreign data type ~A.", 1, f);
}
memcpy(f->foreign.data + ndx, value->foreign.data, size);
@ -550,10 +552,10 @@ si_foreign_data_ref_elt(cl_object f, cl_object andx, cl_object type)
cl_index ndx = fixnnint(andx);
cl_index limit = f->foreign.size;
enum ecl_ffi_tag tag = ecl_foreign_type_code(type);
if (ndx >= limit || (ndx + ecl_foreign_type_size[tag] > limit)) {
if (ecl_unlikely(ndx >= limit || (ndx + ecl_foreign_type_size[tag] > limit))) {
FEerror("Out of bounds reference into foreign data type ~A.", 1, f);
}
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_nth_arg(@'si::foreign-data-ref-elt', 1, f,
@'si::foreign-data');
}
@ -566,10 +568,10 @@ si_foreign_data_set_elt(cl_object f, cl_object andx, cl_object type, cl_object v
cl_index ndx = fixnnint(andx);
cl_index limit = f->foreign.size;
enum ecl_ffi_tag tag = ecl_foreign_type_code(type);
if (ndx >= limit || ndx + ecl_foreign_type_size[tag] > limit) {
if (ecl_unlikely(ndx >= limit || ndx + ecl_foreign_type_size[tag] > limit)) {
FEerror("Out of bounds reference into foreign data type ~A.", 1, f);
}
if (type_of(f) != t_foreign) {
if (ecl_unlikely(type_of(f) != t_foreign)) {
FEwrong_type_nth_arg(@'si::foreign-data-set-elt', 1, f,
@'si::foreign-data');
}
@ -587,7 +589,7 @@ si_size_of_foreign_elt_type(cl_object type)
cl_object
si_null_pointer_p(cl_object f)
{
if (type_of(f) != t_foreign)
if (ecl_unlikely(type_of(f) != t_foreign))
FEwrong_type_only_arg(@'si::null-pointer-p', f,
@'si::foreign-data');
@(return ((f->foreign.data == NULL)? Ct : Cnil))
@ -596,7 +598,7 @@ si_null_pointer_p(cl_object f)
cl_object
si_foreign_data_recast(cl_object f, cl_object size, cl_object tag)
{
if (type_of(f) != t_foreign)
if (ecl_unlikely(type_of(f) != t_foreign))
FEwrong_type_nth_arg(@'si::foreign-data-recast', 1, f,
@'si::foreign-data');
f->foreign.size = fixnnint(size);
@ -627,8 +629,9 @@ si_load_foreign_module(cl_object filename)
mp_giveup_lock(ecl_symbol_value(@'mp::+load-compile-lock+'));
} CL_UNWIND_PROTECT_END;
# endif
if (type_of(output) != t_codeblock) {
FEerror("LOAD-FOREIGN-MODULE: Could not load foreign module ~S (Error: ~S)", 2, filename, output);
if (ecl_unlikely(type_of(output) != t_codeblock)) {
FEerror("LOAD-FOREIGN-MODULE: Could not load "
"foreign module ~S (Error: ~S)", 2, filename, output);
}
output->cblock.locked |= 1;
@(return output)
@ -655,8 +658,10 @@ si_find_foreign_symbol(cl_object var, cl_object module, cl_object type, cl_objec
}
output = ecl_make_foreign_data(type, ecl_to_fixnum(size), sym);
OUTPUT:
if (type_of(output) != t_foreign)
FEerror("FIND-FOREIGN-SYMBOL: Could not load foreign symbol ~S from module ~S (Error: ~S)", 3, var, module, output);
if (ecl_unlikely(type_of(output) != t_foreign))
FEerror("FIND-FOREIGN-SYMBOL: Could not load "
"foreign symbol ~S from module ~S (Error: ~S)",
3, var, module, output);
@(return output)
#endif
}

View file

@ -1851,7 +1851,8 @@ cl_make_two_way_stream(cl_object istrm, cl_object ostrm)
cl_object
cl_two_way_stream_input_stream(cl_object strm)
{
if (type_of(strm) != t_stream || strm->stream.mode != smm_two_way)
if (ecl_unlikely(type_of(strm) != t_stream ||
strm->stream.mode != smm_two_way))
FEwrong_type_only_arg(@'two-way-stream-input-stream',
strm, @'two-way-stream');
@(return TWO_WAY_STREAM_INPUT(strm))
@ -1860,7 +1861,8 @@ cl_two_way_stream_input_stream(cl_object strm)
cl_object
cl_two_way_stream_output_stream(cl_object strm)
{
if (type_of(strm) != t_stream || strm->stream.mode != smm_two_way)
if (ecl_unlikely(type_of(strm) != t_stream ||
strm->stream.mode != smm_two_way))
FEwrong_type_only_arg(@'two-way-stream-output-stream',
strm, @'two-way-stream');
@(return TWO_WAY_STREAM_OUTPUT(strm))
@ -2040,7 +2042,8 @@ const struct ecl_file_ops broadcast_ops = {
cl_object
cl_broadcast_stream_streams(cl_object strm)
{
if (type_of(strm) != t_stream || strm->stream.mode != smm_broadcast)
if (ecl_unlikely(type_of(strm) != t_stream ||
strm->stream.mode != smm_broadcast))
FEwrong_type_only_arg(@'broadcast-stream-streams',
strm, @'broadcast-stream');
return cl_copy_list(BROADCAST_STREAM_LIST(strm));
@ -2221,7 +2224,8 @@ cl_make_echo_stream(cl_object strm1, cl_object strm2)
cl_object
cl_echo_stream_input_stream(cl_object strm)
{
if (type_of(strm) != t_stream || strm->stream.mode != smm_echo)
if (ecl_unlikely(type_of(strm) != t_stream ||
strm->stream.mode != smm_echo))
FEwrong_type_only_arg(@'echo-stream-input-stream',
strm, @'echo-stream');
@(return ECHO_STREAM_INPUT(strm))
@ -2230,7 +2234,8 @@ cl_echo_stream_input_stream(cl_object strm)
cl_object
cl_echo_stream_output_stream(cl_object strm)
{
if (type_of(strm) != t_stream || strm->stream.mode != smm_echo)
if (ecl_unlikely(type_of(strm) != t_stream ||
strm->stream.mode != smm_echo))
FEwrong_type_only_arg(@'echo-stream-output-stream',
strm, @'echo-stream');
@(return ECHO_STREAM_OUTPUT(strm))
@ -2373,7 +2378,8 @@ const struct ecl_file_ops concatenated_ops = {
cl_object
cl_concatenated_stream_streams(cl_object strm)
{
if (type_of(strm) != t_stream || strm->stream.mode != smm_concatenated)
if (ecl_unlikely(type_of(strm) != t_stream ||
strm->stream.mode != smm_concatenated))
FEwrong_type_only_arg(@'concatenated-stream-streams',
strm, @'concatenated-stream');
return cl_copy_list(CONCATENATED_STREAM_LIST(strm));
@ -2572,7 +2578,8 @@ cl_make_synonym_stream(cl_object sym)
cl_object
cl_synonym_stream_symbol(cl_object strm)
{
if (type_of(strm) != t_stream || strm->stream.mode != smm_synonym)
if (ecl_unlikely(type_of(strm) != t_stream ||
strm->stream.mode != smm_synonym))
FEwrong_type_only_arg(@'synonym-stream-symbol',
strm, @'synonym-stream');
@(return SYNONYM_STREAM_SYMBOL(strm))
@ -4360,7 +4367,7 @@ cl_open_stream_p(cl_object strm)
return funcall(2, @'gray::open-stream-p', strm);
}
#endif
if (type_of(strm) != t_stream)
if (ecl_unlikely(type_of(strm) != t_stream))
FEwrong_type_only_arg(@'open-stream-p', strm, @'stream');
@(return (strm->stream.closed ? Cnil : Ct))
}
@ -4383,7 +4390,7 @@ cl_stream_external_format(cl_object strm)
output = @':default';
else
#endif
if (t != t_stream)
if (ecl_unlikely(t != t_stream))
FEwrong_type_only_arg(@'stream-external-format', strm, @'stream');
if (strm->stream.mode == smm_synonym) {
strm = SYNONYM_STREAM_STREAM(strm);

View file

@ -71,7 +71,7 @@ reshape_instance(cl_object x, int delta)
cl_object
clos_set_funcallable_instance_function(cl_object x, cl_object function_or_t)
{
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'clos::set-funcallable-instance-function',
1, x, @'ext::instance');
if (x->instance.isgf == ECL_USER_DISPATCH) {

View file

@ -30,7 +30,7 @@ static void corrupted_hash(cl_object hashtable) /*__attribute__((noreturn))*/;
static void
assert_type_hash_table(cl_object function, cl_narg narg, cl_object p)
{
if (type_of(p) != t_hashtable)
if (ecl_unlikely(type_of(p) != t_hashtable))
FEwrong_type_nth_arg(function, narg, p, @'hash-table');
}

View file

@ -57,7 +57,7 @@ si_instance_sig_set(cl_object x)
cl_object
si_instance_class(cl_object x)
{
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_only_arg(@'class-of', x, @'ext::instance');
@(return CLASS_OF(x))
}
@ -65,9 +65,9 @@ si_instance_class(cl_object x)
cl_object
si_instance_class_set(cl_object x, cl_object y)
{
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::instance-class-set', 1, x, @'ext::instance');
if (!ECL_INSTANCEP(y))
if (ecl_unlikely(!ECL_INSTANCEP(y)))
FEwrong_type_nth_arg(@'si::instance-class-set', 2, y, @'ext::instance');
CLASS_OF(x) = y;
@(return x)
@ -76,9 +76,9 @@ si_instance_class_set(cl_object x, cl_object y)
cl_object
ecl_instance_ref(cl_object x, cl_fixnum i)
{
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::instance-ref', 1, x, @'ext::instance');
if (i < 0 || i >= (cl_fixnum)x->instance.length)
if (ecl_unlikely(i < 0 || i >= (cl_fixnum)x->instance.length))
FEtype_error_index(x, MAKE_FIXNUM(i));
return(x->instance.slots[i]);
}
@ -88,10 +88,10 @@ si_instance_ref(cl_object x, cl_object index)
{
cl_fixnum i;
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::instance-ref', 1, x, @'ext::instance');
if (!FIXNUMP(index) ||
(i = fix(index)) < 0 || i >= (cl_fixnum)x->instance.length)
if (ecl_unlikely(!FIXNUMP(index) ||
(i = fix(index)) < 0 || i >= (cl_fixnum)x->instance.length))
FEtype_error_index(x, index);
@(return x->instance.slots[i])
}
@ -101,13 +101,13 @@ si_instance_ref_safe(cl_object x, cl_object index)
{
cl_fixnum i;
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::instance-ref', 1, x, @'ext::instance');
if (!FIXNUMP(index) ||
(i = fix(index)) < 0 || i >= x->instance.length)
if (ecl_unlikely(!FIXNUMP(index) ||
(i = fix(index)) < 0 || i >= x->instance.length))
FEtype_error_index(x, index);
x = x->instance.slots[i];
if (x == ECL_UNBOUND)
if (ecl_unlikely(x == ECL_UNBOUND))
cl_error(5, @'unbound-slot', @':name', index, @':instance', x);
@(return x)
}
@ -115,9 +115,9 @@ si_instance_ref_safe(cl_object x, cl_object index)
cl_object
ecl_instance_set(cl_object x, cl_fixnum i, cl_object v)
{
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::instance-set', 1, x, @'ext::instance');
if (i >= x->instance.length || i < 0)
if (ecl_unlikely(i >= x->instance.length || i < 0))
FEtype_error_index(x, MAKE_FIXNUM(i));
x->instance.slots[i] = v;
return(v);
@ -128,10 +128,10 @@ si_instance_set(cl_object x, cl_object index, cl_object value)
{
cl_fixnum i;
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::instance-set', 1, x, @'ext::instance');
if (!FIXNUMP(index) ||
(i = fix(index)) >= (cl_fixnum)x->instance.length || i < 0)
if (ecl_unlikely(!FIXNUMP(index) ||
(i = fix(index)) >= (cl_fixnum)x->instance.length || i < 0))
FEtype_error_index(x, index);
x->instance.slots[i] = value;
@(return value)
@ -162,10 +162,10 @@ si_sl_makunbound(cl_object x, cl_object index)
{
cl_fixnum i;
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::sl-makunbound', 1, x, @'ext::instance');
if (!FIXNUMP(index) ||
(i = fix(index)) >= x->instance.length || i < 0)
if (ecl_unlikely(!FIXNUMP(index) ||
(i = fix(index)) >= x->instance.length || i < 0))
FEtype_error_index(x, index);
x->instance.slots[i] = ECL_UNBOUND;
@(return x)
@ -176,7 +176,7 @@ si_copy_instance(cl_object x)
{
cl_object y;
if (!ECL_INSTANCEP(x))
if (ecl_unlikely(!ECL_INSTANCEP(x)))
FEwrong_type_nth_arg(@'si::copy-instance', 1, x, @'ext::instance');
y = ecl_allocate_instance(x->instance.clas, x->instance.length);
y->instance.sig = x->instance.sig;

View file

@ -136,21 +136,17 @@ setup_test(struct cl_test *t, cl_object item, cl_object test,
cl_object
cl_car(cl_object x)
{
if (Null(x))
return1(x);
if (CONSP(x))
return1(CAR(x));
FEwrong_type_only_arg(@'car', x, @'list');
if (ecl_unlikely(!LISTP(x)))
FEwrong_type_only_arg(@'car', x, @'list');
return1(Null(x)? x : ECL_CONS_CAR(x));
}
cl_object
cl_cdr(cl_object x)
{
if (Null(x))
return1(x);
if (CONSP(x))
return1(ECL_CONS_CDR(x));
FEwrong_type_only_arg(@'cdr', x, @'list');
if (ecl_unlikely(!LISTP(x)))
FEwrong_type_only_arg(@'car', x, @'list');
return1(Null(x)? x : ECL_CONS_CDR(x));
}
@(defun list (&rest args)
@ -236,19 +232,19 @@ ecl_append(cl_object x, cl_object y)
}
/* Open coded CARs and CDRs */
#define car(foo) \
foo; \
if (!LISTP(x)) goto E; \
#define car(foo) \
foo; \
if (ecl_unlikely(!LISTP(x))) goto E; \
if (!Null(x)) x = ECL_CONS_CAR(x);
#define cdr(foo) \
foo; \
if (!LISTP(x)) goto E; \
#define cdr(foo) \
foo; \
if (ecl_unlikely(!LISTP(x))) goto E; \
if (!Null(x)) x = ECL_CONS_CDR(x);
#define defcxr(name, arg, code) \
cl_object cl_##name(cl_object foo) { \
register cl_object arg = foo; \
code; return1(arg); \
E: FEwrong_type_only_arg(@'car',arg,@'list');}
#define defcxr(name, arg, code) \
cl_object cl_##name(cl_object foo) { \
register cl_object arg = foo; \
code; return1(arg); \
E: FEwrong_type_only_arg(@'car',arg,@'list');}
defcxr(caar, x, car(car(x)))
defcxr(cadr, x, car(cdr(x)))
@ -330,21 +326,24 @@ BEGIN:
cl_object
cl_endp(cl_object x)
{
if (Null(x))
@(return Ct);
if (LISTP(x))
@(return Cnil);
FEwrong_type_only_arg(@'endp', x, @'list');
cl_object output = Cnil;
if (Null(x)) {
output = Ct;
} else if (ecl_unlikely(!LISTP(x))) {
FEwrong_type_only_arg(@'endp', x, @'list');
}
@(return output);
}
bool
ecl_endp(cl_object x)
{
if (Null(x))
return(TRUE);
if (LISTP(x))
return(FALSE);
FEwrong_type_only_arg(@'endp', x, @'list');
if (Null(x)) {
return TRUE;
} else if (ecl_unlikely(!LISTP(x))) {
FEwrong_type_only_arg(@'endp', x, @'list');
}
return FALSE;
}
cl_object
@ -355,7 +354,7 @@ cl_list_length(cl_object x)
/* INV: A list's length always fits in a fixnum */
fast = slow = x;
for (n = 0; !Null(fast); n++, fast = ECL_CONS_CDR(fast)) {
if (!LISTP(fast)) {
if (ecl_unlikely(!LISTP(fast))) {
FEtype_error_list(fast);
}
if (n & 1) {
@ -459,7 +458,7 @@ cl_object
cl_copy_list(cl_object x)
{
cl_object copy;
if (!LISTP(x)) {
if (ecl_unlikely(!LISTP(x))) {
FEwrong_type_only_arg(@'copy-list', x, @'list');
}
copy = Cnil;
@ -488,7 +487,7 @@ cl_object
cl_copy_alist(cl_object x)
{
cl_object copy;
if (!LISTP(x)) {
if (ecl_unlikely(!LISTP(x))) {
FEwrong_type_only_arg(@'copy-alist', x, @'list');
}
copy = Cnil;
@ -625,7 +624,7 @@ cl_object
ecl_nbutlast(cl_object l, cl_index n)
{
cl_object r;
if (!LISTP(l))
if (ecl_unlikely(!LISTP(l)))
FEwrong_type_only_arg(@'nbutlast', l, @'list');
for (n++, r = l; n && CONSP(r); n--, r = ECL_CONS_CDR(r))
;
@ -654,7 +653,7 @@ cl_object
cl_ldiff(cl_object x, cl_object y)
{
cl_object head = Cnil;
if (!LISTP(x)) {
if (ecl_unlikely(!LISTP(x))) {
FEwrong_type_only_arg(@'ldiff', x, @'list');
}
/* Here we use that, if X or Y are CONS, then (EQL X Y)
@ -683,7 +682,7 @@ cl_ldiff(cl_object x, cl_object y)
cl_object
cl_rplaca(cl_object x, cl_object v)
{
if (!CONSP(x))
if (ecl_unlikely(!CONSP(x)))
FEwrong_type_nth_arg(@'rplaca', 1, x, @'cons');
ECL_RPLACA(x, v);
@(return x)
@ -692,7 +691,7 @@ cl_rplaca(cl_object x, cl_object v)
cl_object
cl_rplacd(cl_object x, cl_object v)
{
if (!CONSP(x))
if (ecl_unlikely(!CONSP(x)))
FEwrong_type_nth_arg(@'rplacd', 1, x, @'cons');
ECL_RPLACD(x, v);
@(return x)

View file

@ -39,7 +39,7 @@
cl_index i;
for (i = 0; i < narg; i++) {
cl_object cdr = ECL_STACK_FRAME_REF(cdrs_frame, i);
if (!LISTP(cdr))
if (ecl_unlikely(!LISTP(cdr)))
FEwrong_type_nth_arg(@'mapcar', i+2, cdr, @'list');
if (Null(cdr)) {
ecl_stack_frame_close(cars_frame);
@ -63,7 +63,7 @@
cl_index i;
for (i = 0; i < narg; i++) {
cl_object cdr = ECL_STACK_FRAME_REF(cdrs_frame, i);
if (!LISTP(cdr))
if (ecl_unlikely(!LISTP(cdr)))
FEwrong_type_nth_arg(@'maplist', i+2, cdr, @'list');
if (Null(cdr)) {
ecl_stack_frame_close(cars_frame);
@ -87,7 +87,7 @@
cl_index i;
for (i = 0; i < narg; i++) {
cl_object cdr = ECL_STACK_FRAME_REF(cdrs_frame, i);
if (!LISTP(cdr))
if (ecl_unlikely(!LISTP(cdr)))
FEwrong_type_nth_arg(@'mapc', i+2, cdr, @'list');
if (Null(cdr)) {
ecl_stack_frame_close(cars_frame);
@ -110,7 +110,7 @@
cl_index i;
for (i = 0; i < narg; i++) {
cl_object cdr = ECL_STACK_FRAME_REF(cdrs_frame, i);
if (!LISTP(cdr))
if (ecl_unlikely(!LISTP(cdr)))
FEwrong_type_nth_arg(@'mapl', i+2, cdr, @'list');
if (Null(cdr)) {
ecl_stack_frame_close(cars_frame);
@ -133,7 +133,7 @@
cl_index i;
for (i = 0; i < narg; i++) {
cl_object cdr = ECL_STACK_FRAME_REF(cdrs_frame, i);
if (!LISTP(cdr))
if (ecl_unlikely(!LISTP(cdr)))
FEwrong_type_nth_arg(@'mapcan', i+2, cdr, @'list');
if (Null(cdr)) {
ecl_stack_frame_close(cars_frame);
@ -158,7 +158,7 @@
cl_index i;
for (i = 0; i < narg; i++) {
cl_object cdr = ECL_STACK_FRAME_REF(cdrs_frame, i);
if (!LISTP(cdr))
if (ecl_unlikely(!LISTP(cdr)))
FEwrong_type_nth_arg(@'mapcon', i+2, cdr, @'list');
if (Null(cdr)) {
ecl_stack_frame_close(cars_frame);

View file

@ -192,7 +192,7 @@ ecl_floor2(cl_object x, cl_object y)
cl_object v0, v1;
cl_type ty;
ty = type_of(y);
if (!ECL_NUMBER_TYPE_P(ty)) {
if (ecl_unlikely(!ECL_NUMBER_TYPE_P(ty))) {
FEwrong_type_nth_arg(@'floor',2,y,@'real');
}
switch(type_of(x)) {
@ -446,7 +446,7 @@ ecl_ceiling2(cl_object x, cl_object y)
cl_object v0, v1;
cl_type ty;
ty = type_of(y);
if (!ECL_NUMBER_TYPE_P(ty)) {
if (ecl_unlikely(!ECL_NUMBER_TYPE_P(ty))) {
FEwrong_type_nth_arg(@'ceiling',2, y, @'real');
}
switch(type_of(x)) {
@ -962,7 +962,7 @@ cl_object
cl_float_radix(cl_object x)
{
const cl_env_ptr the_env = ecl_process_env();
if (cl_floatp(x) != Ct) {
if (ecl_unlikely(cl_floatp(x) != Ct)) {
FEwrong_type_nth_arg(@'float-radix',1,x,@'float');
}
@(return MAKE_FIXNUM(FLT_RADIX))

View file

@ -223,7 +223,7 @@ ecl_make_random_state(cl_object rs)
if (Null(rs)) {
rs = ecl_symbol_value(@'*random-state*');
}
if (type_of(rs) != t_random) {
if (ecl_unlikely(type_of(rs) != t_random)) {
FEwrong_type_only_arg(@'make-random-state', rs,
@'random-state');
}

View file

@ -158,11 +158,11 @@ cl_expt(cl_object x, cl_object y)
cl_type ty, tx;
cl_object z;
ty = type_of(y);
if (!ECL_NUMBER_TYPE_P(ty)) {
if (ecl_unlikely(!ECL_NUMBER_TYPE_P(ty))) {
FEwrong_type_nth_arg(@'expt', 2, y, @'number');
}
tx = type_of(x);
if (!ECL_NUMBER_TYPE_P(tx)) {
if (ecl_unlikely(!ECL_NUMBER_TYPE_P(tx))) {
FEwrong_type_nth_arg(@'expt', 2, x, @'number');
}
if (ecl_zerop(y)) {
@ -401,7 +401,7 @@ cl_sqrt(cl_object x)
cl_type tx;
ECL_MATHERR_CLEAR;
tx = type_of(x);
if (!ECL_NUMBER_TYPE_P(tx)) {
if (ecl_unlikely(!ECL_NUMBER_TYPE_P(tx))) {
FEwrong_type_only_arg(@'sqrt', x, @'number');
}
if (tx == t_complex) {

View file

@ -305,7 +305,7 @@ ecl_intern(cl_object name, cl_object p, int *intern_flag)
{
cl_object s, ul;
if (!ECL_STRINGP(name))
if (ecl_unlikely(!ECL_STRINGP(name)))
FEwrong_type_nth_arg(@'intern', 1, name, @'string');
p = si_coerce_to_package(p);
TRY_AGAIN_LABEL:
@ -376,7 +376,7 @@ find_symbol_inner(cl_object name, cl_object p, int *intern_flag)
cl_object
ecl_find_symbol(cl_object n, cl_object p, int *intern_flag)
{
if (!ECL_STRINGP(n))
if (ecl_unlikely(!ECL_STRINGP(n)))
FEwrong_type_nth_arg(@'find-symbol', 1, n, @'string');
p = si_coerce_to_package(p);
return find_symbol_inner(n, p, intern_flag);
@ -975,7 +975,7 @@ si_package_hash_tables(cl_object p)
{
const cl_env_ptr the_env = ecl_process_env();
cl_object he, hi, u;
if (type_of(p) != t_package)
if (ecl_unlikely(type_of(p) != t_package))
FEwrong_type_only_arg(@'si::package-hash-tables', p, @'package');
PACKAGE_OP_LOCK();
he = si_copy_hash_table(p->pack.external);

View file

@ -1387,7 +1387,7 @@ coerce_to_from_pathname(cl_object x, cl_object host)
cl_object pair, l;
@
/* Check that host is a valid host name */
if (!ECL_STRINGP(host))
if (ecl_unlikely(!ECL_STRINGP(host)))
FEwrong_type_nth_arg(@'si::pathname-translations', 1, host, @'string');
len = ecl_length(host);
parse_word(host, is_null, WORD_LOGICAL, 0, len, &parsed_len);
@ -1400,7 +1400,7 @@ coerce_to_from_pathname(cl_object x, cl_object host)
@(return ((pair == Cnil)? Cnil : CADR(pair)));
}
/* Set the new translation list */
if (!LISTP(set)) {
if (ecl_unlikely(!LISTP(set))) {
FEwrong_type_nth_arg(@'si::pathname-translations', 2, set, @'list');
}
if (pair == Cnil) {

View file

@ -1904,7 +1904,7 @@ potential_number_p(cl_object strng, int base)
@(defun write-string (strng &o strm &k (start MAKE_FIXNUM(0)) end)
@
if (!ECL_STRINGP(strng))
if (ecl_unlikely(!ECL_STRINGP(strng)))
FEwrong_type_nth_arg(@'write-string', 1, strng, @'string');
strm = stream_or_default_output(strm);
#ifdef ECL_CLOS_STREAMS
@ -1918,7 +1918,7 @@ potential_number_p(cl_object strng, int base)
@(defun write-line (strng &o strm &k (start MAKE_FIXNUM(0)) end)
@
if (!ECL_STRINGP(strng))
if (ecl_unlikely(!ECL_STRINGP(strng)))
FEwrong_type_nth_arg(@'write-line', 1, strng, @'string');
strm = stream_or_default_output(strm);
#ifdef ECL_CLOS_STREAMS

View file

@ -1427,7 +1427,7 @@ sharp_dollar_reader(cl_object in, cl_object c, cl_object d)
static void
assert_type_readtable(cl_object function, cl_narg narg, cl_object p)
{
if (type_of(p) != t_readtable)
if (ecl_unlikely(type_of(p) != t_readtable))
FEwrong_type_nth_arg(function, narg, p, @'readtable');
}
@ -1805,11 +1805,11 @@ EOFCHK: if (c == EOF && TOKEN_STRING_FILLP(token) == 0) {
cl_index s, e, ep;
cl_object rtbl = ecl_current_readtable();
@ {
if (!ECL_STRINGP(strng))
if (ecl_unlikely(!ECL_STRINGP(strng)))
FEwrong_type_nth_arg(@'parse-integer', 1, strng, @'string');
get_string_start_end(strng, start, end, &s, &e);
if (!FIXNUMP(radix) ||
fix(radix) < 2 || fix(radix) > 36)
if (ecl_unlikely(!FIXNUMP(radix) ||
fix(radix) < 2 || fix(radix) > 36))
FEerror("~S is an illegal radix.", 1, radix);
while (s < e &&
ecl_readtable_get(rtbl, ecl_char(strng, s), NULL) == cat_whitespace) {

View file

@ -131,12 +131,13 @@ cl_symbol_value(cl_object sym)
if (Null(sym)) {
value = sym;
} else {
if (!SYMBOLP(sym)) {
if (ecl_unlikely(!SYMBOLP(sym))) {
FEwrong_type_only_arg(@'symbol-value', sym, @'symbol');
}
value = ECL_SYM_VAL(the_env, sym);
if (value == OBJNULL)
if (ecl_unlikely(value == OBJNULL)) {
FEunbound_variable(sym);
}
}
@(return value)
}
@ -147,7 +148,7 @@ ecl_boundp(cl_env_ptr env, cl_object sym)
if (Null(sym)) {
return 1;
} else {
if (!SYMBOLP(sym))
if (ecl_unlikely(!SYMBOLP(sym)))
FEwrong_type_only_arg(@'boundp', sym, @'symbol');
return ECL_SYM_VAL(env, sym) != OBJNULL;
}

View file

@ -865,7 +865,7 @@ nstring_case(cl_narg narg, cl_object fun, ecl_casefun casefun, cl_va_list ARGS)
KEYS[1]=@':end';
cl_parse_key(ARGS, 2, KEYS, KEY_VARS, NULL, FALSE);
if (!ECL_STRINGP(strng))
if (ecl_unlikely(!ECL_STRINGP(strng)))
FEwrong_type_nth_arg(fun, 1, strng, @'string');
if (startp == Cnil) start = MAKE_FIXNUM(0);
get_string_start_end(strng, start, end, &s, &e);

View file

@ -91,7 +91,7 @@ ecl_copy_structure(cl_object x)
cl_index j, size;
cl_object y;
if (!si_structurep(x))
if (ecl_unlikely(Null(si_structurep(x))))
FEwrong_type_only_arg(@'copy-structure', x, @'structure');
y = ecl_alloc_object(T_STRUCTURE);
STYPE(y) = STYPE(x);
@ -134,7 +134,7 @@ cl_copy_structure(cl_object s)
cl_object
si_structure_name(cl_object s)
{
if (!si_structurep(s))
if (ecl_unlikely(Null(si_structurep(s))))
FEwrong_type_only_arg(@'si::structure-name', s, @'structure');
@(return SNAME(s))
}
@ -142,8 +142,8 @@ si_structure_name(cl_object s)
cl_object
si_structure_ref(cl_object x, cl_object type, cl_object index)
{
if (type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type))
if (ecl_unlikely(type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type)))
FEwrong_type_nth_arg(@'si::structure-ref', 1, x, type);
@(return SLOT(x, fix(index)))
}
@ -152,8 +152,8 @@ cl_object
ecl_structure_ref(cl_object x, cl_object type, int n)
{
if (type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type))
if (ecl_unlikely(type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type)))
FEwrong_type_nth_arg(@'si::structure-ref', 1, x, type);
return(SLOT(x, n));
}
@ -161,8 +161,8 @@ ecl_structure_ref(cl_object x, cl_object type, int n)
cl_object
si_structure_set(cl_object x, cl_object type, cl_object index, cl_object val)
{
if (type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type))
if (ecl_unlikely(type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type)))
FEwrong_type_nth_arg(@'si::structure-set', 1, x, type);
SLOT(x, fix(index)) = val;
@(return val)
@ -172,8 +172,8 @@ cl_object
ecl_structure_set(cl_object x, cl_object type, int n, cl_object v)
{
if (type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type))
if (ecl_unlikely(type_of(x) != T_STRUCTURE ||
!structure_subtypep(STYPE(x), type)))
FEwrong_type_nth_arg(@'si::structure-set', 1, x, type);
SLOT(x, n) = v;
return(v);

View file

@ -358,7 +358,7 @@ cl_symbol_name(cl_object x)
cl_object output, s;
int intern_flag;
@
if (!ECL_STRINGP(prefix))
if (ecl_unlikely(!ECL_STRINGP(prefix)))
FEwrong_type_nth_arg(@'gentemp', 1, prefix, @'string');
pack = si_coerce_to_package(pack);
ONCE_MORE:

View file

@ -323,7 +323,7 @@ si_open_unix_socket_stream(cl_object path)
cl_object stream;
struct sockaddr_un addr;
if (type_of(path) != t_base_string)
if (ecl_unlikely(type_of(path) != t_base_string))
FEwrong_type_nth_arg(@'si::open-unix-socket-stream', 1, path,
@'string');
if (path->base_string.fillp > UNIX_MAX_PATH-1)

View file

@ -610,17 +610,17 @@ mp_condition_variable_wait(cl_object cv, cl_object lock)
#else
int count, rc;
cl_object own_process = mp_current_process();
if (type_of(cv) != t_condition_variable)
if (ecl_unlikely(type_of(cv) != t_condition_variable))
FEwrong_type_nth_arg(@'mp::condition-variable-wait', 1, cv,
@'mp::condition-variable');
if (type_of(lock) != t_lock)
if (ecl_unlikely(type_of(lock) != t_lock))
FEwrong_type_nth_arg(@'mp::condition-variable-wait', 2, lock,
@'mp::lock');
if (lock->lock.holder != own_process) {
if (ecl_unlikely(lock->lock.holder != own_process)) {
FEerror("Attempt to wait on a condition variable using lock~%~S"
"~%which is not owned by process~%~S", 2, lock, own_process);
}
if (lock->lock.counter > 1) {
if (ecl_unlikely(lock->lock.counter > 1)) {
FEerror("mp:condition-variable-wait can not be used with recursive"
" locks:~%~S", 1, lock);
}
@ -632,7 +632,7 @@ mp_condition_variable_wait(cl_object cv, cl_object lock)
&lock->lock.mutex);
lock->lock.holder = own_process;
lock->lock.counter = 1;
if (rc != 0) {
if (ecl_unlikely(rc != 0)) {
FEerror("System returned error code ~D "
"when waiting on condition variable~%~A~%and lock~%~A.",
3, MAKE_FIXNUM(rc), cv, lock);
@ -653,26 +653,27 @@ mp_condition_variable_timedwait(cl_object cv, cl_object lock, cl_object seconds)
struct timespec ts;
struct timeval tp;
if (type_of(cv) != t_condition_variable)
if (ecl_unlikely(type_of(cv) != t_condition_variable))
FEwrong_type_nth_arg(@'mp::condition-variable-timedwait',
1, cv, @'mp::condition-variable');
if (type_of(lock) != t_lock)
if (ecl_unlikely(type_of(lock) != t_lock))
FEwrong_type_nth_arg(@'mp::condition-variable-timedwait',
2, lock, @'mp::lock');
if (lock->lock.holder != own_process) {
if (ecl_unlikely(lock->lock.holder != own_process)) {
FEerror("Attempt to wait on a condition variable using lock~%~S"
"~%which is not owned by process~%~S", 2, lock, own_process);
}
if (lock->lock.counter > 1) {
if (ecl_unlikely(lock->lock.counter > 1)) {
FEerror("mp:condition-variable-wait can not be used with recursive"
" locks:~%~S", 1, lock);
}
/* INV: ecl_minusp() makes sure `seconds' is real */
if (ecl_minusp(seconds))
if (ecl_unlikely(ecl_minusp(seconds))) {
cl_error(9, @'simple-type-error', @':format-control',
make_constant_base_string("Not a non-negative number ~S"),
@':format-arguments', cl_list(1, seconds),
@':expected-type', @'real', @':datum', seconds);
}
gettimeofday(&tp, NULL);
/* Convert from timeval to timespec */
ts.tv_sec = tp.tv_sec;
@ -709,9 +710,10 @@ mp_condition_variable_signal(cl_object cv)
#ifdef ECL_WINDOWS_THREADS
FEerror("Condition variables are not supported under Windows.", 0);
#else
if (type_of(cv) != t_condition_variable)
if (ecl_unlikely(type_of(cv) != t_condition_variable)) {
FEwrong_type_only_arg(@'mp::condition-variable-signal',
cv, @'mp::condition-variable');
}
pthread_cond_signal(&cv->condition_variable.cv);
#endif
@(return Ct)
@ -723,9 +725,10 @@ mp_condition_variable_broadcast(cl_object cv)
#ifdef ECL_WINDOWS_THREADS
FEerror("Condition variables are not supported under Windows.", 0);
#else
if (type_of(cv) != t_condition_variable)
if (ecl_unlikely(type_of(cv) != t_condition_variable)) {
FEwrong_type_only_arg(@'mp::condition-variable-broadcast',
cv, @'mp::condition-variable');
}
pthread_cond_broadcast(&cv->condition_variable.cv);
#endif
@(return Ct)
@ -790,8 +793,9 @@ cl_object
mp_semaphore_trywait(cl_object sem)
{
cl_object output;
if (typeof(sem) != t_semaphore)
if (ecl_unlikely(typeof(sem) != t_semaphore)) {
FEwrong_type_only_arg(@'mp::semaphore-trywait', sem, @'mp::semaphore');
}
AGAIN:
#ifdef ECL_WINDOWS_THREADS
{
@ -832,8 +836,9 @@ cl_object
mp_semaphore_wait(cl_object sem)
{
cl_object output;
if (typeof(sem) != t_semaphore)
if (ecl_unlikely(typeof(sem) != t_semaphore)) {
FEwrong_type_only_arg(@'mp::semaphore-wait', sem, @'mp::semaphore');
}
AGAIN:
#ifdef ECL_WINDOWS_THREADS
{
@ -863,8 +868,9 @@ mp_semaphore_wait(cl_object sem)
cl_object
mp_semaphore_signal(cl_object sem)
{
if (typeof(sem) != t_semaphore)
if (ecl_unlikely(typeof(sem) != t_semaphore)) {
FEwrong_type_only_arg(@'mp::semaphore-signal', sem, @'mp::semaphore');
}
AGAIN:
#ifdef ECL_WINDOWS_THREADS
{
@ -894,8 +900,9 @@ mp_semaphore_signal(cl_object sem)
cl_object
mp_semaphore_close(cl_object sem)
{
if (typeof(sem) != t_semaphore)
if (ecl_unlikely(typeof(sem) != t_semaphore)) {
FEwrong_type_only_arg(@'mp::semaphore-close', sem, @'mp::semaphore');
}
#ifdef ECL_WINDOWS_THREADS
{
HANDLE h = (HANDLE)(sem->semaphore.handle);