aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-01-28 00:53:52 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-01-28 00:53:52 +0000
commit81cec7bde4ff55a28d3a9e3c71b5d488378eeac4 (patch)
treee87f9cdce87b2c7920a25980e36942cb227f5a02
parent66ddaafef221825f3affff6fdc8b65a2e9bb944d (diff)
downloadklibc-81cec7bde4ff55a28d3a9e3c71b5d488378eeac4.tar.gz
Correct the definition of stdin, stdout, stderr; make __create_file()klibc-0.99
a macro so it can be used in static initializers
-rw-r--r--include/stdio.h14
-rw-r--r--klibc/include/stdio.h14
2 files changed, 12 insertions, 16 deletions
diff --git a/include/stdio.h b/include/stdio.h
index 31a1fe40af296..fba1e30746a9d 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -15,10 +15,6 @@
struct _IO_file;
typedef struct _IO_file FILE;
-#define stdin ((FILE *)0)
-#define stdout ((FILE *)1)
-#define stderr ((FILE *)2)
-
#ifndef EOF
# define EOF (-1)
#endif
@@ -44,10 +40,12 @@ static __inline__ int fileno(FILE *__f)
return (int)(size_t)__f - 1;
}
-static __inline__ FILE * __create_file(int __fd)
-{
- return (FILE *)(size_t)(__fd + 1);
-}
+/* This is a macro so it can be used as initializer */
+#define __create_file(__fd) ((FILE *)(size_t)((__fd) + 1))
+
+#define stdin __create_file(0)
+#define stdout __create_file(1)
+#define stderr __create_file(2)
__extern FILE *fopen(const char *, const char *);
diff --git a/klibc/include/stdio.h b/klibc/include/stdio.h
index 31a1fe40af296..fba1e30746a9d 100644
--- a/klibc/include/stdio.h
+++ b/klibc/include/stdio.h
@@ -15,10 +15,6 @@
struct _IO_file;
typedef struct _IO_file FILE;
-#define stdin ((FILE *)0)
-#define stdout ((FILE *)1)
-#define stderr ((FILE *)2)
-
#ifndef EOF
# define EOF (-1)
#endif
@@ -44,10 +40,12 @@ static __inline__ int fileno(FILE *__f)
return (int)(size_t)__f - 1;
}
-static __inline__ FILE * __create_file(int __fd)
-{
- return (FILE *)(size_t)(__fd + 1);
-}
+/* This is a macro so it can be used as initializer */
+#define __create_file(__fd) ((FILE *)(size_t)((__fd) + 1))
+
+#define stdin __create_file(0)
+#define stdout __create_file(1)
+#define stderr __create_file(2)
__extern FILE *fopen(const char *, const char *);