File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / iftop / integers.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 16:57:34 2012 UTC (12 years, 3 months ago) by misho
Branches: iftop, MAIN
CVS tags: v1_0rc4, v0_17p0, v0_17, HEAD
iftop

    1: /*
    2:  * integers.h:
    3:  * This header file ensures that we have u_int<n>_t types of the proper width,
    4:  * using a rather convoluted set of conditionals generated by configure. This
    5:  * is an almighty pain in the arse, and is completely irrelevant on most
    6:  * systems which already define this stuff.
    7:  *
    8:  * $Id: integers.h,v 1.1.1.1 2012/02/21 16:57:34 misho Exp $
    9:  *
   10:  */
   11: 
   12: #ifndef __INTEGERS_H_ /* include guard */
   13: #define __INTEGERS_H_
   14: 
   15: #include <sys/types.h>
   16: #include "config.h"
   17: 
   18: #if SIZEOF_U_INT8_T != 1 || SIZEOF_U_INT16_T != 2 || SIZEOF_U_INT32_T != 4
   19: 
   20: #   if defined(HAVE_C99_INTS)
   21:         
   22:         /* 
   23:          * Use the C99 standard-width integers, defined in some appropriate
   24:          * header file.
   25:          */
   26: 
   27: #       if defined(HAVE_STDINT_H)
   28: #           include <stdint.h>
   29: #       elif defined(HAVE_SYS_INTTYPES_H)
   30: #           include <sys/inttypes.h>
   31: #       endif
   32: 
   33:         /* Don't replace existing u_int<n>_t types. */
   34: #       if SIZEOF_U_INT8_T != 1
   35:             typedef uint8_t u_int8_t;
   36: #       endif
   37: 
   38: #       if SIZEOF_U_INT16_T != 2
   39:             typedef uint16_t u_int16_t;
   40: #       endif
   41: 
   42: #       if SIZEOF_U_INT32_T != 4
   43:             typedef uint32_t u_int32_t;
   44: #       endif
   45: 
   46: #   elif (SIZEOF_UNSIGNED_SHORT_INT == 2 || SIZEOF_UNSIGNED_INT == 2)    \
   47:           && (SIZEOF_UNSIGNED_INT == 4 || SIZEOF_UNSIGNED_LONG_INT == 4)
   48:     
   49:         /*
   50:          * Use an appropriately-sized basic type.
   51:          */
   52:     
   53: #       if SIZEOF_U_INT8_T != 1
   54:             typedef unsigned char u_int8_t;         /* By definition. */
   55: #       endif
   56: 
   57: #       if SIZEOF_U_INT16_T != 2
   58: #           if SIZEOF_UNSIGNED_SHORT_INT == 2
   59:                 typedef unsigned short int u_int16_t;
   60: #           elif SIZEOF_UNSIGNED_INT == 2
   61:                 typedef unsigned int u_int16_t;     /* Not likely. */
   62: #           endif
   63: #       endif
   64: 
   65: #       if SIZEOF_U_INT32_T != 4
   66: #           if SIZEOF_UNSIGNED_INT == 4
   67:                 typedef unsigned int u_int32_t;
   68: #           elif SIZEOF_UNSIGNED_LONG_INT == 4
   69:                 typedef unsigned long int u_int32_t;
   70: #           endif
   71: #       endif
   72: 
   73:         /* Whew. */
   74: 
   75: #   else
   76: #       error "Your C compiler seems to lack 16 and 32 bit unsigned integer types"
   77: #   endif
   78: 
   79: #endif /* No existing u_int<n>_t types. */
   80: 
   81: #endif /* __INTEGERS_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>