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>
16 printf("[BEGIN] dlopen-read\n");
18 __block
bool allGood
= true;
19 dispatch_apply(6, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT
, 0), ^(size_t index
) {
20 for (int i
=0; i
< 500; ++i
) {
21 void* handle
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_LAZY
);
22 if ( handle
== NULL
) {
23 printf("[FAIL] dlopen-read: %s\n", dlerror());
30 printf("[PASS] dlopen-read\n");