Skip to content

Getting Onion to Work on macOS

Eugene edited this page Mar 11, 2019 · 4 revisions

Note: All the changes detailed below have already been applied to this fork of the Onion library.

  1. Clone the master branch of Onion
  2. CMakeLists.txt: Change the CMake minimum required version to 3.6. Delete the CMake policy command.
  3. Remove the deprecated use of sem_init(...) from /src/onion/poller_libev.c and /src/onion/poller_libevent.c and implement proper freeing of semaphores:
    1. Update the onion_poller_t struct to use a pointer to a semaphore: sem_t *sem;
    2. In onion_poller_new(...), add sem_unlink("/poller"); to the start of the function, and replace sem_init(&ret->sem, 0, 1) with ret->sem = sem_open("/poller", O_CREAT, 0, 1).
    3. In onion_poller_free(...), add sem_close(p->sem); sem_unlink("/poller"); to the start of the function.
    4. In onion_poller_poll(...), simply use poller->sem and poller->sem.
  4. Resolve some of the compilation warnings by including <strings.h>, <stdlib.h>, and <alloca.h>, by using %lld for printf, and by using the correct onion_poller_slot_type_e parameter type.
  5. Run CMake from the build directory: cmake ..
  6. Compile the static Onion C library (dynamic C++ library does not compile): make onion_static
Clone this wiki locally