On some platforms, the sockets support code for the GNAT runtime library needs to redefine C macro FD_SETSIZE to increase its value from the system default. This must occur before any system header file is included, so that all code sees a consistent value.
Tested on x86_64-pc-linux-gnu, committed on trunk 2011-12-12 Thomas Quinot <qui...@adacore.com> * gsocket.h, s-oscons-tmplt.c: Ensure we do not include any system header file prior to redefining FD_SETSIZE.
Index: gsocket.h =================================================================== --- gsocket.h (revision 182223) +++ gsocket.h (working copy) @@ -6,7 +6,7 @@ * * * C Header File * * * - * Copyright (C) 2004-2010, Free Software Foundation, Inc. * + * Copyright (C) 2004-2011, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -58,9 +58,12 @@ /* For Tru64 */ #endif -#include <limits.h> -#include <errno.h> +/** No system header may be included prior to this point since on some targets + ** we need to redefine FD_SETSIZE. + **/ +/* Target-specific includes and definitions */ + #if defined(__vxworks) #include <vxWorks.h> #include <ioLib.h> @@ -163,6 +166,8 @@ #elif defined(VMS) #define FD_SETSIZE 4096 +#include <sys/types.h> +#include <sys/time.h> #ifndef IN_RTS /* These DEC C headers are not available when building with GCC */ #include <in.h> @@ -173,6 +178,9 @@ #endif +#include <limits.h> +#include <errno.h> + #if defined (__vxworks) && ! defined (__RTP__) #include <sys/times.h> #else @@ -180,11 +188,11 @@ #endif /* - * RTEMS has these .h files but not until you have built and installed - * RTEMS. When building a C/C++ toolset, you also build the newlib C library. - * So the build procedure for an RTEMS GNAT toolset requires that - * you build a C/C++ toolset, then build and install RTEMS with - * --enable-multilib, and finally build the Ada part of the toolset. + * RTEMS has these .h files but not until you have built and installed RTEMS. + * When building a C/C++ toolset, you also build the newlib C library, so the + * build procedure for an RTEMS GNAT toolset requires that you build a C/C++ + * toolset, then build and install RTEMS with --enable-multilib, and finally + * build the Ada part of the toolset. */ #if !(defined (VMS) || defined (__MINGW32__)) #include <sys/socket.h> Index: s-oscons-tmplt.c =================================================================== --- s-oscons-tmplt.c (revision 182223) +++ s-oscons-tmplt.c (working copy) @@ -78,6 +78,8 @@ ** $ RUN xoscons **/ +/* Feature macro definitions */ + #if defined (__linux__) && !defined (_XOPEN_SOURCE) /** For Linux _XOPEN_SOURCE must be defined, otherwise IOV_MAX is not defined **/ @@ -93,6 +95,10 @@ #endif #endif +/* Include gsocket.h before any system header so it can redefine FD_SETSIZE */ + +#include "gsocket.h" + #include <stdlib.h> #include <string.h> #include <limits.h> @@ -130,8 +136,6 @@ # include <vxWorks.h> #endif -#include "gsocket.h" - #ifdef DUMMY # if defined (TARGET)