bfin: remove inline keyword
[xenomai-head.git] / src / testsuite / regression / native / heap.c
blob1c70dd22440555acfee9ad3ce1d129f95fc4dba6
1 /*
2 * Copyright (C) 2011-2012 Gilles Chanteperdrix <gch@xenomai.org>
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include <stdlib.h>
25 #include <stdio.h>
27 #include <sys/mman.h>
29 #include <native/task.h>
30 #include <native/heap.h>
32 #include "check.h"
34 #define HEAP_NAME "heap"
35 #define HEAP_SZ 16384
37 int main(void)
39 RT_TASK task;
40 RT_HEAP heap;
41 unsigned i;
42 void *mem;
44 mlockall(MCL_CURRENT | MCL_FUTURE);
46 fprintf(stderr, "Checking native skin shared heaps\n");
48 check_native(rt_task_shadow(&task, "task", 1, 0));
50 check_native(rt_heap_create(&heap, HEAP_NAME,
51 HEAP_SZ, H_PRIO | H_SHARED));
52 check_native(rt_heap_alloc(&heap, HEAP_SZ, TM_INFINITE, &mem));
53 memset(mem, 0xA5, HEAP_SZ);
55 for (i = 0; i < HEAP_SZ; i++)
56 if (((unsigned char *)mem)[i] != 0xA5) {
57 fprintf(stderr, "Test failed at byte %u\n", i);
58 rt_heap_delete(&heap);
59 exit(EXIT_FAILURE);
62 check_native(rt_heap_free(&heap, mem));
63 check_native(rt_heap_delete(&heap));
65 fprintf(stderr, "native skin shared heaps: success\n");
66 return EXIT_SUCCESS;