-
Notifications
You must be signed in to change notification settings - Fork 0
/
segment.h
72 lines (61 loc) · 2.13 KB
/
segment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* memtoy: segment.h - memory segments interface
*/
/*
* Copyright (c) 2005,2006,2007 Hewlett-Packard, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _MEMTOY_SEGMENT_H_
#define _MEMTOY_SEGMENT_H_
#include <sys/shm.h> /* need SHM_HUGETLB */
/*
* a "memory segment" known to memtoy
*/
typedef enum {
SEGT_NONE=0, /* unused segment */
SEGT_ANON=1, /* anonymous -- MAP_ANON */
SEGT_FILE=2,
SEGT_SHM=3,
SEGT_NTYPES
} seg_type_t;
#define SEGF_MAPS 0x80000000 /* segment from /proc/<mypid>/maps */
#define MEMTOY_MAP_HUGE SHM_HUGETLB
struct segment;
typedef struct segment segment_t;
/*
* range: optional (offset, length) arguments
*/
typedef struct range {
off_t offset;
size_t length;
void *start; /* for task image segments */
} range_t;
#define DEFAULT_LENGTH (size_t)(-1)
struct global_context;
extern void segment_init(struct global_context *);
extern void segment_cleanup(struct global_context *);
extern int segment_register(seg_type_t, char*, range_t*, int);
extern int segment_show(char*);
extern int segment_remove(char*);
extern int segment_map(char*, range_t*, int);
extern int segment_unmap(char*);
extern int segment_touch(char*, range_t*, int);
extern int segment_mbind(char*, range_t*, int, nodemask_t*, int);
extern int segment_location(char*, range_t*);
extern int segment_lock_unlock(char*, range_t*, int, int);
extern range_t* segment_range(char *segname, range_t *ret);
extern int segment_mprotect(char *segname, int prot);
#endif