portab.h: Restructure and clean up code

- Don't use HAVE_SYS_TYPES_H, <sys/types.h> is a required header now.
- Streamline check for boolean data types.
- Better indent #ifdef constructs.
This commit is contained in:
Alexander Barton 2014-03-17 01:17:30 +01:00
parent 67256f9da1
commit 37090a28e8
1 changed files with 40 additions and 44 deletions

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors. * Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,28 +23,6 @@
# define NDEBUG # define NDEBUG
#endif #endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
# define NGIRC_GOT_INTTYPES
#else
# ifdef HAVE_STDINT_H
# include <stdint.h>
# define NGIRC_GOT_INTTYPES
# endif
#endif
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#endif
/* compiler features */ /* compiler features */
#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7)) #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
@ -65,6 +43,22 @@
/* datatypes */ /* datatypes */
#include <sys/types.h>
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
# define NGIRC_GOT_INTTYPES
#else
# ifdef HAVE_STDINT_H
# include <stdint.h>
# define NGIRC_GOT_INTTYPES
# endif
#endif
#ifndef PROTOTYPES #ifndef PROTOTYPES
# ifndef signed # ifndef signed
# define signed # define signed
@ -83,7 +77,9 @@ typedef unsigned short UINT16;
typedef unsigned int UINT32; typedef unsigned int UINT32;
#endif #endif
#ifndef HAVE_STDBOOL_H #ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else
typedef unsigned char bool; typedef unsigned char bool;
# define true (bool)1 # define true (bool)1
# define false (bool)0 # define false (bool)0