summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel@rtems.org>2017-04-14 13:55:48 -0500
committerJoel Sherrill <joel@rtems.org>2017-04-18 11:24:44 -0500
commit54bdf0c7e5d689da76d41ccbbf2c9dc830fd8c4e (patch)
tree9df296747c4d42e9580c04ad5f7d4e1ca469b532 /cpukit
parenttestsuite: Fix rtems-test-check not excluding tests. (diff)
downloadrtems-54bdf0c7e5d689da76d41ccbbf2c9dc830fd8c4e.tar.bz2
rtems/inttypes.h: New file. Uses contents from cpukit
Provide extentions to <inttpes.h> PRIxxx constants for more POSIX types. Start with existing definitions found in RTEMS Project owned code in cpukit/. updates #2983.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/Makefile.am1
-rw-r--r--cpukit/include/rtems/inttypes.h78
-rw-r--r--cpukit/libdl/rtl-shell.c11
-rw-r--r--cpukit/libfs/src/nfsclient/src/dirutils.c19
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-dir.c9
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c9
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems.c8
-rw-r--r--cpukit/libmisc/shell/main_time.c10
-rw-r--r--cpukit/preinstall.am4
9 files changed, 90 insertions, 59 deletions
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
+ * <inttypes.h>
+ */
+
+/*
+ * 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 <inttypes.h>
+
+#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 <inttypes.h>
-
-/*
- * 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 <rtems/inttypes.h>
#include <stdio.h>
#include <string.h>
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 <limits.h> /* PATH_MAX */
#include <inttypes.h> /* 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 <rtems/inttypes.h> /* extended PRI* */
#ifdef HAVE_CEXP
#include <cexpHelp.h>
@@ -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 <inttypes.h>
+#include <rtems/inttypes.h>
#include <string.h>
-#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 <rtems/rfs/rtems-rfs-block.h>
#include <rtems/rfs/rtems-rfs-buffer.h>
#include <rtems/rfs/rtems-rfs-file-system.h>
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 <inttypes.h>
+#include <rtems/inttypes.h>
#include <string.h>
-#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 <rtems/rfs/rtems-rfs-file.h>
#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 <string.h>
#include <stdlib.h>
-#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 <rtems/inttypes.h>
#include <rtems/rfs/rtems-rfs-file.h>
#include <rtems/rfs/rtems-rfs-dir.h>
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 <rtems.h>
#include <rtems/shell.h>
+#include <rtems/inttypes.h>
#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