2010-10-10 02:20:09 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* include/inttypes.h
|
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2010-10-10 02:20:09 +02:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2010-10-10 02:20:09 +02:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2010-10-10 02:20:09 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_INTTYPES_H
|
|
|
|
#define __INCLUDE_INTTYPES_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2011-07-12 18:36:45 +02:00
|
|
|
#include <stddef.h> /* for wchar_t */
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2010-10-10 02:20:09 +02:00
|
|
|
/* Notes from www.opengroup.org:
|
|
|
|
*
|
|
|
|
* "The <inttypes.h> header shall include the <stdint.h> header."
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-10-27 20:52:57 +02:00
|
|
|
#include <arch/inttypes.h>
|
|
|
|
|
2010-10-10 02:20:09 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2010-10-10 02:20:09 +02:00
|
|
|
/* "The following macros shall be defined. Each expands to a character string
|
2020-02-23 09:50:23 +01:00
|
|
|
* literal containing a conversion specifier, possibly modified by a length
|
2010-10-10 02:20:09 +02:00
|
|
|
* modifier, suitable for use within the format argument of a formatted
|
|
|
|
* input/output function when converting the corresponding integer type.
|
|
|
|
* These macros have the general form of PRI (character string literals for
|
2020-11-06 00:12:46 +01:00
|
|
|
* the fprintf() and fwprintf() family of functions) or SCN (character
|
|
|
|
* string literals for the fscanf() and fwscanf() family of functions),
|
|
|
|
* followed by the conversion specifier, followed by a name corresponding
|
|
|
|
* to a similar type name in <stdint.h>. In these names, N represents the
|
|
|
|
* width of the type as described in <stdint.h>. For example, PRIdFAST32
|
|
|
|
* can be used in a format string to print the value of an integer of type
|
|
|
|
* int_fast32_t.
|
2010-10-10 02:20:09 +02:00
|
|
|
*
|
|
|
|
* "The fprintf() macros for signed integers are:
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* PRIdN
|
|
|
|
* PRIdLEASTN
|
|
|
|
* PRIdFASTN
|
|
|
|
* PRIdMAX
|
|
|
|
* PRIdPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* PRIiN
|
|
|
|
* PRIiLEASTN
|
|
|
|
* PRIiFASTN
|
|
|
|
* PRIiMAX
|
|
|
|
* PRIiPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* "The fprintf() macros for unsigned integers are:
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* PRIoN
|
|
|
|
* PRIoLEASTN
|
|
|
|
* PRIoFASTN
|
|
|
|
* PRIoMAX
|
|
|
|
* PRIoPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* PRIuN
|
|
|
|
* PRIuLEASTN
|
|
|
|
* PRIuFASTN
|
|
|
|
* PRIuMAX
|
|
|
|
* PRIuPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* PRIxN
|
|
|
|
* PRIxLEASTN
|
|
|
|
* PRIxFASTN
|
|
|
|
* PRIxMAX
|
|
|
|
* PRIxPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* PRIXN
|
|
|
|
* PRIXLEASTN
|
|
|
|
* PRIXFASTN
|
|
|
|
* PRIXMAX
|
|
|
|
* PRIXPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* "The fscanf() macros for signed integers are:
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* SCNdN
|
|
|
|
* SCNdLEASTN
|
|
|
|
* SCNdFASTN
|
|
|
|
* SCNdMAX
|
|
|
|
* SCNdPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* SCNiN
|
|
|
|
* SCNiLEASTN
|
|
|
|
* SCNiFASTN
|
|
|
|
* SCNiMAX
|
|
|
|
* SCNiPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* "The fscanf() macros for unsigned integers are:
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* SCNoN
|
|
|
|
* SCNoLEASTN
|
|
|
|
* SCNoFASTN
|
|
|
|
* SCNoMAX
|
|
|
|
* SCNoPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* SCNuN
|
|
|
|
* SCNuLEASTN
|
|
|
|
* SCNuFASTN
|
|
|
|
* SCNuMAX
|
|
|
|
* SCNuPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* SCNxN
|
|
|
|
* SCNxLEASTN
|
|
|
|
* SCNxFASTN
|
|
|
|
* SCNxMAX
|
|
|
|
* SCNxPTR
|
2014-04-13 22:32:20 +02:00
|
|
|
*
|
2010-10-10 02:20:09 +02:00
|
|
|
* "For each type that the implementation provides in <stdint.h>, the
|
|
|
|
* corresponding fprintf() and fwprintf() macros shall be defined and the
|
|
|
|
* corresponding fscanf() and fwscanf() macros shall be defined unless the
|
|
|
|
* implementation does not have a suitable modifier for the type.
|
|
|
|
*/
|
|
|
|
|
2020-11-06 00:10:55 +01:00
|
|
|
/* On NuttX, least and fast types are aliases of the exact type.
|
|
|
|
* (See stdint.h)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PRIdLEAST8 PRId8
|
|
|
|
#define PRIdLEAST16 PRId16
|
|
|
|
#define PRIdLEAST32 PRId32
|
|
|
|
#if defined(PRId64)
|
|
|
|
#define PRIdLEAST64 PRId64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIdFAST8 PRId8
|
|
|
|
#define PRIdFAST16 PRId16
|
|
|
|
#define PRIdFAST32 PRId32
|
|
|
|
#if defined(PRId64)
|
|
|
|
#define PRIdFAST64 PRId64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIiLEAST8 PRIi8
|
|
|
|
#define PRIiLEAST16 PRIi16
|
|
|
|
#define PRIiLEAST32 PRIi32
|
|
|
|
#if defined(PRIi64)
|
|
|
|
#define PRIiLEAST64 PRIi64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIiFAST8 PRIi8
|
|
|
|
#define PRIiFAST16 PRIi16
|
|
|
|
#define PRIiFAST32 PRIi32
|
|
|
|
#if defined(PRIi64)
|
|
|
|
#define PRIiFAST64 PRIi64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIoLEAST8 PRIo8
|
|
|
|
#define PRIoLEAST16 PRIo16
|
|
|
|
#define PRIoLEAST32 PRIo32
|
|
|
|
#if defined(PRIo64)
|
|
|
|
#define PRIoLEAST64 PRIo64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIoFAST8 PRIo8
|
|
|
|
#define PRIoFAST16 PRIo16
|
|
|
|
#define PRIoFAST32 PRIo32
|
|
|
|
#if defined(PRIo64)
|
|
|
|
#define PRIoFAST64 PRIo64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIuLEAST8 PRIu8
|
|
|
|
#define PRIuLEAST16 PRIu16
|
|
|
|
#define PRIuLEAST32 PRIu32
|
|
|
|
#if defined(PRIu64)
|
|
|
|
#define PRIuLEAST64 PRIu64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIuFAST8 PRIu8
|
|
|
|
#define PRIuFAST16 PRIu16
|
|
|
|
#define PRIuFAST32 PRIu32
|
|
|
|
#if defined(PRIu64)
|
|
|
|
#define PRIuFAST64 PRIu64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIxLEAST8 PRIx8
|
|
|
|
#define PRIxLEAST16 PRIx16
|
|
|
|
#define PRIxLEAST32 PRIx32
|
|
|
|
#if defined(PRIx64)
|
|
|
|
#define PRIxLEAST64 PRIx64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIxFAST8 PRIx8
|
|
|
|
#define PRIxFAST16 PRIx16
|
|
|
|
#define PRIxFAST32 PRIx32
|
|
|
|
#if defined(PRIx64)
|
|
|
|
#define PRIxFAST64 PRIx64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIXLEAST8 PRIX8
|
|
|
|
#define PRIXLEAST16 PRIX16
|
|
|
|
#define PRIXLEAST32 PRIX32
|
|
|
|
#if defined(PRIX64)
|
|
|
|
#define PRIXLEAST64 PRIX64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRIXFAST8 PRIX8
|
|
|
|
#define PRIXFAST16 PRIX16
|
|
|
|
#define PRIXFAST32 PRIX32
|
|
|
|
#if defined(PRIX64)
|
|
|
|
#define PRIXFAST64 PRIX64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNdLEAST8 SCNd8
|
|
|
|
#define SCNdLEAST16 SCNd16
|
|
|
|
#define SCNdLEAST32 SCNd32
|
|
|
|
#if defined(SCNd64)
|
|
|
|
#define SCNdLEAST64 SCNd64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNdFAST8 SCNd8
|
|
|
|
#define SCNdFAST16 SCNd16
|
|
|
|
#define SCNdFAST32 SCNd32
|
|
|
|
#if defined(SCNd64)
|
|
|
|
#define SCNdFAST64 SCNd64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNiLEAST8 SCNi8
|
|
|
|
#define SCNiLEAST16 SCNi16
|
|
|
|
#define SCNiLEAST32 SCNi32
|
|
|
|
#if defined(SCNi64)
|
|
|
|
#define SCNiLEAST64 SCNi64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNiFAST8 SCNi8
|
|
|
|
#define SCNiFAST16 SCNi16
|
|
|
|
#define SCNiFAST32 SCNi32
|
|
|
|
#if defined(SCNi64)
|
|
|
|
#define SCNiFAST64 SCNi64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNoLEAST8 SCNo8
|
|
|
|
#define SCNoLEAST16 SCNo16
|
|
|
|
#define SCNoLEAST32 SCNo32
|
|
|
|
#if defined(SCNo64)
|
|
|
|
#define SCNoLEAST64 SCNo64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNoFAST8 SCNo8
|
|
|
|
#define SCNoFAST16 SCNo16
|
|
|
|
#define SCNoFAST32 SCNo32
|
|
|
|
#if defined(SCNo64)
|
|
|
|
#define SCNoFAST64 SCNo64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNuLEAST8 SCNu8
|
|
|
|
#define SCNuLEAST16 SCNu16
|
|
|
|
#define SCNuLEAST32 SCNu32
|
|
|
|
#if defined(SCNu64)
|
|
|
|
#define SCNuLEAST64 SCNu64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNuFAST8 SCNu8
|
|
|
|
#define SCNuFAST16 SCNu16
|
|
|
|
#define SCNuFAST32 SCNu32
|
|
|
|
#if defined(SCNu64)
|
|
|
|
#define SCNuFAST64 SCNu64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNxLEAST8 SCNx8
|
|
|
|
#define SCNxLEAST16 SCNx16
|
|
|
|
#define SCNxLEAST32 SCNx32
|
|
|
|
#if defined(SCNx64)
|
|
|
|
#define SCNxLEAST64 SCNx64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SCNxFAST8 SCNx8
|
|
|
|
#define SCNxFAST16 SCNx16
|
|
|
|
#define SCNxFAST32 SCNx32
|
|
|
|
#if defined(SCNx64)
|
|
|
|
#define SCNxFAST64 SCNx64
|
|
|
|
#endif
|
|
|
|
|
2020-11-19 06:09:39 +01:00
|
|
|
/* intmax_t/uintmax_t */
|
|
|
|
|
|
|
|
#define PRIdMAX "jd"
|
|
|
|
#define PRIiMAX "ji"
|
|
|
|
#define PRIoMAX "jo"
|
|
|
|
#define PRIuMAX "ju"
|
|
|
|
#define PRIxMAX "jx"
|
|
|
|
#define PRIXMAX "jX"
|
|
|
|
|
|
|
|
#define SCNdMAX "jd"
|
|
|
|
#define SCNiMAX "ji"
|
|
|
|
#define SCNoMAX "jo"
|
|
|
|
#define SCNuMAX "ju"
|
|
|
|
#define SCNxMAX "jx"
|
|
|
|
|
2021-07-21 05:46:21 +02:00
|
|
|
/* off_t */
|
|
|
|
|
|
|
|
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
|
|
|
#define PRIdOFF PRId64
|
|
|
|
#define PRIiOFF PRIi64
|
|
|
|
#define PRIoOFF PRIo64
|
|
|
|
#define PRIuOFF PRIu64
|
|
|
|
#define PRIxOFF PRIx64
|
|
|
|
#define PRIXOFF PRIX64
|
|
|
|
|
|
|
|
#define SCNdOFF SCNd64
|
|
|
|
#define SCNiOFF SCNi64
|
|
|
|
#define SCNoOFF SCNo64
|
|
|
|
#define SCNuOFF SCNu64
|
|
|
|
#define SCNxOFF SCNx64
|
|
|
|
#else
|
|
|
|
#define PRIdOFF PRId32
|
|
|
|
#define PRIiOFF PRIi32
|
|
|
|
#define PRIoOFF PRIo32
|
|
|
|
#define PRIuOFF PRIu32
|
|
|
|
#define PRIxOFF PRIx32
|
|
|
|
#define PRIXOFF PRIX32
|
|
|
|
|
|
|
|
#define SCNdOFF SCNd32
|
|
|
|
#define SCNiOFF SCNi32
|
|
|
|
#define SCNoOFF SCNo32
|
|
|
|
#define SCNuOFF SCNu32
|
|
|
|
#define SCNxOFF SCNx32
|
|
|
|
#endif
|
|
|
|
|
2010-10-10 02:20:09 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* "The <inttypes.h> header shall include a definition of at least the
|
|
|
|
* following type:
|
|
|
|
*
|
2014-04-13 22:32:20 +02:00
|
|
|
* imaxdiv_t
|
2010-10-10 02:20:09 +02:00
|
|
|
* Structure type that is the type of the value returned by the imaxdiv()
|
|
|
|
* function.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef void *imaxdiv_t; /* Dummy type since imaxdiv is not yet supported */
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
2014-06-27 16:14:07 +02:00
|
|
|
extern "C"
|
|
|
|
{
|
2010-10-10 02:20:09 +02:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* "The following shall be declared as functions and may also be defined as
|
|
|
|
* macros. Function prototypes shall be provided."
|
|
|
|
*/
|
|
|
|
|
2017-02-16 22:12:37 +01:00
|
|
|
intmax_t imaxabs(intmax_t j);
|
2020-02-23 09:50:23 +01:00
|
|
|
imaxdiv_t imaxdiv(intmax_t number, intmax_t denom);
|
2017-02-16 22:12:37 +01:00
|
|
|
intmax_t strtoimax(FAR const char *nptr, FAR char **endptr, int base);
|
|
|
|
uintmax_t strtoumax(FAR const char *nptr, FAR char **endptr, int base);
|
2010-10-10 02:20:09 +02:00
|
|
|
|
2017-02-16 22:12:37 +01:00
|
|
|
intmax_t wcstoimax(FAR const wchar_t *nptr, FAR wchar_t **endptr, int base);
|
|
|
|
uintmax_t wcstoumax(FAR const wchar_t *nptr, FAR wchar_t **endptr, int base);
|
2010-10-10 02:20:09 +02:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __INCLUDE_INTTYPES_H */
|