From 54bdf0c7e5d689da76d41ccbbf2c9dc830fd8c4e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 14 Apr 2017 13:55:48 -0500 Subject: rtems/inttypes.h: New file. Uses contents from cpukit Provide extentions to PRIxxx constants for more POSIX types. Start with existing definitions found in RTEMS Project owned code in cpukit/. updates #2983. --- cpukit/Makefile.am | 1 + cpukit/include/rtems/inttypes.h | 78 +++++++++++++++++++++++++++++ cpukit/libdl/rtl-shell.c | 11 +--- cpukit/libfs/src/nfsclient/src/dirutils.c | 19 +------ cpukit/libfs/src/rfs/rtems-rfs-dir.c | 9 +--- cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c | 9 +--- cpukit/libfs/src/rfs/rtems-rfs-rtems.c | 8 +-- cpukit/libmisc/shell/main_time.c | 10 +--- cpukit/preinstall.am | 4 ++ 9 files changed, 90 insertions(+), 59 deletions(-) create mode 100644 cpukit/include/rtems/inttypes.h diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index 755bc1173a..1987586b7c 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -111,6 +111,7 @@ include_rtems_debugger_HEADERS += libdebugger/rtems-debugger-remote.h endif include_rtems_HEADERS += include/rtems/bspIo.h +include_rtems_HEADERS += include/rtems/inttypes.h include_rtems_HEADERS += include/rtems/print.h include_rtems_HEADERS += include/rtems/printer.h include_rtems_HEADERS += include/rtems/userenv.h diff --git a/cpukit/include/rtems/inttypes.h b/cpukit/include/rtems/inttypes.h new file mode 100644 index 0000000000..19022afc54 --- /dev/null +++ b/cpukit/include/rtems/inttypes.h @@ -0,0 +1,78 @@ +/** + * @file rtems/inttypes.h + * + * @brief Provide printf() PRIxxx Constante Beyond Standards + * + * This include file defines PRIxxx constants beyond those in + * the C and POSIX standards. These are used to write portable + * printf() format strings for POSIX and RTEMS types not in + * + */ + +/* + * COPYRIGHT (c) 2017 On-Line Applications Research Corporation. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_INTTYPES_H +#define _RTEMS_INTTYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup RTEMS inttypes.h Extensions + * + * This module defines portable PRIxxx constants beyond those + * in the C and POSIX standard. + */ + +/** Helper macro to print "modet" in octal */ +#if SIZEOF_MODE_T == 8 +#define PRIomode_t PRIo64 +#elif SIZEOF_MODE_T == 4 +#define PRIomode_t PRIo32 +#else +#error "PRIomode_t: unsupport size of mode_t" +#endif + +/** Helper macro to print "off_t" in octal */ +#if SIZEOF_OFF_T == 8 +#define PRIooff_t PRIo64 +#elif SIZEOF_OFF_T == 4 +#define PRIooff_t PRIo32 +#else +#error "PRIooff_t: unsupported size of off_t" +#endif + +/** Helper macro to print "off_t" in decimal */ +#if SIZEOF_OFF_T == 8 +#define PRIdoff_t PRId64 +#elif SIZEOF_OFF_T == 4 +#define PRIdoff_t PRId32 +#else +#error "PRIdoff_t: unsupported size of off_t" +#endif + +/** Helper macro to print "time_t" in decimal */ +#if SIZEOF_TIME_T == 8 +#define PRIdtime_t PRId64 +#elif SIZEOF_TIME_T == 4 +#define PRIdtime_t PRId32 +#else +#error "PRIdtime_t: unsupported size of time_t" +#endif + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/libdl/rtl-shell.c b/cpukit/libdl/rtl-shell.c index a10c931c6e..0bb3519555 100644 --- a/cpukit/libdl/rtl-shell.c +++ b/cpukit/libdl/rtl-shell.c @@ -20,16 +20,7 @@ #endif #include - -/* - * Flag the targets where off_t is 32 bits. This is not a compiler type - * so we can't rely on prerdefines. - */ -#if defined(__moxie__) -#define PRIdoff_t PRIo32 -#else -#define PRIdoff_t PRIo64 -#endif +#include #include #include diff --git a/cpukit/libfs/src/nfsclient/src/dirutils.c b/cpukit/libfs/src/nfsclient/src/dirutils.c index 5dd7fcf3b8..7155ef998a 100644 --- a/cpukit/libfs/src/nfsclient/src/dirutils.c +++ b/cpukit/libfs/src/nfsclient/src/dirutils.c @@ -70,22 +70,7 @@ #include /* PATH_MAX */ #include /* PRI* */ - -#if SIZEOF_MODE_T == 8 -#define PRIomode_t PRIo64 -#elif SIZEOF_MODE_T == 4 -#define PRIomode_t PRIo32 -#else -#error "unsupport size of mode_t" -#endif - -#if SIZEOF_OFF_T == 8 -#define PRIdoff_t PRIo64 -#elif SIZEOF_OFF_T == 4 -#define PRIdoff_t PRIo32 -#else -#error "unsupported size of off_t" -#endif +#include /* extended PRI* */ #ifdef HAVE_CEXP #include @@ -142,7 +127,7 @@ char *t; t = "@"; break; } - printf("%10li, %10" PRIdoff_t "b, %5i.%-5i 0%04" PRIomode_t " %s%s\n", + printf("%10li, %10" PRIooff_t "b, %5i.%-5i 0%04" PRIomode_t " %s%s\n", buf->st_ino, buf->st_size, buf->st_uid, diff --git a/cpukit/libfs/src/rfs/rtems-rfs-dir.c b/cpukit/libfs/src/rfs/rtems-rfs-dir.c index 5a39cd47cd..58bf305f4e 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-dir.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-dir.c @@ -28,16 +28,9 @@ #endif #include +#include #include -#if SIZEOF_OFF_T == 8 -#define PRIooff_t PRIo64 -#elif SIZEOF_OFF_T == 4 -#define PRIooff_t PRIo32 -#else -#error "unsupported size of off_t" -#endif - #include #include #include diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c index 8902a0d269..31df78acf1 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c @@ -21,16 +21,9 @@ #endif #include +#include #include -#if SIZEOF_OFF_T == 8 -#define PRIdoff_t PRId64 -#elif SIZEOF_OFF_T == 4 -#define PRIdoff_t PRId32 -#else -#error "unsupported size of off_t" -#endif - #include #include "rtems-rfs-rtems.h" diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c index d3393d672a..5ce526a8ed 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c @@ -25,13 +25,7 @@ #include #include -#if SIZEOF_MODE_T == 8 -#define PRIomode_t PRIo64 -#elif SIZEOF_MODE_T == 4 -#define PRIomode_t PRIo32 -#else -#error "unsupport size of mode_t" -#endif +#include #include #include diff --git a/cpukit/libmisc/shell/main_time.c b/cpukit/libmisc/shell/main_time.c index 5ea1bf7498..61fc22aa33 100644 --- a/cpukit/libmisc/shell/main_time.c +++ b/cpukit/libmisc/shell/main_time.c @@ -22,17 +22,9 @@ #include #include +#include #include "internal.h" -/* Helper macro to print "time_t" */ -#if SIZEOF_TIME_T == 8 -#define PRIdtime_t PRId64 -#elif SIZEOF_TIME_T == 4 -#define PRIdtime_t PRId32 -#else -#error "PRIdtime_t: unsupported size of time_t" -#endif - static int rtems_shell_main_time( int argc, char *argv[] diff --git a/cpukit/preinstall.am b/cpukit/preinstall.am index 598d034f9f..2ae31ef987 100644 --- a/cpukit/preinstall.am +++ b/cpukit/preinstall.am @@ -263,6 +263,10 @@ $(PROJECT_INCLUDE)/rtems/bspIo.h: include/rtems/bspIo.h $(PROJECT_INCLUDE)/rtems $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bspIo.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bspIo.h +$(PROJECT_INCLUDE)/rtems/inttypes.h: include/rtems/inttypes.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/inttypes.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/inttypes.h + $(PROJECT_INCLUDE)/rtems/print.h: include/rtems/print.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/print.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/print.h -- cgit v1.2.3