mirror of
https://github.com/fluencelabs/musl
synced 2025-06-25 04:31:56 +00:00
global cleanup to use the new syscall interface
This commit is contained in:
@ -20,8 +20,8 @@ FILE *__fdopen(int fd, const char *mode)
|
||||
|
||||
/* Set append mode on fd if opened for append */
|
||||
if (*mode == 'a') {
|
||||
int flags = __syscall_fcntl(fd, F_GETFL, 0);
|
||||
__syscall_fcntl(fd, F_SETFL, flags | O_APPEND);
|
||||
int flags = syscall(SYS_fcntl, fd, F_GETFL, 0);
|
||||
syscall(SYS_fcntl, fd, F_SETFL, flags | O_APPEND);
|
||||
}
|
||||
|
||||
f->fd = fd;
|
||||
@ -30,7 +30,7 @@ FILE *__fdopen(int fd, const char *mode)
|
||||
|
||||
/* Activate line buffered mode for terminals */
|
||||
f->lbf = EOF;
|
||||
if (!(f->flags & F_NOWR) && !__syscall_ioctl(fd, TCGETS, &tio))
|
||||
if (!(f->flags & F_NOWR) && !syscall(SYS_ioctl, fd, TCGETS, &tio))
|
||||
f->lbf = '\n';
|
||||
|
||||
/* Initialize op ptrs. No problem if some are unneeded. */
|
||||
|
@ -4,7 +4,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le
|
||||
{
|
||||
memset(f, 0, sizeof *f);
|
||||
|
||||
f->fd = __syscall_open(filename, O_RDONLY, 0);
|
||||
f->fd = syscall(SYS_open, filename, O_RDONLY|O_LARGEFILE, 0);
|
||||
if (f->fd < 0) return 0;
|
||||
|
||||
f->flags = F_NOWR | F_PERM;
|
||||
|
@ -13,7 +13,7 @@ void __lockfile(FILE *f)
|
||||
spins = 100000;
|
||||
while (a_swap(&f->lock, 1))
|
||||
if (spins) spins--, a_spin();
|
||||
else syscall0(__NR_sched_yield);
|
||||
else syscall(SYS_sched_yield);
|
||||
f->owner = __pthread_self()->tid;
|
||||
f->lockcount = 1;
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
int __stdio_close(FILE *f)
|
||||
{
|
||||
return __syscall_close(f->fd);
|
||||
return syscall(SYS_close, f->fd);
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
size_t __stdio_read(FILE *f, unsigned char *buf, size_t len)
|
||||
{
|
||||
return __syscall_read(f->fd, buf, len);
|
||||
return syscall(SYS_read, f->fd, buf, len);
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ static off_t retneg1(FILE *f, off_t off, int whence)
|
||||
off_t __stdio_seek(FILE *f, off_t off, int whence)
|
||||
{
|
||||
off_t ret;
|
||||
#ifdef __NR__llseek
|
||||
if (syscall5(__NR__llseek, f->fd, off>>32, off, (long)&ret, whence)<0)
|
||||
#ifdef SYS__llseek
|
||||
if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0)
|
||||
ret = -1;
|
||||
#else
|
||||
ret = syscall3(__NR_lseek, f->fd, off, whence);
|
||||
ret = syscall(SYS_lseek, f->fd, off, whence);
|
||||
#endif
|
||||
/* Detect unseekable files and optimize future failures out */
|
||||
if (ret < 0 && off == 0 && whence == SEEK_CUR)
|
||||
|
@ -4,6 +4,6 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
|
||||
{
|
||||
const unsigned char *stop = buf+len;
|
||||
ssize_t cnt = 1;
|
||||
for (; buf<stop && (cnt=__syscall_write(f->fd, buf, len))>0; buf+=cnt);
|
||||
for (; buf<stop && (cnt=syscall(SYS_write, f->fd, buf, len))>0; buf+=cnt);
|
||||
return len-(stop-buf);
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ FILE *fopen(const char *filename, const char *mode)
|
||||
if (*mode == 'w') flags |= O_TRUNC;
|
||||
if (*mode == 'a') flags |= O_APPEND;
|
||||
|
||||
fd = __syscall_open(filename, flags, 0666);
|
||||
fd = syscall(SYS_open, filename, flags|O_LARGEFILE, 0666);
|
||||
if (fd < 0) return 0;
|
||||
|
||||
f = __fdopen(fd, mode);
|
||||
if (f) return f;
|
||||
|
||||
__syscall_close(fd);
|
||||
syscall(SYS_close, fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,13 @@ FILE *freopen(const char *filename, const char *mode, FILE *f)
|
||||
if (!filename) {
|
||||
f2 = fopen("/dev/null", mode);
|
||||
if (!f2) goto fail;
|
||||
fl = __syscall_fcntl(f2->fd, F_GETFL, 0);
|
||||
if (fl < 0 || __syscall_fcntl(f->fd, F_SETFL, fl) < 0)
|
||||
fl = syscall(SYS_fcntl, f2->fd, F_GETFL, 0);
|
||||
if (fl < 0 || syscall(SYS_fcntl, f->fd, F_SETFL, fl) < 0)
|
||||
goto fail2;
|
||||
} else {
|
||||
f2 = fopen(filename, mode);
|
||||
if (!f2) goto fail;
|
||||
if (__syscall_dup2(f2->fd, f->fd) < 0)
|
||||
if (syscall(SYS_dup2, f2->fd, f->fd) < 0)
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
int remove(const char *path)
|
||||
{
|
||||
return __syscall_unlink(path);
|
||||
return syscall(SYS_unlink, path);
|
||||
}
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
int rename(const char *old, const char *new)
|
||||
{
|
||||
return syscall2(__NR_rename, (long)old, (long)new);
|
||||
return syscall(SYS_rename, old, new);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ FILE *tmpfile(void)
|
||||
for (;;) {
|
||||
s = tmpnam(buf);
|
||||
if (!s) return NULL;
|
||||
fd = __syscall_open(s, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
fd = syscall(SYS_open, s, O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600);
|
||||
if (fd >= 0) {
|
||||
f = __fdopen(fd, "w+");
|
||||
remove(s);
|
||||
|
Reference in New Issue
Block a user