[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] macro: Move PA_LIKELY()/PA_UNLIKELY(), PA_CLAMP()/PA_CLAMP_UNLIKELY() to pulse/gccmacro.h

Tanu Kaskinen gitlab at gitlab.freedesktop.org
Sat Dec 21 06:50:28 UTC 2019



Tanu Kaskinen pushed to branch master at PulseAudio / pulseaudio


Commits:
d6b69444 by Peter Meerwald at 2019-12-21T06:36:28Z
macro: Move PA_LIKELY()/PA_UNLIKELY(), PA_CLAMP()/PA_CLAMP_UNLIKELY() to pulse/gccmacro.h

PA_CLAMP_VOLUME() in pulse/volume.h makes use of PA_CLAMP_UNLIKELY()

see https://bugs.freedesktop.org/show_bug.cgi?id=89515

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

- - - - -


2 changed files:

- src/pulse/gccmacro.h
- src/pulsecore/macro.h


Changes:

=====================================
src/pulse/gccmacro.h
=====================================
@@ -129,4 +129,42 @@
 #endif
 #endif
 
+#ifndef PA_LIKELY
+#ifdef __GNUC__
+#define PA_LIKELY(x) (__builtin_expect(!!(x),1))
+#define PA_UNLIKELY(x) (__builtin_expect(!!(x),0))
+#else
+#define PA_LIKELY(x) (x)
+#define PA_UNLIKELY(x) (x)
+#endif
+#endif
+
+#ifdef __GNUC__
+#define PA_CLAMP(x, low, high)                                          \
+    __extension__ ({                                                    \
+            typeof(x) _x = (x);                                         \
+            typeof(low) _low = (low);                                   \
+            typeof(high) _high = (high);                                \
+            ((_x > _high) ? _high : ((_x < _low) ? _low : _x));         \
+        })
+#else
+#define PA_CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+#endif
+
+#ifdef __GNUC__
+#define PA_CLAMP_UNLIKELY(x, low, high)                                 \
+    __extension__ ({                                                    \
+            typeof(x) _x = (x);                                         \
+            typeof(low) _low = (low);                                   \
+            typeof(high) _high = (high);                                \
+            (PA_UNLIKELY(_x > _high) ? _high : (PA_UNLIKELY(_x < _low) ? _low : _x)); \
+        })
+#else
+#define PA_CLAMP_UNLIKELY(x, low, high) (PA_UNLIKELY((x) > (high)) ? (high) : (PA_UNLIKELY((x) < (low)) ? (low) : (x)))
+#endif
+
+/* We don't define a PA_CLAMP_LIKELY here, because it doesn't really
+ * make sense: we cannot know if it is more likely that the value is
+ * lower or greater than the boundaries. */
+
 #endif


=====================================
src/pulsecore/macro.h
=====================================
@@ -34,16 +34,6 @@
 #error "Please include config.h before including this file!"
 #endif
 
-#ifndef PA_LIKELY
-#ifdef __GNUC__
-#define PA_LIKELY(x) (__builtin_expect(!!(x),1))
-#define PA_UNLIKELY(x) (__builtin_expect(!!(x),0))
-#else
-#define PA_LIKELY(x) (x)
-#define PA_UNLIKELY(x) (x)
-#endif
-#endif
-
 /* Rounds down */
 static inline void* PA_ALIGN_PTR(const void *p) {
     return (void*) (((size_t) p) & ~(sizeof(void*) - 1));
@@ -99,34 +89,6 @@ static inline size_t PA_ALIGN(size_t l) {
 #define PA_MIN(a, b) ((a) < (b) ? (a) : (b))
 #endif
 
-#ifdef __GNUC__
-#define PA_CLAMP(x, low, high)                                          \
-    __extension__ ({                                                    \
-            typeof(x) _x = (x);                                         \
-            typeof(low) _low = (low);                                   \
-            typeof(high) _high = (high);                                \
-            ((_x > _high) ? _high : ((_x < _low) ? _low : _x));         \
-        })
-#else
-#define PA_CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
-#endif
-
-#ifdef __GNUC__
-#define PA_CLAMP_UNLIKELY(x, low, high)                                 \
-    __extension__ ({                                                    \
-            typeof(x) _x = (x);                                         \
-            typeof(low) _low = (low);                                   \
-            typeof(high) _high = (high);                                \
-            (PA_UNLIKELY(_x > _high) ? _high : (PA_UNLIKELY(_x < _low) ? _low : _x)); \
-        })
-#else
-#define PA_CLAMP_UNLIKELY(x, low, high) (PA_UNLIKELY((x) > (high)) ? (high) : (PA_UNLIKELY((x) < (low)) ? (low) : (x)))
-#endif
-
-/* We don't define a PA_CLAMP_LIKELY here, because it doesn't really
- * make sense: we cannot know if it is more likely that the values is
- * lower or greater than the boundaries.*/
-
 #ifdef __GNUC__
 #define PA_ROUND_UP(a, b)                       \
     __extension__ ({                            \



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/commit/d6b69444be44a5baf49ec8385c60b9fa393a3b34

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/commit/d6b69444be44a5baf49ec8385c60b9fa393a3b34
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20191221/5a6898a2/attachment-0001.htm>


More information about the pulseaudio-commits mailing list