ObjFW  Check-in [e35b10115e]

Overview
Comment:Always use __foo__ instead of foo for attributes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e35b10115e23ecbb038427dad47c5da5a2132e4b5d2a94e2fb3d6f5a31a5b264
User & Date: js on 2014-05-14 20:28:11
Other Links: manifest | tags
Context
2014-05-14
20:45
Add C11 noreturn check-in: bac91ccede user: js tags: trunk
20:28
Always use __foo__ instead of foo for attributes check-in: e35b10115e user: js tags: trunk
20:19
Use thread_local instead of __thread check-in: c701e89b83 user: js tags: trunk
Changes

Modified configure.ac from [c1957ea278] to [6c6bb6568f].

957
958
959
960
961
962
963
964
965
966
967
968
969
970
971

	old_OBJCFLAGS="$OBJCFLAGS"
	OBJCFLAGS="$OBJCFLAGS -Wcast-align"
	AC_MSG_CHECKING(whether -Wcast-align is buggy)
	AC_TRY_COMPILE([
		#ifdef __has_attribute
		# if __has_attribute(objc_root_class)
		__attribute__((objc_root_class))
		# endif
		#endif
		@interface Foo
		{
			struct objc_class *_isa;
		}
		@end







|







957
958
959
960
961
962
963
964
965
966
967
968
969
970
971

	old_OBJCFLAGS="$OBJCFLAGS"
	OBJCFLAGS="$OBJCFLAGS -Wcast-align"
	AC_MSG_CHECKING(whether -Wcast-align is buggy)
	AC_TRY_COMPILE([
		#ifdef __has_attribute
		# if __has_attribute(objc_root_class)
		__attribute__((__objc_root_class__))
		# endif
		#endif
		@interface Foo
		{
			struct objc_class *_isa;
		}
		@end

Modified src/OFBlock.m from [5efc26dc00] to [f3946988e2].

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

static struct objc_abi_module module = {
	8, sizeof(module), NULL, (struct objc_abi_symtab*)&symtab
};

extern void __objc_exec_class(struct objc_abi_module*);

static void __attribute__((constructor))
constructor(void)
{
	__objc_exec_class(&module);
}
/* End of ObjC module */
#elif defined(OF_APPLE_RUNTIME)
extern Class objc_initializeClassPair(Class, const char*, Class, Class);







|







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

static struct objc_abi_module module = {
	8, sizeof(module), NULL, (struct objc_abi_symtab*)&symtab
};

extern void __objc_exec_class(struct objc_abi_module*);

static void __attribute__((__constructor__))
constructor(void)
{
	__objc_exec_class(&module);
}
/* End of ObjC module */
#elif defined(OF_APPLE_RUNTIME)
extern Class objc_initializeClassPair(Class, const char*, Class, Class);

Modified src/OFObject.h from [b5db2a6441] to [3f124a3246].

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#  define true ((bool)1)
#  undef false
#  define false ((bool)0)
# endif
#endif

#if defined(__clang__) || __GCC_VERSION__ >= 406
# define OF_SENTINEL __attribute__((sentinel))
# define OF_NO_RETURN __attribute__((noreturn))
#else
# define OF_SENTINEL
# define OF_NO_RETURN
#endif

#if __has_attribute(objc_requires_super)
# define OF_REQUIRES_SUPER __attribute__((objc_requires_super))
#else
# define OF_REQUIRES_SUPER
#endif

#if __has_attribute(objc_root_class)
# define OF_ROOT_CLASS __attribute__((objc_root_class))
#else
# define OF_ROOT_CLASS
#endif

#ifdef OF_APPLE_RUNTIME
# if defined(__x86_64__) || defined(__i386__) || defined(__ARM64_ARCH_8__) || \
	defined(__arm__) || defined(__ppc__)







|
|





|
|




|
|







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#  define true ((bool)1)
#  undef false
#  define false ((bool)0)
# endif
#endif

#if defined(__clang__) || __GCC_VERSION__ >= 406
# define OF_SENTINEL __attribute__((__sentinel__))
# define OF_NO_RETURN __attribute__((__noreturn__))
#else
# define OF_SENTINEL
# define OF_NO_RETURN
#endif

#if __has_attribute(__objc_requires_super__)
# define OF_REQUIRES_SUPER __attribute__((__objc_requires_super__))
#else
# define OF_REQUIRES_SUPER
#endif

#if __has_attribute(__objc_root_class__)
# define OF_ROOT_CLASS __attribute__((__objc_root_class__))
#else
# define OF_ROOT_CLASS
#endif

#ifdef OF_APPLE_RUNTIME
# if defined(__x86_64__) || defined(__i386__) || defined(__ARM64_ARCH_8__) || \
	defined(__arm__) || defined(__ppc__)
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170
171
#    define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET
#   endif
#  endif
# endif
#endif

#if __has_feature(objc_arc)
# define OF_RETURNS_RETAINED __attribute__((ns_returns_retained))
# define OF_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
# define OF_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer))

# define OF_CONSUMED __attribute__((ns_consumed))
# define OF_WEAK_UNAVAILABLE __attribute__((objc_arc_weak_unavailable))
#else
# define OF_RETURNS_RETAINED
# define OF_RETURNS_NOT_RETAINED
# define OF_RETURNS_INNER_POINTER
# define OF_CONSUMED
# define OF_WEAK_UNAVAILABLE
# define __unsafe_unretained







|
|
|
>
|
|







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#    define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET
#   endif
#  endif
# endif
#endif

#if __has_feature(objc_arc)
# define OF_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
# define OF_RETURNS_NOT_RETAINED __attribute__((__ns_returns_not_retained__))
# define OF_RETURNS_INNER_POINTER \
	__attribute__((__objc_returns_inner_pointer__))
# define OF_CONSUMED __attribute__((__ns_consumed__))
# define OF_WEAK_UNAVAILABLE __attribute__((__objc_arc_weak_unavailable__))
#else
# define OF_RETURNS_RETAINED
# define OF_RETURNS_NOT_RETAINED
# define OF_RETURNS_INNER_POINTER
# define OF_CONSUMED
# define OF_WEAK_UNAVAILABLE
# define __unsafe_unretained

Modified src/autorelease.m from [2dc209441b] to [3bbb1328d7].

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#else
static id *objects = NULL;
static id *top = NULL;
static size_t size = 0;
#endif

#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
static void __attribute__((constructor))
init(void)
{
	OF_ENSURE(of_tlskey_new(&objectsKey));
	OF_ENSURE(of_tlskey_new(&topKey));
	OF_ENSURE(of_tlskey_new(&sizeKey));
}
#endif







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#else
static id *objects = NULL;
static id *top = NULL;
static size_t size = 0;
#endif

#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
static void __attribute__((__constructor__))
init(void)
{
	OF_ENSURE(of_tlskey_new(&objectsKey));
	OF_ENSURE(of_tlskey_new(&topKey));
	OF_ENSURE(of_tlskey_new(&sizeKey));
}
#endif

Modified src/foundation-compat.m from [fba6ea3e91] to [2720266c59].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
autorelease(id self, SEL _cmd)
{
	[OFAutoreleasePool addObject: self];

	return self;
}

static void __attribute__((constructor))
init(void)
{
	Class NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
	Class NSObject = objc_getClass("NSObject");
	Method allocMethod;
	Method addObjectMethod;
	Method autoreleaseMethod;







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
autorelease(id self, SEL _cmd)
{
	[OFAutoreleasePool addObject: self];

	return self;
}

static void __attribute__((__constructor__))
init(void)
{
	Class NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
	Class NSObject = objc_getClass("NSObject");
	Method allocMethod;
	Method addObjectMethod;
	Method autoreleaseMethod;

Modified src/macros.h from [4a0014aee6] to [d84414160a].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <string.h>

#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif

#ifdef __GNUC__
# define OF_INLINE inline __attribute__((always_inline))
# define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1))
# define OF_UNLIKELY(cond) (__builtin_expect(!!(cond), 0))
# define OF_CONST_FUNC __attribute__((const))
#else
# define OF_INLINE inline
# define OF_LIKELY(cond) cond
# define OF_UNLIKELY(cond) cond
# define OF_CONST_FUNC
#endif








|


|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <string.h>

#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif

#ifdef __GNUC__
# define OF_INLINE inline __attribute__((__always_inline__))
# define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1))
# define OF_UNLIKELY(cond) (__builtin_expect(!!(cond), 0))
# define OF_CONST_FUNC __attribute__((__const__))
#else
# define OF_INLINE inline
# define OF_LIKELY(cond) cond
# define OF_UNLIKELY(cond) cond
# define OF_CONST_FUNC
#endif

Modified src/resolver.m from [f9485d971c] to [444e71a5a9].

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#endif

#import "socket_helpers.h"

#if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS)
static of_mutex_t mutex;

static void __attribute__((constructor))
init(void)
{
	if (!of_mutex_new(&mutex))
		@throw [OFInitializationFailedException exception];
}
#endif








|







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#endif

#import "socket_helpers.h"

#if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS)
static of_mutex_t mutex;

static void __attribute__((__constructor__))
init(void)
{
	if (!of_mutex_new(&mutex))
		@throw [OFInitializationFailedException exception];
}
#endif

Modified src/runtime/class.m from [cf051d40ec] to [0d2c7753b9].

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

	for (ml = cls->methodlist; ml != NULL; ml = ml->next)
		for (i = 0; i < ml->count; i++)
			objc_register_selector(
			    (struct objc_abi_selector*)&ml->methods[i]);
}

inline Class __attribute__((gnu_inline))
objc_classname_to_class(const char *name, bool cache)
{
	Class c;

	if (classes == NULL)
		return Nil;








|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

	for (ml = cls->methodlist; ml != NULL; ml = ml->next)
		for (i = 0; i < ml->count; i++)
			objc_register_selector(
			    (struct objc_abi_selector*)&ml->methods[i]);
}

inline Class __attribute__((__gnu_inline__))
objc_classname_to_class(const char *name, bool cache)
{
	Class c;

	if (classes == NULL)
		return Nil;

Modified src/runtime/property.m from [5f10cc9561] to [db56428575].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# import "threading.h"
# define NUM_SPINLOCKS 8	/* needs to be a power of 2 */
# define SPINLOCK_HASH(p) ((unsigned)((uintptr_t)p >> 4) & (NUM_SPINLOCKS - 1))
static of_spinlock_t spinlocks[NUM_SPINLOCKS];
#endif

#ifdef OF_HAVE_THREADS
static void __attribute__((constructor))
init(void)
{
	size_t i;

	for (i = 0; i < NUM_SPINLOCKS; i++)
		if (!of_spinlock_new(&spinlocks[i]))
			OBJC_ERROR("Failed to initialize spinlocks!")







|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# import "threading.h"
# define NUM_SPINLOCKS 8	/* needs to be a power of 2 */
# define SPINLOCK_HASH(p) ((unsigned)((uintptr_t)p >> 4) & (NUM_SPINLOCKS - 1))
static of_spinlock_t spinlocks[NUM_SPINLOCKS];
#endif

#ifdef OF_HAVE_THREADS
static void __attribute__((__constructor__))
init(void)
{
	size_t i;

	for (i = 0; i < NUM_SPINLOCKS; i++)
		if (!of_spinlock_new(&spinlocks[i]))
			OBJC_ERROR("Failed to initialize spinlocks!")

Modified src/runtime/protocol.m from [f526015ede] to [c39410b65b].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#import "runtime.h"
#import "runtime-private.h"

@implementation Protocol
@end

inline const char* __attribute__((gnu_inline))
protocol_getName(Protocol *p)
{
	return p->name;
}

inline bool __attribute__((gnu_inline))
protocol_isEqual(Protocol *a, Protocol *b)
{
	return (strcmp(protocol_getName(a), protocol_getName(b)) == 0);
}

bool
protocol_conformsToProtocol(Protocol *a, Protocol *b)







|





|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#import "runtime.h"
#import "runtime-private.h"

@implementation Protocol
@end

inline const char* __attribute__((__gnu_inline__))
protocol_getName(Protocol *p)
{
	return p->name;
}

inline bool __attribute__((__gnu_inline__))
protocol_isEqual(Protocol *a, Protocol *b)
{
	return (strcmp(protocol_getName(a), protocol_getName(b)) == 0);
}

bool
protocol_conformsToProtocol(Protocol *a, Protocol *b)

Modified src/runtime/runtime.h from [b35afd5ad2] to [e5c437ae29].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

#if __has_feature(objc_arc)
# define OBJC_UNSAFE_UNRETAINED __unsafe_unretained
#else
# define OBJC_UNSAFE_UNRETAINED
#endif

#if __has_attribute(objc_root_class)
# define OBJC_ROOT_CLASS __attribute__((objc_root_class))
#else
# define OBJC_ROOT_CLASS
#endif

#define Nil (Class)0
#define nil (id)0
#define YES (BOOL)1







|
|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

#if __has_feature(objc_arc)
# define OBJC_UNSAFE_UNRETAINED __unsafe_unretained
#else
# define OBJC_UNSAFE_UNRETAINED
#endif

#if __has_attribute(__objc_root_class__)
# define OBJC_ROOT_CLASS __attribute__((__objc_root_class__))
#else
# define OBJC_ROOT_CLASS
#endif

#define Nil (Class)0
#define nil (id)0
#define YES (BOOL)1

Modified src/runtime/synchronized.m from [df7cc30f83] to [f83bd6c3af].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
	int	      count;
	of_rmutex_t   rmutex;
	struct lock_s *next;
} *locks = NULL;

static of_mutex_t mutex;

static void __attribute__((constructor))
init(void)
{
	if (!of_mutex_new(&mutex))
		OBJC_ERROR("Failed to create mutex!")
}
#endif








|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
	int	      count;
	of_rmutex_t   rmutex;
	struct lock_s *next;
} *locks = NULL;

static of_mutex_t mutex;

static void __attribute__((__constructor__))
init(void)
{
	if (!of_mutex_new(&mutex))
		OBJC_ERROR("Failed to create mutex!")
}
#endif