summaryrefslogtreecommitdiff
path: root/src/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio')
-rw-r--r--src/stdio/__fdopen.c6
-rw-r--r--src/stdio/__fopen_rb_ca.c2
-rw-r--r--src/stdio/__stdio_read.c1
-rw-r--r--src/stdio/__stdio_write.c1
-rw-r--r--src/stdio/__stdout_write.c2
-rw-r--r--src/stdio/__string_read.c1
-rw-r--r--src/stdio/fgetln.c1
-rw-r--r--src/stdio/fgets.c1
-rw-r--r--src/stdio/fgetwc.c2
-rw-r--r--src/stdio/fgetws.c1
-rw-r--r--src/stdio/fmemopen.c16
-rw-r--r--src/stdio/fopen.c3
-rw-r--r--src/stdio/fputs.c1
-rw-r--r--src/stdio/fputwc.c3
-rw-r--r--src/stdio/fputws.c1
-rw-r--r--src/stdio/fread.c1
-rw-r--r--src/stdio/freopen.c1
-rw-r--r--src/stdio/ftell.c2
-rw-r--r--src/stdio/ftrylockfile.c1
-rw-r--r--src/stdio/fwrite.c1
-rw-r--r--src/stdio/getdelim.c3
-rw-r--r--src/stdio/gets.c2
-rw-r--r--src/stdio/getwc.c1
-rw-r--r--src/stdio/getwchar.c1
-rw-r--r--src/stdio/open_memstream.c16
-rw-r--r--src/stdio/open_wmemstream.c17
-rw-r--r--src/stdio/pclose.c3
-rw-r--r--src/stdio/popen.c3
-rw-r--r--src/stdio/putwc.c1
-rw-r--r--src/stdio/putwchar.c1
-rw-r--r--src/stdio/ungetwc.c4
-rw-r--r--src/stdio/vfprintf.c9
-rw-r--r--src/stdio/vfscanf.c2
-rw-r--r--src/stdio/vfwprintf.c7
-rw-r--r--src/stdio/vsnprintf.c4
-rw-r--r--src/stdio/vswprintf.c5
-rw-r--r--src/stdio/vswscanf.c1
37 files changed, 108 insertions, 20 deletions
diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c
index df6ed71d..59690f6d 100644
--- a/src/stdio/__fdopen.c
+++ b/src/stdio/__fdopen.c
@@ -1,4 +1,10 @@
#include "stdio_impl.h"
+#include <stdlib.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
FILE *__fdopen(int fd, const char *mode)
{
diff --git a/src/stdio/__fopen_rb_ca.c b/src/stdio/__fopen_rb_ca.c
index a1b1b3b6..9202c8ce 100644
--- a/src/stdio/__fopen_rb_ca.c
+++ b/src/stdio/__fopen_rb_ca.c
@@ -1,4 +1,6 @@
#include "stdio_impl.h"
+#include <fcntl.h>
+#include <string.h>
FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len)
{
diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c
index c99ca9a9..05e56f92 100644
--- a/src/stdio/__stdio_read.c
+++ b/src/stdio/__stdio_read.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <sys/uio.h>
#include <pthread.h>
static void cleanup(void *p)
diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
index cef7bbdc..e52e91ae 100644
--- a/src/stdio/__stdio_write.c
+++ b/src/stdio/__stdio_write.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <sys/uio.h>
#include <pthread.h>
static void cleanup(void *p)
diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c
index 0cf71236..200fe2c9 100644
--- a/src/stdio/__stdout_write.c
+++ b/src/stdio/__stdout_write.c
@@ -1,4 +1,6 @@
#include "stdio_impl.h"
+#include <termios.h>
+#include <sys/ioctl.h>
size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len)
{
diff --git a/src/stdio/__string_read.c b/src/stdio/__string_read.c
index de002fc1..7b50a7e1 100644
--- a/src/stdio/__string_read.c
+++ b/src/stdio/__string_read.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <string.h>
size_t __string_read(FILE *f, unsigned char *buf, size_t len)
{
diff --git a/src/stdio/fgetln.c b/src/stdio/fgetln.c
index 06b88837..a2e4bd3c 100644
--- a/src/stdio/fgetln.c
+++ b/src/stdio/fgetln.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <string.h>
char *fgetln(FILE *f, size_t *plen)
{
diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c
index ee0ac30e..b01a4187 100644
--- a/src/stdio/fgets.c
+++ b/src/stdio/fgets.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <string.h>
#define MIN(a,b) ((a)<(b) ? (a) : (b))
diff --git a/src/stdio/fgetwc.c b/src/stdio/fgetwc.c
index 6f9f9ec2..8626d54c 100644
--- a/src/stdio/fgetwc.c
+++ b/src/stdio/fgetwc.c
@@ -1,4 +1,6 @@
#include "stdio_impl.h"
+#include <wchar.h>
+#include <errno.h>
wint_t __fgetwc_unlocked(FILE *f)
{
diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
index fab9bd0f..195cb435 100644
--- a/src/stdio/fgetws.c
+++ b/src/stdio/fgetws.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <wchar.h>
wint_t __fgetwc_unlocked(FILE *);
diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c
index 770fd995..d7849609 100644
--- a/src/stdio/fmemopen.c
+++ b/src/stdio/fmemopen.c
@@ -1,4 +1,7 @@
#include "stdio_impl.h"
+#include <errno.h>
+#include <string.h>
+#include <inttypes.h>
struct cookie {
size_t pos, len, size;
@@ -105,12 +108,13 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode)
f->seek = mseek;
f->close = mclose;
- if (!libc.threaded) {
- f->lock = -1;
- f->next = libc.ofl_head;
- if (libc.ofl_head) libc.ofl_head->prev = f;
- libc.ofl_head = f;
- }
+ if (!libc.threaded) f->lock = -1;
+
+ OFLLOCK();
+ f->next = libc.ofl_head;
+ if (libc.ofl_head) libc.ofl_head->prev = f;
+ libc.ofl_head = f;
+ OFLUNLOCK();
return f;
}
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c
index c741aede..da17ce8b 100644
--- a/src/stdio/fopen.c
+++ b/src/stdio/fopen.c
@@ -1,4 +1,7 @@
#include "stdio_impl.h"
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
FILE *fopen(const char *restrict filename, const char *restrict mode)
{
diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c
index b41bc8c7..1112b192 100644
--- a/src/stdio/fputs.c
+++ b/src/stdio/fputs.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <string.h>
int fputs(const char *restrict s, FILE *restrict f)
{
diff --git a/src/stdio/fputwc.c b/src/stdio/fputwc.c
index 45ea8c23..7b621dd2 100644
--- a/src/stdio/fputwc.c
+++ b/src/stdio/fputwc.c
@@ -1,4 +1,7 @@
#include "stdio_impl.h"
+#include <wchar.h>
+#include <limits.h>
+#include <ctype.h>
wint_t __fputwc_unlocked(wchar_t c, FILE *f)
{
diff --git a/src/stdio/fputws.c b/src/stdio/fputws.c
index 0b593c08..5723cbcd 100644
--- a/src/stdio/fputws.c
+++ b/src/stdio/fputws.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <wchar.h>
int fputws(const wchar_t *restrict ws, FILE *restrict f)
{
diff --git a/src/stdio/fread.c b/src/stdio/fread.c
index 3f31af8a..c461256c 100644
--- a/src/stdio/fread.c
+++ b/src/stdio/fread.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <string.h>
#define MIN(a,b) ((a)<(b) ? (a) : (b))
diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c
index 7ae116d8..6c1b575f 100644
--- a/src/stdio/freopen.c
+++ b/src/stdio/freopen.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <fcntl.h>
/* The basic idea of this implementation is to open a new FILE,
* hack the necessary parts of the new FILE into the old one, then
diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c
index 3904a1d8..82371e37 100644
--- a/src/stdio/ftell.c
+++ b/src/stdio/ftell.c
@@ -1,4 +1,6 @@
#include "stdio_impl.h"
+#include <limits.h>
+#include <errno.h>
off_t __ftello_unlocked(FILE *f)
{
diff --git a/src/stdio/ftrylockfile.c b/src/stdio/ftrylockfile.c
index 725c4c3e..eef4e250 100644
--- a/src/stdio/ftrylockfile.c
+++ b/src/stdio/ftrylockfile.c
@@ -1,5 +1,6 @@
#include "stdio_impl.h"
#include "pthread_impl.h"
+#include <limits.h>
int ftrylockfile(FILE *f)
{
diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c
index 8027b306..d5f6542d 100644
--- a/src/stdio/fwrite.c
+++ b/src/stdio/fwrite.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <string.h>
size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f)
{
diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c
index 5015c3a6..26093a6c 100644
--- a/src/stdio/getdelim.c
+++ b/src/stdio/getdelim.c
@@ -1,4 +1,7 @@
#include "stdio_impl.h"
+#include <string.h>
+#include <inttypes.h>
+#include <errno.h>
#define MIN(a,b) ((a)<(b) ? (a) : (b))
diff --git a/src/stdio/gets.c b/src/stdio/gets.c
index 24319eb2..6c4645e5 100644
--- a/src/stdio/gets.c
+++ b/src/stdio/gets.c
@@ -1,4 +1,6 @@
#include "stdio_impl.h"
+#include <limits.h>
+#include <string.h>
char *gets(char *s)
{
diff --git a/src/stdio/getwc.c b/src/stdio/getwc.c
index a2818bc4..a5008f0e 100644
--- a/src/stdio/getwc.c
+++ b/src/stdio/getwc.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <wchar.h>
wint_t getwc(FILE *f)
{
diff --git a/src/stdio/getwchar.c b/src/stdio/getwchar.c
index 2295bd40..bd89e0ec 100644
--- a/src/stdio/getwchar.c
+++ b/src/stdio/getwchar.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <wchar.h>
wint_t getwchar(void)
{
diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c
index 687e818d..9eafdfba 100644
--- a/src/stdio/open_memstream.c
+++ b/src/stdio/open_memstream.c
@@ -1,4 +1,7 @@
#include "stdio_impl.h"
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
struct cookie {
char **bufp;
@@ -74,12 +77,13 @@ FILE *open_memstream(char **bufp, size_t *sizep)
f->seek = ms_seek;
f->close = ms_close;
- if (!libc.threaded) {
- f->lock = -1;
- f->next = libc.ofl_head;
- if (libc.ofl_head) libc.ofl_head->prev = f;
- libc.ofl_head = f;
- }
+ if (!libc.threaded) f->lock = -1;
+
+ OFLLOCK();
+ f->next = libc.ofl_head;
+ if (libc.ofl_head) libc.ofl_head->prev = f;
+ libc.ofl_head = f;
+ OFLUNLOCK();
return f;
}
diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c
index a830b143..35370309 100644
--- a/src/stdio/open_wmemstream.c
+++ b/src/stdio/open_wmemstream.c
@@ -1,4 +1,8 @@
#include "stdio_impl.h"
+#include <wchar.h>
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
struct cookie {
wchar_t **bufp;
@@ -75,12 +79,13 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep)
f->seek = wms_seek;
f->close = wms_close;
- if (!libc.threaded) {
- f->lock = -1;
- f->next = libc.ofl_head;
- if (libc.ofl_head) libc.ofl_head->prev = f;
- libc.ofl_head = f;
- }
+ if (!libc.threaded) f->lock = -1;
+
+ OFLLOCK();
+ f->next = libc.ofl_head;
+ if (libc.ofl_head) libc.ofl_head->prev = f;
+ libc.ofl_head = f;
+ OFLUNLOCK();
return f;
}
diff --git a/src/stdio/pclose.c b/src/stdio/pclose.c
index 7fb76ed4..080a4262 100644
--- a/src/stdio/pclose.c
+++ b/src/stdio/pclose.c
@@ -1,5 +1,6 @@
#include "stdio_impl.h"
-#include "syscall.h"
+#include <errno.h>
+#include <unistd.h>
int pclose(FILE *f)
{
diff --git a/src/stdio/popen.c b/src/stdio/popen.c
index ca3cdf9d..ed20f5a1 100644
--- a/src/stdio/popen.c
+++ b/src/stdio/popen.c
@@ -1,4 +1,7 @@
#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
#include "stdio_impl.h"
#include "pthread_impl.h"
#include "syscall.h"
diff --git a/src/stdio/putwc.c b/src/stdio/putwc.c
index 80b54a47..4bb74733 100644
--- a/src/stdio/putwc.c
+++ b/src/stdio/putwc.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <wchar.h>
wint_t putwc(wchar_t c, FILE *f)
{
diff --git a/src/stdio/putwchar.c b/src/stdio/putwchar.c
index 3aacc1cf..b249c4ac 100644
--- a/src/stdio/putwchar.c
+++ b/src/stdio/putwchar.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <wchar.h>
wint_t putwchar(wchar_t c)
{
diff --git a/src/stdio/ungetwc.c b/src/stdio/ungetwc.c
index 5282fee1..8cc85a6b 100644
--- a/src/stdio/ungetwc.c
+++ b/src/stdio/ungetwc.c
@@ -1,4 +1,8 @@
#include "stdio_impl.h"
+#include <wchar.h>
+#include <limits.h>
+#include <ctype.h>
+#include <string.h>
wint_t ungetwc(wint_t c, FILE *f)
{
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index 4a2752b2..1e7e6a47 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -1,4 +1,13 @@
#include "stdio_impl.h"
+#include <errno.h>
+#include <ctype.h>
+#include <limits.h>
+#include <string.h>
+#include <stdarg.h>
+#include <wchar.h>
+#include <inttypes.h>
+#include <math.h>
+#include <float.h>
/* Some useful macros */
diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
index 54d08495..fe071e95 100644
--- a/src/stdio/vfscanf.c
+++ b/src/stdio/vfscanf.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
@@ -9,6 +8,7 @@
#include <errno.h>
#include <math.h>
#include <float.h>
+#include <inttypes.h>
#include "stdio_impl.h"
#include "shgetc.h"
diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
index a42ba195..eb079312 100644
--- a/src/stdio/vfwprintf.c
+++ b/src/stdio/vfwprintf.c
@@ -1,4 +1,11 @@
#include "stdio_impl.h"
+#include <errno.h>
+#include <ctype.h>
+#include <limits.h>
+#include <string.h>
+#include <stdarg.h>
+#include <wchar.h>
+#include <inttypes.h>
/* Convenient bit representation for modifier flags, which all fall
* within 31 codepoints of the space character. */
diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c
index 6f19b028..be2c44eb 100644
--- a/src/stdio/vsnprintf.c
+++ b/src/stdio/vsnprintf.c
@@ -1,4 +1,8 @@
#include "stdio_impl.h"
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+#include <stdint.h>
static size_t sn_write(FILE *f, const unsigned char *s, size_t l)
{
diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
index f3d4fec1..7d237bae 100644
--- a/src/stdio/vswprintf.c
+++ b/src/stdio/vswprintf.c
@@ -1,4 +1,9 @@
#include "stdio_impl.h"
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+#include <stdint.h>
+#include <wchar.h>
struct cookie {
wchar_t *ws;
diff --git a/src/stdio/vswscanf.c b/src/stdio/vswscanf.c
index a205200a..7a2f7c7a 100644
--- a/src/stdio/vswscanf.c
+++ b/src/stdio/vswscanf.c
@@ -1,4 +1,5 @@
#include "stdio_impl.h"
+#include <wchar.h>
static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
{