This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Document LIKELY, UNLIKELY
authorKarl Williamson <khw@cpan.org>
Mon, 5 Aug 2019 00:14:43 +0000 (18:14 -0600)
committerKarl Williamson <khw@cpan.org>
Tue, 3 Sep 2019 03:52:10 +0000 (21:52 -0600)
perl.h

diff --git a/perl.h b/perl.h
index 746ce98..937ad17 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3514,8 +3514,25 @@ EXTERN_C int perl_tsa_mutex_unlock(perl_mutex* mutex)
 #else
 #  define EXPECT(expr,val)                  (expr)
 #endif
+
+/*
+=head1 Miscellaneous Functions
+
+=for apidoc AmU|bool|LIKELY|const bool expr
+
+Returns the input unchanged, but at the same time it gives a branch prediction
+hint to the compiler that this condition is likely to be true.
+
+=for apidoc AmU|bool|UNLIKELY|const bool expr
+
+Returns the input unchanged, but at the same time it gives a branch prediction
+hint to the compiler that this condition is likely to be false.
+
+=cut
+*/
 #define LIKELY(cond)                        EXPECT(cBOOL(cond),TRUE)
 #define UNLIKELY(cond)                      EXPECT(cBOOL(cond),FALSE)
+
 #ifdef HAS_BUILTIN_CHOOSE_EXPR
 /* placeholder */
 #endif