- // XXX: break this into the build environment
- const char *library("/usr/lib/libcycript.dylib");
-
- static const size_t Stack_(8 * 1024);
- size_t length(strlen(library) + 1), depth(sizeof(Baton) + length);
- depth = (depth + sizeof(uintptr_t) + 1) / sizeof(uintptr_t) * sizeof(uintptr_t);
-
- CYPool pool;
- uint8_t *local(reinterpret_cast<uint8_t *>(apr_palloc(pool, depth)));
- Baton *baton(reinterpret_cast<Baton *>(local));
-
- uintptr_t set_self_internal;
- uintptr_t set_self_external;
-
-#if defined(__i386__) || defined(__arm__)
- struct nlist nl[3];
- memset(nl, 0, sizeof(nl));
- nl[0].n_un.n_name = (char *) "__pthread_set_self";
- nl[1].n_un.n_name = (char *) "___pthread_set_self";
- nlist("/usr/lib/libSystem.B.dylib", nl);
- nlset(set_self_internal, nl, 0);
- nlset(set_self_external, nl, 1);
-#else
- set_self_internal = 0;
- set_self_external = 0;
-#endif
-
- baton->_pthread_set_self = reinterpret_cast<void (*)(pthread_t)>(reinterpret_cast<uintptr_t>(&__pthread_set_self) - set_self_external + set_self_internal);
-
- baton->pthread_create = &pthread_create;
- baton->pthread_join = &pthread_join;
-
- baton->dlopen = &dlopen;
- baton->dlsym = &dlsym;
-
- baton->mach_thread_self = &mach_thread_self;
- baton->thread_terminate = &thread_terminate;
-
- baton->pid = getpid();
- memcpy(baton->library, library, length);
-
- vm_size_t size(depth + Stack_);