aboutsummaryrefslogtreecommitdiffstats
path: root/elff/elff-common.h
diff options
context:
space:
mode:
Diffstat (limited to 'elff/elff-common.h')
-rw-r--r--elff/elff-common.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/elff/elff-common.h b/elff/elff-common.h
new file mode 100644
index 0000000..922de10
--- /dev/null
+++ b/elff/elff-common.h
@@ -0,0 +1,59 @@
+/* Copyright (C) 2007-2010 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** 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.
+*/
+
+/*
+ * Includes common headers for the ELFF library.
+ */
+
+#ifndef ELFF_ELFF_COMMON_H_
+#define ELFF_ELFF_COMMON_H_
+
+#include "stddef.h"
+#include "sys/types.h"
+#include "assert.h"
+#include "memory.h"
+#include "errno.h"
+#ifdef WIN32
+#include "Windows.h"
+#else // WIN32
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#endif // WIN32
+
+static inline void _set_errno(uint32_t err) {
+ errno = err;
+}
+
+/* Main operator new. We overwrite it to redirect memory
+ * allocations to qemu_malloc, instead of malloc. */
+inline void* operator new(size_t size) {
+ return qemu_malloc(size);
+}
+
+/* Main operator delete. We overwrite it to redirect memory
+ * deallocation to qemu_free, instead of free. */
+inline void operator delete(void* p) {
+ if (p != NULL) {
+ qemu_free(p);
+ }
+}
+
+/* Main operator delete for arrays. We overwrite it to redirect
+ * memory deallocation to qemu_free, instead of free. */
+inline void operator delete[](void* p) {
+ if (p != NULL) {
+ qemu_free(p);
+ }
+}
+
+#endif // ELFF_ELFF_COMMON_H_