5 // Created by Louis Gerbarg on 11/14/18.
9 #include <sys/sysctl.h>
10 #include <TargetConditionals.h>
12 #include "Loading.h" // For internalInstall()
17 * Checks to see if there are any args that impact dyld. These args
18 * can be set sevaral ways. These will only be honored on development
19 * and Apple Internal builds.
21 bool BootArgs::contains(const char* arg
)
23 //FIXME: Use strnstr(). Unfortunately we are missing an imp in libc.a
24 #if TARGET_OS_SIMULATOR
27 // don't check for boot-args on customer installs
28 if ( !internalInstall() )
31 // get length of full boot-args string
33 if ( sysctlbyname("kern.bootargs", NULL
, &len
, NULL
, 0) != 0 )
36 // get copy of boot-args string
37 char bootArgsBuffer
[len
];
38 if ( sysctlbyname("kern.bootargs", bootArgsBuffer
, &len
, NULL
, 0) != 0 )
41 // return true if 'arg' is a sub-string of boot-args
42 return (strstr(bootArgsBuffer
, arg
) != nullptr);
46 uint64_t BootArgs::_flags
= 0;
48 bool BootArgs::forceCustomerCache() {
49 return (_flags
& kForceCustomerCacheMask
);
52 bool BootArgs::forceDyld2() {
53 // If both force dyld2 and dyld3 are set then use dyld3
54 if (_flags
& kForceDyld3CacheMask
) { return false; }
55 if (_flags
& kForceDyld2CacheMask
) { return true; }
56 if (contains("force_dyld2=1")) { return true; }
60 bool BootArgs::forceDyld3() {
61 return ((_flags
& kForceDyld3CacheMask
) || contains("force_dyld3=1"));
64 bool BootArgs::enableDyldTestMode() {
65 return (_flags
& kDyldTestModeMask
);
68 bool BootArgs::enableCompactImageInfo() {
69 return (_flags
& kEnableCompactImageInfoMask
);
72 void BootArgs::setFlags(uint64_t flags
) {
73 #if TARGET_IPHONE_SIMULATOR
76 // don't check for boot-args on customer installs
77 if ( !internalInstall() )