revert between 56095 -> 55830 in arch
[AROS.git] / compiler / arossupport / kprintf.c
blob8b248747596a7a3bcff214479149c91301994f71
1 /*
2 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Formats a message and makes sure the user will see it.
6 Lang: english
7 */
9 #include <aros/config.h>
10 #include <aros/arossupportbase.h>
11 #include <stdarg.h>
13 #include <aros/system.h>
14 #include <proto/exec.h>
15 #include <proto/arossupport.h>
16 #undef kprintf
17 #undef vkprintf
18 #include <exec/execbase.h>
20 #if defined(__AROSEXEC_SMP__)
21 #include <aros/atomic.h>
22 #include <asm/cpu.h>
23 extern volatile ULONG safedebug;
24 #endif
27 The floating point math code pulls in symbols
28 that cannot be used in the amiga rom
30 #if !defined(__m68k__)
31 #define FULL_SPECIFIERS
32 #endif
34 #if defined(FULL_SPECIFIERS)
35 #include <float.h>
36 #endif
38 /* provide inline versions of clib functions
39 used in FMTPRINTF */
41 /* ctype.h ... */
42 static inline int isdigit(int c)
44 return '0' <= c && c <= '9';
47 static inline unsigned char tolower(unsigned char c)
49 if ((int)c >= (int)'A')
50 c -= 'A'-'a';
51 return c;
54 #define isprint(x) (((x) >= ' ' && (x) <= 128) || (x) >= 160)
56 /* math.h ... */
57 #define isnan(x) 1
58 #define isinf(x) 1
59 #define log10(x) 1
60 #define log10l(x) 1
61 #define pow(x,y) 1
62 #define powl(x,y) 1
64 /* string.h ... */
65 static inline int kprintf_strlen(const char *c)
67 int i = 0;
68 while (*(c++)) i++;
69 return i;
72 /* limits.h ... */
73 #define ULONG_MAX 4294967295UL
75 /* support macros for FMTPRINTF */
76 #define FMTPRINTF_COUT(c) RawPutChar(c)
77 #define FMTPRINTF_STRLEN(str) kprintf_strlen(str)
79 #if defined(FULL_SPECIFIERS)
80 #define FMTPRINTF_DECIMALPOINT __arossupport_char_decimalpoint
81 #endif
83 #include "fmtprintf_pre.c"
85 /*****************************************************************************
87 NAME */
88 #include <proto/arossupport.h>
90 int kprintf (
92 /* SYNOPSIS */
93 const char * fmt,
94 ...)
96 /* FUNCTION
97 Formats fmt with the specified arguments like printf() (and *not*
98 like RawDoFmt()) and uses a secure way to deliver the message to
99 the user; ie. the user *will* see this message no matter what.
101 INPUTS
102 fmt - printf()-style format string
104 RESULT
105 The number of characters output.
107 NOTES
108 This function is not part of a library and may thus be called
109 any time.
111 EXAMPLE
113 BUGS
115 SEE ALSO
117 INTERNALS
119 HISTORY
120 24-12-95 digulla created
122 ******************************************************************************/
124 va_list ap;
125 int result;
127 va_start (ap, fmt);
128 result = vkprintf (fmt, ap);
129 va_end (ap);
131 return result;
132 } /* kprintf */
134 /******************************************************************************/
135 int vkprintf (const char * format, va_list args)
137 #if defined(FULL_SPECIFIERS)
138 const unsigned char *const __arossupport_char_decimalpoint = ".";
139 #endif
140 #if defined(__AROSEXEC_SMP__)
141 if (safedebug & 1)
143 while (bit_test_and_set_long((ULONG*)&safedebug, 1)) { asm volatile("pause"); };
145 #endif
146 #include "fmtprintf.c"
147 #if defined(__AROSEXEC_SMP__)
148 if (safedebug & 1)
150 __AROS_ATOMIC_AND_L(safedebug, ~(1 << 1));
152 #endif
153 return outcount;
154 } /* vkprintf */