Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion centrallix-lib/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])]
)
]
)
Expand Down
1 change: 1 addition & 0 deletions centrallix-lib/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion centrallix-lib/include/cxlibconfig-internal.h.in
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -34,4 +39,3 @@

/* defined to 1 if SIOCOUTQ is available */
#undef HAVE_SIOCOUTQ

9 changes: 9 additions & 0 deletions centrallix-lib/include/cxlibconfig.h.in
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -33,6 +39,9 @@
/* Define to 1 if you have the <stdlib.h> 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

Expand Down
27 changes: 17 additions & 10 deletions centrallix-lib/include/expect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/* */
Expand All @@ -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
15 changes: 0 additions & 15 deletions centrallix/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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,
[
Expand Down
3 changes: 0 additions & 3 deletions centrallix/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 0 additions & 30 deletions centrallix/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions centrallix/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down