/* [<][>][^][v][top][bottom][index][help] */
1 /*****************************************************************************
2 * Copyright (C) 2014 Kapil Arya <kapil@ccs.neu.edu> *
3 * Copyright (C) 2014 Gene Cooperman <gene@ccs.neu.edu> *
4 * *
5 * DMTCP is free software: you can redistribute it and/or *
6 * modify it under the terms of the GNU Lesser General Public License as *
7 * published by the Free Software Foundation, either version 3 of the *
8 * License, or (at your option) any later version. *
9 * *
10 * DMTCP is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU Lesser General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with DMTCP. If not, see <http://www.gnu.org/licenses/>. *
17 *****************************************************************************/
18
19 #ifndef LDT_H
20 #define LDT_H
21 #include <linux/version.h>
22 // ARM is missing asm/ldt.h in Ubuntu 11.10 (Linux 3.0, glibc-2.13)
23 #if defined(__arm__) || defined(__aarch64__)
24 /* Structure passed to `modify_ldt', 'set_thread_area', and 'clone' calls.
25 This seems to have been stable since the beginning of Linux 2.6 */
26 struct user_desc
27 {
28 unsigned int entry_number;
29 unsigned long int base_addr;
30 unsigned int limit;
31 unsigned int seg_32bit:1;
32 unsigned int contents:2;
33 unsigned int read_exec_only:1;
34 unsigned int limit_in_pages:1;
35 unsigned int seg_not_present:1;
36 unsigned int useable:1;
37 unsigned int empty:25; /* Some variations leave this out. */
38 };
39 #else
40 // Defines struct user_desc
41 # include <asm/ldt.h>
42 // WARNING: /usr/include/linux/version.h often has out-of-date version.
43 /* struct user_desc * uinfo; */
44 /* In Linux 2.6.9 for i386, uinfo->base_addr is
45 * correctly typed as unsigned long int.
46 * In Linux 2.6.9, uinfo->base_addr is incorrectly typed as
47 * unsigned int. So, we'll just lie about the type.
48 */
49 /* SuSE Linux Enterprise Server 9 uses Linux 2.6.5 and requires original
50 * struct user_desc from /usr/include/.../ldt.h
51 * Perhaps kernel was patched by backport. Let's not re-define user_desc.
52 */
53 /* RHEL 4 (Update 3) / Rocks 4.1.1-2.0 has <linux/version.h> saying
54 * LINUX_VERSION_CODE is 2.4.20 (and UTS_RELEASE=2.4.20)
55 * while uname -r says 2.6.9-34.ELsmp. Here, it acts like a version earlier
56 * than the above 2.6.9. So, we conditionalize on its 2.4.20 version.
57 */
58 # if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
59 /* struct modify_ldt_ldt_s was defined instead of struct user_desc */
60 # define user_desc modify_ldt_ldt_s
61 # endif
62 #endif
63
64 #endif