Changeset 150729 in webkit


Ignore:
Timestamp:
May 26, 2013 6:25:52 PM (11 years ago)
Author:
Patrick Gansterer
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):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r150724 r150729  
     12013-05-26  Patrick Gansterer  <paroga@webkit.org>
     2
     3        [WINCE] Add wtf_bsearch()
     4        https://bugs.webkit.org/show_bug.cgi?id=116528
     5
     6        Reviewed by Darin Adler.
     7
     8        r149833 introduced usage of ::bsearch(), which does not exist on Windwos CE.
     9        Add our own implementation of this function as wtf_bsearch and define
     10        bsearch as wtf_bsearch to fix compilation on Windwos CE.
     11
     12        * wtf/StdLibExtras.h:
     13        (wtf_bsearch):
     14
    1152013-05-26  Kent Tamura  <tkent@chromium.org>
    216
  • trunk/Source/WTF/wtf/StdLibExtras.h

    r146774 r150729  
    11/*
    22 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
     3 * Copyright (C) 2013 Patrick Gansterer <paroga@paroga.com>
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    262263} // namespace WTF
    263264
     265#if OS(WINCE)
     266// Windows CE CRT has does not implement bsearch().
     267inline void* wtf_bsearch(const void* key, const void* base, size_t count, size_t size, int (*compare)(const void *, const void *))
     268{
     269    const char* first = static_cast<const char*>(base);
     270
     271    while (count) {
     272        size_t pos = (count - 1) >> 1;
     273        const char* item = first + pos * size;
     274        int compareResult = compare(item, key);
     275        if (!compareResult)
     276            return const_cast<char*>(item);
     277        if (compareResult < 0) {
     278            count -= (pos + 1);
     279            first += (pos + 1) * size;
     280        } else
     281            count = pos;
     282    }
     283
     284    return 0;
     285}
     286
     287#define bsearch(key, base, count, size, compare) wtf_bsearch(key, base, count, size, compare)
     288#endif
     289
    264290// This version of placement new omits a 0 check.
    265291enum NotNullTag { NotNull };
Note: See TracChangeset for help on using the changeset viewer.