Build variadic functions as part of relibc

This commit is contained in:
Jeremy Soller
2018-03-27 21:13:11 -06:00
parent b849165438
commit 79d05d7eda
9 changed files with 103 additions and 55 deletions
+2 -17
View File
@@ -1,22 +1,7 @@
#ifndef _BITS_FCNTL_H
#define _BITS_FCNTL_H
int open(const char* filename, int flags, ...) {
mode_t mode = 0;
va_list ap;
va_start(ap, flags);
mode = va_arg(ap, mode_t);
va_end(ap);
return sys_open(filename, flags, mode);
}
int fcntl(int fildes, int cmd, ...) {
int args = 0;
va_list ap;
va_start(ap, cmd);
args = va_arg(ap, int);
va_end(ap);
return sys_fcntl(fildes, cmd, args);
}
int open(const char* filename, int flags, ...);
int fcntl(int fildes, int cmd, ...);
#endif
+4 -35
View File
@@ -1,40 +1,9 @@
#ifndef _BITS_STDIO_H
#define _BITS_STDIO_H
int fprintf(FILE * stream, const char * fmt, ...) {
int ret;
va_list ap;
va_start(ap, fmt);
ret = vfprintf(stream, fmt, ap);
va_end(ap);
return ret;
}
int printf(const char * fmt, ...) {
int ret;
va_list ap;
va_start(ap, fmt);
ret = vprintf(fmt, ap);
va_end(ap);
return ret;
}
int snprintf(char *s, size_t n, const char * fmt, ...) {
int ret;
va_list ap;
va_start(ap, fmt);
ret = vsnprintf(s, n, fmt, ap);
va_end(ap);
return ret;
}
int sprintf(char *s, const char * fmt, ...) {
int ret;
va_list ap;
va_start(ap, fmt);
ret = vsprintf(s, fmt, ap);
va_end(ap);
return ret;
}
int fprintf(FILE * stream, const char * fmt, ...);
int printf(const char * fmt, ...);
int snprintf(char *s, size_t n, const char * fmt, ...);
int sprintf(char *s, const char * fmt, ...);
#endif /* _BITS_STDIO_H */
+3 -3
View File
@@ -1,9 +1,9 @@
#ifndef _BITS_STDIO_H
#define _BITS_STDIO_H
#ifndef _BITS_STRING_H
#define _BITS_STRING_H
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
void *memmove(void *dest, const void *src, size_t n);
void *memset(void *s, int c, size_t n);
#endif /* _BITS_STDIO_H */
#endif /* _BITS_STRING_H */