Skip to content

Commit

Permalink
On OpenBSD use the MacOS msleep(), not the default one
Browse files Browse the repository at this point in the history
which uses clock_nanosleep(2) which OpenBSD doesn't have.
  • Loading branch information
Al2Klimov committed Oct 24, 2022
1 parent 3735047 commit bca777b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,18 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
}
}

#endif /* Apple Macintosh */

#if (__APPLE__ && __MACH__) || defined(__OpenBSD__)

#include <unistd.h> /* For usleep(). */

void msleep(double wait_ms)
{
assert(!usleep(wait_ms * 1000));
}

#else
#else /* Apple Macintosh / OpenBSD */

#include <time.h> /* For clock_gettime() and clock_nanosleep(). */

Expand Down Expand Up @@ -254,4 +258,4 @@ void msleep(double wait_ms)
assert(ret == 0);
}

#endif
#endif /* Apple Macintosh / OpenBSD */

0 comments on commit bca777b

Please sign in to comment.