cinvoke-svn
[Top][All Lists]
Advanced

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

[cinvoke-svn] r74 - in trunk/cinvoke: . lib lib/arch test tools


From: will
Subject: [cinvoke-svn] r74 - in trunk/cinvoke: . lib lib/arch test tools
Date: 5 Jul 2006 23:36:27 -0400

Author: will
Date: 2006-07-05 23:36:27 -0400 (Wed, 05 Jul 2006)
New Revision: 74

Added:
   trunk/cinvoke/Makefile.ppc
   trunk/cinvoke/lib/Makefile.ppc
   trunk/cinvoke/lib/arch/gcc_ppc_osx.c
   trunk/cinvoke/lib/arch/gcc_ppc_osx.h
   trunk/cinvoke/tools/buildshared.sh
   trunk/cinvoke/tools/dyncflags.sh
Modified:
   trunk/cinvoke/Makefile.x64
   trunk/cinvoke/Makefile.x86
   trunk/cinvoke/configure.sh
   trunk/cinvoke/lib/cinvoke-arch.h
   trunk/cinvoke/test/Makefile
Log:
skeleton build files for ppc


Added: trunk/cinvoke/Makefile.ppc
===================================================================
--- trunk/cinvoke/Makefile.ppc                          (rev 0)
+++ trunk/cinvoke/Makefile.ppc  2006-07-06 03:36:27 UTC (rev 74)
@@ -0,0 +1,14 @@
+PREFIX = /usr/local
+
+all:
+       cd lib && $(MAKE) BUILDARCH=-DARCH_GCC_PPC_OSX
+       cd test && $(MAKE) BUILDARCH=-DARCH_GCC_PPC_OSX DYNEXT=dylib
+       cp -f lib/arch/gcc_ppc_osx.h lib/cinvoke-archspec.h
+
+install:
+       install lib/cinvoke.h lib/cinvoke-arch.h lib/cinvoke-archspec.h 
$(PREFIX)/include
+       install lib/libcinvoke.a $(PREFIX)/lib
+
+clean:
+       cd lib && $(MAKE) clean
+       cd test && $(MAKE) clean

Modified: trunk/cinvoke/Makefile.x64
===================================================================
--- trunk/cinvoke/Makefile.x64  2006-07-06 02:00:09 UTC (rev 73)
+++ trunk/cinvoke/Makefile.x64  2006-07-06 03:36:27 UTC (rev 74)
@@ -2,7 +2,7 @@
 
 all:
        cd lib && $(MAKE) BUILDARCH=-DARCH_GCC_X64_UNIX
-       cd test && $(MAKE) BUILDARCH=-DARCH_GCC_X64_UNIX
+       cd test && $(MAKE) BUILDARCH=-DARCH_GCC_X64_UNIX DYNEXT=so
        cp -f lib/arch/gcc_x64_unix.h lib/cinvoke-archspec.h
 
 install:

Modified: trunk/cinvoke/Makefile.x86
===================================================================
--- trunk/cinvoke/Makefile.x86  2006-07-06 02:00:09 UTC (rev 73)
+++ trunk/cinvoke/Makefile.x86  2006-07-06 03:36:27 UTC (rev 74)
@@ -2,7 +2,7 @@
 
 all:
        cd lib && $(MAKE) BUILDARCH=-DARCH_GCC_X86_UNIX
-       cd test && $(MAKE) BUILDARCH=-DARCH_GCC_X86_UNIX
+       cd test && $(MAKE) BUILDARCH=-DARCH_GCC_X86_UNIX DYNEXT=so
        cp -f lib/arch/gcc_x86_unix.h lib/cinvoke-archspec.h
 
 install:

Modified: trunk/cinvoke/configure.sh
===================================================================
--- trunk/cinvoke/configure.sh  2006-07-06 02:00:09 UTC (rev 73)
+++ trunk/cinvoke/configure.sh  2006-07-06 03:36:27 UTC (rev 74)
@@ -9,11 +9,15 @@
                ln -s Makefile.x64 Makefile
                cd lib ; ln -s Makefile.x64 Makefile
                ;;
+       'ppc')
+               ln -s Makefile.ppc Makefile
+               cd lib ; ln -s Makefile.ppc Makefile
+               ;;
        'clean')
                rm -f Makefile lib/Makefile
                ;;
        *)
                echo "Usage: configure.sh <target>"
-               echo "Available targets are: x86 x64 clean"
+               echo "Available targets are: x86 x64 ppc clean"
                ;;
 esac

Added: trunk/cinvoke/lib/Makefile.ppc
===================================================================
--- trunk/cinvoke/lib/Makefile.ppc                              (rev 0)
+++ trunk/cinvoke/lib/Makefile.ppc      2006-07-06 03:36:27 UTC (rev 74)
@@ -0,0 +1,25 @@
+TARGET = libcinvoke.a
+
+all: $(TARGET)
+
+clean:
+       rm -f *.o arch/*.o libcinvoke.a
+
+SRCS = cinvoke.c structure.c hashtable.c arch/gcc_ppc_osx.c
+
+OBJS = $(SRCS:.c=.o)
+
+$(TARGET): $(OBJS)
+       libtool -static -o $(TARGET) $(OBJS)
+
+.c.o:
+       gcc -g -Wall -Werror $(BUILDARCH) -DCINVOKE_BUILD -c $< -o $@
+
+cinvoke.o: cinvoke.c cinvoke.h cinvoke-arch.h arch/gcc_ppc_osx.h \
+  cinvoke-private.h hashtable.h
+structure.o: structure.c cinvoke.h cinvoke-arch.h arch/gcc_ppc_osx.h \
+  cinvoke-private.h hashtable.h
+hashtable.o: hashtable.c hashtable.h
+arch/gcc_ppc_osx.o: arch/gcc_ppc_osx.c arch/../cinvoke.h \
+  arch/../cinvoke-arch.h arch/../arch/gcc_ppc_osx.h \
+  arch/../cinvoke-private.h arch/../hashtable.h

Added: trunk/cinvoke/lib/arch/gcc_ppc_osx.c
===================================================================
--- trunk/cinvoke/lib/arch/gcc_ppc_osx.c                                (rev 0)
+++ trunk/cinvoke/lib/arch/gcc_ppc_osx.c        2006-07-06 03:36:27 UTC (rev 74)
@@ -0,0 +1,322 @@
+/*
+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.
+*/
+#ifdef CINVOKE_BUILD
+#include "../cinvoke.h"
+#include "../cinvoke-private.h"
+#else
+#include "cinvoke.h"
+#include "cinvoke-private.h"
+#endif
+
+#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;
+
+       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;
+
+       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;
+       }
+
+       return CINV_SUCCESS;
+}
+
+const static int LEN = 4096;
+
+char *arch_callback_stub(void *functionp, void *param,
+       short stacksize, cinv_callconv_t cc) {
+       char *ret = mmap(0, LEN, PROT_EXEC|PROT_READ|PROT_WRITE,
+               MAP_ANON|MAP_PRIVATE, -1, 0);
+       if (ret == MAP_FAILED)
+               return NULL;
+       
+       //void f() {
+       //      __asm("movq %%rdi, %%r11" ::: "%r11");
+       //      ((void (*)(void *))0xAAAAAAAAAAAAAAAA)(
+       //              (void *)0xBBBBBBBBBBBBBBBB);
+       //}
+       memcpy(ret,
+               "\x55\x48\x89\xe5\x49\x89\xfb\x48\xb8"
+               "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+               "\x48\xbf\xbb\xbb\xbb\xbb\xbb\xbb\xbb\xbb"
+               "\xff\xd0\xc9\xc3",
+               31);
+
+       memcpy(ret + 9, &functionp, 8);
+       memcpy(ret + 19, &param, 8);
+       
+       return ret;
+}
+void arch_free_stub(char *stub) {
+       munmap(stub, LEN);
+}
+
+int isflt(cinv_type_t t) {
+       return (t == CINV_T_FLOAT) || (t == CINV_T_DOUBLE);
+}
+int arch_is_register_parm(cinv_callconv_t callingconvention, int index,
+       int num_params, cinv_type_t types[]) {
+       int numints = 0, numflts = 0;
+       int i;
+       for (i = 0; i < index; i++) {
+               if (isflt(types[i]))
+                       numflts++;
+               else
+                       numints++;
+       }
+       return (isflt(types[index]) && numflts < 8) || (numints < 6);
+}
+
+void set_flt(ArchRegParms *regparms, int index, void *p, cinv_type_t type) {
+       long *toset[] = {
+               &(regparms->xmm0), &(regparms->xmm1), &(regparms->xmm2),
+               &(regparms->xmm3), &(regparms->xmm4), &(regparms->xmm5),
+               &(regparms->xmm6), &(regparms->xmm7)
+       };
+       
+       if (type == CINV_T_FLOAT)
+               *((float *)toset[index]) = *(float *)p;
+       else
+               *((double *)toset[index]) = *(double *)p;
+}
+void set_int(ArchRegParms *regparms, int index, void *p, cinv_type_t type) {
+       long *toset[] = {
+               &(regparms->rdi), &(regparms->rsi), &(regparms->rdx), 
+               &(regparms->rcx), &(regparms->r8), &(regparms->r9) 
+       };
+       
+       if (type == CINV_T_CHAR)
+               *(toset[index]) = *(char *)p;
+       else if (type == CINV_T_SHORT)
+               *(toset[index]) = *(short *)p;
+       else if (type == CINV_T_INT)
+               *(toset[index]) = *(int *)p;
+       else if (type == CINV_T_LONG)
+               *(toset[index]) = *(long *)p;
+       else if (type == CINV_T_EXTRALONG)
+               *(toset[index]) = *(long long *)p;
+       else
+               *(toset[index]) = (long)*(void **)p;
+}
+
+void arch_set_register_parms(ArchRegParms *regparms, 
+       cinv_callconv_t callingconvention, int num_params, void *parameters[], 
+       cinv_type_t types[]) {
+       int numints = 0, numflts = 0;
+       int i;
+       for (i = 0; i < num_params; i++) {
+               if (isflt(types[i])) {
+                       if (numflts < 8)
+                               set_flt(regparms, numflts, parameters[i], 
types[i]);
+                       numflts++;
+               } else {
+                       if (numints < 6)
+                               set_int(regparms, numints, parameters[i], 
types[i]);
+                       numints++;
+               }
+       }
+}
+void get_flt(void *po, int index, ArchRegParms *regparms, cinv_type_t type) {
+       long *toget[] = {
+               &(regparms->xmm0), &(regparms->xmm1), &(regparms->xmm2),
+               &(regparms->xmm3), &(regparms->xmm4), &(regparms->xmm5),
+               &(regparms->xmm6), &(regparms->xmm7)
+       };
+       
+       if (type == CINV_T_FLOAT)
+               *(float *)po = *((float *)toget[index]);
+       else
+               *(double *)po = *((double *)toget[index]);
+}
+void get_int(void *po, int index, ArchRegParms *regparms, cinv_type_t type) {
+       long *toget[] = {
+               &(regparms->rdi), &(regparms->rsi), &(regparms->rdx), 
+               &(regparms->rcx), &(regparms->r8), &(regparms->r9) 
+       };
+       
+       if (type == CINV_T_CHAR)
+               *(char *)po = (char)*(toget[index]);
+       else if (type == CINV_T_SHORT)
+               *(short *)po = (short)*(toget[index]);
+       else if (type == CINV_T_INT)
+               *(int *)po = (int)*(toget[index]);
+       else if (type == CINV_T_LONG)
+               *(long *)po = *(toget[index]);
+       else if (type == CINV_T_EXTRALONG)
+               *(long long *)po = (long long)*(toget[index]);
+       else
+               *(void **)po = (void *)*(toget[index]);
+}
+
+void arch_get_register_parms(ArchRegParms *regparms,
+       cinv_callconv_t callingconvention, int num_params, void 
*parameters_out[],
+       cinv_type_t types[]) {
+       int numints = 0, numflts = 0;
+       int i;
+       for (i = 0; i < num_params; i++) {
+               if (isflt(types[i])) {
+                       if (numflts < 8)
+                               get_flt(parameters_out[i], numflts, regparms, 
types[i]);
+                       numflts++;
+               } else {
+                       if (numints < 6)
+                               get_int(parameters_out[i], numints, regparms, 
types[i]);
+                       numints++;
+               }
+       }
+}
+
+void arch_getval_char(ArchRetValue *archval, char *outval) {
+       *outval = archval->ival;
+}
+void arch_getval_short(ArchRetValue *archval, short *outval) {
+       *outval = archval->ival;
+}
+void arch_getval_int(ArchRetValue *archval, int *outval) {
+       *outval = archval->ival;
+}
+void arch_getval_long(ArchRetValue *archval, long int *outval) {
+       *outval = archval->ival;
+}
+void arch_getval_extralong(ArchRetValue *archval, long long int *outval) {
+       *outval = archval->ival;
+}
+void arch_getval_float(ArchRetValue *archval, float *outval) {
+       float f = *(float *)&archval->dval;
+       *outval = f;
+}
+void arch_getval_double(ArchRetValue *archval, double *outval) {
+       double d = *(double *)&archval->dval;
+       *outval = d;
+}
+void arch_getval_ptr(ArchRetValue *archval, void **outval) {
+       *outval = (void *)archval->ival;
+}
+
+void arch_setval_char(ArchRetValue *archval, char val) {
+       archval->ival = val;
+}
+void arch_setval_short(ArchRetValue *archval, short val) {
+       archval->ival = val;
+}
+void arch_setval_int(ArchRetValue *archval, int val) {
+       archval->ival = val;
+}
+void arch_setval_long(ArchRetValue *archval, long int val) {
+       archval->ival = val;
+}
+void arch_setval_extralong(ArchRetValue *archval, long long int val) {
+       archval->ival = val;
+}
+void arch_setval_float(ArchRetValue *archval, float val) {
+       *((float *)&archval->dval) = val;
+}
+void arch_setval_double(ArchRetValue *archval, double val) {
+       *((double *)&archval->dval) = val;
+}
+void arch_setval_ptr(ArchRetValue *archval, void *val) {
+       archval->ival = (long)val;
+}
+
+void arch_size_char(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 1;
+}
+void arch_size_short(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 2;
+       *structalign_out = 2;
+}
+void arch_size_int(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 4;
+       *structalign_out = 4;
+}
+void arch_size_long(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 8;
+       *structalign_out = 8;
+}
+void arch_size_extralong(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 8;
+       *structalign_out = 8;
+}
+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 = 8;
+}
+void arch_size_ptr(int *stacksize_out, int *structsize_out,
+       int *stackalign_out, int *structalign_out) {
+       *stacksize_out = 8;
+       *structsize_out = 8;
+       *structalign_out = 8;
+}

Added: trunk/cinvoke/lib/arch/gcc_ppc_osx.h
===================================================================
--- trunk/cinvoke/lib/arch/gcc_ppc_osx.h                                (rev 0)
+++ trunk/cinvoke/lib/arch/gcc_ppc_osx.h        2006-07-06 03:36:27 UTC (rev 74)
@@ -0,0 +1,178 @@
+/*
+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 {
+       long ival;
+       long dval;
+} ArchRetValue;
+
+typedef struct _ArchRegParms {
+       long rdi;
+       long rsi;
+       long rdx;
+       long rcx;
+       long r8;
+       long r9;
+       long xmm0;
+       long xmm1;
+       long xmm2;
+       long xmm3;
+       long xmm4;
+       long xmm5;
+       long xmm6;
+       long xmm7;
+} ArchRegParms;
+
+typedef char cinv_int8_t;
+typedef short cinv_int16_t;
+typedef int cinv_int32_t;
+typedef 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
+/////////////////////////////////////
+// note we use r11 instead of rdi, this is because we
+// saved this value in the callback stub
+#define ARCH_SAVE_REGPARMS(regparms) \
+       ;/*__asm__("movq %%r11, %0; \
+               movq %%rsi, %1; \
+               movq %%rdx, %2; \
+               movq %%rcx, %3; \
+               movq %%r8, %4; \
+               movq %%r9, %5; \
+               movsd %%xmm0, %6; \
+               movsd %%xmm1, %7; \
+               movsd %%xmm2, %8; \
+               movsd %%xmm3, %9; \
+               movsd %%xmm4, %10; \
+               movsd %%xmm5, %11; \
+               movsd %%xmm6, %12; \
+               movsd %%xmm7, %13" : \
+                       "=m" ((regparms).rdi), \
+                       "=m" ((regparms).rsi), \
+                       "=m" ((regparms).rdx), \
+                       "=m" ((regparms).rcx), \
+                       "=m" ((regparms).r8), \
+                       "=m" ((regparms).r9), \
+                       "=m" ((regparms).xmm0), \
+                       "=m" ((regparms).xmm1), \
+                       "=m" ((regparms).xmm2), \
+                       "=m" ((regparms).xmm3), \
+                       "=m" ((regparms).xmm4), \
+                       "=m" ((regparms).xmm5), \
+                       "=m" ((regparms).xmm6), \
+                       "=m" ((regparms).xmm7));*/
+
+#define ARCH_CALL(regparms, ep) \
+       ;/*__asm__("movq %0, %%rdi; \
+               movq %1, %%rsi; \
+               movq %2, %%rdx; \
+               movq %3, %%rcx; \
+               movq %4, %%r8; \
+               movq %5, %%r9; \
+               movsd %6, %%xmm0; \
+               movsd %7, %%xmm1; \
+               movsd %8, %%xmm2; \
+               movsd %9, %%xmm3; \
+               movsd %10, %%xmm4; \
+               movsd %11, %%xmm5; \
+               movsd %12, %%xmm6; \
+               movsd %13, %%xmm7; \
+               call *%14" :: \
+                       "m" ((regparms).rdi), \
+                       "m" ((regparms).rsi), \
+                       "m" ((regparms).rdx), \
+                       "m" ((regparms).rcx), \
+                       "m" ((regparms).r8), \
+                       "m" ((regparms).r9), \
+                       "m" ((regparms).xmm0), \
+                       "m" ((regparms).xmm1), \
+                       "m" ((regparms).xmm2), \
+                       "m" ((regparms).xmm3), \
+                       "m" ((regparms).xmm4), \
+                       "m" ((regparms).xmm5), \
+                       "m" ((regparms).xmm6), \
+                       "m" ((regparms).xmm7), \
+                       "m" (ep) : \
+                       "%rdi", "%rsi", "%rdx", "%rcx", \
+                       "%r8", "%r9", "%xmm0", "%xmm1", \
+                       "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
+                       "%xmm6", "%xmm7");*/
+
+#define ARCH_SAVE_RETURN(archvalue) \
+       ;/*__asm__("movq %%rax, %0; \
+               movsd %%xmm0, %1" : \
+                       "=m" ((archvalue).ival), \
+                       "=m" ((archvalue).dval));*/
+
+#define ARCH_SET_RETURN(archvalue) \
+       ;/*__asm__("movq %0, %%rax; \
+               movsd %1, %%xmm0" :: \
+                       "m" ((archvalue).ival), \
+                       "m" ((archvalue).dval) : \
+                       "%rax", "%xmm0");*/
+
+#define ARCH_PUT_STACK_BYTES(bcount) \
+;/*{ \
+       long bc = bcount; \
+       __asm__("subq %0, %%rsp" :: "m" (bc) : "%rsp"); \
+}*/
+#define ARCH_REMOVE_STACK_BYTES(bcount) \
+;/*{ \
+       long bc = bcount; \
+       __asm__("addq %0, %%rsp" :: "m" (bc) : "%rsp"); \
+}*/
+#define ARCH_GET_STACK(sp) \
+;/*    __asm__("movq %%rsp, %0" : "=m" (sp));*/
+
+#define ARCH_GET_FRAME_PTR(fp) \
+;/*    __asm__("movq %%rbp, %0" : "=m" (fp));*/
+
+#define ARCH_CALLBACK_ARG_OFFSET (32)
+
+#define ARCH_STACK_GROWS_DOWN 1
+
+#endif

Modified: trunk/cinvoke/lib/cinvoke-arch.h
===================================================================
--- trunk/cinvoke/lib/cinvoke-arch.h    2006-07-06 02:00:09 UTC (rev 73)
+++ trunk/cinvoke/lib/cinvoke-arch.h    2006-07-06 03:36:27 UTC (rev 74)
@@ -76,6 +76,9 @@
 #ifdef ARCH_CL_X86_WIN
 #include "arch/cl_x86_win.h"
 #endif
+#ifdef ARCH_GCC_PPC_OSX
+#include "arch/gcc_ppc_osx.h"
+#endif
 #ifndef CINVOKE_BUILD
 #include "cinvoke-archspec.h"
 #endif

Modified: trunk/cinvoke/test/Makefile
===================================================================
--- trunk/cinvoke/test/Makefile 2006-07-06 02:00:09 UTC (rev 73)
+++ trunk/cinvoke/test/Makefile 2006-07-06 03:36:27 UTC (rev 74)
@@ -1,10 +1,15 @@
-all: lib.so runtests
+SHARED = lib.$(DYNEXT)
 
+all: $(SHARED) runtests
+
 clean:
-       rm -f lib.so runtests
+       rm -f lib.o $(SHARED) runtests
 
-lib.so: lib.c
-       gcc -g -shared -fPIC lib.c -o lib.so -Wall -Werror
+lib.o: lib.c
+       gcc -g -c `sh ../tools/dyncflags.sh` lib.c -o lib.o -Wall -Werror
 
-runtests: runtests.c lib.so ../lib/libcinvoke.a
+$(SHARED): lib.o
+       sh ../tools/buildshared.sh $(SHARED) lib.o
+
+runtests: runtests.c $(SHARED) ../lib/libcinvoke.a
        gcc -g -DCINVOKE_BUILD $(BUILDARCH) -o runtests runtests.c -Wall 
-Werror -L../lib -I../lib `sh ../tools/libdl.sh` -lcinvoke -lm

Added: trunk/cinvoke/tools/buildshared.sh
===================================================================
--- trunk/cinvoke/tools/buildshared.sh                          (rev 0)
+++ trunk/cinvoke/tools/buildshared.sh  2006-07-06 03:36:27 UTC (rev 74)
@@ -0,0 +1,8 @@
+#!/bin/sh
+if [ `uname` = 'Darwin' ] ; then
+       echo "libtool -dynamic -o $1 $2 -lc"
+       libtool -dynamic -o $1 $2 -lc
+else
+       echo "gcc -shared -o $1 $2"
+       gcc -shared -o $1 $2
+fi

Added: trunk/cinvoke/tools/dyncflags.sh
===================================================================
--- trunk/cinvoke/tools/dyncflags.sh                            (rev 0)
+++ trunk/cinvoke/tools/dyncflags.sh    2006-07-06 03:36:27 UTC (rev 74)
@@ -0,0 +1,6 @@
+#!/bin/sh
+if [ `uname` = 'Darwin' ] ; then
+       echo '-dynamic'
+else
+       echo '-fPIC'
+fi





reply via email to

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