Tidied indents

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3151 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1998-11-02 09:38:25 +00:00
parent 776f91d7ec
commit af00f419e8
11 changed files with 388 additions and 265 deletions

View file

@ -19,12 +19,12 @@
The code in this directory was written by The code in this directory was written by
Richard Frith-Macdonald <richard@brainstorm.co.uk>. Richard Frith-Macdonald <richard@brainstorm.co.uk>.
Inspiration for this software came from the original mframe.m by Inspiration for (and some of the code of) this software came from the
Andrew McCallum, and the libFoundation software by Ovidiu Predescu and original mframe.m by Andrew McCallum, the gcc compiler, and the
Mircea Oancea, while the algorithms used are copied from gcc and are libFoundation software by Ovidiu Predescu and Mircea Oancea.
copyright the Free Software Foundation. Many code fragments are derived The algorithms used are copied from gcc and are copyright the Free
from gcc by way of libFoundation. 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 These files are used by the configuration script to build a
machine/operating-system specific 'mframe.m' file containing macros used 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. structure return via pointe, you should also define this to zero.
MFRAME_STRUCT_BYREF 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. by reference, 0 otherwise.
MFRAME_ARGS_SIZE MFRAME_ARGS_SIZE
@ -71,6 +71,11 @@ MFRAME_RESULT_SIZE
value like 128 - which will probably be far larger than required value like 128 - which will probably be far larger than required
(and therefore somewhat inefficient) but will msot likely work. (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) MFRAME_STRUCT_ADDR(ARGFRAME,TYPES)
If a function returns a structure by copying it into a location If a function returns a structure by copying it into a location
whose address is set by the caller, this macro must return that whose address is set by the caller, this macro must return that

View file

@ -6,36 +6,46 @@
#define MFRAME_RESULT_SIZE 16 #define MFRAME_RESULT_SIZE 16
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
**(void***)(ARGS) : (void*)0) **(void***)(ARGS) : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
**(void***)(ARGS) = (ADDR);}) **(void***)(ARGS) = (ADDR);})
#define MFRAME_ARGS int #define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
\ \
(CUM) = ROUND((CUM), align); \ (CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \ (TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \ if (*(TYPE) == '+') \
while (isdigit(*(TYPE))) (TYPE)++; \ { \
(DEST)=&(DEST)[strlen(DEST)]; \ (TYPE)++; \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ } \
(STACK) = (CUM) + ROUND(size, align); \ while (isdigit(*(TYPE))) \
else \ { \
(STACK) = (CUM) + size; \ (TYPE)++; \
((((CUM) & 01) && ((size+3)/4) > 1) && (CUM)++); \ } \
(CUM) += ((size+3)/4); \ (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); \
})

View file

@ -6,35 +6,42 @@
#define MFRAME_RESULT_SIZE 116 #define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0) *(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);}) *(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);})
#define MFRAME_ARGS int #define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
\ \
(CUM) = ROUND((CUM), align); \ (CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \ (TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \ if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \ while (isdigit(*(TYPE))) \
(DEST)=&(DEST)[strlen(DEST)]; \ { \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ (TYPE)++; \
(STACK) = (CUM) + ROUND(size, align); \ } \
else \ (DEST)=&(DEST)[strlen(DEST)]; \
(STACK) = (CUM) + size; \ if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
(CUM) += ROUND(size, sizeof(void*)); \ { \
}) (STACK) = (CUM) + ROUND(size, align); \
} \
else \
{ \
(STACK) = (CUM) + size; \
} \
(CUM) += ROUND(size, sizeof(void*)); \
})

View file

@ -6,35 +6,45 @@
#define MFRAME_RESULT_SIZE 116 #define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0) *(void**)(ARGS)->arg_ptr : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);}) *(void**)(ARGS)->arg_ptr = (ADDR);})
#define MFRAME_ARGS int #define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
\ \
(CUM) = ROUND((CUM), align); \ (CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \ (TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \ if (*(TYPE) == '+') \
while (isdigit(*(TYPE))) (TYPE)++; \ { \
(DEST)=&(DEST)[strlen(DEST)]; \ (TYPE)++; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ } \
(STACK) = (CUM) + ROUND(size, align); \ while (isdigit(*(TYPE))) \
else \ { \
(STACK) = (CUM) + size; \ (TYPE)++; \
(CUM) += ROUND(size, sizeof(void*)); \ } \
}) (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*)); \
})

View file

@ -6,35 +6,45 @@
#define MFRAME_RESULT_SIZE 116 #define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0) *(void**)(ARGS)->arg_ptr : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);}) *(void**)(ARGS)->arg_ptr = (ADDR);})
#define MFRAME_ARGS int #define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
\ \
(CUM) = ROUND((CUM), align); \ (CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \ (TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \ if (*(TYPE) == '+') \
while (isdigit(*(TYPE))) (TYPE)++; \ { \
(DEST)=&(DEST)[strlen(DEST)]; \ (TYPE)++; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ } \
(STACK) = (CUM) + ROUND(size, align); \ while (isdigit(*(TYPE))) \
else \ { \
(STACK) = (CUM) + size; \ (TYPE)++; \
(CUM) += ROUND(size, sizeof(void*)); \ } \
}) (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*)); \
})

View file

@ -6,35 +6,45 @@
#define MFRAME_RESULT_SIZE 116 #define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0) *(void**)(ARGS)->arg_ptr : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);}) *(void**)(ARGS)->arg_ptr = (ADDR);})
#define MFRAME_ARGS int #define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ ((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
\ \
(CUM) = ROUND((CUM), align); \ (CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \ (TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \ if (*(TYPE) == '+') \
while (isdigit(*(TYPE))) (TYPE)++; \ { \
(DEST)=&(DEST)[strlen(DEST)]; \ (TYPE)++; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ } \
(STACK) = (CUM) + ROUND(size, align); \ while (isdigit(*(TYPE))) \
else \ { \
(STACK) = (CUM) + size; \ (TYPE)++; \
(CUM) += ROUND(size, sizeof(void*)); \ } \
}) (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*)); \
})

View file

@ -2,67 +2,90 @@
inline static void* inline static void*
mframe_arg_addr(arglist_t argf, NSArgumentInfo *info) mframe_arg_addr(arglist_t argf, NSArgumentInfo *info)
{ {
int offset = info->offset; int offset = info->offset;
#if WORDS_BIGENDIAN #if WORDS_BIGENDIAN
if (info->size < sizeof(int)) if (info->size < sizeof(int))
offset += sizeof(int) - info->size; {
offset += sizeof(int) - info->size;
}
#endif #endif
if (info->isReg) if (info->isReg)
return(argf->arg_regs + offset); {
else return(argf->arg_regs + offset);
return(argf->arg_ptr + offset); }
else
{
return(argf->arg_ptr + offset);
}
} }
inline static void inline static void
mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer) mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
{ {
#if MFRAME_STRUCT_BYREF #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 * If structures are passed in the stack frame by reference - we need
* to copy the actual structure, rather than it's pointer. * to copy the actual structure, rather than it's pointer.
*/ */
if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) { if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size); {
memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size);
} }
else else
#endif #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 inline static void
mframe_set_arg(arglist_t argf, NSArgumentInfo *info, void* buffer) mframe_set_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
{ {
#if MFRAME_STRUCT_BYREF #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 * If structures are passed in the stack frame by reference - we need
* to copy a pointer onto the stack rather than the actual structure. * 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) { if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*)); {
memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*));
} }
else else
#endif #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 inline static void
mframe_cpy_arg(arglist_t dst, arglist_t src, NSArgumentInfo *info) mframe_cpy_arg(arglist_t dst, arglist_t src, NSArgumentInfo *info)
{ {
#if MFRAME_STRUCT_BYREF #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 * If structures are passed in the stack frame by reference - we need
* to copy a pointer onto the stack rather than the actual structure. * 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) { 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*)); {
memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), sizeof(void*));
} }
else else
#endif #endif
memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), info->size); memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), info->size);
} }

View file

@ -1,5 +1,5 @@
/* Interface for functions that dissect/make method calls /* 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 <mccallum@gnu.ai.mit.edu> Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: Oct 1994 Created: Oct 1994
@ -31,8 +31,8 @@
#if NeXT_runtime #if NeXT_runtime
typedef union { typedef union {
char *arg_ptr; char *arg_ptr;
char arg_regs[sizeof (char*)]; char arg_regs[sizeof (char*)];
} *arglist_t; } *arglist_t;
#endif #endif

View file

@ -6,64 +6,83 @@
#define MFRAME_RESULT_SIZE 16 #define MFRAME_RESULT_SIZE 16
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);})
#define IN_REGS 0 #define IN_REGS 0
#define ON_STACK 1 #define ON_STACK 1
struct sparc_args { struct sparc_args {
int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */
int onStack; int onStack;
}; };
#define MFRAME_ARGS struct sparc_args #define MFRAME_ARGS struct sparc_args
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #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).offsets[0] = 8; /* encoding in regs starts from 8 */ \
(CUM).onStack = NO; }) (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \
(CUM).onStack = NO; \
})
#define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \ #define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \
((CUM).onStack \ ((CUM).onStack \
? ON_STACK \ ? ON_STACK \
: ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \
? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \
? 0 : ((CUM).offsets[ON_STACK] += 4)),\ ? 0 : ((CUM).offsets[ON_STACK] += 4)),\
IN_REGS) \ IN_REGS) \
: ((CUM).onStack = YES, ON_STACK))) : ((CUM).onStack = YES, ON_STACK)))
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \
\ \
(CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \
if (size < sizeof(int)) \ if (size < sizeof(int)) \
(CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ { \
(TYPE) = objc_skip_typespec(type); \ (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \
if (locn == IN_REGS) \ } \
sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ (TYPE) = objc_skip_typespec(type); \
else \ if (locn == IN_REGS) \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ { \
if (*(TYPE) == '+') (TYPE)++; \ sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \
while (isdigit(*(TYPE))) (TYPE)++; \ } \
(DEST)=&(DEST)[strlen(DEST)]; \ else \
if (locn == ON_STACK) { \ { \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \
(STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ } \
else \ if (*(TYPE) == '+') \
(STACK) = (CUM).offsets[ON_STACK] + size; \ { \
(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] += \ else \
size < sizeof(int) \ { \
? ROUND(size, align) \ (STACK) = (CUM).offsets[ON_STACK] + size; \
: ROUND(size, sizeof(void*)); \ } \
}) } \
(CUM).offsets[locn] += \
size < sizeof(int) \
? ROUND(size, align) \
: ROUND(size, sizeof(void*)); \
})

View file

@ -6,64 +6,83 @@
#define MFRAME_RESULT_SIZE 16 #define MFRAME_RESULT_SIZE 16
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ ({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);})
#define IN_REGS 0 #define IN_REGS 0
#define ON_STACK 1 #define ON_STACK 1
struct sparc_args { struct sparc_args {
int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */
int onStack; int onStack;
}; };
#define MFRAME_ARGS struct sparc_args #define MFRAME_ARGS struct sparc_args
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #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).offsets[0] = 8; /* encoding in regs starts from 8 */ \
(CUM).onStack = NO; }) (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \
(CUM).onStack = NO; \
})
#define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \ #define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \
((CUM).onStack \ ((CUM).onStack \
? ON_STACK \ ? ON_STACK \
: ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \
? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \
? 0 : ((CUM).offsets[ON_STACK] += 4)),\ ? 0 : ((CUM).offsets[ON_STACK] += 4)),\
IN_REGS) \ IN_REGS) \
: ((CUM).onStack = YES, ON_STACK))) : ((CUM).onStack = YES, ON_STACK)))
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \
\ \
(CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \
if (size < sizeof(int)) \ if (size < sizeof(int)) \
(CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ { \
(TYPE) = objc_skip_typespec(type); \ (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \
if (locn == IN_REGS) \ } \
sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ (TYPE) = objc_skip_typespec(type); \
else \ if (locn == IN_REGS) \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ { \
if (*(TYPE) == '+') (TYPE)++; \ sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \
while (isdigit(*(TYPE))) (TYPE)++; \ } \
(DEST)=&(DEST)[strlen(DEST)]; \ else \
if (locn == ON_STACK) { \ { \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \
(STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ } \
else \ if (*(TYPE) == '+') \
(STACK) = (CUM).offsets[ON_STACK] + size; \ { \
(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] += \ else \
size < sizeof(int) \ { \
? ROUND(size, align) \ (STACK) = (CUM).offsets[ON_STACK] + size; \
: ROUND(size, sizeof(void*)); \ } \
}) } \
(CUM).offsets[locn] += \
size < sizeof(int) \
? ROUND(size, align) \
: ROUND(size, sizeof(void*)); \
})

View file

@ -6,40 +6,50 @@
#define MFRAME_RESULT_SIZE 128 #define MFRAME_RESULT_SIZE 128
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ #define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
(((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) && \ (((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) && \
objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) ? \ objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) ? \
*(void**)((ARGS)->arg_ptr + sizeof(void*)) : (void*)0) *(void**)((ARGS)->arg_ptr + sizeof(void*)) : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ #define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || \ ({if ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || \
*(TYPES)==_C_ARY_B) && \ *(TYPES)==_C_ARY_B) && \
objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) \ objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) \
*(void**)((ARGS)->arg_ptr + sizeof(void*)) = (ADDR);}) *(void**)((ARGS)->arg_ptr + sizeof(void*)) = (ADDR);})
#define MFRAME_ARGS int #define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \ #define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ ((CUM) = ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) && \ *(RTYPE)==_C_ARY_B) && \
objc_sizeof_type(RTYPE) > MFRAME_SMALL_STRUCT) \ objc_sizeof_type(RTYPE) > MFRAME_SMALL_STRUCT) \
? sizeof(void*) : 0) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ #define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \ ({ \
const char* type = (TYPE); \ const char* type = (TYPE); \
int align = objc_alignof_type(type); \ int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \ int size = objc_sizeof_type(type); \
\ \
(CUM) = ROUND((CUM), align); \ (CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \ (TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \ if (*(TYPE) == '+') \
while (isdigit(*(TYPE))) (TYPE)++; \ { \
(DEST)=&(DEST)[strlen(DEST)]; \ (TYPE)++; \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ } \
(STACK) = (CUM) + ROUND(size, align); \ while (isdigit(*(TYPE))) \
else \ { \
(STACK) = (CUM) + size; \ (TYPE)++; \
(CUM) += ROUND(size, sizeof(void*)); \ } \
}) (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*)); \
})