On Thu, 5 May 2011, David E. O'Brien wrote:

Log:
 Don't duplicate define the stdint types.

This is a regression.  The [_]stdint.h files were correctly structured before.

The stdint types weren't duplicate-defined (modulo bugs), but their
definitions were repeated as necessary inside ifdfs.  Using an omnibus
header like sys/_stdint.h gives uncontrollable namespace pollution.

 head/sys/sys/_stdint.h
    - copied, changed from r221139, head/sys/sys/stdint.h

sys/_stdint.h was intentionally left out, since it can only be used to
increase namespace pollution (unlike machine/_stdint.h, which exists to
avoid namespace pollution).

Modified: head/lib/libutil/libutil.h
==============================================================================
--- head/lib/libutil/libutil.h  Thu May  5 14:43:35 2011        (r221501)
+++ head/lib/libutil/libutil.h  Thu May  5 14:45:24 2011        (r221502)
@@ -41,22 +41,13 @@

#include <sys/cdefs.h>
#include <sys/_types.h>
+#include <sys/_stdint.h>

This also unsorts the includes.

#ifndef _GID_T_DECLARED
typedef __gid_t         gid_t;
#define _GID_T_DECLARED
#endif

-#ifndef _INT64_T_DECLARED
-typedef        __int64_t       int64_t;
-#define        _INT64_T_DECLARED
-#endif
-
-#ifndef _UINT64_T_DECLARED
-typedef        __uint64_t      uint64_t;
-#define        _UINT64_T_DECLARED
-#endif
-

It used to define only 2 application types from <stdint.h>.  Hopefully
precisely the ones that it used.  Now it defines all the application
types defined in <sys/_stdint.h>, and it can't control pollution bloat
if the latter is expanded.

#ifndef _PID_T_DECLARED
typedef __pid_t         pid_t;
#define _PID_T_DECLARED

Copied and modified: head/sys/sys/_stdint.h (from r221139, 
head/sys/sys/stdint.h)
==============================================================================
--- head/sys/sys/stdint.h       Wed Apr 27 20:42:30 2011        (r221139, copy 
source)
+++ head/sys/sys/_stdint.h      Thu May  5 14:45:24 2011        (r221502)
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 2011 David E. O'Brien <obr...@freebsd.org>
 * Copyright (c) 2001 Mike Barcroft <m...@freebsd.org>
 * All rights reserved.
 *
@@ -26,13 +27,8 @@
 * $FreeBSD$
 */

-#ifndef _SYS_STDINT_H_
-#define _SYS_STDINT_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-#include <machine/_stdint.h>
+#ifndef _SYS__STDINT_H_
+#define _SYS__STDINT_H_

#ifndef _INT8_T_DECLARED
typedef __int8_t                int8_t;
@@ -74,33 +70,13 @@ typedef     __uint64_t              uint64_t;
#define _UINT64_T_DECLARED
#endif

-typedef        __int_least8_t          int_least8_t;
-typedef        __int_least16_t         int_least16_t;
-typedef        __int_least32_t         int_least32_t;
-typedef        __int_least64_t         int_least64_t;
-
-typedef        __uint_least8_t         uint_least8_t;
-typedef        __uint_least16_t        uint_least16_t;
-typedef        __uint_least32_t        uint_least32_t;
-typedef        __uint_least64_t        uint_least64_t;
-
-typedef        __int_fast8_t           int_fast8_t;
-typedef        __int_fast16_t          int_fast16_t;
-typedef        __int_fast32_t          int_fast32_t;
-typedef        __int_fast64_t          int_fast64_t;
-
-typedef        __uint_fast8_t          uint_fast8_t;
-typedef        __uint_fast16_t         uint_fast16_t;
-typedef        __uint_fast32_t         uint_fast32_t;
-typedef        __uint_fast64_t         uint_fast64_t;
-
-typedef        __intmax_t              intmax_t;
-typedef        __uintmax_t             uintmax_t;
-
#ifndef _INTPTR_T_DECLARED
typedef __intptr_t              intptr_t;
-typedef        __uintptr_t             uintptr_t;
#define _INTPTR_T_DECLARED
#endif
+#ifndef _UINTPTR_T_DECLARED
+typedef        __uintptr_t             uintptr_t;
+#define        _UINTPTR_T_DECLARED
+#endif

-#endif /* !_SYS_STDINT_H_ */
+#endif /* !_SYS__STDINT_H_ */

Modified: head/sys/sys/stdint.h
==============================================================================
--- head/sys/sys/stdint.h       Thu May  5 14:43:35 2011        (r221501)
+++ head/sys/sys/stdint.h       Thu May  5 14:45:24 2011        (r221502)
@@ -33,46 +33,7 @@
#include <sys/_types.h>

#include <machine/_stdint.h>
-
-#ifndef _INT8_T_DECLARED
-typedef        __int8_t                int8_t;
-#define        _INT8_T_DECLARED
-#endif
-
-#ifndef _INT16_T_DECLARED
-typedef        __int16_t               int16_t;
-#define        _INT16_T_DECLARED
-#endif
-
-#ifndef _INT32_T_DECLARED
-typedef        __int32_t               int32_t;
-#define        _INT32_T_DECLARED
-#endif
-
-#ifndef _INT64_T_DECLARED
-typedef        __int64_t               int64_t;
-#define        _INT64_T_DECLARED
-#endif
-
-#ifndef _UINT8_T_DECLARED
-typedef        __uint8_t               uint8_t;
-#define        _UINT8_T_DECLARED
-#endif
-
-#ifndef _UINT16_T_DECLARED
-typedef        __uint16_t              uint16_t;
-#define        _UINT16_T_DECLARED
-#endif
-
-#ifndef _UINT32_T_DECLARED
-typedef        __uint32_t              uint32_t;
-#define        _UINT32_T_DECLARED
-#endif
-
-#ifndef _UINT64_T_DECLARED
-typedef        __uint64_t              uint64_t;
-#define        _UINT64_T_DECLARED
-#endif
+#include <sys/_stdint.h>

typedef __int_least8_t          int_least8_t;
typedef __int_least16_t         int_least16_t;
@@ -94,13 +55,13 @@ typedef     __uint_fast16_t         uint_fast16_t;
typedef __uint_fast32_t         uint_fast32_t;
typedef __uint_fast64_t         uint_fast64_t;

+#ifndef _INTMAX_T_DECLARED
typedef __intmax_t              intmax_t;
+#define        _INTMAX_T_DECLARED
+#endif
+#ifndef _UINTMAX_T_DECLARED
typedef __uintmax_t             uintmax_t;
-
-#ifndef _INTPTR_T_DECLARED
-typedef        __intptr_t              intptr_t;
-typedef        __uintptr_t             uintptr_t;
-#define        _INTPTR_T_DECLARED
+#define        _UINTMAX_T_DECLARED
#endif

#endif /* !_SYS_STDINT_H_ */

sys/stdint.h (= <stdint.h>) is obfuscated by putting its main definitions
in sys/_types.h and sys/_stdint.h.  Its bad enough that its basic
definitions are not visible.  Hmm, why does it use sys/_types.h?  That
only declares POSIX-related typedefs, but <stdint.h> cannot declare  any
POSIX-related types.

Modified: head/sys/sys/types.h
==============================================================================
--- head/sys/sys/types.h        Thu May  5 14:43:35 2011        (r221501)
+++ head/sys/sys/types.h        Thu May  5 14:45:24 2011        (r221502)
@@ -60,51 +60,7 @@ typedef      unsigned int    uint;           /* Sys V com
/*
 * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
 */

As the XXX comment says, it is a bug for these to be declared here at
all.  Applications must include <stdint.h> if they want to use the
types in it.  Some of the types that should be declared only in
<stdint.h> are declared here for historical reasons.  The pollution
has been here so long (together with other pollution), that it is now
very hard to clean up.  Probably the kernel was the main abuser of the
pollution here.  here.  But now the kernel is even more polluted by
default, so the pollution here has almost no effect on the kernel,
since <sys/systm.h> was polluted to include <sys/stdint.h> mainly for
the convenience of casting things to intmax_t, etc., in printfs.

-#ifndef _INT8_T_DECLARED
-typedef        __int8_t        int8_t;
-#define        _INT8_T_DECLARED
-#endif
-
-#ifndef _INT16_T_DECLARED
-typedef        __int16_t       int16_t;
-#define        _INT16_T_DECLARED
-#endif
-
-#ifndef _INT32_T_DECLARED
-typedef        __int32_t       int32_t;
-#define        _INT32_T_DECLARED
-#endif
-
-#ifndef _INT64_T_DECLARED
-typedef        __int64_t       int64_t;
-#define        _INT64_T_DECLARED
-#endif
-
-#ifndef _UINT8_T_DECLARED
-typedef        __uint8_t       uint8_t;
-#define        _UINT8_T_DECLARED
-#endif
-
-#ifndef _UINT16_T_DECLARED
-typedef        __uint16_t      uint16_t;
-#define        _UINT16_T_DECLARED
-#endif
-
-#ifndef _UINT32_T_DECLARED
-typedef        __uint32_t      uint32_t;
-#define        _UINT32_T_DECLARED
-#endif
-
-#ifndef _UINT64_T_DECLARED
-typedef        __uint64_t      uint64_t;
-#define        _UINT64_T_DECLARED
-#endif
-
-#ifndef _INTPTR_T_DECLARED
-typedef        __intptr_t      intptr_t;
-typedef        __uintptr_t     uintptr_t;
-#define        _INTPTR_T_DECLARED
-#endif
+#include <sys/_stdint.h>

Declaring the pollution in another header expands the bug and makes
it harder to see how large it is.


typedef __uint8_t       u_int8_t;       /* unsigned integrals (deprecated) */
typedef __uint16_t      u_int16_t;


Bruce
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to