Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2014-12-03 23:25:09 +0300
committerJeff Johnston <jjohnstn@redhat.com>2014-12-03 23:25:09 +0300
commit8c049028d9d8057a390deb15852695e882996469 (patch)
tree0347489b2d4d34d9d83f4f0382d45b67a0bd1367
parentc9cfd71d8cba307981075ef640be73ba95119008 (diff)
2014-12-03 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/inttypes.h: Only enable the 8-bit scanning macros if _WANT_IO_C99_FORMATS is defined by configuration. Add comment on why.
-rw-r--r--newlib/ChangeLog6
-rw-r--r--newlib/libc/include/inttypes.h50
2 files changed, 45 insertions, 11 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index cf69c05ad..fa98a7cdb 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-03 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/include/inttypes.h: Only enable the 8-bit scanning macros
+ if _WANT_IO_C99_FORMATS is defined by configuration. Add comment
+ on why.
+
2014-11-28 Matthew Fortune <matthew.fortune@imgtec.com>
* libc/include/machine/setjmp.h [__mips__]: Remove __mips_fpr == 64
diff --git a/newlib/libc/include/inttypes.h b/newlib/libc/include/inttypes.h
index 5a8770bc6..39bf13511 100644
--- a/newlib/libc/include/inttypes.h
+++ b/newlib/libc/include/inttypes.h
@@ -13,6 +13,7 @@
#ifndef _INTTYPES_H
#define _INTTYPES_H
+#include <newlib.h>
#include <sys/_intsup.h>
#include <stdint.h>
#define __need_wchar_t
@@ -22,7 +23,20 @@
/* 8-bit types */
#define __PRI8(x) __STRINGIFY(x)
-#define __SCN8(x) __STRINGIFY(hh##x)
+
+/* NOTICE: scanning 8-bit types requires use of the hh specifier
+ * which is only supported on newlib platforms that
+ * are built with C99 I/O format support enabled. If the flag in
+ * newlib.h hasn't been set during configuration to indicate this, the 8-bit
+ * scanning format macros are disabled here as they result in undefined
+ * behaviour which can include memory overwrite. Overriding the flag after the
+ * library has been built is not recommended as it will expose the underlying
+ * undefined behaviour.
+ */
+
+#if defined(_WANT_IO_C99_FORMATS)
+ #define __SCN8(x) __STRINGIFY(hh##x)
+#endif /* _WANT_IO_C99_FORMATS */
#define PRId8 __PRI8(d)
@@ -32,12 +46,17 @@
#define PRIx8 __PRI8(x)
#define PRIX8 __PRI8(X)
+/* Macros below are only enabled for a newlib built with C99 I/O format support. */
+#if defined(_WANT_IO_C99_FORMATS)
+
#define SCNd8 __SCN8(d)
#define SCNi8 __SCN8(i)
#define SCNo8 __SCN8(o)
#define SCNu8 __SCN8(u)
#define SCNx8 __SCN8(x)
+#endif /* _WANT_IO_C99_FORMATS */
+
#define PRIdLEAST8 __PRI8(d)
#define PRIiLEAST8 __PRI8(i)
@@ -46,12 +65,16 @@
#define PRIxLEAST8 __PRI8(x)
#define PRIXLEAST8 __PRI8(X)
-#define SCNdLEAST8 __SCN8(d)
-#define SCNiLEAST8 __SCN8(i)
-#define SCNoLEAST8 __SCN8(o)
-#define SCNuLEAST8 __SCN8(u)
-#define SCNxLEAST8 __SCN8(x)
+/* Macros below are only enabled for a newlib built with C99 I/O format support. */
+#if defined(_WANT_IO_C99_FORMATS)
+
+ #define SCNdLEAST8 __SCN8(d)
+ #define SCNiLEAST8 __SCN8(i)
+ #define SCNoLEAST8 __SCN8(o)
+ #define SCNuLEAST8 __SCN8(u)
+ #define SCNxLEAST8 __SCN8(x)
+#endif /* _WANT_IO_C99_FORMATS */
#define PRIdFAST8 __PRI8(d)
#define PRIiFAST8 __PRI8(i)
@@ -60,11 +83,16 @@
#define PRIxFAST8 __PRI8(x)
#define PRIXFAST8 __PRI8(X)
-#define SCNdFAST8 __SCN8(d)
-#define SCNiFAST8 __SCN8(i)
-#define SCNoFAST8 __SCN8(o)
-#define SCNuFAST8 __SCN8(u)
-#define SCNxFAST8 __SCN8(x)
+/* Macros below are only enabled for a newlib built with C99 I/O format support. */
+#if defined(_WANT_IO_C99_FORMATS)
+
+ #define SCNdFAST8 __SCN8(d)
+ #define SCNiFAST8 __SCN8(i)
+ #define SCNoFAST8 __SCN8(o)
+ #define SCNuFAST8 __SCN8(u)
+ #define SCNxFAST8 __SCN8(x)
+
+#endif /* _WANT_IO_C99_FORMATS */
/* 16-bit types */
#define __PRI16(x) __STRINGIFY(x)