Index: src/OFCharacterSet.m ================================================================== --- src/OFCharacterSet.m +++ src/OFCharacterSet.m @@ -105,12 +105,12 @@ return [[[self alloc] initWithRange: range] autorelease]; } + (OFCharacterSet *)whitespaceCharacterSet { - static of_once_t onceControl = OF_ONCE_INIT; - of_once(&onceControl, initWhitespaceCharacterSet); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, initWhitespaceCharacterSet); return whitespaceCharacterSet; } - (instancetype)init Index: src/OFColor.m ================================================================== --- src/OFColor.m +++ src/OFColor.m @@ -20,28 +20,28 @@ #import "once.h" #import "OFInvalidArgumentException.h" @implementation OFColor -#define PREDEFINED_COLOR(name, r, g, b) \ - static OFColor *name##Color = nil; \ - \ - static void \ - initPredefinedColor_##name(void) \ - { \ - name##Color = [[OFColor alloc] initWithRed: r \ - green: g \ - blue: b \ - alpha: 1]; \ - } \ - \ - + (OFColor *)name \ - { \ - static of_once_t onceControl = OF_ONCE_INIT; \ - of_once(&onceControl, initPredefinedColor_##name); \ - \ - return name##Color; \ +#define PREDEFINED_COLOR(name, redValue, greenValue, blueValue) \ + static OFColor *name##Color = nil; \ + \ + static void \ + initPredefinedColor_##name(void) \ + { \ + name##Color = [[OFColor alloc] initWithRed: redValue \ + green: greenValue \ + blue: blueValue \ + alpha: 1]; \ + } \ + \ + + (OFColor *)name \ + { \ + static OFOnceControl onceControl = OFOnceControlInitValue; \ + OFOnce(&onceControl, initPredefinedColor_##name); \ + \ + return name##Color; \ } PREDEFINED_COLOR(black, 0.00f, 0.00f, 0.00f) PREDEFINED_COLOR(silver, 0.75f, 0.75f, 0.75f) PREDEFINED_COLOR(grey, 0.50f, 0.50f, 0.50f) Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -293,12 +293,12 @@ #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX uint64_t value; #endif if (seconds == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, initZeroDate); + static OFOnceControl once = OFOnceControlInitValue; + OFOnce(&once, initZeroDate); return (id)zeroDate; } #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX value = OF_BSWAP64_IF_LE(OF_DOUBLE_TO_INT_RAW(OF_BSWAP_DOUBLE_IF_LE( @@ -408,19 +408,19 @@ format: format] autorelease]; } + (instancetype)distantFuture { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, initDistantFuture); + static OFOnceControl once = OFOnceControlInitValue; + OFOnce(&once, initDistantFuture); return distantFuture; } + (instancetype)distantPast { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, initDistantPast); + static OFOnceControl once = OFOnceControlInitValue; + OFOnce(&once, initDistantPast); return distantPast; } - (instancetype)init { Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -148,16 +148,16 @@ @implementation OFNumberPlaceholder - (instancetype)initWithBool: (bool)value { if (value) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, trueNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, trueNumberInit); return (id)trueNumber; } else { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, falseNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, falseNumberInit); return (id)falseNumber; } } #ifdef __clang__ @@ -165,12 +165,12 @@ # pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" #endif - (instancetype)initWithChar: (signed char)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, charZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, charZeroNumberInit); return (id)charZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned char)value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned char)value << TAG_BITS) | TAG_CHAR); @@ -184,12 +184,12 @@ } - (instancetype)initWithShort: (short)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, shortZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, shortZeroNumberInit); return (id)shortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned short)value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned short)value << TAG_BITS) | TAG_SHORT); @@ -203,12 +203,12 @@ } - (instancetype)initWithInt: (int)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, intZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, intZeroNumberInit); return (id)intZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned int)value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned int)value << TAG_BITS) | TAG_INT); @@ -222,12 +222,12 @@ } - (instancetype)initWithLong: (long)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, longZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, longZeroNumberInit); return (id)longZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long)value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long)value << TAG_BITS) | TAG_LONG); @@ -241,12 +241,12 @@ } - (instancetype)initWithLongLong: (long long)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, longLongZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, longLongZeroNumberInit); return (id)longLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long long)value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long long)value << TAG_BITS) | @@ -261,12 +261,12 @@ } - (instancetype)initWithUnsignedChar: (unsigned char)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, unsignedCharZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, unsignedCharZeroNumberInit); return (id)unsignedCharZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << TAG_BITS) | TAG_UNSIGNED_CHAR); @@ -280,12 +280,12 @@ } - (instancetype)initWithUnsignedShort: (unsigned short)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, unsignedShortZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, unsignedShortZeroNumberInit); return (id)unsignedShortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << TAG_BITS) | TAG_UNSIGNED_SHORT); @@ -299,12 +299,12 @@ } - (instancetype)initWithUnsignedInt: (unsigned int)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, unsignedIntZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, unsignedIntZeroNumberInit); return (id)unsignedIntZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << TAG_BITS) | TAG_UNSIGNED_INT); @@ -318,12 +318,12 @@ } - (instancetype)initWithUnsignedLong: (unsigned long)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, unsignedLongZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, unsignedLongZeroNumberInit); return (id)unsignedLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << TAG_BITS) | TAG_UNSIGNED_LONG); @@ -337,12 +337,12 @@ } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, unsignedLongLongZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, unsignedLongLongZeroNumberInit); return (id)unsignedLongLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> TAG_BITS)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << TAG_BITS) | TAG_UNSIGNED_LONG_LONG); @@ -356,23 +356,23 @@ } - (instancetype)initWithFloat: (float)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, floatZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, floatZeroNumberInit); return (id)floatZeroNumber; } return (id)[[OFNumber of_alloc] initWithFloat: value]; } - (instancetype)initWithDouble: (double)value { if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, doubleZeroNumberInit); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, doubleZeroNumberInit); return (id)doubleZeroNumber; } return (id)[[OFNumber of_alloc] initWithDouble: value]; } Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -175,13 +175,12 @@ OF_ENSURE(getrandom(&buffer, sizeof(buffer), 0) == sizeof(buffer)); return buffer; #else - static of_once_t onceControl = OF_ONCE_INIT; - - of_once(&onceControl, initRandom); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, initRandom); # ifdef HAVE_RANDOM return random() & 0xFFFF; # else return rand() & 0xFFFF; # endif Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -331,20 +331,20 @@ return OBJFW_VERSION_MINOR; } + (OFString *)operatingSystemName { - static of_once_t onceControl = OF_ONCE_INIT; - of_once(&onceControl, initOperatingSystemName); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, initOperatingSystemName); return operatingSystemName; } + (OFString *)operatingSystemVersion { - static of_once_t onceControl = OF_ONCE_INIT; - of_once(&onceControl, initOperatingSystemVersion); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, initOperatingSystemVersion); return operatingSystemVersion; } #ifdef OF_HAVE_FILES Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -58,12 +58,13 @@ static OFCharacterSet *URLSchemeAllowedCharacterSet = nil; static OFCharacterSet *URLPathAllowedCharacterSet = nil; static OFCharacterSet *URLQueryOrFragmentAllowedCharacterSet = nil; static OFCharacterSet *URLQueryKeyValueAllowedCharacterSet = nil; -static of_once_t URLAllowedCharacterSetOnce = OF_ONCE_INIT; -static of_once_t URLQueryOrFragmentAllowedCharacterSetOnce = OF_ONCE_INIT; +static OFOnceControl URLAllowedCharacterSetOnce = OFOnceControlInitValue; +static OFOnceControl URLQueryOrFragmentAllowedCharacterSetOnce = + OFOnceControlInitValue; static void initURLAllowedCharacterSet(void) { URLAllowedCharacterSet = [[OFURLAllowedCharacterSet alloc] init]; @@ -338,64 +339,64 @@ } @implementation OFCharacterSet (URLCharacterSets) + (OFCharacterSet *)URLSchemeAllowedCharacterSet { - static of_once_t onceControl = OF_ONCE_INIT; - of_once(&onceControl, initURLSchemeAllowedCharacterSet); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, initURLSchemeAllowedCharacterSet); return URLSchemeAllowedCharacterSet; } + (OFCharacterSet *)URLHostAllowedCharacterSet { - of_once(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet); + OFOnce(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet); return URLAllowedCharacterSet; } + (OFCharacterSet *)URLUserAllowedCharacterSet { - of_once(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet); + OFOnce(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet); return URLAllowedCharacterSet; } + (OFCharacterSet *)URLPasswordAllowedCharacterSet { - of_once(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet); + OFOnce(&URLAllowedCharacterSetOnce, initURLAllowedCharacterSet); return URLAllowedCharacterSet; } + (OFCharacterSet *)URLPathAllowedCharacterSet { - static of_once_t onceControl = OF_ONCE_INIT; - of_once(&onceControl, initURLPathAllowedCharacterSet); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, initURLPathAllowedCharacterSet); return URLPathAllowedCharacterSet; } + (OFCharacterSet *)URLQueryAllowedCharacterSet { - of_once(&URLQueryOrFragmentAllowedCharacterSetOnce, + OFOnce(&URLQueryOrFragmentAllowedCharacterSetOnce, initURLQueryOrFragmentAllowedCharacterSet); return URLQueryOrFragmentAllowedCharacterSet; } + (OFCharacterSet *)URLQueryKeyValueAllowedCharacterSet { - static of_once_t onceControl = OF_ONCE_INIT; - of_once(&onceControl, initURLQueryKeyValueAllowedCharacterSet); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, initURLQueryKeyValueAllowedCharacterSet); return URLQueryKeyValueAllowedCharacterSet; } + (OFCharacterSet *)URLFragmentAllowedCharacterSet { - of_once(&URLQueryOrFragmentAllowedCharacterSetOnce, + OFOnce(&URLQueryOrFragmentAllowedCharacterSetOnce, initURLQueryOrFragmentAllowedCharacterSet); return URLQueryOrFragmentAllowedCharacterSet; } @end Index: src/once.h ================================================================== --- src/once.h +++ src/once.h @@ -17,22 +17,22 @@ #include "platform.h" #if defined(OF_HAVE_PTHREADS) # include -typedef pthread_once_t of_once_t; -# define OF_ONCE_INIT PTHREAD_ONCE_INIT +typedef pthread_once_t OFOnceControl; +# define OFOnceControlInitValue PTHREAD_ONCE_INIT #elif defined(OF_HAVE_ATOMIC_OPS) -typedef volatile int of_once_t; -# define OF_ONCE_INIT 0 +typedef volatile int OFOnceControl; +# define OFOnceControlInitValue 0 #elif defined(OF_AMIGAOS) || !defined(OF_HAVE_THREADS) -typedef int of_once_t; -# define OF_ONCE_INIT 0 +typedef int OFOnceControl; +# define OFOnceControlInitValue 0 #endif #ifdef __cplusplus extern "C" { #endif -extern void of_once(of_once_t *control, void (*func)(void)); +extern void OFOnce(OFOnceControl *control, void (*func)(void)); #ifdef __cplusplus } #endif Index: src/once.m ================================================================== --- src/once.m +++ src/once.m @@ -27,11 +27,11 @@ # import "atomic.h" # import "mutex.h" #endif void -of_once(of_once_t *control, void (*func)(void)) +OFOnce(OFOnceControl *control, void (*func)(void)) { #if !defined(OF_HAVE_THREADS) if (*control == 0) { func(); *control = 1; @@ -78,8 +78,8 @@ if (run) { func(); *control = 2; } #else -# error No of_once available +# error No OFOnce available #endif } Index: src/runtime/threading.m ================================================================== --- src/runtime/threading.m +++ src/runtime/threading.m @@ -33,12 +33,12 @@ } void objc_global_mutex_lock(void) { - static of_once_t once_control = OF_ONCE_INIT; - of_once(&once_control, init); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, init); if (of_rmutex_lock(&globalMutex) != 0) OBJC_ERROR("Failed to lock global mutex!"); } Index: src/socket.m ================================================================== --- src/socket.m +++ src/socket.m @@ -161,12 +161,12 @@ bool of_socket_init(void) { #if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS) - static of_once_t onceControl = OF_ONCE_INIT; - of_once(&onceControl, init); + static OFOnceControl onceControl = OFOnceControlInitValue; + OFOnce(&onceControl, init); return initSuccessful; #else struct Library *socketBase; # ifdef OF_AMIGAOS4