15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* ***** BEGIN LICENSE BLOCK *****
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Version: MPL 1.1/GPL 2.0/LGPL 2.1
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The contents of this file are subject to the Mozilla Public License Version
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 1.1 (the "License"); you may not use this file except in compliance with
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the License. You may obtain a copy of the License at
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * http://www.mozilla.org/MPL/
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Software distributed under the License is distributed on an "AS IS" basis,
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * for the specific language governing rights and limitations under the
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * License.
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Original Code is mozilla.org code.
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Initial Developer of the Original Code is
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * mozilla.org.
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Portions created by the Initial Developer are Copyright (C) 2004
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the Initial Developer. All Rights Reserved.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Contributor(s):
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *   Johnny Stenback <jst@mozilla.org> (Original author)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Alternatively, the contents of this file may be used under the terms of
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * either the GNU General Public License Version 2 or later (the "GPL"), or
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * in which case the provisions of the GPL or the LGPL are applicable instead
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * of those above. If you wish to allow use of your version of this file only
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * under the terms of either the GPL or the LGPL, and not to allow others to
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * use your version of this file under the terms of the MPL, indicate your
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * decision by deleting the provisions above and replace them with the notice
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * and other provisions required by the GPL or the LGPL. If you do not delete
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the provisions above, a recipient may use your version of this file under
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the terms of any one of the MPL, the GPL or the LGPL.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * ***** END LICENSE BLOCK ***** */
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef nptypes_h_
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define nptypes_h_
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Header file for ensuring that C99 types ([u]int32_t, [u]int64_t and bool) and
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * true/false macros are available.
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(WIN32) || defined(OS2)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /*
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Win32 and OS/2 don't know C99, so define [u]int_16/32/64 here. The bool
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * is predefined tho, both in C and C++.
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef short int16_t;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned short uint16_t;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef int int32_t;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned int uint32_t;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef long long int64_t;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef unsigned long long uint64_t;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /*
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * AIX and SunOS ship a inttypes.h header that defines [u]int32_t,
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * but not bool for C.
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #include <inttypes.h>
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #ifndef __cplusplus
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    typedef int bool;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #define true   1
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #define false  0
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #endif
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /*
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * u_int32_t.
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #include <sys/types.h>
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /*
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * BSD/OS ships no header that defines uint32_t, nor bool (for C)
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #if defined(bsdi)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef u_int32_t uint32_t;
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef u_int64_t uint64_t;
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #if !defined(__cplusplus)
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    typedef int bool;
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #define true   1
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #define false  0
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #endif
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #else
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /*
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * FreeBSD and OpenBSD define uint32_t and bool.
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #include <inttypes.h>
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #include <stdbool.h>
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #endif
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(BEOS)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #include <inttypes.h>
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /*
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * For those that ship a standard C99 stdint.h header file, include
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * it. Can't do the same for stdbool.h tho, since some systems ship
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * with a stdbool.h file that doesn't compile!
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #include <stdint.h>
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #ifndef __cplusplus
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95)
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      #include <stdbool.h>
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #else
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      /*
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)       * GCC 2.91 can't deal with a typedef for bool, but a #define
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)       * works.
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)       */
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      #define bool int
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      #define true   1
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      #define false  0
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #endif
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #endif
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* nptypes_h_ */
122