From aa492f3cbdf42eb52f6783dd174eebf01b0b7964 Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Tue, 7 Mar 2000 22:48:41 +0000 Subject: Bugzilla bug #30367: define uint for Neutrino. Rearranged the ifdef's in protypes.h so that it is easier to understand. Added the test obsints.c to ensure that all the (obsolete) integer types are defined. Added file: pr/tests/obsints.c Modified files: protypes.h, pr/tests/Makefile, pr/tests/Makefile.in --- pr/include/obsolete/protypes.h | 117 ++++++++++++++++++++++++++++++++--------- pr/tests/Makefile | 1 + pr/tests/Makefile.in | 1 + pr/tests/obsints.c | 64 ++++++++++++++++++++++ 4 files changed, 159 insertions(+), 24 deletions(-) create mode 100644 pr/tests/obsints.c diff --git a/pr/include/obsolete/protypes.h b/pr/include/obsolete/protypes.h index 631137e4..75be482e 100644 --- a/pr/include/obsolete/protypes.h +++ b/pr/include/obsolete/protypes.h @@ -17,7 +17,7 @@ */ /* - * This section typedefs the old 'native' types to the new PRs. + * This header typedefs the old 'native' types to the new PRs. * These definitions are scheduled to be eliminated at the earliest * possible time. The NSPR API is implemented and documented using * the new definitions. @@ -32,53 +32,107 @@ typedef PRIntn intn; #endif /* - * BeOS already defines the integer types below in its standard - * header file SupportDefs.h. + * It is trickier to define uint, int8, uint8, int16, uint16, + * int32, uint32, int64, and uint64 because some of these int + * types are defined by standard header files on some platforms. + * Our strategy here is to include all such standard headers + * first, and then define these int types only if they are not + * defined by those standard headers. */ -#ifdef XP_BEOS +/* + * BeOS defines all the int types below in its standard header + * file SupportDefs.h. + */ +#ifdef XP_BEOS #include +#endif -#elif defined(VMS) /* - * OpenVMS already defines the integer types below in its standard + * OpenVMS defines all the int types below in its standard * header files ints.h and types.h. */ +#ifdef VMS #include #include -#else +#endif -/* SVR4 typedef of uint is commonly found on UNIX machines. */ +/* + * SVR4 typedef of uint is commonly found on UNIX machines. + * + * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h) + * defines the types int8, int16, int32, and int64. + */ #ifdef XP_UNIX #include -#else +#endif + +/* model.h on HP-UX defines int8, int16, and int32. */ +#ifdef HPUX +#include +#endif + +/* + * uint + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(XP_UNIX) || defined(NTO) typedef PRUintn uint; #endif +/* + * uint64 + */ + +#if !defined(XP_BEOS) && !defined(VMS) typedef PRUint64 uint64; +#endif + +/* + * uint32 + */ + +#if !defined(XP_BEOS) && !defined(VMS) #if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) typedef PRUint32 uint32; #else typedef unsigned long uint32; #endif +#endif + +/* + * uint16 + */ + +#if !defined(XP_BEOS) && !defined(VMS) typedef PRUint16 uint16; +#endif + +/* + * uint8 + */ + +#if !defined(XP_BEOS) && !defined(VMS) typedef PRUint8 uint8; +#endif /* - * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very - * common header file) defines the types int8, int16, int32, and int64. - * So we don't define these four types here to avoid conflicts in case - * the code also includes sys/types.h. + * int64 */ -#if defined(_PR_AIX_HAVE_BSD_INT_TYPES) -/* is already included */ -#else + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) typedef PRInt64 int64; +#endif -/* /usr/include/model.h on HP-UX defines int8, int16, and int32 */ -#if defined(HPUX) -#include -#else +/* + * int32 + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) #if !defined(WIN32) || !defined(_WINSOCK2API_) /* defines its own "int32" */ #if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) typedef PRInt32 int32; @@ -86,12 +140,27 @@ typedef PRInt32 int32; typedef long int32; #endif #endif +#endif + +/* + * int16 + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) typedef PRInt16 int16; -typedef PRInt8 int8; -#endif /* HPUX */ -#endif /* _PR_AIX_HAVE_BSD_INT_TYPES */ +#endif -#endif /* XP_BEOS VMS */ +/* + * int8 + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) +typedef PRInt8 int8; +#endif typedef PRFloat64 float64; typedef PRUptrdiff uptrdiff_t; diff --git a/pr/tests/Makefile b/pr/tests/Makefile index d1851723..bdb0c4a3 100644 --- a/pr/tests/Makefile +++ b/pr/tests/Makefile @@ -95,6 +95,7 @@ CSRCS = \ nonblock.c \ ntioto.c \ ntoh.c \ + obsints.c \ op_2long.c \ op_excl.c \ op_filnf.c \ diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in index 30dad6d7..dc58a025 100644 --- a/pr/tests/Makefile.in +++ b/pr/tests/Makefile.in @@ -99,6 +99,7 @@ CSRCS = \ nonblock.c \ ntioto.c \ ntoh.c \ + obsints.c \ op_2long.c \ op_excl.c \ op_filnf.c \ diff --git a/pr/tests/obsints.c b/pr/tests/obsints.c new file mode 100644 index 00000000..684734e2 --- /dev/null +++ b/pr/tests/obsints.c @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* + * Test: obsints.c + * + * Description: make sure that protypes.h defines the obsolete integer + * types intn, uintn, uint, int8, uint8, int16, uint16, int32, uint32, + * int64, and uint64. + */ + +#include + +#ifdef NO_NSPR_10_SUPPORT + +/* nothing to do */ +int main() +{ + printf("PASS\n"); + return 0; +} + +#else /* NO_NSPR_10_SUPPORT */ + +#include "prtypes.h" /* which includes protypes.h */ + +int main() +{ + /* + * Compilation fails if any of these integer types are not + * defined by protypes.h. + */ + intn in; + uintn uin; + uint ui; + int8 i8; + uint8 ui8; + int16 i16; + uint16 ui16; + int32 i32; + uint32 ui32; + int64 i64; + uint64 ui64; + + printf("PASS\n"); + return 0; +} + +#endif /* NO_NSPR_10_SUPPORT */ -- cgit v1.2.1