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

View file

@ -134,7 +134,7 @@ void _Block_release(const void *) __attribute__((weak));
#endif
#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
#ifndef Block_release
# 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 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))

View file

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

View file

@ -101,7 +101,7 @@ typedef GSIMapNode_t *GSIMapNode;
pointerFunctionsAssign(&M->cb.pf, (void**)addr, (x).obj);
#define GSI_MAP_READ_KEY(M,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

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));
#define GSI_MAP_READ_KEY(M,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) \
(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)\
(M->legacy ? 0\
: (IS_WEAK_KEY(M) || IS_WEAK_VALUE(M)) ? YES : NO)

View file

@ -2923,14 +2923,14 @@ static NSLock *cached_proxies_gate = nil;
NSParameterAssert (IisValid);
[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++)
{
unsigned target;
NSDistantObject *prox;
[rmc decodeValueOfObjCType: @encode(typeof(target)) at: &target];
[rmc decodeValueOfObjCType: @encode(__typeof__(target)) at: &target];
prox = [self includesLocalTarget: target];
if (prox != 0)
@ -2985,7 +2985,7 @@ static NSLock *cached_proxies_gate = nil;
[rmc decodeValueOfObjCType: @encode(int) at: &sequence];
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];
if (debug_connection > 3)
@ -3823,7 +3823,7 @@ static NSLock *cached_proxies_gate = nil;
int seq_num;
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];
ip = [self _getReplyRmc: seq_num for: "retain"];

View file

@ -192,7 +192,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
NSAssert(decoder_connection, NSInternalInconsistencyException);
/* 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];
switch (proxy_tag)
@ -204,7 +204,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* Lookup the target handle to ensure that it exists here.
* Return a retained copy of the local target object.
*/
[aCoder decodeValueOfObjCType: @encode(typeof(target))
[aCoder decodeValueOfObjCType: @encode(__typeof__(target))
at: &target];
if (debug_proxy)
@ -236,7 +236,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* return the proxy object we already created for this target, or
* create a new proxy object if necessary.
*/
[aCoder decodeValueOfObjCType: @encode(typeof(target))
[aCoder decodeValueOfObjCType: @encode(__typeof__(target))
at: &target];
if (debug_proxy)
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
* object ...
*/
[aCoder decodeValueOfObjCType: @encode(typeof(intermediary))
[aCoder decodeValueOfObjCType: @encode(__typeof__(intermediary))
at: &intermediary];
AUTORELEASE([self initWithTarget: intermediary
connection: decoder_connection]);
@ -283,7 +283,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
* and (if necessary) get the originating process to retain the
* object for us.
*/
[aCoder decodeValueOfObjCType: @encode(typeof(target))
[aCoder decodeValueOfObjCType: @encode(__typeof__(target))
at: &target];
[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",
proxy_target, _connection);
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag))
[aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_tag))
at: &proxy_tag];
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_target))
[aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_target))
at: &proxy_target];
/*
* 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",
proxy_target, _connection);
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag))
[aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_tag))
at: &proxy_tag];
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_target))
[aRmc encodeValueOfObjCType: @encode(__typeof__(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
* triangle connection to
*/
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag))
[aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_tag))
at: &proxy_tag];
[aRmc encodeValueOfObjCType: @encode(typeof(localProxy->_handle))
[aRmc encodeValueOfObjCType: @encode(__typeof__(localProxy->_handle))
at: &localProxy->_handle];
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_target))
[aRmc encodeValueOfObjCType: @encode(__typeof__(proxy_target))
at: &proxy_target];
[aRmc encodeBycopyObject: proxy_connection_out_port];

View file

@ -63,7 +63,7 @@ skip_offset(const char *ptr)
}
#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); })
/* Step through method encoding information extracting details.

View file

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

View file

@ -153,7 +153,7 @@ static errbuf[BUFSIZ];
#define MAX_EXTRA ((GDO_NAME_MAX_LEN - 2 * IASIZE)/IASIZE)
#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); })
typedef unsigned char *uptr;