mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Revert "OSX doesn't support unnamed semaphores so to make it work, fake the threading by just creating the threads and waiting for them to finish."
This reverts commit b81542cea4.
Revert the change bypassing semaphores in OSX in preparation for changing the semaphores to mutexes.
This commit is contained in:
parent
ea9b00c839
commit
05c5326df3
77
rzip.h
77
rzip.h
|
|
@ -164,38 +164,6 @@ static inline i64 get_ram(void)
|
||||||
|
|
||||||
return ramsize;
|
return ramsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OSX doesn't support unnamed semaphores so we fake the threading by
|
|
||||||
* serialising threads and ignore all the semaphore calls.
|
|
||||||
*/
|
|
||||||
static inline void init_sem(sem_t *sem __attribute__((unused)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void post_sem(sem_t *s __attribute__((unused)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void wait_sem(sem_t *s __attribute__((unused)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void destroy_sem(sem_t *s __attribute__((unused)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void create_pthread(pthread_t * thread, pthread_attr_t * attr,
|
|
||||||
void * (*start_routine)(void *), void *arg)
|
|
||||||
{
|
|
||||||
if (pthread_create(thread, attr, start_routine, arg))
|
|
||||||
fatal("pthread_create");
|
|
||||||
if (pthread_join(*thread, NULL))
|
|
||||||
fatal("pthread_join");
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void join_pthread(pthread_t th __attribute__((unused)), void **thread_return __attribute__((unused)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#else /* __APPLE__ */
|
#else /* __APPLE__ */
|
||||||
#define memstream_update_buffer(A, B, C) (0)
|
#define memstream_update_buffer(A, B, C) (0)
|
||||||
static inline i64 get_ram(void)
|
static inline i64 get_ram(void)
|
||||||
|
|
@ -221,51 +189,6 @@ static inline i64 get_ram(void)
|
||||||
|
|
||||||
return ramsize;
|
return ramsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void init_sem(sem_t *sem)
|
|
||||||
{
|
|
||||||
if (unlikely(sem_init(sem, 0, 0)))
|
|
||||||
fatal("sem_init\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void post_sem(sem_t *s)
|
|
||||||
{
|
|
||||||
retry:
|
|
||||||
if (unlikely((sem_post(s)) == -1)) {
|
|
||||||
if (errno == EINTR)
|
|
||||||
goto retry;
|
|
||||||
fatal("sem_post failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void wait_sem(sem_t *s)
|
|
||||||
{
|
|
||||||
retry:
|
|
||||||
if (unlikely((sem_wait(s)) == -1)) {
|
|
||||||
if (errno == EINTR)
|
|
||||||
goto retry;
|
|
||||||
fatal("sem_wait failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void destroy_sem(sem_t *s)
|
|
||||||
{
|
|
||||||
if (unlikely(sem_destroy(s)))
|
|
||||||
fatal("sem_destroy failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void create_pthread(pthread_t *thread, pthread_attr_t * attr,
|
|
||||||
void * (*start_routine)(void *), void *arg)
|
|
||||||
{
|
|
||||||
if (pthread_create(thread, attr, start_routine, arg))
|
|
||||||
fatal("pthread_create");
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void join_pthread(pthread_t th, void **thread_return)
|
|
||||||
{
|
|
||||||
if (pthread_join(th, thread_return))
|
|
||||||
fatal("pthread_join");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
|
|
|
||||||
45
stream.c
45
stream.c
|
|
@ -45,6 +45,51 @@ struct uncomp_thread{
|
||||||
int stream;
|
int stream;
|
||||||
} *ucthread;
|
} *ucthread;
|
||||||
|
|
||||||
|
void init_sem(sem_t *sem)
|
||||||
|
{
|
||||||
|
if (unlikely(sem_init(sem, 0, 0)))
|
||||||
|
fatal("sem_init\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void post_sem(sem_t *s)
|
||||||
|
{
|
||||||
|
retry:
|
||||||
|
if (unlikely((sem_post(s)) == -1)) {
|
||||||
|
if (errno == EINTR)
|
||||||
|
goto retry;
|
||||||
|
fatal("sem_post failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void wait_sem(sem_t *s)
|
||||||
|
{
|
||||||
|
retry:
|
||||||
|
if (unlikely((sem_wait(s)) == -1)) {
|
||||||
|
if (errno == EINTR)
|
||||||
|
goto retry;
|
||||||
|
fatal("sem_wait failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void destroy_sem(sem_t *s)
|
||||||
|
{
|
||||||
|
if (unlikely(sem_destroy(s)))
|
||||||
|
fatal("sem_destroy failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void create_pthread(pthread_t * thread, pthread_attr_t * attr,
|
||||||
|
void * (*start_routine)(void *), void *arg)
|
||||||
|
{
|
||||||
|
if (pthread_create(thread, attr, start_routine, arg))
|
||||||
|
fatal("pthread_create");
|
||||||
|
}
|
||||||
|
|
||||||
|
void join_pthread(pthread_t th, void **thread_return)
|
||||||
|
{
|
||||||
|
if (pthread_join(th, thread_return))
|
||||||
|
fatal("pthread_join");
|
||||||
|
}
|
||||||
|
|
||||||
/* just to keep things clean, declare function here
|
/* just to keep things clean, declare function here
|
||||||
* but move body to the end since it's a work function
|
* but move body to the end since it's a work function
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue