| 40 | #endif |
| 41 | |
| 42 | void |
| 43 | ink_sem_init(ink_semaphore *sp, unsigned int count) |
| 44 | { |
| 45 | // Darwin has sem_open, but not sem_init. We emulate sem_init with sem_open. |
| 46 | #if TS_EMULATE_ANON_SEMAPHORES |
| 47 | char sname[NAME_MAX]; |
| 48 | |
| 49 | sp->semid = ink_atomic_increment(&ink_semaphore_count, 1); |
| 50 | snprintf(sname, sizeof(sname), "/trafficserver/anon/%" PRId64, sp->semid); |
| 51 | |
| 52 | ink_assert((sp->sema = sem_open(sname, O_CREAT | O_EXCL, 0770, count)) != SEM_FAILED); |
| 53 | |
| 54 | // Since we are emulating anonymous semaphores, unlink the name |
| 55 | // so no other process can accidentally get it. |
| 56 | ink_assert(sem_unlink(sname) != -1); |
| 57 | #else |
| 58 | ink_assert(sem_init(sp->get(), 0 /* pshared */, count) != -1); |
| 59 | #endif |
| 60 | } |
| 61 | |
| 62 | void |
| 63 | ink_sem_destroy(ink_semaphore *sp) |
no test coverage detected