2 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
3 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-race.exe -DRUN_DIR="$RUN_DIR"
5 // RUN: ./dlopen-race.exe
10 #include <dispatch/dispatch.h>
12 #include "test_support.h"
14 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
15 __block
bool allGood
= true;
16 dispatch_apply(6, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT
, 0), ^(size_t index
) {
17 for (int i
=0; i
< 500; ++i
) {
18 void* handle
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_LAZY
);
19 if ( handle
== NULL
) {
20 FAIL("dlopen-read: %s", dlerror());