- const char *library(CY_LIBRARY);
-
- 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(pool.malloc<uint8_t>(depth));
- Baton *baton(reinterpret_cast<Baton *>(local));
-
- baton->__pthread_set_self = &__pthread_set_self;
- baton->pthread_create = &pthread_create;
-
- baton->mach_thread_self = &mach_thread_self;
- baton->thread_terminate = &thread_terminate;
-
- baton->dlerror = &dlerror;
- baton->dlsym = &dlsym;
-
- baton->pid = getpid();
- memcpy(baton->library, library, length);
-
- vm_size_t size(depth + Stack_);
+ Dl_info addr;
+ _assert(dladdr(reinterpret_cast<void *>(&CYHandleServer), &addr) != 0);
+ const char *library(addr.dli_fname);