summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Orth <ro@gcc.gnu.org>2019-10-22 08:44:25 +0000
committerRainer Orth <ro@gcc.gnu.org>2019-10-22 08:44:25 +0000
commit69445f095c22aac2388f939bedebf224a6efcdaf (patch)
tree8f09fc70cd4ef32613368c9ae3759cccc04b490b
parent59231e5aff254f28b7ea7bcfd32cd759511d5844 (diff)
downloadcompiler-rt-69445f095c22aac2388f939bedebf224a6efcdaf.tar.gz
[builtins][test] Avoid unportable mmap call in clear_cache_test.cHEADmaster
Within the last two weeks, the Builtins-*-sunos :: clear_cache_test.c started to FAIL on Solaris. Running it under truss shows mmap(0x00000000, 128, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 0, 0) Err#22 EINVAL _exit(1) While there are several possible reasons mmap can return EINVAL on Solaris, it turns out it's this one (from mmap(2)): MAP_ANON was specified, but the file descriptor was not -1. And indeed even the Linux mmap(2) documents this as unportable: MAP_ANONYMOUS The mapping is not backed by any file; its contents are initial‐ ized to zero. The fd argument is ignored; however, some imple‐ mentations require fd to be -1 if MAP_ANONYMOUS (or MAP_ANON) is specified, and portable applications should ensure this. The This patch follows this advise. Tested on x86_64-pc-linux-gnu, amd64-pc-solaris2.11 and sparcv9-sun-solaris2.11. Differential Revision: https://reviews.llvm.org/D68455 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@375490 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/builtins/Unit/clear_cache_test.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/builtins/Unit/clear_cache_test.c b/test/builtins/Unit/clear_cache_test.c
index 1713bec93..bc7b00608 100644
--- a/test/builtins/Unit/clear_cache_test.c
+++ b/test/builtins/Unit/clear_cache_test.c
@@ -49,7 +49,7 @@ int main()
#if !defined(_WIN32)
uint8_t *execution_buffer = mmap(0, kSize,
PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_ANON | MAP_PRIVATE, 0, 0);
+ MAP_ANON | MAP_PRIVATE, -1, 0);
if (execution_buffer == MAP_FAILED)
return 1;
#else