syscall(3)'s return type should be long.
This doesn't require us to change any of the syscall implementations
because (a) the LP32 ones have sizeof(int) == sizeof(long) anyway,
which is how we never noticed this bug before and (b) the LP64 ones
all use a 64-bit register for the result (and for the syscall number
too).
Bug: https://code.google.com/p/android/issues/detail?id=73952
Bug: 16568314
(cherry picked from commit 21972b61ec
)
Change-Id: Ifbc424be29e5650ec72a24df25dd35f24fdd5b3c
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int syscall(int number, ...);
|
||||
long syscall(long number, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
@@ -212,6 +213,14 @@ TEST(unistd, read_EBADF) {
|
||||
ASSERT_EQ(EBADF, errno);
|
||||
}
|
||||
|
||||
TEST(unistd, syscall_long) {
|
||||
// Check that syscall(3) correctly returns long results.
|
||||
// https://code.google.com/p/android/issues/detail?id=73952
|
||||
// We assume that the break is > 4GiB, but this is potentially flaky.
|
||||
uintptr_t p = reinterpret_cast<uintptr_t>(sbrk(0));
|
||||
ASSERT_EQ(p, static_cast<uintptr_t>(syscall(__NR_brk, 0)));
|
||||
}
|
||||
|
||||
TEST(unistd, alarm) {
|
||||
ASSERT_EQ(0U, alarm(0));
|
||||
}
|
||||
|
Reference in New Issue
Block a user