[RISCV] Add RVVConstraint to SiFive custom matrix multiply instructions. (#124055)
[llvm-project.git] / compiler-rt / test / asan / TestCases / Posix / mapped_mem_interceptors.c
blob2df40fafbe7fad0fb73235442034e7c648d7c59a
1 // Test for mmap/munmap interceptors.
2 // RUN: %clang_asan %s -o %t
3 // RUN: %run %t 2>&1
5 #include <assert.h>
6 #include <sanitizer/asan_interface.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <sys/mman.h>
11 int main(int argc, char **argv) {
12 int size = 4096;
13 int val = 42;
15 // Get any mmaped pointer.
16 void *r =
17 mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
18 assert(r != MAP_FAILED);
20 // Make sure the memory is unpoisoned.
21 if (__asan_region_is_poisoned(r, size) != 0) {
22 fprintf(stderr, "Memory returned by mmap should be unpoisoned.\n");
23 abort();
26 // First munmmap and then mmap the same pointer using MAP_FIXED.
27 __asan_poison_memory_region(r, size);
28 munmap(r, size);
29 if (__asan_region_is_poisoned(r, size) != 0) {
30 fprintf(stderr, "Shadow memory was not cleaned by munmap.\n");
31 abort();
33 __asan_poison_memory_region(r, size);
34 void *p = mmap(r, size, PROT_READ | PROT_WRITE,
35 MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
36 assert(r == p);
38 // Make sure the memory is unpoisoned.
39 if (__asan_region_is_poisoned(r, size) != 0) {
40 fprintf(stderr, "Memory returned by mmap should be unpoisoned.\n");
41 abort();
44 return 0;