Message ID | gerrit.1463536537129.I580a500edcf4812e570be586890abef746083a8c@gerrit.osmocom.org |
---|---|
State | New |
Headers | show |
Arran Cudbard-bell has uploaded a new patch set (#2). Change subject: Fix build for OSX ...................................................................... Fix build for OSX Change-Id: I580a500edcf4812e570be586890abef746083a8c --- M .gitignore M include/osmocom/core/endian.h M src/stats.c 3 files changed, 25 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/74/74/2
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/74 to look at the new patch set (#3). Change subject: Fix build for OSX ...................................................................... Fix build for OSX Change-Id: I580a500edcf4812e570be586890abef746083a8c --- M .gitignore M include/osmocom/core/endian.h M src/stats.c 3 files changed, 25 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/74/74/3
Patch Set 3: Hi, we (specially I am) are a bit picky on granularity of changes. Could you move the .gitignore part to a different patch please. In terms of OSX did you try to run make check? We hijack/overload/interpose some of the "libc" symbols in our tests and this fails on OSX because in OSX the symbol look-up is per DSO. There is an option in the OSX linker to disable it but I never made up my mind if: * we skip these test on OSX * force the linker to be more like GNU/Linux and FreeBSD Do you have an opinion?
Patch Set 4: Code-Review+2 (1 comment) https://gerrit.osmocom.org/#/c/74/4/src/stats.c File src/stats.c: Line 357: #ifdef MSG_NOSIGNAL I don't like #ifdefs in code too much. I will let this one in but in general maybe having a #ifdef __APPLE__ #define MSG_NOSIGNAL 0 #endif at the top is a better idea? 0 | .. will result in a working bitmask and the problem of SIGPIPE might still be the case not that I think we will hit it here.
Patch Set 5:
(1 comment)
SIP needs to be disabled anyway for SCTP NKE. So could use LD_PRELOAD... OR something else if you wanted me to investigate abstracting SCTP out and using usrsctp.
https://gerrit.osmocom.org/#/c/74/4/src/stats.c
File src/stats.c:
Line 357: #ifdef MSG_NOSIGNAL
> I don't like #ifdefs in code too much. I will let this one in but in genera
The issue I have with defining macros to be no ops is that it makes things harder to track down. If you put MSG_NOSIGNAL in a bitmask you expect that behaviour, not for it to be ignored.
Usually I try and define abstract macros that deal with the variances between systems, but that's not possible here.
diff --git a/.gitignore b/.gitignore index 32915aa..03ce379 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ aminclude.am m4/*.m4 autom4te.cache +config.cache config.h* config.sub config.log diff --git a/include/osmocom/core/endian.h b/include/osmocom/core/endian.h index c890fd7..4616a65 100644 --- a/include/osmocom/core/endian.h +++ b/include/osmocom/core/endian.h @@ -23,6 +23,17 @@ #else #error "Unknown endian" #endif +#elif defined(__APPLE__) +#include <machine/endian.h> + #if defined(__DARWIN_LITTLE_ENDIAN) + #define OSMO_IS_LITTLE_ENDIAN 1 + #define OSMO_IS_BIG_ENDIAN 0 + #elif define(__DARWIN_BIG_ENDIAN) + #define OSMO_IS_LITTLE_ENDIAN 1 + #define OSMO_IS_BIG_ENDIAN 0 + #else + #error "Unknown endian" + #endif #else #include <endian.h> #if __BYTE_ORDER == __LITTLE_ENDIAN diff --git a/src/stats.c b/src/stats.c index 73b2703..5f1d028 100644 --- a/src/stats.c +++ b/src/stats.c @@ -301,6 +301,14 @@ if (sock == -1) return -errno; +#if defined(__APPLE__) && !defined(MSG_NOSIGNAL) + { + static int val = 1; + + rc = setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&val, sizeof(val)); + goto failed; + } +#endif if (srep->bind_addr_len > 0) { rc = bind(sock, &srep->bind_addr, srep->bind_addr_len); if (rc == -1) @@ -345,7 +353,11 @@ { int rc; - rc = sendto(srep->fd, data, data_len, MSG_NOSIGNAL | MSG_DONTWAIT, + rc = sendto(srep->fd, data, data_len, +#ifdef MSG_NOSIGNAL + MSG_NOSIGNAL | +#endif + MSG_DONTWAIT, &srep->dest_addr, srep->dest_addr_len); if (rc == -1)