Add generic versions of machine/int_*.h for compilers providing

appropiate macros for all necessary types.
This commit is contained in:
joerg 2014-07-25 21:43:13 +00:00
parent c34b7725c2
commit d87708c52a
22 changed files with 658 additions and 19 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1903 2014/07/25 08:32:22 dholland Exp $
# $NetBSD: mi,v 1.1904 2014/07/25 21:43:13 joerg Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -3129,6 +3129,11 @@
./usr/include/sys/chio.h comp-c-include
./usr/include/sys/clist.h comp-obsolete obsolete
./usr/include/sys/clockctl.h comp-c-include
./usr/include/sys/common_int_const.h comp-c-include
./usr/include/sys/common_int_fmtio.h comp-c-include
./usr/include/sys/common_int_limits.h comp-c-include
./usr/include/sys/common_int_mwgwtypes.h comp-c-include
./usr/include/sys/common_int_types.h comp-c-include
./usr/include/sys/condvar.h comp-c-include
./usr/include/sys/conf.h comp-c-include
./usr/include/sys/core.h comp-c-include

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_const.h,v 1.4 2010/05/29 17:33:57 tnozaki Exp $ */
/* $NetBSD: int_const.h,v 1.5 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _AMD64_INT_CONST_H_
#define _AMD64_INT_CONST_H_
#ifdef __INTMAX_C_SUFFIX__
#include <sys/common_int_const.h>
#else
#ifdef __x86_64__
/*
@ -61,4 +65,6 @@
#endif /* __x86_64__ */
#endif
#endif /* !_AMD64_INT_CONST_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_fmtio.h,v 1.6 2008/10/26 00:08:15 mrg Exp $ */
/* $NetBSD: int_fmtio.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _AMD64_INT_FMTIO_H_
#define _AMD64_INT_FMTIO_H_
#ifdef __INTPTR_FMTd__
#include <sys/common_int_fmtio.h>
#else
#ifdef __x86_64__
/*
@ -217,4 +221,6 @@
#endif /* __x86_64__ */
#endif
#endif /* !_AMD64_INT_FMTIO_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_limits.h,v 1.8 2012/01/27 15:41:02 christos Exp $ */
/* $NetBSD: int_limits.h,v 1.9 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _AMD64_INT_LIMITS_H_
#define _AMD64_INT_LIMITS_H_
#ifdef __SIG_ATOMIC_MAX__
#include <sys/common_int_limits.h>
#else
#ifdef __x86_64__
/*
@ -132,4 +136,6 @@
#endif /* __x86_64__ */
#endif
#endif /* !_AMD64_INT_LIMITS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_mwgwtypes.h,v 1.7 2008/10/26 00:08:15 mrg Exp $ */
/* $NetBSD: int_mwgwtypes.h,v 1.8 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _AMD64_INT_MWGWTYPES_H_
#define _AMD64_INT_MWGWTYPES_H_
#ifdef __UINT_FAST64_TYPE__
#include <sys/common_int_mwgwtypes.h>
#else
#ifdef __x86_64__
/*
@ -70,4 +74,6 @@ typedef unsigned long int uintmax_t;
#endif /* __x86_64__ */
#endif
#endif /* !_AMD64_INT_MWGWTYPES_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_types.h,v 1.6 2008/10/26 00:08:15 mrg Exp $ */
/* $NetBSD: int_types.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -34,6 +34,10 @@
#ifndef _AMD64_INT_TYPES_H_
#define _AMD64_INT_TYPES_H_
#ifdef __UINTPTR_TYPE__
#include <sys/common_int_types.h>
#else
#ifdef __x86_64__
#include <sys/cdefs.h>
@ -66,4 +70,6 @@ typedef unsigned long __uintptr_t;
#endif /* __x86_64__ */
#endif
#endif /* !_AMD64_INT_TYPES_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_const.h,v 1.3 2010/05/29 17:33:57 tnozaki Exp $ */
/* $NetBSD: int_const.h,v 1.4 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,9 @@
#ifndef _ARM_INT_CONST_H_
#define _ARM_INT_CONST_H_
#ifdef __INTMAX_C_SUFFIX__
#include <sys/common_int_const.h>
#else
/*
* 7.18.4 Macros for integer constants
*/
@ -52,5 +55,6 @@
#define INTMAX_C(c) c ## LL
#define UINTMAX_C(c) c ## ULL
#endif
#endif /* !_ARM_INT_CONST_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_fmtio.h,v 1.7 2014/01/29 18:51:37 matt Exp $ */
/* $NetBSD: int_fmtio.h,v 1.8 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,12 +32,14 @@
#ifndef _ARM_INT_FMTIO_H_
#define _ARM_INT_FMTIO_H_
#ifdef __INTPTR_FMTd__
#include <sys/common_int_fmtio.h>
#else
/*
* 7.8.1 Macros for format specifiers
*/
/* fprintf macros for signed integers */
#define PRId8 "d" /* int8_t */
#define PRId16 "d" /* int16_t */
#define PRId32 "d" /* int32_t */
@ -208,5 +210,6 @@
#define SCNxFAST64 "llx" /* uint_fast64_t */
#define SCNxMAX "llx" /* uintmax_t */
#define SCNxPTR "lx" /* uintptr_t */
#endif
#endif /* !_ARM_INT_FMTIO_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_limits.h,v 1.10 2014/01/29 01:40:35 matt Exp $ */
/* $NetBSD: int_limits.h,v 1.11 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,9 @@
#ifndef _ARM_INT_LIMITS_H_
#define _ARM_INT_LIMITS_H_
#ifdef __SIG_ATOMIC_MAX__
#include <sys/common_int_limits.h>
#else
/*
* 7.18.2 Limits of specified-width integer types
*/
@ -138,5 +141,6 @@
#else
#define SIZE_MAX 0xffffffffUL /* size_t */
#endif
#endif
#endif /* !_ARM_INT_LIMITS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_mwgwtypes.h,v 1.6 2014/01/29 18:51:37 matt Exp $ */
/* $NetBSD: int_mwgwtypes.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -32,6 +32,9 @@
#ifndef _ARM_INT_MWGWTYPES_H_
#define _ARM_INT_MWGWTYPES_H_
#ifdef __UINT_FAST64_TYPE__
#include <sys/common_int_mwgwtypes.h>
#else
/*
* 7.18.1 Integer types
*/
@ -119,5 +122,6 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
typedef __INTMAX_TYPE__ intmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
#endif
#endif /* !_ARM_INT_MWGWTYPES_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_types.h,v 1.16 2014/07/14 20:20:31 joerg Exp $ */
/* $NetBSD: int_types.h,v 1.17 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -32,6 +32,9 @@
#ifndef _ARM_INT_TYPES_H_
#define _ARM_INT_TYPES_H_
#ifdef __UINTPTR_TYPE__
#include <sys/common_int_types.h>
#else
#include <sys/cdefs.h>
/*
@ -91,5 +94,6 @@ typedef __UINT64_TYPE__ __uint64_t;
typedef __INTPTR_TYPE__ __intptr_t;
typedef __UINTPTR_TYPE__ __uintptr_t;
#endif
#endif /* !_ARM_INT_TYPES_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_const.h,v 1.3 2010/05/29 17:33:57 tnozaki Exp $ */
/* $NetBSD: int_const.h,v 1.4 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _I386_INT_CONST_H_
#define _I386_INT_CONST_H_
#ifdef __INTMAX_C_SUFFIX__
#include <sys/common_int_const.h>
#else
/*
* 7.18.4 Macros for integer constants
*/
@ -53,4 +57,6 @@
#define INTMAX_C(c) c ## LL
#define UINTMAX_C(c) c ## ULL
#endif
#endif /* !_I386_INT_CONST_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_fmtio.h,v 1.7 2008/04/28 20:23:24 martin Exp $ */
/* $NetBSD: int_fmtio.h,v 1.8 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _I386_INT_FMTIO_H_
#define _I386_INT_FMTIO_H_
#ifdef __INTPTR_FMTd__
#include <sys/common_int_fmtio.h>
#else
/*
* 7.8.1 Macros for format specifiers
*/
@ -209,4 +213,6 @@
#define SCNxMAX "llx" /* uintmax_t */
#define SCNxPTR "x" /* uintptr_t */
#endif
#endif /* !_I386_INT_FMTIO_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_limits.h,v 1.8 2008/04/28 20:23:24 martin Exp $ */
/* $NetBSD: int_limits.h,v 1.9 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _I386_INT_LIMITS_H_
#define _I386_INT_LIMITS_H_
#ifdef __SIG_ATOMIC_MAX__
#include <sys/common_int_limits.h>
#else
/*
* 7.18.2 Limits of specified-width integer types
*/
@ -124,4 +128,6 @@
/* limit of size_t */
#define SIZE_MAX 0xffffffffU /* size_t */
#endif
#endif /* !_I386_INT_LIMITS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_mwgwtypes.h,v 1.6 2008/04/28 20:23:24 martin Exp $ */
/* $NetBSD: int_mwgwtypes.h,v 1.7 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -32,6 +32,10 @@
#ifndef _I386_INT_MWGWTYPES_H_
#define _I386_INT_MWGWTYPES_H_
#ifdef __UINT_FAST64_TYPE__
#include <sys/common_int_mwgwtypes.h>
#else
/*
* 7.18.1 Integer types
*/
@ -84,4 +88,6 @@ typedef long long int intmax_t;
typedef unsigned long long int uintmax_t;
#endif
#endif
#endif /* !_I386_INT_MWGWTYPES_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: int_types.h,v 1.10 2005/12/24 20:07:10 perry Exp $ */
/* $NetBSD: int_types.h,v 1.11 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -34,6 +34,10 @@
#ifndef _I386_INT_TYPES_H_
#define _I386_INT_TYPES_H_
#ifdef __UINTPTR_TYPE__
#include <sys/common_int_types.h>
#else
#include <sys/cdefs.h>
/*
@ -65,4 +69,6 @@ typedef unsigned long long int __uint64_t;
typedef int __intptr_t;
typedef unsigned int __uintptr_t;
#endif
#endif /* !_I386_INT_TYPES_H_ */

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.148 2014/03/20 06:50:54 skrll Exp $
# $NetBSD: Makefile,v 1.149 2014/07/25 21:43:13 joerg Exp $
.include <bsd.own.mk>
@ -7,7 +7,10 @@ INCSDIR= /usr/include/sys
INCS= acct.h agpio.h aio.h ansi.h aout_mids.h ataio.h atomic.h audioio.h \
bitops.h bootblock.h bswap.h buf.h \
callback.h callout.h cdbr.h cdefs.h cdefs_aout.h \
cdefs_elf.h cdio.h chio.h clockctl.h condvar.h conf.h core.h \
cdefs_elf.h cdio.h chio.h clockctl.h \
common_int_const.h common_int_fmtio.h common_int_limits.h \
common_int_mwgwtypes.h common_int_types.h \
condvar.h conf.h core.h \
cpufreq.h cpuio.h ctype_bits.h ctype_inline.h \
device.h device_if.h \
dir.h dirent.h \

View File

@ -0,0 +1,62 @@
/* $NetBSD: common_int_const.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Joerg Sonnenberger.
*
* 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.
*
* 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 _SYS_COMMON_INT_CONST_H_
#define _SYS_COMMON_INT_CONST_H_
#ifndef __INTMAX_C_SUFFIX__
#error Your compiler does not provide inter constant suffix macros.
#endif
#define __int_join_(c,suffix) c ## suffix
#define __int_join(c,suffix) __int_join_(c,suffix)
/*
* 7.18.4 Macros for integer constants
*/
/* 7.18.4.1 Macros for minimum-width integer constants */
#define INT8_C(c) __int_join(c, __INT8_C_SUFFIX__)
#define INT16_C(c) __int_join(c, __INT16_C_SUFFIX__)
#define INT32_C(c) __int_join(c, __INT32_C_SUFFIX__)
#define INT64_C(c) __int_join(c, __INT64_C_SUFFIX__)
#define UINT8_C(c) __int_join(c, __UINT8_C_SUFFIX__)
#define UINT16_C(c) __int_join(c, __UINT16_C_SUFFIX__)
#define UINT32_C(c) __int_join(c, __UINT32_C_SUFFIX__)
#define UINT64_C(c) __int_join(c, __UINT64_C_SUFFIX__)
/* 7.18.4.2 Macros for greatest-width integer constants */
#define INTMAX_C(c) __int_join(c, __INTMAX_C_SUFFIX__)
#define UINTMAX_C(c) __int_join(c, __UINTMAX_C_SUFFIX__)
#endif /* _SYS_COMMON_INT_CONST_H_ */

230
sys/sys/common_int_fmtio.h Normal file
View File

@ -0,0 +1,230 @@
/* $NetBSD: common_int_fmtio.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Joerg Sonnenberger.
*
* 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.
*
* 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 _SYS_COMMON_INT_FMTIO_H_
#define _SYS_COMMON_INT_FMTIO_H_
#ifndef __INTPTR_FMTd__
#error Your compiler does not provide format string macros.
#endif
/*
* 7.8.1 Macros for format specifiers
*/
/* fprintf macros for signed integers */
#define PRId8 __INT8_FMTd__
#define PRId16 __INT16_FMTd__
#define PRId32 __INT32_FMTd__
#define PRId64 __INT64_FMTd__
#define PRIdLEAST8 __INT_LEAST8_FMTd__
#define PRIdLEAST16 __INT_LEAST16_FMTd__
#define PRIdLEAST32 __INT_LEAST32_FMTd__
#define PRIdLEAST64 __INT_LEAST64_FMTd__
#define PRIdFAST8 __INT_FAST8_FMTd__
#define PRIdFAST16 __INT_FAST16_FMTd__
#define PRIdFAST32 __INT_FAST32_FMTd__
#define PRIdFAST64 __INT_FAST64_FMTd__
#define PRIdMAX __INTMAX_FMTd__
#define PRIdPTR __INTPTR_FMTd__
#define PRIi8 __INT8_FMTi__
#define PRIi16 __INT16_FMTi__
#define PRIi32 __INT32_FMTi__
#define PRIi64 __INT64_FMTi__
#define PRIiLEAST8 __INT_LEAST8_FMTi__
#define PRIiLEAST16 __INT_LEAST16_FMTi__
#define PRIiLEAST32 __INT_LEAST32_FMTi__
#define PRIiLEAST64 __INT_LEAST64_FMTi__
#define PRIiFAST8 __INT_FAST8_FMTi__
#define PRIiFAST16 __INT_FAST16_FMTi__
#define PRIiFAST32 __INT_FAST32_FMTi__
#define PRIiFAST64 __INT_FAST64_FMTi__
#define PRIiMAX __INTMAX_FMTi__
#define PRIiPTR __INTPTR_FMTi__
/* fprintf macros for unsigned integers */
#define PRIo8 __UINT8_FMTo__
#define PRIo16 __UINT16_FMTo__
#define PRIo32 __UINT32_FMTo__
#define PRIo64 __UINT64_FMTo__
#define PRIoLEAST8 __UINT_LEAST8_FMTo__
#define PRIoLEAST16 __UINT_LEAST16_FMTo__
#define PRIoLEAST32 __UINT_LEAST32_FMTo__
#define PRIoLEAST64 __UINT_LEAST64_FMTo__
#define PRIoFAST8 __UINT_FAST8_FMTo__
#define PRIoFAST16 __UINT_FAST16_FMTo__
#define PRIoFAST32 __UINT_FAST32_FMTo__
#define PRIoFAST64 __UINT_FAST64_FMTo__
#define PRIoMAX __UINTMAX_FMTo__
#define PRIoPTR __UINTPTR_FMTo__
#define PRIu8 __UINT8_FMTu__
#define PRIu16 __UINT16_FMTu__
#define PRIu32 __UINT32_FMTu__
#define PRIu64 __UINT64_FMTu__
#define PRIuLEAST8 __UINT_LEAST8_FMTu__
#define PRIuLEAST16 __UINT_LEAST16_FMTu__
#define PRIuLEAST32 __UINT_LEAST32_FMTu__
#define PRIuLEAST64 __UINT_LEAST64_FMTu__
#define PRIuFAST8 __UINT_FAST8_FMTu__
#define PRIuFAST16 __UINT_FAST16_FMTu__
#define PRIuFAST32 __UINT_FAST32_FMTu__
#define PRIuFAST64 __UINT_FAST64_FMTu__
#define PRIuMAX __UINTMAX_FMTu__
#define PRIuPTR __UINTPTR_FMTu__
#define PRIx8 __UINT8_FMTx__
#define PRIx16 __UINT16_FMTx__
#define PRIx32 __UINT32_FMTx__
#define PRIx64 __UINT64_FMTx__
#define PRIxLEAST8 __UINT_LEAST8_FMTx__
#define PRIxLEAST16 __UINT_LEAST16_FMTx__
#define PRIxLEAST32 __UINT_LEAST32_FMTx__
#define PRIxLEAST64 __UINT_LEAST64_FMTx__
#define PRIxFAST8 __UINT_FAST8_FMTx__
#define PRIxFAST16 __UINT_FAST16_FMTx__
#define PRIxFAST32 __UINT_FAST32_FMTx__
#define PRIxFAST64 __UINT_FAST64_FMTx__
#define PRIxMAX __UINTMAX_FMTx__
#define PRIxPTR __UINTPTR_FMTx__
#define PRIX8 __UINT8_FMTX__
#define PRIX16 __UINT16_FMTX__
#define PRIX32 __UINT32_FMTX__
#define PRIX64 __UINT64_FMTX__
#define PRIXLEAST8 __UINT_LEAST8_FMTX__
#define PRIXLEAST16 __UINT_LEAST16_FMTX__
#define PRIXLEAST32 __UINT_LEAST32_FMTX__
#define PRIXLEAST64 __UINT_LEAST64_FMTX__
#define PRIXFAST8 __UINT_FAST8_FMTX__
#define PRIXFAST16 __UINT_FAST16_FMTX__
#define PRIXFAST32 __UINT_FAST32_FMTX__
#define PRIXFAST64 __UINT_FAST64_FMTX__
#define PRIXMAX __UINTMAX_FMTX__
#define PRIXPTR __UINTPTR_FMTX__
/* fscanf macros for signed integers */
#define SCNd8 __INT8_FMTd__
#define SCNd16 __INT16_FMTd__
#define SCNd32 __INT32_FMTd__
#define SCNd64 __INT64_FMTd__
#define SCNdLEAST8 __INT_LEAST8_FMTd__
#define SCNdLEAST16 __INT_LEAST16_FMTd__
#define SCNdLEAST32 __INT_LEAST32_FMTd__
#define SCNdLEAST64 __INT_LEAST64_FMTd__
#define SCNdFAST8 __INT_FAST8_FMTd__
#define SCNdFAST16 __INT_FAST16_FMTd__
#define SCNdFAST32 __INT_FAST32_FMTd__
#define SCNdFAST64 __INT_FAST64_FMTd__
#define SCNdMAX __INTMAX_FMTd__
#define SCNdPTR __INTPTR_FMTd__
#define SCNi8 __INT8_FMTi__
#define SCNi16 __INT16_FMTi__
#define SCNi32 __INT32_FMTi__
#define SCNi64 __INT64_FMTi__
#define SCNiLEAST8 __INT_LEAST8_FMTi__
#define SCNiLEAST16 __INT_LEAST16_FMTi__
#define SCNiLEAST32 __INT_LEAST32_FMTi__
#define SCNiLEAST64 __INT_LEAST64_FMTi__
#define SCNiFAST8 __INT_FAST8_FMTi__
#define SCNiFAST16 __INT_FAST16_FMTi__
#define SCNiFAST32 __INT_FAST32_FMTi__
#define SCNiFAST64 __INT_FAST64_FMTi__
#define SCNiMAX __INTMAX_FMTi__
#define SCNiPTR __INTPTR_FMTi__
/* fscanf macros for unsigned integers */
#define SCNo8 __UINT8_FMTo__
#define SCNo16 __UINT16_FMTo__
#define SCNo32 __UINT32_FMTo__
#define SCNo64 __UINT64_FMTo__
#define SCNoLEAST8 __UINT_LEAST8_FMTo__
#define SCNoLEAST16 __UINT_LEAST16_FMTo__
#define SCNoLEAST32 __UINT_LEAST32_FMTo__
#define SCNoLEAST64 __UINT_LEAST64_FMTo__
#define SCNoFAST8 __UINT_FAST8_FMTo__
#define SCNoFAST16 __UINT_FAST16_FMTo__
#define SCNoFAST32 __UINT_FAST32_FMTo__
#define SCNoFAST64 __UINT_FAST64_FMTo__
#define SCNoMAX __UINTMAX_FMTo__
#define SCNoPTR __UINTPTR_FMTo__
#define SCNu8 __UINT8_FMTu__
#define SCNu16 __UINT16_FMTu__
#define SCNu32 __UINT32_FMTu__
#define SCNu64 __UINT64_FMTu__
#define SCNuLEAST8 __UINT_LEAST8_FMTu__
#define SCNuLEAST16 __UINT_LEAST16_FMTu__
#define SCNuLEAST32 __UINT_LEAST32_FMTu__
#define SCNuLEAST64 __UINT_LEAST64_FMTu__
#define SCNuFAST8 __UINT_FAST8_FMTu__
#define SCNuFAST16 __UINT_FAST16_FMTu__
#define SCNuFAST32 __UINT_FAST32_FMTu__
#define SCNuFAST64 __UINT_FAST64_FMTu__
#define SCNuMAX __UINTMAX_FMTu__
#define SCNuPTR __UINTPTR_FMTu__
#define SCNx8 __UINT8_FMTx__
#define SCNx16 __UINT16_FMTx__
#define SCNx32 __UINT32_FMTx__
#define SCNx64 __UINT64_FMTx__
#define SCNxLEAST8 __UINT_LEAST8_FMTx__
#define SCNxLEAST16 __UINT_LEAST16_FMTx__
#define SCNxLEAST32 __UINT_LEAST32_FMTx__
#define SCNxLEAST64 __UINT_LEAST64_FMTx__
#define SCNxFAST8 __UINT_FAST8_FMTx__
#define SCNxFAST16 __UINT_FAST16_FMTx__
#define SCNxFAST32 __UINT_FAST32_FMTx__
#define SCNxFAST64 __UINT_FAST64_FMTx__
#define SCNxMAX __UINTMAX_FMTx__
#define SCNxPTR __UINTPTR_FMTx__
#define SCNX8 __UINT8_FMTX__
#define SCNX16 __UINT16_FMTX__
#define SCNX32 __UINT32_FMTX__
#define SCNX64 __UINT64_FMTX__
#define SCNXLEAST8 __UINT_LEAST8_FMTX__
#define SCNXLEAST16 __UINT_LEAST16_FMTX__
#define SCNXLEAST32 __UINT_LEAST32_FMTX__
#define SCNXLEAST64 __UINT_LEAST64_FMTX__
#define SCNXFAST8 __UINT_FAST8_FMTX__
#define SCNXFAST16 __UINT_FAST16_FMTX__
#define SCNXFAST32 __UINT_FAST32_FMTX__
#define SCNXFAST64 __UINT_FAST64_FMTX__
#define SCNXMAX __UINTMAX_FMTX__
#define SCNXPTR __UINTPTR_FMTX__
#endif /* _SYS_COMMON_INT_FMTIO_H_ */

130
sys/sys/common_int_limits.h Normal file
View File

@ -0,0 +1,130 @@
/* $NetBSD: common_int_limits.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Joerg Sonnenberger.
*
* 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.
*
* 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 _SYS_COMMON_INT_LIMITS_H_
#define _SYS_COMMON_INT_LIMITS_H_
#ifndef __SIG_ATOMIC_MAX__
#error Your compiler does not provide limit macros.
#endif
/*
* 7.18.2 Limits of specified-width integer types
*/
/* 7.18.2.1 Limits of exact-width integer types */
/* minimum values of exact-width signed integer types */
#define INT8_MIN (-__INT8_MAX__-1)
#define INT16_MIN (-__INT16_MAX__-1)
#define INT32_MIN (-__INT32_MAX__-1)
#define INT64_MIN (-__INT64_MAX__-1)
/* maximum values of exact-width signed integer types */
#define INT8_MAX __INT8_MAX__
#define INT16_MAX __INT16_MAX__
#define INT32_MAX __INT32_MAX__
#define INT64_MAX __INT64_MAX__
/* maximum values of exact-width unsigned integer types */
#define UINT8_MAX __UINT8_MAX__
#define UINT16_MAX __UINT16_MAX__
#define UINT32_MAX __UINT32_MAX__
#define UINT64_MAX __UINT64_MAX__
/* 7.18.2.2 Limits of minimum-width integer types */
/* minimum values of minimum-width signed integer types */
#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__-1)
#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__-1)
#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__-1)
#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__-1)
/* maximum values of minimum-width signed integer types */
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
/* maximum values of minimum-width unsigned integer types */
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
/* 7.18.2.3 Limits of fastest minimum-width integer types */
/* minimum values of fastest minimum-width signed integer types */
#define INT_FAST8_MIN (-__INT_FAST8_MAX__-1)
#define INT_FAST16_MIN (-__INT_FAST16_MAX__-1)
#define INT_FAST32_MIN (-__INT_FAST32_MAX__-1)
#define INT_FAST64_MIN (-__INT_FAST64_MAX__-1)
/* maximum values of fastest minimum-width signed integer types */
#define INT_FAST8_MAX __INT_FAST8_MAX__
#define INT_FAST16_MAX __INT_FAST16_MAX__
#define INT_FAST32_MAX __INT_FAST32_MAX__
#define INT_FAST64_MAX __INT_FAST64_MAX__
/* maximum values of fastest minimum-width unsigned integer types */
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
/* 7.18.2.4 Limits of integer types capable of holding object pointers */
#define INTPTR_MIN (-__INTPTR_MAX__-1)
#define INTPTR_MAX __INTPTR_MAX__
#define UINTPTR_MAX __UINTPTR_MAX__
/* 7.18.2.5 Limits of greatest-width integer types */
#define INTMAX_MIN (-__INTMAX_MAX__-1)
#define INTMAX_MAX __INTMAX_MAX__
#define UINTMAX_MAX __UINTMAX_MAX__
/*
* 7.18.3 Limits of other integer types
*/
/* limits of ptrdiff_t */
#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1)
#define PTRDIFF_MAX __PTRDIFF_MAX__
/* limits of sig_atomic_t */
#define SIG_ATOMIC_MIN (-__SIG_ATOMIC_MAX__-1)
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
/* limit of size_t */
#define SIZE_MAX __SIZE_MAX__
#endif /* _SYS_COMMON_INT_LIMITS_H_ */

View File

@ -0,0 +1,69 @@
/* $NetBSD: common_int_mwgwtypes.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Joerg Sonnenberger.
*
* 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.
*
* 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 _SYS_COMMON_INT_MWGWTYPES_H_
#define _SYS_COMMON_INT_MWGWTYPES_H_
#ifndef __UINT_FAST64_TYPE__
#error Your compiler does not provide min/fast width type macros.
#endif
/*
* 7.18.1 Integer types
*/
/* 7.18.1.2 Minimum-width integer types */
typedef __INT_LEAST8_TYPE__ int_least8_t;
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
typedef __INT_LEAST16_TYPE__ int_least16_t;
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
typedef __INT_LEAST32_TYPE__ int_least32_t;
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
typedef __INT_LEAST64_TYPE__ int_least64_t;
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
/* 7.18.1.3 Fastest minimum-width integer types */
typedef __INT_FAST8_TYPE__ int_fast8_t;
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
typedef __INT_FAST16_TYPE__ int_fast16_t;
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
typedef __INT_FAST32_TYPE__ int_fast32_t;
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
typedef __INT_FAST64_TYPE__ int_fast64_t;
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
/* 7.18.1.5 Greatest-width integer types */
typedef __INTMAX_TYPE__ intmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
#endif /* _SYS_COMMON_INT_MWGWTYPES_H_ */

View File

@ -0,0 +1,61 @@
/* $NetBSD: common_int_types.h,v 1.1 2014/07/25 21:43:13 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Joerg Sonnenberger.
*
* 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.
*
* 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 _SYS_COMMON_INT_TYPES_H_
#define _SYS_COMMON_INT_TYPES_H_
#ifndef __UINTPTR_TYPE__
#error Your compiler does not provide exact width type macros.
#endif
/*
* 7.18.1 Integer types
*/
/* 7.18.1.1 Exact-width integer types */
typedef __INT8_TYPE__ __int8_t;
typedef __UINT8_TYPE__ __uint8_t;
typedef __INT16_TYPE__ __int16_t;
typedef __UINT16_TYPE__ __uint16_t;
typedef __INT32_TYPE__ __int32_t;
typedef __UINT32_TYPE__ __uint32_t;
typedef __INT64_TYPE__ __int64_t;
typedef __UINT64_TYPE__ __uint64_t;
#define __BIT_TYPES_DEFINED__
/* 7.18.1.4 Integer types capable of holding object pointers */
typedef __INTPTR_TYPE__ __intptr_t;
typedef __UINTPTR_TYPE__ __uintptr_t;
#endif /* _SYS_COMMON_INT_TYPES_H_ */