Index: src/runtime/autorelease.m ================================================================== --- src/runtime/autorelease.m +++ src/runtime/autorelease.m @@ -39,11 +39,11 @@ static void __attribute__((constructor)) init(void) { if (!of_tlskey_new(&objectsKey) || !of_tlskey_new(&sizeKey) || !of_tlskey_new(&topKey)) - ERROR("Unable to create TLS key for autorelease pools!") + OBJC_ERROR("Unable to create TLS key for autorelease pools!") } #endif id objc_autorelease(id object) @@ -85,11 +85,11 @@ top = NULL; } #ifndef OF_COMPILER_TLS if (!of_tlskey_set(objectsKey, objects) ||!of_tlskey_set(topKey, top)) - ERROR("Failed to set TLS key!") + OBJC_ERROR("Failed to set TLS key!") #endif } id _objc_rootAutorelease(id object) @@ -100,17 +100,17 @@ size_t size = (size_t)(uintptr_t)of_tlskey_get(sizeKey); #endif if (objects == NULL) { if ((objects = malloc(of_pagesize)) == NULL) - ERROR("Out of memory for autorelease pools!") + OBJC_ERROR("Out of memory for autorelease pools!") #ifndef OF_COMPILER_TLS if (!of_tlskey_set(objectsKey, objects)) - ERROR("Failed to set TLS key!") + OBJC_ERROR("Failed to set TLS key!") if (!of_tlskey_set(sizeKey, (void*)(uintptr_t)of_pagesize)) - ERROR("Failed to set TLS key!") + OBJC_ERROR("Failed to set TLS key!") #endif top = objects; size = of_pagesize; } @@ -118,17 +118,17 @@ if ((uintptr_t)top >= (uintptr_t)objects + size) { ptrdiff_t diff = top - objects; size += of_pagesize; if ((objects = realloc(objects, size)) == NULL) - ERROR("Out of memory for autorelease pools!") + OBJC_ERROR("Out of memory for autorelease pools!") #ifndef OF_COMPILER_TLS if (!of_tlskey_set(objectsKey, objects)) - ERROR("Failed to set TLS key!") + OBJC_ERROR("Failed to set TLS key!") if (!of_tlskey_set(sizeKey, (void*)(uintptr_t)size)) - ERROR("Failed to set TLS key!") + OBJC_ERROR("Failed to set TLS key!") #endif top = objects + diff; } @@ -135,10 +135,10 @@ *top = object; top++; #ifndef OF_COMPILER_TLS if (!of_tlskey_set(topKey, objects)) - ERROR("Failed to set TLS key!") + OBJC_ERROR("Failed to set TLS key!") #endif return object; } Index: src/runtime/category.m ================================================================== --- src/runtime/category.m +++ src/runtime/category.m @@ -60,12 +60,12 @@ for (i = 0; cats[i] != NULL; i++); if ((ncats = realloc(cats, (i + 2) * sizeof(struct objc_abi_category*))) == NULL) - ERROR("Not enough memory for category %s of class %s!", - cat->category_name, cat->class_name); + OBJC_ERROR("Not enough memory for category %s of " + "class %s!", cat->category_name, cat->class_name); ncats[i] = cat; ncats[i + 1] = NULL; objc_hashtable_set(categories, cat->class_name, ncats); @@ -76,11 +76,11 @@ return; } if ((cats = malloc(2 * sizeof(struct objc_abi_category*))) == NULL) - ERROR("Not enough memory for category %s of class %s!\n", + OBJC_ERROR("Not enough memory for category %s of class %s!\n", cat->category_name, cat->class_name); cats[0] = cat; cats[1] = NULL; objc_hashtable_set(categories, cat->class_name, cats); Index: src/runtime/class.m ================================================================== --- src/runtime/class.m +++ src/runtime/class.m @@ -178,11 +178,11 @@ size_t i; if (cls->superclass->subclass_list == NULL) { if ((cls->superclass->subclass_list = malloc(2 * sizeof(Class))) == NULL) - ERROR("Not enough memory for subclass list of " + OBJC_ERROR("Not enough memory for subclass list of " "class %s!", cls->superclass->name); cls->superclass->subclass_list[0] = cls; cls->superclass->subclass_list[1] = Nil; @@ -193,11 +193,11 @@ cls->superclass->subclass_list = realloc(cls->superclass->subclass_list, (i + 2) * sizeof(Class)); if (cls->superclass->subclass_list == NULL) - ERROR("Not enough memory for subclass list of class %s\n", + OBJC_ERROR("Not enough memory for subclass list of class %s\n", cls->superclass->name); cls->superclass->subclass_list[i] = cls; cls->superclass->subclass_list[i + 1] = Nil; } @@ -314,11 +314,11 @@ load_queue = realloc(load_queue, sizeof(Class) * (load_queue_cnt + 1)); if (load_queue == NULL) - ERROR("Not enough memory for load " + OBJC_ERROR("Not enough memory for load " "queue!"); load_queue[load_queue_cnt++] = cls; } } else @@ -344,11 +344,11 @@ load_queue = realloc(load_queue, sizeof(Class) * load_queue_cnt); if (load_queue == NULL) - ERROR("Not enough memory for load queue!"); + OBJC_ERROR("Not enough memory for load queue!"); } } } inline Class @@ -378,11 +378,11 @@ objc_get_class(const char *name) { Class cls; if ((cls = objc_lookup_class(name)) == Nil) - ERROR("Class %s not found!", name); + OBJC_ERROR("Class %s not found!", name); return cls; } const char* @@ -512,11 +512,11 @@ } } /* FIXME: We need a way to free this at objc_exit() */ if ((ml = malloc(sizeof(struct objc_method_list))) == NULL) - ERROR("Not enough memory to replace method!"); + OBJC_ERROR("Not enough memory to replace method!"); ml->next = cls->methodlist; ml->count = 1; ml->methods[0].sel.uid = sel->uid; ml->methods[0].sel.types = types; Index: src/runtime/hashtable.m ================================================================== --- src/runtime/hashtable.m +++ src/runtime/hashtable.m @@ -50,18 +50,18 @@ { struct objc_hashtable *h; uint32_t i; if ((h = malloc(sizeof(struct objc_hashtable))) == NULL) - ERROR("Not enough memory to allocate hash table!"); + OBJC_ERROR("Not enough memory to allocate hash table!"); h->count = 0; h->last_idx = size - 1; h->data = malloc(size * sizeof(struct objc_hashtable_bucket*)); if (h->data == NULL) - ERROR("Not enough memory to allocate hash table!"); + OBJC_ERROR("Not enough memory to allocate hash table!"); for (i = 0; i < size; i++) h->data[i] = NULL; return h; @@ -82,11 +82,12 @@ assert(nsize > 0); ndata = malloc(nsize * sizeof(struct objc_hashtable_bucket*)); if (ndata == NULL) - ERROR("Not enough memory to insert into hash table!"); + OBJC_ERROR("Not enough memory to insert into hash " + "table!"); for (i = 0; i < nsize; i++) ndata[i] = NULL; for (i = 0; i <= h->last_idx; i++) { @@ -104,11 +105,11 @@ for (j = 0; j < last && ndata[j] != NULL; j++); } if (j >= last) - ERROR("No free bucket!"); + OBJC_ERROR("No free bucket!"); ndata[j] = h->data[i]; } } @@ -126,14 +127,14 @@ for (i = 0; i < last && h->data[i] != NULL; i++); } if (i >= last) - ERROR("No free bucket!"); + OBJC_ERROR("No free bucket!"); if ((bucket = malloc(sizeof(struct objc_hashtable_bucket))) == NULL) - ERROR("Not enough memory to allocate hash table bucket!"); + OBJC_ERROR("Not enough memory to allocate hash table bucket!"); bucket->key = key; bucket->hash = hash; bucket->obj = obj; Index: src/runtime/lookup.m ================================================================== --- src/runtime/lookup.m +++ src/runtime/lookup.m @@ -37,11 +37,11 @@ if (!(cls->info & OBJC_CLASS_INFO_SETUP)) { if (is_class) return objc_msg_lookup(nil, sel); else - ERROR("Could not dispatch message for " + OBJC_ERROR("Could not dispatch message for " "incomplete class %s!", cls->name); } /* * We don't need to handle the case that super was called. @@ -53,11 +53,11 @@ } if (objc_forward_handler != NULL) return objc_forward_handler(obj, sel); - ERROR("Selector %s is not implemented for class %s!", + OBJC_ERROR("Selector %s is not implemented for class %s!", sel_getName(sel), object_getClassName(obj)); } BOOL class_respondsToSelector(Class cls, SEL sel) Index: src/runtime/runtime-private.h ================================================================== --- src/runtime/runtime-private.h +++ src/runtime/runtime-private.h @@ -190,12 +190,12 @@ return (void*)s->buckets[i]->buckets[j]; #endif } -#define ERROR(...) \ +#define OBJC_ERROR(...) \ { \ fprintf(stderr, "[objc @ " __FILE__ ":%d] ", __LINE__); \ fprintf(stderr, __VA_ARGS__); \ fputs("\n", stderr); \ abort(); \ } Index: src/runtime/selector.m ================================================================== --- src/runtime/selector.m +++ src/runtime/selector.m @@ -52,11 +52,11 @@ name = sel->name; rsel = (struct objc_selector*)sel; rsel->uid = selectors_cnt++; if (selectors_cnt > SEL_MAX) - ERROR("Out of selector slots!"); + OBJC_ERROR("Out of selector slots!"); objc_hashtable_set(selectors, name, rsel); objc_sparsearray_set(selector_names, (uint32_t)rsel->uid, name); } @@ -74,14 +74,14 @@ return (SEL)rsel; } /* FIXME: Free on objc_exit() */ if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL) - ERROR("Not enough memory to allocate selector!"); + OBJC_ERROR("Not enough memory to allocate selector!"); if ((sel->name = strdup(name)) == NULL) - ERROR("Not enough memory to allocate selector!"); + OBJC_ERROR("Not enough memory to allocate selector!"); sel->types = NULL; objc_register_selector(sel); Index: src/runtime/sparsearray.m ================================================================== --- src/runtime/sparsearray.m +++ src/runtime/sparsearray.m @@ -32,18 +32,18 @@ { uint_fast16_t i; empty_level2 = malloc(sizeof(struct objc_sparsearray_level2)); if (empty_level2 == NULL) - ERROR("Not enough memory to allocate sparse array!"); + OBJC_ERROR("Not enough memory to allocate sparse array!"); empty_level2->empty = YES; #ifndef OF_SELUID16 empty_level3 = malloc(sizeof(struct objc_sparsearray_level3)); if (empty_level3 == NULL) - ERROR("Not enough memory to allocate sparse array!"); + OBJC_ERROR("Not enough memory to allocate sparse array!"); empty_level3->empty = YES; #endif #ifndef OF_SELUID16 @@ -70,11 +70,11 @@ if (empty_level2 == NULL) init(); #endif if ((s = malloc(sizeof(struct objc_sparsearray))) == NULL) - ERROR("Not enough memory to allocate sparse array!"); + OBJC_ERROR("Not enough memory to allocate sparse array!"); for (i = 0; i < 256; i++) s->buckets[i] = empty_level2; return s; @@ -145,11 +145,12 @@ uint_fast16_t l; t = malloc(sizeof(struct objc_sparsearray_level2)); if (t == NULL) - ERROR("Not enough memory to insert into sparse array!"); + OBJC_ERROR("Not enough memory to insert into sparse " + "array!"); t->empty = NO; for (l = 0; l < 256; l++) #ifndef OF_SELUID16 @@ -167,11 +168,12 @@ uint_fast16_t l; t = malloc(sizeof(struct objc_sparsearray_level3)); if (t == NULL) - ERROR("Not enough memory to insert into sparse array!"); + OBJC_ERROR("Not enough memory to insert into sparse " + "array!"); t->empty = NO; for (l = 0; l < 256; l++) t->buckets[l] = NULL; Index: src/runtime/static-instances.m ================================================================== --- src/runtime/static-instances.m +++ src/runtime/static-instances.m @@ -56,12 +56,12 @@ static_instances = realloc(static_instances, sizeof(struct objc_abi_static_instances*) * static_instances_cnt); if (static_instances == NULL) - ERROR("Not enough memory for list of static " - "instances!"); + OBJC_ERROR("Not enough memory for list of " + "static instances!"); } } si = (struct objc_abi_static_instances**) symtab->defs[symtab->cls_def_cnt + symtab->cat_def_cnt]; @@ -86,12 +86,12 @@ static_instances = realloc(static_instances, sizeof(struct objc_abi_static_instances*) * (static_instances_cnt + 1)); if (static_instances == NULL) - ERROR("Not enough memory for list of static " - "instances!"); + OBJC_ERROR("Not enough memory for list of " + "static instances!"); static_instances[static_instances_cnt++] = *si; } } } Index: src/runtime/threading.m ================================================================== --- src/runtime/threading.m +++ src/runtime/threading.m @@ -70,11 +70,11 @@ static void objc_global_mutex_new(void) { if (!objc_mutex_new(&global_mutex)) - ERROR("Failed to create global mutex!"); + OBJC_ERROR("Failed to create global mutex!"); global_mutex_init = YES; } void @@ -82,21 +82,21 @@ { if (!global_mutex_init) objc_global_mutex_new(); if (!objc_mutex_lock(&global_mutex)) - ERROR("Failed to lock global mutex!"); + OBJC_ERROR("Failed to lock global mutex!"); } void objc_global_mutex_unlock(void) { if (!objc_mutex_unlock(&global_mutex)) - ERROR("Failed to unlock global mutex!"); + OBJC_ERROR("Failed to unlock global mutex!"); } void objc_global_mutex_free(void) { if (!objc_mutex_free(&global_mutex)) - ERROR("Failed to free global mutex!"); + OBJC_ERROR("Failed to free global mutex!"); }