diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-10-16 21:42:09 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-10-16 21:42:09 +0200 |
commit | eaa07ed646b56e928f730dde26a8af1b898e7379 (patch) | |
tree | 2fc67642cda17cbc166e1469b160b5d753d3f446 | |
parent | heuristically determine int_fastN_t (diff) | |
download | slibc-eaa07ed646b56e928f730dde26a8af1b898e7379.tar.gz slibc-eaa07ed646b56e928f730dde26a8af1b898e7379.tar.bz2 slibc-eaa07ed646b56e928f730dde26a8af1b898e7379.tar.xz |
some integer types are pointer-like types that are limited to long
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | include/bits/types.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/include/bits/types.h b/include/bits/types.h index da5521b..dfaef5d 100644 --- a/include/bits/types.h +++ b/include/bits/types.h @@ -41,6 +41,20 @@ (((type)1) << sizeof(type)) #endif +/** + * An integer type for pointers, but not wider than `long int`. + */ +#ifndef __LIMITED_PTR_INT +# if __PTR_BIT == __CHAR_BIT +# define __LIMITED_PTR_INT char +# elif __PTR_BIT == __SHORT_BIT +# define __LIMITED_PTR_INT short int +# elif __PTR_BIT == __INT_BIT +# define __LIMITED_PTR_INT int +# else +# define __LIMITED_PTR_INT long int +#endif + /** * Signed integer type of the result of subtracting two pointers. @@ -48,7 +62,7 @@ */ #if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t) # define __DEFINED_ptrdiff_t -typedef signed long int ptrdiff_t; +typedef signed __LIMITED_PTR_INT ptrdiff_t; #endif @@ -57,7 +71,7 @@ typedef signed long int ptrdiff_t; */ #if defined(__NEED_uptrdiff_t) && !defined(__DEFINED_uptrdiff_t) # define __DEFINED_uptrdiff_t -typedef unsigned long int uptrdiff_t; +typedef unsigned __LIMITED_PTR_INT uptrdiff_t; #endif @@ -107,11 +121,11 @@ typedef wchar_t wint_t /** * Unsigned integer type of the result of the * `sizeof` operator. May not be greater than the - * with of type long. + * width of type `long int`. */ #if defined(__NEED_size_t) && !defined(__DEFINED_size_t) # define __DEFINED_size_t -typedef unsigned long int size_t; +typedef unsigned __LIMITED_PTR_INT size_t; #endif @@ -120,7 +134,7 @@ typedef unsigned long int size_t; */ #if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t) # define __DEFINED_ssize_t -typedef signed long int ssize_t; +typedef signed __LIMITED_PTR_INT ssize_t; #endif @@ -482,7 +496,7 @@ typedef unsigned __INT64 fsfilcnt_t; */ #if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t) # define __DEFINED_blksize_t -typedef signed long int blksize_t; +typedef signed __LIMITED_PTR_INT blksize_t; #endif @@ -494,3 +508,6 @@ typedef signed long int blksize_t; typedef signed __INT64 blkcnt_t; #endif + +/* pid_t and suseconds_t may not exceed long int */ + |