Make 'likely' macro available in all of Emacs (bug#81115)

* src/android.c (likely): Move ...
* src/conf_post.h (likely): ... here.  Ensure true values which aren't
equal to 1 are still predicted correctly.
This commit is contained in:
Pip Cet 2026-05-31 06:24:58 +00:00
parent 35f69be393
commit 0f6c382888
2 changed files with 5 additions and 2 deletions

View file

@ -6158,8 +6158,6 @@ android_build_jstring (const char *text)
if global_foo cannot be allocated, and after the global reference
is created. */
#define likely(cond) __builtin_expect (cond, 1)
/* Check for JNI exceptions and call memory_full in that
situation. */

View file

@ -371,6 +371,11 @@ extern int emacs_setenv_TZ (char const *);
# define UNINIT /* empty */
#endif
/* likely (COND) is equivalent to COND ? 1 : 0, but instructs the
compiler to provide static branch prediction hints to the CPU so that
the branch isn't mispredicted. */
#define likely(cond) __builtin_expect (!!(cond), 1)
/* Emacs needs neither glibc strftime behavior for AM and PM indicators,
nor Gnulib strftime support for non-Gregorian calendars. */
#define REQUIRE_GNUISH_STRFTIME_AM_PM false