diff --git a/centrallix-lib/aclocal.m4 b/centrallix-lib/aclocal.m4 index cd74b27b2..279b7291d 100644 --- a/centrallix-lib/aclocal.m4 +++ b/centrallix-lib/aclocal.m4 @@ -47,7 +47,7 @@ AC_DEFUN(CHECK_BUILTIN_EXPECT, AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define if __builtin_expect is available]) AC_MSG_RESULT([yes]) ], - [AC_MSG_RESULT([no])], + [AC_MSG_RESULT([no])] ) ] ) diff --git a/centrallix-lib/configure b/centrallix-lib/configure index 4995f514f..c8c03668c 100755 --- a/centrallix-lib/configure +++ b/centrallix-lib/configure @@ -4104,6 +4104,7 @@ $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext diff --git a/centrallix-lib/include/cxlibconfig-internal.h.in b/centrallix-lib/include/cxlibconfig-internal.h.in index 6649e4478..7074db4ee 100644 --- a/centrallix-lib/include/cxlibconfig-internal.h.in +++ b/centrallix-lib/include/cxlibconfig-internal.h.in @@ -1,5 +1,10 @@ /* include/cxlibconfig-internal.h.in. Generated from configure.ac by autoheader. */ +/*** cxlibconfig-internal.h.in lists defines that are used by centrallix-lib + *** internally and will not be needed in other modules. For external + *** usecases, see cxlibconfig.h.in. + ***/ + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT @@ -34,4 +39,3 @@ /* defined to 1 if SIOCOUTQ is available */ #undef HAVE_SIOCOUTQ - diff --git a/centrallix-lib/include/cxlibconfig.h.in b/centrallix-lib/include/cxlibconfig.h.in index dc6b3ad29..d1fc408fa 100644 --- a/centrallix-lib/include/cxlibconfig.h.in +++ b/centrallix-lib/include/cxlibconfig.h.in @@ -1,5 +1,11 @@ /* include/cxlibconfig.h.in. Generated from configure.ac by autoheader. */ +/*** cxlibconfig-h.in lists defines that should be availabe to anyone + *** using centrallix-lib. For example, a define used in an external .h + *** file should be written here so that the .h file can include it even + *** if it is used in another project. + ***/ + /* Define to 1 if you have the `endservent' function. */ #undef HAVE_ENDSERVENT @@ -33,6 +39,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `__builtin_expect' function. */ +#undef HAVE_BUILTIN_EXPECT + /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP diff --git a/centrallix-lib/include/expect.h b/centrallix-lib/include/expect.h index 7f859213b..03db37ab3 100644 --- a/centrallix-lib/include/expect.h +++ b/centrallix-lib/include/expect.h @@ -11,7 +11,7 @@ /* GNU Lesser General Public License, Version 2.1, contained in the */ /* included file "COPYING". */ /* */ -/* Module: Expect Branch Optimization Module (mtask.c, mtask.h) */ +/* Module: Expect Branch Optimization Module (expect.h) */ /* Author: Israel Fuller */ /* Date: February 27th, 2026 */ /* */ @@ -23,19 +23,26 @@ /* true, UNLIKELY() indicates it is likely to be false. */ /************************************************************************/ +#ifdef HAVE_CONFIG_H + #ifdef CXLIB_INTERNAL + #include "cxlibconfig.h" + #else + #include "cxlib/cxlibconfig.h" + #endif +#endif /** Define macros for signalling the more likely branch to the compiler. **/ #ifdef HAVE_BUILTIN_EXPECT -/** Use the GCC __builtin_expect() function for optimization. **/ -/** Note: We use !!(x) which normalizes to 0 or 1 to help the compiler. **/ -#define LIKELY(x) (__builtin_expect(!!(x), 1)) -#define UNLIKELY(x) (__builtin_expect(!!(x), 0)) + /** Use the GCC __builtin_expect() function for optimization. **/ + /** Note: We use !!(x) which normalizes to 0 or 1 to help the compiler. **/ + #define LIKELY(x) (__builtin_expect(!!(x), 1)) + #define UNLIKELY(x) (__builtin_expect(!!(x), 0)) #else -/*** Fallback: Define pass through functions to support compilers that don't - *** have this feature. - ***/ -#define LIKELY(x) (x) -#define UNLIKELY(x) (x) + /*** Fallback: Define pass through functions to support compilers that don't + *** have this feature. + ***/ + #define LIKELY(x) (x) + #define UNLIKELY(x) (x) #endif #endif diff --git a/centrallix/aclocal.m4 b/centrallix/aclocal.m4 index 3b8716131..9f0905c91 100644 --- a/centrallix/aclocal.m4 +++ b/centrallix/aclocal.m4 @@ -1173,21 +1173,6 @@ AC_DEFUN(CHECK_COVERAGE, ] ) -dnl check if gcc allows __builtin_expect() -AC_DEFUN(CHECK_BUILTIN_EXPECT, - [ - AC_MSG_CHECKING(if __builtin_expect is available) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], [__builtin_expect(0, 0)])], - [ - AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define if __builtin_expect is available]) - AC_MSG_RESULT([yes]) - ], - [AC_MSG_RESULT([no])], - ) - ] -) - dnl check if gcc allows -fPIC and -pg at the same time AC_DEFUN(CHECK_PROFILE, [ diff --git a/centrallix/config.h.in b/centrallix/config.h.in index a40a4e6a0..8abbefb32 100644 --- a/centrallix/config.h.in +++ b/centrallix/config.h.in @@ -12,9 +12,6 @@ /* Define to 1 if you have the `basename' function. */ #undef HAVE_BASENAME -/* Define if __builtin_expect is available */ -#undef HAVE_BUILTIN_EXPECT - /* Whether __ctype_b is present and usable */ #undef HAVE_CTYPE_B diff --git a/centrallix/configure b/centrallix/configure index adf0045a8..d8c30ba8f 100755 --- a/centrallix/configure +++ b/centrallix/configure @@ -5807,36 +5807,6 @@ $as_echo "#define HAVE_NCURSES 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if __builtin_expect is available" >&5 -$as_echo_n "checking if __builtin_expect is available... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -__builtin_expect(0, 0) - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - -$as_echo "#define HAVE_BUILTIN_EXPECT 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - - - has_ctype_b="test" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if __ctype_b is present and usable" >&5 diff --git a/centrallix/configure.ac b/centrallix/configure.ac index c96525983..fe58222e3 100644 --- a/centrallix/configure.ac +++ b/centrallix/configure.ac @@ -92,9 +92,6 @@ CENTRALLIX_CHECK_SQLITE dnl Check for ncurses CENTRALLIX_CHECK_NCURSES -dnl Check for __builtin_expect() -CHECK_BUILTIN_EXPECT - dnl Check for __ctype_b AH_TEMPLATE([HAVE_CTYPE_B], [Whether __ctype_b is present and usable]) CHECK_CTYPE_B