diff -uNr pnet/include/il_align.h pnet-cris/include/il_align.h --- pnet/include/il_align.h 2001-11-08 08:21:51.000000000 +0100 +++ pnet-cris/include/il_align.h 2004-10-25 12:12:35.903514200 +0200 @@ -63,6 +63,11 @@ _IL_ALIGN_FOR_TYPE(double), \ _IL_ALIGN_FOR_TYPE(long_double))) +#ifdef __cris__ +#undef IL_BEST_ALIGNMENT +#define IL_BEST_ALIGNMENT 4 +#endif + #ifdef __cplusplus }; #endif diff -uNr pnet/libffi/Makefile.am pnet-cris/libffi/Makefile.am --- pnet/libffi/Makefile.am 2003-07-13 00:14:06.000000000 +0200 +++ pnet-cris/libffi/Makefile.am 2004-10-25 12:10:50.255575128 +0200 @@ -17,6 +17,7 @@ src/powerpc/darwin.S src/powerpc/aix.S \ src/powerpc/darwin_closure.S src/powerpc/aix_closure.S \ src/arm/ffi.c src/arm/sysv.S \ + src/cris/ffi.c src/cris/sysv.S \ src/s390/ffi.c src/s390/sysv.S \ src/sh/ffi.c src/sh/sysv.S @@ -98,6 +99,7 @@ TARGET_SRC_POWERPC_AIX = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S TARGET_SRC_POWERPC_DARWIN = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S TARGET_SRC_ARM = src/arm/sysv.S src/arm/ffi.c +TARGET_SRC_CRIS32 = src/cris/sysv.S src/cris/ffi.c TARGET_SRC_S390 = src/s390/sysv.S src/s390/ffi.c TARGET_SRC_X86_64 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S TARGET_SRC_SH = src/sh/sysv.S src/sh/ffi.c @@ -122,6 +124,10 @@ libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86) libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86) endif +if CRIS32 +libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_CRIS32) +libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_CRIS32) +endif if X86_WIN32 libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86_WIN32) libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86_WIN32) @@ -158,6 +164,10 @@ libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_ARM) libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_ARM) endif +if CRIS32 +libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_CRIS32) +libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_CRIS32) +endif if S390 libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_S390) libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_S390) diff -uNr pnet/libffi/Makefile.in pnet-cris/libffi/Makefile.in --- pnet/libffi/Makefile.in 2003-07-13 00:14:07.000000000 +0200 +++ pnet-cris/libffi/Makefile.in 2004-10-25 12:10:50.257574824 +0200 @@ -100,6 +100,7 @@ src/powerpc/darwin.S src/powerpc/aix.S \ src/powerpc/darwin_closure.S src/powerpc/aix_closure.S \ src/arm/ffi.c src/arm/sysv.S \ + src/cris/ffi.c src/cris/sysv.S \ src/s390/ffi.c src/s390/sysv.S \ src/sh/ffi.c src/sh/sysv.S @@ -177,6 +178,7 @@ TARGET_SRC_POWERPC_AIX = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S TARGET_SRC_POWERPC_DARWIN = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S TARGET_SRC_ARM = src/arm/sysv.S src/arm/ffi.c +TARGET_SRC_CRIS32 = src/cris/sysv.S src/cris/ffi.c TARGET_SRC_S390 = src/s390/sysv.S src/s390/ffi.c TARGET_SRC_X86_64 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S TARGET_SRC_SH = src/sh/sysv.S src/sh/ffi.c @@ -288,6 +290,9 @@ @address@hidden = src/debug.lo src/prep_cif.lo \ @address@hidden/types.lo src/raw_api.lo src/java_raw_api.lo \ @address@hidden/arm/sysv.lo src/arm/ffi.lo address@hidden@libffi_convenience_la_OBJECTS = src/debug.lo src/prep_cif.lo \ address@hidden@src/types.lo src/raw_api.lo src/java_raw_api.lo \ address@hidden@src/cris/sysv.lo src/cris/ffi.lo libffi_la_LIBADD = @address@hidden = src/debug.lo src/prep_cif.lo src/types.lo \ @address@hidden/raw_api.lo src/java_raw_api.lo src/sh/sysv.lo \ @@ -318,6 +323,9 @@ @address@hidden = src/debug.lo src/prep_cif.lo src/types.lo \ @address@hidden/raw_api.lo src/java_raw_api.lo src/arm/sysv.lo \ @address@hidden/arm/ffi.lo address@hidden@libffi_la_OBJECTS = src/debug.lo src/prep_cif.lo src/types.lo \ address@hidden@src/raw_api.lo src/java_raw_api.lo src/cris/sysv.lo \ address@hidden@src/cris/ffi.lo @address@hidden = src/debug.lo src/prep_cif.lo \ @address@hidden/types.lo src/raw_api.lo src/java_raw_api.lo \ @address@hidden/alpha/ffi.lo src/alpha/osf.lo @@ -615,7 +623,7 @@ mkdir $(distdir) -chmod 777 $(distdir) $(mkinstalldirs) $(distdir)/src/alpha $(distdir)/src/arm \ - $(distdir)/src/m68k $(distdir)/src/mips \ + $(distdir)/src/m68k $(distdir)/src/mips $(distdir)/src/cris \ $(distdir)/src/powerpc $(distdir)/src/s390 $(distdir)/src/sh \ $(distdir)/src/sparc $(distdir)/src/x86 @for file in $(DISTFILES); do \ diff -uNr pnet/libffi/configure pnet-cris/libffi/configure --- pnet/libffi/configure 2003-02-13 06:36:27.000000000 +0100 +++ pnet-cris/libffi/configure 2004-10-25 12:10:50.261574216 +0200 @@ -2462,6 +2462,7 @@ powerpc-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;; rs6000-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;; arm*-*-linux-*) TARGET=ARM; TARGETDIR=arm;; +cris*-*-linux-*) TARGET=CRIS32; TARGETDIR=cris;; s390-*-linux-*) TARGET=S390; TARGETDIR=s390;; s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;; x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;; @@ -2590,6 +2591,13 @@ ARM_FALSE= fi +if test x$TARGET = xCRIS32; then + CRIS32_TRUE= + CRIS32_FALSE='#' +else + CRIS32_TRUE='#' + CRIS32_FALSE= +fi if test x$TARGET = xS390; then S390_TRUE= @@ -3849,6 +3857,8 @@ address@hidden@%$POWERPC_DARWIN_FALSE%g address@hidden@%$ARM_TRUE%g address@hidden@%$ARM_FALSE%g address@hidden@%$CRIS32_TRUE%g address@hidden@%$CRIS32_FALSE%g address@hidden@%$S390_TRUE%g address@hidden@%$S390_FALSE%g address@hidden@%$X86_64_TRUE%g diff -uNr pnet/libffi/configure.in pnet-cris/libffi/configure.in --- pnet/libffi/configure.in 2004-07-16 15:48:05.000000000 +0200 +++ pnet-cris/libffi/configure.in 2004-10-25 12:10:50.262574064 +0200 @@ -72,6 +72,7 @@ powerpc-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;; rs6000-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;; arm*-*-linux-*) TARGET=ARM; TARGETDIR=arm;; +cris*-*-linux-*) TARGET=CRIS32; TARGETDIR=cris;; s390-*-linux-*) TARGET=S390; TARGETDIR=s390;; s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;; x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;; @@ -95,6 +96,7 @@ AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX) AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN) AM_CONDITIONAL(ARM, test x$TARGET = xARM) +AM_CONDITIONAL(CRIS32, test x$TARGET = xCRIS32) AM_CONDITIONAL(S390, test x$TARGET = xS390) AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64) AM_CONDITIONAL(SH, test x$TARGET = xSH) diff -uNr pnet/libffi/include/ffi.h.in pnet-cris/libffi/include/ffi.h.in --- pnet/libffi/include/ffi.h.in 2003-02-06 02:15:38.000000000 +0100 +++ pnet-cris/libffi/include/ffi.h.in 2004-10-25 12:10:50.263573912 +0200 @@ -264,6 +264,12 @@ FFI_DEFAULT_ABI = FFI_SYSV, #endif + /* ---- CRIS32 --------------------- */ +#ifdef CRIS32 + FFI_SYSV, + FFI_DEFAULT_ABI = FFI_SYSV, +#endif + /* ---- S390 --------------------- */ #ifdef S390 FFI_SYSV, diff -uNr pnet/libffi/src/cris/ffi.c pnet-cris/libffi/src/cris/ffi.c --- pnet/libffi/src/cris/ffi.c 1970-01-01 01:00:00.000000000 +0100 +++ pnet-cris/libffi/src/cris/ffi.c 2004-10-25 12:16:27.658282120 +0200 @@ -0,0 +1,194 @@ +/* ----------------------------------------------------------------------- + ffi.c - Copyright (c) 1998 Cygnus Solutions + Copyright (c) 2004 Simon Posnjak + + CRIS Foreign Function Interface + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +#include +#include + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +/address@hidden@*/ +int ffi_prep_args (char *stack, extended_cif * ecif) +/address@hidden@*/ +{ + register unsigned int i; + register unsigned int struct_count = 0; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + argp = stack; + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0); i--, p_arg++) + { + size_t z; + + /* Align if necessary */ + if (((*p_arg)->alignment - 1) & (unsigned) argp) + { + argp = (char *) ALIGN (argp, (*p_arg)->alignment); + } + + switch ((*p_arg)->type) + { + case FFI_TYPE_STRUCT: + { + z = (*p_arg)->size; + if (z <= 8) + { + memcpy (argp, *p_argv, z); + z += (4 - (z % 4)); + } + else + { + unsigned int uiLocOnStack; + + uiLocOnStack = 4 * ecif->cif->nargs + struct_count; + struct_count = struct_count + (*p_arg)->size; + *(unsigned int *) argp = + (unsigned int) (UINT32 *) (stack + uiLocOnStack); + memcpy ((stack + uiLocOnStack), *p_argv, (*p_arg)->size); + } + break; + } + default: + z = (*p_arg)->size; + if (z < sizeof (int)) + { + z = sizeof (int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int) *(SINT8 *) (*p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = + (unsigned int) *(UINT8 *) (*p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int) *(SINT16 *) (*p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = + (unsigned int) *(UINT16 *) (*p_argv); + break; + + default: + FFI_ASSERT (0); + } + } + else if (z == sizeof (int)) + { + *(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv); + } + else + { + memcpy (argp, *p_argv, z); + } + break; + } + p_argv++; + argp += z; + } + + return (struct_count); +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep (ffi_cif * cif) +{ + switch (cif->rtype->type) + { + case FFI_TYPE_VOID: + case FFI_TYPE_STRUCT: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = (unsigned) cif->rtype->type; + break; + + default: + cif->flags = FFI_TYPE_INT; + break; + } + + return FFI_OK; +} + + +/address@hidden@*/ +/address@hidden@*/ +extern void ffi_call_SYSV (void (*)(char *, extended_cif *), + /address@hidden@ */ extended_cif *, + unsigned, unsigned, + /address@hidden@ */ unsigned *, + void (*fn) ()); +/address@hidden@*/ +/address@hidden@*/ + +void ffi_call ( /address@hidden@ */ ffi_cif * cif, + void (*fn) (), + /address@hidden@ */ void *rvalue, + /address@hidden@ */ void **avalue) +{ + extended_cif ecif; + + ecif.cif = cif; + ecif.avalue = avalue; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) + { + /address@hidden@ */ + ecif.rvalue = alloca (cif->rtype->size); + /address@hidden@ */ + } + else + ecif.rvalue = rvalue; + + + switch (cif->abi) + { + case FFI_SYSV: + /address@hidden@ */ + ffi_call_SYSV (ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + /address@hidden@ */ + break; + default: + FFI_ASSERT (0); + break; + } +} diff -uNr pnet/libffi/src/cris/sysv.S pnet-cris/libffi/src/cris/sysv.S --- pnet/libffi/src/cris/sysv.S 1970-01-01 01:00:00.000000000 +0100 +++ pnet-cris/libffi/src/cris/sysv.S 2004-10-25 12:10:50.264573760 +0200 @@ -0,0 +1,163 @@ +/* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 2004 Simon Posnjak + + CRIS Foreign Function Interface + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include + + .text + + ;; OK, when we get called we should have this (according to + ;; AXIS ETRAX 100LX Programmer's Manual chapter 6.3) + ;; + ;; R10: ffi_prep_args (func. pointer) + ;; R11: &ecif + ;; R12: cif->bytes + ;; R13: fig->flags + ;; sp+0: ecif.rvalue + ;; sp+4: fn (function pointer to the function that we need to call) + + .globl ffi_call_SYSV + .type ffi_call_SYSV,@function + +ffi_call_SYSV: + ;; save the regs to the stack + Push $srp + push $r6 + push $r7 + push $r8 + push $r13 + move.d $sp,$r8 + move.d $sp,$r6 + + ;; move address of ffi_prep_args to r13 + move.d $r10, $r13 + + ;; make room on the stack for the args of fn + sub.d $r12, $sp + + ;; void ffi_prep_args(char *stack, extended_cif *ecif) + ;; so: + ;; r10 <-- stack pointer + ;; r11 <-- &ecif (already there) + move.d $sp,$r10 + + ;; load the ffi_prep_args function pointer into r13 + ;; call the function + jsr $r13 + + ;; save the size of the structures which are passed by stack + move.d $r10, $r7 + + ;; move first four args in to r10..r13 + move.d [$sp+0], $r10 + move.d [$sp+4], $r11 + move.d [$sp+8], $r12 + move.d [$sp+12], $r13 + + ;; adjust the stack + addq 16, $sp + sub.d $r7, $r6 + cmp.d $sp, $r6 + + bmi go_on_no_params_on_stack + nop + + beq go_on_no_params_on_stack + nop + + ba go_on + nop + +go_on_no_params_on_stack: + move.d $r6, $sp + +go_on: + ;; discover if we need to put rval address in to $r9 + move.d [$r8 + 0], $r7 + cmpq FFI_TYPE_STRUCT, $r7 + bne call_now + nop + + move.d [$r8 + 20], $r9 + +call_now: + ;; move address of the function in to r7 + move.d [$r8 + 24], $r7 + + ;; call the function + jsr $r7 + + ;; reset stack + move.d $r8, $sp + + ;; Load rval type in to r13 + pop $r13 + + ;; detect rval type + cmpq FFI_TYPE_VOID, $r13 + beq epilogue + nop + + cmpq FFI_TYPE_STRUCT, $r13 + beq epilogue + nop + + cmpq FFI_TYPE_DOUBLE, $r13 + beq return_double_or_longlong + nop + + cmpq FFI_TYPE_UINT64, $r13 + beq return_double_or_longlong + nop + + cmpq FFI_TYPE_SINT64, $r13 + beq return_double_or_longlong + nop + + ;; just return the 32 bit value + ba return + nop + +return_double_or_longlong: + move.d [$sp+16], $r13 + move.d $r10, [$r13] + addq 4, $r13 + move.d $r11, [$r13] + ba epilogue + nop + +return: + move.d [$sp+16], $r13 + move.d $r10, [$r13] + ba epilogue + nop + +epilogue: + pop $r8 + pop $r7 + pop $r6 + Jump [$sp+] + + .size ffi_call_SYSV,.-ffi_call_SYSV diff -uNr pnet/libffi/src/prep_cif.c pnet-cris/libffi/src/prep_cif.c --- pnet/libffi/src/prep_cif.c 2003-02-06 02:15:38.000000000 +0100 +++ pnet-cris/libffi/src/prep_cif.c 2004-10-25 12:15:48.300265448 +0200 @@ -33,6 +33,44 @@ /* Perform machine independent initialization of aggregate type specifications. */ +ffi_status initialize_aggregate_packed_params ( /address@hidden@ */ ffi_type * arg) +{ + ffi_type **ptr; + + FFI_ASSERT (arg != NULL); + + /address@hidden@ */ + + FFI_ASSERT (arg->elements != NULL); + FFI_ASSERT (arg->size == 0); + FFI_ASSERT (arg->alignment == 0); + + ptr = &(arg->elements[0]); + + while ((*ptr) != NULL) { + if (((*ptr)->size == 0) + && (initialize_aggregate_packed_params ((*ptr)) != FFI_OK)) + return FFI_BAD_TYPEDEF; + + /* Perform a sanity check on the argument type */ + FFI_ASSERT (ffi_type_test ((*ptr))); + + arg->size += (*ptr)->size; + + arg->alignment = (arg->alignment > (*ptr)->alignment) ? + arg->alignment : (*ptr)->alignment; + + ptr++; + } + + if (arg->size == 0) + return FFI_BAD_TYPEDEF; + else + return FFI_OK; + + /address@hidden@ */ +} + static ffi_status initialize_aggregate(/address@hidden@*/ ffi_type *arg) { ffi_type **ptr; @@ -104,7 +142,7 @@ FFI_ASSERT(ffi_type_test(cif->rtype)); /* x86-64 and s390 stack space allocation is handled in prep_machdep. */ -#if !defined M68K && !defined __x86_64__ && !defined S390 +#if !defined M68K && !defined __x86_64__ && !defined S390 && !defined CRIS /* Make space for the return structure pointer */ if (cif->rtype->type == FFI_TYPE_STRUCT #ifdef SPARC @@ -120,8 +158,20 @@ FFI_ASSERT(ffi_type_test(*ptr)); /* Initialize any uninitialized aggregate type definitions */ +#ifdef CRIS32 + if ((*ptr)->type == FFI_TYPE_STRUCT) + { + if (((*ptr)->size == 0) && (initialize_aggregate_packed_params((*ptr)) != FFI_OK)) + return FFI_BAD_TYPEDEF; + } + else + { +#endif if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK)) return FFI_BAD_TYPEDEF; +#ifdef CRIS32 + } +#endif #if !defined __x86_64__ && !defined S390 #ifdef SPARC @@ -136,8 +186,29 @@ /* Add any padding if necessary */ if (((*ptr)->alignment - 1) & bytes) bytes = ALIGN(bytes, (*ptr)->alignment); - +#ifdef CRIS32 + if ((*ptr)->type == FFI_TYPE_STRUCT) + { + if ((*ptr)->size > 8) + { + bytes += (*ptr)->size; + bytes += sizeof (void *); + } + else + { + if ((*ptr)->size > 4) + bytes += 8; + else + bytes += 4; + } + } + else + { + bytes += STACK_ARG_SIZE((*ptr)->size); + } +#else bytes += STACK_ARG_SIZE((*ptr)->size); +#endif } #endif } diff -uNr pnet/libffi/src/types.c pnet-cris/libffi/src/types.c --- pnet/libffi/src/types.c 2003-02-06 02:15:38.000000000 +0100 +++ pnet-cris/libffi/src/types.c 2004-10-25 12:10:50.266573456 +0200 @@ -53,7 +53,7 @@ #endif -#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K +#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K || defined CRIS32 FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64); FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64); @@ -76,7 +76,7 @@ FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE); FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE); -#elif defined ARM +#elif defined ARM || defined CRIS32 FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE); FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE); diff -uNr pnet/libgc/include/gc.h pnet-cris/libgc/include/gc.h --- pnet/libgc/include/gc.h 2004-06-16 15:06:19.000000000 +0200 +++ pnet-cris/libgc/include/gc.h 2004-10-25 12:10:50.268573152 +0200 @@ -476,6 +476,9 @@ # if defined(__i386__) || defined(__x86_64__) # define GC_CAN_SAVE_CALL_STACKS # endif +# if defined(__UCLIBC__) +# undef GC_HAVE_BUILTIN_BACKTRACE +# endif #endif #if defined(GC_HAVE_BUILTIN_BACKTRACE) && !defined(GC_CAN_SAVE_CALL_STACKS) diff -uNr pnet/libgc/include/private/gc_locks.h pnet-cris/libgc/include/private/gc_locks.h --- pnet/libgc/include/private/gc_locks.h 2004-05-27 00:33:33.000000000 +0200 +++ pnet-cris/libgc/include/private/gc_locks.h 2004-10-25 12:10:50.269573000 +0200 @@ -231,6 +231,28 @@ } # define GC_TEST_AND_SET_DEFINED # endif /* ARM32 */ +# ifdef CRIS32 + inline static int GC_test_and_set(volatile unsigned int *addr) { + /* Riped from linuxthreads/sysdeps/cris/pt-machine.h + */ + register unsigned long int ret; + + /* Note the use of a dummy output of *spinlock to expose the write. The + memory barrier is to stop *other* writes being moved past this code. */ + __asm__ __volatile__("clearf\n" + "0:\n\t" + "movu.b [%2],%0\n\t" + "ax\n\t" + "move.b %3,[%2]\n\t" + "bwf 0b\n\t" + "clearf" + : "=&r" (ret), "=m" (*addr) + : "r" (addr), "r" ((int) 1), "m" (*addr) + : "memory"); + return ret; + } +# define GC_TEST_AND_SET_DEFINED +# endif /* CRIS32 */ # ifdef S390 inline static int GC_test_and_set(volatile unsigned int *addr) { int ret; diff -uNr pnet/libgc/include/private/gcconfig.h pnet-cris/libgc/include/private/gcconfig.h --- pnet/libgc/include/private/gcconfig.h 2004-07-16 15:48:06.000000000 +0200 +++ pnet-cris/libgc/include/private/gcconfig.h 2004-10-25 12:10:50.272572544 +0200 @@ -232,6 +232,10 @@ # define ARM32 # define mach_type_known # endif +# if defined(LINUX) && defined(__cris__) +# define CRIS32 +# define mach_type_known +# endif # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || defined(powerpc64) || defined(__powerpc64__)) # define POWERPC # define mach_type_known @@ -474,6 +478,7 @@ /* POWERPC ==> IBM/Apple PowerPC */ /* (MACOS(<=9),DARWIN(incl.MACOSX),*/ /* LINUX, NETBSD, NOSYS variants) */ + /* CRIS32 ==> Axis Etrax 100LX */ /* @@ -1800,6 +1805,19 @@ # endif #endif +# ifdef CRIS32 +# define MACH_TYPE "CRIS" +# define CPP_WORDSZ 32 +# define ALIGNMENT 1 +# define OS_TYPE "LINUX" +# define DYNAMIC_LOADING +# define LINUX_STACKBOTTOM +# define USE_GENERIC_PUSH_REGS +# define SEARCH_FOR_DATA_START + extern int _end[]; +# define DATAEND (_end) +# endif + # ifdef SH # define MACH_TYPE "SH" # define ALIGNMENT 4 @@ -2048,7 +2066,7 @@ # endif # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(DARWIN) \ - || defined(LINT) || defined(MSWINCE) || defined(ARM32) \ + || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS32) \ || (defined(I386) && defined(__LCC__)) /* Use setjmp based hack to mark from callee-save registers. */ /* The define should move to the individual platform */ diff -uNr pnet/libgc/os_dep.c pnet-cris/libgc/os_dep.c --- pnet/libgc/os_dep.c 2004-07-16 15:48:05.000000000 +0200 +++ pnet-cris/libgc/os_dep.c 2004-10-25 12:10:50.276571936 +0200 @@ -2527,7 +2527,11 @@ # if defined(ARM32) char * addr = (char *)sc.fault_address; # else - --> architecture not supported +# if defined(CRIS32) + char * addr = (char *)sc.regs.csraddr; +# else + --> architecture not supported +# endif # endif # endif # endif