summaryrefslogtreecommitdiff
path: root/lockme.h
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-04 00:04:15 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-06-04 00:04:15 +0200
commit9e4cf71371187927a6eb7cc4fe32b67d58a93010 (patch)
tree063ebd26cfc7b50212a2c8069cf702fb9b4b8708 /lockme.h
parent8bb67e4e60d1c0d9fba66c1b28e62e4d92d8d4ce (diff)
xutils: break out string handling and locking
Break out all string handling functions and lockme stuff in order to further eliminate the big code blob in xutils, so that it can be easier maintained. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'lockme.h')
-rw-r--r--lockme.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/lockme.h b/lockme.h
new file mode 100644
index 0000000..7cce97b
--- /dev/null
+++ b/lockme.h
@@ -0,0 +1,19 @@
+#ifndef LOCKME_H
+#define LOCKME_H
+
+#include <sys/mman.h>
+
+#include "die.h"
+
+static inline void xlockme(void)
+{
+ if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0)
+ panic("Cannot lock pages!\n");
+}
+
+static inline void xunlockme(void)
+{
+ munlockall();
+}
+
+#endif /* LOCKME_H */