xref: /haiku/headers/posix/stdio_post.h (revision 81f5654c124bf46fba0fd251f208e2d88d81e1ce)
1 /*
2 ** Distributed under the terms of the OpenBeOS License.
3 */
4 #ifndef _STDIO_POST_H_
5 #define _STDIO_POST_H_
6 
7 // "Private"/inline functions of our BeOS compatible stdio implementation
8 
9 // ToDo: this is a work in progress to make our stdio
10 //		BeOS' GNU/libio (almost) binary compatible
11 //		We are not yet compatible!
12 //		Currently only function names are compatible
13 
14 #ifndef _STDIO_H_
15 #	error "This file must be included from stdio.h!"
16 #endif
17 
18 extern char _single_threaded;
19 	// this boolean value is true (1) if there is only the main thread
20 	// running - as soon as you spawn the first thread, it's set to
21 	// false (0)
22 
23 #ifdef __cplusplus
24 #	define __INLINE inline
25 #else
26 #	define __INLINE extern __inline
27 #endif
28 
29 
30 __INLINE int
31 feof_unlocked(FILE *stream)
32 {
33 	return _IO_feof_unlocked(stream);
34 }
35 
36 
37 __INLINE int
38 ferror_unlocked(FILE *stream)
39 {
40 	return _IO_ferror_unlocked(stream);
41 }
42 
43 
44 #define getc(stream) \
45 	(_single_threaded ? _IO_getc_unlocked(stream) : _IO_getc(stream))
46 #define putc(c, stream) \
47 	(_single_threaded ? _IO_putc_unlocked(c, stream) : _IO_putc(c, stream))
48 
49 
50 __INLINE int
51 putc_unlocked(int c, FILE *stream)
52 {
53 	return _IO_putc_unlocked(c, stream);
54 }
55 
56 
57 __INLINE int
58 putchar_unlocked(int c)
59 {
60 	return _IO_putc_unlocked(c, stdout);
61 }
62 
63 
64 __INLINE int
65 getc_unlocked(FILE *stream)
66 {
67 	return _IO_getc_unlocked(stream);
68 }
69 
70 
71 __INLINE int
72 getchar_unlocked(void)
73 {
74 	return _IO_getc_unlocked(stdin);
75 }
76 
77 #undef __INLINE
78 
79 #endif	/* _STDIO_POST_H_ */
80