cinvoke-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cinvoke-svn] r21 - in trunk/cinvoke: lib/arch test


From: will
Subject: [cinvoke-svn] r21 - in trunk/cinvoke: lib/arch test
Date: 15 Jun 2006 00:24:10 -0400

Author: will
Date: 2006-06-15 00:24:09 -0400 (Thu, 15 Jun 2006)
New Revision: 21

Added:
   trunk/cinvoke/lib/arch/gcc_x86_unix.c
   trunk/cinvoke/lib/arch/gcc_x86_unix.h
Removed:
   trunk/cinvoke/lib/arch/gcc_x86_linux.c
   trunk/cinvoke/lib/arch/gcc_x86_linux.h
Modified:
   trunk/cinvoke/test/Makefile
Log:
more freebsd fixes


Deleted: trunk/cinvoke/lib/arch/gcc_x86_linux.c
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x86_linux.c      2006-06-15 04:14:47 UTC (rev 20)
+++ trunk/cinvoke/lib/arch/gcc_x86_linux.c      2006-06-15 04:24:09 UTC (rev 21)
@@ -1,215 +0,0 @@
-/*
-C/Invoke Source Code File
-
-Copyright (c) 2006 Will Weisser
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-   1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-   2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-   3. The name of the author may not be used to endorse or promote products
-derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-*/
-#include "cinvoke.h"
-#include "cinvoke-private.h"
-
-#include <dlfcn.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-void arch_free_errstr(char *str) {}
-
-cinv_status_t arch_library_create(CInvContext *context, const char *path,
-       ArchLibrary *library_out) {
-       void *dl = dlopen(path, RTLD_LAZY);
-       if (!dl) {
-               context_set_error(context, -1, (char*)dlerror(), 0);
-               return CINV_ERROR;
-       }
-               
-       library_out->dl = dl;
-
-       context_clear_error(context);
-       return CINV_SUCCESS;
-}
-cinv_status_t arch_library_get_entrypoint(CInvContext *context,
-       ArchLibrary *library, const char *name, void **entrypoint_out) {
-       void *sym = dlsym(library->dl, name);
-       if (!sym) {
-               context_set_error(context, -1, (char*)dlerror(), 0);
-               return CINV_ERROR;
-       }
-
-       *entrypoint_out = sym;
-
-       context_clear_error(context);
-       return CINV_SUCCESS;
-}
-cinv_status_t arch_library_delete(CInvContext *context, ArchLibrary *library) {
-       if (dlclose(library->dl)) {
-               context_set_error(context, -1, (char*)dlerror(), 0);
-               return CINV_ERROR;
-       }
-
-       context_clear_error(context);
-       return CINV_SUCCESS;
-}
-
-const static int LEN = 4096;
-
-char *arch_callback_stub(void *functionp, void *param,
-       short stacksize, cinv_callconv_t cc) {
-#if defined (__linux__)
-       char *ret = mmap(0, LEN, PROT_EXEC|PROT_READ|PROT_WRITE,
-               MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-#else
-       char *ret = mmap(0, LEN, PROT_EXEC|PROT_READ|PROT_WRITE,
-               MAP_ANON|MAP_PRIVATE, -1, 0);
-#endif
-       if (ret == MAP_FAILED)
-               return NULL;
-       
-       // void f() { ((void (*)(void *))0xAAAAAAAA)((void *)0xBBBBBBBB); }
-       memcpy(ret,
-               "\x55\x89\xe5\x83\xec\x08\x83\xec\x0c\x68"
-               "\xbb\xbb\xbb\xbb\xb8\xaa\xaa\xaa\xaa\xff"
-               "\xd0\x83\xc4\x10\xc9\xc3",
-               26);
-
-       memcpy(ret + 10, &param, 4);
-       memcpy(ret + 15, &functionp, 4);
-       
-       return ret;
-}
-void arch_free_stub(char *stub) {
-       munmap(stub, LEN);
-}
-
-int arch_is_register_parm(cinv_callconv_t callingconvention, int index,
-       int num_params, cinv_type_t types[]) { return 0; }
-void arch_set_register_parms(ArchRegParms *regparms, 
-       cinv_callconv_t callingconvention, int num_params, void *parameters[], 
-       cinv_type_t types[]) {}
-void arch_get_register_parms(ArchRegParms *regparms,
-       cinv_callconv_t callingconvention, int num_params, void 
*parameters_out[],
-       cinv_type_t types[]) {}
-
-void arch_getval_char(ArchRetValue *archval, char *outval) {
-       *outval = archval->ivallow;
-}
-void arch_getval_short(ArchRetValue *archval, short *outval) {
-       *outval = archval->ivallow;
-}
-void arch_getval_int(ArchRetValue *archval, int *outval) {
-       *outval = archval->ivallow;
-}
-void arch_getval_long(ArchRetValue *archval, long int *outval) {
-       *outval = archval->ivallow;
-}
-void arch_getval_extralong(ArchRetValue *archval, long long int *outval) {
-       *outval = archval->ivalhigh;
-       *outval <<= 32;
-       *outval |= archval->ivallow;
-}
-void arch_getval_float(ArchRetValue *archval, float *outval) {
-       *outval = (float)archval->dval;
-}
-void arch_getval_double(ArchRetValue *archval, double *outval) {
-       *outval = archval->dval;
-}
-void arch_getval_ptr(ArchRetValue *archval, void **outval) {
-       *outval = (void *)archval->ivallow;
-}
-
-void arch_setval_char(ArchRetValue *archval, char val) {
-       archval->ivallow = val;
-}
-void arch_setval_short(ArchRetValue *archval, short val) {
-       archval->ivallow = val;
-}
-void arch_setval_int(ArchRetValue *archval, int val) {
-       archval->ivallow = val;
-}
-void arch_setval_long(ArchRetValue *archval, long int val) {
-       archval->ivallow = val;
-}
-void arch_setval_extralong(ArchRetValue *archval, long long int val) {
-       archval->ivalhigh = (val >> 32);
-       archval->ivallow = val;
-}
-void arch_setval_float(ArchRetValue *archval, float val) {
-       archval->dval = val;
-}
-void arch_setval_double(ArchRetValue *archval, double val) {
-       archval->dval = val;
-}
-void arch_setval_ptr(ArchRetValue *archval, void *val) {
-       archval->ivallow = (int)val;
-}
-
-void arch_size_char(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 4;
-       *structsize_out = 1;
-}
-void arch_size_short(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 4;
-       *structsize_out = 2;
-       *structalign_out = 2;
-}
-void arch_size_int(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 4;
-       *structsize_out = 4;
-       *structalign_out = 4;
-}
-void arch_size_long(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 4;
-       *structsize_out = 4;
-       *structalign_out = 4;
-}
-void arch_size_extralong(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 8;
-       *structsize_out = 8;
-       *structalign_out = 4;
-}
-void arch_size_float(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 4;
-       *structsize_out = 4;
-       *structalign_out = 4;
-}
-void arch_size_double(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 8;
-       *structsize_out = 8;
-       *structalign_out = 4;
-}
-void arch_size_ptr(int *stacksize_out, int *structsize_out,
-       int *stackalign_out, int *structalign_out) {
-       *stacksize_out = 4;
-       *structsize_out = 4;
-       *structalign_out = 4;
-}

Deleted: trunk/cinvoke/lib/arch/gcc_x86_linux.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x86_linux.h      2006-06-15 04:14:47 UTC (rev 20)
+++ trunk/cinvoke/lib/arch/gcc_x86_linux.h      2006-06-15 04:24:09 UTC (rev 21)
@@ -1,100 +0,0 @@
-/*
-C/Invoke Source Code File
-
-Copyright (c) 2006 Will Weisser
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-   1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-   2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
-and/or other materials provided with the distribution.
-   3. The name of the author may not be used to endorse or promote products
-derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-*/
-#ifndef _ARCH_GCC_X86_LINUX_H
-#define _ARCH_GCC_X86_LINUX_H
-
-#include <errno.h>
-
-typedef struct _ArchLibrary {
-       void *dl;
-} ArchLibrary;
-
-typedef struct _ArchRetValue {
-       int ivallow;
-       int ivalhigh;
-       double dval;
-} ArchRetValue;
-
-typedef struct _ArchRegParms {} ArchRegParms;
-
-typedef char cinv_int8_t;
-typedef short cinv_int16_t;
-typedef int cinv_int32_t;
-typedef long long cinv_int64_t;
-
-#define CINV_E_NOMEM ((cinv_int32_t)ENOMEM)
-#define CINV_S_NOMEM (strerror(ENOMEM))
-#define CINV_NOMEM_NEEDSFREE 1
-#define CINV_E_INVAL ((cinv_int32_t)EINVAL)
-
-#define CINV_CC_DEFAULT CINV_CC_CDECL
-#define CINV_T_2BYTE CINV_T_SHORT
-#define CINV_T_4BYTE CINV_T_INT
-#define CINV_T_8BYTE CINV_T_EXTRALONG
-
-/////////////////////////////////////
-// macros
-/////////////////////////////////////
-#define ARCH_SAVE_REGPARMS(regparms)
-
-#define ARCH_CALL(regparms, ep) ((void (*)())ep)();
-
-#define ARCH_SAVE_RETURN(archvalue) \
-       __asm__("movl %%eax, %0; \
-                       movl %%edx, %1; \
-                       fstpl %2" : \
-                       "=m" ((archvalue).ivallow), \
-                       "=m" ((archvalue).ivalhigh), \
-                       "=m" ((archvalue).dval));
-
-#define ARCH_SET_RETURN(archvalue) \
-       __asm__("movl %0, %%eax; \
-                       movl %1, %%edx; \
-                       fldl %2" :: \
-                       "m" ((archvalue).ivallow), \
-                       "m" ((archvalue).ivalhigh), \
-                       "m" ((archvalue).dval) : \
-                       "%eax", "%edx", "%st");
-
-#define ARCH_PUT_STACK_BYTES(bcount) \
-       __asm__("subl %0, %%esp" :: "m" (bcount) : "%esp");
-
-#define ARCH_REMOVE_STACK_BYTES(bcount) \
-       __asm__("addl %0, %%esp" :: "m" (bcount) : "%esp");
-
-#define ARCH_GET_STACK(sp) \
-       __asm__("movl %%esp, %0" : "=m" (sp));
-
-#define ARCH_GET_FRAME_PTR(fp) \
-       __asm__("movl %%ebp, %0" : "=m" (fp));
-
-#define ARCH_CALLBACK_ARG_OFFSET (4*10)
-
-#define ARCH_STACK_GROWS_DOWN 1
-
-#endif

Copied: trunk/cinvoke/lib/arch/gcc_x86_unix.c (from rev 20, 
trunk/cinvoke/lib/arch/gcc_x86_linux.c)
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x86_unix.c                               (rev 0)
+++ trunk/cinvoke/lib/arch/gcc_x86_unix.c       2006-06-15 04:24:09 UTC (rev 21)
@@ -0,0 +1,215 @@
+/*
+C/Invoke Source Code File
+
+Copyright (c) 2006 Will Weisser
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+   3. The name of the author may not be used to endorse or promote products
+derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
+#include "cinvoke.h"
+#include "cinvoke-private.h"
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+void arch_free_errstr(char *str) {}
+
+cinv_status_t arch_library_create(CInvContext *context, const char *path,
+       ArchLibrary *library_out) {
+       void *dl = dlopen(path, RTLD_LAZY);
+       if (!dl) {
+               context_set_error(context, -1, (char*)dlerror(), 0);
+               return CINV_ERROR;
+       }
+               
+       library_out->dl = dl;
+
+       context_clear_error(context);
+       return CINV_SUCCESS;
+}
+cinv_status_t arch_library_get_entrypoint(CInvContext *context,
+       ArchLibrary *library, const char *name, void **entrypoint_out) {
+       void *sym = dlsym(library->dl, name);
+       if (!sym) {
+               context_set_error(context, -1, (char*)dlerror(), 0);
+               return CINV_ERROR;
+       }
+
+       *entrypoint_out = sym;
+
+       context_clear_error(context);
+       return CINV_SUCCESS;
+}
+cinv_status_t arch_library_delete(CInvContext *context, ArchLibrary *library) {
+       if (dlclose(library->dl)) {
+               context_set_error(context, -1, (char*)dlerror(), 0);
+               return CINV_ERROR;
+       }
+
+       context_clear_error(context);
+       return CINV_SUCCESS;
+}
+
+const static int LEN = 4096;
+
+char *arch_callback_stub(void *functionp, void *param,
+       short stacksize, cinv_callconv_t cc) {
+#if defined (__linux__)
+       char *ret = mmap(0, LEN, PROT_EXEC|PROT_READ|PROT_WRITE,
+               MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+#else
+       char *ret = mmap(0, LEN, PROT_EXEC|PROT_READ|PROT_WRITE,
+               MAP_ANON|MAP_PRIVATE, -1, 0);
+#endif
+       if (ret == MAP_FAILED)
+               return NULL;
+       
+       // void f() { ((void (*)(void *))0xAAAAAAAA)((void *)0xBBBBBBBB); }
+       memcpy(ret,
+               "\x55\x89\xe5\x83\xec\x08\x83\xec\x0c\x68"
+               "\xbb\xbb\xbb\xbb\xb8\xaa\xaa\xaa\xaa\xff"
+               "\xd0\x83\xc4\x10\xc9\xc3",
+               26);
+
+       memcpy(ret + 10, &param, 4);
+       memcpy(ret + 15, &functionp, 4);
+       
+       return ret;
+}
+void arch_free_stub(char *stub) {
+       munmap(stub, LEN);
+}
+
+int arch_is_register_parm(cinv_callconv_t callingconvention, int index,
+       int num_params, cinv_type_t types[]) { return 0; }
+void arch_set_register_parms(ArchRegParms *regparms, 
+       cinv_callconv_t callingconvention, int num_params, void *parameters[], 
+       cinv_type_t types[]) {}
+void arch_get_register_parms(ArchRegParms *regparms,
+       cinv_callconv_t callingconvention, int num_params, void 
*parameters_out[],
+       cinv_type_t types[]) {}
+
+void arch_getval_char(ArchRetValue *archval, char *outval) {
+       *outval = archval->ivallow;
+}
+void arch_getval_short(ArchRetValue *archval, short *outval) {
+       *outval = archval->ivallow;
+}
+void arch_getval_int(ArchRetValue *archval, int *outval) {
+       *outval = archval->ivallow;
+}
+void arch_getval_long(ArchRetValue *archval, long int *outval) {
+       *outval = archval->ivallow;
+}
+void arch_getval_extralong(ArchRetValue *archval, long long int *outval) {
+       *outval = archval->ivalhigh;
+       *outval <<= 32;
+       *outval |= archval->ivallow;
+}
+void arch_getval_float(ArchRetValue *archval, float *outval) {
+       *outval = (float)archval->dval;
+}
+void arch_getval_double(ArchRetValue *archval, double *outval) {
+       *outval = archval->dval;
+}
+void arch_getval_ptr(ArchRetValue *archval, void **outval) {
+       *outval = (void *)archval->ivallow;
+}
+
+void arch_setval_char(ArchRetValue *archval, char val) {
+       archval->ivallow = val;
+}
+void arch_setval_short(ArchRetValue *archval, short val) {
+       archval->ivallow = val;
+}
+void arch_setval_int(ArchRetValue *archval, int val) {
+       archval->ivallow = val;
+}
+void arch_setval_long(ArchRetValue *archval, long int val) {
+       archval->ivallow = val;
+}
+void arch_setval_extralong(ArchRetValue *archval, long long int val) {
+       archval->ivalhigh = (val >> 32);
+       archval->ivallow = val;
+}
+void arch_setval_float(ArchRetValue *archval, float val) {
+       archval->dval = val;
+}
+void arch_setval_double(ArchRetValue *archval, double val) {
+       archval->dval = val;
+}
+void arch_setval_ptr(ArchRetValue *archval, void *val) {
+       archval->ivallow = (int)val;
+}
+
+void arch_size_char(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 4;
+       *structsize_out = 1;
+}
+void arch_size_short(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 4;
+       *structsize_out = 2;
+       *structalign_out = 2;
+}
+void arch_size_int(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 4;
+       *structsize_out = 4;
+       *structalign_out = 4;
+}
+void arch_size_long(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 4;
+       *structsize_out = 4;
+       *structalign_out = 4;
+}
+void arch_size_extralong(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 8;
+       *structalign_out = 4;
+}
+void arch_size_float(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 4;
+       *structsize_out = 4;
+       *structalign_out = 4;
+}
+void arch_size_double(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 8;
+       *structalign_out = 4;
+}
+void arch_size_ptr(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 4;
+       *structsize_out = 4;
+       *structalign_out = 4;
+}

Copied: trunk/cinvoke/lib/arch/gcc_x86_unix.h (from rev 19, 
trunk/cinvoke/lib/arch/gcc_x86_linux.h)
===================================================================
--- trunk/cinvoke/lib/arch/gcc_x86_unix.h                               (rev 0)
+++ trunk/cinvoke/lib/arch/gcc_x86_unix.h       2006-06-15 04:24:09 UTC (rev 21)
@@ -0,0 +1,100 @@
+/*
+C/Invoke Source Code File
+
+Copyright (c) 2006 Will Weisser
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+   3. The name of the author may not be used to endorse or promote products
+derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef _ARCH_GCC_X86_LINUX_H
+#define _ARCH_GCC_X86_LINUX_H
+
+#include <errno.h>
+
+typedef struct _ArchLibrary {
+       void *dl;
+} ArchLibrary;
+
+typedef struct _ArchRetValue {
+       int ivallow;
+       int ivalhigh;
+       double dval;
+} ArchRetValue;
+
+typedef struct _ArchRegParms {} ArchRegParms;
+
+typedef char cinv_int8_t;
+typedef short cinv_int16_t;
+typedef int cinv_int32_t;
+typedef long long cinv_int64_t;
+
+#define CINV_E_NOMEM ((cinv_int32_t)ENOMEM)
+#define CINV_S_NOMEM (strerror(ENOMEM))
+#define CINV_NOMEM_NEEDSFREE 1
+#define CINV_E_INVAL ((cinv_int32_t)EINVAL)
+
+#define CINV_CC_DEFAULT CINV_CC_CDECL
+#define CINV_T_2BYTE CINV_T_SHORT
+#define CINV_T_4BYTE CINV_T_INT
+#define CINV_T_8BYTE CINV_T_EXTRALONG
+
+/////////////////////////////////////
+// macros
+/////////////////////////////////////
+#define ARCH_SAVE_REGPARMS(regparms)
+
+#define ARCH_CALL(regparms, ep) ((void (*)())ep)();
+
+#define ARCH_SAVE_RETURN(archvalue) \
+       __asm__("movl %%eax, %0; \
+                       movl %%edx, %1; \
+                       fstpl %2" : \
+                       "=m" ((archvalue).ivallow), \
+                       "=m" ((archvalue).ivalhigh), \
+                       "=m" ((archvalue).dval));
+
+#define ARCH_SET_RETURN(archvalue) \
+       __asm__("movl %0, %%eax; \
+                       movl %1, %%edx; \
+                       fldl %2" :: \
+                       "m" ((archvalue).ivallow), \
+                       "m" ((archvalue).ivalhigh), \
+                       "m" ((archvalue).dval) : \
+                       "%eax", "%edx", "%st");
+
+#define ARCH_PUT_STACK_BYTES(bcount) \
+       __asm__("subl %0, %%esp" :: "m" (bcount) : "%esp");
+
+#define ARCH_REMOVE_STACK_BYTES(bcount) \
+       __asm__("addl %0, %%esp" :: "m" (bcount) : "%esp");
+
+#define ARCH_GET_STACK(sp) \
+       __asm__("movl %%esp, %0" : "=m" (sp));
+
+#define ARCH_GET_FRAME_PTR(fp) \
+       __asm__("movl %%ebp, %0" : "=m" (fp));
+
+#define ARCH_CALLBACK_ARG_OFFSET (4*10)
+
+#define ARCH_STACK_GROWS_DOWN 1
+
+#endif

Modified: trunk/cinvoke/test/Makefile
===================================================================
--- trunk/cinvoke/test/Makefile 2006-06-15 04:14:47 UTC (rev 20)
+++ trunk/cinvoke/test/Makefile 2006-06-15 04:24:09 UTC (rev 21)
@@ -6,5 +6,9 @@
 lib.so: lib.c
        gcc -g -shared -fPIC lib.c -o lib.so -Wall -Werror
 
+LIBDL = -ldl
+#uncomment for *BSD
+#LIBDL = 
+
 runtests: runtests.c lib.so
-       gcc -g -o runtests runtests.c -Wall -Werror ../lib/cinvoke.a -I../lib 
-ldl -lm
+       gcc -g -o runtests runtests.c -Wall -Werror ../lib/cinvoke.a -I../lib 
$(LIBDL) -lm





reply via email to

[Prev in Thread] Current Thread [Next in Thread]