shithub: scc

Download patch

ref: e0701f28ae8920a135298ea06a2d493732770c65
parent: d75c01ac6bb53fc48551d716458abf428c2687c6
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Aug 25 03:07:15 EDT 2018

[lib/c] Introduce libc.h

This header is intended for all the internal definitions that cannot
be public.

--- a/lib/c/_fpopen.c
+++ b/lib/c/_fpopen.c
@@ -3,12 +3,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "syscall.h"
+#include "libc.h"
 #undef fopen
 
 FILE *
 _fpopen(const char * restrict fname,
-         const char * restrict mode,
-         FILE * restrict fp)
+        const char * restrict mode,
+        FILE * restrict fp)
 {
 	int i, flags, fd, rw, bin;
 
--- a/lib/c/fopen.c
+++ b/lib/c/fopen.c
@@ -3,6 +3,7 @@
 #include <stdio.h>
 
 #include "syscall.h"
+#include "libc.h"
 #undef fopen
 
 
--- a/lib/c/freopen.c
+++ b/lib/c/freopen.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 
 #include "syscall.h"
+#include "libc.h"
 #undef freopen
 
 FILE *
--- /dev/null
+++ b/lib/c/libc.h
@@ -1,0 +1,14 @@
+#ifdef stdin
+extern FILE *_fpopen(const char * restrict fname,
+                     const char * restrict mode,
+                     FILE * restrict fp);
+#endif
+
+/* TODO: Move to system headers */
+#define O_RDONLY  0x00000000
+#define O_WRONLY  0x00000001
+#define O_RDWR    0x00000002
+
+#define O_TRUNC   0x00000400
+#define O_APPEND  0x00000008
+#define O_CREAT   0x00000200
--- a/lib/c/syscall.h
+++ b/lib/c/syscall.h
@@ -6,18 +6,3 @@
 extern int _lseek(int fd, long off, int whence);
 extern void _Exit(int status);
 extern int _access(char *path, int mode);
-
-/* auxiliar functions */
-
-#ifdef stdin
-extern FILE *_fpopen(const char * restrict fname,
-                     const char * restrict mode,
-                     FILE * restrict fp);
-#endif
-
-#define O_WRONLY  1
-#define O_RDONLY  2
-#define O_RDWR    4
-#define O_TRUNC   8
-#define O_APPEND 16
-#define O_CREAT  32