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.
This commit is contained in:
Jeff Johnston 2014-12-03 20:25:09 +00:00
parent c9cfd71d8c
commit 8c049028d9
2 changed files with 45 additions and 11 deletions

View File

@ -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

View File

@ -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)
/* 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)
/* 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,12 +83,17 @@
#define PRIxFAST8 __PRI8(x)
#define PRIXFAST8 __PRI8(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)
#define __SCN16(x) __STRINGIFY(h##x)