[PATCH 3/4] Include config.h before any other headers.

Alan Coopersmith alan.coopersmith at oracle.com
Fri Feb 6 19:47:34 PST 2015


Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

Though I wonder if now you can drop the explicit #define _GNU_SOURCE in
linux_sysfs.c now that you moved the config.h up to the same spot, since
the AC_USE_SYSTEM_EXTENSIONS in configure.ac should #define _GNU_SOURCE in
config.h.

	-alan-

On 02/ 6/15 09:29 AM, Emil Velikov wrote:
> The former has a series of defines which in some cases are crusial to be
> set before including any system headers.
>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
>   src/common_vgaarb.c | 8 ++++----
>   src/freebsd_pci.c   | 8 ++++----
>   src/linux_sysfs.c   | 8 ++++----
>   src/netbsd_pci.c    | 8 ++++----
>   4 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
> index b2e1d8a..7a7d204 100644
> --- a/src/common_vgaarb.c
> +++ b/src/common_vgaarb.c
> @@ -25,6 +25,10 @@
>    *
>    */
>
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
>   #include <stdio.h>
>   #include <string.h>
>   #include <unistd.h>
> @@ -33,10 +37,6 @@
>   #include <stdlib.h>
>   #include <limits.h>
>
> -#ifdef HAVE_CONFIG_H
> -#include "config.h"
> -#endif
> -
>   #include "pciaccess.h"
>   #include "pciaccess_private.h"
>
> diff --git a/src/freebsd_pci.c b/src/freebsd_pci.c
> index a9304de..f9c1476 100644
> --- a/src/freebsd_pci.c
> +++ b/src/freebsd_pci.c
> @@ -33,6 +33,10 @@
>    * \author Eric Anholt <eric at anholt.net>
>    */
>
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
>   #include <stdlib.h>
>   #include <stdio.h>
>   #include <string.h>
> @@ -45,10 +49,6 @@
>   #include <sys/mman.h>
>   #include <sys/memrange.h>
>
> -#ifdef HAVE_CONFIG_H
> -#include "config.h"
> -#endif
> -
>   #include "pciaccess.h"
>   #include "pciaccess_private.h"
>
> diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
> index 08c9971..50d94cf 100644
> --- a/src/linux_sysfs.c
> +++ b/src/linux_sysfs.c
> @@ -34,6 +34,10 @@
>
>   #define _GNU_SOURCE
>
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
>   #include <stdlib.h>
>   #include <string.h>
>   #include <stdio.h>
> @@ -57,10 +61,6 @@
>   #define iopl(x) -1
>   #endif
>
> -#ifdef HAVE_CONFIG_H
> -#include "config.h"
> -#endif
> -
>   #ifdef HAVE_MTRR
>   #include <asm/mtrr.h>
>   #include <sys/ioctl.h>
> diff --git a/src/netbsd_pci.c b/src/netbsd_pci.c
> index 52591b0..f972f94 100644
> --- a/src/netbsd_pci.c
> +++ b/src/netbsd_pci.c
> @@ -16,15 +16,15 @@
>    * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>    */
>
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
>   #include <sys/param.h>
>   #include <sys/ioctl.h>
>   #include <sys/mman.h>
>   #include <sys/types.h>
>
> -#ifdef HAVE_CONFIG_H
> -#include "config.h"
> -#endif
> -
>   #ifdef HAVE_MTRR
>   #include <machine/sysarch.h>
>   #include <machine/mtrr.h>
>


-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list