From: R. Andrew Ohana Date: Tue, 29 Jul 2014 20:38:49 +0000 (-0700) Subject: Omit htonll when already #defined X-Git-Tag: 0.27-rc1~49 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=75d089e7cdb7a7eb4d69c352f56dad5ad3aa1f97 Omit htonll when already #defined OS X 10.10 Yosemite defines it as a macro. Signed-off-by: R. Andrew Ohana [rlb@defaultvalue.org: adjust comments; adjust commit message] Reviewed-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index 6957d2c..4d2f9fd 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -54,6 +54,22 @@ static int istty2 = 0; + +#ifndef htonll +// This function should technically be macro'd out if it's going to be used +// more than ocasionally. As of this writing, it'll actually never be called +// in real world bup scenarios (because our packs are < MAX_INT bytes). +static uint64_t htonll(uint64_t value) +{ + static const int endian_test = 42; + + if (*(char *)&endian_test == endian_test) // LSB-MSB + return ((uint64_t)htonl(value & 0xFFFFFFFF) << 32) | htonl(value >> 32); + return value; // already in network byte order MSB-LSB +} +#endif + + // At the moment any code that calls INTGER_TO_PY() will have to // disable -Wtautological-compare for clang. See below. @@ -586,18 +602,6 @@ static PyObject *merge_into(PyObject *self, PyObject *args) return PyLong_FromUnsignedLong(count); } -// This function should technically be macro'd out if it's going to be used -// more than ocasionally. As of this writing, it'll actually never be called -// in real world bup scenarios (because our packs are < MAX_INT bytes). -static uint64_t htonll(uint64_t value) -{ - static const int endian_test = 42; - - if (*(char *)&endian_test == endian_test) // LSB-MSB - return ((uint64_t)htonl(value & 0xFFFFFFFF) << 32) | htonl(value >> 32); - return value; // already in network byte order MSB-LSB -} - #define FAN_ENTRIES 256 static PyObject *write_idx(PyObject *self, PyObject *args)