[01/23,AARCH64] define word size for lp64 and ilp32

Message ID 1467131978-669-2-git-send-email-ynorov@caviumnetworks.com
State New
Headers show

Commit Message

Yury Norov June 28, 2016, 4:39 p.m.
From: Andrew Pinski <apinski@cavium.com>


Additionally introduce and/or define MIN/MAX macro for size
and ptrdiff types.

Signed-off-by: Andrew Pinski <apinski@cavium.com>

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

---
 sysdeps/aarch64/bits/wordsize.h | 25 +++++++++++++++++++++++++
 sysdeps/generic/stdint.h        |  9 +++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 sysdeps/aarch64/bits/wordsize.h

-- 
2.7.4

Patch

diff --git a/sysdeps/aarch64/bits/wordsize.h b/sysdeps/aarch64/bits/wordsize.h
new file mode 100644
index 0000000..569307a
--- /dev/null
+++ b/sysdeps/aarch64/bits/wordsize.h
@@ -0,0 +1,25 @@ 
+/* Copyright (C) 2014 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef __LP64__
+# define __WORDSIZE			64
+#else
+# define __WORDSIZE			32
+# define __WORDSIZE32_SIZE_ULONG	1
+# define __WORDSIZE32_PTRDIFF_LONG	1
+#endif
+
diff --git a/sysdeps/generic/stdint.h b/sysdeps/generic/stdint.h
index 4427627..cedbe43 100644
--- a/sysdeps/generic/stdint.h
+++ b/sysdeps/generic/stdint.h
@@ -248,8 +248,13 @@  typedef unsigned long long int	uintmax_t;
 #  define PTRDIFF_MIN		(-9223372036854775807L-1)
 #  define PTRDIFF_MAX		(9223372036854775807L)
 # else
-#  define PTRDIFF_MIN		(-2147483647-1)
-#  define PTRDIFF_MAX		(2147483647)
+#  if __WORDSIZE32_PTRDIFF_LONG
+#    define PTRDIFF_MIN		(-2147483647L-1)
+#    define PTRDIFF_MAX		(2147483647L)
+#  else
+#    define PTRDIFF_MIN		(-2147483647-1)
+#    define PTRDIFF_MAX		(2147483647)
+#  endif
 # endif
 
 /* Limits of `sig_atomic_t'.  */