Merge codemem functions into one source file
authorDavid Schleef <ds@schleef.org>
Fri, 13 Mar 2009 05:30:57 +0000 (22:30 -0700)
committerDavid Schleef <ds@schleef.org>
Fri, 13 Mar 2009 05:30:57 +0000 (22:30 -0700)
configure.ac
orc/Makefile.am
orc/orccodemem.c [moved from orc/orcprogram-linux.c with 78% similarity]
orc/orcprogram-win32.c [deleted file]

index f4a3004..2e84683 100644 (file)
@@ -88,16 +88,15 @@ fi
 
 case "${host_os}" in
   mingw*|cygwin*)
-    CODEMEM_BACKEND=win32
+    AC_DEFINE(HAVE_CODEMEM_MALLOC, 1, [Use malloc to allocate code for execution])
     ;;
   linux*|darwin*|solaris*|netbsd*|freebsd*|openbsd*)
-    CODEMEM_BACKEND=linux
+    AC_DEFINE(HAVE_CODEMEM_MMAP, 1, [Use mmap to allocate code for execution])
     ;;
   *)
     AC_ERROR([no code allocation backend])
     ;;
 esac
-AC_SUBST(CODEMEM_BACKEND)
 
 AC_DEFINE(ORC_EXPORTS, 1, [Defined for compiling internal code])
 
index 12315b5..e5a410e 100644 (file)
@@ -12,6 +12,7 @@ liborc_@ORC_MAJORMINOR@_la_SOURCES = \
        orc.c \
        orcexecutor.c \
        orcrule.c \
+       orccodemem.c \
        orcprogram.c \
        orcprogram-arm.c \
        orcprogram-c.c \
@@ -28,8 +29,6 @@ liborc_@ORC_MAJORMINOR@_la_SOURCES = \
        x86.c \
        arm.c
 
-liborc_@ORC_MAJORMINOR@_la_SOURCES += orcprogram-@CODEMEM_BACKEND@.c
-
 if HAVE_I386
 liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-x86.c
 else
similarity index 78%
rename from orc/orcprogram-linux.c
rename to orc/orccodemem.c
index 2a4fc14..f9fc028 100644 (file)
@@ -15,6 +15,7 @@
 #define SIZE 65536
 
 
+#ifdef HAVE_CODEMEM_MMAP
 void
 orc_program_allocate_codemem (OrcProgram *program)
 {
@@ -53,4 +54,18 @@ orc_program_allocate_codemem (OrcProgram *program)
   program->code_size = SIZE;
   program->codeptr = program->code;
 }
+#endif
+
+#ifdef HAVE_CODEMEM_MALLOC
+void
+orc_program_allocate_codemem (OrcProgram *program)
+{
+  /* Now you know why Windows has viruses */
+
+  program->code = malloc(SIZE);
+  program->code_exec = program->code;
+  program->code_size = SIZE;
+  program->codeptr = program->code;
+}
+#endif
 
diff --git a/orc/orcprogram-win32.c b/orc/orcprogram-win32.c
deleted file mode 100644 (file)
index 5f7445a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <orc/orcprogram.h>
-
-#define SIZE 65536
-
-
-void
-orc_program_allocate_codemem (OrcProgram *program)
-{
-  /* Now you know why Windows has viruses */
-
-  program->code = malloc(SIZE);
-  program->code_exec = program->code;
-  program->code_size = SIZE;
-  program->codeptr = program->code;
-}
-