Consistently use __typeof__() rather than typeof() or __typeof() for compatibility (GCC and clang and, perhaps, other future compilers) irrespective of -std= compilation options.

This commit is contained in:
Richard Frith-Macdonald 2020-12-15 13:01:00 +00:00
parent 5026274f6c
commit 6d20773f56
11 changed files with 30 additions and 30 deletions

View file

@ -168,7 +168,7 @@ void *__object = (void*)(object);\
*/ */
#define ASSIGN(object,value) ({\ #define ASSIGN(object,value) ({\
void *__object = (void*)object; \ void *__object = (void*)object; \
object = (typeof(object))[(value) retain]; \ object = (__typeof__(object))[(value) retain]; \
[(id)__object release]; \ [(id)__object release]; \
}) })
#endif #endif
@ -181,7 +181,7 @@ void *__object = (void*)(object);\
*/ */
#define ASSIGNCOPY(object,value) ({\ #define ASSIGNCOPY(object,value) ({\
void *__object = (void*)object; \ void *__object = (void*)object; \
object = (typeof(object))[(value) copy];\ object = (__typeof__(object))[(value) copy];\
[(id)__object release]; \ [(id)__object release]; \
}) })
#endif #endif
@ -194,7 +194,7 @@ void *__object = (void*)(object);\
*/ */
#define ASSIGNMUTABLECOPY(object,value) ({\ #define ASSIGNMUTABLECOPY(object,value) ({\
void *__object = (void*)object; \ void *__object = (void*)object; \
object = (typeof(object))[(value) mutableCopy];\ object = (__typeof__(object))[(value) mutableCopy];\
[(id)__object release]; \ [(id)__object release]; \
}) })
#endif #endif

View file

@ -134,7 +134,7 @@ void _Block_release(const void *) __attribute__((weak));
#endif #endif
#ifndef Block_copy #ifndef Block_copy
# define Block_copy(x) ((__typeof(x))_Block_copy((const void *)(x))) # define Block_copy(x) ((__typeof__(x))_Block_copy((const void *)(x)))
#endif #endif
#ifndef Block_release #ifndef Block_release
# define Block_release(x) _Block_release((const void *)(x)) # define Block_release(x) _Block_release((const void *)(x))

View file

@ -12,5 +12,5 @@ BLOCKS_EXPORT void *_Block_copy(const void *);
BLOCKS_EXPORT void _Block_release(const void *); BLOCKS_EXPORT void _Block_release(const void *);
BLOCKS_EXPORT const char *_Block_get_types(const void*); BLOCKS_EXPORT const char *_Block_get_types(const void*);
#define Block_copy(x) ((__typeof(x))_Block_copy((const void *)(x))) #define Block_copy(x) ((__typeof__(x))_Block_copy((const void *)(x)))
#define Block_release(x) _Block_release((const void *)(x)) #define Block_release(x) _Block_release((const void *)(x))

View file

@ -3573,7 +3573,7 @@ substring_c(GSStr self, NSRange aRange)
{ {
return @""; return @"";
} }
o = (typeof(o))NSAllocateObject(GSCSubStringClass, o = (__typeof__(o))NSAllocateObject(GSCSubStringClass,
0, NSDefaultMallocZone()); 0, NSDefaultMallocZone());
o->_contents.c = self->_contents.c + aRange.location; o->_contents.c = self->_contents.c + aRange.location;
o->_count = aRange.length; o->_count = aRange.length;
@ -3592,7 +3592,7 @@ substring_u(GSStr self, NSRange aRange)
{ {
return @""; return @"";
} }
o = (typeof(o))NSAllocateObject(GSUnicodeSubStringClass, o = (__typeof__(o))NSAllocateObject(GSUnicodeSubStringClass,
0, NSDefaultMallocZone()); 0, NSDefaultMallocZone());
o->_contents.u = self->_contents.u + aRange.location; o->_contents.u = self->_contents.u + aRange.location;
o->_count = aRange.length; o->_count = aRange.length;

View file

@ -101,7 +101,7 @@ typedef GSIMapNode_t *GSIMapNode;
pointerFunctionsAssign(&M->cb.pf, (void**)addr, (x).obj); pointerFunctionsAssign(&M->cb.pf, (void**)addr, (x).obj);
#define GSI_MAP_READ_KEY(M,addr) \ #define GSI_MAP_READ_KEY(M,addr) \
(M->legacy ? *(addr) :\ (M->legacy ? *(addr) :\
(typeof(*addr))pointerFunctionsRead(&M->cb.pf, (void**)addr)) (__typeof__(*addr))pointerFunctionsRead(&M->cb.pf, (void**)addr))
#define GSI_MAP_ENUMERATOR NSHashEnumerator #define GSI_MAP_ENUMERATOR NSHashEnumerator

View file

@ -132,10 +132,10 @@ typedef GSIMapNode_t *GSIMapNode;
(IS_WEAK_VALUE(M) ? pointerFunctionsAssign(&M->cb.pf.v, (void**)addr, (x).obj) : (*(id*)(addr) = (x).obj)); (IS_WEAK_VALUE(M) ? pointerFunctionsAssign(&M->cb.pf.v, (void**)addr, (x).obj) : (*(id*)(addr) = (x).obj));
#define GSI_MAP_READ_KEY(M,addr) \ #define GSI_MAP_READ_KEY(M,addr) \
(M->legacy ? *(addr)\ (M->legacy ? *(addr)\
: (typeof(*addr))pointerFunctionsRead(&M->cb.pf.k, (void**)addr)) : (__typeof__(*addr))pointerFunctionsRead(&M->cb.pf.k, (void**)addr))
#define GSI_MAP_READ_VALUE(M,addr) \ #define GSI_MAP_READ_VALUE(M,addr) \
(M->legacy ? *(addr)\ (M->legacy ? *(addr)\
: (typeof(*addr))pointerFunctionsRead(&M->cb.pf.v, (void**)addr)) : (__typeof__(*addr))pointerFunctionsRead(&M->cb.pf.v, (void**)addr))
#define GSI_MAP_ZEROED(M)\ #define GSI_MAP_ZEROED(M)\
(M->legacy ? 0\ (M->legacy ? 0\
: (IS_WEAK_KEY(M) || IS_WEAK_VALUE(M)) ? YES : NO) : (IS_WEAK_KEY(M) || IS_WEAK_VALUE(M)) ? YES : NO)

View file

@ -2923,14 +2923,14 @@ static NSLock *cached_proxies_gate = nil;
NSParameterAssert (IisValid); NSParameterAssert (IisValid);
[rmc decodeValueOfObjCType: @encode(int) at: &sequence]; [rmc decodeValueOfObjCType: @encode(int) at: &sequence];
[rmc decodeValueOfObjCType: @encode(typeof(count)) at: &count]; [rmc decodeValueOfObjCType: @encode(__typeof__(count)) at: &count];
for (pos = 0; pos < count; pos++) for (pos = 0; pos < count; pos++)
{ {
unsigned target; unsigned target;
NSDistantObject *prox; NSDistantObject *prox;
[rmc decodeValueOfObjCType: @encode(typeof(target)) at: &target]; [rmc decodeValueOfObjCType: @encode(__typeof__(target)) at: &target];
prox = [self includesLocalTarget: target]; prox = [self includesLocalTarget: target];
if (prox != 0) if (prox != 0)
@ -2985,7 +2985,7 @@ static NSLock *cached_proxies_gate = nil;
[rmc decodeValueOfObjCType: @encode(int) at: &sequence]; [rmc decodeValueOfObjCType: @encode(int) at: &sequence];
op = [self _newOutRmc: sequence generate: 0 reply: NO]; op = [self _newOutRmc: sequence generate: 0 reply: NO];
[rmc decodeValueOfObjCType: @encode(typeof(target)) at: &target]; [rmc decodeValueOfObjCType: @encode(__typeof__(target)) at: &target];
[self _doneInRmc: rmc]; [self _doneInRmc: rmc];
if (debug_connection > 3) if (debug_connection > 3)
@ -3823,7 +3823,7 @@ static NSLock *cached_proxies_gate = nil;
int seq_num; int seq_num;
op = [self _newOutRmc: 0 generate: &seq_num reply: YES]; op = [self _newOutRmc: 0 generate: &seq_num reply: YES];
[op encodeValueOfObjCType: @encode(typeof(target)) at: &target]; [op encodeValueOfObjCType: @encode(__typeof__(target)) at: &target];
[self _sendOutRmc: op type: PROXY_RETAIN sequence: seq_num]; [self _sendOutRmc: op type: PROXY_RETAIN sequence: seq_num];
ip = [self _getReplyRmc: seq_num for: "retain"]; ip = [self _getReplyRmc: seq_num for: "retain"];

View file

@ -192,7 +192,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
NSAssert(decoder_connection, NSInternalInconsistencyException); NSAssert(decoder_connection, NSInternalInconsistencyException);
/* First get the tag, so we know what values need to be decoded. */ /* First get the tag, so we know what values need to be decoded. */
[aCoder decodeValueOfObjCType: @encode(typeof(proxy_tag)) [aCoder decodeValueOfObjCType: @encode(__typeof__(proxy_tag))
at: &proxy_tag]; at: &proxy_tag];
switch (proxy_tag) switch (proxy_tag)
@ -204,7 +204,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* Lookup the target handle to ensure that it exists here. * Lookup the target handle to ensure that it exists here.
* Return a retained copy of the local target object. * Return a retained copy of the local target object.
*/ */
[aCoder decodeValueOfObjCType: @encode(typeof(target)) [aCoder decodeValueOfObjCType: @encode(__typeof__(target))
at: &target]; at: &target];
if (debug_proxy) if (debug_proxy)
@ -236,7 +236,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* return the proxy object we already created for this target, or * return the proxy object we already created for this target, or
* create a new proxy object if necessary. * create a new proxy object if necessary.
*/ */
[aCoder decodeValueOfObjCType: @encode(typeof(target)) [aCoder decodeValueOfObjCType: @encode(__typeof__(target))
at: &target]; at: &target];
if (debug_proxy) if (debug_proxy)
NSLog(@"Receiving a proxy, was local 0x%x connection %p\n", NSLog(@"Receiving a proxy, was local 0x%x connection %p\n",
@ -273,7 +273,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* time we will have obtained our own proxy for the original * time we will have obtained our own proxy for the original
* object ... * object ...
*/ */
[aCoder decodeValueOfObjCType: @encode(typeof(intermediary)) [aCoder decodeValueOfObjCType: @encode(__typeof__(intermediary))
at: &intermediary]; at: &intermediary];
AUTORELEASE([self initWithTarget: intermediary AUTORELEASE([self initWithTarget: intermediary
connection: decoder_connection]); connection: decoder_connection]);
@ -283,7 +283,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* and (if necessary) get the originating process to retain the * and (if necessary) get the originating process to retain the
* object for us. * object for us.
*/ */
[aCoder decodeValueOfObjCType: @encode(typeof(target)) [aCoder decodeValueOfObjCType: @encode(__typeof__(target))
at: &target]; at: &target];
[aCoder decodeValueOfObjCType: @encode(id) [aCoder decodeValueOfObjCType: @encode(id)
@ -513,10 +513,10 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
NSLog(@"Sending a proxy, will be remote 0x%x connection %p\n", NSLog(@"Sending a proxy, will be remote 0x%x connection %p\n",
proxy_target, _connection); proxy_target, _connection);
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag)) [aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_tag))
at: &proxy_tag]; at: &proxy_tag];
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_target)) [aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_target))
at: &proxy_target]; at: &proxy_target];
/* /*
* Tell connection this object is being vended. * Tell connection this object is being vended.
@ -534,10 +534,10 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
NSLog(@"Sending a proxy, will be local 0x%x connection %p\n", NSLog(@"Sending a proxy, will be local 0x%x connection %p\n",
proxy_target, _connection); proxy_target, _connection);
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag)) [aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_tag))
at: &proxy_tag]; at: &proxy_tag];
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_target)) [aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_target))
at: &proxy_target]; at: &proxy_target];
} }
} }
@ -577,13 +577,13 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* It's remote here, so we need to tell other side where to form * It's remote here, so we need to tell other side where to form
* triangle connection to * triangle connection to
*/ */
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag)) [aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_tag))
at: &proxy_tag]; at: &proxy_tag];
[aRmc encodeValueOfObjCType: @encode(typeof(localProxy->_handle)) [aRmc encodeValueOfObjCType: @encode(__typeof__(localProxy->_handle))
at: &localProxy->_handle]; at: &localProxy->_handle];
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_target)) [aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_target))
at: &proxy_target]; at: &proxy_target];
[aRmc encodeBycopyObject: proxy_connection_out_port]; [aRmc encodeBycopyObject: proxy_connection_out_port];

View file

@ -63,7 +63,7 @@ skip_offset(const char *ptr)
} }
#define ROUND(V, A) \ #define ROUND(V, A) \
({ typeof(V) __v=(V); typeof(A) __a=(A); \ ({ __typeof__(V) __v=(V); __typeof__(A) __a=(A); \
__a*((__v+__a-1)/__a); }) __a*((__v+__a-1)/__a); })
/* Step through method encoding information extracting details. /* Step through method encoding information extracting details.

View file

@ -10,7 +10,7 @@
} }
- (const char *) objCType - (const char *) objCType
{ {
return @encode(typeof(VALUE)); return @encode(__typeof__(VALUE));
} }
- (NSString*) descriptionWithLocale: (id)aLocale - (NSString*) descriptionWithLocale: (id)aLocale
{ {
@ -19,7 +19,7 @@
} }
- (void) getValue: (void*)buffer - (void) getValue: (void*)buffer
{ {
typeof(VALUE) *ptr = buffer; __typeof__(VALUE) *ptr = buffer;
*ptr = VALUE; *ptr = VALUE;
} }
#undef FORMAT #undef FORMAT

View file

@ -153,7 +153,7 @@ static errbuf[BUFSIZ];
#define MAX_EXTRA ((GDO_NAME_MAX_LEN - 2 * IASIZE)/IASIZE) #define MAX_EXTRA ((GDO_NAME_MAX_LEN - 2 * IASIZE)/IASIZE)
#define ROUND(V, A) \ #define ROUND(V, A) \
({ typeof(V) __v=(V); typeof(A) __a=(A); \ ({ __typeof__(V) __v=(V); __typeof__(A) __a=(A); \
__a*((__v+__a-1)/__a); }) __a*((__v+__a-1)/__a); })
typedef unsigned char *uptr; typedef unsigned char *uptr;