dom/plugins/base/nptypes.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/base/nptypes.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     1.4 +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nptypes_h_
    1.10 +#define nptypes_h_
    1.11 +
    1.12 +/*
    1.13 + * Header file for ensuring that C99 types ([u]int32_t, [u]int64_t and bool) and
    1.14 + * true/false macros are available.
    1.15 + */
    1.16 +
    1.17 +#if defined(WIN32)
    1.18 +  /*
    1.19 +   * Win32 and OS/2 don't know C99, so define [u]int_16/32/64 here. The bool
    1.20 +   * is predefined tho, both in C and C++.
    1.21 +   */
    1.22 +  typedef short int16_t;
    1.23 +  typedef unsigned short uint16_t;
    1.24 +  typedef int int32_t;
    1.25 +  typedef unsigned int uint32_t;
    1.26 +  typedef long long int64_t;
    1.27 +  typedef unsigned long long uint64_t;
    1.28 +#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX)
    1.29 +  /*
    1.30 +   * AIX and SunOS ship a inttypes.h header that defines [u]int32_t,
    1.31 +   * but not bool for C.
    1.32 +   */
    1.33 +  #include <inttypes.h>
    1.34 +
    1.35 +  #ifndef __cplusplus
    1.36 +    typedef int bool;
    1.37 +    #define true   1
    1.38 +    #define false  0
    1.39 +  #endif
    1.40 +#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD)
    1.41 +  /*
    1.42 +   * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and
    1.43 +   * u_int32_t.
    1.44 +   */
    1.45 +  #include <sys/types.h>
    1.46 +
    1.47 +  /*
    1.48 +   * BSD/OS ships no header that defines uint32_t, nor bool (for C)
    1.49 +   */
    1.50 +  #if defined(bsdi)
    1.51 +  typedef u_int32_t uint32_t;
    1.52 +  typedef u_int64_t uint64_t;
    1.53 +
    1.54 +  #if !defined(__cplusplus)
    1.55 +    typedef int bool;
    1.56 +    #define true   1
    1.57 +    #define false  0
    1.58 +  #endif
    1.59 +  #else
    1.60 +  /*
    1.61 +   * FreeBSD and OpenBSD define uint32_t and bool.
    1.62 +   */
    1.63 +    #include <inttypes.h>
    1.64 +    #include <stdbool.h>
    1.65 +  #endif
    1.66 +#elif defined(BEOS)
    1.67 +  #include <inttypes.h>
    1.68 +#else
    1.69 +  /*
    1.70 +   * For those that ship a standard C99 stdint.h header file, include
    1.71 +   * it. Can't do the same for stdbool.h tho, since some systems ship
    1.72 +   * with a stdbool.h file that doesn't compile!
    1.73 +   */
    1.74 +  #include <stdint.h>
    1.75 +
    1.76 +  #ifndef __cplusplus
    1.77 +    #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95)
    1.78 +      #include <stdbool.h>
    1.79 +    #else
    1.80 +      /*
    1.81 +       * GCC 2.91 can't deal with a typedef for bool, but a #define
    1.82 +       * works.
    1.83 +       */
    1.84 +      #define bool int
    1.85 +      #define true   1
    1.86 +      #define false  0
    1.87 +    #endif
    1.88 +  #endif
    1.89 +#endif
    1.90 +
    1.91 +#endif /* nptypes_h_ */

mercurial