eo_base_class: move shift init to the first call
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Thu, 31 Oct 2019 16:48:27 +0000 (12:48 -0400)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 11 Nov 2019 02:20:41 +0000 (11:20 +0900)
Summary:
this cannot be evalulated in compile time, so this must be evalulated in
runtime, at the first call.

This should fix OSX build.

Co-authored-by: Cedric Bail <cedric.bail@free.fr>
Reviewers: zmike, cedric, raster

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10582

src/lib/eo/eo_base_class.c

index 39da0e8..43068c7 100644 (file)
@@ -1230,7 +1230,12 @@ _efl_pending_future_new(void)
 static inline unsigned char
 _pointer_hash(const uintptr_t val)
 {
-   static const unsigned char shift = (unsigned char) log2(1 + sizeof (Efl_Event_Description));
+   static unsigned char shift = 0;
+
+   /* Sadly LLVM doesn't have log2 in its compile time optimization. So
+      we can not use static const here for portability sake. */
+   if (EINA_UNLIKELY((!shift)))
+     shift = (unsigned char) log2(1 + sizeof (Efl_Event_Description));
 #ifdef EFL64
    return (unsigned char)(((val) >> shift) & 0x3F);
 #else