File indexing completed on 2024-04-21 15:38:03

0001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
0002 /* ***** BEGIN LICENSE BLOCK *****
0003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
0004  *
0005  * The contents of this file are subject to the Mozilla Public License Version
0006  * 1.1 (the "License"); you may not use this file except in compliance with
0007  * the License. You may obtain a copy of the License at
0008  * http://www.mozilla.org/MPL/
0009  *
0010  * Software distributed under the License is distributed on an "AS IS" basis,
0011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
0012  * for the specific language governing rights and limitations under the
0013  * License.
0014  *
0015  * The Original Code is mozilla.org code.
0016  *
0017  * The Initial Developer of the Original Code is
0018  * mozilla.org.
0019  * Portions created by the Initial Developer are Copyright (C) 2004
0020  * the Initial Developer. All Rights Reserved.
0021  *
0022  * Contributor(s):
0023  *   Johnny Stenback <jst@mozilla.org> (Original author)
0024  *
0025  * Alternatively, the contents of this file may be used under the terms of
0026  * either the GNU General Public License Version 2 or later (the "GPL"), or
0027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
0028  * in which case the provisions of the GPL or the LGPL are applicable instead
0029  * of those above. If you wish to allow use of your version of this file only
0030  * under the terms of either the GPL or the LGPL, and not to allow others to
0031  * use your version of this file under the terms of the MPL, indicate your
0032  * decision by deleting the provisions above and replace them with the notice
0033  * and other provisions required by the GPL or the LGPL. If you do not delete
0034  * the provisions above, a recipient may use your version of this file under
0035  * the terms of any one of the MPL, the GPL or the LGPL.
0036  *
0037  * ***** END LICENSE BLOCK ***** */
0038 
0039 /*
0040  * Header file for ensuring that C99 types ([u]int32_t and bool) and
0041  * true/false macros are available.
0042  */
0043 
0044 #if defined(WIN32) || defined(OS2)
0045   /*
0046    * Win32 and OS/2 don't know C99, so define [u]int_16/32 here. The bool
0047    * is predefined tho, both in C and C++.
0048    */
0049   typedef short int16_t;
0050   typedef unsigned short uint16_t;
0051   typedef int int32_t;
0052   typedef unsigned int uint32_t;
0053 #elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX)
0054   /*
0055    * AIX and SunOS ship a inttypes.h header that defines [u]int32_t,
0056    * but not bool for C.
0057    */
0058   #include <inttypes.h>
0059 
0060   #ifndef __cplusplus
0061     typedef int bool;
0062     #define true   1
0063     #define false  0
0064   #endif
0065 #elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD)
0066   /*
0067    * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and 
0068    * u_int32_t.
0069    */
0070   #include <sys/types.h>
0071 
0072   /*
0073    * BSD/OS ships no header that defines uint32_t, nor bool (for C)
0074    */
0075   #if defined(bsdi)
0076   typedef u_int32_t uint32_t;
0077 
0078   #if !defined(__cplusplus)
0079     typedef int bool;
0080     #define true   1
0081     #define false  0
0082   #endif
0083   #else
0084   /*
0085    * FreeBSD and OpenBSD define uint32_t and bool.
0086    */
0087     #include <inttypes.h>
0088     #include <stdbool.h>
0089   #endif
0090 #elif defined(BEOS)
0091   #include <inttypes.h>
0092 #else
0093   /*
0094    * For those that ship a standard C99 stdint.h header file, include
0095    * it. Can't do the same for stdbool.h tho, since some systems ship
0096    * with a stdbool.h file that doesn't compile!
0097    */
0098   #include <stdint.h>
0099 
0100   #ifndef __cplusplus
0101     #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95)
0102       #include <stdbool.h>
0103     #else
0104       /*
0105        * GCC 2.91 can't deal with a typedef for bool, but a #define
0106        * works.
0107        */
0108       #define bool int
0109       #define true   1
0110       #define false  0
0111     #endif
0112   #endif
0113 #endif