changeset 11559:b7f5d7ba4651

Don't use undefined macro 'max'.
author Bruno Haible <bruno@clisp.org>
date Sat, 09 May 2009 00:01:36 +0200
parents 3ee72ca3f3ad
children 987b2dec97b7
files ChangeLog lib/sys_socket.in.h
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-08  Bruno Haible  <bruno@clisp.org>
+
+	* lib/sys_socket.in.h (_SS_PADSIZE): Use a conditional expression
+	instead of 'max'.
+
 2009-05-08  Simon Josefsson  <simon@josefsson.org>
 
 	* m4/sys_socket_h.m4: Test for ws2tcpip.h earlier, needed for
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -44,14 +44,16 @@
 #define _GL_SYS_SOCKET_H
 
 #if !@HAVE_STRUCT_SOCKADDR_STORAGE@
-#include <alignof.h>
+# include <alignof.h>
 /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
    2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
-#define __ss_aligntype  unsigned long int
-#define _SS_SIZE	256
-#define _SS_PADSIZE	(_SS_SIZE - (max (sizeof (sa_family_t),		\
-					  alignof (__ss_aligntype))	\
-				     + sizeof (__ss_aligntype)))
+# define __ss_aligntype unsigned long int
+# define _SS_SIZE 256
+# define _SS_PADSIZE \
+    (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype)	\
+		  ? sizeof (sa_family_t)				\
+		  : alignof (__ss_aligntype))				\
+		 + sizeof (__ss_aligntype)))
 
 struct sockaddr_storage
 {