summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-03-04 03:14:54 -0500
committerJakob Kaivo <jkk@ung.org>2020-03-04 03:14:54 -0500
commit2c6147ab6c567babf07b85820e99f541e423614a (patch)
tree9067b51de895125ecfee07bc57c254d6fb4f8fad
parent584c5b3e93e3007dfb16bcb43d901df74be21116 (diff)
fix compilation when c=199409
-rw-r--r--src/stdio/_stdio.h13
-rw-r--r--src/stdio/flockfile.c9
-rw-r--r--src/stdio/funlockfile.c9
-rw-r--r--src/stdio/getc_unlocked.c23
-rw-r--r--src/stdio/getchar_unlocked.c10
-rw-r--r--src/stdio/putc_unlocked.c10
-rw-r--r--src/stdio/putchar_unlocked.c10
-rw-r--r--src/wchar/fgetwc.c6
8 files changed, 86 insertions, 4 deletions
diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h
index 3335fa7e..84ad60ca 100644
--- a/src/stdio/_stdio.h
+++ b/src/stdio/_stdio.h
@@ -3,9 +3,14 @@
#include <stdarg.h>
#include <stdio.h>
-#include "../sys/types/pid_t.c"
#include "nonstd/internal.h"
+#ifdef _POSIX_C_SOURCE
+#include <sys/types.h>
+#else
+#include "../sys/types/pid_t.c"
+#endif
+
struct __FILE {
fpos_t pos;
char *buf;
@@ -49,9 +54,9 @@ struct io_options {
int __printf(struct io_options * restrict, const char * restrict, va_list);
int __scanf(struct io_options * restrict, const char * restrict, va_list);
-#ifndef _POSIX_C_SOURCE
-#define flockfile(...)
-#define funlockfile(...)
+#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L
+#define flockfile(_file) (void)(_file)
+#define funlockfile(_file) (void)(_file)
#endif
#endif
diff --git a/src/stdio/flockfile.c b/src/stdio/flockfile.c
new file mode 100644
index 00000000..d8d5776b
--- /dev/null
+++ b/src/stdio/flockfile.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+void flockfile(FILE * file)
+{
+}
+
+/*
+POSIX(199506)
+*/
diff --git a/src/stdio/funlockfile.c b/src/stdio/funlockfile.c
new file mode 100644
index 00000000..b85f4842
--- /dev/null
+++ b/src/stdio/funlockfile.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+void funlockfile(FILE * file)
+{
+}
+
+/*
+POSIX(199506)
+*/
diff --git a/src/stdio/getc_unlocked.c b/src/stdio/getc_unlocked.c
new file mode 100644
index 00000000..8abae5de
--- /dev/null
+++ b/src/stdio/getc_unlocked.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include "_stdio.h"
+#include "unistd.h"
+
+int getc_unlocked(FILE * stream)
+{
+ char c = 0;
+
+ if (!stream) {
+ return EOF;
+ }
+
+ if (read(stream->fd, &c, sizeof(c)) != 1) {
+ stream->err = 1;
+ return EOF;
+ }
+
+ return c;
+}
+
+/*
+POSIX(199506)
+*/
diff --git a/src/stdio/getchar_unlocked.c b/src/stdio/getchar_unlocked.c
new file mode 100644
index 00000000..adeeccbd
--- /dev/null
+++ b/src/stdio/getchar_unlocked.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+int getchar_unlocked(void)
+{
+ return getc_unlocked(stdin);
+}
+
+/*
+POSIX(199506)
+*/
diff --git a/src/stdio/putc_unlocked.c b/src/stdio/putc_unlocked.c
new file mode 100644
index 00000000..77068408
--- /dev/null
+++ b/src/stdio/putc_unlocked.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+int putc_unlocked(int c, FILE * stream)
+{
+ return 0;
+}
+
+/*
+POSIX(199506)
+*/
diff --git a/src/stdio/putchar_unlocked.c b/src/stdio/putchar_unlocked.c
new file mode 100644
index 00000000..aecfe4a1
--- /dev/null
+++ b/src/stdio/putchar_unlocked.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+int putchar_unlocked(int c)
+{
+ return putc_unlocked(c, stdout);
+}
+
+/*
+POSIX(199506)
+*/
diff --git a/src/wchar/fgetwc.c b/src/wchar/fgetwc.c
index 1ae00f59..2c4d0d24 100644
--- a/src/wchar/fgetwc.c
+++ b/src/wchar/fgetwc.c
@@ -3,6 +3,12 @@
#include "../stdio/_stdio.h"
#include "limits.h"
+#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L
+#include "../unistd/read.c"
+static int getc_unlocked(FILE *);
+#include "../stdio/getc_unlocked.c"
+#endif
+
wint_t fgetwc(FILE * stream)
{
if (fwide(stream, 1) <= 0) {