Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src * Move definitions of exact-width integer types from <machin...
details: https://anonhg.NetBSD.org/src/rev/208dfc4c3328
branches: trunk
changeset: 509167:208dfc4c3328
user: kleink <kleink%NetBSD.org@localhost>
date: Sat Apr 28 15:41:28 2001 +0000
description:
* Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
diffstat:
include/Makefile | 4 +-
include/inttypes.h | 52 ++++++++++
lib/libc/include/namespace.h | 4 +-
lib/libc/stdio/printf.3 | 65 +++++++++++++-
lib/libc/stdio/scanf.3 | 31 ++++++-
lib/libc/stdio/vfprintf.c | 83 +++++++++++-----
lib/libc/stdio/vfscanf.c | 95 ++++++++++++-------
lib/libc/stdlib/Makefile.inc | 10 +-
lib/libc/stdlib/_strtoimax.c | 49 ++++++++++
lib/libc/stdlib/_strtoumax.c | 49 ++++++++++
lib/libc/stdlib/strtoimax.c | 169 +++++++++++++++++++++++++++++++++++
lib/libc/stdlib/strtol.3 | 46 +++++++-
lib/libc/stdlib/strtoul.3 | 47 +++++++--
lib/libc/stdlib/strtoumax.c | 128 ++++++++++++++++++++++++++
sys/arch/alpha/include/int_types.h | 4 +-
sys/arch/alpha/include/types.h | 18 +---
sys/arch/arm/include/int_types.h | 4 +-
sys/arch/arm/include/types.h | 20 +---
sys/arch/i386/include/int_types.h | 4 +-
sys/arch/i386/include/types.h | 18 +---
sys/arch/m68k/include/int_types.h | 4 +-
sys/arch/m68k/include/types.h | 20 +---
sys/arch/mips/include/int_types.h | 4 +-
sys/arch/mips/include/types.h | 20 +---
sys/arch/pc532/include/int_types.h | 4 +-
sys/arch/pc532/include/types.h | 18 +---
sys/arch/powerpc/include/int_types.h | 4 +-
sys/arch/powerpc/include/types.h | 20 +---
sys/arch/sh3/include/int_types.h | 4 +-
sys/arch/sh3/include/types.h | 20 +---
sys/arch/sparc/include/int_types.h | 4 +-
sys/arch/sparc/include/types.h | 38 +++----
sys/arch/sparc64/include/int_types.h | 4 +-
sys/arch/sparc64/include/types.h | 38 +++----
sys/arch/vax/include/int_types.h | 4 +-
sys/arch/vax/include/types.h | 18 +---
sys/sys/Makefile | 8 +-
sys/sys/inttypes.h | 29 +----
sys/sys/stdint.h | 104 +++++++++++++++++++++
sys/sys/types.h | 52 ++++++++++-
40 files changed, 991 insertions(+), 326 deletions(-)
diffs (truncated from 2254 to 300 lines):
diff -r bfffe14ca3e2 -r 208dfc4c3328 include/Makefile
--- a/include/Makefile Sat Apr 28 15:09:42 2001 +0000
+++ b/include/Makefile Sat Apr 28 15:41:28 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.96 2001/03/19 04:13:16 atatat Exp $
+# $NetBSD: Makefile,v 1.97 2001/04/28 15:41:28 kleink Exp $
# @(#)Makefile 8.2 (Berkeley) 1/4/94
# Doing a make includes builds /usr/include
@@ -8,7 +8,7 @@
INCS= a.out.h ar.h assert.h bitstring.h bm.h cpio.h ctype.h db.h dirent.h \
disktab.h dlfcn.h err.h errno.h fmtmsg.h fnmatch.h fstab.h fts.h \
getopt.h glob.h grp.h hesiod.h ifaddrs.h \
- iso646.h kvm.h langinfo.h libgen.h \
+ inttypes.h iso646.h kvm.h langinfo.h libgen.h \
limits.h link.h link_aout.h link_elf.h locale.h \
login_cap.h malloc.h math.h md2.h md4.h md5.h \
memory.h mpool.h ndbm.h netconfig.h netdb.h netgroup.h nlist.h \
diff -r bfffe14ca3e2 -r 208dfc4c3328 include/inttypes.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/inttypes.h Sat Apr 28 15:41:28 2001 +0000
@@ -0,0 +1,52 @@
+/* $NetBSD: inttypes.h,v 1.1 2001/04/28 15:41:28 kleink Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _INTTYPES_H_
+#define _INTTYPES_H_
+
+#include <sys/cdefs.h>
+#include <sys/inttypes.h>
+
+__BEGIN_DECLS
+intmax_t strtoimax __P((const char * __restrict,
+ char ** __restrict, int));
+uintmax_t strtoumax __P((const char * __restrict,
+ char ** __restrict, int));
+__END_DECLS
+
+#endif /* !_INTTYPES_H_ */
diff -r bfffe14ca3e2 -r 208dfc4c3328 lib/libc/include/namespace.h
--- a/lib/libc/include/namespace.h Sat Apr 28 15:09:42 2001 +0000
+++ b/lib/libc/include/namespace.h Sat Apr 28 15:41:28 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.63 2001/04/13 14:18:09 kleink Exp $ */
+/* $NetBSD: namespace.h,v 1.64 2001/04/28 15:41:29 kleink Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -52,8 +52,10 @@
#define inet_pton _inet_pton
#define pipe _pipe
#define sbrk _sbrk
+#define strtoimax _strtoimax
#define strtoll _strtoll
#define strtoull _strtoull
+#define strtoumax _strtoumax
#define sys_errlist _sys_errlist
#define sys_nerr _sys_nerr
#define sys_siglist _sys_siglist
diff -r bfffe14ca3e2 -r 208dfc4c3328 lib/libc/stdio/printf.3
--- a/lib/libc/stdio/printf.3 Sat Apr 28 15:09:42 2001 +0000
+++ b/lib/libc/stdio/printf.3 Sat Apr 28 15:41:28 2001 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: printf.3,v 1.17 2001/04/26 19:25:12 kleink Exp $
+.\" $NetBSD: printf.3,v 1.18 2001/04/28 15:41:29 kleink Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -37,7 +37,7 @@
.\"
.\" @(#)printf.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd April 26, 2001
.Dt PRINTF 3
.Os
.Sh NAME
@@ -334,6 +334,26 @@
argument.
.It
The optional character
+.Cm j ,
+specifying that a following
+.Cm d ,
+.Cm i ,
+.Cm o ,
+.Cm u ,
+.Cm x ,
+or
+.Cm X
+conversion corresponds to an
+.Em intmax_t
+or
+.Em uintmax_t
+argument, or that a following
+.Cm n
+conversion corresponds to a pointer to a
+.Em intmax_t
+argument.
+.It
+The optional character
.Cm l
(ell) specifying that a following
.Cm d ,
@@ -376,6 +396,47 @@
.Em quad_t
argument.
.It
+The optional character
+.Cm t ,
+specifying that a following
+.Cm d ,
+.Cm i ,
+.Cm o ,
+.Cm u ,
+.Cm x ,
+or
+.Cm X
+conversion corresponds to a
+.Em ptrdiff_t
+or
+the corresponding unsigned integer type
+argument, or that a following
+.Cm n
+conversion corresponds to a pointer to a
+.Em ptrdiff_t
+argument.
+.It
+The optional character
+.Cm z ,
+specifying that a following
+.Cm d ,
+.Cm i ,
+.Cm o ,
+.Cm u ,
+.Cm x ,
+or
+.Cm X
+conversion corresponds to a
+.Em size_t
+or
+the corresponding signed integer type
+argument, or that a following
+.Cm n
+conversion corresponds to a pointer to a
+signed integer type correspoinding to
+.Em ptrdiff_t
+argument.
+.It
The character
.Cm L
specifying that a following
diff -r bfffe14ca3e2 -r 208dfc4c3328 lib/libc/stdio/scanf.3
--- a/lib/libc/stdio/scanf.3 Sat Apr 28 15:09:42 2001 +0000
+++ b/lib/libc/stdio/scanf.3 Sat Apr 28 15:41:28 2001 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: scanf.3,v 1.10 2000/12/29 15:22:51 kleink Exp $
+.\" $NetBSD: scanf.3,v 1.11 2001/04/28 15:41:29 kleink Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -37,7 +37,7 @@
.\"
.\" @(#)scanf.3 8.2 (Berkeley) 12/11/93
.\"
-.Dd January 31, 1995
+.Dd April 26, 2001
.Dt SCANF 3
.Os
.Sh NAME
@@ -152,6 +152,15 @@
.Em short int
(rather than
.Em int ) .
+.It Cm j
+Indicates that the conversion will be one of
+.Cm dioux
+or
+.Cm n
+and the next pointer is a pointer to an
+.Em intmax_t
+(rather than
+.Em int ) .
.It Cm l
Indicates either that the conversion will be one of
.Cm dioux
@@ -176,6 +185,24 @@
.Em quad_t
(rather than
.Em int ) .
+.It Cm t
+Indicates that the conversion will be one of
+.Cm dioux
+or
+.Cm n
+and the next pointer is a pointer to a
+.Em ptrdiff_t
+(rather than
+.Em int ) .
+.It Cm z
+Indicates that the conversion will be one of
+.Cm dioux
+or
+.Cm n
+and the next pointer is a pointer to a
+.Em size_t
+(rather than
+.Em int ) .
.It Cm L
Indicates that the conversion will be
.Cm efg
diff -r bfffe14ca3e2 -r 208dfc4c3328 lib/libc/stdio/vfprintf.c
--- a/lib/libc/stdio/vfprintf.c Sat Apr 28 15:09:42 2001 +0000
+++ b/lib/libc/stdio/vfprintf.c Sat Apr 28 15:41:28 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfprintf.c,v 1.35 2000/12/30 04:13:25 itojun Exp $ */
+/* $NetBSD: vfprintf.c,v 1.36 2001/04/28 15:41:29 kleink Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -41,7 +41,7 @@
#if 0
static char *sccsid = "@(#)vfprintf.c 5.50 (Berkeley) 12/16/92";
#else
-__RCSID("$NetBSD: vfprintf.c,v 1.35 2000/12/30 04:13:25 itojun Exp $");
+__RCSID("$NetBSD: vfprintf.c,v 1.36 2001/04/28 15:41:29 kleink Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -56,6 +56,8 @@
#include <assert.h>
#include <errno.h>
+#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -186,8 +188,11 @@
#define LONGINT 0x010 /* long integer */
#define QUADINT 0x020 /* quad integer */
#define SHORTINT 0x040 /* short integer */
-#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
-#define FPT 0x100 /* Floating point number */
+#define MAXINT 0x080 /* (unsigned) intmax_t */
+#define PTRINT 0x100 /* (unsigned) ptrdiff_t */
+#define SIZEINT 0x200 /* (signed) size_t */
+#define ZEROPAD 0x400 /* zero (as opposed to blank) pad */
+#define FPT 0x800 /* Floating point number */
int
vfprintf(fp, fmt0, ap)
FILE *fp;
@@ -222,7 +227,10 @@
#define u_quad_t unsigned long long
#endif
- u_quad_t _uquad; /* integer arguments %[diouxX] */
+#define INTMAX_T intmax_t
+#define UINTMAX_T uintmax_t
+
+ UINTMAX_T _uintmax; /* integer arguments %[diouxX] */
enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */
int dprec; /* a copy of prec if [diouxX], 0 otherwise */
int realsz; /* field size expanded by dprec */
@@ -280,12 +288,18 @@
Home |
Main Index |
Thread Index |
Old Index