From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMzVv-0006Z8-KM for qemu-devel@nongnu.org; Tue, 12 Jul 2016 11:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMzVq-00045s-Ff for qemu-devel@nongnu.org; Tue, 12 Jul 2016 11:22:22 -0400 Received: from resqmta-po-10v.sys.comcast.net ([2001:558:fe16:19:96:114:154:169]:53105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMzVq-00045T-9b for qemu-devel@nongnu.org; Tue, 12 Jul 2016 11:22:18 -0400 From: Eric Blake Date: Tue, 12 Jul 2016 09:21:52 -0600 Message-Id: <1468336912-20396-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH] build: Work around SIZE_MAX bug in OSX headers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, kwolf@redhat.com, qemu-block@nongnu.org C99 requires SIZE_MAX to be declared with the same type as the integral promotion of size_t, but OSX mistakenly defines it as an unsigned long long expression even though size_t is only unsigned long. Rather than futzing around with whether size_t is 32- or 64-bits wide, let the compiler get the right type for us by virtue of integer promotion. See also https://patchwork.ozlabs.org/patch/542327/ for an instance where the wrong type trips us up if we don't fix it for good in osdep.h. Signed-off-by: Eric Blake --- I can't test this on OSX, but I _did_ test that if I remove the '#ifdef __APPLE__' conditional (and just blindly do the redefine), things still compile on Linux (which means I got the type computation correct). This is my response to https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg02276.html include/qemu/osdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 7361006..9b4b2d3 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -141,6 +141,13 @@ extern int daemon(int, int); # error Unknown pointer size #endif +/* Mac OSX has a bug that incorrectly defines SIZE_MAX with + * the wrong type */ +#ifdef __APPLE__ +#undef SIZE_MAX +#define SIZE_MAX ((sizeof(char)) * -1) +#endif + #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif -- 2.5.5