diff options
Diffstat (limited to '05/musl-0.6.0/src/stdio')
-rw-r--r-- | 05/musl-0.6.0/src/stdio/clearerr.c | 8 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/feof.c | 5 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/ferror.c | 5 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/fgetc.c | 9 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/fgets.c | 5 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/fileno.c | 5 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/fputc.c | 9 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/fputs.c | 7 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/fread.c | 4 | ||||
-rw-r--r-- | 05/musl-0.6.0/src/stdio/fwrite.c | 10 |
10 files changed, 59 insertions, 8 deletions
diff --git a/05/musl-0.6.0/src/stdio/clearerr.c b/05/musl-0.6.0/src/stdio/clearerr.c index 3bf94d3..a409120 100644 --- a/05/musl-0.6.0/src/stdio/clearerr.c +++ b/05/musl-0.6.0/src/stdio/clearerr.c @@ -7,4 +7,10 @@ void clearerr(FILE *f) FUNLOCK(f); } -weak_alias(clearerr, clearerr_unlocked); +void clearerr_unlocked(FILE *f) +{ + FLOCK(f); + f->flags &= ~(F_EOF|F_ERR); + FUNLOCK(f); +} + diff --git a/05/musl-0.6.0/src/stdio/feof.c b/05/musl-0.6.0/src/stdio/feof.c index f2b739b..9038a7c 100644 --- a/05/musl-0.6.0/src/stdio/feof.c +++ b/05/musl-0.6.0/src/stdio/feof.c @@ -7,4 +7,7 @@ int feof(FILE *f) return !!(f->flags & F_EOF); } -weak_alias(feof, feof_unlocked); +int feof_unlocked(FILE *f) +{ + return !!(f->flags & F_EOF); +} diff --git a/05/musl-0.6.0/src/stdio/ferror.c b/05/musl-0.6.0/src/stdio/ferror.c index f535fbe..2c59172 100644 --- a/05/musl-0.6.0/src/stdio/ferror.c +++ b/05/musl-0.6.0/src/stdio/ferror.c @@ -7,4 +7,7 @@ int ferror(FILE *f) return !!(f->flags & F_ERR); } -weak_alias(ferror, ferror_unlocked); +int ferror_unlocked(FILE *f) +{ + return !!(f->flags & F_ERR); +} diff --git a/05/musl-0.6.0/src/stdio/fgetc.c b/05/musl-0.6.0/src/stdio/fgetc.c index 3a7f1e3..8810f35 100644 --- a/05/musl-0.6.0/src/stdio/fgetc.c +++ b/05/musl-0.6.0/src/stdio/fgetc.c @@ -8,3 +8,12 @@ int fgetc(FILE *f) FUNLOCK(f); return c; } + +int fgetc_unlocked(FILE *f) +{ + int c; + FLOCK(f); + c = f->rpos < f->rstop ? *f->rpos++ : __uflow(f); + FUNLOCK(f); + return c; +} diff --git a/05/musl-0.6.0/src/stdio/fgets.c b/05/musl-0.6.0/src/stdio/fgets.c index 7939303..22dab95 100644 --- a/05/musl-0.6.0/src/stdio/fgets.c +++ b/05/musl-0.6.0/src/stdio/fgets.c @@ -31,4 +31,7 @@ char *fgets(char *s, int n, FILE *f) return (p == s) ? 0 : s; } -weak_alias(fgets, fgets_unlocked); + +char *fgets_unlocked(char *s, int n, FILE *f) { + return fgets(s, n, f); +} diff --git a/05/musl-0.6.0/src/stdio/fileno.c b/05/musl-0.6.0/src/stdio/fileno.c index 9ffb26d..38bc8e8 100644 --- a/05/musl-0.6.0/src/stdio/fileno.c +++ b/05/musl-0.6.0/src/stdio/fileno.c @@ -5,4 +5,7 @@ int fileno(FILE *f) return f->fd; } -weak_alias(fileno, fileno_unlocked); +int fileno_unlocked(FILE *f) +{ + return f->fd; +} diff --git a/05/musl-0.6.0/src/stdio/fputc.c b/05/musl-0.6.0/src/stdio/fputc.c index ec85938..3e0f738 100644 --- a/05/musl-0.6.0/src/stdio/fputc.c +++ b/05/musl-0.6.0/src/stdio/fputc.c @@ -8,3 +8,12 @@ int fputc(int c, FILE *f) FUNLOCK(f); return c; } + +int fputc_unlocked(int c, FILE *f) +{ + FLOCK(f); + if (c != f->lbf && f->wpos + 1 < f->wend) *f->wpos++ = c; + else c = __overflow(f, c); + FUNLOCK(f); + return c; +} diff --git a/05/musl-0.6.0/src/stdio/fputs.c b/05/musl-0.6.0/src/stdio/fputs.c index e6bdb20..5f78ca7 100644 --- a/05/musl-0.6.0/src/stdio/fputs.c +++ b/05/musl-0.6.0/src/stdio/fputs.c @@ -7,4 +7,9 @@ int fputs(const char *s, FILE *f) return (int)fwrite(s, l, 1, f) - 1; } -weak_alias(fputs, fputs_unlocked); +int fputs_unlocked(const char *s, FILE *f) +{ + size_t l = strlen(s); + if (!l) return 0; + return (int)fwrite(s, l, 1, f) - 1; +} diff --git a/05/musl-0.6.0/src/stdio/fread.c b/05/musl-0.6.0/src/stdio/fread.c index 0fa0b2a..8b9ca55 100644 --- a/05/musl-0.6.0/src/stdio/fread.c +++ b/05/musl-0.6.0/src/stdio/fread.c @@ -46,4 +46,6 @@ eof: return (len-l)/size; } -weak_alias(fread, fread_unlocked); +size_t fread_unlocked(void *destv, size_t size, size_t nmemb, FILE *f) { + return fread(destv, size, nmemb, f); +} diff --git a/05/musl-0.6.0/src/stdio/fwrite.c b/05/musl-0.6.0/src/stdio/fwrite.c index 23974fe..d6bf314 100644 --- a/05/musl-0.6.0/src/stdio/fwrite.c +++ b/05/musl-0.6.0/src/stdio/fwrite.c @@ -48,4 +48,12 @@ size_t fwrite(const void *src, size_t size, size_t nmemb, FILE *f) return l/size; } -weak_alias(fwrite, fwrite_unlocked); +size_t fwrite_unlocked(const void *src, size_t size, size_t nmemb, FILE *f) +{ + size_t l = size*nmemb; + if (!l) return l; + FLOCK(f); + l = __fwritex(src, l, f); + FUNLOCK(f); + return l/size; +} |