aboutsummaryrefslogtreecommitdiff
path: root/libobjc/archive.c
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-09-12 00:43:15 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-09-12 00:43:15 +0000
commit7b8699866416f7a55116e19bf6fe2c28bae12a68 (patch)
treee22bed6f4601015a5042c0e66fd318e63707468e /libobjc/archive.c
parent201fb1f2283994930d4bc07f9eaeaaf7d98052c0 (diff)
downloadgcc-7b8699866416f7a55116e19bf6fe2c28bae12a68.zip
gcc-7b8699866416f7a55116e19bf6fe2c28bae12a68.tar.gz
gcc-7b8699866416f7a55116e19bf6fe2c28bae12a68.tar.bz2
In libobjc/:
* objc/deprecated/objc_error.h: New file. * objc/objc-api.h: Include deprecated/objc_error.h instead of defining objc_error and related. * error.c: New file. Added _objc_abort function which replaces objc_error. No change in functionality as they both print an error and abort. * misc.c: File removed. Code moved into memory.c and error.c. * memory.c: New file. * objc-private/error.h: New file. * archive.c: Include objc-private/error.h and use _objc_abort instead of objc_error everywhere. * class.c: Same change. * encoding.c: Same change. * init.c: Same change, and simplified init_check_module_version. * memory.c: Same change. * sendmsg.c: Same change. * thr.c: Same change. * Makefile.in (OBJ_DEPRECATED_H): Added objc_error.h. (OBJ_H): Reordered list. (OBJS): Removed misc.lo, added memory.lo and error.lo. (OBJS_GC): Removed misc_gc.lo, added memory_gc.lo and error_gc.lo. (misc_gc.lo): Rule removed. (error_gc.lo): Rule added. (memory_gc.lo): Rule added. From-SVN: r164223
Diffstat (limited to 'libobjc/archive.c')
-rw-r--r--libobjc/archive.c83
1 files changed, 34 insertions, 49 deletions
diff --git a/libobjc/archive.c b/libobjc/archive.c
index 6603ab1..9b46976 100644
--- a/libobjc/archive.c
+++ b/libobjc/archive.c
@@ -22,7 +22,10 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+/* This file is entirely deprecated and will be removed. */
+
#include "objc-private/common.h"
+#include "objc-private/error.h"
#include "tconfig.h"
#include "objc/objc.h"
#include "objc/objc-api.h"
@@ -364,8 +367,7 @@ __objc_write_extension (struct objc_typed_stream *stream, unsigned char code)
}
else
{
- objc_error (nil, OBJC_ERR_BAD_OPCODE,
- "__objc_write_extension: bad opcode %c\n", code);
+ _objc_abort ("__objc_write_extension: bad opcode %c\n", code);
return -1;
}
}
@@ -402,8 +404,7 @@ objc_write_root_object (struct objc_typed_stream *stream, id object)
{
int len = 0;
if (stream->writing_root_p)
- objc_error (nil, OBJC_ERR_RECURSE_ROOT,
- "objc_write_root_object called recursively");
+ _objc_abort ("objc_write_root_object called recursively");
else
{
stream->writing_root_p = 1;
@@ -527,9 +528,8 @@ objc_read_char (struct objc_typed_stream *stream, char *val)
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected 8bit signed int, got %dbit int",
- (int) (buf&_B_NUMBER)*8);
+ _objc_abort ("expected 8bit signed int, got %dbit int",
+ (int) (buf&_B_NUMBER)*8);
}
return len;
}
@@ -549,9 +549,8 @@ objc_read_unsigned_char (struct objc_typed_stream *stream, unsigned char *val)
len = (*stream->read) (stream->physical, (char*)val, 1);
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected 8bit unsigned int, got %dbit int",
- (int) (buf&_B_NUMBER)*8);
+ _objc_abort ("expected 8bit unsigned int, got %dbit int",
+ (int) (buf&_B_NUMBER)*8);
}
return len;
}
@@ -571,8 +570,7 @@ objc_read_short (struct objc_typed_stream *stream, short *value)
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (short))
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected short, got bigger (%dbits)", nbytes*8);
+ _objc_abort ("expected short, got bigger (%dbits)", nbytes*8);
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
@@ -600,8 +598,7 @@ objc_read_unsigned_short (struct objc_typed_stream *stream,
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (short))
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected short, got int or bigger");
+ _objc_abort ("expected short, got int or bigger");
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
@@ -627,7 +624,7 @@ objc_read_int (struct objc_typed_stream *stream, int *value)
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (int))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
+ _objc_abort ("expected int, got bigger");
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
@@ -654,7 +651,7 @@ objc_read_long (struct objc_typed_stream *stream, long *value)
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > (int) sizeof (long))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
+ _objc_abort ("expected long, got bigger");
len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
@@ -675,7 +672,7 @@ __objc_read_nbyte_uint (struct objc_typed_stream *stream,
unsigned char buf[sizeof (unsigned int) + 1];
if (nbytes > sizeof (int))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
+ _objc_abort ("expected int, got bigger");
len = (*stream->read) (stream->physical, (char*)buf, nbytes);
(*val) = 0;
@@ -712,7 +709,7 @@ __objc_read_nbyte_ulong (struct objc_typed_stream *stream,
unsigned char buf[sizeof (unsigned long) + 1];
if (nbytes > sizeof (long))
- objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
+ _objc_abort ("expected long, got bigger");
len = (*stream->read) (stream->physical, (char*)buf, nbytes);
(*val) = 0;
@@ -793,8 +790,7 @@ objc_read_string (struct objc_typed_stream *stream,
break;
default:
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected string, got opcode %c\n", (buf[0]&_B_CODE));
+ _objc_abort ("expected string, got opcode %c\n", (buf[0]&_B_CODE));
}
}
@@ -839,14 +835,13 @@ objc_read_object (struct objc_typed_stream *stream, id *object)
/* check null-byte */
len = (*stream->read) (stream->physical, (char*)buf, 1);
if (buf[0] != '\0')
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected null-byte, got opcode %c", buf[0]);
+ _objc_abort ("expected null-byte, got opcode %c", buf[0]);
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ _objc_abort ("cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
(*object) = objc_hash_value_for_key (stream->object_table,
LONG2PTR(key));
@@ -866,15 +861,13 @@ objc_read_object (struct objc_typed_stream *stream, id *object)
else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY,
- "cannot register root object...");
+ _objc_abort ("cannot register root object...");
len = objc_read_object (stream, object);
__objc_finish_read_root_object (stream);
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected object, got opcode %c", buf[0]);
+ _objc_abort ("expected object, got opcode %c", buf[0]);
}
return len;
}
@@ -917,18 +910,16 @@ objc_read_class (struct objc_typed_stream *stream, Class *class)
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ _objc_abort ("cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
*class = objc_hash_value_for_key (stream->stream_table,
LONG2PTR(key));
if (! *class)
- objc_error (nil, OBJC_ERR_BAD_CLASS,
- "cannot find class for key %lu", key);
+ _objc_abort ("cannot find class for key %lu", key);
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected class, got opcode %c", buf[0]);
+ _objc_abort ("expected class, got opcode %c", buf[0]);
}
return len;
}
@@ -974,15 +965,14 @@ objc_read_selector (struct objc_typed_stream *stream, SEL* selector)
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ _objc_abort ("cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
(*selector) = objc_hash_value_for_key (stream->stream_table,
LONG2PTR(key));
}
else
- objc_error (nil, OBJC_ERR_BAD_DATA,
- "expected selector, got opcode %c", buf[0]);
+ _objc_abort ("expected selector, got opcode %c", buf[0]);
}
return len;
}
@@ -1082,8 +1072,7 @@ objc_write_type (TypedStream *stream, const char *type, const void *data)
default:
{
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_write_type: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_write_type: cannot parse typespec: %s\n", type);
return 0;
}
}
@@ -1178,8 +1167,7 @@ objc_read_type(TypedStream *stream, const char *type, void *data)
default:
{
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_read_type: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_read_type: cannot parse typespec: %s\n", type);
return 0;
}
}
@@ -1276,13 +1264,12 @@ objc_write_types (TypedStream *stream, const char *type, ...)
res = objc_write_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
if (*t != _C_ARY_E)
- objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
+ _objc_abort ("expected `]', got: %s", t);
}
break;
default:
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_write_types: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_write_types: cannot parse typespec: %s\n", type);
}
}
va_end(args);
@@ -1368,13 +1355,12 @@ objc_read_types(TypedStream *stream, const char *type, ...)
res = objc_read_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
if (*t != _C_ARY_E)
- objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
+ _objc_abort ("expected `]', got: %s", t);
}
break;
default:
- objc_error (nil, OBJC_ERR_BAD_TYPE,
- "objc_read_types: cannot parse typespec: %s\n", type);
+ _objc_abort ("objc_read_types: cannot parse typespec: %s\n", type);
}
}
va_end (args);
@@ -1446,7 +1432,7 @@ __objc_no_write (FILE *file __attribute__ ((__unused__)),
const char *data __attribute__ ((__unused__)),
int len __attribute__ ((__unused__)))
{
- objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing");
+ _objc_abort ("TypedStream not open for writing");
return 0;
}
@@ -1455,7 +1441,7 @@ __objc_no_read (FILE *file __attribute__ ((__unused__)),
const char *data __attribute__ ((__unused__)),
int len __attribute__ ((__unused__)))
{
- objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading");
+ _objc_abort ("TypedStream not open for reading");
return 0;
}
@@ -1470,8 +1456,7 @@ __objc_read_typed_stream_signature (TypedStream *stream)
;
sscanf (buffer, "GNU TypedStream %d", &stream->version);
if (stream->version != OBJC_TYPED_STREAM_VERSION)
- objc_error (nil, OBJC_ERR_STREAM_VERSION,
- "cannot handle TypedStream version %d", stream->version);
+ _objc_abort ("cannot handle TypedStream version %d", stream->version);
return 1;
}