Title: [150729] trunk/Source/WTF
Revision
150729
Author
par...@webkit.org
Date
2013-05-26 18:25:52 -0700 (Sun, 26 May 2013)

Log Message

[WINCE] Add wtf_bsearch()
https://bugs.webkit.org/show_bug.cgi?id=116528

Reviewed by Darin Adler.

r149833 introduced usage of ::bsearch(), which does not exist on Windwos CE.
Add our own implementation of this function as wtf_bsearch and define
bsearch as wtf_bsearch to fix compilation on Windwos CE.

* wtf/StdLibExtras.h:
(wtf_bsearch):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (150728 => 150729)


--- trunk/Source/WTF/ChangeLog	2013-05-27 00:00:25 UTC (rev 150728)
+++ trunk/Source/WTF/ChangeLog	2013-05-27 01:25:52 UTC (rev 150729)
@@ -1,3 +1,17 @@
+2013-05-26  Patrick Gansterer  <par...@webkit.org>
+
+        [WINCE] Add wtf_bsearch()
+        https://bugs.webkit.org/show_bug.cgi?id=116528
+
+        Reviewed by Darin Adler.
+
+        r149833 introduced usage of ::bsearch(), which does not exist on Windwos CE.
+        Add our own implementation of this function as wtf_bsearch and define
+        bsearch as wtf_bsearch to fix compilation on Windwos CE.
+
+        * wtf/StdLibExtras.h:
+        (wtf_bsearch):
+
 2013-05-26  Kent Tamura  <tk...@chromium.org>
 
         Remove ENABLE_CALENDAR_PICKER

Modified: trunk/Source/WTF/wtf/StdLibExtras.h (150728 => 150729)


--- trunk/Source/WTF/wtf/StdLibExtras.h	2013-05-27 00:00:25 UTC (rev 150728)
+++ trunk/Source/WTF/wtf/StdLibExtras.h	2013-05-27 01:25:52 UTC (rev 150729)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2013 Patrick Gansterer <par...@paroga.com>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -261,6 +262,31 @@
 
 } // namespace WTF
 
+#if OS(WINCE)
+// Windows CE CRT has does not implement bsearch().
+inline void* wtf_bsearch(const void* key, const void* base, size_t count, size_t size, int (*compare)(const void *, const void *))
+{
+    const char* first = static_cast<const char*>(base);
+
+    while (count) {
+        size_t pos = (count - 1) >> 1;
+        const char* item = first + pos * size;
+        int compareResult = compare(item, key);
+        if (!compareResult)
+            return const_cast<char*>(item);
+        if (compareResult < 0) {
+            count -= (pos + 1);
+            first += (pos + 1) * size;
+        } else
+            count = pos;
+    }
+
+    return 0;
+}
+
+#define bsearch(key, base, count, size, compare) wtf_bsearch(key, base, count, size, compare)
+#endif
+
 // This version of placement new omits a 0 check.
 enum NotNullTag { NotNull };
 inline void* operator new(size_t, NotNullTag, void* location)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to