Skip to content
This repository

fixes for netbsd #591

Closed
wants to merge 4 commits into from

1 participant

YAMAMOTO Takashi
YAMAMOTO Takashi
yamt commented

No description provided.

yamt added some commits
YAMAMOTO Takashi yamt don't define _XOPEN_SOURCE for NetBSD
on NetBSD, defining _XOPEN_SOURCE hides extensions
like inet_aton, strcasecmp, etc.
ed3f412
YAMAMOTO Takashi yamt rename popcount to popcount_binary to avoid a conflict with NetBSD libc
NetBSD-current's libc has a function named popcount.
hiding these extensions using feature macros is not possible because
redis uses other extensions covered by the same feature macro.
eg. inet_aton
8c13e40
YAMAMOTO Takashi yamt use nanosleep instead of usleep
SUSv3 says that:
	The useconds argument shall be less than one million. If the value of
	useconds is 0, then the call has no effect.
and actually NetBSD's implementation rejects such a value with EINVAL.
use nanosleep which has no such a limitation instead.
45ae74a
YAMAMOTO Takashi yamt _XOPEN_SOURCE 600 for NetBSD as well
it's necessary for getaddrinfo etc.
while i'm not sure why this is under #ifdef linux in the first place,
keep non-NetBSD cases as-is for now.
7e92f84
YAMAMOTO Takashi yamt referenced this pull request
Closed

fixes for netbsd #735

YAMAMOTO Takashi

see rebased version: #735

YAMAMOTO Takashi yamt closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 4 unique commits by 1 author.

Jul 19, 2012
YAMAMOTO Takashi yamt don't define _XOPEN_SOURCE for NetBSD
on NetBSD, defining _XOPEN_SOURCE hides extensions
like inet_aton, strcasecmp, etc.
ed3f412
YAMAMOTO Takashi yamt rename popcount to popcount_binary to avoid a conflict with NetBSD libc
NetBSD-current's libc has a function named popcount.
hiding these extensions using feature macros is not possible because
redis uses other extensions covered by the same feature macro.
eg. inet_aton
8c13e40
YAMAMOTO Takashi yamt use nanosleep instead of usleep
SUSv3 says that:
	The useconds argument shall be less than one million. If the value of
	useconds is 0, then the call has no effect.
and actually NetBSD's implementation rejects such a value with EINVAL.
use nanosleep which has no such a limitation instead.
45ae74a
YAMAMOTO Takashi yamt _XOPEN_SOURCE 600 for NetBSD as well
it's necessary for getaddrinfo etc.
while i'm not sure why this is under #ifdef linux in the first place,
keep non-NetBSD cases as-is for now.
7e92f84
This page is out of date. Refresh to see the latest.
2  deps/hiredis/fmacros.h
@@ -7,7 +7,7 @@
7 7
8 8 #if defined(__sun__)
9 9 #define _POSIX_C_SOURCE 200112L
10   -#elif defined(__linux__)
  10 +#elif defined(__linux__) || defined(__NetBSD__)
11 11 #define _XOPEN_SOURCE 600
12 12 #else
13 13 #define _XOPEN_SOURCE
4 src/bitops.c
@@ -28,7 +28,7 @@ static int getBitOffsetFromArgument(redisClient *c, robj *o, size_t *offset) {
28 28 /* Count number of bits set in the binary array pointed by 's' and long
29 29 * 'count' bytes. The implementation of this function is required to
30 30 * work with a input string length up to 512 MB. */
31   -long popcount(void *s, long count) {
  31 +long popcount_binary(void *s, long count) {
32 32 long bits = 0;
33 33 unsigned char *p;
34 34 uint32_t *p4 = s;
@@ -375,6 +375,6 @@ void bitcountCommand(redisClient *c) {
375 375 } else {
376 376 long bytes = end-start+1;
377 377
378   - addReplyLongLong(c,popcount(p+start,bytes));
  378 + addReplyLongLong(c,popcount_binary(p+start,bytes));
379 379 }
380 380 }
5 src/debug.c
@@ -294,8 +294,11 @@ void debugCommand(redisClient *c) {
294 294 } else if (!strcasecmp(c->argv[1]->ptr,"sleep") && c->argc == 3) {
295 295 double dtime = strtod(c->argv[2]->ptr,NULL);
296 296 long long utime = dtime*1000000;
  297 + struct timespec tv;
297 298
298   - usleep(utime);
  299 + tv.tv_sec = utime / 1000000;
  300 + tv.tv_nsec = (utime % 1000000) * 1000;
  301 + nanosleep(&tv, NULL);
299 302 addReply(c,shared.ok);
300 303 } else {
301 304 addReplyError(c,
6 src/fmacros.h
@@ -5,7 +5,11 @@
5 5
6 6 #if defined(__linux__) || defined(__OpenBSD__)
7 7 #define _XOPEN_SOURCE 700
8   -#else
  8 +/*
  9 + * On NetBSD, _XOPEN_SOURCE undefines _NETBSD_SOURCE and
  10 + * thus hides inet_aton etc.
  11 + */
  12 +#elif !defined(__NetBSD__)
9 13 #define _XOPEN_SOURCE
10 14 #endif
11 15

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.