diff options
| author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-10 07:59:45 +0000 | 
|---|---|---|
| committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2017-02-10 07:59:45 +0000 | 
| commit | 4051a5afbfc92873af44d47ae6613d7bd17f7433 (patch) | |
| tree | 09afe1ad6bded8815a058ef6476ea4481d9a032a /src/lib | |
| parent | 0557bc02b963bab6f690b410fe937a9f487a84ba (diff) | |
| parent | aa1643ae393d9460bea8e2922c9cc0a3e6caf63d (diff) | |
| download | ouroboros-4051a5afbfc92873af44d47ae6613d7bd17f7433.tar.gz ouroboros-4051a5afbfc92873af44d47ae6613d7bd17f7433.zip | |
Merged in dstaesse/ouroboros/be-bsd (pull request #368)
Be bsd
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/byte_order.h | 8 | ||||
| -rw-r--r-- | src/lib/rib.c | 12 | ||||
| -rw-r--r-- | src/lib/tests/rib_test.c | 2 | 
3 files changed, 17 insertions, 5 deletions
| diff --git a/src/lib/byte_order.h b/src/lib/byte_order.h index 9ee082af..364b06cc 100644 --- a/src/lib/byte_order.h +++ b/src/lib/byte_order.h @@ -49,7 +49,9 @@  #include <stdlib.h>  #ifdef __GLIBC__ -# include <endian.h> +#include <endian.h> +#elif defined(__FreeBSD__) +#include <sys/endian.h>  #endif  /* if x86 compatible cpu */ @@ -131,7 +133,8 @@ static inline uint32_t bswap_32(uint32_t x) {  #if defined(__GNUC__) && (__GNUC__ >= 4) && \          (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)  #define bswap_64(x) __builtin_bswap64(x) -#elif !defined(__STRICT_ANSI__) +#elif !defined (bswap64) +#if !defined(__STRICT_ANSI__)  static inline uint64_t bswap_64(uint64_t x) {          union {                  uint64_t ll; @@ -145,6 +148,7 @@ static inline uint64_t bswap_64(uint64_t x) {  #else  #error "bswap_64 unsupported"  #endif +#endif  #ifdef CPU_BIG_ENDIAN  #define be2me_32(x) (x) diff --git a/src/lib/rib.c b/src/lib/rib.c index e0456b6f..af4abccf 100644 --- a/src/lib/rib.c +++ b/src/lib/rib.c @@ -778,11 +778,19 @@ static struct rib_sub * rib_get_sub(uint32_t sid)  static struct rib_sub * rib_sub_create(uint32_t sid)  { +        pthread_condattr_t cattr;          struct rib_sub * sub = malloc(sizeof(*sub));          if (sub == NULL)                  return NULL; -        if (pthread_cond_init(&sub->cond, NULL)) { +        if (pthread_condattr_init(&cattr)) { +                free(sub); +                return NULL; +        } +#ifndef __APPLE__ +        pthread_condattr_setclock(&cattr, PTHREAD_COND_CLOCK); +#endif +        if (pthread_cond_init(&sub->cond, &cattr)) {                  free(sub);                  return NULL;          } @@ -1136,7 +1144,7 @@ int rib_event_wait(ro_set_t *              set,          if (ret != -ETIMEDOUT)                  list_move(&rq->events, &sub->events); -        pthread_rwlock_wrlock(&rib.lock); +        pthread_rwlock_unlock(&rib.lock);          return ret;  } diff --git a/src/lib/tests/rib_test.c b/src/lib/tests/rib_test.c index efc35d63..a7ae7311 100644 --- a/src/lib/tests/rib_test.c +++ b/src/lib/tests/rib_test.c @@ -52,7 +52,7 @@ int rib_test(int     argc,          uint8_t * buf;          ssize_t   buf_len; -        struct timespec t = {0, 100 * BILLION}; +        struct timespec t = {0, 100 * MILLION};          (void) argc;          (void) argv; | 
