ecl_disable_interrupts_env(the_env);
lb = type_info->size + TYPD_EXTRA_BYTES;
- if (__builtin_expect(SMALL_OBJ(lb),1)) {
+ if (ecl_likely(SMALL_OBJ(lb))) {
lg = GC_size_map[lb];
opp = &(cl_object_free_list[lg]);
LOCK();
{
#if 1
cl_type t = ((cl_object)addr)->d.t;
- if (__builtin_expect(t > t_start && t < t_end, 1)) {
+ if (ecl_likely(t > t_start && t < t_end)) {
struct ecl_type_information *info = type_info + t;
GC_word d = info->descriptor;
GC_word *p;
{
#ifdef GBC_BOEHM_PRECISE
struct ecl_type_information *ti;
- if (__builtin_expect(t > t_start && t < t_end, 1)) {
+ if (ecl_likely(t > t_start && t < t_end)) {
ti = type_info + t;
return ti->allocator(ti);
}
cf->cfunfixed.file = Cnil;
cf->cfunfixed.file_position = MAKE_FIXNUM(-1);
cf->cfunfixed.narg = narg;
- if (__builtin_expect(narg < 0 || narg > C_ARGUMENTS_LIMIT, 0))
+ if (ecl_unlikely(narg < 0 || narg > C_ARGUMENTS_LIMIT))
FEprogram_error_noreturn("ecl_make_cfun: function requires "
"too many arguments.",0);
return cf;
for (; args[0].narg > 1; ) {
cl_object keyword = cl_va_arg(args);
cl_object value = cl_va_arg(args);
- if (__builtin_expect(!SYMBOLP(keyword), 0))
+ if (ecl_unlikely(!SYMBOLP(keyword)))
FEprogram_error_noreturn("LAMBDA: Keyword expected, got ~S.",
1, keyword);
if (rest != NULL) {
unknown_keyword = keyword;
goon:;
}
- if (__builtin_expect(args[0].narg != 0, 0))
+ if (ecl_unlikely(args[0].narg != 0))
FEprogram_error_noreturn("Odd number of keys", 0);
- if (__builtin_expect(unknown_keyword != OBJNULL && !allow_other_keys &&
- (supplied_allow_other_keys == Cnil ||
- supplied_allow_other_keys == OBJNULL), 0))
+ if (ecl_unlikely(unknown_keyword != OBJNULL && !allow_other_keys &&
+ (supplied_allow_other_keys == Cnil ||
+ supplied_allow_other_keys == OBJNULL)))
FEprogram_error("Unknown keyword ~S", 1, unknown_keyword);
}
static void
asm_op2(cl_env_ptr env, int code, int n) {
- if (__builtin_expect(n < -MAX_OPARG || MAX_OPARG < n, 0))
+ if (ecl_unlikely(n < -MAX_OPARG || MAX_OPARG < n))
FEprogram_error_noreturn("Argument to bytecode is too large", 0);
asm_op(env, code);
asm_arg(env, n);
static void
asm_complete(cl_env_ptr env, int op, cl_index pc) {
cl_fixnum delta = current_pc(env) - pc; /* [1] */
- if (__builtin_expect(op && (asm_ref(env, pc-1) != op), 0))
+ if (ecl_unlikely(op && (asm_ref(env, pc-1) != op)))
FEprogram_error_noreturn("Non matching codes in ASM-COMPLETE2", 0);
- else if (__builtin_expect(delta < -MAX_OPARG || delta > MAX_OPARG, 0))
+ else if (ecl_unlikely(delta < -MAX_OPARG || delta > MAX_OPARG))
FEprogram_error_noreturn("Too large jump", 0);
else {
#ifdef ECL_SMALL_BYTECODES
}
if (nopt == 0 && !rest_flag && !key_flag) {
put_lineno();
- fprintf(out, "\tif (__builtin_expect(narg!=%d,0)) FEwrong_num_arguments(MAKE_FIXNUM(%d));\n", nreq, function_code);
+ fprintf(out, "\tif (ecl_unlikely(narg!=%d))");
+ fprintf(out, "\t FEwrong_num_arguments(MAKE_FIXNUM(%d));\n",
+ nreq, function_code);
} else {
simple_varargs = !rest_flag && !key_flag && ((nreq + nopt) < 32);
if (key_flag) {
rest_var, rest_var, ((nreq > 0) ? required[nreq-1] : "narg"),
nreq);
put_lineno();
- fprintf(out, "\tif (__builtin_expect(narg < %d", nreq);
+ fprintf(out, "\tif (ecl_unlikely(narg < %d", nreq);
if (nopt > 0 && !rest_flag && !key_flag) {
fprintf(out, "|| narg > %d", nreq + nopt);
}
- fprintf(out, ",0)) FEwrong_num_arguments(MAKE_FIXNUM(%d));\n", function_code);
+ fprintf(out, ")) FEwrong_num_arguments(MAKE_FIXNUM(%d));\n", function_code);
for (i = 0; i < nopt; i++) {
put_lineno();
fprintf(out, "\tif (narg > %d) {\n", nreq+i);
cl_object fun = x;
AGAIN:
frame->frame.env->function = fun;
- if (__builtin_expect(fun == OBJNULL || fun == Cnil, 0))
+ if (ecl_unlikely(fun == OBJNULL || fun == Cnil))
FEundefined_function(x);
switch (type_of(fun)) {
case t_cfunfixed:
- if (__builtin_expect(narg != (cl_index)fun->cfun.narg, 0))
+ if (ecl_unlikely(narg != (cl_index)fun->cfun.narg))
FEwrong_num_arguments(fun);
return APPLY_fixed(narg, fun->cfunfixed.entry_fixed, sp);
case t_cfun:
goto AGAIN;
#endif
case t_symbol:
- if (__builtin_expect(fun->symbol.stype & stp_macro, 0))
+ if (ecl_unlikely(fun->symbol.stype & stp_macro))
FEundefined_function(x);
fun = SYM_FUN(fun);
goto AGAIN;
{
cl_object fun = x;
AGAIN:
- if (__builtin_expect(fun == OBJNULL || fun == Cnil, 0))
+ if (ecl_unlikely(fun == OBJNULL || fun == Cnil))
FEundefined_function(x);
switch (type_of(fun)) {
case t_cfunfixed:
return fun->instance.entry;
#endif
case t_symbol:
- if (__builtin_expect(fun->symbol.stype & stp_macro, 0))
+ if (ecl_unlikely(fun->symbol.stype & stp_macro))
FEundefined_function(x);
fun = SYM_FUN(fun);
goto AGAIN;
ecl_stack_frame_push(frame, lastarg->frame.base[i]);
}
} else loop_for_in (lastarg) {
- if (__builtin_expect(i >= CALL_ARGUMENTS_LIMIT, 0)) {
+ if (ecl_unlikely(i >= CALL_ARGUMENTS_LIMIT)) {
ecl_stack_frame_close(frame);
FEprogram_error_noreturn("CALL-ARGUMENTS-LIMIT exceeded",0);
}
when_macro(cl_object whole, cl_object env)
{
cl_object args = CDR(whole);
- if (__builtin_expect(ecl_endp(args), 0))
+ if (ecl_unlikely(ecl_endp(args)))
FEprogram_error_noreturn("Syntax error: ~S.", 1, whole);
return cl_list(3, @'if', CAR(args), CONS(@'progn', CDR(args)));
}
ECL_STACK_FRAME_FROM_VA_LIST(env,cdrs_frame,list); \
ECL_STACK_FRAME_COPY(cars_frame, cdrs_frame); \
narg = cars_frame->frame.size; \
- if (__builtin_expect(narg == 0, 0)) { \
+ if (ecl_unlikely(narg == 0)) { \
FEprogram_error_noreturn("MAP*: Too few arguments", 0); \
}
(unless (or local-entry-p (not (compiler-check-args)))
(incf *inline-blocks*)
(if (and use-narg (not varargs))
- (wt-nl "if (__builtin_expect(narg!=" nreq ",0)) FEwrong_num_arguments_anonym();")
+ (wt-nl "if (ecl_unlikely(narg!=" nreq ")) FEwrong_num_arguments_anonym();")
(when varargs
(when requireds
- (wt-nl "if (__builtin_expect(narg<" nreq ",0)) FEwrong_num_arguments_anonym();"))
+ (wt-nl "if (ecl_unlikely(narg<" nreq ")) FEwrong_num_arguments_anonym();"))
(unless (or rest keywords allow-other-keys)
- (wt-nl "if (__builtin_expect(narg>" (+ nreq nopt) ",0)) FEwrong_num_arguments_anonym();"))))
+ (wt-nl "if (ecl_unlikely(narg>" (+ nreq nopt) ")) FEwrong_num_arguments_anonym();"))))
(wt-nl "{"))
;; If the number of required arguments exceeds the number of variables we
#include <ecl/unify.h>
#endif
-#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
-#define ECL_INLINE inline
-#else
-#define ECL_INLINE
-#endif
-#if !defined(__GNUC__)
-# define __builtin_expect(form,value) (form)
-#else
-# if (__GNUC__ < 3)
-# define __builtin_expect(form,value) (form)
-# endif
-#endif
-
typedef void (*ecl_init_function_t)(cl_object block);
#endif /* ECL_H */
#define _ARGS(x) x
+#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#define ECL_INLINE inline
+#else
+#define ECL_INLINE
+#endif
+#if !defined(__GNUC__)
+# define ecl_likely(form) (form)
+# define ecl_unlikely(form) (form)
+#else
+# if (__GNUC__ < 3)
+# define ecl_likely(form) (form)
+# define ecl_unlikely(form) (form)
+# else
+# define ecl_likely(form) __builtin_expect(form,1)
+# define ecl_unlikely(form) __builtin_expect(form,0)
+# endif
+#endif
+
/*
* Per-thread data.
*/