+extern void bar();
+
+
+// NSCreateObjectFileImageFromMemory is only available on Mac OS X - not iPhone OS
+#if __MAC_OS_X_VERSION_MIN_REQUIRED
+
+void loadAsBundleFromMemory(const char* path)
+{
+ int fd = open(path, O_RDONLY, 0);
+ if ( fd == -1 ) {
+ FAIL("bundle-v-dylib: open() failed");
+ exit(0);
+ }
+
+ struct stat stat_buf;
+ if ( fstat(fd, &stat_buf) == -1) {
+ FAIL("bundle-v-dylib: fstat() failed");
+ exit(0);
+ }
+
+ void* loadAddress = mmap(NULL, stat_buf.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);
+ if ( loadAddress == ((void*)(-1)) ) {
+ FAIL("bundle-v-dylib: mmap() failed");
+ exit(0);
+ }
+
+ close(fd);
+
+ NSObjectFileImage ofi;
+ if ( NSCreateObjectFileImageFromMemory(loadAddress, stat_buf.st_size, &ofi) == NSObjectFileImageSuccess ) {
+ FAIL("bundle-v-dylib: NSCreateObjectFileImageFromMemory() incorrectly allowed %s to be loaded", path);
+ exit(0);
+ }
+}