Build with non-fragile ivars.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29715 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-02-24 10:23:47 +00:00
parent d26e836e7b
commit 48070cb1ca
16 changed files with 8036 additions and 7966 deletions

View file

@ -36,6 +36,7 @@ extern "C" {
@interface NSInvocation : NSObject
{
#if GS_EXPOSE(NSInvocation)
@public
NSMethodSignature *_sig;
void *_cframe;
void *_retval;

View file

@ -110,7 +110,7 @@ struct _NSNotificationQueueList;
@interface NSNotificationQueue : NSObject
{
#if GS_EXPOSE(NSNotificationQueue)
@private
@public
NSNotificationCenter *_center;
struct _NSNotificationQueueList *_asapQueue;
struct _NSNotificationQueueList *_idleQueue;

View file

@ -51,6 +51,7 @@
#include <openssl/crypto.h>
#undef id
#define EXPOSE_GSFileHandle_IVARS 1
#import "Foundation/NSDebug.h"
#import "Foundation/NSFileHandle.h"
#import "Foundation/NSFileManager.h"

View file

@ -1190,9 +1190,6 @@ GSObjCGetInstanceVariableDefinition(Class cls, NSString *name)
return GSCGetInstanceVariableDefinition(cls, [name cString]);
}
typedef struct {
@defs(Protocol)
} *pcl;
GS_STATIC_INLINE unsigned int
gs_string_hash(const char *s)
@ -1205,19 +1202,19 @@ gs_string_hash(const char *s)
return val;
}
GS_STATIC_INLINE pcl
GS_STATIC_INLINE Protocol *
gs_find_protocol_named_in_protocol_list(const char *name,
struct objc_protocol_list *pcllist)
struct objc_protocol_list *pcllist)
{
pcl p = NULL;
Protocol *p = NULL;
size_t i;
while (pcllist != NULL)
{
for (i=0; i<pcllist->count; i++)
for (i = 0; i < pcllist->count; i++)
{
p = (pcl)pcllist->list[i];
if (strcmp(p->protocol_name, name) == 0)
p = (Protocol*)pcllist->list[i];
if (strcmp([p name], name) == 0)
{
return p;
}
@ -1227,10 +1224,10 @@ gs_find_protocol_named_in_protocol_list(const char *name,
return NULL;
}
GS_STATIC_INLINE pcl
GS_STATIC_INLINE Protocol *
gs_find_protocol_named(const char *name)
{
pcl p = NULL;
Protocol *p = NULL;
Class cls;
#ifdef NeXT_RUNTIME
Class *clsList, *clsListStart;
@ -1307,17 +1304,14 @@ GSRegisterProtocol(Protocol *proto)
if (proto != nil)
{
GSIMapNode node;
pcl p;
p = (pcl)proto;
pthread_mutex_lock(&protocol_by_name_lock);
node = GSIMapNodeForKey(&protocol_by_name,
(GSIMapKey) p->protocol_name);
node = GSIMapNodeForKey(&protocol_by_name, (GSIMapKey) [proto name]);
if (node == 0)
{
GSIMapAddPairNoRetain(&protocol_by_name,
(GSIMapKey) (void *) p->protocol_name,
(GSIMapVal) (void *) p);
(GSIMapKey) (void *) [proto name],
(GSIMapVal) (void *) proto);
}
pthread_mutex_unlock(&protocol_by_name_lock);
}
@ -1327,7 +1321,7 @@ Protocol *
GSProtocolFromName(const char *name)
{
GSIMapNode node;
pcl p;
Protocol *p;
if (protocol_by_name_init == NO)
{
@ -1356,15 +1350,15 @@ GSProtocolFromName(const char *name)
/* Use the protocol's name to save us from allocating
a copy of the parameter 'name'. */
GSIMapAddPairNoRetain(&protocol_by_name,
(GSIMapKey) (void *) p->protocol_name,
(GSIMapVal) (void *) p);
(GSIMapKey) (void *) [p name],
(GSIMapVal) (void *) p);
}
}
pthread_mutex_unlock(&protocol_by_name_lock);
}
return (Protocol *)p;
return p;
}
@ -2360,13 +2354,15 @@ GSAutoreleasedBuffer(unsigned size)
static Class autorelease_class;
static SEL autorelease_sel;
static IMP autorelease_imp;
static int instance_size;
static int offset;
NSObject *o;
if (buffer_class == 0)
{
buffer_class = [GSAutoreleasedMemory class];
offset = buffer_class->instance_size % ALIGN;
instance_size = class_getInstanceSize(buffer_class);
offset = instance_size % ALIGN;
autorelease_class = [NSAutoreleasePool class];
autorelease_sel = @selector(addObject:);
autorelease_imp = [autorelease_class methodForSelector: autorelease_sel];
@ -2374,7 +2370,7 @@ GSAutoreleasedBuffer(unsigned size)
o = (NSObject*)NSAllocateObject(buffer_class,
size + offset, NSDefaultMallocZone());
(*autorelease_imp)(autorelease_class, autorelease_sel, o);
return ((void*)&o[1]) + offset;
return ((void*)o) + instance_size + offset;
#endif
}

View file

@ -24,6 +24,7 @@
#import "common.h"
#define EXPOSE_NSInvocation_IVARS 1
#import "Foundation/NSException.h"
#import "Foundation/NSCoder.h"
#import "Foundation/NSDistantObject.h"
@ -38,10 +39,6 @@
#define INLINE inline
#endif
typedef struct _NSInvocation_t {
@defs(NSInvocation)
} NSInvocation_t;
/* Function that implements the actual forwarding */
typedef void (*ffi_closure_fun) (ffi_cif*,void*,void**,void*);
@ -392,10 +389,8 @@ static id gs_objc_proxy_lookup(id receiver, SEL op)
* routines (like the DO forwarding)
*/
void
GSFFIInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp)
GSFFIInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp)
{
NSInvocation_t *inv = (NSInvocation_t*)_inv;
/* Do it */
ffi_call(inv->_cframe, (f_fun)imp, (inv->_retval),
((cifframe_t *)inv->_cframe)->values);
@ -642,7 +637,7 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
/* If we are returning a value, we must copy it from the invocation
* to the memory indicated by 'retp'.
*/
if (retp != 0 && ((NSInvocation_t *)invocation)->_validReturn == YES)
if (retp != 0 && invocation->_validReturn == YES)
{
[invocation getReturnValue: retp];
}

View file

@ -26,7 +26,7 @@
*/
#import "common.h"
#define EXPOSE_NSNSDateFormatter_IVARS 1
#define EXPOSE_NSDateFormatter_IVARS 1
#import "Foundation/NSDate.h"
#import "Foundation/NSCalendarDate.h"
#import "Foundation/NSTimeZone.h"

View file

@ -34,7 +34,8 @@
#import "common.h"
#define EXPOSE_NSNSDecimalNumber_IVARS 1
#define EXPOSE_NSDecimalNumber_IVARS 1
#define EXPOSE_NSDecimalNumberHandler_IVARS 1
#import "Foundation/NSCoder.h"
#import "Foundation/NSDecimal.h"
#import "Foundation/NSDecimalNumber.h"

View file

@ -69,10 +69,6 @@ static int debug_proxy = 0;
static Class placeHolder = 0;
static Class distantObjectClass = 0;
typedef struct {
@defs(NSDistantObject)
} NSDO;
@interface Object (NSConformsToProtocolNamed)
- (BOOL) _conformsToProtocolNamed: (char*)aName;
@end
@ -81,25 +77,24 @@ typedef struct {
@end
/*
* Evil hack ... if a remote system wants to know if we conform
* to a protocol we pretend we have a local protocol with the same name.
* to a protocol we usa a local protocol with the same name.
*/
typedef struct {
@defs(Protocol)
} Proto;
@implementation Object (NSConformsToProtocolNamed)
- (BOOL) _conformsToProtocolNamed: (char*)aName
{
Proto p;
p.protocol_name = (char*)aName;
return [self conformsTo: (Protocol*)&p];
Protocol *p;
p = objc_getProtocol(aName);
return [self conformsTo: p];
}
@end
@implementation NSObject (NSConformsToProtocolNamed)
- (BOOL) _conformsToProtocolNamed: (char*)aName
{
Proto p;
p.protocol_name = (char*)aName;
return [self conformsToProtocol: (Protocol*)&p];
Protocol *p;
p = objc_getProtocol(aName);
return [self conformsToProtocol: p];
}
@end
@ -221,9 +216,9 @@ enum proxyLocation
if (debug_proxy)
{
NSLog(@"Local object is %p (%p)\n",
(uintptr_t)o, (uintptr_t)o ? ((NSDO*)o)->_object : 0);
(uintptr_t)o, (uintptr_t)o ? o->_object : 0);
}
return RETAIN(((NSDO*)o)->_object);
return RETAIN(o->_object);
}
case PROXY_LOCAL_FOR_SENDER:

View file

@ -26,7 +26,7 @@
*/
#import "common.h"
#define EXPOSE_NSNSDistributedNotificationCenter_IVARS 1
#define EXPOSE_NSDistributedNotificationCenter_IVARS 1
#import "Foundation/NSConnection.h"
#import "Foundation/NSDistantObject.h"
#import "Foundation/NSException.h"

View file

@ -26,6 +26,7 @@
#import "common.h"
#define EXPOSE_NSException_IVARS 1
#define EXPOSE_NSThread_IVARS 1
#import "GSPrivate.h"
#import "Foundation/NSBundle.h"
#import "Foundation/NSEnumerator.h"
@ -57,8 +58,6 @@ static NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler = 0;
#define _e_info (((id*)_reserved)[0])
#define _e_stack (((id*)_reserved)[1])
typedef struct { @defs(NSThread) } *TInfo;
/* This is the GNU name for the CTOR list */
@interface GSStackTrace : NSObject
@ -895,7 +894,7 @@ callUncaughtHandler(id value)
- (void) raise
{
#ifndef _NATIVE_OBJC_EXCEPTIONS
TInfo thread;
NSThread *thread;
NSHandler *handler;
#endif
@ -908,7 +907,7 @@ callUncaughtHandler(id value)
#ifdef _NATIVE_OBJC_EXCEPTIONS
@throw self;
#else
thread = (TInfo)GSCurrentThread();
thread = GSCurrentThread();
handler = thread->_exception_handler;
if (handler == NULL)
{
@ -1083,9 +1082,9 @@ callUncaughtHandler(id value)
void
_NSAddHandler (NSHandler* handler)
{
TInfo thread;
NSThread *thread;
thread = (TInfo)GSCurrentThread();
thread = GSCurrentThread();
#if defined(__MINGW32__) && defined(DEBUG)
if (thread->_exception_handler
&& IsBadReadPtr(thread->_exception_handler, sizeof(NSHandler)))
@ -1100,9 +1099,9 @@ _NSAddHandler (NSHandler* handler)
void
_NSRemoveHandler (NSHandler* handler)
{
TInfo thread;
NSThread *thread;
thread = (TInfo)GSCurrentThread();
thread = GSCurrentThread();
#if defined(DEBUG)
if (thread->_exception_handler != handler)
{

View file

@ -44,6 +44,7 @@
#import "common.h"
#define EXPOSE_NSFileManager_IVARS 1
#define EXPOSE_NSDirectoryEnumerator_IVARS 1
#import "Foundation/NSArray.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSBundle.h"

View file

@ -47,10 +47,6 @@
static NSString* lkey = @"NotificationQueueListThreadKey";
static NSString* qkey = @"NotificationQueueThreadKey";
typedef struct {
@defs(NSNotificationQueue)
} *accessQueue;
@interface NotificationQueueList : NSObject
{
@ -652,10 +648,10 @@ GSPrivateNotifyASAP(NSString *mode)
{
if (item->queue)
{
notify(((accessQueue)item->queue)->_center,
((accessQueue)item->queue)->_asapQueue,
notify(item->queue->_center,
item->queue->_asapQueue,
mode,
((accessQueue)item->queue)->_zone);
item->queue->_zone);
}
}
}
@ -669,10 +665,10 @@ GSPrivateNotifyIdle(NSString *mode)
{
if (item->queue)
{
notify(((accessQueue)item->queue)->_center,
((accessQueue)item->queue)->_idleQueue,
notify(item->queue->_center,
item->queue->_idleQueue,
mode,
((accessQueue)item->queue)->_zone);
item->queue->_zone);
}
}
}
@ -688,7 +684,7 @@ GSPrivateNotifyMore(NSString *mode)
{
NSNotificationQueueRegistration *r;
r = ((accessQueue)item->queue)->_idleQueue->head;
r = item->queue->_idleQueue->head;
while (r != 0)
{
if (mode == nil || [r->modes indexOfObject: mode] != NSNotFound)

View file

@ -709,36 +709,45 @@ NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone)
/* FIXME ... the following code is a hack for the gnu runtime only
*/
struct objc_method_description_list {
int count;
struct objc_method_description list[1];
};
typedef struct {
@defs(Protocol)
} *pcl;
/* Must have same layout as ivars of Protocol class
*/
struct protocol_class {
Class isa;
char *protocol_name;
struct objc_protocol_list *protocol_list;
struct objc_method_description_list *instance_methods;
struct objc_method_description_list *class_methods;
};
struct objc_method_description *
GSDescriptionForInstanceMethod(pcl self, SEL aSel)
GSDescriptionForInstanceMethod(Protocol *self, SEL aSel)
{
struct protocol_class *pcl = (struct protocol_class*)self;
int i;
struct objc_protocol_list *p_list;
const char *name = sel_getName(aSel);
struct objc_method_description *result;
if (self->instance_methods != 0)
if (pcl->instance_methods != 0)
{
for (i = 0; i < self->instance_methods->count; i++)
for (i = 0; i < pcl->instance_methods->count; i++)
{
if (!strcmp ((char*)self->instance_methods->list[i].name, name))
return &(self->instance_methods->list[i]);
if (!strcmp ((char*)pcl->instance_methods->list[i].name, name))
return &(pcl->instance_methods->list[i]);
}
}
for (p_list = self->protocol_list; p_list != 0; p_list = p_list->next)
for (p_list = pcl->protocol_list; p_list != 0; p_list = p_list->next)
{
for (i = 0; i < p_list->count; i++)
{
result = GSDescriptionForInstanceMethod((pcl)p_list->list[i], aSel);
result = GSDescriptionForInstanceMethod(p_list->list[i], aSel);
if (result)
{
return result;
@ -750,26 +759,27 @@ GSDescriptionForInstanceMethod(pcl self, SEL aSel)
}
struct objc_method_description *
GSDescriptionForClassMethod(pcl self, SEL aSel)
GSDescriptionForClassMethod(Protocol *self, SEL aSel)
{
struct protocol_class *pcl = (struct protocol_class*)self;
int i;
struct objc_protocol_list *p_list;
const char *name = sel_getName(aSel);
struct objc_method_description *result;
if (self->class_methods != 0)
if (pcl->class_methods != 0)
{
for (i = 0; i < self->class_methods->count; i++)
for (i = 0; i < pcl->class_methods->count; i++)
{
if (!strcmp ((char*)self->class_methods->list[i].name, name))
return &(self->class_methods->list[i]);
if (!strcmp ((char*)pcl->class_methods->list[i].name, name))
return &(pcl->class_methods->list[i]);
}
}
for (p_list = self->protocol_list; p_list != 0; p_list = p_list->next)
for (p_list = pcl->protocol_list; p_list != 0; p_list = p_list->next)
{
for (i = 0; i < p_list->count; i++)
{
result = GSDescriptionForClassMethod((pcl)p_list->list[i], aSel);
result = GSDescriptionForClassMethod(p_list->list[i], aSel);
if (result)
{
return result;
@ -784,12 +794,12 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel
{
return GSDescriptionForInstanceMethod((pcl)self, aSel);
return GSDescriptionForInstanceMethod(self, aSel);
}
- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel;
{
return GSDescriptionForClassMethod((pcl)self, aSel);
return GSDescriptionForClassMethod(self, aSel);
}
@end

View file

@ -507,7 +507,7 @@ class_replaceMethod(Class cls, SEL name, IMP imp, const char *types)
BOOL
class_respondsToSelector(Class cls, SEL sel)
{
return __objc_responds_to(cls, sel);
return __objc_responds_to((id)&cls, sel);
}
void

15801
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -669,6 +669,18 @@ else
fi
AC_SUBST(OBJC2RUNTIME)
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -fobjc-nonfragile-abi -x objective-c"
AC_MSG_CHECKING(for non-fragile-abi support)
AC_RUN_IFELSE([#include "$srcdir/config/config.non-fragile-ivars.m"],
non_fragile=yes, non_fragile=no)
CPPFLAGS="$saved_CPPFLAGS"
if test $non_fragile = yes; then
OBJCFLAGS="$OBJCFLAGS -fobjc-nonfragile-abi"
AC_SUBST(OBJCFLAGS)
fi
AC_MSG_RESULT($non_fragile)
# Don't revert any Objective-C flags as they are used in the next test
#--------------------------------------------------------------------
@ -1391,18 +1403,6 @@ if test $have_forward_hook = no; then
fi
CPPFLAGS="$saved_CPPFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -fobjc-nonfragile-abi -x objective-c"
AC_MSG_CHECKING(for non-fragile-abi support)
AC_RUN_IFELSE([#include "$srcdir/config/config.non-fragile-ivars.m"],
non_fragile=yes, non_fragile=no)
CPPFLAGS="$saved_CPPFLAGS"
if test $non_fragile = yes; then
OBJCFLAGS="$OBJCFLAGS -fobjc-nonfragile-abi"
AC_SUBST(OBJCFLAGS)
fi
AC_MSG_RESULT($non_fragile)
AC_MSG_CHECKING(FFI library usage)
WITH_FFI=none
if test $enable_libffi = yes; then