Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:13

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief Provide printf() PRIxxx Constante Beyond Standards
0007  *
0008  * This include file defines PRIxxx constants beyond those in
0009  * the C and POSIX standards. These are used to write portable
0010  * printf() format strings for POSIX and RTEMS types not in
0011  * <inttypes.h>
0012  */
0013 
0014 /*
0015  *  COPYRIGHT (c) 2017 On-Line Applications Research Corporation.
0016  *
0017  * Redistribution and use in source and binary forms, with or without
0018  * modification, are permitted provided that the following conditions
0019  * are met:
0020  * 1. Redistributions of source code must retain the above copyright
0021  *    notice, this list of conditions and the following disclaimer.
0022  * 2. Redistributions in binary form must reproduce the above copyright
0023  *    notice, this list of conditions and the following disclaimer in the
0024  *    documentation and/or other materials provided with the distribution.
0025  *
0026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0036  * POSSIBILITY OF SUCH DAMAGE.
0037  */
0038 
0039 #ifndef _RTEMS_INTTYPES_H
0040 #define _RTEMS_INTTYPES_H
0041 
0042 #include <inttypes.h>
0043 #include <rtems/score/cpuopts.h>
0044 
0045 #ifdef __cplusplus
0046 extern "C" {
0047 #endif
0048 
0049 /**
0050  * @defgroup RTEMS inttypes.h Extensions
0051  *
0052  * @ingroup RTEMSAPIPrintSupport
0053  *
0054  * This module defines portable PRIxxx constants beyond those
0055  * in the C and POSIX standard.
0056  */
0057 
0058 /** Helper macro to print "modet" in octal */
0059 #if __RTEMS_SIZEOF_MODE_T__ == 8
0060 #define PRIomode_t PRIo64
0061 #elif __RTEMS_SIZEOF_MODE_T__ == 4
0062 #define PRIomode_t PRIo32
0063 #else
0064 #error "PRIomode_t: unsupported size of mode_t"
0065 #endif
0066 
0067 /** Helper macro to print "off_t" in octal */
0068 #if __RTEMS_SIZEOF_OFF_T__ == 8
0069 #define PRIooff_t PRIo64
0070 #elif __RTEMS_SIZEOF_OFF_T__ == 4
0071 #define PRIooff_t PRIo32
0072 #else
0073 #error "PRIooff_t: unsupported size of off_t"
0074 #endif
0075 
0076 /** Helper macro to print "off_t" in decimal */
0077 #if __RTEMS_SIZEOF_OFF_T__ == 8
0078 #define PRIdoff_t PRId64
0079 #elif __RTEMS_SIZEOF_OFF_T__ == 4
0080 #define PRIdoff_t PRId32
0081 #else
0082 #error "PRIdoff_t: unsupported size of off_t"
0083 #endif
0084 
0085 /** Helper macro to print "time_t" in decimal */
0086 #if __RTEMS_SIZEOF_TIME_T__ == 8
0087 #define PRIdtime_t PRId64
0088 #elif __RTEMS_SIZEOF_TIME_T__ == 4
0089 #define PRIdtime_t PRId32
0090 #else
0091 #error "PRIdtime_t: unsupported size of time_t"
0092 #endif
0093 
0094 /** Helper macro to print "blksize_t" in hexadecimal */
0095 #if __RTEMS_SIZEOF_BLKSIZE_T__ == 8
0096 #define PRIxblksize_t PRIx64
0097 #elif __RTEMS_SIZEOF_BLKSIZE_T__ == 4
0098 #define PRIxblksize_t PRIx32
0099 #else
0100 /* Warn and fall back to "long" */
0101 #warning "unsupported size of blksize_t"
0102 #define PRIxblksize_t "lx"
0103 #endif
0104 
0105 /** Helper macro to print "blkcnt_t" in hexadecimal */
0106 #if __RTEMS_SIZEOF_BLKCNT_T__ == 8
0107 #define PRIxblkcnt_t PRIx64
0108 #elif __RTEMS_SIZEOF_BLKCNT_T__ == 4
0109 #define PRIxblkcnt_t PRIx32
0110 #else
0111 /* Warn and fall back to "long" */
0112 #warning "unsupported size of blkcnt_t"
0113 #define PRIxblkcnt_t "lx"
0114 #endif
0115 
0116 /*
0117  * Various inttypes.h-stype macros to assist printing
0118  * certain system types on different targets.
0119  */
0120 
0121 #define PRIxrtems_id PRIx32
0122 
0123 /* c.f. cpukit/score/include/rtems/score/priority.h */
0124 #define PRIdPriority_Control PRIu64
0125 #define PRIxPriority_Control PRIx64
0126 /* rtems_task_priority is a typedef to Priority_Control */
0127 #define PRIdrtems_task_priority PRIu32
0128 #define PRIxrtems_task_priority PRIx32
0129 
0130 /* c.f. cpukit/score/include/rtems/score/watchdog.h */
0131 #define PRIdWatchdog_Interval PRIu32
0132 /* rtems_interval is a typedef to Watchdog_Interval */
0133 #define PRIdrtems_interval    PRIdWatchdog_Interval
0134 
0135 /* c.f. cpukit/score/include/rtems/score/thread.h */
0136 #define PRIdThread_Entry_numeric_type PRIuPTR
0137 /* rtems_task_argument is a typedef to Thread_Entry_numeric_type */
0138 #define PRIdrtems_task_argument PRIdThread_Entry_numeric_type
0139 
0140 /* rtems_event_set is a typedef to uint32_t */
0141 #define PRIxrtems_event_set PRIx32
0142 
0143 /* newlib defines pthread_t as a typedef to __uint32_t which matches
0144  * RTEMS expectations for an Object ID.
0145  */
0146 #define PRIxpthread_t PRIx32
0147 
0148 /* rtems_signal_set is a typedef to uint32_t */
0149 #define PRIxrtems_signal_set PRIx32
0150 
0151 /* newlib's ino_t is a typedef to __uint64_t */
0152 #define PRIuino_t PRIu64
0153 
0154 /* newlib's ino_t is a typedef to __uint64_t */
0155 #define PRIxino_t PRIx64
0156 
0157 /* ioctl_command_t */
0158 #define PRIdioctl_command_t "ld"
0159 
0160 /* rtems_blkdev_bnum */
0161 #define PRIdrtems_blkdev_bnum PRId32
0162 
0163 /* rtems_blkdev_bnum */
0164 #define PRIdrtems_blkdev_bnum PRId32
0165 
0166 /* rtems_vector_number */
0167 #define PRIdrtems_vector_number PRId32
0168 
0169 /**@}*/
0170 
0171 #ifdef __cplusplus
0172 }
0173 #endif
0174 
0175 #endif