• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *
4  *   Copyright (c) International Business Machines Corp., 2001
5  */
6 
7 /*
8  * hugetlb.h - common definitions for the hugepage tests
9  */
10 
11 #ifndef __HUGETLB_H
12 #define __HUGETLB_H
13 
14 #include <stdlib.h>
15 #include <sys/ipc.h>
16 #include <sys/shm.h>
17 #include <errno.h>
18 #include <sys/wait.h>
19 #include "tst_test.h"
20 #include "old_tmpdir.h"
21 #include "mem.h"
22 
23 #define PALIGN(p, a) ((void *)LTP_ALIGN((unsigned long)(p), (a)))
24 
25 #define SHM_RD	0400
26 #define SHM_WR	0200
27 #define SHM_RW	(SHM_RD|SHM_WR)
28 
29 #ifndef SHM_HUGETLB
30 #define SHM_HUGETLB	04000	/* segment is mapped via hugetlb */
31 #endif
32 
33 #ifndef barrier
34 # ifdef mb
35 	/* Redefining the mb() */
36 #   define barrier() mb()
37 # else
38 #   define barrier() __asm__ __volatile__ ("" : : : "memory")
39 # endif
40 #endif
41 
42 /*
43  * to get the lower nine permission bits
44  * from shmid_ds.ipc_perm.mode
45  */
46 #define MODE_MASK	0x01FF
47 
48 extern key_t shmkey;			/* an IPC key generated by ftok() */
49 
50 int getipckey(void);
51 int getuserid(char *user);
52 void rm_shm(int shm_id);
53 int do_readback(void *p, size_t size, char *desc);
54 #endif /* hugetlb.h */
55