2 // BUILD: $CC main.c -o $BUILD_DIR/dyld_launch_mode.exe
4 // RUN: ./dyld_launch_mode.exe
9 #include <mach-o/dyld_priv.h>
12 #include "test_support.h"
14 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[])
16 const char* modeStr
= getenv("DYLD_USE_CLOSURES");
17 if ( modeStr
== NULL
) {
18 FAIL("dyld_launch_mode: DYLD_USE_CLOSURES env var not set");
21 uint32_t expectedFlags
;
22 uint32_t launchFlags
= _dyld_launch_mode();
23 fprintf(stderr
, "launchFlags=0x%08x\n", launchFlags
);
25 if ( strcmp(modeStr
, "0") == 0 ) {
28 else if ( strcmp(modeStr
, "1") == 0 ) {
29 expectedFlags
= DYLD_LAUNCH_MODE_USING_CLOSURE
| DYLD_LAUNCH_MODE_BUILT_CLOSURE_AT_LAUNCH
;
31 else if ( strcmp(modeStr
, "2") == 0 ) {
32 expectedFlags
= DYLD_LAUNCH_MODE_USING_CLOSURE
| DYLD_LAUNCH_MODE_BUILT_CLOSURE_AT_LAUNCH
| DYLD_LAUNCH_MODE_MINIMAL_CLOSURE
;
35 FAIL("dyld_launch_mode: DYLD_USE_CLOSURES value unknown");
39 if ( launchFlags
== expectedFlags
)
40 PASS("dyld_launch_mode");
42 FAIL("dyld_launch_mode: expected flags to be 0x%08X but were 0x%08X", expectedFlags
, launchFlags
);