source: rtems/cpukit/include/rtems/inttypes.h

Last change on this file was 77d1ac6c, checked in by Joel Sherrill <joel@…>, on 03/24/22 at 21:35:19

cpukit/include/sys: Change license to BSD-2.

Updates #3053.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief Provide printf() PRIxxx Constante Beyond Standards
7 *
8 * This include file defines PRIxxx constants beyond those in
9 * the C and POSIX standards. These are used to write portable
10 * printf() format strings for POSIX and RTEMS types not in
11 * <inttypes.h>
12 */
13
14/*
15 *  COPYRIGHT (c) 2017 On-Line Applications Research Corporation.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 *    notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 *    notice, this list of conditions and the following disclaimer in the
24 *    documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _RTEMS_INTTYPES_H
40#define _RTEMS_INTTYPES_H
41
42#include <inttypes.h>
43#include <rtems/score/cpuopts.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/**
50 * @defgroup RTEMS inttypes.h Extensions
51 *
52 * @ingroup RTEMSAPIPrintSupport
53 *
54 * This module defines portable PRIxxx constants beyond those
55 * in the C and POSIX standard.
56 */
57
58/** Helper macro to print "modet" in octal */
59#if __RTEMS_SIZEOF_MODE_T__ == 8
60#define PRIomode_t PRIo64
61#elif __RTEMS_SIZEOF_MODE_T__ == 4
62#define PRIomode_t PRIo32
63#else
64#error "PRIomode_t: unsupported size of mode_t"
65#endif
66
67/** Helper macro to print "off_t" in octal */
68#if __RTEMS_SIZEOF_OFF_T__ == 8
69#define PRIooff_t PRIo64
70#elif __RTEMS_SIZEOF_OFF_T__ == 4
71#define PRIooff_t PRIo32
72#else
73#error "PRIooff_t: unsupported size of off_t"
74#endif
75
76/** Helper macro to print "off_t" in decimal */
77#if __RTEMS_SIZEOF_OFF_T__ == 8
78#define PRIdoff_t PRId64
79#elif __RTEMS_SIZEOF_OFF_T__ == 4
80#define PRIdoff_t PRId32
81#else
82#error "PRIdoff_t: unsupported size of off_t"
83#endif
84
85/** Helper macro to print "time_t" in decimal */
86#if __RTEMS_SIZEOF_TIME_T__ == 8
87#define PRIdtime_t PRId64
88#elif __RTEMS_SIZEOF_TIME_T__ == 4
89#define PRIdtime_t PRId32
90#else
91#error "PRIdtime_t: unsupported size of time_t"
92#endif
93
94/** Helper macro to print "blksize_t" in hexadecimal */
95#if __RTEMS_SIZEOF_BLKSIZE_T__ == 8
96#define PRIxblksize_t PRIx64
97#elif __RTEMS_SIZEOF_BLKSIZE_T__ == 4
98#define PRIxblksize_t PRIx32
99#else
100/* Warn and fall back to "long" */
101#warning "unsupported size of blksize_t"
102#define PRIxblksize_t "lx"
103#endif
104
105/** Helper macro to print "blkcnt_t" in hexadecimal */
106#if __RTEMS_SIZEOF_BLKCNT_T__ == 8
107#define PRIxblkcnt_t PRIx64
108#elif __RTEMS_SIZEOF_BLKCNT_T__ == 4
109#define PRIxblkcnt_t PRIx32
110#else
111/* Warn and fall back to "long" */
112#warning "unsupported size of blkcnt_t"
113#define PRIxblkcnt_t "lx"
114#endif
115
116/*
117 * Various inttypes.h-stype macros to assist printing
118 * certain system types on different targets.
119 */
120
121#define PRIxrtems_id PRIx32
122
123/* c.f. cpukit/score/include/rtems/score/priority.h */
124#define PRIdPriority_Control PRIu64
125#define PRIxPriority_Control PRIx64
126/* rtems_task_priority is a typedef to Priority_Control */
127#define PRIdrtems_task_priority PRIu32
128#define PRIxrtems_task_priority PRIx32
129
130/* c.f. cpukit/score/include/rtems/score/watchdog.h */
131#define PRIdWatchdog_Interval PRIu32
132/* rtems_interval is a typedef to Watchdog_Interval */
133#define PRIdrtems_interval    PRIdWatchdog_Interval
134
135/* c.f. cpukit/score/include/rtems/score/thread.h */
136#define PRIdThread_Entry_numeric_type PRIuPTR
137/* rtems_task_argument is a typedef to Thread_Entry_numeric_type */
138#define PRIdrtems_task_argument PRIdThread_Entry_numeric_type
139
140/* rtems_event_set is a typedef to uint32_t */
141#define PRIxrtems_event_set PRIx32
142
143/* newlib defines pthread_t as a typedef to __uint32_t which matches
144 * RTEMS expectations for an Object ID.
145 */
146#define PRIxpthread_t PRIx32
147
148/* rtems_signal_set is a typedef to uint32_t */
149#define PRIxrtems_signal_set PRIx32
150
151/* newlib's ino_t is a typedef to __uint64_t */
152#define PRIuino_t PRIu64
153
154/* newlib's ino_t is a typedef to __uint64_t */
155#define PRIxino_t PRIx64
156
157/* ioctl_command_t */
158#define PRIdioctl_command_t "ld"
159
160/* rtems_blkdev_bnum */
161#define PRIdrtems_blkdev_bnum PRId32
162
163/* rtems_blkdev_bnum */
164#define PRIdrtems_blkdev_bnum PRId32
165
166/* rtems_vector_number */
167#define PRIdrtems_vector_number PRId32
168
169/**@}*/
170
171#ifdef __cplusplus
172}
173#endif
174
175#endif
Note: See TracBrowser for help on using the repository browser.