data_type
large_stringclasses
3 values
source
large_stringclasses
29 values
code
large_stringlengths
98
49.4M
filepath
large_stringlengths
5
161
message
large_stringclasses
234 values
commit
large_stringclasses
234 values
subject
large_stringclasses
418 values
critique
large_stringlengths
101
1.26M
metadata
dict
source
musl
.global sigsetjmp .global __sigsetjmp .type sigsetjmp,@function .type __sigsetjmp,@function sigsetjmp: __sigsetjmp: test %esi,%esi jz 1f popq 64(%rdi) mov %rbx,72+8(%rdi) mov %rdi,%rbx call setjmp@PLT pushq 64(%rbx) mov %rbx,%rdi mov %eax,%esi mov 72+8(%rbx),%rbx .hidden __sigsetjmp_tail jmp __sigsetjmp_...
src/signal/x86_64/sigsetjmp.s
null
null
null
null
null
source
musl
#include <sys/stat.h> #if !_REDIR_TIME64 int __fxstat(int ver, int fd, struct stat *buf) { return fstat(fd, buf); } int __fxstatat(int ver, int fd, const char *path, struct stat *buf, int flag) { return fstatat(fd, path, buf, flag); } int __lxstat(int ver, const char *path, struct stat *buf) { return lstat(path,...
src/stat/__xstat.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <fcntl.h> #include "syscall.h" int chmod(const char *path, mode_t mode) { #ifdef SYS_chmod return syscall(SYS_chmod, path, mode); #else return syscall(SYS_fchmodat, AT_FDCWD, path, mode); #endif }
src/stat/chmod.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <errno.h> #include <fcntl.h> #include "syscall.h" int fchmod(int fd, mode_t mode) { int ret = __syscall(SYS_fchmod, fd, mode); if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0) return __syscall_ret(ret); char buf[15+3*sizeof(int)]; __procfdname(buf, fd); #ifdef SYS_chmod...
src/stat/fchmod.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include "syscall.h" int fchmodat(int fd, const char *path, mode_t mode, int flag) { if (!flag) return syscall(SYS_fchmodat, fd, path, mode); int ret = __syscall(SYS_fchmodat2, fd, path, mode, flag); if (ret != -ENOSYS) return __syscall_ret(ret); if (fl...
src/stat/fchmodat.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <sys/stat.h> #include <errno.h> #include <fcntl.h> #include "syscall.h" int __fstat(int fd, struct stat *st) { if (fd<0) return __syscall_ret(-EBADF); return __fstatat(fd, "", st, AT_EMPTY_PATH); } weak_alias(__fstat, fstat);
src/stat/fstat.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <sys/stat.h> #include <string.h> #include <fcntl.h> #include <errno.h> #include <stdint.h> #include <sys/sysmacros.h> #include "syscall.h" struct statx { uint32_t stx_mask; uint32_t stx_blksize; uint64_t stx_attributes; uint32_t stx_nlink; uint32_t stx_uid; uint32_t stx_gid; uint16_...
src/stat/fstatat.c
null
null
null
null
null
source
musl
#include <sys/stat.h> int futimens(int fd, const struct timespec times[2]) { return utimensat(fd, 0, times, 0); }
src/stat/futimens.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <sys/time.h> #include <sys/stat.h> #include <errno.h> #include "syscall.h" int __futimesat(int dirfd, const char *pathname, const struct timeval times[2]) { struct timespec ts[2]; if (times) { int i; for (i=0; i<2; i++) { if (times[i].tv_usec >= 1000000ULL) return __syscall_re...
src/stat/futimesat.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <sys/stat.h> #include <fcntl.h> int lchmod(const char *path, mode_t mode) { return fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW); }
src/stat/lchmod.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <fcntl.h> int lstat(const char *restrict path, struct stat *restrict buf) { return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); }
src/stat/lstat.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <fcntl.h> #include "syscall.h" int mkdir(const char *path, mode_t mode) { #ifdef SYS_mkdir return syscall(SYS_mkdir, path, mode); #else return syscall(SYS_mkdirat, AT_FDCWD, path, mode); #endif }
src/stat/mkdir.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include "syscall.h" int mkdirat(int fd, const char *path, mode_t mode) { return syscall(SYS_mkdirat, fd, path, mode); }
src/stat/mkdirat.c
null
null
null
null
null
source
musl
#include <sys/stat.h> int mkfifo(const char *path, mode_t mode) { return mknod(path, mode | S_IFIFO, 0); }
src/stat/mkfifo.c
null
null
null
null
null
source
musl
#include <sys/stat.h> int mkfifoat(int fd, const char *path, mode_t mode) { return mknodat(fd, path, mode | S_IFIFO, 0); }
src/stat/mkfifoat.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <fcntl.h> #include "syscall.h" int mknod(const char *path, mode_t mode, dev_t dev) { #ifdef SYS_mknod return syscall(SYS_mknod, path, mode, dev); #else return syscall(SYS_mknodat, AT_FDCWD, path, mode, dev); #endif }
src/stat/mknod.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include "syscall.h" int mknodat(int fd, const char *path, mode_t mode, dev_t dev) { return syscall(SYS_mknodat, fd, path, mode, dev); }
src/stat/mknodat.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <fcntl.h> int stat(const char *restrict path, struct stat *restrict buf) { return fstatat(AT_FDCWD, path, buf, 0); }
src/stat/stat.c
null
null
null
null
null
source
musl
#include <sys/statvfs.h> #include <sys/statfs.h> #include "syscall.h" static int __statfs(const char *path, struct statfs *buf) { *buf = (struct statfs){0}; #ifdef SYS_statfs64 return syscall(SYS_statfs64, path, sizeof *buf, buf); #else return syscall(SYS_statfs, path, buf); #endif } static int __fstatfs(int fd, s...
src/stat/statvfs.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include "syscall.h" mode_t umask(mode_t mode) { return syscall(SYS_umask, mode); }
src/stat/umask.c
null
null
null
null
null
source
musl
#include <sys/stat.h> #include <sys/time.h> #include <fcntl.h> #include <errno.h> #include "syscall.h" #define IS32BIT(x) !((x)+0x80000000ULL>>32) #define NS_SPECIAL(ns) ((ns)==UTIME_NOW || (ns)==UTIME_OMIT) int utimensat(int fd, const char *path, const struct timespec times[2], int flags) { int r; if (times && tim...
src/stat/utimensat.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <stdlib.h> #include <sys/ioctl.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include "libc.h" FILE *__fdopen(int fd, const char *mode) { FILE *f; struct winsize wsz; /* Check for valid initial mode character */ if (!strchr("rwa", *mode)) { errno = EINVAL; retur...
src/stdio/__fdopen.c
null
null
null
null
null
source
musl
#include <fcntl.h> #include <string.h> int __fmodeflags(const char *mode) { int flags; if (strchr(mode, '+')) flags = O_RDWR; else if (*mode == 'r') flags = O_RDONLY; else flags = O_WRONLY; if (strchr(mode, 'x')) flags |= O_EXCL; if (strchr(mode, 'e')) flags |= O_CLOEXEC; if (*mode != 'r') flags |= O_CREAT; if...
src/stdio/__fmodeflags.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <fcntl.h> #include <string.h> FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len) { memset(f, 0, sizeof *f); f->fd = sys_open(filename, O_RDONLY|O_CLOEXEC); if (f->fd < 0) return 0; __syscall(SYS_fcntl, f->fd, F_SETFD, FD_CLOEXEC); f->flags = F_NOW...
src/stdio/__fopen_rb_ca.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "pthread_impl.h" int __lockfile(FILE *f) { int owner = f->lock, tid = __pthread_self()->tid; if ((owner & ~MAYBE_WAITERS) == tid) return 0; owner = a_cas(&f->lock, 0, tid); if (!owner) return 1; while ((owner = a_cas(&f->lock, 0, tid|MAYBE_WAITERS))) { if ((owner & MAYBE_WAITE...
src/stdio/__lockfile.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" int __overflow(FILE *f, int _c) { unsigned char c = _c; if (!f->wend && __towrite(f)) return EOF; if (f->wpos != f->wend && c != f->lbf) return *f->wpos++ = c; if (f->write(f, &c, 1)!=1) return EOF; return c; }
src/stdio/__overflow.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "aio_impl.h" static int dummy(int fd) { return fd; } weak_alias(dummy, __aio_close); int __stdio_close(FILE *f) { return syscall(SYS_close, __aio_close(f->fd)); }
src/stdio/__stdio_close.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" static FILE *volatile dummy_file = 0; weak_alias(dummy_file, __stdin_used); weak_alias(dummy_file, __stdout_used); weak_alias(dummy_file, __stderr_used); static void close_file(FILE *f) { if (!f) return; FFINALLOCK(f); if (f->wpos != f->wbase) f->write(f, 0, 0); if (f->rpos != f->rend) f->...
src/stdio/__stdio_exit.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <sys/uio.h> size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) { struct iovec iov[2] = { { .iov_base = buf, .iov_len = len - !!f->buf_size }, { .iov_base = f->buf, .iov_len = f->buf_size } }; ssize_t cnt; cnt = iov[0].iov_len ? syscall(SYS_readv, f->fd, iov, 2) : s...
src/stdio/__stdio_read.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <unistd.h> off_t __stdio_seek(FILE *f, off_t off, int whence) { return __lseek(f->fd, off, whence); }
src/stdio/__stdio_seek.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <sys/uio.h> size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) { struct iovec iovs[2] = { { .iov_base = f->wbase, .iov_len = f->wpos-f->wbase }, { .iov_base = (void *)buf, .iov_len = len } }; struct iovec *iov = iovs; size_t rem = iov[0].iov_len + iov[1].iov_le...
src/stdio/__stdio_write.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <sys/ioctl.h> size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) { struct winsize wsz; f->write = __stdio_write; if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz)) f->lbf = -1; return __stdio_write(f, buf, len); }
src/stdio/__stdout_write.c
null
null
null
null
null
source
musl
#include <stdio_impl.h> int __toread(FILE *f) { f->mode |= f->mode-1; if (f->wpos != f->wbase) f->write(f, 0, 0); f->wpos = f->wbase = f->wend = 0; if (f->flags & F_NORD) { f->flags |= F_ERR; return EOF; } f->rpos = f->rend = f->buf + f->buf_size; return (f->flags & F_EOF) ? EOF : 0; } hidden void __toread...
src/stdio/__toread.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" int __towrite(FILE *f) { f->mode |= f->mode-1; if (f->flags & F_NOWR) { f->flags |= F_ERR; return EOF; } /* Clear read buffer (easier than summoning nasal demons) */ f->rpos = f->rend = 0; /* Activate write through the buffer. */ f->wpos = f->wbase = f->buf; f->wend = f->buf + f->b...
src/stdio/__towrite.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" /* This function assumes it will never be called if there is already * data buffered for reading. */ int __uflow(FILE *f) { unsigned char c; if (!__toread(f) && f->read(f, &c, 1)==1) return c; return EOF; }
src/stdio/__uflow.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <stdio.h> #include <stdarg.h> int asprintf(char **s, const char *fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vasprintf(s, fmt, ap); va_end(ap); return ret; }
src/stdio/asprintf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" void clearerr(FILE *f) { FLOCK(f); f->flags &= ~(F_EOF|F_ERR); FUNLOCK(f); } weak_alias(clearerr, clearerr_unlocked);
src/stdio/clearerr.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int dprintf(int fd, const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vdprintf(fd, fmt, ap); va_end(ap); return ret; }
src/stdio/dprintf.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include "stdio_impl.h" #include <stdio_ext.h> void _flushlbf(void) { fflush(0); } int __fsetlocking(FILE *f, int type) { return 0; } int __fwriting(FILE *f) { return (f->flags & F_NORD) || f->wend; } int __freading(FILE *f) { return (f->flags & F_NOWR) || f->rend; } int __freadable(FILE *f...
src/stdio/ext.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <stdio_ext.h> size_t __freadahead(FILE *f) { return f->rend ? f->rend - f->rpos : 0; } const char *__freadptr(FILE *f, size_t *sizep) { if (f->rpos == f->rend) return 0; *sizep = f->rend - f->rpos; return (const char *)f->rpos; } void __freadptrinc(FILE *f, size_t inc) { f->rpos...
src/stdio/ext2.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <stdlib.h> static void dummy(FILE *f) { } weak_alias(dummy, __unlist_locked_file); int fclose(FILE *f) { int r; FLOCK(f); r = fflush(f); r |= f->close(f); FUNLOCK(f); /* Past this point, f is closed and any further explict access * to it is undefined. However, it still exis...
src/stdio/fclose.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #undef feof int feof(FILE *f) { FLOCK(f); int ret = !!(f->flags & F_EOF); FUNLOCK(f); return ret; } weak_alias(feof, feof_unlocked); weak_alias(feof, _IO_feof_unlocked);
src/stdio/feof.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #undef ferror int ferror(FILE *f) { FLOCK(f); int ret = !!(f->flags & F_ERR); FUNLOCK(f); return ret; } weak_alias(ferror, ferror_unlocked); weak_alias(ferror, _IO_ferror_unlocked);
src/stdio/ferror.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" /* stdout.c will override this if linked */ static FILE *volatile dummy = 0; weak_alias(dummy, __stdout_used); weak_alias(dummy, __stderr_used); int fflush(FILE *f) { if (!f) { int r = 0; if (__stdout_used) r |= fflush(__stdout_used); if (__stderr_used) r |= fflush(__stderr_used); fo...
src/stdio/fflush.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include "stdio_impl.h" #include <string.h> char *fgetln(FILE *f, size_t *plen) { char *ret = 0, *z; ssize_t l; FLOCK(f); ungetc(getc_unlocked(f), f); if (f->rend && (z=memchr(f->rpos, '\n', f->rend - f->rpos))) { ret = (char *)f->rpos; *plen = ++z - ret; f->rpos = (void *)z; } else if ...
src/stdio/fgetln.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" int fgetpos(FILE *restrict f, fpos_t *restrict pos) { off_t off = __ftello(f); if (off < 0) return -1; *(long long *)pos = off; return 0; }
src/stdio/fgetpos.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <string.h> #define MIN(a,b) ((a)<(b) ? (a) : (b)) char *fgets(char *restrict s, int n, FILE *restrict f) { char *p = s; unsigned char *z; size_t k; int c; FLOCK(f); if (n<=1) { f->mode |= f->mode-1; FUNLOCK(f); if (n<1) return 0; *s = 0; return s; } n--; while (n...
src/stdio/fgets.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "locale_impl.h" #include <wchar.h> #include <errno.h> static wint_t __fgetwc_unlocked_internal(FILE *f) { wchar_t wc; int c; size_t l; /* Convert character from buffer if possible */ if (f->rpos != f->rend) { l = mbtowc(&wc, (void *)f->rpos, f->rend - f->rpos); if (l+1 >= 1) ...
src/stdio/fgetwc.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <wchar.h> wint_t __fgetwc_unlocked(FILE *); wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f) { wchar_t *p = s; if (!n--) return s; FLOCK(f); for (; n; n--) { wint_t c = __fgetwc_unlocked(f); if (c == WEOF) break; *p++ = c; if (c == '\n') break; } *p = 0; ...
src/stdio/fgetws.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <errno.h> int fileno(FILE *f) { FLOCK(f); int fd = f->fd; FUNLOCK(f); if (fd < 0) { errno = EBADF; return -1; } return fd; } weak_alias(fileno, fileno_unlocked);
src/stdio/fileno.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "pthread_impl.h" void flockfile(FILE *f) { if (!ftrylockfile(f)) return; __lockfile(f); __register_locked_file(f, __pthread_self()); }
src/stdio/flockfile.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <errno.h> #include <string.h> #include <stdlib.h> #include <stddef.h> #include <inttypes.h> #include "libc.h" struct cookie { size_t pos, len, size; unsigned char *buf; int mode; }; struct mem_FILE { FILE f; struct cookie c; unsigned char buf[UNGET+BUFSIZ], buf2[]; }; static of...
src/stdio/fmemopen.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <fcntl.h> #include <string.h> #include <errno.h> FILE *fopen(const char *restrict filename, const char *restrict mode) { FILE *f; int fd; int flags; /* Check for valid initial mode character */ if (!strchr("rwa", *mode)) { errno = EINVAL; return 0; } /* Compute the flags t...
src/stdio/fopen.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include "stdio_impl.h" #include <stdlib.h> #include <sys/ioctl.h> #include <fcntl.h> #include <errno.h> #include <string.h> struct fcookie { void *cookie; cookie_io_functions_t iofuncs; }; struct cookie_FILE { FILE f; struct fcookie fc; unsigned char buf[UNGET+BUFSIZ]; }; static size_t cook...
src/stdio/fopencookie.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int fprintf(FILE *restrict f, const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vfprintf(f, fmt, ap); va_end(ap); return ret; }
src/stdio/fprintf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <string.h> int fputs(const char *restrict s, FILE *restrict f) { size_t l = strlen(s); return (fwrite(s, 1, l, f)==l) - 1; } weak_alias(fputs, fputs_unlocked);
src/stdio/fputs.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "locale_impl.h" #include <wchar.h> #include <limits.h> #include <ctype.h> wint_t __fputwc_unlocked(wchar_t c, FILE *f) { char mbc[MB_LEN_MAX]; int l; locale_t *ploc = &CURRENT_LOCALE, loc = *ploc; if (f->mode <= 0) fwide(f, 1); *ploc = f->locale; if (isascii(c)) { c = putc_un...
src/stdio/fputwc.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "locale_impl.h" #include <wchar.h> int fputws(const wchar_t *restrict ws, FILE *restrict f) { unsigned char buf[BUFSIZ]; size_t l=0; locale_t *ploc = &CURRENT_LOCALE, loc = *ploc; FLOCK(f); fwide(f, 1); *ploc = f->locale; while (ws && (l = wcsrtombs((void *)buf, (void*)&ws, s...
src/stdio/fputws.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <string.h> #define MIN(a,b) ((a)<(b) ? (a) : (b)) size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f) { unsigned char *dest = destv; size_t len = size*nmemb, l = len, k; if (!size) nmemb = 0; FLOCK(f); f->mode |= f->mode-1; if (f->rpos != f->rend) ...
src/stdio/fread.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <fcntl.h> #include <unistd.h> /* The basic idea of this implementation is to open a new FILE, * hack the necessary parts of the new FILE into the old one, then * close the new FILE. */ /* Locking IS necessary because another thread may provably hold the * lock, via flockfile or oth...
src/stdio/freopen.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int fscanf(FILE *restrict f, const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vfscanf(f, fmt, ap); va_end(ap); return ret; } weak_alias(fscanf, __isoc99_fscanf);
src/stdio/fscanf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <errno.h> int __fseeko_unlocked(FILE *f, off_t off, int whence) { /* Fail immediately for invalid whence argument. */ if (whence != SEEK_CUR && whence != SEEK_SET && whence != SEEK_END) { errno = EINVAL; return -1; } /* Adjust relative offset for unread data in buffer, if any....
src/stdio/fseek.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" int fsetpos(FILE *f, const fpos_t *pos) { return __fseeko(f, *(const long long *)pos, SEEK_SET); }
src/stdio/fsetpos.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <limits.h> #include <errno.h> off_t __ftello_unlocked(FILE *f) { off_t pos = f->seek(f, 0, (f->flags & F_APP) && f->wpos != f->wbase ? SEEK_END : SEEK_CUR); if (pos < 0) return pos; /* Adjust for data in buffer. */ if (f->rend) pos += f->rpos - f->rend; else if (f->wbase) ...
src/stdio/ftell.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "pthread_impl.h" #include <limits.h> void __do_orphaned_stdio_locks() { FILE *f; for (f=__pthread_self()->stdio_locks; f; f=f->next_locked) a_store(&f->lock, 0x40000000); } void __unlist_locked_file(FILE *f) { if (f->lockcount) { if (f->next_locked) f->next_locked->prev_locked ...
src/stdio/ftrylockfile.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "pthread_impl.h" void funlockfile(FILE *f) { if (f->lockcount == 1) { __unlist_locked_file(f); f->lockcount = 0; __unlockfile(f); } else { f->lockcount--; } }
src/stdio/funlockfile.c
null
null
null
null
null
source
musl
#include <wchar.h> #include "stdio_impl.h" #include "locale_impl.h" int fwide(FILE *f, int mode) { FLOCK(f); if (mode) { if (!f->locale) f->locale = MB_CUR_MAX==1 ? C_LOCALE : UTF8_LOCALE; if (!f->mode) f->mode = mode>0 ? 1 : -1; } mode = f->mode; FUNLOCK(f); return mode; }
src/stdio/fwide.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> #include <wchar.h> int fwprintf(FILE *restrict f, const wchar_t *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vfwprintf(f, fmt, ap); va_end(ap); return ret; }
src/stdio/fwprintf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <string.h> size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) { size_t i=0; if (!f->wend && __towrite(f)) return 0; if (l > f->wend - f->wpos) return f->write(f, s, l); if (f->lbf >= 0) { /* Match /^(.*\n|)/ */ for (i=l; i && s[i-1] != '\n'; i--); ...
src/stdio/fwrite.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> #include <wchar.h> int fwscanf(FILE *restrict f, const wchar_t *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vfwscanf(f, fmt, ap); va_end(ap); return ret; } weak_alias(fwscanf,__isoc99_fwscanf);
src/stdio/fwscanf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include "getc.h" int getc(FILE *f) { return do_getc(f); } weak_alias(getc, _IO_getc);
src/stdio/getc.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "pthread_impl.h" #ifdef __GNUC__ __attribute__((__noinline__)) #endif static int locking_getc(FILE *f) { if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); int c = getc_unlocked(f); if (a_swap(&f->lock, 0) & MAYBE_WAITERS) __wake(&f->lock, 1, 1); return c; } static inline i...
src/stdio/getc.h
null
null
null
null
null
source
musl
#include "stdio_impl.h" int (getc_unlocked)(FILE *f) { return getc_unlocked(f); } weak_alias (getc_unlocked, fgetc_unlocked); weak_alias (getc_unlocked, _IO_getc_unlocked);
src/stdio/getc_unlocked.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <string.h> #include <stdlib.h> #include <inttypes.h> #include <errno.h> ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restrict f) { char *tmp; unsigned char *z; size_t k; size_t i=0; int c; FLOCK(f); if (!n || !s) { f->mode |= f->mode-1; f->flags...
src/stdio/getdelim.c
null
null
null
null
null
source
musl
#include <stdio.h> ssize_t getline(char **restrict s, size_t *restrict n, FILE *restrict f) { return getdelim(s, n, '\n', f); }
src/stdio/getline.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <limits.h> #include <string.h> char *gets(char *s) { size_t i=0; int c; FLOCK(stdin); while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c; s[i] = 0; if (c != '\n' && (!feof(stdin) || !i)) s = 0; FUNLOCK(stdin); return s; }
src/stdio/gets.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <stdio.h> int getw(FILE *f) { int x; return fread(&x, sizeof x, 1, f) ? x : EOF; }
src/stdio/getw.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <wchar.h> wint_t getwchar(void) { return fgetwc(stdin); } weak_alias(getwchar, getwchar_unlocked);
src/stdio/getwchar.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "lock.h" #include "fork_impl.h" static FILE *ofl_head; static volatile int ofl_lock[1]; volatile int *const __stdio_ofl_lockptr = ofl_lock; FILE **__ofl_lock() { LOCK(ofl_lock); return &ofl_head; } void __ofl_unlock() { UNLOCK(ofl_lock); }
src/stdio/ofl.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" FILE *__ofl_add(FILE *f) { FILE **head = __ofl_lock(); f->next = *head; if (*head) (*head)->prev = f; *head = f; __ofl_unlock(); return f; }
src/stdio/ofl_add.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <errno.h> #include <limits.h> #include <string.h> #include <stdlib.h> #include "libc.h" struct cookie { char **bufp; size_t *sizep; size_t pos; char *buf; size_t len; size_t space; }; struct ms_FILE { FILE f; struct cookie c; unsigned char buf[BUFSIZ]; }; static off_t ms_see...
src/stdio/open_memstream.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <wchar.h> #include <errno.h> #include <limits.h> #include <string.h> #include <stdlib.h> #include "libc.h" struct cookie { wchar_t **bufp; size_t *sizep; size_t pos; wchar_t *buf; size_t len; size_t space; mbstate_t mbs; }; struct wms_FILE { FILE f; struct cookie c; unsigned...
src/stdio/open_wmemstream.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <errno.h> #include <unistd.h> int pclose(FILE *f) { int status, r; pid_t pid = f->pipe_pid; fclose(f); while ((r=__sys_wait4(pid, &status, 0, 0)) == -EINTR); if (r<0) return __syscall_ret(r); return status; }
src/stdio/pclose.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <string.h> #include <errno.h> #include "stdio_impl.h" void perror(const char *msg) { FILE *f = stderr; char *errstr = strerror(errno); FLOCK(f); /* Save stderr's orientation and encoding rule, since perror is not * permitted to change them. */ void *old_locale = f->locale; int old...
src/stdio/perror.c
null
null
null
null
null
source
musl
#include <fcntl.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <spawn.h> #include "stdio_impl.h" #include "syscall.h" extern char **__environ; FILE *popen(const char *cmd, const char *mode) { int p[2], op, e; pid_t pid; FILE *f; posix_spawn_file_actions_t fa; if (*mode == 'r') { op = 0...
src/stdio/popen.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int printf(const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vfprintf(stdout, fmt, ap); va_end(ap); return ret; }
src/stdio/printf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include "putc.h" int putc(int c, FILE *f) { return do_putc(c, f); } weak_alias(putc, _IO_putc);
src/stdio/putc.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "pthread_impl.h" #ifdef __GNUC__ __attribute__((__noinline__)) #endif static int locking_putc(int c, FILE *f) { if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); c = putc_unlocked(c, f); if (a_swap(&f->lock, 0) & MAYBE_WAITERS) __wake(&f->lock, 1, 1); return c; } static in...
src/stdio/putc.h
null
null
null
null
null
source
musl
#include "stdio_impl.h" int (putc_unlocked)(int c, FILE *f) { return putc_unlocked(c, f); } weak_alias(putc_unlocked, fputc_unlocked); weak_alias(putc_unlocked, _IO_putc_unlocked);
src/stdio/putc_unlocked.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" int puts(const char *s) { int r; FLOCK(stdout); r = -(fputs(s, stdout) < 0 || putc_unlocked('\n', stdout) < 0); FUNLOCK(stdout); return r; }
src/stdio/puts.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <stdio.h> int putw(int x, FILE *f) { return (int)fwrite(&x, sizeof x, 1, f)-1; }
src/stdio/putw.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <wchar.h> wint_t putwc(wchar_t c, FILE *f) { return fputwc(c, f); }
src/stdio/putwc.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <wchar.h> wint_t putwchar(wchar_t c) { return fputwc(c, stdout); } weak_alias(putwchar, putwchar_unlocked);
src/stdio/putwchar.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <errno.h> #include <fcntl.h> #include "syscall.h" int remove(const char *path) { #ifdef SYS_unlink int r = __syscall(SYS_unlink, path); #else int r = __syscall(SYS_unlinkat, AT_FDCWD, path, 0); #endif #ifdef SYS_rmdir if (r==-EISDIR) r = __syscall(SYS_rmdir, path); #else if (r==-EISDIR)...
src/stdio/remove.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <fcntl.h> #include "syscall.h" int rename(const char *old, const char *new) { #if defined(SYS_rename) return syscall(SYS_rename, old, new); #elif defined(SYS_renameat) return syscall(SYS_renameat, AT_FDCWD, old, AT_FDCWD, new); #else return syscall(SYS_renameat2, AT_FDCWD, old, AT_FDCWD,...
src/stdio/rename.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" void rewind(FILE *f) { FLOCK(f); __fseeko_unlocked(f, 0, SEEK_SET); f->flags &= ~F_ERR; FUNLOCK(f); }
src/stdio/rewind.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int scanf(const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vscanf(fmt, ap); va_end(ap); return ret; } weak_alias(scanf,__isoc99_scanf);
src/stdio/scanf.c
null
null
null
null
null
source
musl
#include <stdio.h> void setbuf(FILE *restrict f, char *restrict buf) { setvbuf(f, buf, buf ? _IOFBF : _IONBF, BUFSIZ); }
src/stdio/setbuf.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <stdio.h> void setbuffer(FILE *f, char *buf, size_t size) { setvbuf(f, buf, buf ? _IOFBF : _IONBF, size); }
src/stdio/setbuffer.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" /* The behavior of this function is undefined except when it is the first * operation on the stream, so the presence or absence of locking is not * observable in a program whose behavior is defined. Thus no locking is * performed here. No allocation of buffers is performed, but a buffer * p...
src/stdio/setvbuf.c
null
null
null
null
null