-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 54d5ba6
Showing
165 changed files
with
1,789 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
BasedOnStyle: LLVM | ||
IndentWidth: 8 | ||
UseTab: Always | ||
BreakBeforeBraces: Linux | ||
AllowShortIfStatementsOnASingleLine: false | ||
IndentCaseLabels: true | ||
IndentPPDirectives: BeforeHash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
*.gch | ||
*.pch | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
*.exe | ||
*.out | ||
*.app | ||
*.pdb | ||
/build*/ | ||
/subprojects/* | ||
!/subprojects/*.wrap | ||
meson-logs | ||
meson-private | ||
meson_benchmark_setup.dat | ||
meson_test_setup.dat | ||
build.ninja | ||
.ninja_deps | ||
.ninja_logs | ||
compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "io/io.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int asprintf(char **string, char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = vasprintf(string, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#define NO_OPAQUE_TYPE | ||
#include "io.h" | ||
|
||
int aswprintf(wchar_t **string, wchar_t const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = vaswprintf(string, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "io.h" | ||
#include <errno.h> | ||
|
||
char* fgets(char *restrict string, int size, FILE *restrict stream) | ||
{ | ||
int character = 0; | ||
for(int i=0;character == '\n' || i < size -1;i++){ | ||
character = _fgetc_wrap(stream); | ||
if(character == _eof_wrap){ | ||
return NULL; | ||
} | ||
} | ||
|
||
return string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "io.h" | ||
#include <errno.h> | ||
|
||
char* fgets(char *restrict string, int size, FILE *restrict stream) | ||
{ | ||
int character = 0; | ||
for(int i=0;character == '\n' || i < size -1;i++){ | ||
character = _fgetc_wrap(stream); | ||
if(character == _eof_wrap){ | ||
return NULL; | ||
} | ||
} | ||
|
||
return string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int fprintf(FILE *stream, char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = _vfprintf_wrap(stream, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "io.h" | ||
#include <errno.h> | ||
|
||
int fputs(char const *restrict string, FILE *restrict stream) | ||
{ | ||
|
||
for (size_t i = 0; string[i]; ++i) { | ||
if(_fputc_wrap(string[i], stream)==_eof_wrap){return _eof_wrap;}; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "io.h" | ||
#include <errno.h> | ||
|
||
int fputs(char const *restrict string, FILE *restrict stream) | ||
{ | ||
|
||
for (size_t i = 0; string[i]; ++i) { | ||
if(_fputc_wrap(string[i], stream)==_eof_wrap){return _eof_wrap;}; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int fscanf(FILE *stream, char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = _vfscanf_wrap(stream, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int fwprintf(FILE *stream, wchar_t const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = _vfwprintf_wrap(stream, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int fwscanf(FILE *stream, wchar_t const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = _vfwscanf_wrap(stream, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "io.h" | ||
|
||
int getchar(void) { return _fgetc_wrap(_stdstream_wrap(stream_input)); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "io.h" | ||
#include <errno.h> | ||
|
||
char* gets(char *string) | ||
{ | ||
size_t i='\0'; | ||
for(int character = 0;character == '\n';i++){ | ||
character = getchar(); | ||
if(character == _eof_wrap){ | ||
return NULL; | ||
} | ||
string[i]=character; | ||
} | ||
|
||
string[++i]='\0'; | ||
|
||
return string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#define NEED_WINT | ||
#include "io.h" | ||
|
||
wint_t getwchar(void) { return fgetwc(_stdstream_wrap(stream_input)); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#if !defined(IO_H) | ||
#define IO_H | ||
|
||
#include <stdarg.h> | ||
#include <stddef.h> | ||
|
||
#if __STDC_HOSTED__ == 1 | ||
#include "wrap/io.h" | ||
|
||
extern void setbuf(FILE *restrict, char *restrict); | ||
extern void rewind(FILE *); | ||
|
||
extern int getchar(void); | ||
extern int putchar(int); | ||
extern int puts(char const *restrict); | ||
extern int fputs(char const *restrict,FILE *restrict); | ||
|
||
#if defined(NEED_WINT) | ||
extern wint_t getwchar(void); | ||
extern wint_t putwchar(wchar_t); | ||
#endif | ||
|
||
extern void perror(char const *); | ||
|
||
extern int fprintf(FILE *, char const *restrict, ...); | ||
extern int printf(char const *restrict, ...); | ||
extern int snprintf(char *, size_t, char const *restrict, ...); | ||
extern int asprintf(char **restrict, char const *restrict, ...); | ||
extern int sprintf(char *, char const *restrict, ...); | ||
extern int vprintf(char const *restrict, va_list); | ||
extern int vsprintf(char *, char const *restrict, va_list); | ||
extern int vasprintf(char **restrict, char const *restrict, va_list); | ||
extern int fwprintf(FILE *, wchar_t const *restrict, ...); | ||
extern int wprintf(wchar_t const *restrict, ...); | ||
extern int swprintf(wchar_t *, size_t, wchar_t const *restrict, ...); | ||
extern int aswprintf(wchar_t **restrict, wchar_t const *restrict, | ||
...); | ||
extern int vwprintf(wchar_t const *restrict, va_list); | ||
extern int vaswprintf(wchar_t **restrict, wchar_t const *restrict, | ||
va_list); | ||
|
||
extern int fscanf(FILE *, char const *restrict, ...); | ||
extern int scanf(char const *restrict, ...); | ||
extern int sscanf(char const *restrict, char const *restrict, ...); | ||
extern int vscanf(char const *restrict, va_list); | ||
extern int fwscanf(FILE *, wchar_t const *restrict, ...); | ||
extern int swscanf(wchar_t const *restrict, wchar_t const *restrict, | ||
...); | ||
extern int vwscanf(wchar_t const *restrict, va_list); | ||
extern int wscanf(wchar_t const *restrict, ...); | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
if is_hosted == 1 | ||
subdir('wrap') | ||
sources += files( | ||
'io.h', | ||
'printf.c', | ||
'fprintf.c', | ||
'snprintf.c', | ||
'asprintf.c', | ||
'sprintf.c', | ||
'vprintf.c', | ||
'vsprintf.c', | ||
'wprinf.c', | ||
'fwprinf.c', | ||
'aswprintf.c', | ||
'swprintf.c', | ||
'vwprintf.c', | ||
'vaswprintf.c', | ||
'perror.c', | ||
'setbuf.c', | ||
'fread.c', | ||
'fwrite.c', | ||
'gets.c', | ||
'fgets.c', | ||
'getws.c', | ||
'fgetws.c', | ||
'getchar.c', | ||
'getwchar.c', | ||
'puts.c' | ||
'fputs.c' | ||
'putws.c' | ||
'fputws.c' | ||
'putchar.c', | ||
'putwchar.c', | ||
'scanf.c', | ||
'vwscanf.c', | ||
'vscanf.c', | ||
'swscanf.c', | ||
'sscanf.c', | ||
'fwscanf.c', | ||
'fscanf.c', | ||
'wscanf.c' | ||
) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
#include <errno.h> | ||
#include <string.h> | ||
|
||
void perror(char const *string) | ||
{ | ||
|
||
fprintf(_stdstream_wrap(stream_error), "%s: %s", string, | ||
strerror(errno)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int printf(char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = vprintf(format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "io.h" | ||
|
||
int putchar(int character) | ||
{ | ||
return _fputc_wrap(character, _stdstream_wrap(stream_output)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
#include <errno.h> | ||
|
||
int puts(char const *string) | ||
{ | ||
if (fputs(string, _stdstream_wrap(stream_output)) == _eof_wrap) { | ||
return _eof_wrap; | ||
} | ||
return putchar('\n'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#define NEED_WINT | ||
#include "io.h" | ||
|
||
wint_t putwchar(wchar_t character) | ||
{ | ||
return fputwc(character, _stdstream_wrap(stream_output)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#define NO_OPAQUE_TYPE | ||
#include "io.h" | ||
|
||
void rewind(FILE *stream) { fseek(stream, 0L, SEEK_SET); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int scanf(char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = vscanf(format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#define NO_OPAQUE_TYPE | ||
#include "io.h" | ||
|
||
void setbuf(FILE *restrict file, char *restrict buffer) | ||
{ | ||
(buffer == NULL) ? _setvbuf_wrap(file, NULL, _IONBF, 0) | ||
: _setvbuf_wrap(file, buffer, _IOFBF, BUFSIZ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int snprintf(char *string, size_t max_size, char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = _vsnprintf_wrap(string, max_size, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int sprintf(char *string, char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = vsprintf(string, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "io.h" | ||
|
||
int sscanf(char const *restrict string, char const *restrict format, ...) | ||
{ | ||
va_list arg; | ||
va_start(arg, format); | ||
int lenght = _vsscanf_wrap(string, format, arg); | ||
va_end(arg); | ||
return lenght; | ||
} |
Oops, something went wrong.