From 1de82bbe86bfdc1717dc4e04ab5125af1f24d51a Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston <jeremyhu@apple.com>
Date: Mon, 7 May 2012 17:07:27 -0700
Subject: [PATCH 3/3] XQuartz: Provide fls implementation for Tiger

Regression-from: 30623d6ff7bca223f9e1a825e86bd317eef8bf16
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
---
 hw/xquartz/console_redirect.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index 1e0e56b..91d693b 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -310,6 +310,20 @@ xq_asl_init(void)
     atexit(redirect_atexit);
 }
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#define fls(v) xq_fls(v)
+
+static inline int fls(int value) {
+    unsigned int b, v;
+
+    v = *((unsigned int *)&value);
+
+    for(b=0 ; v ; v >>= 1 , b++);
+
+    return b;
+}
+#endif
+
 int
 xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
 {
-- 
1.7.10.1

