summaryrefslogtreecommitdiff
path: root/src/unistd
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-02-13 22:45:42 -0500
committerRich Felker <dalias@aerifal.cx>2011-02-13 22:45:42 -0500
commit2cdfb7ca26f46f151afbc23d5d94fc68597137f5 (patch)
tree0baa2cd0776f2a44997950e0bc8ab646dc2067b2 /src/unistd
parent978ca016593077d27cc2a828f21c5e45e57074aa (diff)
downloadmusl-2cdfb7ca26f46f151afbc23d5d94fc68597137f5.tar.gz
cleaning up syscalls in preparation for x86_64 port
- hide all the legacy xxxxxx32 name cruft in syscall.h so the actual source files can be clean and uniform across all archs. - cleanup llseek/lseek and mmap2/mmap handling for 32/64 bit systems - alternate implementation for nice if the target lacks nice syscall
Diffstat (limited to 'src/unistd')
-rw-r--r--src/unistd/chown.c2
-rw-r--r--src/unistd/fchown.c2
-rw-r--r--src/unistd/getegid.c2
-rw-r--r--src/unistd/geteuid.c2
-rw-r--r--src/unistd/getgid.c2
-rw-r--r--src/unistd/getgroups.c3
-rw-r--r--src/unistd/getuid.c2
-rw-r--r--src/unistd/lchown.c2
-rw-r--r--src/unistd/lseek.c13
-rw-r--r--src/unistd/nice.c5
-rw-r--r--src/unistd/setgid.c4
-rw-r--r--src/unistd/setregid.c4
-rw-r--r--src/unistd/setreuid.c4
-rw-r--r--src/unistd/setuid.c4
14 files changed, 27 insertions, 24 deletions
diff --git a/src/unistd/chown.c b/src/unistd/chown.c
index 6069a2fe..b89b1735 100644
--- a/src/unistd/chown.c
+++ b/src/unistd/chown.c
@@ -3,5 +3,5 @@
int chown(const char *path, uid_t uid, gid_t gid)
{
- return syscall3(__NR_chown32, (long)path, uid, gid);
+ return syscall3(__NR_chown, (long)path, uid, gid);
}
diff --git a/src/unistd/fchown.c b/src/unistd/fchown.c
index 990f006d..6050b774 100644
--- a/src/unistd/fchown.c
+++ b/src/unistd/fchown.c
@@ -3,5 +3,5 @@
int fchown(int fd, uid_t uid, gid_t gid)
{
- return syscall3(__NR_fchown32, fd, uid, gid);
+ return syscall3(__NR_fchown, fd, uid, gid);
}
diff --git a/src/unistd/getegid.c b/src/unistd/getegid.c
index 0e626b75..33ee2057 100644
--- a/src/unistd/getegid.c
+++ b/src/unistd/getegid.c
@@ -3,5 +3,5 @@
gid_t getegid(void)
{
- return syscall0(__NR_getegid32);
+ return syscall0(__NR_getegid);
}
diff --git a/src/unistd/geteuid.c b/src/unistd/geteuid.c
index 39d6ac7b..cdec631a 100644
--- a/src/unistd/geteuid.c
+++ b/src/unistd/geteuid.c
@@ -3,5 +3,5 @@
uid_t geteuid(void)
{
- return syscall0(__NR_geteuid32);
+ return syscall0(__NR_geteuid);
}
diff --git a/src/unistd/getgid.c b/src/unistd/getgid.c
index 186635a2..8a4590be 100644
--- a/src/unistd/getgid.c
+++ b/src/unistd/getgid.c
@@ -3,5 +3,5 @@
gid_t getgid(void)
{
- return syscall0(__NR_getgid32);
+ return syscall0(__NR_getgid);
}
diff --git a/src/unistd/getgroups.c b/src/unistd/getgroups.c
index 6f19870e..37619b9a 100644
--- a/src/unistd/getgroups.c
+++ b/src/unistd/getgroups.c
@@ -3,6 +3,5 @@
int getgroups(int count, gid_t list[])
{
- /* this depends on our gid_t being 32bit */
- return syscall2(__NR_getgroups32, count, (long)list);
+ return syscall2(__NR_getgroups, count, (long)list);
}
diff --git a/src/unistd/getuid.c b/src/unistd/getuid.c
index 9d4e53f5..cd7233d1 100644
--- a/src/unistd/getuid.c
+++ b/src/unistd/getuid.c
@@ -3,5 +3,5 @@
uid_t getuid(void)
{
- return syscall0(__NR_getuid32);
+ return syscall0(__NR_getuid);
}
diff --git a/src/unistd/lchown.c b/src/unistd/lchown.c
index 30e83916..a8402132 100644
--- a/src/unistd/lchown.c
+++ b/src/unistd/lchown.c
@@ -3,5 +3,5 @@
int lchown(const char *path, uid_t uid, gid_t gid)
{
- return syscall3(__NR_lchown32, (long)path, uid, gid);
+ return syscall3(__NR_lchown, (long)path, uid, gid);
}
diff --git a/src/unistd/lseek.c b/src/unistd/lseek.c
index 0dab2679..0152866f 100644
--- a/src/unistd/lseek.c
+++ b/src/unistd/lseek.c
@@ -4,13 +4,12 @@
off_t lseek(int fd, off_t offset, int whence)
{
- /* optimized away at compiletime */
- if (sizeof(long) == 8)
- return syscall3(__NR_lseek, fd, offset, whence);
- else {
- off_t result;
- return syscall5(__NR__llseek, fd, offset>>32, offset, (long)&result, whence) ? -1 : result;
- }
+#ifdef __NR__llseek
+ off_t result;
+ return syscall5(__NR__llseek, fd, offset>>32, offset, (long)&result, whence) ? -1 : result;
+#else
+ return syscall3(__NR_lseek, fd, offset, whence);
+#endif
}
LFS64(lseek);
diff --git a/src/unistd/nice.c b/src/unistd/nice.c
index 4b28ef41..f38db678 100644
--- a/src/unistd/nice.c
+++ b/src/unistd/nice.c
@@ -1,7 +1,12 @@
#include <unistd.h>
+#include <sys/resource.h>
#include "syscall.h"
int nice(int inc)
{
+#ifdef __NR_nice
return syscall1(__NR_nice, inc);
+#else
+ return setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS, 0)+inc);
+#endif
}
diff --git a/src/unistd/setgid.c b/src/unistd/setgid.c
index 00c7a03a..42976d95 100644
--- a/src/unistd/setgid.c
+++ b/src/unistd/setgid.c
@@ -4,6 +4,6 @@
int setgid(gid_t gid)
{
- if (libc.rsyscall) return libc.rsyscall(__NR_setgid32, gid, 0, 0, 0, 0, 0);
- return syscall1(__NR_setgid32, gid);
+ if (libc.rsyscall) return libc.rsyscall(__NR_setgid, gid, 0, 0, 0, 0, 0);
+ return syscall1(__NR_setgid, gid);
}
diff --git a/src/unistd/setregid.c b/src/unistd/setregid.c
index d25dab76..158753be 100644
--- a/src/unistd/setregid.c
+++ b/src/unistd/setregid.c
@@ -4,6 +4,6 @@
int setregid(gid_t rgid, gid_t egid)
{
- if (libc.rsyscall) return libc.rsyscall(__NR_setregid32, rgid, egid, 0, 0, 0, 0);
- return syscall2(__NR_setregid32, rgid, egid);
+ if (libc.rsyscall) return libc.rsyscall(__NR_setregid, rgid, egid, 0, 0, 0, 0);
+ return syscall2(__NR_setregid, rgid, egid);
}
diff --git a/src/unistd/setreuid.c b/src/unistd/setreuid.c
index 0ba2277b..47c67306 100644
--- a/src/unistd/setreuid.c
+++ b/src/unistd/setreuid.c
@@ -4,6 +4,6 @@
int setreuid(uid_t ruid, uid_t euid)
{
- if (libc.rsyscall) return libc.rsyscall(__NR_setreuid32, ruid, euid, 0, 0, 0, 0);
- return syscall2(__NR_setreuid32, ruid, euid);
+ if (libc.rsyscall) return libc.rsyscall(__NR_setreuid, ruid, euid, 0, 0, 0, 0);
+ return syscall2(__NR_setreuid, ruid, euid);
}
diff --git a/src/unistd/setuid.c b/src/unistd/setuid.c
index 53b74d88..9e9da61f 100644
--- a/src/unistd/setuid.c
+++ b/src/unistd/setuid.c
@@ -4,6 +4,6 @@
int setuid(uid_t uid)
{
- if (libc.rsyscall) return libc.rsyscall(__NR_setuid32, uid, 0, 0, 0, 0, 0);
- return syscall1(__NR_setuid32, uid);
+ if (libc.rsyscall) return libc.rsyscall(__NR_setuid, uid, 0, 0, 0, 0, 0);
+ return syscall1(__NR_setuid, uid);
}