u_int32_t vs uint32_t

Stuart Kreitman Stuart.Kreitman at Sun.COM
Mon Aug 23 09:00:50 PDT 2004


Matthieu:
The editor "fgsch" made the change to u_int32_t in OpenBSD sources
in April 2002 with your review.  Jim Gettys picked it up this weekend
for the X.ORG next release.

We need to explain how the typedefs "u_int32_t" vs "uint32_t" conform to 
various
standards in ANSI or ISO.  I do not have access to the OpenBSD files, 
but include
the relevent statements from Solaris:


Excerpted from <sys/int_types.h> on Solaris 10:

#pragma ident   "@(#)int_types.h        1.9     04/06/14 SMI"

/*
 * This file, <sys/int_types.h>, is part of the Sun Microsystems 
implementation
 * of <inttypes.h> defined in the ISO C standard, ISO/IEC 9899:1999
 * Programming language - C.
 *
 * Programs/Modules should not directly include this file.  Access to the
 * types defined in this file should be through the inclusion of one of the
 * following files:
 *
 *      <sys/types.h>           Provides only the "_t" types defined in this
 *                              file which is a subset of the contents of
 *                              <inttypes.h>.  (This can be appropriate for
 *                              all programs/modules except those claiming
 *                              ANSI-C conformance.)
 *
 *      <sys/inttypes.h>        Provides the Kernel and Driver appropriate
 *                              components of <inttypes.h>.
 *
 *      <inttypes.h>            For use by applications.
 *
 * See these files for more details.
 */

#include <sys/feature_tests.h>
#include <sys/isa_defs.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Basic / Extended integer types
 *
 * The following defines the basic fixed-size integer types.
 *
 * Implementations are free to typedef them to Standard C integer types or
 * extensions that they support. If an implementation does not support one
 * of the particular integer data types below, then it should not define the
 * typedefs and macros corresponding to that data type.  Note that int8_t
 * is not defined in -Xs mode on ISAs for which the ABI specifies "char"
 * as an unsigned entity because there is no way to define an eight bit
 * signed integral.
 */
#if defined(_CHAR_IS_SIGNED)
typedef char                    int8_t;
#else
#if defined(__STDC__)
typedef signed char             int8_t;
#endif
#endif
typedef short                   int16_t;
typedef int                     int32_t;
#ifdef  _LP64
#define _INT64_TYPE
typedef long                    int64_t;
#else   /* _ILP32 */
#if defined(_LONGLONG_TYPE)
#define _INT64_TYPE
typedef long long               int64_t;
#endif
#endif

typedef unsigned char           uint8_t;
typedef unsigned short          uint16_t;
typedef unsigned int            uint32_t;
#ifdef  _LP64
typedef unsigned long           uint64_t;
#else   /* _ILP32 */
#if defined(_LONGLONG_TYPE)
typedef unsigned long long      uint64_t;
#endif
#endif




More information about the release-wranglers mailing list