diff --git a/Source/mframe/README b/Source/mframe/README index 45a7e1d61..ea6c2cb5e 100644 --- a/Source/mframe/README +++ b/Source/mframe/README @@ -19,12 +19,12 @@ The code in this directory was written by Richard Frith-Macdonald . - Inspiration for this software came from the original mframe.m by - Andrew McCallum, and the libFoundation software by Ovidiu Predescu and - Mircea Oancea, while the algorithms used are copied from gcc and are - copyright the Free Software Foundation. Many code fragments are derived - from gcc by way of libFoundation. - + Inspiration for (and some of the code of) this software came from the + original mframe.m by Andrew McCallum, the gcc compiler, and the + libFoundation software by Ovidiu Predescu and Mircea Oancea. + The algorithms used are copied from gcc and are copyright the Free + Software Foundation. Many code fragments are derived from gcc either + directly or by way of libFoundation. These files are used by the configuration script to build a machine/operating-system specific 'mframe.m' file containing macros used @@ -52,7 +52,7 @@ MFRAME_SMALL_STRUCT structure return via pointe, you should also define this to zero. MFRAME_STRUCT_BYREF - This should be defined to 1 if structure aprguments are passed + This should be defined to 1 if structure arguments are passed by reference, 0 otherwise. MFRAME_ARGS_SIZE @@ -71,6 +71,11 @@ MFRAME_RESULT_SIZE value like 128 - which will probably be far larger than required (and therefore somewhat inefficient) but will msot likely work. +MFRAME_FLT_IN_FRAME_AS_DBL + This should be defined as 1 if float parameters to functions and + objective-c methods are passed on the stack as double values. + Otherwise it should not be defined. + MFRAME_STRUCT_ADDR(ARGFRAME,TYPES) If a function returns a structure by copying it into a location whose address is set by the caller, this macro must return that diff --git a/Source/mframe/hppa/generic b/Source/mframe/hppa/generic index 677f3b76d..8c8bb6753 100644 --- a/Source/mframe/hppa/generic +++ b/Source/mframe/hppa/generic @@ -6,36 +6,46 @@ #define MFRAME_RESULT_SIZE 16 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ - **(void***)(ARGS) : (void*)0) +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + **(void***)(ARGS) : (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ - **(void***)(ARGS) = (ADDR);}) +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + **(void***)(ARGS) = (ADDR);}) #define MFRAME_ARGS int #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ - *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ \ - (CUM) = ROUND((CUM), align); \ - (TYPE) = objc_skip_typespec(type); \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ - (STACK) = (CUM) + ROUND(size, align); \ - else \ - (STACK) = (CUM) + size; \ - ((((CUM) & 01) && ((size+3)/4) > 1) && (CUM)++); \ - (CUM) += ((size+3)/4); \ - }) + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + ((((CUM) & 01) && ((size+3)/4) > 1) && (CUM)++); \ + (CUM) += ((size+3)/4); \ +}) diff --git a/Source/mframe/i386/generic b/Source/mframe/i386/generic index e37f09ac5..a6cfffb10 100644 --- a/Source/mframe/i386/generic +++ b/Source/mframe/i386/generic @@ -6,35 +6,42 @@ #define MFRAME_RESULT_SIZE 116 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ - *(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0) +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ - *(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);}) +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);}) #define MFRAME_ARGS int #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ - *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ \ - (CUM) = ROUND((CUM), align); \ - (TYPE) = objc_skip_typespec(type); \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ - (STACK) = (CUM) + ROUND(size, align); \ - else \ - (STACK) = (CUM) + size; \ - (CUM) += ROUND(size, sizeof(void*)); \ - }) + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') (TYPE)++; \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) diff --git a/Source/mframe/i386/linux b/Source/mframe/i386/linux index 68c9176cd..9b9f1ffcc 100644 --- a/Source/mframe/i386/linux +++ b/Source/mframe/i386/linux @@ -6,35 +6,45 @@ #define MFRAME_RESULT_SIZE 116 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ - *(void**)(ARGS)->arg_ptr : (void*)0) +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(ARGS)->arg_ptr : (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ - *(void**)(ARGS)->arg_ptr = (ADDR);}) +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(ARGS)->arg_ptr = (ADDR);}) #define MFRAME_ARGS int #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ - *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ \ - (CUM) = ROUND((CUM), align); \ - (TYPE) = objc_skip_typespec(type); \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ - (STACK) = (CUM) + ROUND(size, align); \ - else \ - (STACK) = (CUM) + size; \ - (CUM) += ROUND(size, sizeof(void*)); \ - }) + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) diff --git a/Source/mframe/i386/linux-gnu b/Source/mframe/i386/linux-gnu index 68c9176cd..9b9f1ffcc 100644 --- a/Source/mframe/i386/linux-gnu +++ b/Source/mframe/i386/linux-gnu @@ -6,35 +6,45 @@ #define MFRAME_RESULT_SIZE 116 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ - *(void**)(ARGS)->arg_ptr : (void*)0) +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(ARGS)->arg_ptr : (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ - *(void**)(ARGS)->arg_ptr = (ADDR);}) +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(ARGS)->arg_ptr = (ADDR);}) #define MFRAME_ARGS int #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ - *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ \ - (CUM) = ROUND((CUM), align); \ - (TYPE) = objc_skip_typespec(type); \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ - (STACK) = (CUM) + ROUND(size, align); \ - else \ - (STACK) = (CUM) + size; \ - (CUM) += ROUND(size, sizeof(void*)); \ - }) + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) diff --git a/Source/mframe/i386/sysv4.2MP b/Source/mframe/i386/sysv4.2MP index ea2105a2f..7e98712f3 100644 --- a/Source/mframe/i386/sysv4.2MP +++ b/Source/mframe/i386/sysv4.2MP @@ -6,35 +6,45 @@ #define MFRAME_RESULT_SIZE 116 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ - *(void**)(ARGS)->arg_ptr : (void*)0) +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(ARGS)->arg_ptr : (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ - *(void**)(ARGS)->arg_ptr = (ADDR);}) +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(ARGS)->arg_ptr = (ADDR);}) #define MFRAME_ARGS int #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ - *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ \ - (CUM) = ROUND((CUM), align); \ - (TYPE) = objc_skip_typespec(type); \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ - (STACK) = (CUM) + ROUND(size, align); \ - else \ - (STACK) = (CUM) + size; \ - (CUM) += ROUND(size, sizeof(void*)); \ - }) + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) diff --git a/Source/mframe/mframe.foot b/Source/mframe/mframe.foot index 79b9c22d0..caf504534 100644 --- a/Source/mframe/mframe.foot +++ b/Source/mframe/mframe.foot @@ -2,67 +2,90 @@ inline static void* mframe_arg_addr(arglist_t argf, NSArgumentInfo *info) { - int offset = info->offset; + int offset = info->offset; #if WORDS_BIGENDIAN - if (info->size < sizeof(int)) - offset += sizeof(int) - info->size; + if (info->size < sizeof(int)) + { + offset += sizeof(int) - info->size; + } #endif - if (info->isReg) - return(argf->arg_regs + offset); - else - return(argf->arg_ptr + offset); + if (info->isReg) + { + return(argf->arg_regs + offset); + } + else + { + return(argf->arg_ptr + offset); + } } inline static void mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer) { #if MFRAME_STRUCT_BYREF - const char *typ = info->type; + const char *typ = info->type; - /* - * If structures are passed in the stack frame by reference - we need - * to copy the actual structure, rather than it's pointer. - */ - if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) { - memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size); + /* + * If structures are passed in the stack frame by reference - we need + * to copy the actual structure, rather than it's pointer. + */ + if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) + { + memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size); } - else + else #endif - memcpy(buffer, mframe_arg_addr(argf, info), info->size); +#if MFRAME_FLT_IN_FRAME_AS_DBL + if (*typ == _C_FLT) + { + *(float*)buffer = (float)*(double*)mframe_arg_addr(argf, info); + } + else +#endif + memcpy(buffer, mframe_arg_addr(argf, info), info->size); } inline static void mframe_set_arg(arglist_t argf, NSArgumentInfo *info, void* buffer) { #if MFRAME_STRUCT_BYREF - const char *typ = info->type; + const char *typ = info->type; - /* - * If structures are passed in the stack frame by reference - we need - * to copy a pointer onto the stack rather than the actual structure. - */ - if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) { - memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*)); + /* + * If structures are passed in the stack frame by reference - we need + * to copy a pointer onto the stack rather than the actual structure. + */ + if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) + { + memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*)); } - else + else #endif - memcpy(mframe_arg_addr(argf, info), buffer, info->size); +#if MFRAME_FLT_IN_FRAME_AS_DBL + if (*typ == _C_FLT) + { + *(double*)mframe_arg_addr(argf, info) = *(float*)buffer; + } + else +#endif + memcpy(mframe_arg_addr(argf, info), buffer, info->size); } inline static void mframe_cpy_arg(arglist_t dst, arglist_t src, NSArgumentInfo *info) { #if MFRAME_STRUCT_BYREF - const char *typ = info->type; + const char *typ = info->type; - /* - * If structures are passed in the stack frame by reference - we need - * to copy a pointer onto the stack rather than the actual structure. - */ - if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) { - memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), sizeof(void*)); + /* + * If structures are passed in the stack frame by reference - we need + * to copy a pointer onto the stack rather than the actual structure. + */ + if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) + { + memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), sizeof(void*)); } - else + else #endif memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), info->size); } diff --git a/Source/mframe/mframe.head b/Source/mframe/mframe.head index 0408a00f1..71f746b3e 100644 --- a/Source/mframe/mframe.head +++ b/Source/mframe/mframe.head @@ -1,5 +1,5 @@ /* Interface for functions that dissect/make method calls - Copyright (C) 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc. Written by: Andrew Kachites McCallum Created: Oct 1994 @@ -31,8 +31,8 @@ #if NeXT_runtime typedef union { - char *arg_ptr; - char arg_regs[sizeof (char*)]; + char *arg_ptr; + char arg_regs[sizeof (char*)]; } *arglist_t; #endif diff --git a/Source/mframe/sparc/generic b/Source/mframe/sparc/generic index 9b5289010..8a7caf027 100644 --- a/Source/mframe/sparc/generic +++ b/Source/mframe/sparc/generic @@ -6,64 +6,83 @@ #define MFRAME_RESULT_SIZE 16 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ - *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ - *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) #define IN_REGS 0 #define ON_STACK 1 struct sparc_args { - int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ - int onStack; + int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ + int onStack; }; #define MFRAME_ARGS struct sparc_args #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ({ (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \ - (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \ - (CUM).onStack = NO; }) +({ \ + (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \ + (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \ + (CUM).onStack = NO; \ +}) #define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \ - ((CUM).onStack \ - ? ON_STACK \ - : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ - ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ - ? 0 : ((CUM).offsets[ON_STACK] += 4)),\ - IN_REGS) \ - : ((CUM).onStack = YES, ON_STACK))) +((CUM).onStack \ + ? ON_STACK \ + : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ + ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ + ? 0 : ((CUM).offsets[ON_STACK] += 4)),\ + IN_REGS) \ + : ((CUM).onStack = YES, ON_STACK))) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ - int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ + int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ \ - (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ - if (size < sizeof(int)) \ - (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ - (TYPE) = objc_skip_typespec(type); \ - if (locn == IN_REGS) \ - sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ - else \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if (locn == ON_STACK) { \ - if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ - (STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ - else \ - (STACK) = (CUM).offsets[ON_STACK] + size; \ + (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ + if (size < sizeof(int)) \ + { \ + (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ + } \ + (TYPE) = objc_skip_typespec(type); \ + if (locn == IN_REGS) \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (locn == ON_STACK) \ + { \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ } \ - (CUM).offsets[locn] += \ - size < sizeof(int) \ - ? ROUND(size, align) \ - : ROUND(size, sizeof(void*)); \ - }) + else \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + size; \ + } \ + } \ + (CUM).offsets[locn] += \ + size < sizeof(int) \ + ? ROUND(size, align) \ + : ROUND(size, sizeof(void*)); \ +}) diff --git a/Source/mframe/sparc/sunos4.1.3 b/Source/mframe/sparc/sunos4.1.3 index 9b5289010..8a7caf027 100644 --- a/Source/mframe/sparc/sunos4.1.3 +++ b/Source/mframe/sparc/sunos4.1.3 @@ -6,64 +6,83 @@ #define MFRAME_RESULT_SIZE 16 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ - *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ - *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) #define IN_REGS 0 #define ON_STACK 1 struct sparc_args { - int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ - int onStack; + int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ + int onStack; }; #define MFRAME_ARGS struct sparc_args #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ({ (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \ - (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \ - (CUM).onStack = NO; }) +({ \ + (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \ + (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \ + (CUM).onStack = NO; \ +}) #define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \ - ((CUM).onStack \ - ? ON_STACK \ - : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ - ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ - ? 0 : ((CUM).offsets[ON_STACK] += 4)),\ - IN_REGS) \ - : ((CUM).onStack = YES, ON_STACK))) +((CUM).onStack \ + ? ON_STACK \ + : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ + ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ + ? 0 : ((CUM).offsets[ON_STACK] += 4)),\ + IN_REGS) \ + : ((CUM).onStack = YES, ON_STACK))) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ - int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ + int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ \ - (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ - if (size < sizeof(int)) \ - (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ - (TYPE) = objc_skip_typespec(type); \ - if (locn == IN_REGS) \ - sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ - else \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if (locn == ON_STACK) { \ - if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ - (STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ - else \ - (STACK) = (CUM).offsets[ON_STACK] + size; \ + (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ + if (size < sizeof(int)) \ + { \ + (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ + } \ + (TYPE) = objc_skip_typespec(type); \ + if (locn == IN_REGS) \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (locn == ON_STACK) \ + { \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ } \ - (CUM).offsets[locn] += \ - size < sizeof(int) \ - ? ROUND(size, align) \ - : ROUND(size, sizeof(void*)); \ - }) + else \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + size; \ + } \ + } \ + (CUM).offsets[locn] += \ + size < sizeof(int) \ + ? ROUND(size, align) \ + : ROUND(size, sizeof(void*)); \ +}) diff --git a/Source/mframe/unknown/generic b/Source/mframe/unknown/generic index 90c5c669f..d37f48043 100644 --- a/Source/mframe/unknown/generic +++ b/Source/mframe/unknown/generic @@ -6,40 +6,50 @@ #define MFRAME_RESULT_SIZE 128 #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ - (((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) && \ - objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) ? \ - *(void**)((ARGS)->arg_ptr + sizeof(void*)) : (void*)0) +(((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) && \ + objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) ? \ + *(void**)((ARGS)->arg_ptr + sizeof(void*)) : (void*)0) #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ - ({if ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || \ - *(TYPES)==_C_ARY_B) && \ - objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) \ - *(void**)((ARGS)->arg_ptr + sizeof(void*)) = (ADDR);}) +({if ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || \ + *(TYPES)==_C_ARY_B) && \ + objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) \ + *(void**)((ARGS)->arg_ptr + sizeof(void*)) = (ADDR);}) #define MFRAME_ARGS int #define MFRAME_INIT_ARGS(CUM, RTYPE) \ - ((CUM) = ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ - *(RTYPE)==_C_ARY_B) && \ - objc_sizeof_type(RTYPE) > MFRAME_SMALL_STRUCT) \ - ? sizeof(void*) : 0) +((CUM) = ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) && \ + objc_sizeof_type(RTYPE) > MFRAME_SMALL_STRUCT) \ + ? sizeof(void*) : 0) #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ - ({ \ - const char* type = (TYPE); \ - int align = objc_alignof_type(type); \ - int size = objc_sizeof_type(type); \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ \ - (CUM) = ROUND((CUM), align); \ - (TYPE) = objc_skip_typespec(type); \ - sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ - if (*(TYPE) == '+') (TYPE)++; \ - while (isdigit(*(TYPE))) (TYPE)++; \ - (DEST)=&(DEST)[strlen(DEST)]; \ - if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ - (STACK) = (CUM) + ROUND(size, align); \ - else \ - (STACK) = (CUM) + size; \ - (CUM) += ROUND(size, sizeof(void*)); \ - }) + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +})