L 1 "..\src\myprintf\MyPrintf.c" N N#include L 1 "d:\Keil\ARM\ARM_Compiler_5.06u7\Bin\..\include\STDIO.h" 1 N/* stdio.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.9 */ N/* Copyright (C) Codemist Ltd., 1988-1993 */ N/* Copyright 1991-1998 ARM Limited. All rights reserved. */ N N/* N * RCS $Revision$ N * Checkin $Date$ N * Revising $Author: sdouglas $ N */ N N/* N * stdio.h declares two types, several macros, and many functions for N * performing input and output. For a discussion on Streams and Files N * refer to sections 4.9.2 and 4.9.3 in the above ANSI draft, or to a N * modern textbook on C. N */ N N#ifndef __stdio_h N#define __stdio_h N#define __ARMCLIB_VERSION 5060044 N N/* N * Depending on compiler version __int64 or __INT64_TYPE__ should be defined. N */ N#ifndef __int64 N #ifdef __INT64_TYPE__ S #define __int64 __INT64_TYPE__ N #endif N /* On some architectures neither of these may be defined - if so, fall N through and error out if used. */ N#endif N N N#define _ARMABI __declspec(__nothrow) N N #ifndef __STDIO_DECLS N #define __STDIO_DECLS N N #undef __CLIBNS N #ifdef __cplusplus S namespace std { S #define __CLIBNS ::std:: S extern "C" { N #else /* ndef __cplusplus */ N #define __CLIBNS N #endif /* ndef __cplusplus */ N N#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || !defined(__size_t) X#if 0L || !0L || !0L N /* always defined in C++ and non-strict C for consistency of debug info */ N #if __sizeof_ptr == 8 X #if 4 == 8 S typedef unsigned long size_t; /* see */ N #else N typedef unsigned int size_t; /* see */ N #endif N #if !defined(__cplusplus) && defined(__STRICT_ANSI__) X #if !0L && 0L S #define __size_t 1 N #endif N#endif N N#undef NULL N#define NULL 0 /* see */ N N/* ANSI forbids va_list to be defined here */ N/* keep in step with and */ N#if !defined(__va_list) && (defined(__cplusplus) || !defined(__STRICT_ANSI__) || !defined(__va_list_defined)) X#if !0L && (0L || !0L || !0L) N/* always defined in C++ and non-strict C for consistency of debug info */ N #ifdef __clang__ S typedef __builtin_va_list __va_list; N #else N typedef struct __va_list __va_list; N #endif N #if !defined(__cplusplus) && defined(__STRICT_ANSI__) X #if !0L && 0L S #define __va_list_defined 1 N #endif N#endif N N /* N * If the compiler supports signalling nans as per N965 then it N * will define __SUPPORT_SNAN__, in which case a user may define N * _WANT_SNAN in order to obtain compliant versions of the printf N * and scanf families of functions N */ N#if defined(__SUPPORT_SNAN__) && defined(_WANT_SNAN) X#if 0L && 0L S#pragma import(__use_snan) N#endif N Ntypedef struct __fpos_t_struct { N unsigned __int64 __pos; N /* N * this structure is equivalent to an mbstate_t, but we're not N * allowed to actually define the type name `mbstate_t' within N * stdio.h N */ N struct { N unsigned int __state1, __state2; N } __mbstate; N} fpos_t; N /* N * fpos_t is an object capable of recording all information needed to N * specify uniquely every position within a file. N */ N N#define _SYS_OPEN 16 N /* _SYS_OPEN defines a limit on the number of open files that is imposed N * by this C library N */ N Ntypedef struct __FILE FILE; N /* N * FILE is an object capable of recording all information needed to control N * a stream, such as its file position indicator, a pointer to its N * associated buffer, an error indicator that records whether a read/write N * error has occurred and an end-of-file indicator that records whether the N * end-of-file has been reached. N * Its structure is not made known to library clients. N */ N N#if defined(__STRICT_ANSI__) && !__FILE_INCOMPLETE X#if 0L && !__FILE_INCOMPLETE Sstruct __FILE { S union { S long __FILE_alignment; S#ifdef __TARGET_ARCH_AARCH64 S char __FILE_size[136]; S#else /* __TARGET_ARCH_AARCH64 */ S char __FILE_size[84]; S#endif /* __TARGET_ARCH_AARCH64 */ S } __FILE_opaque; S}; S /* S * FILE must be an object type (C99 - 7.19.1) and an object type fully S * describes an object [including its static size] (C99 - 6.2.5). S * This definition is a placeholder which matches the struct __FILE in S * size and alignment as used internally by libc. S */ N#endif N N Nextern FILE __stdin, __stdout, __stderr; Nextern FILE *__aeabi_stdin, *__aeabi_stdout, *__aeabi_stderr; N N#if _AEABI_PORTABILITY_LEVEL != 0 || (!defined _AEABI_PORTABILITY_LEVEL && __DEFAULT_AEABI_PORTABILITY_LEVEL != 0) X#if _AEABI_PORTABILITY_LEVEL != 0 || (!0L && __DEFAULT_AEABI_PORTABILITY_LEVEL != 0) S#define stdin (__CLIBNS __aeabi_stdin) S /* pointer to a FILE object associated with standard input stream */ S#define stdout (__CLIBNS __aeabi_stdout) S /* pointer to a FILE object associated with standard output stream */ S#define stderr (__CLIBNS __aeabi_stderr) S /* pointer to a FILE object associated with standard error stream */ Sextern const int __aeabi_IOFBF; S#define _IOFBF (__CLIBNS __aeabi_IOFBF) Sextern const int __aeabi_IONBF; S#define _IONBF (__CLIBNS __aeabi_IONBF) Sextern const int __aeabi_IOLBF; S#define _IOLBF (__CLIBNS __aeabi_IOLBF) Sextern const int __aeabi_BUFSIZ; S#define BUFSIZ (__CLIBNS __aeabi_BUFSIZ) Sextern const int __aeabi_FOPEN_MAX; S#define FOPEN_MAX (__CLIBNS __aeabi_FOPEN_MAX) Sextern const int __aeabi_TMP_MAX; S#define TMP_MAX (__CLIBNS __aeabi_TMP_MAX) Sextern const int __aeabi_FILENAME_MAX; S#define FILENAME_MAX (__CLIBNS __aeabi_FILENAME_MAX) Sextern const int __aeabi_L_tmpnam; S#define L_tmpnam (__CLIBNS __aeabi_L_tmpnam) N#else N#define stdin (&__CLIBNS __stdin) N /* pointer to a FILE object associated with standard input stream */ N#define stdout (&__CLIBNS __stdout) N /* pointer to a FILE object associated with standard output stream */ N#define stderr (&__CLIBNS __stderr) N /* pointer to a FILE object associated with standard error stream */ N N#define _IOFBF 0x100 /* fully buffered IO */ N#define _IOLBF 0x200 /* line buffered IO */ N#define _IONBF 0x400 /* unbuffered IO */ N N /* Various default file IO buffer sizes */ N#define BUFSIZ (512) /* system buffer size (as used by setbuf) */ N N#define FOPEN_MAX _SYS_OPEN N /* N * an integral constant expression that is the minimum number of files that N * this implementation guarantees can be open simultaneously. N */ N N#define FILENAME_MAX 256 N /* N * an integral constant expression that is the size of an array of char N * large enough to hold the longest filename string N */ N#define L_tmpnam FILENAME_MAX N /* N * an integral constant expression that is the size of an array of char N * large enough to hold a temporary file name string generated by the N * tmpnam function. N */ N#define TMP_MAX 256 N /* N * an integral constant expression that is the minimum number of unique N * file names that shall be generated by the tmpnam function. N */ N N#endif N N#define EOF (-1) N /* N * negative integral constant, indicates end-of-file, that is, no more input N * from a stream. N */ N N#define SEEK_SET 0 /* start of stream (see fseek) */ N#define SEEK_CUR 1 /* current position in stream (see fseek) */ N#define SEEK_END 2 /* end of stream (see fseek) */ N N /* N * _IOBIN is the flag passed to _sys_write to denote a binary N * file. N */ N#define _IOBIN 0x04 /* binary stream */ N N#define __STDIN_BUFSIZ (64) /* default stdin buffer size */ N#define __STDOUT_BUFSIZ (64) /* default stdout buffer size */ N#define __STDERR_BUFSIZ (16) /* default stderr buffer size */ N Nextern _ARMABI int remove(const char * /*filename*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int remove(const char * ) __attribute__((__nonnull__(1))); N /* N * causes the file whose name is the string pointed to by filename to be N * removed. Subsequent attempts to open the file will fail, unless it is N * created anew. If the file is open, the behaviour of the remove function N * is implementation-defined. N * Returns: zero if the operation succeeds, nonzero if it fails. N */ Nextern _ARMABI int rename(const char * /*old*/, const char * /*new*/) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int rename(const char * , const char * ) __attribute__((__nonnull__(1,2))); N /* N * causes the file whose name is the string pointed to by old to be N * henceforth known by the name given by the string pointed to by new. The N * file named old is effectively removed. If a file named by the string N * pointed to by new exists prior to the call of the rename function, the N * behaviour is implementation-defined. N * Returns: zero if the operation succeeds, nonzero if it fails, in which N * case if the file existed previously it is still known by its N * original name. N */ Nextern _ARMABI FILE *tmpfile(void); Xextern __declspec(__nothrow) FILE *tmpfile(void); N /* N * creates a temporary binary file that will be automatically removed when N * it is closed or at program termination. The file is opened for update. N * Returns: a pointer to the stream of the file that it created. If the file N * cannot be created, a null pointer is returned. N */ Nextern _ARMABI char *tmpnam(char * /*s*/); Xextern __declspec(__nothrow) char *tmpnam(char * ); N /* N * generates a string that is not the same as the name of an existing file. N * The tmpnam function generates a different string each time it is called, N * up to TMP_MAX times. If it is called more than TMP_MAX times, the N * behaviour is implementation-defined. N * Returns: If the argument is a null pointer, the tmpnam function leaves N * its result in an internal static object and returns a pointer to N * that object. Subsequent calls to the tmpnam function may modify N * the same object. if the argument is not a null pointer, it is N * assumed to point to an array of at least L_tmpnam characters; N * the tmpnam function writes its result in that array and returns N * the argument as its value. N */ N Nextern _ARMABI int fclose(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int fclose(FILE * ) __attribute__((__nonnull__(1))); N /* N * causes the stream pointed to by stream to be flushed and the associated N * file to be closed. Any unwritten buffered data for the stream are N * delivered to the host environment to be written to the file; any unread N * buffered data are discarded. The stream is disassociated from the file. N * If the associated buffer was automatically allocated, it is deallocated. N * Returns: zero if the stream was succesfully closed, or nonzero if any N * errors were detected or if the stream was already closed. N */ Nextern _ARMABI int fflush(FILE * /*stream*/); Xextern __declspec(__nothrow) int fflush(FILE * ); N /* N * If the stream points to an output or update stream in which the most N * recent operation was output, the fflush function causes any unwritten N * data for that stream to be delivered to the host environment to be N * written to the file. If the stream points to an input or update stream, N * the fflush function undoes the effect of any preceding ungetc operation N * on the stream. N * Returns: nonzero if a write error occurs. N */ Nextern _ARMABI FILE *fopen(const char * __restrict /*filename*/, Xextern __declspec(__nothrow) FILE *fopen(const char * __restrict , N const char * __restrict /*mode*/) __attribute__((__nonnull__(1,2))); N /* N * opens the file whose name is the string pointed to by filename, and N * associates a stream with it. N * The argument mode points to a string beginning with one of the following N * sequences: N * "r" open text file for reading N * "w" create text file for writing, or truncate to zero length N * "a" append; open text file or create for writing at eof N * "rb" open binary file for reading N * "wb" create binary file for writing, or truncate to zero length N * "ab" append; open binary file or create for writing at eof N * "r+" open text file for update (reading and writing) N * "w+" create text file for update, or truncate to zero length N * "a+" append; open text file or create for update, writing at eof N * "r+b"/"rb+" open binary file for update (reading and writing) N * "w+b"/"wb+" create binary file for update, or truncate to zero length N * "a+b"/"ab+" append; open binary file or create for update, writing at eof N * N * Opening a file with read mode ('r' as the first character in the mode N * argument) fails if the file does not exist or cannot be read. N * Opening a file with append mode ('a' as the first character in the mode N * argument) causes all subsequent writes to be forced to the current end of N * file, regardless of intervening calls to the fseek function. In some N * implementations, opening a binary file with append mode ('b' as the N * second or third character in the mode argument) may initially position N * the file position indicator beyond the last data written, because of the N * NUL padding. N * When a file is opened with update mode ('+' as the second or third N * character in the mode argument), both input and output may be performed N * on the associated stream. However, output may not be directly followed N * by input without an intervening call to the fflush fuction or to a file N * positioning function (fseek, fsetpos, or rewind), and input be not be N * directly followed by output without an intervening call to the fflush N * fuction or to a file positioning function, unless the input operation N * encounters end-of-file. Opening a file with update mode may open or N * create a binary stream in some implementations. When opened, a stream N * is fully buffered if and only if it does not refer to an interactive N * device. The error and end-of-file indicators for the stream are N * cleared. N * Returns: a pointer to the object controlling the stream. If the open N * operation fails, fopen returns a null pointer. N */ Nextern _ARMABI FILE *freopen(const char * __restrict /*filename*/, Xextern __declspec(__nothrow) FILE *freopen(const char * __restrict , N const char * __restrict /*mode*/, N FILE * __restrict /*stream*/) __attribute__((__nonnull__(2,3))); N /* N * opens the file whose name is the string pointed to by filename and N * associates the stream pointed to by stream with it. The mode argument is N * used just as in the fopen function. N * The freopen function first attempts to close any file that is associated N * with the specified stream. Failure to close the file successfully is N * ignored. The error and end-of-file indicators for the stream are cleared. N * Returns: a null pointer if the operation fails. Otherwise, freopen N * returns the value of the stream. N */ Nextern _ARMABI void setbuf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) void setbuf(FILE * __restrict , N char * __restrict /*buf*/) __attribute__((__nonnull__(1))); N /* N * Except that it returns no value, the setbuf function is equivalent to the N * setvbuf function invoked with the values _IOFBF for mode and BUFSIZ for N * size, or (if buf is a null pointer), with the value _IONBF for mode. N * Returns: no value. N */ Nextern _ARMABI int setvbuf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) int setvbuf(FILE * __restrict , N char * __restrict /*buf*/, N int /*mode*/, size_t /*size*/) __attribute__((__nonnull__(1))); N /* N * may be used after the stream pointed to by stream has been associated N * with an open file but before it is read or written. The argument mode N * determines how stream will be buffered, as follows: _IOFBF causes N * input/output to be fully buffered; _IOLBF causes output to be line N * buffered (the buffer will be flushed when a new-line character is N * written, when the buffer is full, or when input is requested); _IONBF N * causes input/output to be completely unbuffered. If buf is not the null N * pointer, the array it points to may be used instead of an automatically N * allocated buffer (the buffer must have a lifetime at least as great as N * the open stream, so the stream should be closed before a buffer that has N * automatic storage duration is deallocated upon block exit). The argument N * size specifies the size of the array. The contents of the array at any N * time are indeterminate. N * Returns: zero on success, or nonzero if an invalid value is given for N * mode or size, or if the request cannot be honoured. N */ N#pragma __printf_args Nextern _ARMABI int fprintf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) int fprintf(FILE * __restrict , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); N /* N * writes output to the stream pointed to by stream, under control of the N * string pointed to by format that specifies how subsequent arguments are N * converted for output. If there are insufficient arguments for the format, N * the behaviour is undefined. If the format is exhausted while arguments N * remain, the excess arguments are evaluated but otherwise ignored. The N * fprintf function returns when the end of the format string is reached. N * The format shall be a multibyte character sequence, beginning and ending N * in its initial shift state. The format is composed of zero or more N * directives: ordinary multibyte characters (not %), which are copied N * unchanged to the output stream; and conversion specifiers, each of which N * results in fetching zero or more subsequent arguments. Each conversion N * specification is introduced by the character %. For a description of the N * available conversion specifiers refer to section 4.9.6.1 in the ANSI N * draft mentioned at the start of this file or to any modern textbook on C. N * The minimum value for the maximum number of characters producable by any N * single conversion is at least 509. N * Returns: the number of characters transmitted, or a negative value if an N * output error occurred. N */ N#pragma __printf_args Nextern _ARMABI int _fprintf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) int _fprintf(FILE * __restrict , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to fprintf, but does not support floating-point formats. N * You can use instead of fprintf to improve code size. N * Returns: as fprintf. N */ N#pragma __printf_args Nextern _ARMABI int printf(const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int printf(const char * __restrict , ...) __attribute__((__nonnull__(1))); N /* N * is equivalent to fprintf with the argument stdout interposed before the N * arguments to printf. N * Returns: the number of characters transmitted, or a negative value if an N * output error occurred. N */ N#pragma __printf_args Nextern _ARMABI int _printf(const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int _printf(const char * __restrict , ...) __attribute__((__nonnull__(1))); N /* N * is equivalent to printf, but does not support floating-point formats. N * You can use instead of printf to improve code size. N * Returns: as printf. N */ N#pragma __printf_args Nextern _ARMABI int sprintf(char * __restrict /*s*/, const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int sprintf(char * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to fprintf, except that the argument s specifies an array N * into which the generated output is to be written, rather than to a N * stream. A null character is written at the end of the characters written; N * it is not counted as part of the returned sum. N * Returns: the number of characters written to the array, not counting the N * terminating null character. N */ N#pragma __printf_args Nextern _ARMABI int _sprintf(char * __restrict /*s*/, const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int _sprintf(char * __restrict , const char * __restrict , ...) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to sprintf, but does not support floating-point formats. N * You can use instead of sprintf to improve code size. N * Returns: as sprintf. N */ N N#pragma __printf_args Nextern _ARMABI int __ARM_snprintf(char * __restrict /*s*/, size_t /*n*/, Xextern __declspec(__nothrow) int __ARM_snprintf(char * __restrict , size_t , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(3))); N N#if !defined(__STRICT_ANSI__) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__) || (defined(__cplusplus) && 201103L <= __cplusplus) X#if !0L || (1L && 199901L <= 199409L) || (0L && 201103L <= __cplusplus) N#pragma __printf_args Nextern _ARMABI int snprintf(char * __restrict /*s*/, size_t /*n*/, Xextern __declspec(__nothrow) int snprintf(char * __restrict , size_t , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(3))); N /* N * is equivalent to fprintf, except that the argument s specifies an array N * into which the generated output is to be written, rather than to a N * stream. The argument n specifies the size of the output array, so as to N * avoid overflowing the buffer. N * A null character is written at the end of the characters written, even N * if the formatting was not completed; it is not counted as part of the N * returned sum. At most n characters of the output buffer are used, N * _including_ the null character. N * Returns: the number of characters that would have been written to the N * array, not counting the terminating null character, if the N * array had been big enough. So if the return is >=0 and =n, the string was truncated (but there is still a null char N * at the end of what was written); if the return is <0, there was N * an error. N */ N#endif N#pragma __printf_args Nextern _ARMABI int _snprintf(char * __restrict /*s*/, size_t /*n*/, Xextern __declspec(__nothrow) int _snprintf(char * __restrict , size_t , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(3))); N /* N * is equivalent to snprintf, but does not support floating-point formats. N * You can use instead of snprintf to improve code size. N * Returns: as snprintf. N */ N#pragma __scanf_args Nextern _ARMABI int fscanf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) int fscanf(FILE * __restrict , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); N /* N * reads input from the stream pointed to by stream, under control of the N * string pointed to by format that specifies the admissible input sequences N * and how thay are to be converted for assignment, using subsequent N * arguments as pointers to the objects to receive the converted input. If N * there are insufficient arguments for the format, the behaviour is N * undefined. If the format is exhausted while arguments remain, the excess N * arguments are evaluated but otherwise ignored. N * The format is composed of zero or more directives: one or more N * white-space characters; an ordinary character (not %); or a conversion N * specification. Each conversion specification is introduced by the N * character %. For a description of the available conversion specifiers N * refer to section 4.9.6.2 in the ANSI draft mentioned at the start of this N * file, or to any modern textbook on C. N * If end-of-file is encountered during input, conversion is terminated. If N * end-of-file occurs before any characters matching the current directive N * have been read (other than leading white space, where permitted), N * execution of the current directive terminates with an input failure; N * otherwise, unless execution of the current directive is terminated with a N * matching failure, execution of the following directive (if any) is N * terminated with an input failure. N * If conversions terminates on a conflicting input character, the offending N * input character is left unread in the input strem. Trailing white space N * (including new-line characters) is left unread unless matched by a N * directive. The success of literal matches and suppressed asignments is N * not directly determinable other than via the %n directive. N * Returns: the value of the macro EOF if an input failure occurs before any N * conversion. Otherwise, the fscanf function returns the number of N * input items assigned, which can be fewer than provided for, or N * even zero, in the event of an early conflict between an input N * character and the format. N */ N#pragma __scanf_args Nextern _ARMABI int _fscanf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) int _fscanf(FILE * __restrict , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to fscanf, but does not support floating-point formats. N * You can use instead of fscanf to improve code size. N * Returns: as fscanf. N */ N#pragma __scanf_args Nextern _ARMABI int scanf(const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int scanf(const char * __restrict , ...) __attribute__((__nonnull__(1))); N /* N * is equivalent to fscanf with the argument stdin interposed before the N * arguments to scanf. N * Returns: the value of the macro EOF if an input failure occurs before any N * conversion. Otherwise, the scanf function returns the number of N * input items assigned, which can be fewer than provided for, or N * even zero, in the event of an early matching failure. N */ N#pragma __scanf_args Nextern _ARMABI int _scanf(const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int _scanf(const char * __restrict , ...) __attribute__((__nonnull__(1))); N /* N * is equivalent to scanf, but does not support floating-point formats. N * You can use instead of scanf to improve code size. N * Returns: as scanf. N */ N#pragma __scanf_args Nextern _ARMABI int sscanf(const char * __restrict /*s*/, Xextern __declspec(__nothrow) int sscanf(const char * __restrict , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to fscanf except that the argument s specifies a string N * from which the input is to be obtained, rather than from a stream. N * Reaching the end of the string is equivalent to encountering end-of-file N * for the fscanf function. N * Returns: the value of the macro EOF if an input failure occurs before any N * conversion. Otherwise, the scanf function returns the number of N * input items assigned, which can be fewer than provided for, or N * even zero, in the event of an early matching failure. N */ N#pragma __scanf_args Nextern _ARMABI int _sscanf(const char * __restrict /*s*/, Xextern __declspec(__nothrow) int _sscanf(const char * __restrict , N const char * __restrict /*format*/, ...) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to sscanf, but does not support floating-point formats. N * You can use instead of sscanf to improve code size. N * Returns: as sscanf. N */ N#if !defined(__STRICT_ANSI__) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__) || (defined(__cplusplus) && 201103L <= __cplusplus) X#if !0L || (1L && 199901L <= 199409L) || (0L && 201103L <= __cplusplus) N/* C99 additions */ Nextern _ARMABI int vfscanf(FILE * __restrict /*stream*/, const char * __restrict /*format*/, __va_list) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int vfscanf(FILE * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); Nextern _ARMABI int vscanf(const char * __restrict /*format*/, __va_list) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int vscanf(const char * __restrict , __va_list) __attribute__((__nonnull__(1))); Nextern _ARMABI int vsscanf(const char * __restrict /*s*/, const char * __restrict /*format*/, __va_list) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int vsscanf(const char * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); N#endif Nextern _ARMABI int _vfscanf(FILE * __restrict /*stream*/, const char * __restrict /*format*/, __va_list) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int _vfscanf(FILE * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); Nextern _ARMABI int _vscanf(const char * __restrict /*format*/, __va_list) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int _vscanf(const char * __restrict , __va_list) __attribute__((__nonnull__(1))); Nextern _ARMABI int _vsscanf(const char * __restrict /*s*/, const char * __restrict /*format*/, __va_list) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int _vsscanf(const char * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); Nextern _ARMABI int __ARM_vsscanf(const char * __restrict /*s*/, const char * __restrict /*format*/, __va_list) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int __ARM_vsscanf(const char * __restrict , const char * __restrict , __va_list) __attribute__((__nonnull__(1,2))); N Nextern _ARMABI int vprintf(const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int vprintf(const char * __restrict , __va_list ) __attribute__((__nonnull__(1))); N /* N * is equivalent to printf, with the variable argument list replaced by arg, N * which has been initialised by the va_start macro (and possibly subsequent N * va_arg calls). The vprintf function does not invoke the va_end function. N * Returns: the number of characters transmitted, or a negative value if an N * output error occurred. N */ Nextern _ARMABI int _vprintf(const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int _vprintf(const char * __restrict , __va_list ) __attribute__((__nonnull__(1))); N /* N * is equivalent to vprintf, but does not support floating-point formats. N * You can use instead of vprintf to improve code size. N * Returns: as vprintf. N */ Nextern _ARMABI int vfprintf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) int vfprintf(FILE * __restrict , N const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to fprintf, with the variable argument list replaced by N * arg, which has been initialised by the va_start macro (and possibly N * subsequent va_arg calls). The vfprintf function does not invoke the N * va_end function. N * Returns: the number of characters transmitted, or a negative value if an N * output error occurred. N */ Nextern _ARMABI int vsprintf(char * __restrict /*s*/, Xextern __declspec(__nothrow) int vsprintf(char * __restrict , N const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to sprintf, with the variable argument list replaced by N * arg, which has been initialised by the va_start macro (and possibly N * subsequent va_arg calls). The vsprintf function does not invoke the N * va_end function. N * Returns: the number of characters written in the array, not counting the N * terminating null character. N */ Nextern _ARMABI int __ARM_vsnprintf(char * __restrict /*s*/, size_t /*n*/, Xextern __declspec(__nothrow) int __ARM_vsnprintf(char * __restrict , size_t , N const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(3))); N#if !defined(__STRICT_ANSI__) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__) || (defined(__cplusplus) && 201103L <= __cplusplus) X#if !0L || (1L && 199901L <= 199409L) || (0L && 201103L <= __cplusplus) Nextern _ARMABI int vsnprintf(char * __restrict /*s*/, size_t /*n*/, Xextern __declspec(__nothrow) int vsnprintf(char * __restrict , size_t , N const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(3))); N /* N * is equivalent to snprintf, with the variable argument list replaced by N * arg, which has been initialised by the va_start macro (and possibly N * subsequent va_arg calls). The vsprintf function does not invoke the N * va_end function. N * Returns: the number of characters that would have been written in the N * array, not counting the terminating null character. As N * snprintf. N */ N#endif Nextern _ARMABI int _vsprintf(char * __restrict /*s*/, Xextern __declspec(__nothrow) int _vsprintf(char * __restrict , N const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to vsprintf, but does not support floating-point formats. N * You can use instead of vsprintf to improve code size. N * Returns: as vsprintf. N */ Nextern _ARMABI int _vfprintf(FILE * __restrict /*stream*/, Xextern __declspec(__nothrow) int _vfprintf(FILE * __restrict , N const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(1,2))); N /* N * is equivalent to vfprintf, but does not support floating-point formats. N * You can use instead of vfprintf to improve code size. N * Returns: as vfprintf. N */ Nextern _ARMABI int _vsnprintf(char * __restrict /*s*/, size_t /*n*/, Xextern __declspec(__nothrow) int _vsnprintf(char * __restrict , size_t , N const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(3))); N /* N * is equivalent to vsnprintf, but does not support floating-point formats. N * You can use instead of vsnprintf to improve code size. N * Returns: as vsnprintf. N */ N#if !defined(__STRICT_ANSI__) X#if !0L N#pragma __printf_args Nextern _ARMABI int asprintf(char ** /*strp*/, const char * __restrict /*format*/, ...) __attribute__((__nonnull__(2))); Xextern __declspec(__nothrow) int asprintf(char ** , const char * __restrict , ...) __attribute__((__nonnull__(2))); Nextern _ARMABI int vasprintf(char ** /*strp*/, const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(2))); Xextern __declspec(__nothrow) int vasprintf(char ** , const char * __restrict , __va_list ) __attribute__((__nonnull__(2))); N#endif N#pragma __printf_args Nextern _ARMABI int __ARM_asprintf(char ** /*strp*/, const char * __restrict /*format*/, ...) __attribute__((__nonnull__(2))); Xextern __declspec(__nothrow) int __ARM_asprintf(char ** , const char * __restrict , ...) __attribute__((__nonnull__(2))); Nextern _ARMABI int __ARM_vasprintf(char ** /*strp*/, const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(2))); Xextern __declspec(__nothrow) int __ARM_vasprintf(char ** , const char * __restrict , __va_list ) __attribute__((__nonnull__(2))); N /* N * dynamically allocates a buffer of the right size for the N * formatted string, and returns it in (*strp). Formal return value N * is the same as any other printf variant, except that it returns N * -1 if the buffer could not be allocated. N * N * (The functions with __ARM_ prefixed names are identical to the N * ones without, but are available in all compilation modes without N * violating user namespace.) N */ N Nextern _ARMABI int fgetc(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int fgetc(FILE * ) __attribute__((__nonnull__(1))); N /* N * obtains the next character (if present) as an unsigned char converted to N * an int, from the input stream pointed to by stream, and advances the N * associated file position indicator (if defined). N * Returns: the next character from the input stream pointed to by stream. N * If the stream is at end-of-file, the end-of-file indicator is N * set and fgetc returns EOF. If a read error occurs, the error N * indicator is set and fgetc returns EOF. N */ Nextern _ARMABI char *fgets(char * __restrict /*s*/, int /*n*/, Xextern __declspec(__nothrow) char *fgets(char * __restrict , int , N FILE * __restrict /*stream*/) __attribute__((__nonnull__(1,3))); N /* N * reads at most one less than the number of characters specified by n from N * the stream pointed to by stream into the array pointed to by s. No N * additional characters are read after a new-line character (which is N * retained) or after end-of-file. A null character is written immediately N * after the last character read into the array. N * Returns: s if successful. If end-of-file is encountered and no characters N * have been read into the array, the contents of the array remain N * unchanged and a null pointer is returned. If a read error occurs N * during the operation, the array contents are indeterminate and a N * null pointer is returned. N */ Nextern _ARMABI int fputc(int /*c*/, FILE * /*stream*/) __attribute__((__nonnull__(2))); Xextern __declspec(__nothrow) int fputc(int , FILE * ) __attribute__((__nonnull__(2))); N /* N * writes the character specified by c (converted to an unsigned char) to N * the output stream pointed to by stream, at the position indicated by the N * asociated file position indicator (if defined), and advances the N * indicator appropriately. If the file position indicator is not defined, N * the character is appended to the output stream. N * Returns: the character written. If a write error occurs, the error N * indicator is set and fputc returns EOF. N */ Nextern _ARMABI int fputs(const char * __restrict /*s*/, FILE * __restrict /*stream*/) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int fputs(const char * __restrict , FILE * __restrict ) __attribute__((__nonnull__(1,2))); N /* N * writes the string pointed to by s to the stream pointed to by stream. N * The terminating null character is not written. N * Returns: EOF if a write error occurs; otherwise it returns a nonnegative N * value. N */ Nextern _ARMABI int getc(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int getc(FILE * ) __attribute__((__nonnull__(1))); N /* N * is equivalent to fgetc except that it may be implemented as an unsafe N * macro (stream may be evaluated more than once, so the argument should N * never be an expression with side-effects). N * Returns: the next character from the input stream pointed to by stream. N * If the stream is at end-of-file, the end-of-file indicator is N * set and getc returns EOF. If a read error occurs, the error N * indicator is set and getc returns EOF. N */ N#ifdef __cplusplus S inline int getchar() { return getc(stdin); } N#else N #define getchar() getc(stdin) N extern _ARMABI int (getchar)(void); X extern __declspec(__nothrow) int (getchar)(void); N#endif N /* N * is equivalent to getc with the argument stdin. N * Returns: the next character from the input stream pointed to by stdin. N * If the stream is at end-of-file, the end-of-file indicator is N * set and getchar returns EOF. If a read error occurs, the error N * indicator is set and getchar returns EOF. N */ Nextern _ARMABI char *gets(char * /*s*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) char *gets(char * ) __attribute__((__nonnull__(1))); N /* N * reads characters from the input stream pointed to by stdin into the array N * pointed to by s, until end-of-file is encountered or a new-line character N * is read. Any new-line character is discarded, and a null character is N * written immediately after the last character read into the array. N * Returns: s if successful. If end-of-file is encountered and no characters N * have been read into the array, the contents of the array remain N * unchanged and a null pointer is returned. If a read error occurs N * during the operation, the array contents are indeterminate and a N * null pointer is returned. N */ Nextern _ARMABI int putc(int /*c*/, FILE * /*stream*/) __attribute__((__nonnull__(2))); Xextern __declspec(__nothrow) int putc(int , FILE * ) __attribute__((__nonnull__(2))); N /* N * is equivalent to fputc except that it may be implemented as aan unsafe N * macro (stream may be evaluated more than once, so the argument should N * never be an expression with side-effects). N * Returns: the character written. If a write error occurs, the error N * indicator is set and putc returns EOF. N */ N#ifdef __cplusplus S inline int putchar(int __c) { return putc(__c, stdout); } N#else N #define putchar(c) putc(c, stdout) N extern _ARMABI int (putchar)(int /*c*/); X extern __declspec(__nothrow) int (putchar)(int ); N#endif N /* N * is equivalent to putc with the second argument stdout. N * Returns: the character written. If a write error occurs, the error N * indicator is set and putc returns EOF. N */ Nextern _ARMABI int puts(const char * /*s*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int puts(const char * ) __attribute__((__nonnull__(1))); N /* N * writes the string pointed to by s to the stream pointed to by stdout, and N * appends a new-line character to the output. The terminating null N * character is not written. N * Returns: EOF if a write error occurs; otherwise it returns a nonnegative N * value. N */ Nextern _ARMABI int ungetc(int /*c*/, FILE * /*stream*/) __attribute__((__nonnull__(2))); Xextern __declspec(__nothrow) int ungetc(int , FILE * ) __attribute__((__nonnull__(2))); N /* N * pushes the character specified by c (converted to an unsigned char) back N * onto the input stream pointed to by stream. The character will be N * returned by the next read on that stream. An intervening call to the N * fflush function or to a file positioning function (fseek, fsetpos, N * rewind) discards any pushed-back characters. The extern _ARMABIal storage N * corresponding to the stream is unchanged. N * One character pushback is guaranteed. If the unget function is called too N * many times on the same stream without an intervening read or file N * positioning operation on that stream, the operation may fail. N * If the value of c equals that of the macro EOF, the operation fails and N * the input stream is unchanged. N * A successful call to the ungetc function clears the end-of-file N * indicator. The value of the file position indicator after reading or N * discarding all pushed-back characters shall be the same as it was before N * the characters were pushed back. For a text stream, the value of the file N * position indicator after a successful call to the ungetc function is N * unspecified until all pushed-back characters are read or discarded. For a N * binary stream, the file position indicator is decremented by each N * successful call to the ungetc function; if its value was zero before a N * call, it is indeterminate after the call. N * Returns: the character pushed back after conversion, or EOF if the N * operation fails. N */ N Nextern _ARMABI size_t fread(void * __restrict /*ptr*/, Xextern __declspec(__nothrow) size_t fread(void * __restrict , N size_t /*size*/, size_t /*nmemb*/, FILE * __restrict /*stream*/) __attribute__((__nonnull__(1,4))); N /* N * reads into the array pointed to by ptr, up to nmemb members whose size is N * specified by size, from the stream pointed to by stream. The file N * position indicator (if defined) is advanced by the number of characters N * successfully read. If an error occurs, the resulting value of the file N * position indicator is indeterminate. If a partial member is read, its N * value is indeterminate. The ferror or feof function shall be used to N * distinguish between a read error and end-of-file. N * Returns: the number of members successfully read, which may be less than N * nmemb if a read error or end-of-file is encountered. If size or N * nmemb is zero, fread returns zero and the contents of the array N * and the state of the stream remain unchanged. N */ N Nextern _ARMABI size_t __fread_bytes_avail(void * __restrict /*ptr*/, Xextern __declspec(__nothrow) size_t __fread_bytes_avail(void * __restrict , N size_t /*count*/, FILE * __restrict /*stream*/) __attribute__((__nonnull__(1,3))); N /* N * reads into the array pointed to by ptr, up to count characters from the N * stream pointed to by stream. The file position indicator (if defined) N * is advanced by the number of characters successfully read. If an error N * occurs, the resulting value of the file position indicator is N * indeterminate. The ferror or feof function shall be used to N * distinguish between a read error and end-of-file. The call will block N * only if no characters are available. N * Returns: the number of characters successfully read, which may be less than N * count. If count is zero, __fread_bytes_avail returns zero and N * the contents of the array and the state of the stream remain N * unchanged. N */ N Nextern _ARMABI size_t fwrite(const void * __restrict /*ptr*/, Xextern __declspec(__nothrow) size_t fwrite(const void * __restrict , N size_t /*size*/, size_t /*nmemb*/, FILE * __restrict /*stream*/) __attribute__((__nonnull__(1,4))); N /* N * writes, from the array pointed to by ptr up to nmemb members whose size N * is specified by size, to the stream pointed to by stream. The file N * position indicator (if defined) is advanced by the number of characters N * successfully written. If an error occurs, the resulting value of the file N * position indicator is indeterminate. N * Returns: the number of members successfully written, which will be less N * than nmemb only if a write error is encountered. N */ N Nextern _ARMABI int fgetpos(FILE * __restrict /*stream*/, fpos_t * __restrict /*pos*/) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int fgetpos(FILE * __restrict , fpos_t * __restrict ) __attribute__((__nonnull__(1,2))); N /* N * stores the current value of the file position indicator for the stream N * pointed to by stream in the object pointed to by pos. The value stored N * contains unspecified information usable by the fsetpos function for N * repositioning the stream to its position at the time of the call to the N * fgetpos function. N * Returns: zero, if successful. Otherwise nonzero is returned and the N * integer expression errno is set to an implementation-defined N * nonzero value. N */ Nextern _ARMABI int fseek(FILE * /*stream*/, long int /*offset*/, int /*whence*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int fseek(FILE * , long int , int ) __attribute__((__nonnull__(1))); N /* N * sets the file position indicator for the stream pointed to by stream. N * For a binary stream, the new position is at the signed number of N * characters specified by offset away from the point specified by whence. N * The specified point is the beginning of the file for SEEK_SET, the N * current position in the file for SEEK_CUR, or end-of-file for SEEK_END. N * A binary stream need not meaningfully support fseek calls with a whence N * value of SEEK_END. N * For a text stream, either offset shall be zero, or offset shall be a N * value returned by an earlier call to the ftell function on the same N * stream and whence shall be SEEK_SET. N * The fseek function clears the end-of-file indicator and undoes any N * effects of the ungetc function on the same stream. After an fseek call, N * the next operation on an update stream may be either input or output. N * Returns: nonzero only for a request that cannot be satisfied. N */ Nextern _ARMABI int fsetpos(FILE * __restrict /*stream*/, const fpos_t * __restrict /*pos*/) __attribute__((__nonnull__(1,2))); Xextern __declspec(__nothrow) int fsetpos(FILE * __restrict , const fpos_t * __restrict ) __attribute__((__nonnull__(1,2))); N /* N * sets the file position indicator for the stream pointed to by stream N * according to the value of the object pointed to by pos, which shall be a N * value returned by an earlier call to the fgetpos function on the same N * stream. N * The fsetpos function clears the end-of-file indicator and undoes any N * effects of the ungetc function on the same stream. After an fsetpos call, N * the next operation on an update stream may be either input or output. N * Returns: zero, if successful. Otherwise nonzero is returned and the N * integer expression errno is set to an implementation-defined N * nonzero value. N */ Nextern _ARMABI long int ftell(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) long int ftell(FILE * ) __attribute__((__nonnull__(1))); N /* N * obtains the current value of the file position indicator for the stream N * pointed to by stream. For a binary stream, the value is the number of N * characters from the beginning of the file. For a text stream, the file N * position indicator contains unspecified information, usable by the fseek N * function for returning the file position indicator to its position at the N * time of the ftell call; the difference between two such return values is N * not necessarily a meaningful measure of the number of characters written N * or read. N * Returns: if successful, the current value of the file position indicator. N * On failure, the ftell function returns -1L and sets the integer N * expression errno to an implementation-defined nonzero value. N */ Nextern _ARMABI void rewind(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) void rewind(FILE * ) __attribute__((__nonnull__(1))); N /* N * sets the file position indicator for the stream pointed to by stream to N * the beginning of the file. It is equivalent to N * (void)fseek(stream, 0L, SEEK_SET) N * except that the error indicator for the stream is also cleared. N * Returns: no value. N */ N Nextern _ARMABI void clearerr(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) void clearerr(FILE * ) __attribute__((__nonnull__(1))); N /* N * clears the end-of-file and error indicators for the stream pointed to by N * stream. These indicators are cleared only when the file is opened or by N * an explicit call to the clearerr function or to the rewind function. N * Returns: no value. N */ N Nextern _ARMABI int feof(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int feof(FILE * ) __attribute__((__nonnull__(1))); N /* N * tests the end-of-file indicator for the stream pointed to by stream. N * Returns: nonzero iff the end-of-file indicator is set for stream. N */ Nextern _ARMABI int ferror(FILE * /*stream*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int ferror(FILE * ) __attribute__((__nonnull__(1))); N /* N * tests the error indicator for the stream pointed to by stream. N * Returns: nonzero iff the error indicator is set for stream. N */ Nextern _ARMABI void perror(const char * /*s*/); Xextern __declspec(__nothrow) void perror(const char * ); N /* N * maps the error number in the integer expression errno to an error N * message. It writes a sequence of characters to the standard error stream N * thus: first (if s is not a null pointer and the character pointed to by N * s is not the null character), the string pointed to by s followed by a N * colon and a space; then an appropriate error message string followed by N * a new-line character. The contents of the error message strings are the N * same as those returned by the strerror function with argument errno, N * which are implementation-defined. N * Returns: no value. N */ N Nextern _ARMABI int _fisatty(FILE * /*stream*/ ) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int _fisatty(FILE * ) __attribute__((__nonnull__(1))); N /* Returns 1 if the stream is tty (stdin), 0 otherwise. Not ANSI compliant. N */ N Nextern _ARMABI void __use_no_semihosting_swi(void); Xextern __declspec(__nothrow) void __use_no_semihosting_swi(void); Nextern _ARMABI void __use_no_semihosting(void); Xextern __declspec(__nothrow) void __use_no_semihosting(void); N /* N * Referencing either of these symbols will cause a link-time N * error if any library functions that use semihosting SWI N * calls are also present in the link, i.e. you define it if N * you want to make sure you haven't accidentally used any such N * SWIs. N */ N N #ifdef __cplusplus S } /* extern "C" */ S } /* namespace std */ N #endif N #endif /* __STDIO_DECLS */ N N #if _AEABI_PORTABILITY_LEVEL != 0 && !defined _AEABI_PORTABLE X #if _AEABI_PORTABILITY_LEVEL != 0 && !0L S #define _AEABI_PORTABLE N #endif N N #if defined(__cplusplus) && !defined(__STDIO_NO_EXPORTS) X #if 0L && !0L S using ::std::size_t; S using ::std::fpos_t; S using ::std::FILE; S using ::std::remove; S using ::std::rename; S using ::std::tmpfile; S using ::std::tmpnam; S using ::std::fclose; S using ::std::fflush; S using ::std::fopen; S using ::std::freopen; S using ::std::setbuf; S using ::std::setvbuf; S using ::std::fprintf; S using ::std::_fprintf; S using ::std::printf; S using ::std::_printf; S using ::std::sprintf; S using ::std::_sprintf; S #if !defined(__STRICT_ANSI__) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__) || (defined(__cplusplus) && 201103L <= __cplusplus) S using ::std::snprintf; S using ::std::vsnprintf; S using ::std::vfscanf; S using ::std::vscanf; S using ::std::vsscanf; S #endif S using ::std::_snprintf; S using ::std::_vsnprintf; S#if !defined(__STRICT_ANSI__) S using ::std::asprintf; S using ::std::vasprintf; S#endif S using ::std::__ARM_asprintf; S using ::std::__ARM_vasprintf; S using ::std::__ARM_vsnprintf; S using ::std::__ARM_snprintf; S using ::std::__ARM_vsscanf; S using ::std::fscanf; S using ::std::_fscanf; S using ::std::scanf; S using ::std::_scanf; S using ::std::sscanf; S using ::std::_sscanf; S using ::std::_vfscanf; S using ::std::_vscanf; S using ::std::_vsscanf; S using ::std::vprintf; S using ::std::_vprintf; S using ::std::vfprintf; S using ::std::_vfprintf; S using ::std::vsprintf; S using ::std::_vsprintf; S using ::std::fgetc; S using ::std::fgets; S using ::std::fputc; S using ::std::fputs; S using ::std::getc; S using ::std::getchar; S using ::std::gets; S using ::std::putc; S using ::std::putchar; S using ::std::puts; S using ::std::ungetc; S using ::std::fread; S using ::std::__fread_bytes_avail; S using ::std::fwrite; S using ::std::fgetpos; S using ::std::fseek; S using ::std::fsetpos; S using ::std::ftell; S using ::std::rewind; S using ::std::clearerr; S using ::std::feof; S using ::std::ferror; S using ::std::perror; S using ::std::_fisatty; S using ::std::__use_no_semihosting_swi; S using ::std::__use_no_semihosting; N #endif N N#endif /* ndef __stdio_h */ N N/* end of stdio.h */ N L 3 "..\src\myprintf\MyPrintf.c" 2 N#include L 1 "d:\Keil\ARM\ARM_Compiler_5.06u7\Bin\..\include\stdarg.h" 1 N/* stdarg.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.8 */ N/* Copyright (C) Codemist Ltd., 1988 */ N/* Copyright (C) ARM Ltd., 1991-1999. All rights reserved */ N N/* N * RCS $Revision$ N * Checkin $Date$ N * Revising $Author: agrant $ N */ N N#ifndef __stdarg_h N#define __stdarg_h N#define __ARMCLIB_VERSION 5060044 N N #ifndef __STDARG_DECLS N #define __STDARG_DECLS N N #undef __CLIBNS N N #ifdef __cplusplus S namespace std { S #define __CLIBNS ::std:: S extern "C" { N #else N #define __CLIBNS N #endif /* __cplusplus */ N N/* N * stdarg.h declares a type and defines macros for advancing through a N * list of arguments whose number and types are not known to the called N * function when it is translated. A function may be called with a variable N * number of arguments of differing types. Its parameter list contains one or N * more parameters. The rightmost parameter plays a special role in the access N * mechanism, and will be called parmN in this description. N */ N N/* N.B. is required to declare vfprintf() without defining */ N/* va_list. Clearly the type __va_list there must keep in step. */ N#ifdef __clang__ S typedef __builtin_va_list va_list; S #define va_start(ap, param) __builtin_va_start(ap, param) S #define va_end(ap) __builtin_va_end(ap) S #define va_arg(ap, type) __builtin_va_arg(ap, type) S #if __STDC_VERSION__ >= 199900L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__) S #define va_copy(dest, src) __builtin_va_copy(dest, src) S #endif N#else N #ifdef __TARGET_ARCH_AARCH64 S typedef struct __va_list { S void *__stack; S void *__gr_top; S void *__vr_top; S int __gr_offs; S int __vr_offs; S } va_list; N #else N typedef struct __va_list { void *__ap; } va_list; N #endif N /* N * an array type suitable for holding information needed by the macro va_arg N * and the function va_end. The called function shall declare a variable N * (referred to as ap) having type va_list. The variable ap may be passed as N * an argument to another function. N * Note: va_list is an array type so that when an object of that type N * is passed as an argument it gets passed by reference. N */ N #define va_start(ap, parmN) __va_start(ap, parmN) N N /* N * The va_start macro shall be executed before any access to the unnamed N * arguments. The parameter ap points to an object that has type va_list. N * The va_start macro initialises ap for subsequent use by va_arg and N * va_end. The parameter parmN is the identifier of the rightmost parameter N * in the variable parameter list in the function definition (the one just N * before the '...'). If the parameter parmN is declared with the register N * storage class an error is given. N * If parmN is a narrow type (char, short, float) an error is given in N * strict ANSI mode, or a warning otherwise. N * Returns: no value. N */ N #define va_arg(ap, type) __va_arg(ap, type) N N /* N * The va_arg macro expands to an expression that has the type and value of N * the next argument in the call. The parameter ap shall be the same as the N * va_list ap initialised by va_start. Each invocation of va_arg modifies N * ap so that successive arguments are returned in turn. The parameter N * 'type' is a type name such that the type of a pointer to an object that N * has the specified type can be obtained simply by postfixing a * to N * 'type'. If type is a narrow type, an error is given in strict ANSI N * mode, or a warning otherwise. If the type is an array or function type, N * an error is given. N * In non-strict ANSI mode, 'type' is allowed to be any expression. N * Returns: The first invocation of the va_arg macro after that of the N * va_start macro returns the value of the argument after that N * specified by parmN. Successive invocations return the values of N * the remaining arguments in succession. N * The result is cast to 'type', even if 'type' is narrow. N */ N N#define __va_copy(dest, src) ((void)((dest) = (src))) N N#if !defined(__STRICT_ANSI__) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__) || (defined(__cplusplus) && 201103L <= __cplusplus) X#if !0L || (1L && 199901L <= 199409L) || (0L && 201103L <= __cplusplus) N /* va_copy is in C99 and non-strict C90 and non-strict C++ N * __va_copy is always present. N */ N #define va_copy(dest, src) ((void)((dest) = (src))) N N /* The va_copy macro makes the va_list dest be a copy of N * the va_list src, as if the va_start macro had been applied N * to it followed by the same sequence of uses of the va_arg N * macro as had previously been used to reach the present state N * of src. N */ N#endif N N#define va_end(ap) __va_end(ap) N /* N * The va_end macro facilitates a normal return from the function whose N * variable argument list was referenced by the expansion of va_start that N * initialised the va_list ap. If the va_end macro is not invoked before N * the return, the behaviour is undefined. N * Returns: no value. N */ N#endif /* __clang__ */ N N #ifdef __cplusplus S } /* extern "C" */ S } /* namespace std */ N #endif /* __cplusplus */ N N #ifdef __GNUC__ S /* be cooperative with glibc */ S typedef __CLIBNS va_list __gnuc_va_list; S #define __GNUC_VA_LIST S #undef __need___va_list N #endif N N #endif /* __STDARG_DECLS */ N N #ifdef __cplusplus S #ifndef __STDARG_NO_EXPORTS S using ::std::va_list; S #endif N #endif /* __cplusplus */ N#endif N N/* end of stdarg.h */ N L 4 "..\src\myprintf\MyPrintf.c" 2 N#include N#include L 1 "..\src\myprintf\MYPRINTF.H" 1 N#ifndef _MYPRINTF_H_ N#define _MYPRINTF_H_ N N#define printf MyPrintf Nint MyPrintf(const char *fmt,...); N#endif N L 6 "..\src\myprintf\MyPrintf.c" 2 N N#include "SEGGER_RTT.h" L 1 "..\src\RTT\SEGGER_RTT.h" 1 N/********************************************************************* N* SEGGER Microcontroller GmbH * N* The Embedded Experts * N********************************************************************** N* * N* (c) 1995 - 2021 SEGGER Microcontroller GmbH * N* * N* www.segger.com Support: support@segger.com * N* * N********************************************************************** N* * N* SEGGER RTT * Real Time Transfer for embedded targets * N* * N********************************************************************** N* * N* All rights reserved. * N* * N* SEGGER strongly recommends to not make any changes * N* to or modify the source code of this software in order to stay * N* compatible with the RTT protocol and J-Link. * N* * N* Redistribution and use in source and binary forms, with or * N* without modification, are permitted provided that the following * N* condition is met: * N* * N* o Redistributions of source code must retain the above copyright * N* notice, this condition and the following disclaimer. * N* * N* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * N* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * N* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * N* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * N* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * N* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * N* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * N* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * N* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * N* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * N* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * N* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * N* DAMAGE. * N* * N********************************************************************** N* * N* RTT version: 7.20 * N* * N********************************************************************** N N---------------------------END-OF-HEADER------------------------------ NFile : SEGGER_RTT.h NPurpose : Implementation of SEGGER real-time transfer which allows N real-time communication on targets which support debugger N memory accesses while the CPU is running. NRevision: $Rev: 20869 $ N---------------------------------------------------------------------- N*/ N N#ifndef SEGGER_RTT_H N#define SEGGER_RTT_H N N#include "SEGGER_RTT_Conf.h" L 1 "..\src\RTT\SEGGER_RTT_Conf.h" 1 N/********************************************************************* N* SEGGER Microcontroller GmbH * N* The Embedded Experts * N********************************************************************** N* * N* (c) 1995 - 2021 SEGGER Microcontroller GmbH * N* * N* www.segger.com Support: support@segger.com * N* * N********************************************************************** N* * N* SEGGER RTT * Real Time Transfer for embedded targets * N* * N********************************************************************** N* * N* All rights reserved. * N* * N* SEGGER strongly recommends to not make any changes * N* to or modify the source code of this software in order to stay * N* compatible with the RTT protocol and J-Link. * N* * N* Redistribution and use in source and binary forms, with or * N* without modification, are permitted provided that the following * N* condition is met: * N* * N* o Redistributions of source code must retain the above copyright * N* notice, this condition and the following disclaimer. * N* * N* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * N* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * N* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * N* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * N* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * N* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * N* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * N* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * N* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * N* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * N* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * N* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * N* DAMAGE. * N* * N********************************************************************** N* * N* RTT version: 7.20 * N* * N********************************************************************** N N---------------------------END-OF-HEADER------------------------------ NFile : SEGGER_RTT_Conf.h NPurpose : Implementation of SEGGER real-time transfer (RTT) which N allows real-time communication on targets which support N debugger memory accesses while the CPU is running. NRevision: $Rev: 21386 $ N N*/ N N#ifndef SEGGER_RTT_CONF_H N#define SEGGER_RTT_CONF_H N N#ifdef __IAR_SYSTEMS_ICC__ S #include N#endif N N/********************************************************************* N* N* Defines, configurable N* N********************************************************************** N*/ N N// N// Take in and set to correct values for Cortex-A systems with CPU cache N// N//#define SEGGER_RTT_CPU_CACHE_LINE_SIZE (32) // Largest cache line size (in bytes) in the current system N//#define SEGGER_RTT_UNCACHED_OFF (0xFB000000) // Address alias where RTT CB and buffers can be accessed uncached N// N// Most common case: N// Up-channel 0: RTT N// Up-channel 1: SystemView N// N#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS N #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3) N#endif N// N// Most common case: N// Down-channel 0: RTT N// Down-channel 1: SystemView N// N#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS N #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3) N#endif N N#ifndef BUFFER_SIZE_UP N #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k) N#endif N N#ifndef BUFFER_SIZE_DOWN N #define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) N#endif N N#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE N #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) N#endif N N#ifndef SEGGER_RTT_MODE_DEFAULT N #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0) N#endif N N/********************************************************************* N* N* RTT memcpy configuration N* N* memcpy() is good for large amounts of data, N* but the overhead is big for small amounts, which are usually stored via RTT. N* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead. N* N* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions. N* This is may be required with memory access restrictions, N* such as on Cortex-A devices with MMU. N*/ N#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP N #define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop N#endif N// N// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets N// N//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__)) N// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes)) N//#endif N N// N// Target is not allowed to perform other RTT operations while string still has not been stored completely. N// Otherwise we would probably end up with a mixed string in the buffer. N// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. N// N// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4. N// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches. N// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly. N// (Higher priority = lower priority number) N// Default value for embOS: 128u N// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) N// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC N// or define SEGGER_RTT_LOCK() to completely disable interrupts. N// N#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY N #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) N#endif N N/********************************************************************* N* N* RTT lock configuration for SEGGER Embedded Studio, N* Rowley CrossStudio and GCC N*/ N#if ((defined(__SES_ARM) || defined(__SES_RISCV) || defined(__CROSSWORKS_ARM) || defined(__GNUC__) || defined(__clang__)) && !defined (__CC_ARM) && !defined(WIN32)) X#if ((0L || 0L || 0L || 0L || 0L) && !1L && !0L) S #if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__)) S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S __asm volatile ("mrs %0, primask \n\t" \ S "movs r1, #1 \n\t" \ S "msr primask, r1 \n\t" \ S : "=r" (_SEGGER_RTT__LockState) \ S : \ S : "r1", "cc" \ S ); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; __asm volatile ("mrs %0, primask \n\t" "movs r1, #1 \n\t" "msr primask, r1 \n\t" : "=r" (_SEGGER_RTT__LockState) : : "r1", "cc" ); S S #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \ S : \ S : "r" (_SEGGER_RTT__LockState) \ S : \ S ); \ S } X #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" : : "r" (_SEGGER_RTT__LockState) : ); } S #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__)) S #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY S #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) S #endif S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S __asm volatile ("mrs %0, basepri \n\t" \ S "mov r1, %1 \n\t" \ S "msr basepri, r1 \n\t" \ S : "=r" (_SEGGER_RTT__LockState) \ S : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \ S : "r1", "cc" \ S ); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; __asm volatile ("mrs %0, basepri \n\t" "mov r1, %1 \n\t" "msr basepri, r1 \n\t" : "=r" (_SEGGER_RTT__LockState) : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) : "r1", "cc" ); S S #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \ S : \ S : "r" (_SEGGER_RTT__LockState) \ S : \ S ); \ S } X #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" : : "r" (_SEGGER_RTT__LockState) : ); } S S #elif defined(__ARM_ARCH_7A__) S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S __asm volatile ("mrs r1, CPSR \n\t" \ S "mov %0, r1 \n\t" \ S "orr r1, r1, #0xC0 \n\t" \ S "msr CPSR_c, r1 \n\t" \ S : "=r" (_SEGGER_RTT__LockState) \ S : \ S : "r1", "cc" \ S ); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; __asm volatile ("mrs r1, CPSR \n\t" "mov %0, r1 \n\t" "orr r1, r1, #0xC0 \n\t" "msr CPSR_c, r1 \n\t" : "=r" (_SEGGER_RTT__LockState) : : "r1", "cc" ); S S #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \ S "mrs r1, CPSR \n\t" \ S "bic r1, r1, #0xC0 \n\t" \ S "and r0, r0, #0xC0 \n\t" \ S "orr r1, r1, r0 \n\t" \ S "msr CPSR_c, r1 \n\t" \ S : \ S : "r" (_SEGGER_RTT__LockState) \ S : "r0", "r1", "cc" \ S ); \ S } X #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" "mrs r1, CPSR \n\t" "bic r1, r1, #0xC0 \n\t" "and r0, r0, #0xC0 \n\t" "orr r1, r1, r0 \n\t" "msr CPSR_c, r1 \n\t" : : "r" (_SEGGER_RTT__LockState) : "r0", "r1", "cc" ); } S #elif defined(__riscv) || defined(__riscv_xlen) S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S __asm volatile ("csrr %0, mstatus \n\t" \ S "csrci mstatus, 8 \n\t" \ S "andi %0, %0, 8 \n\t" \ S : "=r" (_SEGGER_RTT__LockState) \ S : \ S : \ S ); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; __asm volatile ("csrr %0, mstatus \n\t" "csrci mstatus, 8 \n\t" "andi %0, %0, 8 \n\t" : "=r" (_SEGGER_RTT__LockState) : : ); S S #define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" \ S "or %0, %0, a1 \n\t" \ S "csrs mstatus, %0 \n\t" \ S : \ S : "r" (_SEGGER_RTT__LockState) \ S : "a1" \ S ); \ S } X #define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" "or %0, %0, a1 \n\t" "csrs mstatus, %0 \n\t" : : "r" (_SEGGER_RTT__LockState) : "a1" ); } S #else S #define SEGGER_RTT_LOCK() S #define SEGGER_RTT_UNLOCK() S #endif N#endif N N/********************************************************************* N* N* RTT lock configuration for IAR EWARM N*/ N#ifdef __ICCARM__ S #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || \ S (defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__)) X #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || (defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__)) S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S _SEGGER_RTT__LockState = __get_PRIMASK(); \ S __set_PRIMASK(1); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; _SEGGER_RTT__LockState = __get_PRIMASK(); __set_PRIMASK(1); S S #define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); \ S } X #define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); } S #elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || \ S (defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || \ S (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || \ S (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) X #elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) S #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY S #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) S #endif S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S _SEGGER_RTT__LockState = __get_BASEPRI(); \ S __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; _SEGGER_RTT__LockState = __get_BASEPRI(); __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); S S #define SEGGER_RTT_UNLOCK() __set_BASEPRI(_SEGGER_RTT__LockState); \ S } X #define SEGGER_RTT_UNLOCK() __set_BASEPRI(_SEGGER_RTT__LockState); } S #elif (defined (__ARM7A__) && (__CORE__ == __ARM7A__)) || \ S (defined (__ARM7R__) && (__CORE__ == __ARM7R__)) X #elif (defined (__ARM7A__) && (__CORE__ == __ARM7A__)) || (defined (__ARM7R__) && (__CORE__ == __ARM7R__)) S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S __asm volatile ("mrs r1, CPSR \n\t" \ S "mov %0, r1 \n\t" \ S "orr r1, r1, #0xC0 \n\t" \ S "msr CPSR_c, r1 \n\t" \ S : "=r" (_SEGGER_RTT__LockState) \ S : \ S : "r1", "cc" \ S ); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; __asm volatile ("mrs r1, CPSR \n\t" "mov %0, r1 \n\t" "orr r1, r1, #0xC0 \n\t" "msr CPSR_c, r1 \n\t" : "=r" (_SEGGER_RTT__LockState) : : "r1", "cc" ); S S #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \ S "mrs r1, CPSR \n\t" \ S "bic r1, r1, #0xC0 \n\t" \ S "and r0, r0, #0xC0 \n\t" \ S "orr r1, r1, r0 \n\t" \ S "msr CPSR_c, r1 \n\t" \ S : \ S : "r" (_SEGGER_RTT__LockState) \ S : "r0", "r1", "cc" \ S ); \ S } X #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" "mrs r1, CPSR \n\t" "bic r1, r1, #0xC0 \n\t" "and r0, r0, #0xC0 \n\t" "orr r1, r1, r0 \n\t" "msr CPSR_c, r1 \n\t" : : "r" (_SEGGER_RTT__LockState) : "r0", "r1", "cc" ); } S #endif N#endif N N/********************************************************************* N* N* RTT lock configuration for IAR RX N*/ N#ifdef __ICCRX__ S #define SEGGER_RTT_LOCK() { \ S unsigned long _SEGGER_RTT__LockState; \ S _SEGGER_RTT__LockState = __get_interrupt_state(); \ S __disable_interrupt(); X #define SEGGER_RTT_LOCK() { unsigned long _SEGGER_RTT__LockState; _SEGGER_RTT__LockState = __get_interrupt_state(); __disable_interrupt(); S S #define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); \ S } X #define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); } N#endif N N/********************************************************************* N* N* RTT lock configuration for IAR RL78 N*/ N#ifdef __ICCRL78__ S #define SEGGER_RTT_LOCK() { \ S __istate_t _SEGGER_RTT__LockState; \ S _SEGGER_RTT__LockState = __get_interrupt_state(); \ S __disable_interrupt(); X #define SEGGER_RTT_LOCK() { __istate_t _SEGGER_RTT__LockState; _SEGGER_RTT__LockState = __get_interrupt_state(); __disable_interrupt(); S S #define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); \ S } X #define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); } N#endif N N/********************************************************************* N* N* RTT lock configuration for KEIL ARM N*/ N#ifdef __CC_ARM N #if (defined __TARGET_ARCH_6S_M) X #if (0L) S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S register unsigned char _SEGGER_RTT__PRIMASK __asm( "primask"); \ S _SEGGER_RTT__LockState = _SEGGER_RTT__PRIMASK; \ S _SEGGER_RTT__PRIMASK = 1u; \ S __schedule_barrier(); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; register unsigned char _SEGGER_RTT__PRIMASK __asm( "primask"); _SEGGER_RTT__LockState = _SEGGER_RTT__PRIMASK; _SEGGER_RTT__PRIMASK = 1u; __schedule_barrier(); S S #define SEGGER_RTT_UNLOCK() _SEGGER_RTT__PRIMASK = _SEGGER_RTT__LockState; \ S __schedule_barrier(); \ S } X #define SEGGER_RTT_UNLOCK() _SEGGER_RTT__PRIMASK = _SEGGER_RTT__LockState; __schedule_barrier(); } N #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) X #elif (1L || 0L) N #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY S #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) N #endif N #define SEGGER_RTT_LOCK() { \ N unsigned int _SEGGER_RTT__LockState; \ N register unsigned char BASEPRI __asm( "basepri"); \ N _SEGGER_RTT__LockState = BASEPRI; \ N BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \ N __schedule_barrier(); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; register unsigned char BASEPRI __asm( "basepri"); _SEGGER_RTT__LockState = BASEPRI; BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; __schedule_barrier(); N N #define SEGGER_RTT_UNLOCK() BASEPRI = _SEGGER_RTT__LockState; \ N __schedule_barrier(); \ N } X #define SEGGER_RTT_UNLOCK() BASEPRI = _SEGGER_RTT__LockState; __schedule_barrier(); } N #endif N#endif N N/********************************************************************* N* N* RTT lock configuration for TI ARM N*/ N#ifdef __TI_ARM__ S #if defined (__TI_ARM_V6M0__) S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S _SEGGER_RTT__LockState = __get_PRIMASK(); \ S __set_PRIMASK(1); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; _SEGGER_RTT__LockState = __get_PRIMASK(); __set_PRIMASK(1); S S #define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); \ S } X #define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); } S #elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__)) S #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY S #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) S #endif S #define SEGGER_RTT_LOCK() { \ S unsigned int _SEGGER_RTT__LockState; \ S _SEGGER_RTT__LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); X #define SEGGER_RTT_LOCK() { unsigned int _SEGGER_RTT__LockState; _SEGGER_RTT__LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); S S #define SEGGER_RTT_UNLOCK() _set_interrupt_priority(_SEGGER_RTT__LockState); \ S } X #define SEGGER_RTT_UNLOCK() _set_interrupt_priority(_SEGGER_RTT__LockState); } S #endif N#endif N N/********************************************************************* N* N* RTT lock configuration for CCRX N*/ N#ifdef __RX S #include S #define SEGGER_RTT_LOCK() { \ S unsigned long _SEGGER_RTT__LockState; \ S _SEGGER_RTT__LockState = get_psw() & 0x010000; \ S clrpsw_i(); X #define SEGGER_RTT_LOCK() { unsigned long _SEGGER_RTT__LockState; _SEGGER_RTT__LockState = get_psw() & 0x010000; clrpsw_i(); S S #define SEGGER_RTT_UNLOCK() set_psw(get_psw() | _SEGGER_RTT__LockState); \ S } X #define SEGGER_RTT_UNLOCK() set_psw(get_psw() | _SEGGER_RTT__LockState); } N#endif N N/********************************************************************* N* N* RTT lock configuration for embOS Simulation on Windows N* (Can also be used for generic RTT locking with embOS) N*/ N#if defined(WIN32) || defined(SEGGER_RTT_LOCK_EMBOS) X#if 0L || 0L S Svoid OS_SIM_EnterCriticalSection(void); Svoid OS_SIM_LeaveCriticalSection(void); S S#define SEGGER_RTT_LOCK() { \ S OS_SIM_EnterCriticalSection(); X#define SEGGER_RTT_LOCK() { OS_SIM_EnterCriticalSection(); S S#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); \ S } X#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); } N#endif N N/********************************************************************* N* N* RTT lock configuration fallback N*/ N#ifndef SEGGER_RTT_LOCK S #define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts) N#endif N N#ifndef SEGGER_RTT_UNLOCK S #define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state) N#endif N N#endif N/*************************** End of file ****************************/ L 62 "..\src\RTT\SEGGER_RTT.h" 2 N N/********************************************************************* N* N* Defines, defaults N* N********************************************************************** N*/ N#ifndef RTT_USE_ASM N #if (defined __SES_ARM) // SEGGER Embedded Studio X #if (0L) S #define _CC_HAS_RTT_ASM_SUPPORT 1 S #elif (defined __CROSSWORKS_ARM) // Rowley Crossworks X #elif (0L) S #define _CC_HAS_RTT_ASM_SUPPORT 1 N #elif (defined __ARMCC_VERSION) // ARM compiler X #elif (1L) N #if (__ARMCC_VERSION >= 6000000) // ARM compiler V6.0 and later is clang based X #if (5060960 >= 6000000) S #define _CC_HAS_RTT_ASM_SUPPORT 1 N #else N #define _CC_HAS_RTT_ASM_SUPPORT 0 N #endif N #elif (defined __GNUC__) // GCC S #define _CC_HAS_RTT_ASM_SUPPORT 1 S #elif (defined __clang__) // Clang compiler S #define _CC_HAS_RTT_ASM_SUPPORT 1 S #elif ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler S #define _CC_HAS_RTT_ASM_SUPPORT 1 S #else S #define _CC_HAS_RTT_ASM_SUPPORT 0 N #endif N #if ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler X #if ((0L) || (0L)) S // S // IAR assembler / compiler S // S #if (__VER__ < 6300000) S #define VOLATILE S #else S #define VOLATILE volatile S #endif S #if (defined __ARM7M__) // Needed for old versions that do not know the define yet S #if (__CORE__ == __ARM7M__) // Cortex-M3 S #define _CORE_HAS_RTT_ASM_SUPPORT 1 S #endif S #endif S #if (defined __ARM7EM__) // Needed for old versions that do not know the define yet S #if (__CORE__ == __ARM7EM__) // Cortex-M4/M7 S #define _CORE_HAS_RTT_ASM_SUPPORT 1 S #define _CORE_NEEDS_DMB 1 S #define RTT__DMB() asm VOLATILE ("DMB"); S #endif S #endif S #if (defined __ARM8M_BASELINE__) // Needed for old versions that do not know the define yet S #if (__CORE__ == __ARM8M_BASELINE__) // Cortex-M23 S #define _CORE_HAS_RTT_ASM_SUPPORT 0 S #define _CORE_NEEDS_DMB 1 S #define RTT__DMB() asm VOLATILE ("DMB"); S #endif S #endif S #if (defined __ARM8M_MAINLINE__) // Needed for old versions that do not know the define yet S #if (__CORE__ == __ARM8M_MAINLINE__) // Cortex-M33 S #define _CORE_HAS_RTT_ASM_SUPPORT 1 S #define _CORE_NEEDS_DMB 1 S #define RTT__DMB() asm VOLATILE ("DMB"); S #endif S #endif N #else N // N // GCC / Clang N // N #if (defined __ARM_ARCH_7M__) // Cortex-M3 X #if (0L) S #define _CORE_HAS_RTT_ASM_SUPPORT 1 S #elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7 X #elif (0L) S #define _CORE_HAS_RTT_ASM_SUPPORT 1 S #define _CORE_NEEDS_DMB 1 S #define RTT__DMB() __asm volatile ("dmb\n" : : :); S #elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23 X #elif (0L) S #define _CORE_HAS_RTT_ASM_SUPPORT 0 S #define _CORE_NEEDS_DMB 1 S #define RTT__DMB() __asm volatile ("dmb\n" : : :); S #elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33 X #elif (0L) S #define _CORE_HAS_RTT_ASM_SUPPORT 1 S #define _CORE_NEEDS_DMB 1 S #define RTT__DMB() __asm volatile ("dmb\n" : : :); N #else N #define _CORE_HAS_RTT_ASM_SUPPORT 0 N #endif N #endif N // N // If IDE and core support the ASM version, enable ASM version by default N // N #ifndef _CORE_HAS_RTT_ASM_SUPPORT S #define _CORE_HAS_RTT_ASM_SUPPORT 0 // Default for unknown cores N #endif N #if (_CC_HAS_RTT_ASM_SUPPORT && _CORE_HAS_RTT_ASM_SUPPORT) X #if (0 && 0) S #define RTT_USE_ASM (1) N #else N #define RTT_USE_ASM (0) N #endif N#endif N N// N// We need to know if a DMB is needed to make sure that on Cortex-M7 etc. N// the order of accesses to the ring buffers is guaranteed N// Needed for: Cortex-M7, Cortex-M23, Cortex-M33 N// N#ifndef _CORE_NEEDS_DMB N #define _CORE_NEEDS_DMB 0 N#endif N N#ifndef RTT__DMB N #if _CORE_NEEDS_DMB X #if 0 S #error "Don't know how to place inline assembly for DMB" N #else N #define RTT__DMB() N #endif N#endif N N#ifndef SEGGER_RTT_CPU_CACHE_LINE_SIZE N #define SEGGER_RTT_CPU_CACHE_LINE_SIZE (0) // On most target systems where RTT is used, we do not have a CPU cache, therefore 0 is a good default here N#endif N N#ifndef SEGGER_RTT_UNCACHED_OFF N #if SEGGER_RTT_CPU_CACHE_LINE_SIZE X #if (0) S #error "SEGGER_RTT_UNCACHED_OFF must be defined when setting SEGGER_RTT_CPU_CACHE_LINE_SIZE != 0" N #else N #define SEGGER_RTT_UNCACHED_OFF (0) N #endif N#endif N#if RTT_USE_ASM X#if (0) S #if SEGGER_RTT_CPU_CACHE_LINE_SIZE S #error "RTT_USE_ASM is not available if SEGGER_RTT_CPU_CACHE_LINE_SIZE != 0" S #endif N#endif N N#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file N#include L 1 "d:\Keil\ARM\ARM_Compiler_5.06u7\Bin\..\include\stdlib.h" 1 N/* stdlib.h: ANSI draft (X3J11 May 88) library header, section 4.10 */ N/* Copyright (C) Codemist Ltd., 1988-1993. */ N/* Copyright 1991-1998,2014 ARM Limited. All rights reserved. */ N/* N * RCS $Revision$ N * Checkin $Date$ N * Revising $Author: agrant $ N */ N N/* N * stdlib.h declares four types, several general purpose functions, N * and defines several macros. N */ N N#ifndef __stdlib_h N#define __stdlib_h N#define __ARMCLIB_VERSION 5060044 N N#if defined(__clang__) || (defined(__ARMCC_VERSION) && !defined(__STRICT_ANSI__)) X#if 0L || (1L && !0L) N /* armclang and non-strict armcc allow 'long long' in system headers */ N #define __LONGLONG long long N#else S /* strict armcc has '__int64' */ S #define __LONGLONG __int64 N#endif N N#define _ARMABI __declspec(__nothrow) N#define _ARMABI_PURE __declspec(__nothrow) __attribute__((const)) N#define _ARMABI_NORETURN __declspec(__nothrow) __declspec(__noreturn) N#define _ARMABI_THROW N N #ifndef __STDLIB_DECLS N #define __STDLIB_DECLS N N /* N * Some of these declarations are new in C99. To access them in C++ N * you can use -D__USE_C99_STDLIB (or -D__USE_C99ALL). N */ N #ifndef __USE_C99_STDLIB N #if defined(__USE_C99_ALL) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__) || (defined(__cplusplus) && 201103L <= __cplusplus) X #if 0L || (1L && 199901L <= 199409L) || (0L && 201103L <= __cplusplus) S #define __USE_C99_STDLIB 1 N #endif N #endif N N #undef __CLIBNS N N #ifdef __cplusplus S namespace std { S #define __CLIBNS ::std:: S extern "C" { N #else N #define __CLIBNS N #endif /* __cplusplus */ N N#if defined(__cplusplus) || !defined(__STRICT_ANSI__) X#if 0L || !0L N /* unconditional in C++ and non-strict C for consistency of debug info */ N #if __sizeof_ptr == 8 X #if 4 == 8 S typedef unsigned long size_t; /* see */ N #else N typedef unsigned int size_t; /* see */ N #endif N#elif !defined(__size_t) S #define __size_t 1 S #if __sizeof_ptr == 8 S typedef unsigned long size_t; /* see */ S #else S typedef unsigned int size_t; /* see */ S #endif N#endif N N#undef NULL N#define NULL 0 /* see */ N N#ifndef __cplusplus /* wchar_t is a builtin type for C++ */ N #if !defined(__STRICT_ANSI__) X #if !0L N /* unconditional in non-strict C for consistency of debug info */ N #if defined(__WCHAR32) || (defined(__ARM_SIZEOF_WCHAR_T) && __ARM_SIZEOF_WCHAR_T == 4) X #if 0L || (0L && __ARM_SIZEOF_WCHAR_T == 4) S typedef unsigned int wchar_t; /* see */ N #else N typedef unsigned short wchar_t; /* see */ N #endif N #elif !defined(__wchar_t) S #define __wchar_t 1 S #if defined(__WCHAR32) || (defined(__ARM_SIZEOF_WCHAR_T) && __ARM_SIZEOF_WCHAR_T == 4) S typedef unsigned int wchar_t; /* see */ S #else S typedef unsigned short wchar_t; /* see */ S #endif N #endif N#endif N Ntypedef struct div_t { int quot, rem; } div_t; N /* type of the value returned by the div function. */ Ntypedef struct ldiv_t { long int quot, rem; } ldiv_t; N /* type of the value returned by the ldiv function. */ N#if !defined(__STRICT_ANSI__) || __USE_C99_STDLIB X#if !0L || __USE_C99_STDLIB Ntypedef struct lldiv_t { __LONGLONG quot, rem; } lldiv_t; Xtypedef struct lldiv_t { long long quot, rem; } lldiv_t; N /* type of the value returned by the lldiv function. */ N#endif N N#ifdef __EXIT_FAILURE S# define EXIT_FAILURE __EXIT_FAILURE S /* S * an integral expression which may be used as an argument to the exit S * function to return unsuccessful termination status to the host S * environment. S */ N#else N# define EXIT_FAILURE 1 /* unixoid */ N#endif N#define EXIT_SUCCESS 0 N /* N * an integral expression which may be used as an argument to the exit N * function to return successful termination status to the host N * environment. N */ N N /* N * Defining __USE_ANSI_EXAMPLE_RAND at compile time switches to N * the example implementation of rand() and srand() provided in N * the ANSI C standard. This implementation is very poor, but is N * provided for completeness. N */ N#ifdef __USE_ANSI_EXAMPLE_RAND S#define srand _ANSI_srand S#define rand _ANSI_rand S#define RAND_MAX 0x7fff N#else N#define RAND_MAX 0x7fffffff N#endif N /* N * RAND_MAX: an integral constant expression, the value of which N * is the maximum value returned by the rand function. N */ Nextern _ARMABI int __aeabi_MB_CUR_MAX(void); Xextern __declspec(__nothrow) int __aeabi_MB_CUR_MAX(void); N#define MB_CUR_MAX ( __aeabi_MB_CUR_MAX() ) N /* N * a positive integer expression whose value is the maximum number of bytes N * in a multibyte character for the extended character set specified by the N * current locale (category LC_CTYPE), and whose value is never greater N * than MB_LEN_MAX. N */ N N /* N * If the compiler supports signalling nans as per N965 then it N * will define __SUPPORT_SNAN__, in which case a user may define N * _WANT_SNAN in order to obtain a compliant version of the strtod N * family of functions. N */ N#if defined(__SUPPORT_SNAN__) && defined(_WANT_SNAN) X#if 0L && 0L S#pragma import(__use_snan) N#endif N Nextern _ARMABI double atof(const char * /*nptr*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) double atof(const char * ) __attribute__((__nonnull__(1))); N /* N * converts the initial part of the string pointed to by nptr to double N * representation. N * Returns: the converted value. N */ Nextern _ARMABI int atoi(const char * /*nptr*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int atoi(const char * ) __attribute__((__nonnull__(1))); N /* N * converts the initial part of the string pointed to by nptr to int N * representation. N * Returns: the converted value. N */ Nextern _ARMABI long int atol(const char * /*nptr*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) long int atol(const char * ) __attribute__((__nonnull__(1))); N /* N * converts the initial part of the string pointed to by nptr to long int N * representation. N * Returns: the converted value. N */ N#if !defined(__STRICT_ANSI__) || __USE_C99_STDLIB X#if !0L || __USE_C99_STDLIB Nextern _ARMABI __LONGLONG atoll(const char * /*nptr*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) long long atoll(const char * ) __attribute__((__nonnull__(1))); N /* N * converts the initial part of the string pointed to by nptr to N * long long int representation. N * Returns: the converted value. N */ N#endif N Nextern _ARMABI double strtod(const char * __restrict /*nptr*/, char ** __restrict /*endptr*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) double strtod(const char * __restrict , char ** __restrict ) __attribute__((__nonnull__(1))); N /* N * converts the initial part of the string pointed to by nptr to double N * representation. First it decomposes the input string into three parts: N * an initial, possibly empty, sequence of white-space characters (as N * specified by the isspace function), a subject sequence resembling a N * floating point constant; and a final string of one or more unrecognised N * characters, including the terminating null character of the input string. N * Then it attempts to convert the subject sequence to a floating point N * number, and returns the result. A pointer to the final string is stored N * in the object pointed to by endptr, provided that endptr is not a null N * pointer. N * Returns: the converted value if any. If no conversion could be performed, N * zero is returned. If the correct value is outside the range of N * representable values, plus or minus HUGE_VAL is returned N * (according to the sign of the value), and the value of the macro N * ERANGE is stored in errno. If the correct value would cause N * underflow, zero is returned and the value of the macro ERANGE is N * stored in errno. N */ N#if !defined(__STRICT_ANSI__) || __USE_C99_STDLIB X#if !0L || __USE_C99_STDLIB Nextern _ARMABI float strtof(const char * __restrict /*nptr*/, char ** __restrict /*endptr*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) float strtof(const char * __restrict , char ** __restrict ) __attribute__((__nonnull__(1))); Nextern _ARMABI long double strtold(const char * __restrict /*nptr*/, char ** __restrict /*endptr*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) long double strtold(const char * __restrict , char ** __restrict ) __attribute__((__nonnull__(1))); N /* N * same as strtod, but return float and long double respectively. N */ N#endif Nextern _ARMABI long int strtol(const char * __restrict /*nptr*/, Xextern __declspec(__nothrow) long int strtol(const char * __restrict , N char ** __restrict /*endptr*/, int /*base*/) __attribute__((__nonnull__(1))); N /* N * converts the initial part of the string pointed to by nptr to long int N * representation. First it decomposes the input string into three parts: N * an initial, possibly empty, sequence of white-space characters (as N * specified by the isspace function), a subject sequence resembling an N * integer represented in some radix determined by the value of base, and a N * final string of one or more unrecognised characters, including the N * terminating null character of the input string. Then it attempts to N * convert the subject sequence to an integer, and returns the result. N * If the value of base is 0, the expected form of the subject sequence is N * that of an integer constant (described in ANSI Draft, section 3.1.3.2), N * optionally preceded by a '+' or '-' sign, but not including an integer N * suffix. If the value of base is between 2 and 36, the expected form of N * the subject sequence is a sequence of letters and digits representing an N * integer with the radix specified by base, optionally preceded by a plus N * or minus sign, but not including an integer suffix. The letters from a N * (or A) through z (or Z) are ascribed the values 10 to 35; only letters N * whose ascribed values are less than that of the base are permitted. If N * the value of base is 16, the characters 0x or 0X may optionally precede N * the sequence of letters and digits following the sign if present. N * A pointer to the final string is stored in the object N * pointed to by endptr, provided that endptr is not a null pointer. N * Returns: the converted value if any. If no conversion could be performed, N * zero is returned and nptr is stored in *endptr. N * If the correct value is outside the range of N * representable values, LONG_MAX or LONG_MIN is returned N * (according to the sign of the value), and the value of the N * macro ERANGE is stored in errno. N */ Nextern _ARMABI unsigned long int strtoul(const char * __restrict /*nptr*/, Xextern __declspec(__nothrow) unsigned long int strtoul(const char * __restrict , N char ** __restrict /*endptr*/, int /*base*/) __attribute__((__nonnull__(1))); N /* N * converts the initial part of the string pointed to by nptr to unsigned N * long int representation. First it decomposes the input string into three N * parts: an initial, possibly empty, sequence of white-space characters (as N * determined by the isspace function), a subject sequence resembling an N * unsigned integer represented in some radix determined by the value of N * base, and a final string of one or more unrecognised characters, N * including the terminating null character of the input string. Then it N * attempts to convert the subject sequence to an unsigned integer, and N * returns the result. If the value of base is zero, the expected form of N * the subject sequence is that of an integer constant (described in ANSI N * Draft, section 3.1.3.2), optionally preceded by a '+' or '-' sign, but N * not including an integer suffix. If the value of base is between 2 and N * 36, the expected form of the subject sequence is a sequence of letters N * and digits representing an integer with the radix specified by base, N * optionally preceded by a '+' or '-' sign, but not including an integer N * suffix. The letters from a (or A) through z (or Z) stand for the values N * 10 to 35; only letters whose ascribed values are less than that of the N * base are permitted. If the value of base is 16, the characters 0x or 0X N * may optionally precede the sequence of letters and digits following the N * sign, if present. A pointer to the final string is stored in the object N * pointed to by endptr, provided that endptr is not a null pointer. N * Returns: the converted value if any. If no conversion could be performed, N * zero is returned and nptr is stored in *endptr. N * If the correct value is outside the range of N * representable values, ULONG_MAX is returned, and the value of N * the macro ERANGE is stored in errno. N */ N N/* C90 reserves all names beginning with 'str' */ Nextern _ARMABI __LONGLONG strtoll(const char * __restrict /*nptr*/, Xextern __declspec(__nothrow) long long strtoll(const char * __restrict , N char ** __restrict /*endptr*/, int /*base*/) N __attribute__((__nonnull__(1))); N /* N * as strtol but returns a long long int value. If the correct value is N * outside the range of representable values, LLONG_MAX or LLONG_MIN is N * returned (according to the sign of the value), and the value of the N * macro ERANGE is stored in errno. N */ Nextern _ARMABI unsigned __LONGLONG strtoull(const char * __restrict /*nptr*/, Xextern __declspec(__nothrow) unsigned long long strtoull(const char * __restrict , N char ** __restrict /*endptr*/, int /*base*/) N __attribute__((__nonnull__(1))); N /* N * as strtoul but returns an unsigned long long int value. If the correct N * value is outside the range of representable values, ULLONG_MAX is returned, N * and the value of the macro ERANGE is stored in errno. N */ N Nextern _ARMABI int rand(void); Xextern __declspec(__nothrow) int rand(void); N /* N * Computes a sequence of pseudo-random integers in the range 0 to RAND_MAX. N * Uses an additive generator (Mitchell & Moore) of the form: N * Xn = (X[n-24] + X[n-55]) MOD 2^31 N * This is described in section 3.2.2 of Knuth, vol 2. It's period is N * in excess of 2^55 and its randomness properties, though unproven, are N * conjectured to be good. Empirical testing since 1958 has shown no flaws. N * Returns: a pseudo-random integer. N */ Nextern _ARMABI void srand(unsigned int /*seed*/); Xextern __declspec(__nothrow) void srand(unsigned int ); N /* N * uses its argument as a seed for a new sequence of pseudo-random numbers N * to be returned by subsequent calls to rand. If srand is then called with N * the same seed value, the sequence of pseudo-random numbers is repeated. N * If rand is called before any calls to srand have been made, the same N * sequence is generated as when srand is first called with a seed value N * of 1. N */ N Nstruct _rand_state { int __x[57]; }; Nextern _ARMABI int _rand_r(struct _rand_state *); Xextern __declspec(__nothrow) int _rand_r(struct _rand_state *); Nextern _ARMABI void _srand_r(struct _rand_state *, unsigned int); Xextern __declspec(__nothrow) void _srand_r(struct _rand_state *, unsigned int); Nstruct _ANSI_rand_state { int __x[1]; }; Nextern _ARMABI int _ANSI_rand_r(struct _ANSI_rand_state *); Xextern __declspec(__nothrow) int _ANSI_rand_r(struct _ANSI_rand_state *); Nextern _ARMABI void _ANSI_srand_r(struct _ANSI_rand_state *, unsigned int); Xextern __declspec(__nothrow) void _ANSI_srand_r(struct _ANSI_rand_state *, unsigned int); N /* N * Re-entrant variants of both flavours of rand, which operate on N * an explicitly supplied state buffer. N */ N Nextern _ARMABI void *calloc(size_t /*nmemb*/, size_t /*size*/); Xextern __declspec(__nothrow) void *calloc(size_t , size_t ); N /* N * allocates space for an array of nmemb objects, each of whose size is N * 'size'. The space is initialised to all bits zero. N * Returns: either a null pointer or a pointer to the allocated space. N */ Nextern _ARMABI void free(void * /*ptr*/); Xextern __declspec(__nothrow) void free(void * ); N /* N * causes the space pointed to by ptr to be deallocated (i.e., made N * available for further allocation). If ptr is a null pointer, no action N * occurs. Otherwise, if ptr does not match a pointer earlier returned by N * calloc, malloc or realloc or if the space has been deallocated by a call N * to free or realloc, the behaviour is undefined. N */ Nextern _ARMABI void *malloc(size_t /*size*/); Xextern __declspec(__nothrow) void *malloc(size_t ); N /* N * allocates space for an object whose size is specified by 'size' and whose N * value is indeterminate. N * Returns: either a null pointer or a pointer to the allocated space. N */ Nextern _ARMABI void *realloc(void * /*ptr*/, size_t /*size*/); Xextern __declspec(__nothrow) void *realloc(void * , size_t ); N /* N * changes the size of the object pointed to by ptr to the size specified by N * size. The contents of the object shall be unchanged up to the lesser of N * the new and old sizes. If the new size is larger, the value of the newly N * allocated portion of the object is indeterminate. If ptr is a null N * pointer, the realloc function behaves like a call to malloc for the N * specified size. Otherwise, if ptr does not match a pointer earlier N * returned by calloc, malloc or realloc, or if the space has been N * deallocated by a call to free or realloc, the behaviour is undefined. N * If the space cannot be allocated, the object pointed to by ptr is N * unchanged. If size is zero and ptr is not a null pointer, the object it N * points to is freed. N * Returns: either a null pointer or a pointer to the possibly moved N * allocated space. N */ N#if !defined(__STRICT_ANSI__) X#if !0L Nextern _ARMABI int posix_memalign(void ** /*ret*/, size_t /*alignment*/, size_t /*size*/); Xextern __declspec(__nothrow) int posix_memalign(void ** , size_t , size_t ); N /* N * allocates space for an object of size 'size', aligned to a N * multiple of 'alignment' (which must be a power of two and at N * least 4). N * N * On success, a pointer to the allocated object is stored in N * *ret, and zero is returned. On failure, the return value is N * either ENOMEM (allocation failed because no suitable piece of N * memory was available) or EINVAL (the 'alignment' parameter was N * invalid). N */ N#endif Ntypedef int (*__heapprt)(void *, char const *, ...); Nextern _ARMABI void __heapstats(int (* /*dprint*/)(void * /*param*/, Xextern __declspec(__nothrow) void __heapstats(int (* )(void * , N char const * /*format*/, ...), N void * /*param*/) __attribute__((__nonnull__(1))); N /* N * reports current heap statistics (eg. number of free blocks in N * the free-list). Output is as implementation-defined free-form N * text, provided via the dprint function. `param' gives an N * extra data word to pass to dprint. You can call N * __heapstats(fprintf,stdout) by casting fprintf to the above N * function type; the typedef `__heapprt' is provided for this N * purpose. N * N * `dprint' will not be called while the heap is being examined, N * so it can allocate memory itself without trouble. N */ Nextern _ARMABI int __heapvalid(int (* /*dprint*/)(void * /*param*/, Xextern __declspec(__nothrow) int __heapvalid(int (* )(void * , N char const * /*format*/, ...), N void * /*param*/, int /*verbose*/) __attribute__((__nonnull__(1))); N /* N * performs a consistency check on the heap. Errors are reported N * through dprint, like __heapstats. If `verbose' is nonzero, N * full diagnostic information on the heap state is printed out. N * N * This routine probably won't work if the heap isn't a N * contiguous chunk (for example, if __user_heap_extend has been N * overridden). N * N * `dprint' may be called while the heap is being examined or N * even in an invalid state, so it must perform no memory N * allocation. In particular, if `dprint' calls (or is) a stdio N * function, the stream it outputs to must already have either N * been written to or been setvbuf'ed, or else the system will N * allocate buffer space for it on the first call to dprint. N */ Nextern _ARMABI_NORETURN void abort(void); Xextern __declspec(__nothrow) __declspec(__noreturn) void abort(void); N /* N * causes abnormal program termination to occur, unless the signal SIGABRT N * is being caught and the signal handler does not return. Whether open N * output streams are flushed or open streams are closed or temporary N * files removed is implementation-defined. N * An implementation-defined form of the status 'unsuccessful termination' N * is returned to the host environment by means of a call to N * raise(SIGABRT). N */ N Nextern _ARMABI int atexit(void (* /*func*/)(void)) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) int atexit(void (* )(void)) __attribute__((__nonnull__(1))); N /* N * registers the function pointed to by func, to be called without its N * arguments at normal program termination. It is possible to register at N * least 32 functions. N * Returns: zero if the registration succeeds, nonzero if it fails. N */ N#if defined(__EDG__) && !defined(__GNUC__) X#if 1L && !0L N#define __LANGUAGE_LINKAGE_CHANGES_FUNCTION_TYPE N#endif N#if defined(__cplusplus) && defined(__LANGUAGE_LINKAGE_CHANGES_FUNCTION_TYPE) X#if 0L && 1L S /* atexit that takes a ptr to a function with C++ linkage S * but not in GNU mode S */ S typedef void (* __C_exitfuncptr)(); S extern "C++" S inline int atexit(void (* __func)()) { S return atexit((__C_exitfuncptr)__func); S } N#endif N N Nextern _ARMABI_NORETURN void exit(int /*status*/); Xextern __declspec(__nothrow) __declspec(__noreturn) void exit(int ); N /* N * causes normal program termination to occur. If more than one call to the N * exit function is executed by a program, the behaviour is undefined. N * First, all functions registered by the atexit function are called, in the N * reverse order of their registration. N * Next, all open output streams are flushed, all open streams are closed, N * and all files created by the tmpfile function are removed. N * Finally, control is returned to the host environment. If the value of N * status is zero or EXIT_SUCCESS, an implementation-defined form of the N * status 'successful termination' is returned. If the value of status is N * EXIT_FAILURE, an implementation-defined form of the status N * 'unsuccessful termination' is returned. Otherwise the status returned N * is implementation-defined. N */ N Nextern _ARMABI_NORETURN void _Exit(int /*status*/); Xextern __declspec(__nothrow) __declspec(__noreturn) void _Exit(int ); N /* N * causes normal program termination to occur. No functions registered N * by the atexit function are called. N * In this implementation, all open output streams are flushed, all N * open streams are closed, and all files created by the tmpfile function N * are removed. N * Control is returned to the host environment. The status returned to N * the host environment is determined in the same way as for 'exit'. N */ N Nextern _ARMABI char *getenv(const char * /*name*/) __attribute__((__nonnull__(1))); Xextern __declspec(__nothrow) char *getenv(const char * ) __attribute__((__nonnull__(1))); N /* N * searches the environment list, provided by the host environment, for a N * string that matches the string pointed to by name. The set of environment N * names and the method for altering the environment list are N * implementation-defined. N * Returns: a pointer to a string associated with the matched list member. N * The array pointed to shall not be modified by the program, but N * may be overwritten by a subsequent call to the getenv function. N * If the specified name cannot be found, a null pointer is N * returned. N */ N Nextern _ARMABI int system(const char * /*string*/); Xextern __declspec(__nothrow) int system(const char * ); N /* N * passes the string pointed to by string to the host environment to be N * executed by a command processor in an implementation-defined manner. N * A null pointer may be used for string, to inquire whether a command N * processor exists. N * N * Returns: If the argument is a null pointer, the system function returns N * non-zero only if a command processor is available. If the N * argument is not a null pointer, the system function returns an N * implementation-defined value. N */ N Nextern _ARMABI_THROW void *bsearch(const void * /*key*/, const void * /*base*/, Xextern void *bsearch(const void * , const void * , N size_t /*nmemb*/, size_t /*size*/, N int (* /*compar*/)(const void *, const void *)) __attribute__((__nonnull__(1,2,5))); N /* N * searches an array of nmemb objects, the initial member of which is N * pointed to by base, for a member that matches the object pointed to by N * key. The size of each member of the array is specified by size. N * The contents of the array shall be in ascending sorted order according to N * a comparison function pointed to by compar, which is called with two N * arguments that point to the key object and to an array member, in that N * order. The function shall return an integer less than, equal to, or N * greater than zero if the key object is considered, respectively, to be N * less than, to match, or to be greater than the array member. N * Returns: a pointer to a matching member of the array, or a null pointer N * if no match is found. If two members compare as equal, which N * member is matched is unspecified. N */ N#if defined(__cplusplus) && defined(__LANGUAGE_LINKAGE_CHANGES_FUNCTION_TYPE) X#if 0L && 1L S /* bsearch that takes a ptr to a function with C++ linkage S * but not in GNU mode S */ S typedef int (* __C_compareprocptr)(const void *, const void *); S extern "C++" S void *bsearch(const void * __key, const void * __base, S size_t __nmemb, size_t __size, S int (* __compar)(const void *, const void *)) __attribute__((__nonnull__(1,2,5))); S extern "C++" S inline void *bsearch(const void * __key, const void * __base, S size_t __nmemb, size_t __size, S int (* __compar)(const void *, const void *)) { S return bsearch(__key, __base, __nmemb, __size, (__C_compareprocptr)__compar); S } N#endif N N Nextern _ARMABI_THROW void qsort(void * /*base*/, size_t /*nmemb*/, size_t /*size*/, Xextern void qsort(void * , size_t , size_t , N int (* /*compar*/)(const void *, const void *)) __attribute__((__nonnull__(1,4))); N /* N * sorts an array of nmemb objects, the initial member of which is pointed N * to by base. The size of each object is specified by size. N * The contents of the array shall be in ascending order according to a N * comparison function pointed to by compar, which is called with two N * arguments that point to the objects being compared. The function shall N * return an integer less than, equal to, or greater than zero if the first N * argument is considered to be respectively less than, equal to, or greater N * than the second. If two members compare as equal, their order in the N * sorted array is unspecified. N */ N N#if defined(__cplusplus) && defined(__LANGUAGE_LINKAGE_CHANGES_FUNCTION_TYPE) X#if 0L && 1L S /* qsort that takes a ptr to a function with C++ linkage S * but not in GNU mode S */ S extern "C++" S void qsort(void * __base, size_t __nmemb, size_t __size, S int (* __compar)(const void *, const void *)) __attribute__((__nonnull__(1,4))); S extern "C++" S inline void qsort(void * __base, size_t __nmemb, size_t __size, S int (* __compar)(const void *, const void *)) { S qsort(__base, __nmemb, __size, (__C_compareprocptr)__compar); S } N#endif N Nextern _ARMABI_PURE int abs(int /*j*/); Xextern __declspec(__nothrow) __attribute__((const)) int abs(int ); N /* N * computes the absolute value of an integer j. If the result cannot be N * represented, the behaviour is undefined. N * Returns: the absolute value. N */ N Nextern _ARMABI_PURE div_t div(int /*numer*/, int /*denom*/); Xextern __declspec(__nothrow) __attribute__((const)) div_t div(int , int ); N /* N * computes the quotient and remainder of the division of the numerator N * numer by the denominator denom. If the division is inexact, the resulting N * quotient is the integer of lesser magnitude that is the nearest to the N * algebraic quotient. If the result cannot be represented, the behaviour is N * undefined; otherwise, quot * denom + rem shall equal numer. N * Returns: a structure of type div_t, comprising both the quotient and the N * remainder. the structure shall contain the following members, N * in either order. N * int quot; int rem; N */ Nextern _ARMABI_PURE long int labs(long int /*j*/); Xextern __declspec(__nothrow) __attribute__((const)) long int labs(long int ); N /* N * computes the absolute value of an long integer j. If the result cannot be N * represented, the behaviour is undefined. N * Returns: the absolute value. N */ N#ifdef __cplusplus S extern "C++" inline _ARMABI_PURE long abs(long int x) { return labs(x); } N#endif N Nextern _ARMABI_PURE ldiv_t ldiv(long int /*numer*/, long int /*denom*/); Xextern __declspec(__nothrow) __attribute__((const)) ldiv_t ldiv(long int , long int ); N /* N * computes the quotient and remainder of the division of the numerator N * numer by the denominator denom. If the division is inexact, the sign of N * the resulting quotient is that of the algebraic quotient, and the N * magnitude of the resulting quotient is the largest integer less than the N * magnitude of the algebraic quotient. If the result cannot be represented, N * the behaviour is undefined; otherwise, quot * denom + rem shall equal N * numer. N * Returns: a structure of type ldiv_t, comprising both the quotient and the N * remainder. the structure shall contain the following members, N * in either order. N * long int quot; long int rem; N */ N#ifdef __cplusplus S extern "C++" inline _ARMABI_PURE ldiv_t div(long int __numer, long int __denom) { S return ldiv(__numer, __denom); S } N#endif N N#if !defined(__STRICT_ANSI__) || __USE_C99_STDLIB X#if !0L || __USE_C99_STDLIB Nextern _ARMABI_PURE __LONGLONG llabs(__LONGLONG /*j*/); Xextern __declspec(__nothrow) __attribute__((const)) long long llabs(long long ); N /* N * computes the absolute value of a long long integer j. If the N * result cannot be represented, the behaviour is undefined. N * Returns: the absolute value. N */ N#ifdef __cplusplus S extern "C++" inline _ARMABI_PURE __LONGLONG abs(__LONGLONG x) { return llabs(x); } N#endif N Nextern _ARMABI_PURE lldiv_t lldiv(__LONGLONG /*numer*/, __LONGLONG /*denom*/); Xextern __declspec(__nothrow) __attribute__((const)) lldiv_t lldiv(long long , long long ); N /* N * computes the quotient and remainder of the division of the numerator N * numer by the denominator denom. If the division is inexact, the sign of N * the resulting quotient is that of the algebraic quotient, and the N * magnitude of the resulting quotient is the largest integer less than the N * magnitude of the algebraic quotient. If the result cannot be represented, N * the behaviour is undefined; otherwise, quot * denom + rem shall equal N * numer. N * Returns: a structure of type lldiv_t, comprising both the quotient and the N * remainder. the structure shall contain the following members, N * in either order. N * long long quot; long long rem; N */ N#ifdef __cplusplus S extern "C++" inline _ARMABI_PURE lldiv_t div(__LONGLONG __numer, __LONGLONG __denom) { S return lldiv(__numer, __denom); S } N#endif N#endif N N#if !(__ARM_NO_DEPRECATED_FUNCTIONS) N/* N * ARM real-time divide functions for guaranteed performance N */ Ntypedef struct __sdiv32by16 { int quot, rem; } __sdiv32by16; Ntypedef struct __udiv32by16 { unsigned int quot, rem; } __udiv32by16; N /* used int so that values return in separate regs, although 16-bit */ Ntypedef struct __sdiv64by32 { int rem, quot; } __sdiv64by32; N N__value_in_regs extern _ARMABI_PURE __sdiv32by16 __rt_sdiv32by16( X__value_in_regs extern __declspec(__nothrow) __attribute__((const)) __sdiv32by16 __rt_sdiv32by16( N int /*numer*/, N short int /*denom*/); N /* N * Signed divide: (16-bit quot), (16-bit rem) = (32-bit) / (16-bit) N */ N__value_in_regs extern _ARMABI_PURE __udiv32by16 __rt_udiv32by16( X__value_in_regs extern __declspec(__nothrow) __attribute__((const)) __udiv32by16 __rt_udiv32by16( N unsigned int /*numer*/, N unsigned short /*denom*/); N /* N * Unsigned divide: (16-bit quot), (16-bit rem) = (32-bit) / (16-bit) N */ N__value_in_regs extern _ARMABI_PURE __sdiv64by32 __rt_sdiv64by32( X__value_in_regs extern __declspec(__nothrow) __attribute__((const)) __sdiv64by32 __rt_sdiv64by32( N int /*numer_h*/, unsigned int /*numer_l*/, N int /*denom*/); N /* N * Signed divide: (32-bit quot), (32-bit rem) = (64-bit) / (32-bit) N */ N#endif N N/* N * ARM floating-point mask/status function (for both hardfp and softfp) N */ Nextern _ARMABI unsigned int __fp_status(unsigned int /*mask*/, unsigned int /*flags*/); Xextern __declspec(__nothrow) unsigned int __fp_status(unsigned int , unsigned int ); N /* N * mask and flags are bit-fields which correspond directly to the N * floating point status register in the FPE/FPA and fplib. N * __fp_status returns the current value of the status register, N * and also sets the writable bits of the word N * (the exception control and flag bytes) to: N * N * new = (old & ~mask) ^ flags; N */ N#define __fpsr_IXE 0x100000 N#define __fpsr_UFE 0x80000 N#define __fpsr_OFE 0x40000 N#define __fpsr_DZE 0x20000 N#define __fpsr_IOE 0x10000 N N#define __fpsr_IXC 0x10 N#define __fpsr_UFC 0x8 N#define __fpsr_OFC 0x4 N#define __fpsr_DZC 0x2 N#define __fpsr_IOC 0x1 N N/* N * Multibyte Character Functions. N * The behaviour of the multibyte character functions is affected by the N * LC_CTYPE category of the current locale. For a state-dependent encoding, N * each function is placed into its initial state by a call for which its N * character pointer argument, s, is a null pointer. Subsequent calls with s N * as other than a null pointer cause the internal state of the function to be N * altered as necessary. A call with s as a null pointer causes these functions N * to return a nonzero value if encodings have state dependency, and a zero N * otherwise. After the LC_CTYPE category is changed, the shift state of these N * functions is indeterminate. N */ Nextern _ARMABI int mblen(const char * /*s*/, size_t /*n*/); Xextern __declspec(__nothrow) int mblen(const char * , size_t ); N /* N * If s is not a null pointer, the mblen function determines the number of N * bytes compromising the multibyte character pointed to by s. Except that N * the shift state of the mbtowc function is not affected, it is equivalent N * to mbtowc((wchar_t *)0, s, n); N * Returns: If s is a null pointer, the mblen function returns a nonzero or N * zero value, if multibyte character encodings, respectively, do N * or do not have state-dependent encodings. If s is not a null N * pointer, the mblen function either returns a 0 (if s points to a N * null character), or returns the number of bytes that compromise N * the multibyte character (if the next n of fewer bytes form a N * valid multibyte character), or returns -1 (they do not form a N * valid multibyte character). N */ Nextern _ARMABI int mbtowc(wchar_t * __restrict /*pwc*/, Xextern __declspec(__nothrow) int mbtowc(wchar_t * __restrict , N const char * __restrict /*s*/, size_t /*n*/); N /* N * If s is not a null pointer, the mbtowc function determines the number of N * bytes that compromise the multibyte character pointed to by s. It then N * determines the code for value of type wchar_t that corresponds to that N * multibyte character. (The value of the code corresponding to the null N * character is zero). If the multibyte character is valid and pwc is not a N * null pointer, the mbtowc function stores the code in the object pointed N * to by pwc. At most n bytes of the array pointed to by s will be examined. N * Returns: If s is a null pointer, the mbtowc function returns a nonzero or N * zero value, if multibyte character encodings, respectively, do N * or do not have state-dependent encodings. If s is not a null N * pointer, the mbtowc function either returns a 0 (if s points to N * a null character), or returns the number of bytes that N * compromise the converted multibyte character (if the next n of N * fewer bytes form a valid multibyte character), or returns -1 N * (they do not form a valid multibyte character). N */ Nextern _ARMABI int wctomb(char * /*s*/, wchar_t /*wchar*/); Xextern __declspec(__nothrow) int wctomb(char * , wchar_t ); N /* N * determines the number of bytes need to represent the multibyte character N * corresponding to the code whose value is wchar (including any change in N * shift state). It stores the multibyte character representation in the N * array object pointed to by s (if s is not a null pointer). At most N * MB_CUR_MAX characters are stored. If the value of wchar is zero, the N * wctomb function is left in the initial shift state). N * Returns: If s is a null pointer, the wctomb function returns a nonzero or N * zero value, if multibyte character encodings, respectively, do N * or do not have state-dependent encodings. If s is not a null N * pointer, the wctomb function returns a -1 if the value of wchar N * does not correspond to a valid multibyte character, or returns N * the number of bytes that compromise the multibyte character N * corresponding to the value of wchar. N */ N N/* N * Multibyte String Functions. N * The behaviour of the multibyte string functions is affected by the LC_CTYPE N * category of the current locale. N */ Nextern _ARMABI size_t mbstowcs(wchar_t * __restrict /*pwcs*/, Xextern __declspec(__nothrow) size_t mbstowcs(wchar_t * __restrict , N const char * __restrict /*s*/, size_t /*n*/) __attribute__((__nonnull__(2))); N /* N * converts a sequence of multibyte character that begins in the initial N * shift state from the array pointed to by s into a sequence of N * corresponding codes and stores not more than n codes into the array N * pointed to by pwcs. No multibyte character that follow a null character N * (which is converted into a code with value zero) will be examined or N * converted. Each multibyte character is converted as if by a call to N * mbtowc function, except that the shift state of the mbtowc function is N * not affected. No more than n elements will be modified in the array N * pointed to by pwcs. If copying takes place between objects that overlap, N * the behaviour is undefined. N * Returns: If an invalid multibyte character is encountered, the mbstowcs N * function returns (size_t)-1. Otherwise, the mbstowcs function N * returns the number of array elements modified, not including N * a terminating zero code, if any. N */ Nextern _ARMABI size_t wcstombs(char * __restrict /*s*/, Xextern __declspec(__nothrow) size_t wcstombs(char * __restrict , N const wchar_t * __restrict /*pwcs*/, size_t /*n*/) __attribute__((__nonnull__(2))); N /* N * converts a sequence of codes that correspond to multibyte characters N * from the array pointed to by pwcs into a sequence of multibyte N * characters that begins in the initial shift state and stores these N * multibyte characters into the array pointed to by s, stopping if a N * multibyte character would exceed the limit of n total bytes or if a N * null character is stored. Each code is converted as if by a call to the N * wctomb function, except that the shift state of the wctomb function is N * not affected. No more than n elements will be modified in the array N * pointed to by s. If copying takes place between objects that overlap, N * the behaviour is undefined. N * Returns: If a code is encountered that does not correspond to a valid N * multibyte character, the wcstombs function returns (size_t)-1. N * Otherwise, the wcstombs function returns the number of bytes N * modified, not including a terminating null character, if any. N */ N Nextern _ARMABI void __use_realtime_heap(void); Xextern __declspec(__nothrow) void __use_realtime_heap(void); Nextern _ARMABI void __use_realtime_division(void); Xextern __declspec(__nothrow) void __use_realtime_division(void); Nextern _ARMABI void __use_two_region_memory(void); Xextern __declspec(__nothrow) void __use_two_region_memory(void); Nextern _ARMABI void __use_no_heap(void); Xextern __declspec(__nothrow) void __use_no_heap(void); Nextern _ARMABI void __use_no_heap_region(void); Xextern __declspec(__nothrow) void __use_no_heap_region(void); N Nextern _ARMABI char const *__C_library_version_string(void); Xextern __declspec(__nothrow) char const *__C_library_version_string(void); Nextern _ARMABI int __C_library_version_number(void); Xextern __declspec(__nothrow) int __C_library_version_number(void); N N #ifdef __cplusplus S } /* extern "C" */ S } /* namespace std */ N #endif /* __cplusplus */ N #endif /* __STDLIB_DECLS */ N N #if _AEABI_PORTABILITY_LEVEL != 0 && !defined _AEABI_PORTABLE X #if _AEABI_PORTABILITY_LEVEL != 0 && !0L S #define _AEABI_PORTABLE N #endif N N #ifdef __cplusplus S #ifndef __STDLIB_NO_EXPORTS S #if !defined(__STRICT_ANSI__) || __USE_C99_STDLIB S using ::std::atoll; S using ::std::lldiv_t; S #endif /* !defined(__STRICT_ANSI__) || __USE_C99_STDLIB */ S using ::std::div_t; S using ::std::ldiv_t; S using ::std::atof; S using ::std::atoi; S using ::std::atol; S using ::std::strtod; S#if !defined(__STRICT_ANSI__) || __USE_C99_STDLIB S using ::std::strtof; S using ::std::strtold; S#endif S using ::std::strtol; S using ::std::strtoul; S using ::std::strtoll; S using ::std::strtoull; S using ::std::rand; S using ::std::srand; S using ::std::_rand_state; S using ::std::_rand_r; S using ::std::_srand_r; S using ::std::_ANSI_rand_state; S using ::std::_ANSI_rand_r; S using ::std::_ANSI_srand_r; S using ::std::calloc; S using ::std::free; S using ::std::malloc; S using ::std::realloc; S#if !defined(__STRICT_ANSI__) S using ::std::posix_memalign; S#endif S using ::std::__heapprt; S using ::std::__heapstats; S using ::std::__heapvalid; S using ::std::abort; S using ::std::atexit; S using ::std::exit; S using ::std::_Exit; S using ::std::getenv; S using ::std::system; S using ::std::bsearch; S using ::std::qsort; S using ::std::abs; S using ::std::div; S using ::std::labs; S using ::std::ldiv; S #if !defined(__STRICT_ANSI__) || __USE_C99_STDLIB S using ::std::llabs; S using ::std::lldiv; S #endif /* !defined(__STRICT_ANSI__) || __USE_C99_STDLIB */ S#if !(__ARM_NO_DEPRECATED_FUNCTIONS) S using ::std::__sdiv32by16; S using ::std::__udiv32by16; S using ::std::__sdiv64by32; S using ::std::__rt_sdiv32by16; S using ::std::__rt_udiv32by16; S using ::std::__rt_sdiv64by32; S#endif S using ::std::__fp_status; S using ::std::mblen; S using ::std::mbtowc; S using ::std::wctomb; S using ::std::mbstowcs; S using ::std::wcstombs; S using ::std::__use_realtime_heap; S using ::std::__use_realtime_division; S using ::std::__use_two_region_memory; S using ::std::__use_no_heap; S using ::std::__use_no_heap_region; S using ::std::__C_library_version_string; S using ::std::__C_library_version_number; S using ::std::size_t; S using ::std::__aeabi_MB_CUR_MAX; S #endif /* __STDLIB_NO_EXPORTS */ N #endif /* __cplusplus */ N N#undef __LONGLONG N N#endif /* __stdlib_h */ N N/* end of stdlib.h */ L 195 "..\src\RTT\SEGGER_RTT.h" 2 N#include N N/********************************************************************* N* N* Defines, fixed N* N********************************************************************** N*/ N N// N// Determine how much we must pad the control block to make it a multiple of a cache line in size N// Assuming: U8 = 1B N// U16 = 2B N// U32 = 4B N// U8/U16/U32* = 4B N// N#if SEGGER_RTT_CPU_CACHE_LINE_SIZE // Avoid division by zero in case we do not have any cache X#if (0) S #define SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(NumBytes) (((NumBytes + SEGGER_RTT_CPU_CACHE_LINE_SIZE - 1) / SEGGER_RTT_CPU_CACHE_LINE_SIZE) * SEGGER_RTT_CPU_CACHE_LINE_SIZE) N#else N #define SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(NumBytes) (NumBytes) N#endif N#define SEGGER_RTT__CB_SIZE (16 + 4 + 4 + (SEGGER_RTT_MAX_NUM_UP_BUFFERS * 24) + (SEGGER_RTT_MAX_NUM_DOWN_BUFFERS * 24)) N#define SEGGER_RTT__CB_PADDING (SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(SEGGER_RTT__CB_SIZE) - SEGGER_RTT__CB_SIZE) N N/********************************************************************* N* N* Types N* N********************************************************************** N*/ N N// N// Description for a circular buffer (also called "ring buffer") N// which is used as up-buffer (T->H) N// Ntypedef struct { N const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" N char* pBuffer; // Pointer to start of buffer N unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. N unsigned WrOff; // Position of next item to be written by either target. N volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host. N unsigned Flags; // Contains configuration flags N} SEGGER_RTT_BUFFER_UP; N N// N// Description for a circular buffer (also called "ring buffer") N// which is used as down-buffer (H->T) N// Ntypedef struct { N const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" N char* pBuffer; // Pointer to start of buffer N unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. N volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host. N unsigned RdOff; // Position of next item to be read by target (down-buffer). N unsigned Flags; // Contains configuration flags N} SEGGER_RTT_BUFFER_DOWN; N N// N// RTT control block which describes the number of buffers available N// as well as the configuration for each buffer N// N// Ntypedef struct { N char acID[16]; // Initialized to "SEGGER RTT" N int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2) N int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2) N SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host X SEGGER_RTT_BUFFER_UP aUp[(3)]; N SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target X SEGGER_RTT_BUFFER_DOWN aDown[(3)]; N#if SEGGER_RTT__CB_PADDING X#if (((16 + 4 + 4 + ((3) * 24) + ((3) * 24))) - (16 + 4 + 4 + ((3) * 24) + ((3) * 24))) S unsigned char aDummy[SEGGER_RTT__CB_PADDING]; N#endif N} SEGGER_RTT_CB; N N/********************************************************************* N* N* Global data N* N********************************************************************** N*/ Nextern SEGGER_RTT_CB _SEGGER_RTT; N N/********************************************************************* N* N* RTT API functions N* N********************************************************************** N*/ N#ifdef __cplusplus S extern "C" { N#endif Nint SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); Nint SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); Nint SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); Nint SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); Nint SEGGER_RTT_GetKey (void); Nunsigned SEGGER_RTT_HasData (unsigned BufferIndex); Nint SEGGER_RTT_HasKey (void); Nunsigned SEGGER_RTT_HasDataUp (unsigned BufferIndex); Nvoid SEGGER_RTT_Init (void); Nunsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize); Nunsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize); Nint SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName); Nint SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName); Nint SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags); Nint SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags); Nint SEGGER_RTT_WaitKey (void); Nunsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); Nunsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); Nunsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); Nunsigned SEGGER_RTT_ASM_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); Nunsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s); Nvoid SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); Nunsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c); Nunsigned SEGGER_RTT_PutCharSkip (unsigned BufferIndex, char c); Nunsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c); Nunsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex); Nunsigned SEGGER_RTT_GetBytesInBuffer (unsigned BufferIndex); N// N// Function macro for performance optimization N// N#define SEGGER_RTT_HASDATA(n) (((SEGGER_RTT_BUFFER_DOWN*)((char*)&_SEGGER_RTT.aDown[n] + SEGGER_RTT_UNCACHED_OFF))->WrOff - ((SEGGER_RTT_BUFFER_DOWN*)((char*)&_SEGGER_RTT.aDown[n] + SEGGER_RTT_UNCACHED_OFF))->RdOff) N N#if RTT_USE_ASM X#if (0) S #define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock N#endif N N/********************************************************************* N* N* RTT transfer functions to send RTT data via other channels. N* N********************************************************************** N*/ Nunsigned SEGGER_RTT_ReadUpBuffer (unsigned BufferIndex, void* pBuffer, unsigned BufferSize); Nunsigned SEGGER_RTT_ReadUpBufferNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize); Nunsigned SEGGER_RTT_WriteDownBuffer (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); Nunsigned SEGGER_RTT_WriteDownBufferNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); N N#define SEGGER_RTT_HASDATA_UP(n) (((SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[n] + SEGGER_RTT_UNCACHED_OFF))->WrOff - ((SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[n] + SEGGER_RTT_UNCACHED_OFF))->RdOff) // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly N N/********************************************************************* N* N* RTT "Terminal" API functions N* N********************************************************************** N*/ Nint SEGGER_RTT_SetTerminal (unsigned char TerminalId); Nint SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s); N N/********************************************************************* N* N* RTT printf functions (require SEGGER_RTT_printf.c) N* N********************************************************************** N*/ Nint SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...); Nint SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList); N N#ifdef __cplusplus S } N#endif N N#endif // ifndef(SEGGER_RTT_ASM) N N/********************************************************************* N* N* Defines N* N********************************************************************** N*/ N N// N// Operating modes. Define behavior if buffer is full (not enough space for entire message) N// N#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) // Skip. Do not block, output nothing. (Default) N#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1) // Trim: Do not block, output as much as fits. N#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2) // Block: Wait until there is space in the buffer. N#define SEGGER_RTT_MODE_MASK (3) N N// N// Control sequences, based on ANSI. N// Can be used to control color, and clear the screen N// N#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors N#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left N N#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m" N#define RTT_CTRL_TEXT_RED "\x1B[2;31m" N#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m" N#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m" N#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m" N#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m" N#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m" N#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m" N N#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m" N#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m" N#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m" N#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m" N#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m" N#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m" N#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m" N#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m" N N#define RTT_CTRL_BG_BLACK "\x1B[24;40m" N#define RTT_CTRL_BG_RED "\x1B[24;41m" N#define RTT_CTRL_BG_GREEN "\x1B[24;42m" N#define RTT_CTRL_BG_YELLOW "\x1B[24;43m" N#define RTT_CTRL_BG_BLUE "\x1B[24;44m" N#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m" N#define RTT_CTRL_BG_CYAN "\x1B[24;46m" N#define RTT_CTRL_BG_WHITE "\x1B[24;47m" N N#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m" N#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m" N#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m" N#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m" N#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m" N#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m" N#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m" N#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m" N N N#endif N N/*************************** End of file ****************************/ L 8 "..\src\myprintf\MyPrintf.c" 2 N N N Nstatic int bInitPrint = 0; Nstatic char buffer[256] = {0}; Nint MyPrintf(const char* fmt, ...) N{ N va_list args; N int tmp_size = 0; N if(bInitPrint==0) N { N bInitPrint = 1; N SEGGER_RTT_Init(); N SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL); X SEGGER_RTT_ConfigUpBuffer(0, 0, 0, 0, (2)); N SEGGER_RTT_WriteString(0, "SEGGER Real-Time-Terminal Sample\r\n\r\n"); N SEGGER_RTT_WriteString(0, "###### Testing SEGGER_printf() ######\r\n"); N } N va_start(args,fmt); X __va_start(args, fmt); N tmp_size = vsnprintf(buffer,sizeof(buffer),fmt,args); N SEGGER_RTT_WriteString(0,buffer); N va_end(args); X __va_end(args); N return tmp_size; N}