[PATCH 1/2] rtems/inttypes.h: New file. Uses contents from cpukit

Joel Sherrill joel at rtems.org
Sat Apr 15 21:17:32 UTC 2017


On Apr 15, 2017 12:40 PM, "Gedare Bloom" <gedare at rtems.org> wrote:

On Sat, Apr 15, 2017 at 9:17 AM, Joel Sherrill <joel at rtems.org> wrote:
> Provide extentions to <inttpes.h> PRIxxx constants for more POSIX types.
extensions
inttypes.h


> 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 755bc11..1987586 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 0000000..19022af
> --- /dev/null
> +++ b/cpukit/include/rtems/inttypes.h
> @@ -0,0 +1,78 @@
> +/**
> + * @file rtems/inttypes.h
> + *
> + * @brief Provide printf() PRIxxx Constante Beyond Standards
Constants

> + *
> + * 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>
Do we usually put a lengthy description here with the @file, or later
after the copyright block?



The file I copied as a template did it this way. We do not put three
comment blocks at the top of a file for sure.


> + */
> +
> +/*
> + *  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 a10c931..0bb3519 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 5dd7fcf..7155ef9 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 5a39cd4..58bf305 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 8902a0d..31df78a 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 d3393d6..5ce526a 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 5ea1bf7..61fc22a 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 598d034..2ae31ef 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
> --
> 1.8.3.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20170415/fc3e8770/attachment-0002.html>


More information about the devel mailing list