Index: .github/ISSUE_TEMPLATE/config.yml
==================================================================
--- .github/ISSUE_TEMPLATE/config.yml
+++ .github/ISSUE_TEMPLATE/config.yml
@@ -12,10 +12,25 @@
url: https://objfw.nil.im/forum
about: Please use this if you have questions or want support.
- name: ObjFW Matrix Room
url: https://matrix.to/#/%23objfw:nil.im
about: Please use this for interactive questions and support.
- - name: ObjFW IRC Channel
- url: https://webchat.freenode.net/?channels=objfw
+ - name: ObjFW Slack Channel
+ url: https://objfw.nil.im/slack
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
+ - name: ObjFW Discord Channel
+ url: https://objfw.nil.im/discord
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
+ - name: ObjFW Telegram Room
+ url: https://t.me/objfw
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
+ - name: ObjFW Gitter Room
+ url: https://gitter.im/ObjFW/ObjFW
about:
Please use this for interactive questions and support - it is bridged to
the Matrix room above.
Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -336,11 +336,11 @@
In order to build the documentation yourself (necessary to have documentation
for trunk / master), you need to have [Doxygen](https://www.doxygen.nl)
installed. Once installed, you can build the documentation from the root
directory of the repository:
- $ doxygen >/dev/null
+ $ make docs
Bugs and feature requests
If you find any bugs or have feature requests, please
@@ -354,14 +354,18 @@
If you have any questions about ObjFW or would like to talk to other ObjFW
users, the following venues are available:
* The [forum](https://objfw.nil.im/forum)
- * A [Matrix](https://matrix.to/#/%23objfw:nil.im) room
- * An [IRC channel](irc://chat.freenode.net/#objfw) on Freenode (`#objfw`,
- [web chat](https://webchat.freenode.net/?channels=objfw)), bridged to the
- Matrix room above
+ * A [Matrix room](https://matrix.to/#/%23objfw:nil.im)
+ * A [Slack channel](https://objfw.nil.im/slack), bridged to the Matrix room
+ above
+ * A [Discord channel](https://objfw.nil.im/discord), bridged to the Matrix
+ room above
+ * A [Telegram room](https://t.me/objfw), bridged to the Matrix room above
+ * A [Gitter room](https://gitter.im/ObjFW/ObjFW), bridged to the Matrix room
+ above
Please don't hesitate to join any or all of those!
Commercial use
Index: build-aux/m4/buildsys.m4
==================================================================
--- build-aux/m4/buildsys.m4
+++ build-aux/m4/buildsys.m4
@@ -47,11 +47,22 @@
[AC_SUBST(DEP_OBJCXXFLAGS, '-MD -MF $${out%.o}.dep')])
AC_SUBST(AMIGA_LIB_CFLAGS)
AC_SUBST(AMIGA_LIB_LDFLAGS)
- AC_PATH_PROG(TPUT, tput)
+ case "$build_os" in
+ morphos*)
+ dnl Don't use tput on MorphOS: The colored
+ dnl output is quite unreadable and in some
+ dnl MorphOS versions, the output from tput is
+ dnl not 8-bit safe, with awk (for AC_SUBST)
+ dnl failing as a result.
+ ;;
+ *)
+ AC_PATH_PROG(TPUT, tput)
+ ;;
+ esac
AS_IF([test x"$TPUT" != x""], [
if x=$($TPUT el 2>/dev/null); then
AC_SUBST(TERM_EL, "$x")
else
@@ -307,10 +318,11 @@
FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}'
])
AC_SUBST(FRAMEWORK_LDFLAGS)
AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME)
+ AC_SUBST(FRAMEWORK_LIBS)
$1
;;
esac
])
Index: buildsys.mk.in
==================================================================
--- buildsys.mk.in
+++ buildsys.mk.in
@@ -61,10 +61,11 @@
PLUGIN_CFLAGS = @PLUGIN_CFLAGS@
PLUGIN_LDFLAGS = @PLUGIN_LDFLAGS@
PLUGIN_SUFFIX = @PLUGIN_SUFFIX@
FRAMEWORK_LDFLAGS = @FRAMEWORK_LDFLAGS@
FRAMEWORK_LDFLAGS_INSTALL_NAME = @FRAMEWORK_LDFLAGS_INSTALL_NAME@
+FRAMEWORK_LIBS = @FRAMEWORK_LIBS@
CODESIGN = @CODESIGN@
CODESIGN_IDENTITY ?= -
CLEAN_LIB = @CLEAN_LIB@
DEP_ASFLAGS = @DEP_ASFLAGS@
DEP_CFLAGS = @DEP_CFLAGS@
Index: configure.ac
==================================================================
--- configure.ac
+++ configure.ac
@@ -100,11 +100,10 @@
AC_SUBST(LIBBASES_M, libbases.m)
])
enable_shared="no"
- enable_threads="no"
;;
*-msdosdjgpp*)
enable_shared="no"
enable_threads="no"
enable_sockets="no"
@@ -147,11 +146,21 @@
: ${GREP:=grep.exe}
: ${RANLIB:=ranlib.exe}
])
AC_LANG([Objective C])
-AC_PROG_OBJC([clang egcc gcc])
+case "$host_os" in
+ morphos*)
+ dnl Don't use clang on MorphOS - it does not support baserel,
+ dnl which is required for the .library.
+ potential_compilers="gcc"
+ ;;
+ *)
+ potential_compilers="clang egcc gcc"
+ ;;
+esac
+AC_PROG_OBJC($potential_compilers)
AC_PROG_OBJCPP
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_EGREP
@@ -358,15 +367,12 @@
AS_HELP_STRING([--disable-shared], [do not build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")
AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a")
- AC_SUBST(EXCEPTIONS_EXCEPTIONS_LIB_A, "exceptions/exceptions.lib.a")
AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a")
- AC_SUBST(FORWARDING_FORWARDING_LIB_A, "forwarding/forwarding.lib.a")
AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a")
- AC_SUBST(LOOKUP_ASM_LOOKUP_ASM_LIB_A, "lookup-asm/lookup-asm.lib.a")
BUILDSYS_FRAMEWORK([
AC_SUBST(OBJFW_FRAMEWORK, "ObjFW.framework")
build_framework="yes"
])
@@ -386,24 +392,26 @@
])
AC_ARG_ENABLE(amiga-lib,
AS_HELP_STRING([--disable-amiga-lib], [do not build Amiga library]))
AS_IF([test x"$supports_amiga_lib" != x"yes"], [enable_amiga_lib="no"])
-
-AS_IF([test x"$enable_shared" = x"no" -a x"$enable_amiga_lib" = x"no"], [
- enable_static="yes"
+AS_IF([test x"$enable_amiga_lib" != x"no"], [
+ AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
+ AC_SUBST(EXCEPTIONS_A, "exceptions.a")
+ AC_SUBST(FORWARDING_A, "forwarding.a")
+ AC_SUBST(LOOKUP_ASM_AMIGALIB_A, "lookup-asm.amigalib.a")
])
AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library]))
-AS_IF([test x"$enable_static" = x"yes" -o x"$enable_amiga_lib" != x"no"], [
+AS_IF([test x"$enable_shared" = x"no" -a x"$enable_amiga_lib" = x"no"], [
+ enable_static="yes"
+])
+AS_IF([test x"$enable_static" = x"yes"], [
AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
AC_SUBST(EXCEPTIONS_A, "exceptions.a")
- AC_SUBST(EXCEPTIONS_EXCEPTIONS_A, "exceptions/exceptions.a")
AC_SUBST(FORWARDING_A, "forwarding.a")
- AC_SUBST(FORWARDING_FORWARDING_A, "forwarding/forwarding.a")
AC_SUBST(LOOKUP_ASM_A, "lookup-asm.a")
- AC_SUBST(LOOKUP_ASM_LOOKUP_ASM_A, "lookup-asm/lookup-asm.a")
])
AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
AS_IF([test x"$enable_files" != x"no" -a x"$PLUGIN_SUFFIX" != x""], [
AC_SUBST(USE_SRCS_PLUGINS, '${SRCS_PLUGINS}')
@@ -1034,14 +1042,18 @@
case "$host" in
aarch64*-*-android*)
# Compiler TLS is broken on AArch64 Android with Clang
enable_compiler_tls="no"
;;
- m68k-*-amigaos | powerpc-*-amigaos)
+ m68k-*-amigaos* | powerpc-*-amigaos*)
# Compiler TLS is broken on AmigaOS
enable_compiler_tls="no"
;;
+ *-*-morphos*)
+ # Compiler TLS needs helpers that we don't want in the
+ # .library
+ enable_compiler_tls="no"
esac
AS_IF([test x"$enable_compiler_tls" != x"no"], [
AC_CHECK_HEADER(threads.h, [
AC_DEFINE(OF_HAVE_THREADS_H, 1,
@@ -1304,19 +1316,13 @@
])
AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_FUNCS(uname)
-case "$host_os" in
- amigaos*)
- ;;
- *)
- AC_CHECK_FUNC(pipe, [
- AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()])
- ])
- ;;
-esac
+AC_CHECK_FUNC(pipe, [
+ AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()])
+])
AC_ARG_ENABLE(sockets,
AS_HELP_STRING([--disable-sockets], [disable socket support]))
AS_IF([test x"$enable_sockets" != x"no"], [
AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets])
@@ -1550,18 +1556,31 @@
])
CHECK_BUILTIN_BSWAP(16)
CHECK_BUILTIN_BSWAP(32)
CHECK_BUILTIN_BSWAP(64)
-case "$host" in
- arm*-apple-darwin*)
- have_processes="no"
+case "$host_os" in
+ darwin*)
+ AC_MSG_CHECKING(whether we are compiling for macOS)
+ AC_EGREP_CPP(egrep_cpp_yes, [
+ #include
+
+ #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+ egrep_cpp_yes
+ #endif
+ ], [
+ AC_MSG_RESULT(yes)
+ have_processes="yes"
+ ], [
+ AC_MSG_RESULT(no)
+ have_processes="no"
+ ])
;;
- *-*-mingw*)
+ mingw*)
have_processes="yes"
;;
- *-*-msdosdjgpp*)
+ msdosdjgpp*)
have_processes="no"
;;
*)
AC_HEADER_SYS_WAIT
AC_CHECK_FUNCS(kill)
Index: extra.mk.in
==================================================================
--- extra.mk.in
+++ extra.mk.in
@@ -20,37 +20,28 @@
BIN_PREFIX = @BIN_PREFIX@
BRIDGE = @BRIDGE@
CVINCLUDE_INLINE_H = @CVINCLUDE_INLINE_H@
ENCODINGS = @ENCODINGS@
ENCODINGS_A = @ENCODINGS_A@
-ENCODINGS_ENCODINGS_A = @ENCODINGS_ENCODINGS_A@
-ENCODINGS_ENCODINGS_LIB_A = @ENCODINGS_ENCODINGS_LIB_A@
ENCODINGS_LIB_A = @ENCODINGS_LIB_A@
ENCODINGS_SRCS = @ENCODINGS_SRCS@
EXCEPTIONS_A = @EXCEPTIONS_A@
-EXCEPTIONS_EXCEPTIONS_A = @EXCEPTIONS_EXCEPTIONS_A@
-EXCEPTIONS_EXCEPTIONS_LIB_A = @EXCEPTIONS_EXCEPTIONS_LIB_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
FISH_COMPLETIONS = @FISH_COMPLETIONS@
FORWARDING_A = @FORWARDING_A@
-FORWARDING_FORWARDING_A = @FORWARDING_FORWARDING_A@
-FORWARDING_FORWARDING_LIB_A = @FORWARDING_FORWARDING_LIB_A@
FORWARDING_LIB_A = @FORWARDING_LIB_A@
INVOCATION_A = @INVOCATION_A@
-INVOCATION_INVOCATION_A = @INVOCATION_INVOCATION_A@
-INVOCATION_INVOCATION_LIB_A = @INVOCATION_INVOCATION_LIB_A@
INVOCATION_LIB_A = @INVOCATION_LIB_A@
LIBBASES_M = @LIBBASES_M@
LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@
LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@
LIBOBJFW_DEP = @LIBOBJFW_DEP@
LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@
LINKLIB = @LINKLIB@
LOOKUP_ASM_A = @LOOKUP_ASM_A@
LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@
-LOOKUP_ASM_LOOKUP_ASM_A = @LOOKUP_ASM_LOOKUP_ASM_A@
-LOOKUP_ASM_LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LOOKUP_ASM_LIB_A@
+LOOKUP_ASM_AMIGALIB_A = @LOOKUP_ASM_AMIGALIB_A@
MAP_LDFLAGS = @MAP_LDFLAGS@
OFARC = @OFARC@
OFDNS = @OFDNS@
OFHASH = @OFHASH@
OFHTTP = @OFHTTP@
Index: src/Makefile
==================================================================
--- src/Makefile
+++ src/Makefile
@@ -212,18 +212,16 @@
${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \
${OF_POLL_KERNEL_EVENT_OBSERVER_M} \
${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \
OFTCPSocketSOCKS5Connector.m
-OBJS_EXTRA = ${RUNTIME_RUNTIME_A} \
- ${EXCEPTIONS_EXCEPTIONS_A} \
- ${ENCODINGS_ENCODINGS_A} \
- ${FORWARDING_FORWARDING_A}
-LIB_OBJS_EXTRA = ${RUNTIME_RUNTIME_LIB_A} \
- ${EXCEPTIONS_EXCEPTIONS_LIB_A} \
- ${ENCODINGS_ENCODINGS_LIB_A} \
- ${FORWARDING_FORWARDING_LIB_A}
+OBJS_EXTRA = exceptions/exceptions.a \
+ encodings/encodings.a \
+ forwarding/forwarding.a
+LIB_OBJS_EXTRA = exceptions/exceptions.lib.a \
+ encodings/encodings.lib.a \
+ forwarding/forwarding.lib.a
include ../buildsys.mk
CPPFLAGS += -I. -I.. -Iexceptions -Iruntime
LD = ${OBJC}
Index: src/OFApplication.m
==================================================================
--- src/OFApplication.m
+++ src/OFApplication.m
@@ -258,11 +258,11 @@
"variable: %s\n", tmp.UTF8String);
continue;
}
key = [tmp substringToIndex: pos];
- value = [tmp substringFromRange: pos + 1];
+ value = [tmp substringFromIndex: pos + 1];
[_environment setObject: value
forKey: key];
objc_autoreleasePoolPop(pool);
Index: src/OFArray.m
==================================================================
--- src/OFArray.m
+++ src/OFArray.m
@@ -239,11 +239,11 @@
}
- (id const *)objects
{
size_t count = self.count;
- id *buffer = of_malloc(count, sizeof(id));
+ id *buffer = of_alloc(count, sizeof(id));
@try {
[self getObjects: buffer
inRange: of_range(0, count)];
@@ -381,11 +381,11 @@
if (![self isKindOfClass: [OFMutableArray class]])
return [OFSubarray arrayWithArray: self
range: range];
- buffer = of_malloc(range.length, sizeof(*buffer));
+ buffer = of_alloc(range.length, sizeof(*buffer));
@try {
[self getObjects: buffer
inRange: range];
ret = [OFArray arrayWithObjects: buffer
@@ -856,11 +856,11 @@
#ifdef OF_HAVE_BLOCKS
- (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block
{
OFArray *ret;
size_t count = self.count;
- id *tmp = of_malloc(count, sizeof(id));
+ id *tmp = of_alloc(count, sizeof(id));
@try {
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
tmp[idx] = block(object, idx);
@@ -877,11 +877,11 @@
- (OFArray *)filteredArrayUsingBlock: (of_array_filter_block_t)block
{
OFArray *ret;
size_t count = self.count;
- id *tmp = of_malloc(count, sizeof(id));
+ id *tmp = of_alloc(count, sizeof(id));
@try {
__block size_t i = 0;
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
Index: src/OFBitSetCharacterSet.m
==================================================================
--- src/OFBitSetCharacterSet.m
+++ src/OFBitSetCharacterSet.m
@@ -38,18 +38,19 @@
size_t length = string.length;
for (size_t i = 0; i < length; i++) {
of_unichar_t c = characters[i];
- if (c / 8 >= _size) {
+ if (c / CHAR_BIT >= _size) {
size_t newSize;
if (UINT32_MAX - c < 1)
@throw [OFOutOfRangeException
exception];
- newSize = OF_ROUND_UP_POW2(8, c + 1) / 8;
+ newSize = OF_ROUND_UP_POW2(CHAR_BIT, c + 1) /
+ CHAR_BIT;
_bitset = of_realloc(_bitset, newSize, 1);
memset(_bitset + _size, '\0', newSize - _size);
_size = newSize;
@@ -74,11 +75,11 @@
[super dealloc];
}
- (bool)characterIsMember: (of_unichar_t)character
{
- if (character / 8 >= _size)
+ if (character / CHAR_BIT >= _size)
return false;
return of_bitset_isset(_bitset, character);
}
@end
Index: src/OFBytesValue.m
==================================================================
--- src/OFBytesValue.m
+++ src/OFBytesValue.m
@@ -29,11 +29,11 @@
self = [super init];
@try {
_size = of_sizeof_type_encoding(objCType);
_objCType = objCType;
- _bytes = of_malloc(1, _size);
+ _bytes = of_alloc(1, _size);
memcpy(_bytes, bytes, _size);
} @catch (id e) {
[self release];
@throw e;
Index: src/OFConstantString.m
==================================================================
--- src/OFConstantString.m
+++ src/OFConstantString.m
@@ -111,11 +111,11 @@
struct of_string_utf8_ivars *ivars;
if ([self isMemberOfClass: [OFConstantUTF8String class]])
return;
- ivars = of_calloc(1, sizeof(*ivars));
+ ivars = of_alloc_zeroed(1, sizeof(*ivars));
ivars->cString = _cString;
ivars->cStringLength = _cStringLength;
switch (of_string_utf8_check(ivars->cString,
ivars->cStringLength, &ivars->length)) {
Index: src/OFDNSResolver.m
==================================================================
--- src/OFDNSResolver.m
+++ src/OFDNSResolver.m
@@ -1136,11 +1136,11 @@
context->_responseLength = 0;
return nil;
}
if (context->_TCPBuffer == nil)
- context->_TCPBuffer = of_malloc(MAX_DNS_RESPONSE_LENGTH, 1);
+ context->_TCPBuffer = of_alloc(MAX_DNS_RESPONSE_LENGTH, 1);
[sock asyncReadIntoBuffer: context->_TCPBuffer
exactLength: 2];
return nil;
}
Index: src/OFData.m
==================================================================
--- src/OFData.m
+++ src/OFData.m
@@ -130,11 +130,11 @@
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
- _items = of_malloc(count, itemSize);
+ _items = of_alloc(count, itemSize);
_count = count;
_itemSize = itemSize;
_freeWhenDone = true;
memcpy(_items, items, count * itemSize);
@@ -194,11 +194,11 @@
# if ULLONG_MAX > SIZE_MAX
if (size > SIZE_MAX)
@throw [OFOutOfRangeException exception];
# endif
- buffer = of_malloc((size_t)size, 1);
+ buffer = of_alloc((size_t)size, 1);
file = [[OFFile alloc] initWithPath: path
mode: @"r"];
@try {
[file readIntoBuffer: buffer
exactLength: (size_t)size];
@@ -246,11 +246,11 @@
_count = 0;
_itemSize = 1;
_freeWhenDone = true;
pageSize = [OFSystemInfo pageSize];
- buffer = of_malloc(1, pageSize);
+ buffer = of_alloc(1, pageSize);
@try {
while (!stream.atEndOfStream) {
size_t length = [stream
readIntoBuffer: buffer
@@ -289,11 +289,11 @@
if (count % 2 != 0)
@throw [OFInvalidFormatException exception];
count /= 2;
- _items = of_malloc(count, 1);
+ _items = of_alloc(count, 1);
_count = count;
_itemSize = 1;
_freeWhenDone = true;
cString = [string
Index: src/OFDate.m
==================================================================
--- src/OFDate.m
+++ src/OFDate.m
@@ -777,11 +777,11 @@
}
# endif
#endif
pageSize = [OFSystemInfo pageSize];
- buffer = of_malloc(1, pageSize);
+ buffer = of_alloc(1, pageSize);
@try {
#ifndef OF_WINDOWS
if (strftime(buffer, pageSize, format.UTF8String, &tm) == 0)
@throw [OFOutOfRangeException exception];
@@ -837,11 +837,11 @@
}
# endif
#endif
pageSize = [OFSystemInfo pageSize];
- buffer = of_malloc(1, pageSize);
+ buffer = of_alloc(1, pageSize);
@try {
#ifndef OF_WINDOWS
if (strftime(buffer, pageSize, format.UTF8String, &tm) == 0)
@throw [OFOutOfRangeException exception];
Index: src/OFFile.m
==================================================================
--- src/OFFile.m
+++ src/OFFile.m
@@ -241,11 +241,11 @@
@throw [OFOpenItemFailedException
exceptionWithPath: path
mode: mode
errNo: errno];
#else
- handle = of_malloc(1, sizeof(*handle));
+ handle = of_alloc(1, sizeof(*handle));
@try {
if ((flags = parseMode(mode.UTF8String,
&handle->append)) == -1)
@throw [OFInvalidArgumentException exception];
Index: src/OFFileManager.m
==================================================================
--- src/OFFileManager.m
+++ src/OFFileManager.m
@@ -663,11 +663,11 @@
size_t pageSize = [OFSystemInfo pageSize];
OFStream *sourceStream = nil;
OFStream *destinationStream = nil;
char *buffer;
- buffer = of_malloc(1, pageSize);
+ buffer = of_alloc(1, pageSize);
@try {
sourceStream = [[OFURLHandler handlerForURL: source]
openItemAtURL: source
mode: @"r"];
destinationStream = [[OFURLHandler handlerForURL:
Index: src/OFFileURLHandler.m
==================================================================
--- src/OFFileURLHandler.m
+++ src/OFFileURLHandler.m
@@ -735,16 +735,16 @@
modificationDate.timeIntervalSince1970;
struct timeval times[2] = {
{
.tv_sec = (time_t)lastAccessTime,
.tv_usec =
- (int)((lastAccessTime - times[0].tv_sec) * 1000)
+ (int)((lastAccessTime - times[0].tv_sec) * 1000000)
},
{
.tv_sec = (time_t)modificationTime,
- .tv_usec =
- (int)((modificationTime - times[1].tv_sec) * 1000)
+ .tv_usec = (int)((modificationTime - times[1].tv_sec) *
+ 1000000)
},
};
if (utimes([path cStringWithEncoding: [OFLocale encoding]], times) != 0)
@throw [OFSetItemAttributesFailedException
Index: src/OFHTTPClient.m
==================================================================
--- src/OFHTTPClient.m
+++ src/OFHTTPClient.m
@@ -513,11 +513,11 @@
lineC = line.UTF8String;
if ((tmp = strchr(lineC, ':')) == NULL)
@throw [OFInvalidServerReplyException exception];
- keyC = of_malloc(tmp - lineC + 1, 1);
+ keyC = of_alloc(tmp - lineC + 1, 1);
memcpy(keyC, lineC, tmp - lineC);
keyC[tmp - lineC] = '\0';
normalizeKey(keyC);
@try {
Index: src/OFInflateStream.m
==================================================================
--- src/OFInflateStream.m
+++ src/OFInflateStream.m
@@ -194,11 +194,11 @@
#ifdef OF_INFLATE64_STREAM_M
_slidingWindowMask = 0xFFFF;
#else
_slidingWindowMask = 0x7FFF;
#endif
- _slidingWindow = of_calloc(_slidingWindowMask + 1, 1);
+ _slidingWindow = of_alloc_zeroed(_slidingWindowMask + 1, 1);
} @catch (id e) {
[self release];
@throw e;
}
@@ -378,11 +378,11 @@
CTX.codeLenCodesCount = bits;
}
if OF_LIKELY (CTX.lengths == NULL)
- CTX.lengths = of_calloc(19, 1);
+ CTX.lengths = of_alloc_zeroed(19, 1);
for (uint16_t i = CTX.receivedCount;
i < CTX.codeLenCodesCount + 4; i++) {
if OF_UNLIKELY (!tryReadBits(self, &bits, 3)) {
CTX.receivedCount = i;
@@ -401,11 +401,11 @@
CTX.receivedCount = 0;
CTX.value = 0xFF;
}
if OF_LIKELY (CTX.lengths == NULL)
- CTX.lengths = of_malloc(
+ CTX.lengths = of_alloc(
CTX.litLenCodesCount + CTX.distCodesCount + 258, 1);
for (uint16_t i = CTX.receivedCount;
i < CTX.litLenCodesCount + CTX.distCodesCount + 258;) {
uint8_t j, count;
Index: src/OFKernelEventObserver.h
==================================================================
--- src/OFKernelEventObserver.h
+++ src/OFKernelEventObserver.h
@@ -122,15 +122,15 @@
OFMutableArray OF_GENERIC(id )
*_readObjects;
OFMutableArray OF_GENERIC(id )
*_writeObjects;
id _Nullable _delegate;
-#if defined(OF_HAVE_PIPE)
- int _cancelFD[2];
-#elif defined(OF_AMIGAOS)
+#if defined(OF_AMIGAOS)
struct Task *_waitingTask;
ULONG _cancelSignal;
+#elif defined(OF_HAVE_PIPE)
+ int _cancelFD[2];
#else
of_socket_t _cancelFD[2];
struct sockaddr_in _cancelAddr;
#endif
#ifdef OF_AMIGAOS
Index: src/OFKernelEventObserver.m
==================================================================
--- src/OFKernelEventObserver.m
+++ src/OFKernelEventObserver.m
@@ -113,11 +113,11 @@
#endif
_readObjects = [[OFMutableArray alloc] init];
_writeObjects = [[OFMutableArray alloc] init];
-#if defined(OF_HAVE_PIPE)
+#if defined(OF_HAVE_PIPE) && !defined(OF_AMIGAOS)
if (pipe(_cancelFD))
@throw [OFInitializationFailedException
exceptionWithClass: self.class];
#elif !defined(OF_AMIGAOS)
_cancelFD[0] = _cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0);
@@ -174,11 +174,11 @@
return self;
}
- (void)dealloc
{
-#if defined(OF_HAVE_PIPE)
+#if defined(OF_HAVE_PIPE) && !defined(OF_AMIGAOS)
close(_cancelFD[0]);
if (_cancelFD[1] != _cancelFD[0])
close(_cancelFD[1]);
#elif !defined(OF_AMIGAOS)
closesocket(_cancelFD[0]);
@@ -257,25 +257,25 @@
[self observeForTimeInterval: date.timeIntervalSinceNow];
}
- (void)cancel
{
-#if defined(OF_HAVE_PIPE)
- OF_ENSURE(write(_cancelFD[1], "", 1) > 0);
-#elif defined(OF_AMIGAOS)
+#if defined(OF_AMIGAOS)
Forbid();
if (_waitingTask != NULL) {
Signal(_waitingTask, (1ul << _cancelSignal));
_waitingTask = NULL;
}
Permit();
+#elif defined(OF_HAVE_PIPE)
+ OF_ENSURE(write(_cancelFD[1], "", 1) > 0);
#elif defined(OF_WII)
OF_ENSURE(sendto(_cancelFD[1], "", 1, 0,
(struct sockaddr *)&_cancelAddr, 8) > 0);
#else
OF_ENSURE(sendto(_cancelFD[1], (void *)"", 1, 0,
(struct sockaddr *)&_cancelAddr, sizeof(_cancelAddr)) > 0);
#endif
}
@end
Index: src/OFLHADecompressingStream.m
==================================================================
--- src/OFLHADecompressingStream.m
+++ src/OFLHADecompressingStream.m
@@ -108,11 +108,11 @@
_distanceBits = distanceBits;
_dictionaryBits = dictionaryBits;
_slidingWindowMask = (1u << dictionaryBits) - 1;
- _slidingWindow = of_malloc(_slidingWindowMask + 1, 1);
+ _slidingWindow = of_alloc(_slidingWindowMask + 1, 1);
memset(_slidingWindow, ' ', _slidingWindowMask + 1);
} @catch (id e) {
[self release];
@throw e;
}
@@ -175,11 +175,11 @@
goto start;
}
_codesCount = bits;
_codesReceived = 0;
- _codesLengths = of_calloc(bits, 1);
+ _codesLengths = of_alloc_zeroed(bits, 1);
_skip = true;
_state = STATE_CODE_LEN_TREE;
goto start;
case STATE_CODE_LEN_TREE:
@@ -256,11 +256,11 @@
goto start;
}
_codesCount = bits;
_codesReceived = 0;
- _codesLengths = of_calloc(bits, 1);
+ _codesLengths = of_alloc_zeroed(bits, 1);
_skip = false;
_treeIter = _codeLenTree;
_state = STATE_LITLEN_TREE;
goto start;
@@ -346,11 +346,11 @@
goto start;
}
_codesCount = bits;
_codesReceived = 0;
- _codesLengths = of_calloc(bits, 1);
+ _codesLengths = of_alloc_zeroed(bits, 1);
_treeIter = _codeLenTree;
_state = STATE_DIST_TREE;
goto start;
case STATE_DIST_TREE:
Index: src/OFList.m
==================================================================
--- src/OFList.m
+++ src/OFList.m
@@ -95,11 +95,11 @@
- (of_list_object_t *)appendObject: (id)object
{
of_list_object_t *listObject;
- listObject = of_malloc(1, sizeof(of_list_object_t));
+ listObject = of_alloc(1, sizeof(of_list_object_t));
listObject->object = [object retain];
listObject->next = NULL;
listObject->previous = _lastListObject;
if (_lastListObject != NULL)
@@ -118,11 +118,11 @@
- (of_list_object_t *)prependObject: (id)object
{
of_list_object_t *listObject;
- listObject = of_malloc(1, sizeof(of_list_object_t));
+ listObject = of_alloc(1, sizeof(of_list_object_t));
listObject->object = [object retain];
listObject->next = _firstListObject;
listObject->previous = NULL;
if (_firstListObject != NULL)
@@ -141,11 +141,11 @@
- (of_list_object_t *)insertObject: (id)object
beforeListObject: (of_list_object_t *)listObject
{
of_list_object_t *newListObject;
- newListObject = of_malloc(1, sizeof(of_list_object_t));
+ newListObject = of_alloc(1, sizeof(of_list_object_t));
newListObject->object = [object retain];
newListObject->next = listObject;
newListObject->previous = listObject->previous;
if (listObject->previous != NULL)
@@ -165,11 +165,11 @@
- (of_list_object_t *)insertObject: (id)object
afterListObject: (of_list_object_t *)listObject
{
of_list_object_t *newListObject;
- newListObject = of_malloc(1, sizeof(of_list_object_t));
+ newListObject = of_alloc(1, sizeof(of_list_object_t));
newListObject->object = [object retain];
newListObject->next = listObject->next;
newListObject->previous = listObject;
if (listObject->next != NULL)
@@ -299,11 +299,11 @@
previous = NULL;
@try {
for (of_list_object_t *iter = _firstListObject;
iter != NULL; iter = iter->next) {
- listObject = of_malloc(1, sizeof(of_list_object_t));
+ listObject = of_alloc(1, sizeof(of_list_object_t));
listObject->object = [iter->object retain];
listObject->next = NULL;
listObject->previous = previous;
if (copy->_firstListObject == NULL)
Index: src/OFMapTable.m
==================================================================
--- src/OFMapTable.m
+++ src/OFMapTable.m
@@ -161,11 +161,11 @@
_capacity *= 2;
if (_capacity < MIN_CAPACITY)
_capacity = MIN_CAPACITY;
- _buckets = of_calloc(_capacity, sizeof(*_buckets));
+ _buckets = of_alloc_zeroed(_capacity, sizeof(*_buckets));
if (of_hash_seed != 0)
_rotate = of_random16() & 31;
} @catch (id e) {
[self release];
@@ -323,11 +323,11 @@
* below the minimum capacity.
*/
if ((capacity < _capacity && count > _count) || capacity < MIN_CAPACITY)
return;
- buckets = of_calloc(capacity, sizeof(*buckets));
+ buckets = of_alloc_zeroed(capacity, sizeof(*buckets));
for (unsigned long i = 0; i < _capacity; i++) {
if (_buckets[i] != NULL && _buckets[i] != &deleted) {
unsigned long j, last;
@@ -412,11 +412,11 @@
}
if (i >= last)
@throw [OFOutOfRangeException exception];
- bucket = of_malloc(1, sizeof(*bucket));
+ bucket = of_alloc(1, sizeof(*bucket));
@try {
bucket->key = _keyFunctions.retain(key);
} @catch (id e) {
free(bucket);
Index: src/OFMapTableDictionary.m
==================================================================
--- src/OFMapTableDictionary.m
+++ src/OFMapTableDictionary.m
@@ -342,11 +342,11 @@
OFArray *ret;
id *keys;
size_t count;
count = _mapTable.count;
- keys = of_malloc(count, sizeof(*keys));
+ keys = of_alloc(count, sizeof(*keys));
@try {
void *pool = objc_autoreleasePoolPush();
OFMapTableEnumerator *enumerator;
void **keyPtr;
@@ -376,11 +376,11 @@
OFArray *ret;
id *objects;
size_t count;
count = _mapTable.count;
- objects = of_malloc(count, sizeof(*objects));
+ objects = of_alloc(count, sizeof(*objects));
@try {
void *pool = objc_autoreleasePoolPush();
OFMapTableEnumerator *enumerator;
void **objectPtr;
Index: src/OFMethodSignature.m
==================================================================
--- src/OFMethodSignature.m
+++ src/OFMethodSignature.m
@@ -595,11 +595,11 @@
length = strlen(types);
if (length == 0)
@throw [OFInvalidFormatException exception];
- _types = of_malloc(length + 1, 1);
+ _types = of_alloc(length + 1, 1);
memcpy(_types, types, length);
_typesPointers = [[OFMutableData alloc]
initWithItemSize: sizeof(char *)];
_offsets = [[OFMutableData alloc]
Index: src/OFMutableAdjacentArray.m
==================================================================
--- src/OFMutableAdjacentArray.m
+++ src/OFMutableAdjacentArray.m
@@ -241,11 +241,11 @@
if (range.length > SIZE_MAX - range.location ||
range.location >= count || range.length > count - range.location)
@throw [OFOutOfRangeException exception];
- copy = of_malloc(range.length, sizeof(*copy));
+ copy = of_alloc(range.length, sizeof(*copy));
memcpy(copy, objects + range.location, range.length * sizeof(id));
@try {
[_array removeItemsInRange: range];
_mutations++;
Index: src/OFMutableData.m
==================================================================
--- src/OFMutableData.m
+++ src/OFMutableData.m
@@ -92,11 +92,11 @@
@try {
if (itemSize == 0)
@throw [OFInvalidArgumentException exception];
- _items = of_malloc(capacity, itemSize);
+ _items = of_alloc(capacity, itemSize);
_itemSize = itemSize;
_capacity = capacity;
_freeWhenDone = true;
} @catch (id e) {
[self release];
Index: src/OFMutableSet.m
==================================================================
--- src/OFMutableSet.m
+++ src/OFMutableSet.m
@@ -170,11 +170,11 @@
{
void *pool = objc_autoreleasePoolPush();
size_t count = self.count;
id *cArray;
- cArray = of_malloc(count, sizeof(id));
+ cArray = of_alloc(count, sizeof(id));
@try {
size_t i;
i = 0;
for (id object in self) {
Index: src/OFMutableUTF8String.m
==================================================================
--- src/OFMutableUTF8String.m
+++ src/OFMutableUTF8String.m
@@ -99,11 +99,11 @@
return;
}
unicodeLen = self.length;
- unicodeString = of_malloc(unicodeLen, sizeof(of_unichar_t));
+ unicodeString = of_alloc(unicodeLen, sizeof(of_unichar_t));
i = j = 0;
newCStringLength = 0;
while (i < _s->cStringLength) {
@@ -153,11 +153,11 @@
i += cLen;
}
@try {
- newCString = of_malloc(newCStringLength + 1, 1);
+ newCString = of_alloc(newCStringLength + 1, 1);
} @catch (id e) {
free(unicodeString);
@throw e;
}
@@ -373,11 +373,11 @@
}
- (void)appendCharacters: (const of_unichar_t *)characters
length: (size_t)length
{
- char *tmp = of_malloc((length * 4) + 1, 1);
+ char *tmp = of_alloc((length * 4) + 1, 1);
@try {
size_t j = 0;
bool isUTF8 = false;
Index: src/OFObject+KeyValueCoding.m
==================================================================
--- src/OFObject+KeyValueCoding.m
+++ src/OFObject+KeyValueCoding.m
@@ -48,11 +48,11 @@
if ((keyLength = key.UTF8StringLength) < 1) {
objc_autoreleasePoolPop(pool);
return [self valueForUndefinedKey: key];
}
- name = of_malloc(keyLength + 3, 1);
+ name = of_alloc(keyLength + 3, 1);
@try {
memcpy(name, "is", 2);
memcpy(name + 2, key.UTF8String, keyLength);
name[keyLength + 2] = '\0';
@@ -160,11 +160,11 @@
[self setValue: value
forUndefinedKey: key];
return;
}
- name = of_malloc(keyLength + 5, 1);
+ name = of_alloc(keyLength + 5, 1);
@try {
memcpy(name, "set", 3);
memcpy(name + 3, key.UTF8String, keyLength);
memcpy(name + keyLength + 3, ":", 2);
Index: src/OFObject.h
==================================================================
--- src/OFObject.h
+++ src/OFObject.h
@@ -1237,11 +1237,12 @@
#ifdef __cplusplus
extern "C" {
#endif
/**
- * @brief Allocates memory for the specified number of items.
+ * @brief Allocates memory for the specified number of items of the specified
+ * size.
*
* To free the allocated memory, use `free()`.
*
* Throws @ref OFOutOfMemoryException if allocating failed and
* @ref OFOutOfRangeException if the requested size exceeds the address space.
@@ -1249,16 +1250,16 @@
* @param count The number of items to allocate
* @param size The size of each item to allocate
* @return A pointer to the allocated memory. May return NULL if the specified
* size or count is 0.
*/
-extern void *_Nullable of_malloc(size_t count, size_t size)
+extern void *_Nullable of_alloc(size_t count, size_t size)
OF_WARN_UNUSED_RESULT;
/**
- * @brief Allocates memory for the specified number of items and initializes it
- * with zeros.
+ * @brief Allocates memory for the specified number of items of the specified
+ * size and initializes it with zeros.
*
* To free the allocated memory, use `free()`.
*
* Throws @ref OFOutOfMemoryException if allocating failed and
* @ref OFOutOfRangeException if the requested size exceeds the address space.
@@ -1266,15 +1267,15 @@
* @param size The size of each item to allocate
* @param count The number of items to allocate
* @return A pointer to the allocated memory. May return NULL if the specified
* size or count is 0.
*/
-extern void *_Nullable of_calloc(size_t count, size_t size)
+extern void *_Nullable of_alloc_zeroed(size_t count, size_t size)
OF_WARN_UNUSED_RESULT;
/**
- * @brief Resizes memory to the specific number of items of the specified size.
+ * @brief Resizes memory to the specified number of items of the specified size.
*
* To free the allocated memory, use `free()`.
*
* If the pointer is NULL, this is equivalent to allocating memory.
* If the size or number of items is 0, this is equivalent to freeing memory.
Index: src/OFObject.m
==================================================================
--- src/OFObject.m
+++ src/OFObject.m
@@ -97,11 +97,11 @@
} allocFailedException;
uint32_t of_hash_seed;
void *
-of_malloc(size_t count, size_t size)
+of_alloc(size_t count, size_t size)
{
void *pointer;
if OF_UNLIKELY (count == 0 || size == 0)
return NULL;
@@ -115,11 +115,11 @@
return pointer;
}
void *
-of_calloc(size_t count, size_t size)
+of_alloc_zeroed(size_t count, size_t size)
{
void *pointer;
if OF_UNLIKELY (count == 0 || size == 0)
return NULL;
Index: src/OFOptionsParser.m
==================================================================
--- src/OFOptionsParser.m
+++ src/OFOptionsParser.m
@@ -84,11 +84,11 @@
*iter->argumentPtr = nil;
count++;
}
- _options = of_malloc(count + 1, sizeof(*_options));
+ _options = of_alloc(count + 1, sizeof(*_options));
_longOptions = [[OFMapTable alloc]
initWithKeyFunctions: keyFunctions
objectFunctions: objectFunctions];
for (iter = options, iter2 = _options;
Index: src/OFPollKernelEventObserver.m
==================================================================
--- src/OFPollKernelEventObserver.m
+++ src/OFPollKernelEventObserver.m
@@ -50,11 +50,11 @@
_FDs = [[OFMutableData alloc] initWithItemSize:
sizeof(struct pollfd)];
[_FDs addItem: &p];
_maxFD = _cancelFD[0];
- _FDToObject = of_malloc((size_t)_maxFD + 1, sizeof(id));
+ _FDToObject = of_alloc((size_t)_maxFD + 1, sizeof(id));
} @catch (id e) {
[self release];
@throw e;
}
Index: src/OFSecureData.m
==================================================================
--- src/OFSecureData.m
+++ src/OFSecureData.m
@@ -99,11 +99,12 @@
static struct page *
addPage(bool allowPreallocated)
{
size_t pageSize = [OFSystemInfo pageSize];
- size_t mapSize = OF_ROUND_UP_POW2(8, pageSize / CHUNK_SIZE) / 8;
+ size_t mapSize = OF_ROUND_UP_POW2(CHAR_BIT, pageSize / CHUNK_SIZE) /
+ CHAR_BIT;
struct page *page;
# if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
struct page *lastPage;
# endif
@@ -138,13 +139,13 @@
return page;
}
}
- page = of_malloc(1, sizeof(*page));
+ page = of_alloc(1, sizeof(*page));
@try {
- page->map = of_calloc(1, mapSize);
+ page->map = of_alloc_zeroed(1, mapSize);
} @catch (id e) {
free(page);
@throw e;
}
@try {
@@ -184,11 +185,12 @@
static void
removePageIfEmpty(struct page *page)
{
unsigned char *map = page->map;
size_t pageSize = [OFSystemInfo pageSize];
- size_t mapSize = OF_ROUND_UP_POW2(8, pageSize / CHUNK_SIZE) / 8;
+ size_t mapSize = OF_ROUND_UP_POW2(CHAR_BIT, pageSize / CHUNK_SIZE) /
+ CHAR_BIT;
for (size_t i = 0; i < mapSize; i++)
if (map[i] != 0)
return;
@@ -292,11 +294,11 @@
size_t i;
if (preallocatedPages != NULL)
@throw [OFInvalidArgumentException exception];
- preallocatedPages = of_calloc(numPages, sizeof(struct page));
+ preallocatedPages = of_alloc_zeroed(numPages, sizeof(struct page));
# if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
of_tlskey_set(preallocatedPagesKey, preallocatedPages);
# endif
@try {
@@ -413,11 +415,11 @@
if (count > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exception];
if (allowsSwappableMemory) {
- _items = of_malloc(count, itemSize);
+ _items = of_alloc(count, itemSize);
_freeWhenDone = true;
memset(_items, 0, count * itemSize);
#if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON)
} else if (count * itemSize >= pageSize)
_items = mapPages(OF_ROUND_UP_POW2(pageSize,
Index: src/OFSelectKernelEventObserver.m
==================================================================
--- src/OFSelectKernelEventObserver.m
+++ src/OFSelectKernelEventObserver.m
@@ -48,21 +48,22 @@
- (instancetype)init
{
self = [super init];
@try {
+ FD_ZERO(&_readFDs);
+ FD_ZERO(&_writeFDs);
+
#ifdef OF_AMIGAOS
_maxFD = 0;
#else
# ifndef OF_WINDOWS
if (_cancelFD[0] >= (int)FD_SETSIZE)
@throw [OFInitializationFailedException
exceptionWithClass: self.class];
# endif
- FD_ZERO(&_readFDs);
- FD_ZERO(&_writeFDs);
FD_SET(_cancelFD[0], &_readFDs);
if (_cancelFD[0] > INT_MAX)
@throw [OFOutOfRangeException exception];
@@ -170,11 +171,12 @@
fd_set readFDs;
fd_set writeFDs;
struct timeval timeout;
int events;
#ifdef OF_AMIGAOS
- ULONG execSignalMask, cancelSignal;
+ BYTE cancelSignal;
+ ULONG execSignalMask;
#endif
void *pool;
if ([self of_processReadBuffers])
return;
@@ -196,14 +198,14 @@
#ifndef OF_WINDOWS
timeout.tv_sec = (time_t)timeInterval;
#else
timeout.tv_sec = (long)timeInterval;
#endif
- timeout.tv_usec = (int)((timeInterval - timeout.tv_sec) * 1000);
+ timeout.tv_usec = (int)((timeInterval - timeout.tv_sec) * 1000000);
#ifdef OF_AMIGAOS
- if ((cancelSignal = AllocSignal(-1)) == (ULONG)-1)
+ if ((cancelSignal = AllocSignal(-1)) == (BYTE)-1)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EAGAIN];
execSignalMask = _execSignalMask | (1ul << cancelSignal);
Index: src/OFStream.m
==================================================================
--- src/OFStream.m
+++ src/OFStream.m
@@ -149,11 +149,11 @@
length: MIN_READ_SIZE];
if (bytesRead > length) {
memcpy(buffer, tmp, length);
- readBuffer = of_malloc(bytesRead - length, 1);
+ readBuffer = of_alloc(bytesRead - length, 1);
memcpy(readBuffer, tmp + length,
bytesRead - length);
_readBuffer = _readBufferMemory = readBuffer;
_readBufferLength = bytesRead - length;
@@ -641,11 +641,11 @@
char *buffer;
if OF_UNLIKELY (count > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exception];
- buffer = of_malloc(count, itemSize);
+ buffer = of_alloc(count, itemSize);
@try {
[self readIntoBuffer: buffer
exactLength: count * itemSize];
ret = [OFData dataWithItemsNoCopy: buffer
@@ -662,11 +662,11 @@
- (OFData *)readDataUntilEndOfStream
{
OFMutableData *data = [OFMutableData data];
size_t pageSize = [OFSystemInfo pageSize];
- char *buffer = of_malloc(1, pageSize);
+ char *buffer = of_alloc(1, pageSize);
@try {
while (!self.atEndOfStream) {
size_t length;
@@ -692,11 +692,11 @@
- (OFString *)readStringWithLength: (size_t)length
encoding: (of_string_encoding_t)encoding
{
OFString *ret;
- char *buffer = of_malloc(length + 1, 1);
+ char *buffer = of_alloc(length + 1, 1);
buffer[length] = 0;
@try {
[self readIntoBuffer: buffer
exactLength: length];
@@ -739,11 +739,11 @@
}
}
/* Read and see if we got a newline or \0 */
pageSize = [OFSystemInfo pageSize];
- buffer = of_malloc(1, pageSize);
+ buffer = of_alloc(1, pageSize);
@try {
if ([self lowlevelIsAtEndOfStream]) {
size_t retLength;
@@ -775,11 +775,11 @@
/* Look if there's a newline or \0 */
for (size_t i = 0; i < bufferLength; i++) {
if OF_UNLIKELY (buffer[i] == '\n' ||
buffer[i] == '\0') {
size_t retLength = _readBufferLength + i;
- char *retCString = of_malloc(retLength, 1);
+ char *retCString = of_alloc(retLength, 1);
if (_readBuffer != NULL)
memcpy(retCString, _readBuffer,
_readBufferLength);
memcpy(retCString + _readBufferLength,
@@ -798,11 +798,11 @@
if (bufferLength > 0) {
/*
* Append data to _readBuffer
* to prevent loss of data.
*/
- readBuffer = of_malloc(
+ readBuffer = of_alloc(
_readBufferLength +
bufferLength, 1);
memcpy(readBuffer, _readBuffer,
_readBufferLength);
@@ -820,11 +820,11 @@
@throw e;
} @finally {
free(retCString);
}
- readBuffer = of_malloc(bufferLength - i - 1, 1);
+ readBuffer = of_alloc(bufferLength - i - 1, 1);
if (readBuffer != NULL)
memcpy(readBuffer, buffer + i + 1,
bufferLength - i - 1);
free(_readBufferMemory);
@@ -836,11 +836,11 @@
}
}
/* There was no newline or \0 */
if (bufferLength > 0) {
- readBuffer = of_malloc(_readBufferLength + bufferLength,
+ readBuffer = of_alloc(_readBufferLength + bufferLength,
1);
memcpy(readBuffer, _readBuffer, _readBufferLength);
memcpy(readBuffer + _readBufferLength,
buffer, bufferLength);
@@ -977,11 +977,11 @@
}
}
/* Read and see if we got a delimiter or \0 */
pageSize = [OFSystemInfo pageSize];
- buffer = of_malloc(1, pageSize);
+ buffer = of_alloc(1, pageSize);
@try {
if ([self lowlevelIsAtEndOfStream]) {
if (_readBuffer == NULL) {
_waitingForDelimiter = false;
@@ -1015,11 +1015,11 @@
if (buffer[i] == '\0')
delimiterLength = 1;
retLength = _readBufferLength + i + 1 -
delimiterLength;
- retCString = of_malloc(retLength, 1);
+ retCString = of_alloc(retLength, 1);
if (_readBuffer != NULL &&
_readBufferLength <= retLength)
memcpy(retCString, _readBuffer,
_readBufferLength);
@@ -1039,11 +1039,11 @@
if (bufferLength > 0) {
/*
* Append data to _readBuffer
* to prevent loss of data.
*/
- readBuffer = of_malloc(
+ readBuffer = of_alloc(
_readBufferLength +
bufferLength, 1);
memcpy(readBuffer, _readBuffer,
_readBufferLength);
@@ -1061,11 +1061,11 @@
@throw e;
} @finally {
free(retCString);
}
- readBuffer = of_malloc(bufferLength - i - 1, 1);
+ readBuffer = of_alloc(bufferLength - i - 1, 1);
if (readBuffer != NULL)
memcpy(readBuffer, buffer + i + 1,
bufferLength - i - 1);
free(_readBufferMemory);
@@ -1077,11 +1077,11 @@
}
}
/* Neither the delimiter nor \0 was found */
if (bufferLength > 0) {
- readBuffer = of_malloc(_readBufferLength + bufferLength,
+ readBuffer = of_alloc(_readBufferLength + bufferLength,
1);
memcpy(readBuffer, _readBuffer, _readBufferLength);
memcpy(readBuffer + _readBufferLength,
buffer, bufferLength);
@@ -1334,11 +1334,11 @@
#ifdef OF_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- uint16_t *tmp = of_malloc(count, sizeof(uint16_t));
+ uint16_t *tmp = of_alloc(count, sizeof(uint16_t));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP16(buffer[i]);
@@ -1364,11 +1364,11 @@
#ifdef OF_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- uint32_t *tmp = of_malloc(count, sizeof(uint32_t));
+ uint32_t *tmp = of_alloc(count, sizeof(uint32_t));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP32(buffer[i]);
@@ -1394,11 +1394,11 @@
#ifdef OF_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- uint64_t *tmp = of_malloc(count, sizeof(uint64_t));
+ uint64_t *tmp = of_alloc(count, sizeof(uint64_t));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP64(buffer[i]);
@@ -1424,11 +1424,11 @@
#ifdef OF_FLOAT_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- float *tmp = of_malloc(count, sizeof(float));
+ float *tmp = of_alloc(count, sizeof(float));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP_FLOAT(buffer[i]);
@@ -1454,11 +1454,11 @@
#ifdef OF_FLOAT_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- double *tmp = of_malloc(count, sizeof(double));
+ double *tmp = of_alloc(count, sizeof(double));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP_DOUBLE(buffer[i]);
@@ -1524,11 +1524,11 @@
#ifndef OF_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- uint16_t *tmp = of_malloc(count, sizeof(uint16_t));
+ uint16_t *tmp = of_alloc(count, sizeof(uint16_t));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP16(buffer[i]);
@@ -1554,11 +1554,11 @@
#ifndef OF_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- uint32_t *tmp = of_malloc(count, sizeof(uint32_t));
+ uint32_t *tmp = of_alloc(count, sizeof(uint32_t));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP32(buffer[i]);
@@ -1584,11 +1584,11 @@
#ifndef OF_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- uint64_t *tmp = of_malloc(count, sizeof(uint64_t));
+ uint64_t *tmp = of_alloc(count, sizeof(uint64_t));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP64(buffer[i]);
@@ -1614,11 +1614,11 @@
#ifndef OF_FLOAT_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- float *tmp = of_malloc(count, sizeof(float));
+ float *tmp = of_alloc(count, sizeof(float));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP_FLOAT(buffer[i]);
@@ -1644,11 +1644,11 @@
#ifndef OF_FLOAT_BIG_ENDIAN
[self writeBuffer: buffer
length: size];
#else
- double *tmp = of_malloc(count, sizeof(double));
+ double *tmp = of_alloc(count, sizeof(double));
@try {
for (size_t i = 0; i < count; i++)
tmp[i] = OF_BSWAP_DOUBLE(buffer[i]);
@@ -1717,11 +1717,11 @@
encoding: (of_string_encoding_t)encoding
{
size_t stringLength = [string cStringLengthWithEncoding: encoding];
char *buffer;
- buffer = of_malloc(stringLength + 1, 1);
+ buffer = of_alloc(stringLength + 1, 1);
@try {
memcpy(buffer, [string cStringWithEncoding: encoding],
stringLength);
buffer[stringLength] = '\n';
@@ -1872,11 +1872,11 @@
char *readBuffer;
if (length > SIZE_MAX - _readBufferLength)
@throw [OFOutOfRangeException exception];
- readBuffer = of_malloc(_readBufferLength + length, 1);
+ readBuffer = of_alloc(_readBufferLength + length, 1);
memcpy(readBuffer, buffer, length);
memcpy(readBuffer + length, _readBuffer, _readBufferLength);
free(_readBufferMemory);
_readBuffer = _readBufferMemory = readBuffer;
Index: src/OFString+JSONParsing.m
==================================================================
--- src/OFString+JSONParsing.m
+++ src/OFString+JSONParsing.m
@@ -146,11 +146,11 @@
char delimiter = **pointer;
if (++(*pointer) + 1 >= stop)
return nil;
- buffer = of_malloc(stop - *pointer, 1);
+ buffer = of_alloc(stop - *pointer, 1);
while (*pointer < stop) {
/* Parse escape codes */
if (**pointer == '\\') {
if (++(*pointer) >= stop) {
@@ -292,11 +292,11 @@
parseIdentifier(const char **pointer, const char *stop)
{
char *buffer;
size_t i = 0;
- buffer = of_malloc(stop - *pointer, 1);
+ buffer = of_alloc(stop - *pointer, 1);
while (*pointer < stop) {
if ((**pointer >= 'a' && **pointer <= 'z') ||
(**pointer >= 'A' && **pointer <= 'Z') ||
(**pointer >= '0' && **pointer <= '9') ||
Index: src/OFString+URLEncoding.m
==================================================================
--- src/OFString+URLEncoding.m
+++ src/OFString+URLEncoding.m
@@ -87,11 +87,11 @@
char *retCString;
char byte = 0;
int state = 0;
size_t i = 0;
- retCString = of_malloc(length + 1, 1);
+ retCString = of_alloc(length + 1, 1);
while (length--) {
char c = *string++;
switch (state) {
Index: src/OFString+XMLEscaping.m
==================================================================
--- src/OFString+XMLEscaping.m
+++ src/OFString+XMLEscaping.m
@@ -40,11 +40,11 @@
string = self.UTF8String;
length = self.UTF8StringLength;
j = 0;
retLength = length;
- retCString = of_malloc(retLength, 1);
+ retCString = of_alloc(retLength, 1);
for (size_t i = 0; i < length; i++) {
switch (string[i]) {
case '<':
append = "<";
Index: src/OFString.m
==================================================================
--- src/OFString.m
+++ src/OFString.m
@@ -1019,11 +1019,11 @@
* to use -[initWithUTF8StringNoCopy:length:freeWhenDone:].
*/
if (SIZE_MAX - (size_t)fileSize < 1)
@throw [OFOutOfRangeException exception];
- tmp = of_malloc((size_t)fileSize + 1, 1);
+ tmp = of_alloc((size_t)fileSize + 1, 1);
@try {
file = [[OFFile alloc] initWithPath: path
mode: @"r"];
[file readIntoBuffer: tmp
@@ -1380,11 +1380,11 @@
char *cString;
size_t cStringLength;
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:
- cString = of_malloc((length * 4) + 1, 1);
+ cString = of_alloc((length * 4) + 1, 1);
@try {
cStringLength = [self
of_getCString: cString
maxLength: (length * 4) + 1
@@ -1413,11 +1413,11 @@
case OF_STRING_ENCODING_CODEPAGE_850:
case OF_STRING_ENCODING_CODEPAGE_858:
case OF_STRING_ENCODING_MAC_ROMAN:
case OF_STRING_ENCODING_KOI8_R:
case OF_STRING_ENCODING_KOI8_U:
- cString = of_malloc(length + 1, 1);
+ cString = of_alloc(length + 1, 1);
@try {
cStringLength = [self of_getCString: cString
maxLength: length + 1
encoding: encoding
@@ -1867,11 +1867,11 @@
pool = objc_autoreleasePoolPush();
searchCharacters = string.characters;
- characters = of_malloc(range.length, sizeof(of_unichar_t));
+ characters = of_alloc(range.length, sizeof(of_unichar_t));
@try {
[self getCharacters: characters
inRange: range];
if (options & OF_STRING_SEARCH_BACKWARDS) {
@@ -1935,11 +1935,11 @@
return OF_NOT_FOUND;
if (range.length > SIZE_MAX / sizeof(of_unichar_t))
@throw [OFOutOfRangeException exception];
- characters = of_malloc(range.length, sizeof(of_unichar_t));
+ characters = of_alloc(range.length, sizeof(of_unichar_t));
@try {
[self getCharacters: characters
inRange: range];
if (options & OF_STRING_SEARCH_BACKWARDS) {
@@ -2178,11 +2178,11 @@
bool hasPrefix;
if ((prefixLength = prefix.length) > self.length)
return false;
- tmp = of_malloc(prefixLength, sizeof(of_unichar_t));
+ tmp = of_alloc(prefixLength, sizeof(of_unichar_t));
@try {
void *pool = objc_autoreleasePoolPush();
[self getCharacters: tmp
inRange: of_range(0, prefixLength)];
@@ -2208,11 +2208,11 @@
if ((suffixLength = suffix.length) > self.length)
return false;
length = self.length;
- tmp = of_malloc(suffixLength, sizeof(of_unichar_t));
+ tmp = of_alloc(suffixLength, sizeof(of_unichar_t));
@try {
void *pool = objc_autoreleasePoolPush();
[self getCharacters: tmp
inRange: of_range(length - suffixLength,
@@ -2501,11 +2501,11 @@
- (const of_unichar_t *)characters
{
size_t length = self.length;
of_unichar_t *buffer;
- buffer = of_malloc(length, sizeof(of_unichar_t));
+ buffer = of_alloc(length, sizeof(of_unichar_t));
@try {
[self getCharacters: buffer
inRange: of_range(0, length)];
return [[OFData dataWithItemsNoCopy: buffer
@@ -2531,11 +2531,11 @@
of_char16_t *buffer;
size_t j;
bool swap = (byteOrder != OF_BYTE_ORDER_NATIVE);
/* Allocate memory for the worst case */
- buffer = of_malloc((length + 1) * 2, sizeof(of_char16_t));
+ buffer = of_alloc((length + 1) * 2, sizeof(of_char16_t));
j = 0;
for (size_t i = 0; i < length; i++) {
of_unichar_t c = characters[i];
@@ -2603,11 +2603,11 @@
- (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
{
size_t length = self.length;
of_char32_t *buffer;
- buffer = of_malloc(length + 1, sizeof(of_char32_t));
+ buffer = of_alloc(length + 1, sizeof(of_char32_t));
@try {
[self getCharacters: buffer
inRange: of_range(0, length)];
buffer[length] = 0;
Index: src/OFUTF8String.m
==================================================================
--- src/OFUTF8String.m
+++ src/OFUTF8String.m
@@ -179,11 +179,11 @@
self = [super init];
@try {
_s = &_storage;
- _s->cString = of_calloc(1, 1);
+ _s->cString = of_alloc_zeroed(1, 1);
_s->freeWhenDone = true;
} @catch (id e) {
[self release];
@throw e;
}
@@ -245,11 +245,11 @@
cStringLength -= 3;
}
_s = &_storage;
- _s->cString = of_malloc(cStringLength + 1, 1);
+ _s->cString = of_alloc(cStringLength + 1, 1);
_s->cStringLength = cStringLength;
_s->freeWhenDone = true;
if (encoding == OF_STRING_ENCODING_UTF_8 ||
encoding == OF_STRING_ENCODING_ASCII) {
@@ -450,11 +450,11 @@
else
_s->isUTF8 = true;
_s->length = string.length;
- _s->cString = of_malloc(_s->cStringLength + 1, 1);
+ _s->cString = of_alloc(_s->cStringLength + 1, 1);
memcpy(_s->cString, string.UTF8String, _s->cStringLength + 1);
_s->freeWhenDone = true;
} @catch (id e) {
[self release];
@throw e;
@@ -471,11 +471,11 @@
@try {
size_t j;
_s = &_storage;
- _s->cString = of_malloc((length * 4) + 1, 1);
+ _s->cString = of_alloc((length * 4) + 1, 1);
_s->length = length;
_s->freeWhenDone = true;
j = 0;
for (size_t i = 0; i < length; i++) {
@@ -527,11 +527,11 @@
} else if (byteOrder != OF_BYTE_ORDER_NATIVE)
swap = true;
_s = &_storage;
- _s->cString = of_malloc((length * 4) + 1, 1);
+ _s->cString = of_alloc((length * 4) + 1, 1);
_s->length = length;
_s->freeWhenDone = true;
j = 0;
for (size_t i = 0; i < length; i++) {
@@ -612,11 +612,11 @@
} else if (byteOrder != OF_BYTE_ORDER_NATIVE)
swap = true;
_s = &_storage;
- _s->cString = of_malloc((length * 4) + 1, 1);
+ _s->cString = of_alloc((length * 4) + 1, 1);
_s->length = length;
_s->freeWhenDone = true;
j = 0;
for (size_t i = 0; i < length; i++) {
@@ -687,11 +687,11 @@
break;
case -1:
@throw [OFInvalidEncodingException exception];
}
- _s->cString = of_malloc(cStringLength + 1, 1);
+ _s->cString = of_alloc(cStringLength + 1, 1);
memcpy(_s->cString, tmp, cStringLength + 1);
_s->freeWhenDone = true;
} @finally {
free(tmp);
}
@@ -1153,11 +1153,11 @@
return array;
}
- (const of_unichar_t *)characters
{
- of_unichar_t *buffer = of_malloc(_s->length, sizeof(of_unichar_t));
+ of_unichar_t *buffer = of_alloc(_s->length, sizeof(of_unichar_t));
size_t i = 0, j = 0;
while (i < _s->cStringLength) {
of_unichar_t c;
ssize_t cLen;
@@ -1180,11 +1180,11 @@
freeWhenDone: true] items];
}
- (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
{
- of_char32_t *buffer = of_malloc(_s->length + 1, sizeof(of_char32_t));
+ of_char32_t *buffer = of_alloc(_s->length + 1, sizeof(of_char32_t));
size_t i = 0, j = 0;
while (i < _s->cStringLength) {
of_char32_t c;
ssize_t cLen;
Index: src/OFValue.m
==================================================================
--- src/OFValue.m
+++ src/OFValue.m
@@ -181,13 +181,13 @@
if (strcmp([object objCType], objCType) != 0)
return false;
size = of_sizeof_type_encoding(objCType);
- value = of_malloc(1, size);
+ value = of_alloc(1, size);
@try {
- otherValue = of_malloc(1, size);
+ otherValue = of_alloc(1, size);
} @catch (id e) {
free(value);
@throw e;
}
@@ -210,11 +210,11 @@
{
size_t size = of_sizeof_type_encoding(self.objCType);
unsigned char *value;
uint32_t hash;
- value = of_malloc(1, size);
+ value = of_alloc(1, size);
@try {
[self getValue: value
size: size];
OF_HASH_INIT(hash);
@@ -311,11 +311,11 @@
OFMutableString *ret =
[OFMutableString stringWithString: @" UINT32_MAX)
@throw [OFOutOfRangeException exception];
- UTF16 = of_malloc(length, sizeof(of_char16_t));
+ UTF16 = of_alloc(length, sizeof(of_char16_t));
@try {
DWORD UTF16Len;
OFMutableData *rest = nil;
size_t i = 0;
@@ -362,11 +362,11 @@
_incompleteUTF8SurrogateLen = 0;
i += toCopy;
}
- tmp = of_malloc(length * 2, sizeof(of_char16_t));
+ tmp = of_alloc(length * 2, sizeof(of_char16_t));
@try {
DWORD bytesWritten;
while (i < length) {
of_unichar_t c;
Index: src/OFWindowsRegistryKey.m
==================================================================
--- src/OFWindowsRegistryKey.m
+++ src/OFWindowsRegistryKey.m
@@ -359,12 +359,12 @@
void *pool = objc_autoreleasePoolPush();
OFData *data;
if ([OFSystemInfo isWindowsNT])
data = [OFData dataWithItems: string.UTF16String
- itemSize: sizeof(of_char16_t)
- count: string.UTF16StringLength + 1];
+ count: string.UTF16StringLength + 1
+ itemSize: sizeof(of_char16_t)];
else {
of_string_encoding_t encoding = [OFLocale encoding];
const char *cString = [string cStringWithEncoding: encoding];
size_t length = [string cStringLengthWithEncoding: encoding];
Index: src/OFXMLComment.m
==================================================================
--- src/OFXMLComment.m
+++ src/OFXMLComment.m
@@ -114,11 +114,11 @@
level: (unsigned int)level
{
OFString *ret;
if (indentation > 0 && level > 0) {
- char *whitespaces = of_malloc((level * indentation) + 1, 1);
+ char *whitespaces = of_alloc((level * indentation) + 1, 1);
memset(whitespaces, ' ', level * indentation);
whitespaces[level * indentation] = 0;
@try {
ret = [OFString stringWithFormat: @"%s",
Index: src/OFXMLElement.m
==================================================================
--- src/OFXMLElement.m
+++ src/OFXMLElement.m
@@ -460,11 +460,11 @@
else
defaultNS = _defaultNamespace;
i = 0;
length = _name.UTF8StringLength + 3 + (level * indentation);
- cString = of_malloc(length, 1);
+ cString = of_alloc(length, 1);
@try {
memset(cString + i, ' ', level * indentation);
i += level * indentation;
Index: src/OFXMLParser.m
==================================================================
--- src/OFXMLParser.m
+++ src/OFXMLParser.m
@@ -276,11 +276,11 @@
}
- (void)parseStream: (OFStream *)stream
{
size_t pageSize = [OFSystemInfo pageSize];
- char *buffer = of_malloc(1, pageSize);
+ char *buffer = of_alloc(1, pageSize);
@try {
while (!stream.atEndOfStream) {
size_t length = [stream readIntoBuffer: buffer
length: pageSize];
Index: src/OFXMLProcessingInstructions.m
==================================================================
--- src/OFXMLProcessingInstructions.m
+++ src/OFXMLProcessingInstructions.m
@@ -115,11 +115,11 @@
level: (unsigned int)level
{
OFString *ret;
if (indentation > 0 && level > 0) {
- char *whitespaces = of_malloc((level * indentation) + 1, 1);
+ char *whitespaces = of_alloc((level * indentation) + 1, 1);
memset(whitespaces, ' ', level * indentation);
whitespaces[level * indentation] = 0;
@try {
ret = [OFString stringWithFormat:
Index: src/forwarding/forwarding-powerpc-elf.S
==================================================================
--- src/forwarding/forwarding-powerpc-elf.S
+++ src/forwarding/forwarding-powerpc-elf.S
@@ -25,17 +25,19 @@
.section .text
of_forward:
stwu %r1, -112(%r1)
mflr %r0
stw %r0, 116(%r1)
+#ifdef OF_PIC
stw %r30, 104(%r1)
bl 0f
0:
mflr %r30
addis %r30, %r30, .Lbiased_got2-0b@ha
addi %r30, %r30, .Lbiased_got2-0b@l
+#endif
/* Save all arguments */
stw %r3, 8(%r1)
stw %r4, 12(%r1)
stw %r5, 16(%r1)
@@ -53,25 +55,44 @@
stfd %f5, 72(%r1)
stfd %f6, 80(%r1)
stfd %f7, 88(%r1)
stfd %f8, 96(%r1)
+#ifdef OF_PIC
bl object_getClass+0x8000@plt
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
bl class_respondsToSelector+0x8000@plt
+#else
+ bl object_getClass
+
+ lis %r4, sel_forwardingTargetForSelector_@ha
+ addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ bl class_respondsToSelector
+#endif
cmpwi %r3, 0
beq- 0f
lwz %r3, 8(%r1)
+#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
bl objc_msg_lookup+0x8000@plt
+#else
+ lis %r4, sel_forwardingTargetForSelector_@ha
+ addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ bl objc_msg_lookup
+#endif
mtctr %r3
lwz %r3, 8(%r1)
+#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
+#else
+ lis %r4, sel_forwardingTargetForSelector_@ha
+ addi %r4, %r4, sel_forwardingTargetForSelector_@l
+#endif
lwz %r5, 12(%r1)
bctrl
cmpwi %r3, 0
beq- 0f
@@ -80,11 +101,15 @@
beq- 0f
stw %r3, 8(%r1)
lwz %r4, 12(%r1)
+#ifdef OF_PIC
bl objc_msg_lookup+0x8000@plt
+#else
+ bl objc_msg_lookup
+#endif
mtctr %r3
/* Restore all arguments */
lwz %r3, 8(%r1)
lwz %r4, 12(%r1)
@@ -103,42 +128,53 @@
lfd %f5, 72(%r1)
lfd %f6, 80(%r1)
lfd %f7, 88(%r1)
lfd %f8, 96(%r1)
+#ifdef OF_PIC
lwz %r30, 104(%r1)
+#endif
lwz %r0, 116(%r1)
mtlr %r0
addi %r1, %r1, 112
bctr
0:
lwz %r3, 8(%r1)
lwz %r4, 12(%r1)
+
+#ifdef OF_PIC
lwz %r0, .Lgot_of_method_not_found-.Lbiased_got2(%r30)
mtctr %r0
-
lwz %r30, 104(%r1)
+#endif
+
lwz %r0, 116(%r1)
mtlr %r0
addi %r1, %r1, 112
+#ifdef OF_PIC
bctr
+#else
+ b of_method_not_found
+#endif
.type of_forward, @function
.size of_forward, .-of_forward
of_forward_stret:
stwu %r1, -112(%r1)
mflr %r0
stw %r0, 116(%r1)
+#ifdef OF_PIC
stw %r30, 104(%r1)
bl 0f
0:
mflr %r30
addis %r30, %r30, .Lbiased_got2-0b@ha
addi %r30, %r30, .Lbiased_got2-0b@l
+#endif
/* Save all arguments */
stw %r3, 8(%r1)
stw %r4, 12(%r1)
stw %r5, 16(%r1)
@@ -157,25 +193,44 @@
stfd %f6, 80(%r1)
stfd %f7, 88(%r1)
stfd %f8, 96(%r1)
mr %r3, %r4
+#ifdef OF_PIC
bl object_getClass+0x800@plt
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
bl class_respondsToSelector+0x8000@plt
+#else
+ bl object_getClass
+
+ lis %r4, sel_forwardingTargetForSelector_@ha
+ addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ bl class_respondsToSelector
+#endif
cmpwi %r3, 0
beq- 0f
lwz %r3, 12(%r1)
+#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
bl objc_msg_lookup+0x8000@plt
+#else
+ lis %r4, sel_forwardingTargetForSelector_@ha
+ addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ bl objc_msg_lookup
+#endif
mtctr %r3
lwz %r3, 12(%r1)
+#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
+#else
+ lis %r4, sel_forwardingTargetForSelector_@ha
+ addi %r4, %r4, sel_forwardingTargetForSelector_@l
+#endif
lwz %r5, 16(%r1)
bctrl
cmpwi %r3, 0
beq- 0f
@@ -184,11 +239,15 @@
beq- 0f
stw %r3, 12(%r1)
lwz %r4, 16(%r1)
+#ifdef OF_PIC
bl objc_msg_lookup_stret+0x8000@plt
+#else
+ bl objc_msg_lookup_stret
+#endif
mtctr %r3
/* Restore all arguments */
lwz %r3, 8(%r1)
lwz %r4, 12(%r1)
@@ -207,35 +266,46 @@
lfd %f5, 72(%r1)
lfd %f6, 80(%r1)
lfd %f7, 88(%r1)
lfd %f8, 96(%r1)
+#ifdef OF_PIC
+ lwz %r30, 104(%r1)
+#endif
lwz %r0, 116(%r1)
mtlr %r0
addi %r1, %r1, 112
bctr
0:
lwz %r3, 8(%r1)
lwz %r4, 12(%r1)
lwz %r5, 16(%r1)
+
+#ifdef OF_PIC
lwz %r0, .Lgot_of_method_not_found_stret-.Lbiased_got2(%r30)
mtctr %r0
-
lwz %r30, 104(%r1)
+#endif
+
lwz %r0, 116(%r1)
mtlr %r0
addi %r1, %r1, 112
+#ifdef OF_PIC
bctr
+#else
+ b of_method_not_found_stret
+#endif
.type of_forward_stret, @function
.size of_forward_stret, .-of_forward_stret
init:
stwu %r1, -16(%r1)
mflr %r0
stw %r0, 20(%r1)
+#ifdef OF_PIC
stw %r30, 8(%r1)
bl 0f
0:
mflr %r30
@@ -244,10 +314,16 @@
lwz %r3, .Lgot_module-.Lbiased_got2(%r30)
bl __objc_exec_class+0x8000@plt
lwz %r30, 8(%r1)
+#else
+ lis %r3, module@ha
+ addi %r3, %r3, module@l
+ bl __objc_exec_class
+#endif
+
lwz %r0, 20(%r1)
addi %r1, %r1, 16
mtlr %r0
blr
@@ -268,10 +344,11 @@
.long 0
.long 0
module:
.long 8, 16, 0, symtab
+#ifdef OF_PIC
.section .got2, "aw"
.Lbiased_got2 = .+0x8000
.Lgot_module:
.long module
.Lgot_sel_forwardingTargetForSelector_:
@@ -278,9 +355,10 @@
.long sel_forwardingTargetForSelector_
.Lgot_of_method_not_found:
.long of_method_not_found
.Lgot_of_method_not_found_stret:
.long of_method_not_found_stret
+#endif
#ifdef OF_LINUX
.section .note.GNU-stack, "", @progbits
#endif
Index: src/huffman_tree.m
==================================================================
--- src/huffman_tree.m
+++ src/huffman_tree.m
@@ -28,11 +28,11 @@
static struct of_huffman_tree *
newTree(void)
{
struct of_huffman_tree *tree;
- tree = of_malloc(1, sizeof(*tree));
+ tree = of_alloc(1, sizeof(*tree));
tree->leaves[0] = tree->leaves[1] = NULL;
tree->value = 0xFFFF;
return tree;
}
Index: src/macros.h
==================================================================
--- src/macros.h
+++ src/macros.h
@@ -25,10 +25,11 @@
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
+#include
#include
#include
#include
#include
#include
@@ -822,23 +823,23 @@
}
static OF_INLINE bool
of_bitset_isset(unsigned char *_Nonnull storage, size_t idx)
{
- return storage[idx / 8] & (1u << (idx % 8));
+ return storage[idx / CHAR_BIT] & (1u << (idx % CHAR_BIT));
}
static OF_INLINE void
of_bitset_set(unsigned char *_Nonnull storage, size_t idx)
{
- storage[idx / 8] |= (1u << (idx % 8));
+ storage[idx / CHAR_BIT] |= (1u << (idx % CHAR_BIT));
}
static OF_INLINE void
of_bitset_clear(unsigned char *_Nonnull storage, size_t idx)
{
- storage[idx / 8] &= ~(1u << (idx % 8));
+ storage[idx / CHAR_BIT] &= ~(1u << (idx % CHAR_BIT));
}
static OF_INLINE char *_Nullable
of_strdup(const char *_Nonnull string)
{
Index: src/platform.h
==================================================================
--- src/platform.h
+++ src/platform.h
@@ -103,11 +103,12 @@
#if defined(__APPLE__)
# include
# if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
(defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR)
# define OF_IOS
-# else
+# endif
+# if defined(TARGET_OS_OSX) && TARGET_OS_OSX
# define OF_MACOS
# endif
#elif defined(__linux__)
# define OF_LINUX
#elif defined(_WIN32)
Index: src/platform/posix/OFProcess.m
==================================================================
--- src/platform/posix/OFProcess.m
+++ src/platform/posix/OFProcess.m
@@ -240,11 +240,11 @@
{
OFString *const *objects = arguments.objects;
size_t i, count = arguments.count;
of_string_encoding_t encoding;
- *argv = of_malloc(count + 2, sizeof(char *));
+ *argv = of_alloc(count + 2, sizeof(char *));
encoding = [OFLocale encoding];
(*argv)[0] = (char *)[programName cStringWithEncoding: encoding];
@@ -265,11 +265,11 @@
return NULL;
encoding = [OFLocale encoding];
count = environment.count;
- envp = of_calloc(count + 1, sizeof(char *));
+ envp = of_alloc_zeroed(count + 1, sizeof(char *));
@try {
OFEnumerator *keyEnumerator = [environment keyEnumerator];
OFEnumerator *objectEnumerator = [environment objectEnumerator];
@@ -283,11 +283,11 @@
keyLen = [key cStringLengthWithEncoding: encoding];
objectLen = [object
cStringLengthWithEncoding: encoding];
- envp[i] = of_malloc(keyLen + objectLen + 2, 1);
+ envp[i] = of_alloc(keyLen + objectLen + 2, 1);
memcpy(envp[i],
[key cStringWithEncoding: encoding], keyLen);
envp[i][keyLen] = '=';
memcpy(envp[i] + keyLen + 1,
Index: src/platform/windows/OFProcess.m
==================================================================
--- src/platform/windows/OFProcess.m
+++ src/platform/windows/OFProcess.m
@@ -193,11 +193,12 @@
si.hStdOutput = _readPipe[1];
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
si.dwFlags |= STARTF_USESTDHANDLES;
length = argumentsString.UTF16StringLength;
- argumentsCopy = of_malloc(length + 1, sizeof(of_char16_t));
+ argumentsCopy = of_alloc(length + 1,
+ sizeof(of_char16_t));
memcpy(argumentsCopy, argumentsString.UTF16String,
(length + 1) * 2);
@try {
if (!CreateProcessW(program.UTF16String,
argumentsCopy, NULL, NULL, TRUE,
Index: src/runtime/Makefile
==================================================================
--- src/runtime/Makefile
+++ src/runtime/Makefile
@@ -31,22 +31,22 @@
sparsearray.m \
static-instances.m \
synchronized.m \
tagged-pointer.m \
${USE_SRCS_THREADS}
-SRCS_THREADS = threading.m \
- ../mutex.m \
- ../once.m \
- ../tlskey.m
+SRCS_THREADS = mutex.m \
+ once.m \
+ threading.m \
+ tlskey.m
INCLUDES = ObjFWRT.h
includesubdir = ObjFWRT
-OBJS_EXTRA = ${LOOKUP_ASM_LOOKUP_ASM_A}
-LIB_OBJS_EXTRA = ${LOOKUP_ASM_LOOKUP_ASM_LIB_A}
+OBJS_EXTRA = lookup-asm/lookup-asm.a
+LIB_OBJS_EXTRA = lookup-asm/lookup-asm.lib.a
AMIGA_LIB_OBJS_START = amiga-library.amigalib.o
AMIGA_LIB_OBJS_EXTRA = amiga-glue.amigalib.o \
- ${LOOKUP_ASM_LOOKUP_ASM_A} \
+ lookup-asm/lookup-asm.amigalib.a \
amiga-end.amigalib.o
include ../../buildsys.mk
${OBJFWRT_AMIGA_LIB}: inline.h
Index: src/runtime/amiga-end.m
==================================================================
--- src/runtime/amiga-end.m
+++ src/runtime/amiga-end.m
@@ -19,13 +19,15 @@
#import "platform.h"
#ifdef OF_MORPHOS
__asm__ (
- ".section .ctors, \"aw\", @progbits\n"
+ ".section .eh_frame, \"aw\"\n"
" .long 0\n"
+ ".section .ctors, \"aw\"\n"
+ " .long 0"
);
#else
__asm__ (
""
);
#endif
Index: src/runtime/amiga-glue.m
==================================================================
--- src/runtime/amiga-glue.m
+++ src/runtime/amiga-glue.m
@@ -822,18 +822,10 @@
M68K_ARG(id, object, a0)
return object_isTaggedPointer(object);
}
-Class __saveds
-glue_object_getTaggedPointerClass PPC_PARAMS(id object)
-{
- M68K_ARG(id, object, a0)
-
- return object_getTaggedPointerClass(object);
-}
-
uintptr_t __saveds
glue_object_getTaggedPointerValue PPC_PARAMS(id object)
{
M68K_ARG(id, object, a0)
Index: src/runtime/amiga-library.m
==================================================================
--- src/runtime/amiga-library.m
+++ src/runtime/amiga-library.m
@@ -148,11 +148,10 @@
extern void glue_objc_hashtable_delete(void);
extern void glue_objc_hashtable_free(void);
extern void glue_objc_setTaggedPointerSecret(void);
extern int glue_objc_registerTaggedPointerClass(void);
extern bool glue_object_isTaggedPointer(void);
-extern Class glue_object_getTaggedPointerClass(void);
extern uintptr_t glue_object_getTaggedPointerValue(void);
extern id glue_objc_createTaggedPointer(void);
#ifdef OF_MORPHOS
const ULONG __abox__ = 1;
@@ -329,12 +328,13 @@
return &child->library;
}
static void *
-expunge(struct ObjFWRTBase *base)
+expunge(struct ObjFWRTBase *base, struct ExecBase *sysBase)
{
+#define SysBase sysBase
void *segList;
if (base->parent != NULL) {
base->parent->library.lib_Flags |= LIBF_DELEXP;
return 0;
@@ -350,23 +350,31 @@
Remove(&base->library.lib_Node);
FreeMem((char *)base - base->library.lib_NegSize,
base->library.lib_NegSize + base->library.lib_PosSize);
return segList;
+#undef SysBase
}
static void *__saveds
lib_expunge(void)
{
OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6)
- return expunge(base);
+ return expunge(base, SysBase);
}
static void *__saveds
lib_close(void)
{
+ /*
+ * SysBase becomes invalid during this function, so we store it in
+ * sysBase and add a define to make the inlines use the right one.
+ */
+ struct ExecBase *sysBase = SysBase;
+#define SysBase sysBase
+
OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6)
if (base->parent != NULL) {
struct ObjFWRTBase *parent;
@@ -386,13 +394,14 @@
base = parent;
}
if (--base->library.lib_OpenCnt == 0 &&
(base->library.lib_Flags & LIBF_DELEXP))
- return expunge(base);
+ return expunge(base, sysBase);
return NULL;
+#undef SysBase
}
static void *
lib_null(void)
{
@@ -406,10 +415,13 @@
#ifdef OF_AMIGAOS_M68K
OBJC_M68K_ARG(struct ObjFWRTBase *, base, a6)
#else
register struct ObjFWRTBase *r12 __asm__("r12");
struct ObjFWRTBase *base = r12;
+#endif
+#ifdef OF_MORPHOS
+ void *frame;
#endif
uintptr_t *iter, *iter0;
if (version > 1)
return false;
@@ -427,14 +439,18 @@
(&_EH_FRAME_OBJECTS__)[i]);
iter0 = &__CTOR_LIST__[1];
#elif defined(OF_MORPHOS)
__asm__ (
- "lis %0, ctors+4@ha\n\t"
- "la %0, ctors+4@l(%0)\n\t"
- : "=r"(iter0)
+ "lis %0, __EH_FRAME_BEGIN__@ha\n\t"
+ "la %0, __EH_FRAME_BEGIN__@l(%0)\n\t"
+ "lis %1, __CTOR_LIST__@ha\n\t"
+ "la %1, __CTOR_LIST__@l(%1)\n\t"
+ : "=r"(frame), "=r"(iter0)
);
+
+ libc.__register_frame(frame);
#endif
for (iter = iter0; *iter != 0; iter++);
while (iter > iter0) {
@@ -577,10 +593,16 @@
_Unwind_Resume(void *ex)
{
libc._Unwind_Resume(ex);
}
#endif
+
+int *
+objc_get_errno(void)
+{
+ return libc.get_errno();
+}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR functionTable[] = {
#ifdef OF_MORPHOS
@@ -680,11 +702,10 @@
(CONST_APTR)glue_objc_hashtable_delete,
(CONST_APTR)glue_objc_hashtable_free,
(CONST_APTR)glue_objc_setTaggedPointerSecret,
(CONST_APTR)glue_objc_registerTaggedPointerClass,
(CONST_APTR)glue_object_isTaggedPointer,
- (CONST_APTR)glue_object_getTaggedPointerClass,
(CONST_APTR)glue_object_getTaggedPointerValue,
(CONST_APTR)glue_objc_createTaggedPointer,
(CONST_APTR)-1,
#ifdef OF_MORPHOS
(CONST_APTR)FUNCARRAY_END
@@ -729,11 +750,16 @@
#endif
};
#ifdef OF_MORPHOS
__asm__ (
- ".section .ctors, \"aw\", @progbits\n"
- "ctors:\n"
- " .long -1\n"
+ ".section .eh_frame, \"aw\"\n"
+ ".globl __EH_FRAME_BEGIN__\n"
+ ".type __EH_FRAME_BEGIN__, @object\n"
+ "__EH_FRAME_BEGIN__:\n"
+ ".section .ctors, \"aw\"\n"
+ ".globl __CTOR_LIST__\n"
+ ".type __CTOR_LIST__, @object\n"
+ "__CTOR_LIST__:\n"
".section .text"
);
#endif
Index: src/runtime/amigaos3.sfd
==================================================================
--- src/runtime/amigaos3.sfd
+++ src/runtime/amigaos3.sfd
@@ -91,9 +91,8 @@
void glue_objc_hashtable_free(struct objc_hashtable *_Nonnull table)(a0)
* Public functions again
void glue_objc_setTaggedPointerSecret(uintptr_t secret)(d0)
int glue_objc_registerTaggedPointerClass(Class _Nonnull class_)(a0)
bool glue_object_isTaggedPointer(id _Nullable object)(a0)
-Class _Nullable glue_object_getTaggedPointerClass(id _Nonnull object)(a0)
uintptr_t glue_object_getTaggedPointerValue(id _Nonnull object)(a0)
id _Nullable glue_objc_createTaggedPointer(int class_, uintptr_t value)(d0,d1)
==end
Index: src/runtime/linklib/linklib.m
==================================================================
--- src/runtime/linklib/linklib.m
+++ src/runtime/linklib/linklib.m
@@ -25,10 +25,11 @@
struct ObjFWRTBase;
#import "inline.h"
+#include
#include
#include
#if defined(OF_AMIGAOS_M68K)
# include
@@ -55,15 +56,27 @@
#ifdef HAVE_SJLJ_EXCEPTIONS
extern void _Unwind_SjLj_Resume(void *);
#else
extern void _Unwind_Resume(void *);
#endif
+#ifdef OF_AMIGAOS_M68K
extern void __register_frame_info(const void *, void *);
extern void *__deregister_frame_info(const void *);
+#endif
+#ifdef OF_MORPHOS
+extern void __register_frame(void *);
+extern void __deregister_frame(void *);
+#endif
struct Library *ObjFWRTBase;
void *__objc_class_name_Protocol;
+
+static int *
+get_errno(void)
+{
+ return &errno;
+}
static void __attribute__((__used__))
ctor(void)
{
static bool initialized = false;
@@ -93,12 +106,19 @@
#ifdef HAVE_SJLJ_EXCEPTIONS
._Unwind_SjLj_Resume = _Unwind_SjLj_Resume,
#else
._Unwind_Resume = _Unwind_Resume,
#endif
+#ifdef OF_AMIGAOS_M68K
.__register_frame_info = __register_frame_info,
.__deregister_frame_info = __deregister_frame_info,
+#endif
+#ifdef OF_MORPHOS
+ .__register_frame = __register_frame,
+ .__deregister_frame = __deregister_frame,
+#endif
+ .get_errno = get_errno,
};
if (initialized)
return;
@@ -724,22 +744,16 @@
object_isTaggedPointer(id object)
{
return glue_object_isTaggedPointer(object);
}
-Class
-object_getTaggedPointerClass(id object)
-{
- return glue_object_getTaggedPointerClass(object);
-}
-
uintptr_t
object_getTaggedPointerValue(id object)
{
return glue_object_getTaggedPointerValue(object);
}
id
objc_createTaggedPointer(int class, uintptr_t value)
{
- return objc_createTaggedPointer(class, value);
+ return glue_objc_createTaggedPointer(class, value);
}
Index: src/runtime/lookup-asm/Makefile
==================================================================
--- src/runtime/lookup-asm/Makefile
+++ src/runtime/lookup-asm/Makefile
@@ -1,10 +1,12 @@
include ../../../extra.mk
STATIC_PIC_LIB_NOINST = ${LOOKUP_ASM_LIB_A}
+STATIC_AMIGA_LIB_NOINST = ${LOOKUP_ASM_AMIGALIB_A}
STATIC_LIB_NOINST = ${LOOKUP_ASM_A}
SRCS = lookup-asm.S
include ../../../buildsys.mk
ASFLAGS += -I../../.. -I../..
+ASFLAGS_lookup-asm.amigalib.o += -DOF_BASEREL
Index: src/runtime/lookup-asm/lookup-asm-powerpc-elf.S
==================================================================
--- src/runtime/lookup-asm/lookup-asm-powerpc-elf.S
+++ src/runtime/lookup-asm/lookup-asm-powerpc-elf.S
@@ -55,10 +55,11 @@
mr %r3, %r5
blr
0:
+#ifdef OF_PIC
stwu %r1, -16(%r1)
mflr %r0
stw %r0, 20(%r1)
stw %r30, 8(%r1)
@@ -75,12 +76,16 @@
lwz %r0, 20(%r1)
addi %r1, %r1, 16
mtlr %r0
bctr
+#else
+ b \not_found
+#endif
.Ltagged_pointer_\name:
+#if defined(OF_PIC)
mflr %r7
bl 0f
0:
mflr %r6
mtlr %r7
@@ -87,14 +92,29 @@
addis %r6, %r6, .Lbiased_got2-0b@ha
addi %r6, %r6, .Lbiased_got2-0b@l
lwz %r5, .Lgot_objc_tagged_pointer_secret-.Lbiased_got2(%r6)
lwz %r5, 0(%r5)
+#elif defined(OF_BASEREL)
+ addis %r5, %r13, objc_tagged_pointer_secret@drel@ha
+ lwz %r5, objc_tagged_pointer_secret@drel@l(%r5)
+#else
+ lis %r5, objc_tagged_pointer_secret@ha
+ lwz %r5, objc_tagged_pointer_secret@l(%r5)
+#endif
xor %r5, %r3, %r5
rlwinm %r5, %r5, 1, 0x1C
+#if defined(OF_PIC)
lwz %r6, .Lgot_objc_tagged_pointer_classes-.Lbiased_got2(%r6)
+#elif defined(OF_BASEREL)
+ addis %r6, %r13, objc_tagged_pointer_classes@drel@ha
+ addi %r6, %r6, objc_tagged_pointer_classes@drel@l
+#else
+ lis %r6, objc_tagged_pointer_classes@ha
+ addi %r6, %r6, objc_tagged_pointer_classes@l
+#endif
lwzx %r5, %r6, %r5
lwz %r5, 32(%r5)
b .Lmain_\name
.type \name, @function
@@ -135,10 +155,11 @@
get_pc:
mflr %r3
blr
+#ifdef OF_PIC
.section .got2, "aw"
.Lbiased_got2 = .+0x8000
.Lgot_objc_method_not_found:
.long objc_method_not_found
.Lgot_objc_method_not_found_stret:
@@ -145,9 +166,10 @@
.long objc_method_not_found_stret
.Lgot_objc_tagged_pointer_secret:
.long objc_tagged_pointer_secret
.Lgot_objc_tagged_pointer_classes:
.long objc_tagged_pointer_classes
+#endif
#ifdef OF_LINUX
.section .note.GNU-stack, "", @progbits
#endif
Index: src/runtime/morphos-clib.h
==================================================================
--- src/runtime/morphos-clib.h
+++ src/runtime/morphos-clib.h
@@ -86,8 +86,7 @@
void glue_objc_hashtable_free(struct objc_hashtable *);
/* Public functions again */
void glue_objc_setTaggedPointerSecret(uintptr_t);
int glue_objc_registerTaggedPointerClass(Class);
bool glue_object_isTaggedPointer(id);
-Class _Nullable glue_object_getTaggedPointerClass(id);
uintptr_t glue_object_getTaggedPointerValue(id);
id glue_objc_createTaggedPointer(int, uintptr_t);
Index: src/runtime/morphos.fd
==================================================================
--- src/runtime/morphos.fd
+++ src/runtime/morphos.fd
@@ -89,9 +89,8 @@
glue_objc_hashtable_free(table)(sysv,r12base)
* Public functions again
glue_objc_setTaggedPointerSecret(secret)(sysv,r12base)
glue_objc_registerTaggedPointerClass(class_)(sysv,r12base)
glue_object_isTaggedPointer(object)(sysv,r12base)
-glue_object_getTaggedPointerClass(object)(sysv,r12base)
glue_object_getTaggedPointerValue(object)(sysv,r12base)
glue_objc_createTaggedPointer(class_,value)(sysv,r12base)
##end
ADDED src/runtime/mutex.m
Index: src/runtime/mutex.m
==================================================================
--- src/runtime/mutex.m
+++ src/runtime/mutex.m
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "ObjFWRT.h"
+#import "private.h"
+
+#include "../mutex.m"
ADDED src/runtime/once.m
Index: src/runtime/once.m
==================================================================
--- src/runtime/once.m
+++ src/runtime/once.m
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "ObjFWRT.h"
+#import "private.h"
+
+#include "../once.m"
Index: src/runtime/private.h
==================================================================
--- src/runtime/private.h
+++ src/runtime/private.h
@@ -246,13 +246,20 @@
# ifdef HAVE_SJLJ_EXCEPTIONS
void (*_Nonnull _Unwind_SjLj_Resume)(void *_Nonnull);
# else
void (*_Nonnull _Unwind_Resume)(void *_Nonnull);
# endif
+# ifdef OF_AMIGAOS_M68K
void (*_Nonnull __register_frame_info)(const void *_Nonnull,
void *_Nonnull);
void *(*_Nonnull __deregister_frame_info)(const void *_Nonnull);
+# endif
+# ifdef OF_MORPHOS
+ void (*_Nonnull __register_frame)(void *_Nonnull);
+ void (*_Nonnull __deregister_frame)(void *_Nonnull);
+# endif
+ int *_Nonnull (*_Nonnull get_errno)(void);
};
#endif
#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# if defined(__MORPHOS__)
@@ -263,11 +270,14 @@
register type reg_##name __asm__(#reg); \
type name = reg_##name;
# endif
# undef stdout
# undef stderr
-extern FILE *stdout, *stderr;
+# undef errno
+extern FILE *_Nonnull stdout, *_Nonnull stderr;
+extern int *_Nonnull objc_get_errno(void);
+# define errno (*objc_get_errno())
#endif
extern void objc_register_all_categories(struct objc_symtab *_Nonnull);
extern struct objc_category *_Nullable *_Nullable
objc_categories_for_class(Class _Nonnull);
ADDED src/runtime/tlskey.m
Index: src/runtime/tlskey.m
==================================================================
--- src/runtime/tlskey.m
+++ src/runtime/tlskey.m
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "ObjFWRT.h"
+#import "private.h"
+
+#include "../tlskey.m"
Index: src/socket.m
==================================================================
--- src/socket.m
+++ src/socket.m
@@ -58,11 +58,13 @@
#if defined(OF_HAVE_THREADS) && !defined(OF_AMIGAOS)
static of_mutex_t mutex;
#endif
#if !defined(OF_AMIGAOS) || !defined(OF_HAVE_THREADS)
static bool initSuccessful = false;
-#else
+#endif
+
+#ifdef OF_AMIGAOS
# ifdef OF_HAVE_THREADS
of_tlskey_t of_socket_base_key;
# ifdef OF_AMIGAOS4
of_tlskey_t of_socket_interface_key;
# endif
Index: tests/OFDataTests.m
==================================================================
--- tests/OFDataTests.m
+++ tests/OFDataTests.m
@@ -34,12 +34,12 @@
of_range_t range;
TEST(@"+[dataWithItemSize:]",
(mutable = [OFMutableData dataWithItemSize: 4096]))
- raw[0] = of_malloc(1, 4096);
- raw[1] = of_malloc(1, 4096);
+ raw[0] = of_alloc(1, 4096);
+ raw[1] = of_alloc(1, 4096);
memset(raw[0], 0xFF, 4096);
memset(raw[1], 0x42, 4096);
TEST(@"-[addItem:]", R([mutable addItem: raw[0]]) &&
R([mutable addItem: raw[1]]))
Index: tests/OFStreamTests.m
==================================================================
--- tests/OFStreamTests.m
+++ tests/OFStreamTests.m
@@ -69,11 +69,11 @@
size_t pageSize = [OFSystemInfo pageSize];
StreamTester *t = [[[StreamTester alloc] init] autorelease];
OFString *str;
char *cstr;
- cstr = of_malloc(pageSize - 2, 1);
+ cstr = of_alloc(pageSize - 2, 1);
memset(cstr, 'X', pageSize - 3);
cstr[pageSize - 3] = '\0';
TEST(@"-[readLine]", [[t readLine] isEqual: @"foo"] &&
[(str = [t readLine]) length] == pageSize - 3 &&
Index: utils/ofhttp/OFHTTP.m
==================================================================
--- utils/ofhttp/OFHTTP.m
+++ utils/ofhttp/OFHTTP.m
@@ -302,11 +302,11 @@
forKey: @"User-Agent"];
_HTTPClient = [[OFHTTPClient alloc] init];
_HTTPClient.delegate = self;
- _buffer = of_malloc(1, [OFSystemInfo pageSize]);
+ _buffer = of_alloc(1, [OFSystemInfo pageSize]);
} @catch (id e) {
[self release];
@throw e;
}