ADDED .github/workflows/macos-12.yml Index: .github/workflows/macos-12.yml ================================================================== --- /dev/null +++ .github/workflows/macos-12.yml @@ -0,0 +1,31 @@ +name: macos-12 +on: [push, pull_request] +jobs: + tests: + runs-on: macos-12 + strategy: + matrix: + configure_flags: + - + - --disable-threads + - --disable-threads --disable-sockets + - --disable-threads --disable-files + - --disable-threads --disable-sockets --disable-files + - --disable-sockets + - --disable-sockets --disable-files + - --disable-files + - --disable-shared + steps: + - name: Install dependencies + run: brew install autoconf automake + - uses: actions/checkout@v4 + - name: autogen.sh + run: ./autogen.sh + - name: configure + run: ./configure ${{ matrix.configure_flags }} + - name: make + run: make -j$(sysctl -n hw.logicalcpu) + - name: make check + run: make check + - name: make install + run: sudo make install DELETED .github/workflows/macos-latest.yml Index: .github/workflows/macos-latest.yml ================================================================== --- .github/workflows/macos-latest.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: macos-latest -on: [push, pull_request] -jobs: - tests: - runs-on: macos-latest - strategy: - matrix: - configure_flags: - - - - --disable-threads - - --disable-threads --disable-sockets - - --disable-threads --disable-files - - --disable-threads --disable-sockets --disable-files - - --disable-sockets - - --disable-sockets --disable-files - - --disable-files - - --disable-shared - steps: - - name: Install dependencies - run: brew install autoconf automake - - uses: actions/checkout@v4 - - name: autogen.sh - run: ./autogen.sh - - name: configure - run: ./configure ${{ matrix.configure_flags }} - - name: make - run: make -j$(sysctl -n hw.logicalcpu) - - name: make check - run: make check - - name: make install - run: sudo make install Index: ChangeLog ================================================================== --- ChangeLog +++ ChangeLog @@ -2,10 +2,20 @@ * Changes of existing features or bugfixes + New features This file only contains the most significant changes. +ObjFW 1.1.2 -> ObjFW 1.1.3, 2024-05-12 + * Fixes +[OFSystemInfo networkInterfaces] on NetBSD. + * Properly hides private symbols so they can't be used accidentally anymore. + * Adds missing documentation for various functions and macros. + * Uses RtlGenRandom to get proper randomness on Windows now. + * No longer uses _wutime64, which is buggy in some MinGW distributions. + * Only uses blx on ARM if it is available now. + * Adds a workaround for OFSubprocess tests on Windows 9x. + * Skips symlink tests if symlinks are unavailable. + ObjFW 1.1.1 -> ObjFW 1.1.2, 2024-04-20 * Fixes configure script on systems using BusyBox for tr. * Fixes compiling for Haiku. * Fixes -[contentsOfDirectoryAtIRI:] corrupting the stack on Solaris. * Fixes compiling for Wii with newer SDK. Index: Doxyfile ================================================================== --- Doxyfile +++ Doxyfile @@ -48,5 +48,6 @@ SIGUSR1 \ SIGUSR2 MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES IGNORE_PREFIX = OF OF_ OT OT_ +EXTRACT_STATIC = yes Index: README.md ================================================================== --- README.md +++ README.md @@ -83,19 +83,21 @@ Operating System | Command ---------------------------|--------------------------------------------- Alpine Linux | `doas apk add objfw` CRUX | `sudo prt-get depinst objfw` + Debian | `sudo apt install objfw` Fedora | `sudo dnf install objfw` FreeBSD | `sudo pkg install objfw` Haiku | `pkgman install objfw` Haiku (gcc2h) | `pkgman install objfw_x86` macOS (Homebrew) | `brew install objfw` macOS (pkgsrc) | `cd $PKGSRCDIR/devel/objfw && make install` NetBSD | `cd /usr/pkgsrc/devel/objfw && make install` OpenBSD | `doas pkg_add objfw` OpenIndiana | `sudo pkg install developer/objfw` + Ubuntu | `sudo apt install objfw` Windows (MSYS2/CLANG64) | `pacman -S mingw-w64-clang-x86_64-objfw` Windows (MSYS2/CLANGARM64) | `pacman -S mingw-w64-clang-aarch64-objfw` Windows (MSYS2/UCRT64) | `pacman -S mingw-w64-ucrt-x86_64-objfw` Windows (MSYS2/MINGW32) | `pacman -S mingw-w64-i686-objfw` Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1,14 +1,13 @@ -AC_INIT(ObjFW, 1.2dev, js@nil.im, objfw, https://objfw.nil.im/) +AC_INIT(ObjFW, 1.1.3, js@nil.im, objfw, https://objfw.nil.im/) AC_CONFIG_SRCDIR(src) AC_CONFIG_AUX_DIR(build-aux) AC_CONFIG_MACRO_DIR(build-aux/m4) AC_DEFINE(OBJFW_VERSION_MAJOR, 1, [The major version of ObjFW]) -AC_DEFINE(OBJFW_VERSION_MINOR, 2, [The minor version of ObjFW]) -dnl This may only be set to 1.2 once 1.2 is released -AC_SUBST(BUNDLE_VERSION, 1.1.0) +AC_DEFINE(OBJFW_VERSION_MINOR, 1, [The minor version of ObjFW]) +AC_SUBST(BUNDLE_VERSION, 1.1.3) AC_SUBST(BUNDLE_SHORT_VERSION, 1.1) for i in configure.ac build-aux/m4/*; do AS_IF([test $i -nt configure], [ AC_MSG_ERROR([$i is newer than configure! Run ./autogen.sh!]) @@ -303,10 +302,11 @@ dnl Clang generates MIPS assembly not accepted by GNU as, dnl however, Clang's integrated assembler doesn't accept dnl everything used in ObjFW's assembly files. Therefore, use dnl the integrated assembler for ObjC files, but not for dnl assembly files. + ASFLAGS="$ASFLAGS -no-integrated-as" OBJCFLAGS="$OBJCFLAGS -integrated-as" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -integrated-as" ;; i?86-*-darwin* | x86_64-*-darwin*) dnl Don't use -no-integrated-as on Darwin. It breaks building @@ -839,10 +839,27 @@ AC_MSG_ERROR( [Floating point implementation does not conform to IEEE 754!])]) case "$host_cpu" in arm* | earm*) + AC_MSG_CHECKING(for blx) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([], [ + #if !defined(__arm64__) && !defined(__arch64__) && \ + !defined(__ARM64_ARCH_8__) + __asm__ __volatile__ ( + "blx r12" + ); + #endif + ]) + ], [ + AC_DEFINE(HAVE_BLX, 1, [Whether we have blx]) + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + ]) + AC_MSG_CHECKING(for VFP2 or above) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([], [ #if !defined(__arm64__) && !defined(__aarch64__) && \ !defined(__ARM64_ARCH_8__) @@ -2042,11 +2059,11 @@ AS_IF([test x"$GOBJC" = x"yes"], [ OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith" AC_ARG_ENABLE(werror, AS_HELP_STRING([--disable-werror], [do not build with -Werror])) - AS_IF([test x"$enable_werror" != x"no"], [ + AS_IF([test x"$enable_werror" = x"yes"], [ OBJCFLAGS="$OBJCFLAGS -Werror" ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Werror" Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -1,19 +1,19 @@ OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@ OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@ OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@ OBJFW_LIB_MAJOR = 1 OBJFW_LIB_MINOR = 1 -OBJFW_LIB_PATCH = 0 +OBJFW_LIB_PATCH = 2 OBJFW_LIB_MAJOR_MINOR = ${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR} OBJFWRT_SHARED_LIB = @OBJFWRT_SHARED_LIB@ OBJFWRT_STATIC_LIB = @OBJFWRT_STATIC_LIB@ OBJFWRT_FRAMEWORK = @OBJFWRT_FRAMEWORK@ OBJFWRT_LIB_MAJOR = 1 OBJFWRT_LIB_MINOR = 1 -OBJFWRT_LIB_PATCH = 0 +OBJFWRT_LIB_PATCH = 1 OBJFWRT_LIB_MAJOR_MINOR = ${OBJFWRT_LIB_MAJOR}.${OBJFWRT_LIB_MINOR} OBJFWBRIDGE_SHARED_LIB = @OBJFWBRIDGE_SHARED_LIB@ OBJFWBRIDGE_STATIC_LIB = @OBJFWBRIDGE_STATIC_LIB@ OBJFWBRIDGE_FRAMEWORK = @OBJFWBRIDGE_FRAMEWORK@ Index: generators/unicode/TableGenerator.m ================================================================== --- generators/unicode/TableGenerator.m +++ generators/unicode/TableGenerator.m @@ -210,11 +210,12 @@ mode: @"w"]; [file writeString: COPYRIGHT @"#include \"config.h\"\n" @"\n" - @"#import \"OFString.h\"\n\n" + @"#import \"unicode.h\"\n" + @"\n" @"static const OFUnichar emptyPage[0x100] = { 0 };\n" @"\n"]; /* Write uppercasePage%u */ for (OFUnichar i = 0; i < 0x110000; i += 0x100) { @@ -381,13 +382,13 @@ _uppercaseTableSize++; _lowercaseTableSize++; _titlecaseTableSize++; _caseFoldingTableSize++; - /* Write OFUnicodeUppercaseTable */ + /* Write _OFUnicodeUppercaseTable */ [file writeFormat: @"const OFUnichar *const " - @"OFUnicodeUppercaseTable[0x%X] = {\n\t", + @"_OFUnicodeUppercaseTable[0x%X] = {\n\t", _uppercaseTableSize]; for (OFUnichar i = 0; i < _uppercaseTableSize; i++) { if (_uppercaseTableUsed[i]) [file writeFormat: @"uppercasePage%u", i]; @@ -402,13 +403,13 @@ } } [file writeString: @"\n};\n\n"]; - /* Write OFUnicodeLowercaseTable */ + /* Write _OFUnicodeLowercaseTable */ [file writeFormat: @"const OFUnichar *const " - @"OFUnicodeLowercaseTable[0x%X] = {\n\t", + @"_OFUnicodeLowercaseTable[0x%X] = {\n\t", _lowercaseTableSize]; for (OFUnichar i = 0; i < _lowercaseTableSize; i++) { if (_lowercaseTableUsed[i]) [file writeFormat: @"lowercasePage%u", i]; @@ -423,13 +424,13 @@ } } [file writeString: @"\n};\n\n"]; - /* Write OFUnicodeTitlecaseTable */ + /* Write _OFUnicodeTitlecaseTable */ [file writeFormat: @"const OFUnichar *const " - @"OFUnicodeTitlecaseTable[0x%X] = {\n\t", + @"_OFUnicodeTitlecaseTable[0x%X] = {\n\t", _titlecaseTableSize]; for (OFUnichar i = 0; i < _titlecaseTableSize; i++) { if (_titlecaseTableUsed[i] == 1) [file writeFormat: @"titlecasePage%u", i]; @@ -446,13 +447,13 @@ } } [file writeString: @"\n};\n\n"]; - /* Write OFUnicodeCaseFoldingTable */ + /* Write _OFUnicodeCaseFoldingTable */ [file writeFormat: @"const OFUnichar *const " - @"OFUnicodeCaseFoldingTable[0x%X] = {\n\t", + @"_OFUnicodeCaseFoldingTable[0x%X] = {\n\t", _caseFoldingTableSize]; for (OFUnichar i = 0; i < _caseFoldingTableSize; i++) { if (_caseFoldingTableUsed[i] == 1) [file writeFormat: @"caseFoldingPage%u", i]; @@ -482,31 +483,35 @@ [file writeString: COPYRIGHT @"#import \"OFString.h\"\n\n"]; [file writeFormat: - @"#define OFUnicodeUppercaseTableSize 0x%X\n" - @"#define OFUnicodeLowercaseTableSize 0x%X\n" - @"#define OFUnicodeTitlecaseTableSize 0x%X\n" - @"#define OFUnicodeCaseFoldingTableSize 0x%X\n\n", + @"#define _OFUnicodeUppercaseTableSize 0x%X\n" + @"#define _OFUnicodeLowercaseTableSize 0x%X\n" + @"#define _OFUnicodeTitlecaseTableSize 0x%X\n" + @"#define _OFUnicodeCaseFoldingTableSize 0x%X\n\n", _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize, _caseFoldingTableSize]; [file writeString: @"#ifdef __cplusplus\n" @"extern \"C\" {\n" @"#endif\n" @"extern const OFUnichar *const _Nonnull\n" - @" OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize];\n" + @" _OFUnicodeUppercaseTable[_OFUnicodeUppercaseTableSize] " + @"OF_VISIBILITY_HIDDEN;\n" + @"extern const OFUnichar *const _Nonnull\n" + @" _OFUnicodeLowercaseTable[_OFUnicodeLowercaseTableSize] " + @"OF_VISIBILITY_HIDDEN;\n" @"extern const OFUnichar *const _Nonnull\n" - @" OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize];\n" + @" _OFUnicodeTitlecaseTable[_OFUnicodeTitlecaseTableSize] " + @"OF_VISIBILITY_HIDDEN;\n" @"extern const OFUnichar *const _Nonnull\n" - @" OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize];\n" - @"extern const OFUnichar *const _Nonnull\n" - @" OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize];\n" + @" _OFUnicodeCaseFoldingTable[_OFUnicodeCaseFoldingTableSize]\n" + @" OF_VISIBILITY_HIDDEN;\n" @"#ifdef __cplusplus\n" @"}\n" @"#endif\n"]; objc_autoreleasePoolPop(pool); } @end Index: src/OFASPrintF.h ================================================================== --- src/OFASPrintF.h +++ src/OFASPrintF.h @@ -31,12 +31,13 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int OFVASPrintF( - char *_Nullable *_Nonnull, const char *_Nonnull, va_list); +extern int _OFVASPrintF( + char *_Nullable *_Nonnull, const char *_Nonnull, va_list) + OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFASPrintF.m ================================================================== --- src/OFASPrintF.m +++ src/OFASPrintF.m @@ -421,11 +421,11 @@ ctx->subformat[ctx->subformatLen - 1] = 's'; { char buffer[5]; - size_t len = OFUTF8StringEncode( + size_t len = _OFUTF8StringEncode( va_arg(ctx->arguments, OFUnichar), buffer); if (len == 0) return false; @@ -452,11 +452,11 @@ if ((buffer = malloc((len * 4) + 1)) == NULL) return false; j = 0; for (size_t i = 0; i < len; i++) { - size_t clen = OFUTF8StringEncode(arg[i], + size_t clen = _OFUTF8StringEncode(arg[i], buffer + j); if (clen == 0) { free(buffer); return false; @@ -757,11 +757,11 @@ formatLengthModifierState, formatConversionSpecifierState }; int -OFVASPrintF(char **string, const char *format, va_list arguments) +_OFVASPrintF(char **string, const char *format, va_list arguments) { struct Context ctx; ctx.format = format; ctx.formatLen = strlen(format); Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -112,11 +112,11 @@ [[OFNotificationCenter defaultCenter] postNotification: notification]; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \ defined(OF_AMIGAOS) && !defined(OF_MORPHOS) - OFSocketDeinit(); + _OFSocketDeinit(); #endif } int OFApplicationMain(int *argc, char **argv[], id delegate) Index: src/OFArchiveIRIHandler.h ================================================================== --- src/OFArchiveIRIHandler.h +++ src/OFArchiveIRIHandler.h @@ -25,12 +25,12 @@ @end #ifdef __cplusplus extern "C" { #endif -extern OFIRI *OFArchiveIRIHandlerIRIForFileInArchive(OFString *, OFString *, - OFIRI *); +extern OFIRI *_OFArchiveIRIHandlerIRIForFileInArchive(OFString *, OFString *, + OFIRI *) OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFArchiveIRIHandler.m ================================================================== --- src/OFArchiveIRIHandler.m +++ src/OFArchiveIRIHandler.m @@ -193,11 +193,11 @@ @selector(characterIsMember:), character)); } @end OFIRI * -OFArchiveIRIHandlerIRIForFileInArchive(OFString *scheme, +_OFArchiveIRIHandlerIRIForFileInArchive(OFString *scheme, OFString *pathInArchive, OFIRI *archiveIRI) { static OFOnceControl onceControl = OFOnceControlInitValue; OFMutableIRI *ret = [OFMutableIRI IRIWithScheme: scheme]; void *pool = objc_autoreleasePoolPush(); Index: src/OFBase64.h ================================================================== --- src/OFBase64.h +++ src/OFBase64.h @@ -32,12 +32,13 @@ @class OFMutableData; #ifdef __cplusplus extern "C" { #endif -extern OFString *OFBase64Encode(const void *, size_t); -extern bool OFBase64Decode(OFMutableData *, const char *, size_t); +extern OFString *_OFBase64Encode(const void *, size_t) OF_VISIBILITY_HIDDEN; +extern bool _OFBase64Decode(OFMutableData *, const char *, size_t) + OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFBase64.m ================================================================== --- src/OFBase64.m +++ src/OFBase64.m @@ -41,11 +41,11 @@ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 }; OFString * -OFBase64Encode(const void *data, size_t length) +_OFBase64Encode(const void *data, size_t length) { OFMutableString *ret = [OFMutableString string]; uint8_t *buffer = (uint8_t *)data; size_t i; uint8_t rest; @@ -97,11 +97,11 @@ return ret; } bool -OFBase64Decode(OFMutableData *data, const char *string, size_t length) +_OFBase64Decode(OFMutableData *data, const char *string, size_t length) { const uint8_t *buffer = (const uint8_t *)string; size_t i; if ((length & 3) != 0) Index: src/OFCRC16.h ================================================================== --- src/OFCRC16.h +++ src/OFCRC16.h @@ -27,10 +27,10 @@ #import "macros.h" #ifdef __cplusplus extern "C" { #endif -extern uint16_t OFCRC16(uint16_t crc, const void *_Nonnull bytes, - size_t length); +extern uint16_t _OFCRC16(uint16_t crc, const void *_Nonnull bytes, + size_t length) OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif Index: src/OFCRC16.m ================================================================== --- src/OFCRC16.m +++ src/OFCRC16.m @@ -22,11 +22,11 @@ #import "OFCRC16.h" static const uint16_t CRC16Magic = 0xA001; uint16_t -OFCRC16(uint16_t CRC, const void *bytes_, size_t length) +_OFCRC16(uint16_t CRC, const void *bytes_, size_t length) { const unsigned char *bytes = bytes_; for (size_t i = 0; i < length; i++) { CRC ^= bytes[i]; Index: src/OFCRC32.h ================================================================== --- src/OFCRC32.h +++ src/OFCRC32.h @@ -27,10 +27,10 @@ #import "macros.h" #ifdef __cplusplus extern "C" { #endif -extern uint32_t OFCRC32(uint32_t crc, const void *_Nonnull bytes, - size_t length); +extern uint32_t _OFCRC32(uint32_t crc, const void *_Nonnull bytes, + size_t length) OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif Index: src/OFCRC32.m ================================================================== --- src/OFCRC32.m +++ src/OFCRC32.m @@ -22,11 +22,11 @@ #import "OFCRC32.h" static const uint32_t CRC32Magic = 0xEDB88320; uint32_t -OFCRC32(uint32_t CRC, const void *bytes_, size_t length) +_OFCRC32(uint32_t CRC, const void *bytes_, size_t length) { const unsigned char *bytes = bytes_; for (size_t i = 0; i < length; i++) { CRC ^= bytes[i]; Index: src/OFConcreteValue.m ================================================================== --- src/OFConcreteValue.m +++ src/OFConcreteValue.m @@ -29,11 +29,11 @@ { self = [super initWithBytes: bytes objCType: objCType]; @try { _size = OFSizeOfTypeEncoding(objCType); - _objCType = OFStrDup(objCType); + _objCType = _OFStrDup(objCType); _bytes = OFAllocMemory(1, _size); memcpy(_bytes, bytes, _size); } @catch (id e) { [self release]; @throw e; Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -95,11 +95,11 @@ ivars = OFAllocZeroedMemory(1, sizeof(*ivars)); ivars->cString = _cString; ivars->cStringLength = _cStringLength; - switch (OFUTF8StringCheck(ivars->cString, ivars->cStringLength, + switch (_OFUTF8StringCheck(ivars->cString, ivars->cStringLength, &ivars->length)) { case 1: ivars->isUTF8 = true; break; case -1: Index: src/OFDDPSocket.m ================================================================== --- src/OFDDPSocket.m +++ src/OFDDPSocket.m @@ -103,11 +103,11 @@ exceptionWithNetwork: network node: node port: port protocolType: protocolType socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -114,11 +114,11 @@ fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindDDPSocketFailedException @@ -132,13 +132,13 @@ memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyAppleTalk; address.length = (socklen_t)sizeof(address.sockaddr); - if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, + if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindDDPSocketFailedException @@ -171,11 +171,11 @@ exceptionWithNetwork: network node: node port: port protocolType: protocolType socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; OFSocketAddressSetAppleTalkNetwork(&address, config.address.s_net); OFSocketAddressSetAppleTalkNode(&address, config.address.s_node); #endif @@ -225,11 +225,11 @@ if ((ret = recvmsg(_socket, &msg, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; if (ret < 1 || protocolType != _protocolType) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: ENOMSG]; @@ -264,11 +264,11 @@ if ((bytesWritten = sendmsg(_socket, &msg, 0)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; if ((size_t)bytesWritten != length + 1) { bytesWritten--; if (bytesWritten < 0) Index: src/OFDNSResolver.m ================================================================== --- src/OFDNSResolver.m +++ src/OFDNSResolver.m @@ -622,11 +622,11 @@ + (void)initialize { if (self != [OFDNSResolver class]) return; - if (!OFSocketInit()) + if (!_OFSocketInit()) @throw [OFInitializationFailedException exceptionWithClass: self]; } #endif Index: src/OFData+CryptographicHashing.h ================================================================== --- src/OFData+CryptographicHashing.h +++ src/OFData+CryptographicHashing.h @@ -24,11 +24,11 @@ @class OFString; #ifdef __cplusplus extern "C" { #endif -extern int _OFData_CryptographicHashing_reference; +extern int _OFData_CryptographicHashing_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFData (CryptographicHashing) Index: src/OFData+MessagePackParsing.h ================================================================== --- src/OFData+MessagePackParsing.h +++ src/OFData+MessagePackParsing.h @@ -22,11 +22,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFData_MessagePackParsing_reference; +extern int _OFData_MessagePackParsing_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFData (MessagePackParsing) Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -52,11 +52,11 @@ @interface OFPlaceholderData: OFString @end /* References for static linking */ -void +void OF_VISIBILITY_HIDDEN _references_to_categories_of_OFData(void) { _OFData_CryptographicHashing_reference = 1; _OFData_MessagePackParsing_reference = 1; } @@ -403,11 +403,11 @@ OFMutableData *data; @try { data = [OFMutableData data]; - if (!OFBase64Decode(data, + if (!_OFBase64Decode(data, [string cStringWithEncoding: OFStringEncodingASCII], [string cStringLengthWithEncoding: OFStringEncodingASCII])) @throw [OFInvalidFormatException exception]; } @catch (id e) { [self release]; @@ -623,11 +623,11 @@ return ret; } - (OFString *)stringByBase64Encoding { - return OFBase64Encode(self.items, self.count * self.itemSize); + return _OFBase64Encode(self.items, self.count * self.itemSize); } - (OFRange)rangeOfData: (OFData *)data options: (OFDataSearchOptions)options range: (OFRange)range Index: src/OFDatagramSocket.m ================================================================== --- src/OFDatagramSocket.m +++ src/OFDatagramSocket.m @@ -58,11 +58,11 @@ + (void)initialize { if (self != [OFDatagramSocket class]) return; - if (!OFSocketInit()) + if (!_OFSocketInit()) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)socket @@ -134,11 +134,11 @@ u_long v = !canBlock; if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = canBlock; #else OF_UNRECOGNIZED_SELECTOR #endif @@ -150,11 +150,11 @@ if (setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, (char *)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #ifdef OF_WII _canSendToBroadcastAddresses = canSendToBroadcastAddresses; #endif } @@ -167,11 +167,11 @@ if (getsockopt(_socket, SOL_SOCKET, SO_BROADCAST, (char *)&v, &len) != 0 || len != sizeof(v)) @throw [OFGetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; return v; #else return _canSendToBroadcastAddresses; #endif @@ -194,11 +194,11 @@ (sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL), (sender != NULL ? &sender->length : NULL))) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if ((ret = recvfrom(_socket, buffer, (int)length, 0, @@ -205,11 +205,11 @@ (sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL), (sender != NULL ? &sender->length : NULL))) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #endif if (sender != NULL) { struct sockaddr *sa = (struct sockaddr *)&sender->sockaddr; @@ -312,11 +312,11 @@ (struct sockaddr *)&receiver->sockaddr, receiver->length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else int bytesWritten; if (length > INT_MAX) @throw [OFOutOfRangeException exception]; @@ -325,11 +325,11 @@ (struct sockaddr *)&receiver->sockaddr, receiver->length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #endif if ((size_t)bytesWritten != length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -277,12 +277,12 @@ OFOnce(&once, initZeroDate); return (id)zeroDate; } #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX - value = OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble( - seconds))); + value = OFFromBigEndian64(OFBitConvertDoubleToUInt64( + OFToBigEndianDouble(seconds))); /* Almost all dates fall into this range. */ if (value & (UINT64_C(4) << 60)) { id ret = [OFTaggedPointerDate dateWithUInt64TimeIntervalSince1970: value]; @@ -413,11 +413,11 @@ void *pool = objc_autoreleasePoolPush(); const char *UTF8String = string.UTF8String; struct tm tm = { .tm_isdst = -1 }; short tz = 0; - if (OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) != + if (_OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) != UTF8String + string.UTF8StringLength) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); @@ -429,18 +429,18 @@ { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = string.UTF8String; struct tm tm = { .tm_isdst = -1 }; /* - * OFStrPTime() can never set this to SHRT_MAX, no matter what is + * _OFStrPTime() can never set this to SHRT_MAX, no matter what is * passed to it, so this is a safe way to figure out if the date * contains a time zone. */ short tz = SHRT_MAX; OFTimeInterval seconds; - if (OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) != + if (_OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) != UTF8String + string.UTF8StringLength) @throw [OFInvalidFormatException exception]; if (tz == SHRT_MAX) { #ifdef OF_WINDOWS @@ -691,11 +691,11 @@ #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { - if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm, + if (_OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { @@ -740,11 +740,11 @@ #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { - if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm, + if (_OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { Index: src/OFEmbeddedIRIHandler.m ================================================================== --- src/OFEmbeddedIRIHandler.m +++ src/OFEmbeddedIRIHandler.m @@ -33,16 +33,16 @@ #ifdef OF_HAVE_THREADS # import "OFOnce.h" # import "OFPlainMutex.h" #endif -struct EmbeddedFile { +static struct EmbeddedFile { OFString *path; const uint8_t *bytes; size_t size; } *embeddedFiles = NULL; -size_t numEmbeddedFiles = 0; +static size_t numEmbeddedFiles = 0; #ifdef OF_HAVE_THREADS static OFPlainMutex mutex; static OFOnceControl mutexOnceControl = OFOnceControlInitValue; static void Index: src/OFGZIPStream.m ================================================================== --- src/OFGZIPStream.m +++ src/OFGZIPStream.m @@ -246,11 +246,11 @@ if (!_inflateStream.atEndOfStream) { size_t bytesRead = [_inflateStream readIntoBuffer: buffer length: length]; - _CRC32 = OFCRC32(_CRC32, buffer, bytesRead); + _CRC32 = _OFCRC32(_CRC32, buffer, bytesRead); _uncompressedSize += bytesRead; return bytesRead; } Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -123,11 +123,11 @@ #endif static OFString * normalizedKey(OFString *key) { - char *cString = OFStrDup(key.UTF8String); + char *cString = _OFStrDup(key.UTF8String); unsigned char *tmp = (unsigned char *)cString; bool firstLetter = true; OFString *ret; while (*tmp != '\0') { Index: src/OFHuffmanTree.h ================================================================== --- src/OFHuffmanTree.h +++ src/OFHuffmanTree.h @@ -31,11 +31,11 @@ uint16_t value; } *OFHuffmanTree; /* Inlined for performance. */ static OF_INLINE bool -OFHuffmanTreeWalk(id _Nullable stream, +_OFHuffmanTreeWalk(id _Nullable stream, bool (*bitReader)(id _Nullable, uint16_t *_Nonnull, uint8_t), OFHuffmanTree _Nonnull *_Nonnull tree, uint16_t *_Nonnull value) { OFHuffmanTree iter = *tree; uint16_t bits; @@ -57,14 +57,16 @@ } #ifdef __cplusplus extern "C" { #endif -extern OFHuffmanTree _Nonnull OFHuffmanTreeNew(uint8_t lengths[_Nonnull], - uint16_t count); -extern OFHuffmanTree _Nonnull OFHuffmanTreeNewSingle(uint16_t value); -extern void OFHuffmanTreeFree(OFHuffmanTree _Nonnull tree); +extern OFHuffmanTree _Nonnull _OFHuffmanTreeNew(uint8_t lengths[_Nonnull], + uint16_t count) OF_VISIBILITY_HIDDEN; +extern OFHuffmanTree _Nonnull _OFHuffmanTreeNewSingle(uint16_t value) + OF_VISIBILITY_HIDDEN; +extern void _OFHuffmanTreeFree(OFHuffmanTree _Nonnull tree) + OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFHuffmanTree.m ================================================================== --- src/OFHuffmanTree.m +++ src/OFHuffmanTree.m @@ -56,11 +56,11 @@ tree->value = value; } OFHuffmanTree -OFHuffmanTreeNew(uint8_t lengths[], uint16_t count) +_OFHuffmanTreeNew(uint8_t lengths[], uint16_t count) { OFHuffmanTree tree; uint16_t *lengthCount = NULL; uint16_t code, maxCode = 0, *nextCode = NULL; uint_fast8_t maxBit = 0; @@ -111,23 +111,23 @@ return tree; } OFHuffmanTree -OFHuffmanTreeNewSingle(uint16_t value) +_OFHuffmanTreeNewSingle(uint16_t value) { OFHuffmanTree tree = newTree(); tree->value = value; return tree; } void -OFHuffmanTreeFree(OFHuffmanTree tree) +_OFHuffmanTreeFree(OFHuffmanTree tree) { for (uint_fast8_t i = 0; i < 2; i++) if OF_LIKELY (tree->leaves[i] != NULL) - OFHuffmanTreeFree(tree->leaves[i]); + _OFHuffmanTreeFree(tree->leaves[i]); OFFreeMemory(tree); } Index: src/OFIPXSocket.m ================================================================== --- src/OFIPXSocket.m +++ src/OFIPXSocket.m @@ -67,11 +67,11 @@ exceptionWithNetwork: network node: node port: port packetType: packetType socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -78,11 +78,11 @@ fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException @@ -96,13 +96,13 @@ memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); - if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, + if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException Index: src/OFIRI.h ================================================================== --- src/OFIRI.h +++ src/OFIRI.h @@ -409,12 +409,13 @@ @end #ifdef __cplusplus extern "C" { #endif -extern bool OFIRIIsIPv6Host(OFString *host); -extern void OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool); +extern bool _OFIRIIsIPv6Host(OFString *host) OF_VISIBILITY_HIDDEN; +extern void _OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool) + OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFIRI.m ================================================================== --- src/OFIRI.m +++ src/OFIRI.m @@ -118,11 +118,11 @@ IRIFragmentAllowedCharacterSet = [[OFIRIFragmentAllowedCharacterSet alloc] init]; } bool -OFIRIIsIPv6Host(OFString *host) +_OFIRIIsIPv6Host(OFString *host) { const char *UTF8String = host.UTF8String; bool hasColon = false; while (*UTF8String != '\0') { @@ -419,11 +419,11 @@ @selector(characterIsMember:), character)); } @end void -OFIRIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet, +_OFIRIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet, bool allowPercent) { void *pool = objc_autoreleasePoolPush(); if (allowPercent) @@ -542,18 +542,18 @@ length: colon - UTF8String]; self->_percentEncodedPassword = [[OFString alloc] initWithUTF8String: colon + 1 length: length - (colon - UTF8String) - 1]; - OFIRIVerifyIsEscaped(self->_percentEncodedPassword, + _OFIRIVerifyIsEscaped(self->_percentEncodedPassword, [OFCharacterSet IRIPasswordAllowedCharacterSet], true); } else self->_percentEncodedUser = [[OFString alloc] initWithUTF8String: UTF8String length: length]; - OFIRIVerifyIsEscaped(self->_percentEncodedUser, + _OFIRIVerifyIsEscaped(self->_percentEncodedUser, [OFCharacterSet IRIUserAllowedCharacterSet], true); } static void parseHostPort(OFIRI *self, const char *UTF8String, size_t length) @@ -595,11 +595,11 @@ UTF8String += length; length = 0; } - OFIRIVerifyIsEscaped(self->_percentEncodedHost, + _OFIRIVerifyIsEscaped(self->_percentEncodedHost, [OFCharacterSet IRIHostAllowedCharacterSet], true); } if (length == 0) return; @@ -655,11 +655,11 @@ if ((fragment = memchr(UTF8String, '#', length)) != NULL) { *fragmentString = [OFString stringWithUTF8String: fragment + 1 length: length - (fragment - UTF8String) - 1]; - OFIRIVerifyIsEscaped(*fragmentString, + _OFIRIVerifyIsEscaped(*fragmentString, [OFCharacterSet IRIQueryAllowedCharacterSet], true); length = fragment - UTF8String; } @@ -666,20 +666,20 @@ if ((query = memchr(UTF8String, '?', length)) != NULL) { *queryString = [OFString stringWithUTF8String: query + 1 length: length - (query - UTF8String) - 1]; - OFIRIVerifyIsEscaped(*queryString, + _OFIRIVerifyIsEscaped(*queryString, [OFCharacterSet IRIFragmentAllowedCharacterSet], true); length = query - UTF8String; } *pathString = [OFString stringWithUTF8String: UTF8String length: length]; - OFIRIVerifyIsEscaped(*pathString, + _OFIRIVerifyIsEscaped(*pathString, [OFCharacterSet IRIPathAllowedCharacterSet], true); } - (instancetype)initWithString: (OFString *)string { @@ -698,11 +698,11 @@ _scheme = [[[OFString stringWithUTF8String: UTF8String length: colon - UTF8String] lowercaseString] copy]; - OFIRIVerifyIsEscaped(_scheme, + _OFIRIVerifyIsEscaped(_scheme, [OFCharacterSet IRISchemeAllowedCharacterSet], false); length -= colon - UTF8String + 1; UTF8String = colon + 1; @@ -1024,11 +1024,11 @@ if ([_percentEncodedHost hasPrefix: @"["] && [_percentEncodedHost hasSuffix: @"]"]) { OFString *host = [_percentEncodedHost substringWithRange: OFMakeRange(1, _percentEncodedHost.length - 2)]; - if (!OFIRIIsIPv6Host(host)) + if (!_OFIRIIsIPv6Host(host)) @throw [OFInvalidArgumentException exception]; return host; } Index: src/OFInflateStream.m ================================================================== --- src/OFInflateStream.m +++ src/OFInflateStream.m @@ -162,16 +162,16 @@ for (uint16_t i = 256; i <= 279; i++) lengths[i] = 7; for (uint16_t i = 280; i <= 287; i++) lengths[i] = 8; - fixedLitLenTree = OFHuffmanTreeNew(lengths, 288); + fixedLitLenTree = _OFHuffmanTreeNew(lengths, 288); for (uint16_t i = 0; i <= 31; i++) lengths[i] = 5; - fixedDistTree = OFHuffmanTreeNew(lengths, 32); + fixedDistTree = _OFHuffmanTreeNew(lengths, 32); } + (instancetype)streamWithStream: (OFStream *)stream { return [[[self alloc] initWithStream: stream] autorelease]; @@ -215,18 +215,18 @@ if (_state == stateHuffmanTree) { OFFreeMemory(_context.huffmanTree.lengths); if (_context.huffmanTree.codeLenTree != NULL) - OFHuffmanTreeFree(_context.huffmanTree.codeLenTree); + _OFHuffmanTreeFree(_context.huffmanTree.codeLenTree); } if (_state == stateHuffmanTree || _state == stateHuffmanBlock) { if (_context.huffman.litLenTree != fixedLitLenTree) - OFHuffmanTreeFree(_context.huffman.litLenTree); + _OFHuffmanTreeFree(_context.huffman.litLenTree); if (_context.huffman.distTree != fixedDistTree) - OFHuffmanTreeFree(_context.huffman.distTree); + _OFHuffmanTreeFree(_context.huffman.distTree); } [super dealloc]; } @@ -393,11 +393,11 @@ } CTX.lengths[codeLengthsOrder[i]] = bits; } - CTX.codeLenTree = OFHuffmanTreeNew(CTX.lengths, 19); + CTX.codeLenTree = _OFHuffmanTreeNew(CTX.lengths, 19); CTX.treeIter = CTX.codeLenTree; OFFreeMemory(CTX.lengths); CTX.lengths = NULL; CTX.receivedCount = 0; @@ -411,11 +411,11 @@ for (uint16_t i = CTX.receivedCount; i < CTX.litLenCodesCount + CTX.distCodesCount + 258;) { uint8_t j, count; if OF_LIKELY (CTX.value == 0xFF) { - if OF_UNLIKELY (!OFHuffmanTreeWalk(self, + if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits, &CTX.treeIter, &value)) { CTX.receivedCount = i; return bytesWritten; } @@ -478,16 +478,16 @@ CTX.lengths[i++] = value; CTX.value = 0xFF; } - OFHuffmanTreeFree(CTX.codeLenTree); + _OFHuffmanTreeFree(CTX.codeLenTree); CTX.codeLenTree = NULL; - CTX.litLenTree = OFHuffmanTreeNew(CTX.lengths, + CTX.litLenTree = _OFHuffmanTreeNew(CTX.lengths, CTX.litLenCodesCount + 257); - CTX.distTree = OFHuffmanTreeNew( + CTX.distTree = _OFHuffmanTreeNew( CTX.lengths + CTX.litLenCodesCount + 257, CTX.distCodesCount + 1); OFFreeMemory(CTX.lengths); @@ -535,11 +535,11 @@ CTX.treeIter = CTX.distTree; } /* Distance of length distance pair */ if (CTX.state == huffmanStateAwaitDistance) { - if OF_UNLIKELY (!OFHuffmanTreeWalk(self, + if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits, &CTX.treeIter, &value)) return bytesWritten; if OF_UNLIKELY (value >= numDistanceCodes) @throw [OFInvalidFormatException @@ -599,20 +599,20 @@ CTX.state = huffmanStateAwaitCode; CTX.treeIter = CTX.litLenTree; } - if OF_UNLIKELY (!OFHuffmanTreeWalk(self, tryReadBits, + if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits, &CTX.treeIter, &value)) return bytesWritten; /* End of block */ if OF_UNLIKELY (value == 256) { if (CTX.litLenTree != fixedLitLenTree) - OFHuffmanTreeFree(CTX.litLenTree); + _OFHuffmanTreeFree(CTX.litLenTree); if (CTX.distTree != fixedDistTree) - OFHuffmanTreeFree(CTX.distTree); + _OFHuffmanTreeFree(CTX.distTree); _state = stateBlockHeader; goto start; } Index: src/OFKernelEventObserver.m ================================================================== --- src/OFKernelEventObserver.m +++ src/OFKernelEventObserver.m @@ -64,11 +64,11 @@ + (void)initialize { if (self != [OFKernelEventObserver class]) return; - if (!OFSocketInit()) + if (!_OFSocketInit()) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)observer @@ -130,11 +130,11 @@ sizeof(_cancelAddr)) != 0) @throw [OFInitializationFailedException exceptionWithClass: self.class]; cancelAddrLen = sizeof(_cancelAddr); - if (OFGetSockName(_cancelFD[0], + if (_OFGetSockName(_cancelFD[0], (struct sockaddr *)&_cancelAddr, &cancelAddrLen) != 0) @throw [OFInitializationFailedException exceptionWithClass: self.class]; # else for (;;) { @@ -150,11 +150,11 @@ sizeof(_cancelAddr)); if (ret == 0) break; - if (OFSocketErrNo() != EADDRINUSE) + if (_OFSocketErrNo() != EADDRINUSE) @throw [OFInitializationFailedException exceptionWithClass: self.class]; } # endif #endif Index: src/OFLHAArchive.m ================================================================== --- src/OFLHAArchive.m +++ src/OFLHAArchive.m @@ -99,11 +99,11 @@ return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { - return OFArchiveIRIHandlerIRIForFileInArchive(@"lha", path, IRI); + return _OFArchiveIRIHandlerIRIForFileInArchive(@"lha", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD @@ -409,11 +409,11 @@ length = (size_t)_toRead; ret = [_decompressedStream readIntoBuffer: buffer length: length]; _toRead -= ret; - _CRC16 = OFCRC16(_CRC16, buffer, ret); + _CRC16 = _OFCRC16(_CRC16, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; if (_CRC16 != _entry.CRC16) { @@ -564,20 +564,20 @@ [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); _bytesWritten += (uint64_t)e.bytesWritten; - _CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten); + _CRC16 = _OFCRC16(_CRC16, buffer, e.bytesWritten); if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } _bytesWritten += (uint64_t)length; - _CRC16 = OFCRC16(_CRC16, buffer, length); + _CRC16 = _OFCRC16(_CRC16, buffer, length); return length; } - (bool)lowlevelIsAtEndOfStream Index: src/OFLHAArchiveEntry.m ================================================================== --- src/OFLHAArchiveEntry.m +++ src/OFLHAArchiveEntry.m @@ -840,11 +840,11 @@ /* Now fill in the size and CRC16 for the entire header */ tmp16 = OFToLittleEndian16(headerSize); memcpy([data mutableItemAtIndex: 0], &tmp16, sizeof(tmp16)); - tmp16 = OFCRC16(0, data.items, data.count); + tmp16 = _OFCRC16(0, data.items, data.count); tmp16 = OFToLittleEndian16(tmp16); memcpy([data mutableItemAtIndex: 27], &tmp16, sizeof(tmp16)); [stream writeData: data]; Index: src/OFLHADecompressingStream.m ================================================================== --- src/OFLHADecompressingStream.m +++ src/OFLHADecompressingStream.m @@ -126,15 +126,15 @@ [self close]; OFFreeMemory(_slidingWindow); if (_codeLenTree != NULL) - OFHuffmanTreeFree(_codeLenTree); + _OFHuffmanTreeFree(_codeLenTree); if (_litLenTree != NULL) - OFHuffmanTreeFree(_litLenTree); + _OFHuffmanTreeFree(_litLenTree); if (_distTree != NULL) - OFHuffmanTreeFree(_distTree); + _OFHuffmanTreeFree(_distTree); OFFreeMemory(_codesLengths); [super dealloc]; } @@ -224,21 +224,21 @@ continue; } else _codesReceived++; } - _codeLenTree = OFHuffmanTreeNew(_codesLengths, _codesCount); + _codeLenTree = _OFHuffmanTreeNew(_codesLengths, _codesCount); OFFreeMemory(_codesLengths); _codesLengths = NULL; _state = stateLitLenCodesCount; goto start; case stateCodeLenTreeSingle: if OF_UNLIKELY (!tryReadBits(self, &bits, 5)) return bytesWritten; - _codeLenTree = OFHuffmanTreeNewSingle(bits); + _codeLenTree = _OFHuffmanTreeNewSingle(bits); _state = stateLitLenCodesCount; goto start; case stateLitLenCodesCount: if OF_UNLIKELY (!tryReadBits(self, &bits, 9)) @@ -246,11 +246,11 @@ if OF_UNLIKELY (bits > 510) @throw [OFInvalidFormatException exception]; if OF_UNLIKELY (bits == 0) { - OFHuffmanTreeFree(_codeLenTree); + _OFHuffmanTreeFree(_codeLenTree); _codeLenTree = NULL; _state = stateLitLenTreeSingle; goto start; } @@ -300,11 +300,11 @@ _skip = false; continue; } - if (!OFHuffmanTreeWalk(self, tryReadBits, &_treeIter, + if (!_OFHuffmanTreeWalk(self, tryReadBits, &_treeIter, &value)) return bytesWritten; _treeIter = _codeLenTree; @@ -313,24 +313,24 @@ _skip = true; } else _codesLengths[_codesReceived++] = value - 2; } - _litLenTree = OFHuffmanTreeNew(_codesLengths, _codesCount); + _litLenTree = _OFHuffmanTreeNew(_codesLengths, _codesCount); OFFreeMemory(_codesLengths); _codesLengths = NULL; - OFHuffmanTreeFree(_codeLenTree); + _OFHuffmanTreeFree(_codeLenTree); _codeLenTree = NULL; _state = stateDistCodesCount; goto start; case stateLitLenTreeSingle: if OF_UNLIKELY (!tryReadBits(self, &bits, 9)) return bytesWritten; - _litLenTree = OFHuffmanTreeNewSingle(bits); + _litLenTree = _OFHuffmanTreeNewSingle(bits); _state = stateDistCodesCount; goto start; case stateDistCodesCount: if OF_UNLIKELY (!tryReadBits(self, &bits, _distanceBits)) @@ -377,11 +377,11 @@ continue; } else _codesReceived++; } - _distTree = OFHuffmanTreeNew(_codesLengths, _codesCount); + _distTree = _OFHuffmanTreeNew(_codesLengths, _codesCount); OFFreeMemory(_codesLengths); _codesLengths = NULL; _treeIter = _litLenTree; _state = stateBlockLitLen; @@ -388,19 +388,19 @@ goto start; case stateDistTreeSingle: if OF_UNLIKELY (!tryReadBits(self, &bits, _distanceBits)) return bytesWritten; - _distTree = OFHuffmanTreeNewSingle(bits); + _distTree = _OFHuffmanTreeNewSingle(bits); _treeIter = _litLenTree; _state = stateBlockLitLen; goto start; case stateBlockLitLen: if OF_UNLIKELY (_symbolsLeft == 0) { - OFHuffmanTreeFree(_litLenTree); - OFHuffmanTreeFree(_distTree); + _OFHuffmanTreeFree(_litLenTree); + _OFHuffmanTreeFree(_distTree); _litLenTree = _distTree = NULL; _state = stateBlockHeader; /* @@ -424,11 +424,11 @@ } if OF_UNLIKELY (length == 0) return bytesWritten; - if OF_UNLIKELY (!OFHuffmanTreeWalk(self, tryReadBits, + if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits, &_treeIter, &value)) return bytesWritten; if OF_LIKELY (value < 256) { buffer[bytesWritten++] = value; @@ -446,11 +446,11 @@ _state = stateBlockDistLength; } goto start; case stateBlockDistLength: - if OF_UNLIKELY (!OFHuffmanTreeWalk(self, tryReadBits, + if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits, &_treeIter, &value)) return bytesWritten; _distance = value; Index: src/OFLocale.m ================================================================== --- src/OFLocale.m +++ src/OFLocale.m @@ -60,11 +60,11 @@ #ifndef OF_AMIGAOS static void parseLocale(char *locale, OFStringEncoding *encoding, OFString **languageCode, OFString **countryCode) { - locale = OFStrDup(locale); + locale = _OFStrDup(locale); @try { OFStringEncoding enc = OFStringEncodingASCII; char *tmp; Index: src/OFMatrix4x4.m ================================================================== --- src/OFMatrix4x4.m +++ src/OFMatrix4x4.m @@ -316,11 +316,12 @@ OFHashInit(&hash); for (uint_fast8_t i = 0; i < 4; i++) for (uint_fast8_t j = 0; j < 4; j++) - OFHashAddHash(&hash, OFFloatToRawUInt32(_values[i][j])); + OFHashAddHash(&hash, + OFBitConvertFloatToUInt32(_values[i][j])); OFHashFinalize(&hash); return hash; } Index: src/OFMutableIRI.m ================================================================== --- src/OFMutableIRI.m +++ src/OFMutableIRI.m @@ -65,11 +65,11 @@ OFString *old = _scheme; if (scheme.length < 1 || !OFASCIIIsAlpha(*scheme.UTF8String)) @throw [OFInvalidFormatException exception]; - OFIRIVerifyIsEscaped(scheme, + _OFIRIVerifyIsEscaped(scheme, [OFCharacterSet IRISchemeAllowedCharacterSet], false); _scheme = [scheme.lowercaseString copy]; [old release]; @@ -80,11 +80,11 @@ - (void)setHost: (OFString *)host { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedHost; - if (OFIRIIsIPv6Host(host)) + if (_OFIRIIsIPv6Host(host)) _percentEncodedHost = [[OFString alloc] initWithFormat: @"[%@]", host]; else _percentEncodedHost = [[host stringByAddingPercentEncodingWithAllowedCharacters: @@ -99,15 +99,15 @@ { OFString *old; if ([percentEncodedHost hasPrefix: @"["] && [percentEncodedHost hasSuffix: @"]"]) { - if (!OFIRIIsIPv6Host([percentEncodedHost substringWithRange: + if (!_OFIRIIsIPv6Host([percentEncodedHost substringWithRange: OFMakeRange(1, percentEncodedHost.length - 2)])) @throw [OFInvalidFormatException exception]; } else if (percentEncodedHost != nil) - OFIRIVerifyIsEscaped(percentEncodedHost, + _OFIRIVerifyIsEscaped(percentEncodedHost, [OFCharacterSet IRIHostAllowedCharacterSet], true); old = _percentEncodedHost; _percentEncodedHost = [percentEncodedHost copy]; [old release]; @@ -141,11 +141,11 @@ - (void)setPercentEncodedUser: (OFString *)percentEncodedUser { OFString *old; if (percentEncodedUser != nil) - OFIRIVerifyIsEscaped(percentEncodedUser, + _OFIRIVerifyIsEscaped(percentEncodedUser, [OFCharacterSet IRIUserAllowedCharacterSet], true); old = _percentEncodedUser; _percentEncodedUser = [percentEncodedUser copy]; [old release]; @@ -168,11 +168,11 @@ - (void)setPercentEncodedPassword: (OFString *)percentEncodedPassword { OFString *old; if (percentEncodedPassword != nil) - OFIRIVerifyIsEscaped(percentEncodedPassword, + _OFIRIVerifyIsEscaped(percentEncodedPassword, [OFCharacterSet IRIPasswordAllowedCharacterSet], true); old = _percentEncodedPassword; _percentEncodedPassword = [percentEncodedPassword copy]; [old release]; @@ -194,11 +194,11 @@ - (void)setPercentEncodedPath: (OFString *)percentEncodedPath { OFString *old; - OFIRIVerifyIsEscaped(percentEncodedPath, + _OFIRIVerifyIsEscaped(percentEncodedPath, [OFCharacterSet IRIPathAllowedCharacterSet], true); old = _percentEncodedPath; _percentEncodedPath = [percentEncodedPath copy]; [old release]; @@ -240,11 +240,11 @@ - (void)setPercentEncodedQuery: (OFString *)percentEncodedQuery { OFString *old; if (percentEncodedQuery != nil) - OFIRIVerifyIsEscaped(percentEncodedQuery, + _OFIRIVerifyIsEscaped(percentEncodedQuery, [OFCharacterSet IRIQueryAllowedCharacterSet], true); old = _percentEncodedQuery; _percentEncodedQuery = [percentEncodedQuery copy]; [old release]; @@ -307,11 +307,11 @@ - (void)setPercentEncodedFragment: (OFString *)percentEncodedFragment { OFString *old; if (percentEncodedFragment != nil) - OFIRIVerifyIsEscaped(percentEncodedFragment, + _OFIRIVerifyIsEscaped(percentEncodedFragment, [OFCharacterSet IRIFragmentAllowedCharacterSet], true); old = _percentEncodedFragment; _percentEncodedFragment = [percentEncodedFragment copy]; [old release]; Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -351,11 +351,11 @@ int UTF8StringLength; if (format == nil) @throw [OFInvalidArgumentException exception]; - if ((UTF8StringLength = OFVASPrintF(&UTF8String, format.UTF8String, + if ((UTF8StringLength = _OFVASPrintF(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { [self appendUTF8String: UTF8String length: UTF8StringLength]; @@ -365,30 +365,30 @@ } #ifdef OF_HAVE_UNICODE_TABLES - (void)uppercase { - [self of_convertWithWordStartTable: OFUnicodeUppercaseTable - wordMiddleTable: OFUnicodeUppercaseTable - wordStartTableSize: OFUnicodeUppercaseTableSize - wordMiddleTableSize: OFUnicodeUppercaseTableSize]; + [self of_convertWithWordStartTable: _OFUnicodeUppercaseTable + wordMiddleTable: _OFUnicodeUppercaseTable + wordStartTableSize: _OFUnicodeUppercaseTableSize + wordMiddleTableSize: _OFUnicodeUppercaseTableSize]; } - (void)lowercase { - [self of_convertWithWordStartTable: OFUnicodeLowercaseTable - wordMiddleTable: OFUnicodeLowercaseTable - wordStartTableSize: OFUnicodeLowercaseTableSize - wordMiddleTableSize: OFUnicodeLowercaseTableSize]; + [self of_convertWithWordStartTable: _OFUnicodeLowercaseTable + wordMiddleTable: _OFUnicodeLowercaseTable + wordStartTableSize: _OFUnicodeLowercaseTableSize + wordMiddleTableSize: _OFUnicodeLowercaseTableSize]; } - (void)capitalize { - [self of_convertWithWordStartTable: OFUnicodeTitlecaseTable - wordMiddleTable: OFUnicodeLowercaseTable - wordStartTableSize: OFUnicodeTitlecaseTableSize - wordMiddleTableSize: OFUnicodeLowercaseTableSize]; + [self of_convertWithWordStartTable: _OFUnicodeTitlecaseTable + wordMiddleTable: _OFUnicodeLowercaseTable + wordStartTableSize: _OFUnicodeTitlecaseTableSize + wordMiddleTableSize: _OFUnicodeLowercaseTableSize]; } #else - (void)uppercase { convert(self, OFASCIIToUpper, OFASCIIToUpper); Index: src/OFMutableUTF8String.m ================================================================== --- src/OFMutableUTF8String.m +++ src/OFMutableUTF8String.m @@ -119,11 +119,11 @@ } else { table = middleTable; tableSize = middleTableSize; } - cLen = OFUTF8StringDecode(_s->cString + i, + cLen = _OFUTF8StringDecode(_s->cString + i, _s->cStringLength - i, &c); if (cLen <= 0 || c > 0x10FFFF) { OFFreeMemory(unicodeString); @throw [OFInvalidEncodingException exception]; @@ -165,11 +165,11 @@ j = 0; for (i = 0; i < unicodeLen; i++) { size_t d; - if ((d = OFUTF8StringEncode(unicodeString[i], + if ((d = _OFUTF8StringEncode(unicodeString[i], newCString + j)) == 0) { OFFreeMemory(unicodeString); OFFreeMemory(newCString); @throw [OFInvalidEncodingException exception]; } @@ -198,11 +198,11 @@ OFUnichar c; size_t lenNew; ssize_t lenOld; if (_s->isUTF8) - idx = OFUTF8StringIndexToPosition(_s->cString, idx, + idx = _OFUTF8StringIndexToPosition(_s->cString, idx, _s->cStringLength); if (idx >= _s->cStringLength) @throw [OFOutOfRangeException exception]; @@ -211,14 +211,14 @@ _s->hasHash = false; _s->cString[idx] = character; return; } - if ((lenNew = OFUTF8StringEncode(character, buffer)) == 0) + if ((lenNew = _OFUTF8StringEncode(character, buffer)) == 0) @throw [OFInvalidEncodingException exception]; - if ((lenOld = OFUTF8StringDecode(_s->cString + idx, + if ((lenOld = _OFUTF8StringDecode(_s->cString + idx, _s->cStringLength - idx, &c)) <= 0) @throw [OFInvalidEncodingException exception]; _s->hasHash = false; @@ -268,11 +268,11 @@ memcmp(UTF8String, "\xEF\xBB\xBF", 3) == 0) { UTF8String += 3; UTF8StringLength -= 3; } - switch (OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) { + switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) { case 1: _s->isUTF8 = true; break; case -1: @throw [OFInvalidEncodingException exception]; @@ -297,11 +297,11 @@ memcmp(UTF8String, "\xEF\xBB\xBF", 3) == 0) { UTF8String += 3; UTF8StringLength -= 3; } - switch (OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) { + switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) { case 1: _s->isUTF8 = true; break; case -1: @throw [OFInvalidEncodingException exception]; @@ -379,11 +379,12 @@ @try { size_t j = 0; bool isUTF8 = false; for (size_t i = 0; i < length; i++) { - size_t len = OFUTF8StringEncode(characters[i], tmp + j); + size_t len = _OFUTF8StringEncode(characters[i], + tmp + j); if (len == 0) @throw [OFInvalidEncodingException exception]; if (len > 1) @@ -415,11 +416,11 @@ int UTF8StringLength; if (format == nil) @throw [OFInvalidArgumentException exception]; - if ((UTF8StringLength = OFVASPrintF(&UTF8String, format.UTF8String, + if ((UTF8StringLength = _OFVASPrintF(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { [self appendUTF8String: UTF8String length: UTF8StringLength]; @@ -434,11 +435,11 @@ if (idx > _s->length) @throw [OFOutOfRangeException exception]; if (_s->isUTF8) - idx = OFUTF8StringIndexToPosition(_s->cString, idx, + idx = _OFUTF8StringIndexToPosition(_s->cString, idx, _s->cStringLength); newCStringLength = _s->cStringLength + string.UTF8StringLength; _s->hasHash = false; _s->cString = OFResizeMemory(_s->cString, newCStringLength + 1, 1); @@ -467,13 +468,13 @@ if (range.length > SIZE_MAX - range.location || end > _s->length) @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { - start = OFUTF8StringIndexToPosition(_s->cString, start, + start = _OFUTF8StringIndexToPosition(_s->cString, start, _s->cStringLength); - end = OFUTF8StringIndexToPosition(_s->cString, end, + end = _OFUTF8StringIndexToPosition(_s->cString, end, _s->cStringLength); } memmove(_s->cString + start, _s->cString + end, _s->cStringLength - end); @@ -504,13 +505,13 @@ @throw [OFOutOfRangeException exception]; newLength = _s->length - range.length + replacement.length; if (_s->isUTF8) { - start = OFUTF8StringIndexToPosition(_s->cString, start, + start = _OFUTF8StringIndexToPosition(_s->cString, start, _s->cStringLength); - end = OFUTF8StringIndexToPosition(_s->cString, end, + end = _OFUTF8StringIndexToPosition(_s->cString, end, _s->cStringLength); } newCStringLength = _s->cStringLength - (end - start) + replacement.UTF8StringLength; @@ -571,13 +572,13 @@ if (range.length > SIZE_MAX - range.location || range.location + range.length > self.length) @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { - range.location = OFUTF8StringIndexToPosition(_s->cString, + range.location = _OFUTF8StringIndexToPosition(_s->cString, range.location, _s->cStringLength); - range.length = OFUTF8StringIndexToPosition( + range.length = _OFUTF8StringIndexToPosition( _s->cString + range.location, range.length, _s->cStringLength - range.location); } if (string.UTF8StringLength > range.length) Index: src/OFObject+KeyValueCoding.h ================================================================== --- src/OFObject+KeyValueCoding.h +++ src/OFObject+KeyValueCoding.h @@ -23,11 +23,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFObject_KeyValueCoding_reference; +extern int _OFObject_KeyValueCoding_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFObject (KeyValueCoding) Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -1480,12 +1480,48 @@ extern id _Nullable objc_getAssociatedObject(id _Nonnull object, const void *_Nonnull key); extern void objc_removeAssociatedObjects(id _Nonnull object); # endif #endif + +/** + * @brief Allocates a new object. + * + * This is useful to override @ref OFObject#alloc in a subclass that can then + * allocate extra memory in the same memory allocation. + * + * @param class_ The class of which to allocate an object + * @param extraSize Extra space after the ivars to allocate + * @param extraAlignment Alignment of the extra space after the ivars + * @param extra A pointer to set to a pointer to the extra space + * @return The allocated object + */ extern id OFAllocObject(Class class_, size_t extraSize, size_t extraAlignment, void *_Nullable *_Nullable extra); + +/** + * @brief This function is called when a method is not found. + * + * It can also be called intentionally to indicate that a method is not + * implemetned, for example in an abstract method. However, instead of calling + * OFMethodNotFound directly, it is preferred to do the following: + * + * - (void)abstractMethod + * { + * OF_UNRECOGNIZED_SELECTOR + * } + * + * However, do not use this for init methods. Instead, use the following: + * + * - (instancetype)init + * { + * OF_INVALID_INIT_METHOD + * } + * + * @param self The object which does not have the method + * @param _cmd The selector of the method that does not exist + */ extern void OF_NO_RETURN_FUNC OFMethodNotFound(id self, SEL _cmd); /** * @brief Initializes the specified hash. * Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -493,11 +493,11 @@ { return [[object description] cStringWithEncoding: [OFLocale encoding]]; } /* References for static linking */ -void +void OF_VISIBILITY_HIDDEN _references_to_categories_of_OFObject(void) { _OFObject_KeyValueCoding_reference = 1; } Index: src/OFPlainCondition.h ================================================================== --- src/OFPlainCondition.h +++ src/OFPlainCondition.h @@ -27,10 +27,12 @@ #endif /* For OFTimeInterval */ #import "OFObject.h" #import "OFPlainMutex.h" + +/** @file */ #if defined(OF_HAVE_PTHREADS) # include typedef pthread_cond_t OFPlainCondition; #elif defined(OF_WINDOWS) @@ -40,33 +42,103 @@ volatile int count; } OFPlainCondition; #elif defined(OF_AMIGAOS) # include typedef struct { - struct OFPlainConditionWaitingTask { + struct _OFPlainConditionWaitingTask { struct Task *task; unsigned char sigBit; - struct OFPlainConditionWaitingTask *next; + struct _OFPlainConditionWaitingTask *next; } *waitingTasks; } OFPlainCondition; #endif #ifdef __cplusplus extern "C" { #endif +/** + * @brief Creates a new plain condition. + * + * A plain condition is similar to an @ref OFCondition, but does not use + * exceptions and can be used from pure C code. + * + * @param condition A pointer to the condition to create + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionNew(OFPlainCondition *condition); + +/** + * @brief Signals the specified condition. + * + * @param condition A pointer to the condition to signal + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionSignal(OFPlainCondition *condition); + +/** + * @brief Broadcasts the specified condition, meaning it will be signaled to + * everyone waiting. + * + * @param condition A pointer to the condition to broadcast + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionBroadcast(OFPlainCondition *condition); + +/** + * @brief Waits on the specified condition with the specified mutex. + * + * @param condition A pointer to the condition to wait on + * @param mutex The mutex to wait with + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionWait(OFPlainCondition *condition, OFPlainMutex *mutex); + +/** + * @brief Waits on the specified condition with the specified mutex with a + * timeout. + * + * @param condition A pointer to the condition to wait on + * @param mutex The mutex to wait with + * @param timeout The timeout after which to give up + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionTimedWait(OFPlainCondition *condition, OFPlainMutex *mutex, OFTimeInterval timeout); + #if defined(OF_AMIGAOS) || defined(DOXYGEN) +/** + * @brief Waits on the specified condition with the specified mutex or the + * specified Exec signal. + * + * @param condition A pointer to the condition to wait on + * @param mutex The mutex to wait with + * @param signalMask The Exec signal mask to wait for + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition, OFPlainMutex *mutex, ULONG *signalMask); + +/** + * @brief Waits on the specified condition with the specified mutex or the + * specified Exec signal, up until the timeout is reached. + * + * @param condition A pointer to the condition to wait on + * @param mutex The mutex to wait with + * @param signalMask The Exec signal mask to wait for + * @param timeout The timeout after which to give up + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition, OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask); #endif + +/** + * @brief Destroys the specified plain condition. + * + * @param condition A pointer to the condition to destroy + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainConditionFree(OFPlainCondition *condition); #ifdef __cplusplus } #endif Index: src/OFPlainMutex.h ================================================================== --- src/OFPlainMutex.h +++ src/OFPlainMutex.h @@ -27,10 +27,12 @@ (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)) # error No mutexes available! #endif #import "macros.h" + +/** @file */ #if defined(OF_HAVE_PTHREADS) # include typedef pthread_mutex_t OFPlainMutex; #elif defined(OF_WINDOWS) @@ -66,26 +68,107 @@ #endif #ifdef __cplusplus extern "C" { #endif +/** + * @brief Creates a new plain mutex. + * + * A plain mutex is similar to an @ref OFMutex, but does not use exceptions and + * is just a lightweight wrapper around the system's mutex implementation. + * + * @param mutex A pointer to the mutex to create + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainMutexNew(OFPlainMutex *mutex); + +/** + * @brief Locks the specified mutex. + * + * @param mutex A pointer to the mutex to lock + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainMutexLock(OFPlainMutex *mutex); + +/** + * @brief Tries to lock the specified mutex without blocking. + * + * @param mutex A pointer to the mutex to try to lock + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainMutexTryLock(OFPlainMutex *mutex); + +/** + * @brief Unlocks the specified mutex. + * + * @param mutex A pointer to the mutex to unlock + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainMutexUnlock(OFPlainMutex *mutex); + +/** + * @brief Destroys the specified mutex + * + * @param mutex A pointer to the mutex to destruct + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainMutexFree(OFPlainMutex *mutex); + +/** + * @brief Creates a new plain recursive mutex. + * + * A plain recursive mutex is similar to an @ref OFRecursiveMutex, but does not + * use exceptions and is just a lightweight wrapper around the system's + * recursive mutex implementation (or lacking that, a simple implementation of + * recursive mutexes via regular mutexes). + * + * @param rmutex A pointer to the recursive mutex to create + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainRecursiveMutexNew(OFPlainRecursiveMutex *rmutex); + +/** + * @brief Locks the specified recursive mutex. + * + * @param rmutex A pointer to the recursive mutex to lock + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainRecursiveMutexLock(OFPlainRecursiveMutex *rmutex); + +/** + * @brief Tries to lock the specified recursive mutex without blocking. + * + * @param rmutex A pointer to the recursive mutex to try to lock + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainRecursiveMutexTryLock(OFPlainRecursiveMutex *rmutex); + +/** + * @brief Unlocks the specified recursive mutex. + * + * @param rmutex A pointer to the recursive mutex to unlock + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainRecursiveMutexUnlock(OFPlainRecursiveMutex *rmutex); + +/** + * @brief Destroys the specified recursive mutex + * + * @param rmutex A pointer to the recursive mutex to destruct + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainRecursiveMutexFree(OFPlainRecursiveMutex *rmutex); #ifdef __cplusplus } #endif /* Spinlocks are inlined for performance. */ +/** + * @brief Yield the current thread, indicating to the OS that another thread + * should execute instead. + */ static OF_INLINE void OFYieldThread(void) { #if defined(OF_HAVE_SCHED_YIELD) sched_yield(); @@ -92,10 +175,16 @@ #elif defined(OF_WINDOWS) Sleep(0); #endif } +/** + * @brief Creates a new spinlock. + * + * @param spinlock A pointer to the spinlock to create + * @return 0 on success, or an error number from `` on error + */ static OF_INLINE int OFSpinlockNew(OFSpinlock *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) *spinlock = 0; @@ -105,10 +194,16 @@ #else return OFPlainMutexNew(spinlock); #endif } +/** + * @brief Tries to lock a spinlock. + * + * @param spinlock A pointer to the spinlock to try to lock + * @return 0 on success, or an error number from `` on error + */ static OF_INLINE int OFSpinlockTryLock(OFSpinlock *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) if (OFAtomicIntCompareAndSwap(spinlock, 0, 1)) { @@ -122,10 +217,16 @@ #else return OFPlainMutexTryLock(spinlock); #endif } +/** + * @brief Locks a spinlock. + * + * @param spinlock A pointer to the spinlock to lock + * @return 0 on success, or an error number from `` on error + */ static OF_INLINE int OFSpinlockLock(OFSpinlock *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) size_t i; @@ -143,10 +244,16 @@ #else return OFPlainMutexLock(spinlock); #endif } +/** + * @brief Unlocks a spinlock. + * + * @param spinlock A pointer to the spinlock to unlock + * @return 0 on success, or an error number from `` on error + */ static OF_INLINE int OFSpinlockUnlock(OFSpinlock *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) bool ret = OFAtomicIntCompareAndSwap(spinlock, 1, 0); @@ -159,10 +266,16 @@ #else return OFPlainMutexUnlock(spinlock); #endif } +/** + * @brief Destroys a spinlock. + * + * @param spinlock A pointer to the spinlock to destroy + * @return 0 on success, or an error number from `` on error + */ static OF_INLINE int OFSpinlockFree(OFSpinlock *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) return 0; Index: src/OFPlainThread.h ================================================================== --- src/OFPlainThread.h +++ src/OFPlainThread.h @@ -25,10 +25,12 @@ (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)) # error No threads available! #endif #import "OFObject.h" + +/** @file */ #if defined(OF_HAVE_PTHREADS) # include typedef pthread_t OFPlainThread; #elif defined(OF_WINDOWS) @@ -51,17 +53,28 @@ typedef struct { float priority; size_t stackSize; } OFPlainThreadAttributes; -#if defined(OF_HAVE_PTHREADS) +#if defined(OF_HAVE_PTHREADS) || defined(DOXYGEN) +/** + * @brief Returns the current plain thread. + * + * @return The current plain thread + */ static OF_INLINE OFPlainThread OFCurrentPlainThread(void) { return pthread_self(); } +/** + * @brief Returns whether the specified plain thread is the current thread. + * + * @param thread The thread to check + * @return Whether the specified plain thread is the current thread + */ static OF_INLINE bool OFPlainThreadIsCurrent(OFPlainThread thread) { return pthread_equal(thread, pthread_self()); } @@ -83,14 +96,54 @@ #endif #ifdef __cplusplus extern "C" { #endif +/** + * @brief Initializes the specified thread attributes. + * + * @param attr A pointer to the thread attributes to initialize + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainThreadAttributesInit(OFPlainThreadAttributes *attr); + +/** + * @brief Creates a new plain thread. + * + * A plain thread is similar to @ref OFThread, but does not use exceptions and + * is just a lightweight wrapper around the system's thread implementation. + * + * @param thread A pointer to the thread to create + * @param name A name for the thread + * @param function The function the thread should execute + * @param object The object to pass to the thread as an argument + * @param attr Thread attributes + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainThreadNew(OFPlainThread *thread, const char *name, void (*function)(id), id object, const OFPlainThreadAttributes *attr); + +/** + * @brief Sets the name of the current thread. + * + * @param name The name for the current thread + */ extern void OFSetThreadName(const char *name); + +/** + * @brief Joins the specified thread. + * + * @param thread The thread to join + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainThreadJoin(OFPlainThread thread); + +/** + * @brief Detaches the specified thread. + * + * @param thread The thread to detach + * @return 0 on success, or an error number from `` on error + */ extern int OFPlainThreadDetach(OFPlainThread thread); #ifdef __cplusplus } #endif Index: src/OFSPXSocket.m ================================================================== --- src/OFSPXSocket.m +++ src/OFSPXSocket.m @@ -192,11 +192,11 @@ @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_socket = socket(address->sockaddr.ipx.sipx_family, SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) { - *errNo = OFSocketErrNo(); + *errNo = _OFSocketErrNo(); return false; } #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -212,11 +212,11 @@ if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (connect(_socket, (struct sockaddr *)&address->sockaddr, address->length) != 0) { - *errNo = OFSocketErrNo(); + *errNo = _OFSocketErrNo(); return false; } return true; } @@ -338,11 +338,11 @@ exceptionWithNetwork: network node: node port: port packetType: SPXPacketType socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -349,11 +349,11 @@ fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException @@ -367,13 +367,13 @@ memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); - if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, + if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException Index: src/OFSPXStreamSocket.m ================================================================== --- src/OFSPXStreamSocket.m +++ src/OFSPXStreamSocket.m @@ -194,11 +194,11 @@ @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_socket = socket(address->sockaddr.ipx.sipx_family, SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) { - *errNo = OFSocketErrNo(); + *errNo = _OFSocketErrNo(); return false; } #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -214,11 +214,11 @@ if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (connect(_socket, (struct sockaddr *)&address->sockaddr, address->length) != 0) { - *errNo = OFSocketErrNo(); + *errNo = _OFSocketErrNo(); return false; } return true; } @@ -339,11 +339,11 @@ exceptionWithNetwork: network node: node port: port packetType: SPXPacketType socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -350,11 +350,11 @@ fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException @@ -368,13 +368,13 @@ memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); - if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, + if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPXSocketFailedException Index: src/OFScrypt.h ================================================================== --- src/OFScrypt.h +++ src/OFScrypt.h @@ -63,14 +63,15 @@ } OFScryptParameters; #ifdef __cplusplus extern "C" { #endif -extern void OFSalsa20_8Core(uint32_t buffer[_Nonnull 16]); -extern void OFScryptBlockMix(uint32_t *output, const uint32_t *input, +/* No OF_VISIBILITY_HIDDEN so tests can call it. */ +extern void _OFSalsa20_8Core(uint32_t buffer[_Nonnull 16]); +extern void _OFScryptBlockMix(uint32_t *output, const uint32_t *input, size_t blockSize); -extern void OFScryptROMix(uint32_t *buffer, size_t blockSize, +extern void _OFScryptROMix(uint32_t *buffer, size_t blockSize, size_t costFactor, uint32_t *tmp); /** * @brief Derives a key from a password and a salt using scrypt. * Index: src/OFScrypt.m ================================================================== --- src/OFScrypt.m +++ src/OFScrypt.m @@ -29,11 +29,11 @@ #import "OFScrypt.h" #import "OFPBKDF2.h" void -OFSalsa20_8Core(uint32_t buffer[16]) +_OFSalsa20_8Core(uint32_t buffer[16]) { uint32_t tmp[16]; for (uint_fast8_t i = 0; i < 16; i++) tmp[i] = OFToLittleEndian32(buffer[i]); @@ -79,11 +79,11 @@ OFZeroMemory(tmp, sizeof(tmp)); } void -OFScryptBlockMix(uint32_t *output, const uint32_t *input, size_t blockSize) +_OFScryptBlockMix(uint32_t *output, const uint32_t *input, size_t blockSize) { uint32_t tmp[16]; /* Check defined here and executed in OFScrypt() */ #define OVERFLOW_CHECK_1 \ @@ -95,11 +95,11 @@ for (size_t i = 0; i < 2 * blockSize; i++) { for (size_t j = 0; j < 16; j++) tmp[j] ^= input[i * 16 + j]; - OFSalsa20_8Core(tmp); + _OFSalsa20_8Core(tmp); /* * Even indices are stored in the first half and odd ones in * the second. */ @@ -108,11 +108,11 @@ OFZeroMemory(tmp, sizeof(tmp)); } void -OFScryptROMix(uint32_t *buffer, size_t blockSize, size_t costFactor, +_OFScryptROMix(uint32_t *buffer, size_t blockSize, size_t costFactor, uint32_t *tmp) { /* Check defined here and executed in OFScrypt() */ #define OVERFLOW_CHECK_2 \ if (param.blockSize > SIZE_MAX / 128 / param.costFactor) \ @@ -122,21 +122,21 @@ memcpy(tmp, buffer, 128 * blockSize); for (size_t i = 0; i < costFactor; i++) { memcpy(tmp2 + i * 32 * blockSize, tmp, 128 * blockSize); - OFScryptBlockMix(tmp, tmp2 + i * 32 * blockSize, blockSize); + _OFScryptBlockMix(tmp, tmp2 + i * 32 * blockSize, blockSize); } for (size_t i = 0; i < costFactor; i++) { uint32_t j = OFFromLittleEndian32( tmp[(2 * blockSize - 1) * 16]) & (costFactor - 1); for (size_t k = 0; k < 32 * blockSize; k++) tmp[k] ^= tmp2[j * 32 * blockSize + k]; - OFScryptBlockMix(buffer, tmp, blockSize); + _OFScryptBlockMix(buffer, tmp, blockSize); if (i < costFactor - 1) memcpy(tmp, buffer, 128 * blockSize); } } @@ -198,11 +198,11 @@ param.blockSize, .allowsSwappableMemory = param.allowsSwappableMemory }); for (size_t i = 0; i < param.parallelization; i++) - OFScryptROMix(bufferItems + i * 32 * param.blockSize, + _OFScryptROMix(bufferItems + i * 32 * param.blockSize, param.blockSize, param.costFactor, tmpItems); OFPBKDF2((OFPBKDF2Parameters){ .HMAC = HMAC, .iterations = 1, Index: src/OFSelectKernelEventObserver.m ================================================================== --- src/OFSelectKernelEventObserver.m +++ src/OFSelectKernelEventObserver.m @@ -240,11 +240,11 @@ #endif if (events < 0) @throw [OFObserveKernelEventsFailedException exceptionWithObserver: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #ifdef OF_AMIGAOS if (execSignalMask != 0 && [_delegate respondsToSelector: @selector(execSignalWasReceived:)]) [_delegate execSignalWasReceived: execSignalMask]; Index: src/OFSequencedPacketSocket.m ================================================================== --- src/OFSequencedPacketSocket.m +++ src/OFSequencedPacketSocket.m @@ -54,11 +54,11 @@ + (void)initialize { if (self != [OFSequencedPacketSocket class]) return; - if (!OFSocketInit()) + if (!_OFSocketInit()) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)socket @@ -100,11 +100,11 @@ int errNo; socklen_t len = sizeof(errNo); if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo, &len) != 0) - return OFSocketErrNo(); + return _OFSocketErrNo(); return errNo; } #endif @@ -141,11 +141,11 @@ u_long v = !canBlock; if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = canBlock; #else OF_UNRECOGNIZED_SELECTOR #endif @@ -161,20 +161,20 @@ #ifndef OF_WINDOWS if ((ret = recv(_socket, buffer, length, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if ((ret = recv(_socket, buffer, (int)length, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #endif return ret; } @@ -239,11 +239,11 @@ if ((bytesWritten = send(_socket, (void *)buffer, length, 0)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else int bytesWritten; if (length > INT_MAX) @throw [OFOutOfRangeException exception]; @@ -251,11 +251,11 @@ if ((bytesWritten = send(_socket, buffer, (int)length, 0)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #endif if ((size_t)bytesWritten != length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length @@ -312,11 +312,11 @@ if (listen(_socket, backlog) == -1) @throw [OFListenOnSocketFailedException exceptionWithSocket: self backlog: backlog - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _listening = true; } - (instancetype)accept @@ -340,26 +340,26 @@ (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) == OFInvalidSocketHandle) @throw [OFAcceptSocketFailedException exceptionWithSocket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) if ((client->_socket = accept4(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, SOCK_CLOEXEC)) == OFInvalidSocketHandle) @throw [OFAcceptSocketFailedException exceptionWithSocket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else if ((client->_socket = accept(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length)) == OFInvalidSocketHandle) @throw [OFAcceptSocketFailedException exceptionWithSocket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif Index: src/OFSocket+Private.h ================================================================== --- src/OFSocket+Private.h +++ src/OFSocket+Private.h @@ -56,13 +56,13 @@ # define closesocket(sock) CloseSocket(sock) # define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg) # define hstrerror(err) "unknown (no hstrerror)" # define SOCKET_ERROR -1 # if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS) -# define SocketBase ((struct Library *)OFTLSKeyGet(OFSocketBaseKey)) +# define SocketBase ((struct Library *)OFTLSKeyGet(_OFSocketBaseKey)) # ifdef OF_AMIGAOS4 -# define ISocket ((struct SocketIFace *)OFTLSKeyGet(OFSocketInterfaceKey)) +# define ISocket ((struct SocketIFace *)OFTLSKeyGet(_OFSocketInterfaceKey)) # endif # endif # ifdef OF_MORPHOS typedef uint32_t in_addr_t; # endif Index: src/OFSocket.h ================================================================== --- src/OFSocket.h +++ src/OFSocket.h @@ -441,24 +441,24 @@ * @return The port of the address */ extern uint8_t OFSocketAddressAppleTalkPort( const OFSocketAddress *_Nonnull address); -extern bool OFSocketInit(void); +extern bool _OFSocketInit(void) OF_VISIBILITY_HIDDEN; #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) -extern void OFSocketDeinit(void); +extern void _OFSocketDeinit(void) OF_VISIBILITY_HIDDEN; #endif -extern int OFSocketErrNo(void); +extern int _OFSocketErrNo(void) OF_VISIBILITY_HIDDEN; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) -extern int OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr, - socklen_t *restrict addrLen); +extern int _OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr, + socklen_t *restrict addrLen) OF_VISIBILITY_HIDDEN; #endif #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) -extern OFTLSKey OFSocketBaseKey; +extern OFTLSKey _OFSocketBaseKey OF_VISIBILITY_HIDDEN; # ifdef OF_AMIGAOS4 -extern OFTLSKey OFSocketInterfaceKey; +extern OFTLSKey _OFSocketInterfaceKey OF_VISIBILITY_HIDDEN; # endif #endif #ifdef __cplusplus } #endif Index: src/OFSocket.m ================================================================== --- src/OFSocket.m +++ src/OFSocket.m @@ -86,13 +86,13 @@ static bool initSuccessful = false; #endif #ifdef OF_AMIGAOS # if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS) -OFTLSKey OFSocketBaseKey; +OFTLSKey _OFSocketBaseKey; # ifdef OF_AMIGAOS4 -OFTLSKey OFSocketInterfaceKey; +OFTLSKey _OFSocketInterfaceKey; # endif # else struct Library *SocketBase; # ifdef OF_AMIGAOS4 struct SocketIFace *ISocket = NULL; @@ -101,15 +101,15 @@ #endif #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) OF_CONSTRUCTOR() { - if (OFTLSKeyNew(&OFSocketBaseKey) != 0) + if (OFTLSKeyNew(&_OFSocketBaseKey) != 0) @throw [OFInitializationFailedException exception]; # ifdef OF_AMIGAOS4 - if (OFTLSKeyNew(&OFSocketInterfaceKey) != 0) + if (OFTLSKeyNew(&_OFSocketInterfaceKey) != 0) @throw [OFInitializationFailedException exception]; # endif } #endif @@ -174,11 +174,11 @@ # endif } #endif bool -OFSocketInit(void) +_OFSocketInit(void) { #if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS) static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, init); @@ -188,13 +188,13 @@ # ifdef OF_AMIGAOS4 struct SocketIFace *socketInterface; # endif # ifdef OF_AMIGAOS4 - if ((socketInterface = OFTLSKeyGet(OFSocketInterfaceKey)) != NULL) + if ((socketInterface = OFTLSKeyGet(_OFSocketInterfaceKey)) != NULL) # else - if ((socketBase = OFTLSKeyGet(OFSocketBaseKey)) != NULL) + if ((socketBase = OFTLSKeyGet(_OFSocketBaseKey)) != NULL) # endif return true; if ((socketBase = OpenLibrary("bsdsocket.library", 4)) == NULL) return false; @@ -205,20 +205,20 @@ CloseLibrary(socketBase); return false; } # endif - if (OFTLSKeySet(OFSocketBaseKey, socketBase) != 0) { + if (OFTLSKeySet(_OFSocketBaseKey, socketBase) != 0) { CloseLibrary(socketBase); # ifdef OF_AMIGAOS4 DropInterface((struct Interface *)socketInterface); # endif return false; } # ifdef OF_AMIGAOS4 - if (OFTLSKeySet(OFSocketInterfaceKey, socketInterface) != 0) { + if (OFTLSKeySet(_OFSocketInterfaceKey, socketInterface) != 0) { CloseLibrary(socketBase); DropInterface((struct Interface *)socketInterface); return false; } # endif @@ -227,15 +227,16 @@ #endif } #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) void -OFSocketDeinit(void) +_OFSocketDeinit(void) { - struct Library *socketBase = OFTLSKeyGet(OFSocketBaseKey); + struct Library *socketBase = OFTLSKeyGet(_OFSocketBaseKey); # ifdef OF_AMIGAOS4 - struct SocketIFace *socketInterface = OFTLSKeyGet(OFSocketInterfaceKey); + struct SocketIFace *socketInterface = + OFTLSKeyGet(_OFSocketInterfaceKey); if (socketInterface != NULL) DropInterface((struct Interface *)socketInterface); # endif if (socketBase != NULL) @@ -242,11 +243,11 @@ CloseLibrary(socketBase); } #endif int -OFSocketErrNo(void) +_OFSocketErrNo(void) { #if defined(OF_WINDOWS) switch (WSAGetLastError()) { case WSAEACCES: return EACCES; @@ -344,11 +345,11 @@ #endif } #ifndef OF_WII int -OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr, +_OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr, socklen_t *restrict addrLen) { int ret; # if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS)) Index: src/OFStrFTime.h ================================================================== --- src/OFStrFTime.h +++ src/OFStrFTime.h @@ -31,12 +31,12 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern size_t OFStrFTime(char *buffer, size_t bufferLen, const char *format, - struct tm *tm, short tz); +extern size_t _OFStrFTime(char *buffer, size_t bufferLen, const char *format, + struct tm *tm, short tz) OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFStrFTime.m ================================================================== --- src/OFStrFTime.m +++ src/OFStrFTime.m @@ -32,11 +32,11 @@ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; size_t -OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm, +_OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm, short tz) { enum { stateSearchConversionSpecifier, stateInConversionSpecifier Index: src/OFStrPTime.h ================================================================== --- src/OFStrPTime.h +++ src/OFStrPTime.h @@ -31,11 +31,12 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern const char *_Nullable OFStrPTime(const char *buffer, const char *format, +/* No OF_VISIBILITY_HIDDEN so tests can call it. */ +extern const char *_Nullable _OFStrPTime(const char *buffer, const char *format, struct tm *tm, short *_Nullable tz); #ifdef __cplusplus } #endif Index: src/OFStrPTime.m ================================================================== --- src/OFStrPTime.m +++ src/OFStrPTime.m @@ -23,11 +23,11 @@ #import "OFStrPTime.h" #import "macros.h" const char * -OFStrPTime(const char *buffer, const char *format, struct tm *tm, short *tz) +_OFStrPTime(const char *buffer, const char *format, struct tm *tm, short *tz) { enum { stateSearchConversionSpecifier, stateInConversionSpecifier } state = stateSearchConversionSpecifier; Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -1178,11 +1178,11 @@ int length; if (format == nil) @throw [OFInvalidArgumentException exception]; - if ((length = OFVASPrintF(&UTF8String, format.UTF8String, + if ((length = _OFVASPrintF(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { [self writeBuffer: UTF8String length: length]; Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -57,11 +57,11 @@ + (void)initialize { if (self != [OFStreamSocket class]) return; - if (!OFSocketInit()) + if (!_OFSocketInit()) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)socket @@ -117,20 +117,20 @@ #ifndef OF_WINDOWS if ((ret = recv(_socket, buffer, length, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if ((ret = recv(_socket, buffer, (int)length, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #endif if (ret == 0) _atEndOfStream = true; @@ -151,11 +151,11 @@ if ((bytesWritten = send(_socket, (void *)buffer, length, 0)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else int bytesWritten; if (length > INT_MAX) @throw [OFOutOfRangeException exception]; @@ -163,11 +163,11 @@ if ((bytesWritten = send(_socket, buffer, (int)length, 0)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #endif return (size_t)bytesWritten; } @@ -181,11 +181,11 @@ # endif if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = canBlock; } #endif @@ -225,11 +225,11 @@ int errNo; socklen_t len = sizeof(errNo); if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo, &len) != 0) - return OFSocketErrNo(); + return _OFSocketErrNo(); return errNo; } #endif @@ -245,11 +245,11 @@ if (listen(_socket, backlog) == -1) @throw [OFListenOnSocketFailedException exceptionWithSocket: self backlog: backlog - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _listening = true; } - (instancetype)accept @@ -273,26 +273,26 @@ (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) == OFInvalidSocketHandle) @throw [OFAcceptSocketFailedException exceptionWithSocket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) if ((client->_socket = accept4(_socket, (struct sockaddr * )&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, SOCK_CLOEXEC)) == OFInvalidSocketHandle) @throw [OFAcceptSocketFailedException exceptionWithSocket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; #else if ((client->_socket = accept(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length)) == OFInvalidSocketHandle) @throw [OFAcceptSocketFailedException exceptionWithSocket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif Index: src/OFString+CryptographicHashing.h ================================================================== --- src/OFString+CryptographicHashing.h +++ src/OFString+CryptographicHashing.h @@ -22,11 +22,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFString_CryptographicHashing_reference; +extern int _OFString_CryptographicHashing_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFString (CryptographicHashing) Index: src/OFString+JSONParsing.h ================================================================== --- src/OFString+JSONParsing.h +++ src/OFString+JSONParsing.h @@ -22,11 +22,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFString_JSONParsing_reference; +extern int _OFString_JSONParsing_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFString (JSONParsing) Index: src/OFString+JSONParsing.m ================================================================== --- src/OFString+JSONParsing.m +++ src/OFString+JSONParsing.m @@ -207,11 +207,11 @@ return nil; } /* Normal character */ if ((c1 & 0xFC00) != 0xD800) { - l = OFUTF8StringEncode(c1, buffer + i); + l = _OFUTF8StringEncode(c1, buffer + i); if (l == 0) { OFFreeMemory(buffer); return nil; } @@ -233,11 +233,11 @@ } c = (((c1 & 0x3FF) << 10) | (c2 & 0x3FF)) + 0x10000; - l = OFUTF8StringEncode(c, buffer + i); + l = _OFUTF8StringEncode(c, buffer + i); if (l == 0) { OFFreeMemory(buffer); return nil; } @@ -329,11 +329,11 @@ return nil; } /* Normal character */ if ((c1 & 0xFC00) != 0xD800) { - l = OFUTF8StringEncode(c1, buffer + i); + l = _OFUTF8StringEncode(c1, buffer + i); if (l == 0) { OFFreeMemory(buffer); return nil; } @@ -354,11 +354,11 @@ return nil; } c = (((c1 & 0x3FF) << 10) | (c2 & 0x3FF)) + 0x10000; - l = OFUTF8StringEncode(c, buffer + i); + l = _OFUTF8StringEncode(c, buffer + i); if (l == 0) { OFFreeMemory(buffer); return nil; } Index: src/OFString+PathAdditions.h ================================================================== --- src/OFString+PathAdditions.h +++ src/OFString+PathAdditions.h @@ -22,11 +22,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFString_PathAdditions_reference; +extern int _OFString_PathAdditions_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFString (PathAdditions) Index: src/OFString+PercentEncoding.h ================================================================== --- src/OFString+PercentEncoding.h +++ src/OFString+PercentEncoding.h @@ -24,11 +24,11 @@ @class OFCharacterSet; #ifdef __cplusplus extern "C" { #endif -extern int _OFString_PercentEncoding_reference; +extern int _OFString_PercentEncoding_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFString (PercentEncoding) Index: src/OFString+PercentEncoding.m ================================================================== --- src/OFString+PercentEncoding.m +++ src/OFString+PercentEncoding.m @@ -52,11 +52,11 @@ [ret appendCharacters: &c length: 1]; else { char buffer[4]; size_t bufferLen; - if ((bufferLen = OFUTF8StringEncode(c, buffer)) == 0) + if ((bufferLen = _OFUTF8StringEncode(c, buffer)) == 0) @throw [OFInvalidEncodingException exception]; for (size_t j = 0; j < bufferLen; j++) { unsigned char byte = buffer[j]; unsigned char high = byte >> 4; Index: src/OFString+PropertyListParsing.h ================================================================== --- src/OFString+PropertyListParsing.h +++ src/OFString+PropertyListParsing.h @@ -22,11 +22,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFString_PropertyListParsing_reference; +extern int _OFString_PropertyListParsing_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFString (PropertyListParsing) Index: src/OFString+XMLEscaping.h ================================================================== --- src/OFString+XMLEscaping.h +++ src/OFString+XMLEscaping.h @@ -22,11 +22,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFString_XMLEscaping_reference; +extern int _OFString_XMLEscaping_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif @interface OFString (XMLEscaping) Index: src/OFString+XMLUnescaping.h ================================================================== --- src/OFString+XMLUnescaping.h +++ src/OFString+XMLUnescaping.h @@ -24,11 +24,11 @@ /** @file */ #ifdef __cplusplus extern "C" { #endif -extern int _OFString_XMLUnescaping_reference; +extern int _OFString_XMLUnescaping_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif #ifdef OF_HAVE_BLOCKS Index: src/OFString+XMLUnescaping.m ================================================================== --- src/OFString+XMLUnescaping.m +++ src/OFString+XMLUnescaping.m @@ -66,11 +66,11 @@ else return nil; } } - if ((i = OFUTF8StringEncode(c, buffer)) == 0) + if ((i = _OFUTF8StringEncode(c, buffer)) == 0) return nil; buffer[i] = 0; return [OFString stringWithUTF8String: buffer length: i]; } Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -1333,15 +1333,30 @@ * @param encoding The encoding for which to return the name * @return The name of the specified OFStringEncoding */ extern OFString *_Nullable OFStringEncodingName(OFStringEncoding encoding); -extern char *_Nullable OFStrDup(const char *_Nonnull); -extern size_t OFUTF8StringEncode(OFUnichar, char *); -extern ssize_t OFUTF8StringDecode(const char *, size_t, OFUnichar *); -extern size_t OFUTF16StringLength(const OFChar16 *); -extern size_t OFUTF32StringLength(const OFChar32 *); +/** + * @brief Returns the length of the specified UTF-16 string. + * + * @param string The UTF-16 string + * @return The length of the specified UTF-16 string + */ +extern size_t OFUTF16StringLength(const OFChar16 *string); + +/** + * @brief Returns the length of the specified UTF-32 string. + * + * @param string The UTF-32 string + * @return The length of the specified UTF-32 string + */ +extern size_t OFUTF32StringLength(const OFChar32 *string); + +extern char *_Nullable _OFStrDup(const char *_Nonnull) OF_VISIBILITY_HIDDEN; +extern size_t _OFUTF8StringEncode(OFUnichar, char *) OF_VISIBILITY_HIDDEN; +extern ssize_t _OFUTF8StringDecode(const char *, size_t, OFUnichar *) + OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -102,35 +102,35 @@ @end @interface OFPlaceholderString: OFString @end -extern bool OFUnicodeToISO8859_2(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToISO8859_3(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToISO8859_15(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToWindows1251(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToWindows1252(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToCodepage437(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToCodepage850(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToCodepage858(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToMacRoman(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToKOI8R(const OFUnichar *, unsigned char *, - size_t, bool); -extern bool OFUnicodeToKOI8U(const OFUnichar *, unsigned char *, +extern bool _OFUnicodeToISO8859_2(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToISO8859_3(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToISO8859_15(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToWindows1251(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToWindows1252(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToCodepage437(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToCodepage850(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToCodepage858(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToMacRoman(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToKOI8R(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool _OFUnicodeToKOI8U(const OFUnichar *, unsigned char *, size_t, bool); /* References for static linking */ -void +void OF_VISIBILITY_HIDDEN _references_to_categories_of_OFString(void) { _OFString_CryptographicHashing_reference = 1; _OFString_JSONParsing_reference = 1; #ifdef OF_HAVE_FILES @@ -140,11 +140,11 @@ _OFString_PropertyListParsing_reference = 1; _OFString_XMLEscaping_reference = 1; _OFString_XMLUnescaping_reference = 1; } -void +void OF_VISIBILITY_HIDDEN _reference_to_OFConstantString(void) { [OFConstantString class]; } @@ -241,11 +241,11 @@ return nil; } size_t -OFUTF8StringEncode(OFUnichar character, char *buffer) +_OFUTF8StringEncode(OFUnichar character, char *buffer) { if (character < 0x80) { buffer[0] = character; return 1; } else if (character < 0x800) { @@ -267,11 +267,11 @@ return 0; } ssize_t -OFUTF8StringDecode(const char *buffer_, size_t length, OFUnichar *ret) +_OFUTF8StringDecode(const char *buffer_, size_t length, OFUnichar *ret) { const unsigned char *buffer = (const unsigned char *)buffer_; if (!(*buffer & 0x80)) { *ret = buffer[0]; @@ -339,11 +339,11 @@ return length; } char * -OFStrDup(const char *string) +_OFStrDup(const char *string) { size_t length = strlen(string); char *copy = (char *)OFAllocMemory(1, length + 1); memcpy(copy, string, length + 1); @@ -1060,11 +1060,11 @@ case OFStringEncodingUTF8:; size_t j = 0; for (i = 0; i < length; i++) { char buffer[4]; - size_t len = OFUTF8StringEncode(characters[i], buffer); + size_t len = _OFUTF8StringEncode(characters[i], buffer); /* * Check for one more than the current index, as we * need one for the terminating zero. */ @@ -1132,11 +1132,11 @@ #ifdef HAVE_ISO_8859_2 case OFStringEncodingISO8859_2: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToISO8859_2(characters, (unsigned char *)cString, + if (!_OFUnicodeToISO8859_2(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1145,11 +1145,11 @@ #ifdef HAVE_ISO_8859_3 case OFStringEncodingISO8859_3: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToISO8859_3(characters, (unsigned char *)cString, + if (!_OFUnicodeToISO8859_3(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1158,12 +1158,12 @@ #ifdef HAVE_ISO_8859_15 case OFStringEncodingISO8859_15: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToISO8859_15(characters, (unsigned char *)cString, - length, lossy)) + if (!_OFUnicodeToISO8859_15(characters, + (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; @@ -1171,11 +1171,11 @@ #ifdef HAVE_WINDOWS_1251 case OFStringEncodingWindows1251: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToWindows1251(characters, + if (!_OFUnicodeToWindows1251(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1184,11 +1184,11 @@ #ifdef HAVE_WINDOWS_1252 case OFStringEncodingWindows1252: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToWindows1252(characters, + if (!_OFUnicodeToWindows1252(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1197,11 +1197,11 @@ #ifdef HAVE_CODEPAGE_437 case OFStringEncodingCodepage437: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToCodepage437(characters, + if (!_OFUnicodeToCodepage437(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1210,11 +1210,11 @@ #ifdef HAVE_CODEPAGE_850 case OFStringEncodingCodepage850: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToCodepage850(characters, + if (!_OFUnicodeToCodepage850(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1223,11 +1223,11 @@ #ifdef HAVE_CODEPAGE_858 case OFStringEncodingCodepage858: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToCodepage858(characters, + if (!_OFUnicodeToCodepage858(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1236,11 +1236,11 @@ #ifdef HAVE_MAC_ROMAN case OFStringEncodingMacRoman: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToMacRoman(characters, (unsigned char *)cString, + if (!_OFUnicodeToMacRoman(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1249,11 +1249,11 @@ #ifdef HAVE_KOI8_R case OFStringEncodingKOI8R: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToKOI8R(characters, (unsigned char *)cString, + if (!_OFUnicodeToKOI8R(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1262,11 +1262,11 @@ #ifdef HAVE_KOI8_U case OFStringEncodingKOI8U: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!OFUnicodeToKOI8U(characters, (unsigned char *)cString, + if (!_OFUnicodeToKOI8U(characters, (unsigned char *)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; @@ -1399,11 +1399,11 @@ characters = self.characters; length = self.length; for (size_t i = 0; i < length; i++) { char buffer[4]; - size_t len = OFUTF8StringEncode(characters[i], buffer); + size_t len = _OFUTF8StringEncode(characters[i], buffer); if (len == 0) @throw [OFInvalidEncodingException exception]; UTF8StringLength += len; @@ -1552,20 +1552,20 @@ for (size_t i = 0; i < minimumLength; i++) { OFUnichar c = characters[i]; OFUnichar oc = otherCharacters[i]; #ifdef OF_HAVE_UNICODE_TABLES - if (c >> 8 < OFUnicodeCaseFoldingTableSize) { + if (c >> 8 < _OFUnicodeCaseFoldingTableSize) { OFUnichar tc = - OFUnicodeCaseFoldingTable[c >> 8][c & 0xFF]; + _OFUnicodeCaseFoldingTable[c >> 8][c & 0xFF]; if (tc) c = tc; } - if (oc >> 8 < OFUnicodeCaseFoldingTableSize) { + if (oc >> 8 < _OFUnicodeCaseFoldingTableSize) { OFUnichar tc = - OFUnicodeCaseFoldingTable[oc >> 8][oc & 0xFF]; + _OFUnicodeCaseFoldingTable[oc >> 8][oc & 0xFF]; if (tc) oc = tc; } #else Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -147,11 +147,11 @@ @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_socket = socket( ((struct sockaddr *)&address->sockaddr)->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) { - *errNo = OFSocketErrNo(); + *errNo = _OFSocketErrNo(); return false; } #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -168,11 +168,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; /* Cast needed for AmigaOS, where the argument is declared non-const */ if (connect(_socket, (struct sockaddr *)&address->sockaddr, address->length) != 0) { - *errNo = OFSocketErrNo(); + *errNo = _OFSocketErrNo(); return false; } return true; } @@ -321,11 +321,11 @@ SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -338,11 +338,11 @@ #if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) if (port != 0) { #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException @@ -365,12 +365,12 @@ if ((ret = bind(_socket, (struct sockaddr *)&address.sockaddr, address.length)) == 0) break; - if (OFSocketErrNo() != EADDRINUSE) { - int errNo = OFSocketErrNo(); + if (_OFSocketErrNo() != EADDRINUSE) { + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException @@ -385,13 +385,13 @@ #if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS) memset(&address, 0, sizeof(address)); address.length = (socklen_t)sizeof(address.sockaddr); - if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, + if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host @@ -433,11 +433,11 @@ if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; } - (bool)sendsKeepAlives { int v; @@ -445,11 +445,11 @@ if (getsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&v, &len) != 0 || len != sizeof(v)) @throw [OFGetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; return v; } #endif @@ -460,11 +460,11 @@ if (setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; } - (bool)canDelaySendingSegments { int v; @@ -472,11 +472,11 @@ if (getsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&v, &len) != 0 || len != sizeof(v)) @throw [OFGetOptionFailedException exceptionWithObject: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; return !v; } #endif Index: src/OFTLSKey.h ================================================================== --- src/OFTLSKey.h +++ src/OFTLSKey.h @@ -27,10 +27,12 @@ (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)) # error No thread-local storage available! #endif #import "macros.h" + +/** @file */ #if defined(OF_HAVE_PTHREADS) # include typedef pthread_key_t OFTLSKey; #elif defined(OF_WINDOWS) @@ -47,60 +49,85 @@ #endif #ifdef __cplusplus extern "C" { #endif +/** + * @brief Creates a new Thread Local Storage key. + * + * @param key A pointer to the key to create + * @return 0 on success, or an error number from `` on error + */ extern int OFTLSKeyNew(OFTLSKey *key); + +/** + * @brief Destroys the specified Thread Local Storage key. + * + * @param key A pointer to the key to destroy + * @return 0 on success, or an error number from `` on error + */ extern int OFTLSKeyFree(OFTLSKey key); #ifdef __cplusplus } #endif /* TLS keys are inlined for performance. */ -#if defined(OF_HAVE_PTHREADS) +#if defined(OF_HAVE_PTHREADS) || defined(DOXYGEN) +/** + * @brief Returns the current value for the specified Thread Local Storage key. + * + * @param key A pointer to the key whose value to return + * @return The current value for the specified Thread Local Storage key + */ static OF_INLINE void * OFTLSKeyGet(OFTLSKey key) { return pthread_getspecific(key); } +/** + * @brief Sets the current value for the specified Thread Local Storage key. + * + * @param key A pointer to the key whose value to set + * @param value The new value for the key + */ static OF_INLINE int -OFTLSKeySet(OFTLSKey key, void *ptr) +OFTLSKeySet(OFTLSKey key, void *value) { - return pthread_setspecific(key, ptr); + return pthread_setspecific(key, value); } #elif defined(OF_WINDOWS) static OF_INLINE void * OFTLSKeyGet(OFTLSKey key) { return TlsGetValue(key); } static OF_INLINE int -OFTLSKeySet(OFTLSKey key, void *ptr) +OFTLSKeySet(OFTLSKey key, void *value) { - return (TlsSetValue(key, ptr) ? 0 : EINVAL); + return (TlsSetValue(key, value) ? 0 : EINVAL); } #elif defined(OF_MORPHOS) static OF_INLINE void * OFTLSKeyGet(OFTLSKey key) { return (void *)TLSGetValue(key); } static OF_INLINE int -OFTLSKeySet(OFTLSKey key, void *ptr) +OFTLSKeySet(OFTLSKey key, void *value) { - return (TLSSetValue(key, (APTR)ptr) ? 0 : EINVAL); + return (TLSSetValue(key, (APTR)value) ? 0 : EINVAL); } #elif defined(OF_AMIGAOS) /* Those are too big too inline. */ # ifdef __cplusplus extern "C" { # endif extern void *OFTLSKeyGet(OFTLSKey key); -extern int OFTLSKeySet(OFTLSKey key, void *ptr); +extern int OFTLSKeySet(OFTLSKey key, void *value); # ifdef __cplusplus } # endif #endif Index: src/OFTLSStream.m ================================================================== --- src/OFTLSStream.m +++ src/OFTLSStream.m @@ -39,11 +39,11 @@ /* * References to exceptions. This is needed because they are only used by * subclasses that are in a different library. */ -void +void OF_VISIBILITY_HIDDEN _references_to_exceptions_of_OFTLSStream(void) { _OFTLSHandshakeFailedException_reference = 1; } Index: src/OFTaggedPointerDate.m ================================================================== --- src/OFTaggedPointerDate.m +++ src/OFTaggedPointerDate.m @@ -38,11 +38,11 @@ { uint64_t value = (uint64_t)object_getTaggedPointerValue(self); value |= UINT64_C(4) << 60; - return OFFromBigEndianDouble(OFRawUInt64ToDouble(OFToBigEndian64( + return OFFromBigEndianDouble(OFBitConvertUInt64ToDouble(OFToBigEndian64( value))); } OF_SINGLETON_METHODS @end Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -90,11 +90,11 @@ return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { - return OFArchiveIRIHandlerIRIForFileInArchive(@"tar", path, IRI); + return _OFArchiveIRIHandlerIRIForFileInArchive(@"tar", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -125,11 +125,11 @@ else OFSetThreadName(object_getClassName(thread)); #if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) if (thread.supportsSockets) - if (!OFSocketInit()) + if (!_OFSocketInit()) @throw [OFInitializationFailedException exceptionWithClass: thread.class]; #endif /* @@ -153,11 +153,11 @@ objc_autoreleasePoolPop(thread->_pool); #endif #if defined(OF_AMIGAOS) && !defined(OF_MORPHOS) && defined(OF_HAVE_SOCKETS) if (thread.supportsSockets) - OFSocketDeinit(); + _OFSocketDeinit(); #endif thread->_running = OFThreadStateWaitingForJoin; [thread release]; Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -60,11 +60,11 @@ SOCK_DGRAM | SOCK_CLOEXEC | extraType, 0)) == OFInvalidSocketHandle) @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) port: OFSocketAddressIPPort(address) socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) /* {} needed to avoid warning with Clang 10 if next #if is false. */ @@ -76,11 +76,11 @@ #if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) if (OFSocketAddressIPPort(address) != 0) { #endif if (bind(_socket, (struct sockaddr *)&address->sockaddr, address->length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException @@ -103,12 +103,12 @@ if ((ret = bind(_socket, (struct sockaddr *)&address->sockaddr, address->length)) == 0) break; - if (OFSocketErrNo() != EADDRINUSE) { - int errNo = OFSocketErrNo(); + if (_OFSocketErrNo() != EADDRINUSE) { + int errNo = _OFSocketErrNo(); OFString *host = OFSocketAddressString(address); uint16_t port = OFSocketAddressIPPort(address); closesocket(_socket); _socket = OFInvalidSocketHandle; @@ -128,13 +128,13 @@ port = OFSocketAddressIPPort(address); memset(address, 0, sizeof(*address)); address->length = (socklen_t)sizeof(address->sockaddr); - if (OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr, + if (_OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr, &address->length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host Index: src/OFUNIXDatagramSocket.m ================================================================== --- src/OFUNIXDatagramSocket.m +++ src/OFUNIXDatagramSocket.m @@ -54,11 +54,11 @@ if ((_socket = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -66,11 +66,11 @@ #endif if (path != nil) { if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindUNIXSocketFailedException Index: src/OFUNIXStreamSocket.m ================================================================== --- src/OFUNIXStreamSocket.m +++ src/OFUNIXStreamSocket.m @@ -50,11 +50,11 @@ if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFConnectUNIXSocketFailedException exceptionWithPath: path socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -61,11 +61,11 @@ fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (connect(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFConnectUNIXSocketFailedException @@ -90,11 +90,11 @@ if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self - errNo: OFSocketErrNo()]; + errNo: _OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) @@ -101,11 +101,11 @@ fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { - int errNo = OFSocketErrNo(); + int errNo = _OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindUNIXSocketFailedException Index: src/OFUTF8String.h ================================================================== --- src/OFUTF8String.h +++ src/OFUTF8String.h @@ -44,12 +44,14 @@ @end #ifdef __cplusplus extern "C" { #endif -extern int OFUTF8StringCheck(const char *, size_t, size_t *); -extern size_t OFUTF8StringIndexToPosition(const char *, size_t, size_t); +extern int _OFUTF8StringCheck(const char *, size_t, size_t *) + OF_VISIBILITY_HIDDEN; +extern size_t _OFUTF8StringIndexToPosition(const char *, size_t, size_t) + OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFUTF8String.m ================================================================== --- src/OFUTF8String.m +++ src/OFUTF8String.m @@ -41,32 +41,32 @@ #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "unicode.h" -extern const OFChar16 OFISO8859_2Table[]; -extern const size_t OFISO8859_2TableOffset; -extern const OFChar16 OFISO8859_3Table[]; -extern const size_t OFISO8859_3TableOffset; -extern const OFChar16 OFISO8859_15Table[]; -extern const size_t OFISO8859_15TableOffset; -extern const OFChar16 OFWindows1251Table[]; -extern const size_t OFWindows1251TableOffset; -extern const OFChar16 OFWindows1252Table[]; -extern const size_t OFWindows1252TableOffset; -extern const OFChar16 OFCodepage437Table[]; -extern const size_t OFCodepage437TableOffset; -extern const OFChar16 OFCodepage850Table[]; -extern const size_t OFCodepage850TableOffset; -extern const OFChar16 OFCodepage858Table[]; -extern const size_t OFCodepage858TableOffset; -extern const OFChar16 OFMacRomanTable[]; -extern const size_t OFMacRomanTableOffset; -extern const OFChar16 OFKOI8RTable[]; -extern const size_t OFKOI8RTableOffset; -extern const OFChar16 OFKOI8UTable[]; -extern const size_t OFKOI8UTableOffset; +extern const OFChar16 _OFISO8859_2Table[]; +extern const size_t _OFISO8859_2TableOffset; +extern const OFChar16 _OFISO8859_3Table[]; +extern const size_t _OFISO8859_3TableOffset; +extern const OFChar16 _OFISO8859_15Table[]; +extern const size_t _OFISO8859_15TableOffset; +extern const OFChar16 _OFWindows1251Table[]; +extern const size_t _OFWindows1251TableOffset; +extern const OFChar16 _OFWindows1252Table[]; +extern const size_t _OFWindows1252TableOffset; +extern const OFChar16 _OFCodepage437Table[]; +extern const size_t _OFCodepage437TableOffset; +extern const OFChar16 _OFCodepage850Table[]; +extern const size_t _OFCodepage850TableOffset; +extern const OFChar16 _OFCodepage858Table[]; +extern const size_t _OFCodepage858TableOffset; +extern const OFChar16 _OFMacRomanTable[]; +extern const size_t _OFMacRomanTableOffset; +extern const OFChar16 _OFKOI8RTable[]; +extern const size_t _OFKOI8RTableOffset; +extern const OFChar16 _OFKOI8UTable[]; +extern const size_t _OFKOI8UTableOffset; static inline int memcasecmp(const char *first, const char *second, size_t length) { for (size_t i = 0; i < length; i++) { @@ -84,11 +84,11 @@ return OFOrderedSame; } int -OFUTF8StringCheck(const char *UTF8String, size_t UTF8Length, size_t *length) +_OFUTF8StringCheck(const char *UTF8String, size_t UTF8Length, size_t *length) { size_t tmpLength = UTF8Length; int isUTF8 = 0; for (size_t i = 0; i < UTF8Length; i++) { @@ -150,11 +150,11 @@ *length = tmpLength; return isUTF8; } -size_t +static size_t positionToIndex(const char *string, size_t position) { size_t idx = position; for (size_t i = 0; i < position; i++) @@ -163,11 +163,11 @@ return idx; } size_t -OFUTF8StringIndexToPosition(const char *string, size_t idx, size_t length) +_OFUTF8StringIndexToPosition(const char *string, size_t idx, size_t length) { for (size_t i = 0; i <= idx; i++) if OF_UNLIKELY ((string[i] & 0xC0) == 0x80) if (++idx > length) @throw [OFInvalidFormatException exception]; @@ -209,11 +209,11 @@ _s = &_storage; _s->cString = storage; _s->cStringLength = UTF8StringLength; - switch (OFUTF8StringCheck(UTF8String, UTF8StringLength, + switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, &_s->length)) { case 1: _s->isUTF8 = true; break; case -1: @@ -253,11 +253,11 @@ _s->cStringLength = cStringLength; _s->freeWhenDone = true; if (encoding == OFStringEncodingUTF8 || encoding == OFStringEncodingASCII) { - switch (OFUTF8StringCheck(cString, cStringLength, + switch (_OFUTF8StringCheck(cString, cStringLength, &_s->length)) { case 1: if (encoding == OFStringEncodingASCII) @throw [OFInvalidEncodingException exception]; @@ -287,11 +287,11 @@ _s->cString[j++] = cString[i]; continue; } _s->isUTF8 = true; - bytes = OFUTF8StringEncode( + bytes = _OFUTF8StringEncode( (uint8_t)cString[i], buffer); if (bytes == 0) @throw [OFInvalidEncodingException exception]; @@ -314,41 +314,41 @@ case encoding: \ table = var; \ tableOffset = var##Offset; \ break; #ifdef HAVE_ISO_8859_2 - CASE(OFStringEncodingISO8859_2, OFISO8859_2Table) + CASE(OFStringEncodingISO8859_2, _OFISO8859_2Table) #endif #ifdef HAVE_ISO_8859_3 - CASE(OFStringEncodingISO8859_3, OFISO8859_3Table) + CASE(OFStringEncodingISO8859_3, _OFISO8859_3Table) #endif #ifdef HAVE_ISO_8859_15 - CASE(OFStringEncodingISO8859_15, OFISO8859_15Table) + CASE(OFStringEncodingISO8859_15, _OFISO8859_15Table) #endif #ifdef HAVE_WINDOWS_1251 - CASE(OFStringEncodingWindows1251, OFWindows1251Table) + CASE(OFStringEncodingWindows1251, _OFWindows1251Table) #endif #ifdef HAVE_WINDOWS_1252 - CASE(OFStringEncodingWindows1252, OFWindows1252Table) + CASE(OFStringEncodingWindows1252, _OFWindows1252Table) #endif #ifdef HAVE_CODEPAGE_437 - CASE(OFStringEncodingCodepage437, OFCodepage437Table) + CASE(OFStringEncodingCodepage437, _OFCodepage437Table) #endif #ifdef HAVE_CODEPAGE_850 - CASE(OFStringEncodingCodepage850, OFCodepage850Table) + CASE(OFStringEncodingCodepage850, _OFCodepage850Table) #endif #ifdef HAVE_CODEPAGE_858 - CASE(OFStringEncodingCodepage858, OFCodepage858Table) + CASE(OFStringEncodingCodepage858, _OFCodepage858Table) #endif #ifdef HAVE_MAC_ROMAN - CASE(OFStringEncodingMacRoman, OFMacRomanTable) + CASE(OFStringEncodingMacRoman, _OFMacRomanTable) #endif #ifdef HAVE_KOI8_R - CASE(OFStringEncodingKOI8R, OFKOI8RTable) + CASE(OFStringEncodingKOI8R, _OFKOI8RTable) #endif #ifdef HAVE_KOI8_U - CASE(OFStringEncodingKOI8U, OFKOI8UTable) + CASE(OFStringEncodingKOI8U, _OFKOI8UTable) #endif #undef CASE default: @throw [OFInvalidArgumentException exception]; } @@ -369,11 +369,11 @@ if (unichar == 0xFFFF) @throw [OFInvalidEncodingException exception]; _s->isUTF8 = true; - byteLength = OFUTF8StringEncode(unichar, buffer); + byteLength = _OFUTF8StringEncode(unichar, buffer); if (byteLength == 0) @throw [OFInvalidEncodingException exception]; _s->cStringLength += byteLength - 1; @@ -415,11 +415,11 @@ memcmp(UTF8String, "\xEF\xBB\xBF", 3) == 0) { UTF8String += 3; UTF8StringLength -= 3; } - switch (OFUTF8StringCheck(UTF8String, UTF8StringLength, + switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, &_s->length)) { case 1: _s->isUTF8 = true; break; case -1: @@ -479,11 +479,11 @@ _s->length = length; _s->freeWhenDone = true; j = 0; for (size_t i = 0; i < length; i++) { - size_t len = OFUTF8StringEncode(characters[i], + size_t len = _OFUTF8StringEncode(characters[i], _s->cString + j); if (len == 0) @throw [OFInvalidEncodingException exception]; @@ -565,11 +565,11 @@ i++; _s->length--; } - len = OFUTF8StringEncode(character, _s->cString + j); + len = _OFUTF8StringEncode(character, _s->cString + j); if (len == 0) @throw [OFInvalidEncodingException exception]; if (len > 1) @@ -621,11 +621,11 @@ _s->freeWhenDone = true; j = 0; for (size_t i = 0; i < length; i++) { char buffer[4]; - size_t len = OFUTF8StringEncode((swap + size_t len = _OFUTF8StringEncode((swap ? OFByteSwap32(characters[i]) : characters[i]), buffer); switch (len) { @@ -674,18 +674,18 @@ if (format == nil) @throw [OFInvalidArgumentException exception]; _s = &_storage; - if ((cStringLength = OFVASPrintF(&tmp, format.UTF8String, + if ((cStringLength = _OFVASPrintF(&tmp, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; _s->cStringLength = cStringLength; @try { - switch (OFUTF8StringCheck(tmp, cStringLength, + switch (_OFUTF8StringCheck(tmp, cStringLength, &_s->length)) { case 1: _s->isUTF8 = true; break; case -1: @@ -875,29 +875,29 @@ while (i < _s->cStringLength && j < otherCStringLength) { OFUnichar c1, c2; ssize_t l1, l2; - l1 = OFUTF8StringDecode(_s->cString + i, + l1 = _OFUTF8StringDecode(_s->cString + i, _s->cStringLength - i, &c1); - l2 = OFUTF8StringDecode(otherCString + j, + l2 = _OFUTF8StringDecode(otherCString + j, otherCStringLength - j, &c2); if (l1 <= 0 || l2 <= 0 || c1 > 0x10FFFF || c2 > 0x10FFFF) @throw [OFInvalidEncodingException exception]; - if (c1 >> 8 < OFUnicodeCaseFoldingTableSize) { + if (c1 >> 8 < _OFUnicodeCaseFoldingTableSize) { OFUnichar tc = - OFUnicodeCaseFoldingTable[c1 >> 8][c1 & 0xFF]; + _OFUnicodeCaseFoldingTable[c1 >> 8][c1 & 0xFF]; if (tc) c1 = tc; } - if (c2 >> 8 < OFUnicodeCaseFoldingTableSize) { + if (c2 >> 8 < _OFUnicodeCaseFoldingTableSize) { OFUnichar tc = - OFUnicodeCaseFoldingTable[c2 >> 8][c2 & 0xFF]; + _OFUnicodeCaseFoldingTable[c2 >> 8][c2 & 0xFF]; if (tc) c2 = tc; } @@ -930,11 +930,11 @@ for (size_t i = 0; i < _s->cStringLength; i++) { OFUnichar c; ssize_t length; - if ((length = OFUTF8StringDecode(_s->cString + i, + if ((length = _OFUTF8StringDecode(_s->cString + i, _s->cStringLength - i, &c)) <= 0) @throw [OFInvalidEncodingException exception]; OFHashAddByte(&hash, (c & 0xFF0000) >> 16); OFHashAddByte(&hash, (c & 0x00FF00) >> 8); @@ -959,13 +959,13 @@ @throw [OFOutOfRangeException exception]; if (!_s->isUTF8) return _s->cString[idx]; - idx = OFUTF8StringIndexToPosition(_s->cString, idx, _s->cStringLength); + idx = _OFUTF8StringIndexToPosition(_s->cString, idx, _s->cStringLength); - if (OFUTF8StringDecode(_s->cString + idx, _s->cStringLength - idx, + if (_OFUTF8StringDecode(_s->cString + idx, _s->cStringLength - idx, &character) <= 0) @throw [OFInvalidEncodingException exception]; return character; } @@ -997,13 +997,13 @@ if (range.length > SIZE_MAX - range.location || range.location + range.length > _s->length) @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { - rangeLocation = OFUTF8StringIndexToPosition( + rangeLocation = _OFUTF8StringIndexToPosition( _s->cString, range.location, _s->cStringLength); - rangeLength = OFUTF8StringIndexToPosition( + rangeLength = _OFUTF8StringIndexToPosition( _s->cString + rangeLocation, range.length, _s->cStringLength - rangeLocation); } else { rangeLocation = range.location; rangeLength = range.length; @@ -1071,13 +1071,13 @@ if (range.length > SIZE_MAX - range.location || end > _s->length) @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { - start = OFUTF8StringIndexToPosition(_s->cString, start, + start = _OFUTF8StringIndexToPosition(_s->cString, start, _s->cStringLength); - end = OFUTF8StringIndexToPosition(_s->cString, end, + end = _OFUTF8StringIndexToPosition(_s->cString, end, _s->cStringLength); } return [OFString stringWithUTF8String: _s->cString + start length: end - start]; @@ -1165,11 +1165,11 @@ while (i < _s->cStringLength) { OFUnichar c; ssize_t cLen; - cLen = OFUTF8StringDecode(_s->cString + i, + cLen = _OFUTF8StringDecode(_s->cString + i, _s->cStringLength - i, &c); if (cLen <= 0 || c > 0x10FFFF) { OFFreeMemory(buffer); @throw [OFInvalidEncodingException exception]; @@ -1200,11 +1200,11 @@ while (i < _s->cStringLength) { OFChar32 c; ssize_t cLen; - cLen = OFUTF8StringDecode(_s->cString + i, + cLen = _OFUTF8StringDecode(_s->cString + i, _s->cStringLength - i, &c); if (cLen <= 0 || c > 0x10FFFF) { OFFreeMemory(buffer); @throw [OFInvalidEncodingException exception]; Index: src/OFZIPArchive.h ================================================================== --- src/OFZIPArchive.h +++ src/OFZIPArchive.h @@ -242,14 +242,14 @@ @end #ifdef __cplusplus extern "C" { #endif -extern uint32_t OFZIPArchiveReadField32(const uint8_t *_Nonnull *_Nonnull, - uint16_t *_Nonnull); -extern uint64_t OFZIPArchiveReadField64(const uint8_t *_Nonnull *_Nonnull, - uint16_t *_Nonnull); +extern uint32_t _OFZIPArchiveReadField32(const uint8_t *_Nonnull *_Nonnull, + uint16_t *_Nonnull) OF_VISIBILITY_HIDDEN; +extern uint64_t _OFZIPArchiveReadField64(const uint8_t *_Nonnull *_Nonnull, + uint16_t *_Nonnull) OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -119,11 +119,11 @@ CRC32Offset: (OFStreamOffset)CRC32Offset size64Offset: (OFStreamOffset)size64Offset; @end uint32_t -OFZIPArchiveReadField32(const uint8_t **data, uint16_t *size) +_OFZIPArchiveReadField32(const uint8_t **data, uint16_t *size) { uint32_t field = 0; if (*size < 4) @throw [OFInvalidFormatException exception]; @@ -136,11 +136,11 @@ return field; } uint64_t -OFZIPArchiveReadField64(const uint8_t **data, uint16_t *size) +_OFZIPArchiveReadField64(const uint8_t **data, uint16_t *size) { uint64_t field = 0; if (*size < 8) @throw [OFInvalidFormatException exception]; @@ -201,11 +201,11 @@ return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { - return OFArchiveIRIHandlerIRIForFileInArchive(@"zip", path, IRI); + return _OFArchiveIRIHandlerIRIForFileInArchive(@"zip", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD @@ -746,14 +746,14 @@ [extraField itemAtIndex: ZIP64Index]; OFRange range = OFMakeRange(ZIP64Index - 4, ZIP64Size + 4); if (_uncompressedSize == 0xFFFFFFFF) - _uncompressedSize = OFZIPArchiveReadField64( + _uncompressedSize = _OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (_compressedSize == 0xFFFFFFFF) - _compressedSize = OFZIPArchiveReadField64( + _compressedSize = _OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (ZIP64Size > 0) @throw [OFInvalidFormatException exception]; @@ -922,11 +922,11 @@ length = (size_t)_toRead; ret = [_decompressedStream readIntoBuffer: buffer length: length]; _toRead -= ret; - _CRC32 = OFCRC32(_CRC32, buffer, ret); + _CRC32 = _OFCRC32(_CRC32, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; if (~_CRC32 != _entry.CRC32) { @@ -1015,20 +1015,20 @@ [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); _bytesWritten += (unsigned long long)e.bytesWritten; - _CRC32 = OFCRC32(_CRC32, buffer, e.bytesWritten); + _CRC32 = _OFCRC32(_CRC32, buffer, e.bytesWritten); if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } _bytesWritten += (unsigned long long)length; - _CRC32 = OFCRC32(_CRC32, buffer, length); + _CRC32 = _OFCRC32(_CRC32, buffer, length); return length; } - (void)close Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -246,20 +246,21 @@ [extraField itemAtIndex: ZIP64Index]; OFRange range = OFMakeRange(ZIP64Index - 4, ZIP64Size + 4); if (_uncompressedSize == 0xFFFFFFFF) - _uncompressedSize = OFZIPArchiveReadField64( + _uncompressedSize = _OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (_compressedSize == 0xFFFFFFFF) - _compressedSize = OFZIPArchiveReadField64( + _compressedSize = _OFZIPArchiveReadField64( &ZIP64, &ZIP64Size); if (_localFileHeaderOffset == 0xFFFFFFFF) _localFileHeaderOffset = - OFZIPArchiveReadField64(&ZIP64, &ZIP64Size); + _OFZIPArchiveReadField64(&ZIP64, + &ZIP64Size); if (_startDiskNumber == 0xFFFF) - _startDiskNumber = OFZIPArchiveReadField32( + _startDiskNumber = _OFZIPArchiveReadField32( &ZIP64, &ZIP64Size); if (ZIP64Size > 0 || _localFileHeaderOffset < 0) @throw [OFInvalidFormatException exception]; Index: src/OFZooArchive.m ================================================================== --- src/OFZooArchive.m +++ src/OFZooArchive.m @@ -107,11 +107,11 @@ return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { - return OFArchiveIRIHandlerIRIForFileInArchive(@"zoo", path, IRI); + return _OFArchiveIRIHandlerIRIForFileInArchive(@"zoo", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD @@ -307,11 +307,11 @@ tmp32 = OFToLittleEndian32((uint32_t)offset); memcpy(buffer + 6, &tmp32, 4); tmp16 = OFToLittleEndian16( - OFCRC16(0, buffer, _lastHeaderLength)); + _OFCRC16(0, buffer, _lastHeaderLength)); memcpy(buffer + 54, &tmp16, 2); [_stream seekToOffset: _lastHeaderOffset whence: OFSeekSet]; [_stream writeBuffer: buffer length: _lastHeaderLength]; @@ -493,11 +493,11 @@ length = (size_t)_toRead; ret = [_decompressedStream readIntoBuffer: buffer length: length]; _toRead -= ret; - _CRC16 = OFCRC16(_CRC16, buffer, ret); + _CRC16 = _OFCRC16(_CRC16, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; if (_CRC16 != _entry.CRC16) { @@ -604,20 +604,20 @@ [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); _bytesWritten += (uint32_t)e.bytesWritten; - _CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten); + _CRC16 = _OFCRC16(_CRC16, buffer, e.bytesWritten); if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } _bytesWritten += (uint32_t)length; - _CRC16 = OFCRC16(_CRC16, buffer, length); + _CRC16 = _OFCRC16(_CRC16, buffer, length); return length; } - (bool)lowlevelIsAtEndOfStream Index: src/bridge/NSArray+OFObject.h ================================================================== --- src/bridge/NSArray+OFObject.h +++ src/bridge/NSArray+OFObject.h @@ -26,11 +26,11 @@ @class OFArray OF_GENERIC(ObjectType); #ifdef __cplusplus extern "C" { #endif -extern int _NSArray_OFObject_reference; +extern int _NSArray_OFObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/NSDictionary+OFObject.h ================================================================== --- src/bridge/NSDictionary+OFObject.h +++ src/bridge/NSDictionary+OFObject.h @@ -26,11 +26,11 @@ @class OFDictionary OF_GENERIC(KeyType, ObjectType); #ifdef __cplusplus extern "C" { #endif -extern int _NSDictionary_OFObject_reference; +extern int _NSDictionary_OFObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/NSEnumerator+OFObject.h ================================================================== --- src/bridge/NSEnumerator+OFObject.h +++ src/bridge/NSEnumerator+OFObject.h @@ -26,11 +26,11 @@ @class OFEnumerator OF_GENERIC(ObjectType); #ifdef __cplusplus extern "C" { #endif -extern int _NSEnumerator_OFObject_reference; +extern int _NSEnumerator_OFObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/NSNumber+OFObject.h ================================================================== --- src/bridge/NSNumber+OFObject.h +++ src/bridge/NSNumber+OFObject.h @@ -26,11 +26,11 @@ @class OFNumber; #ifdef __cplusplus extern "C" { #endif -extern int _NSNumber_OFObject_reference; +extern int _NSNumber_OFObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/NSSet+OFObject.h ================================================================== --- src/bridge/NSSet+OFObject.h +++ src/bridge/NSSet+OFObject.h @@ -26,11 +26,11 @@ @class OFSet OF_GENERIC(ObjectType); #ifdef __cplusplus extern "C" { #endif -extern int _NSSet_OFObject_reference; +extern int _NSSet_OFObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/NSString+OFObject.h ================================================================== --- src/bridge/NSString+OFObject.h +++ src/bridge/NSString+OFObject.h @@ -26,11 +26,11 @@ @class OFString; #ifdef __cplusplus extern "C" { #endif -extern int _NSString_OFObject_reference; +extern int _NSString_OFObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/OFArray+NSObject.h ================================================================== --- src/bridge/OFArray+NSObject.h +++ src/bridge/OFArray+NSObject.h @@ -32,11 +32,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFArray_NSObject_reference; +extern int _OFArray_NSObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/OFDictionary+NSObject.h ================================================================== --- src/bridge/OFDictionary+NSObject.h +++ src/bridge/OFDictionary+NSObject.h @@ -32,11 +32,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFDictionary_NSObject_reference; +extern int _OFDictionary_NSObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/OFEnumerator+NSObject.h ================================================================== --- src/bridge/OFEnumerator+NSObject.h +++ src/bridge/OFEnumerator+NSObject.h @@ -32,11 +32,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFEnumerator_NSObject_reference; +extern int _OFEnumerator_NSObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/OFNumber+NSObject.h ================================================================== --- src/bridge/OFNumber+NSObject.h +++ src/bridge/OFNumber+NSObject.h @@ -32,11 +32,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFNumber_NSObject_reference; +extern int _OFNumber_NSObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/OFSet+NSObject.h ================================================================== --- src/bridge/OFSet+NSObject.h +++ src/bridge/OFSet+NSObject.h @@ -32,11 +32,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFSet_NSObject_reference; +extern int _OFSet_NSObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/bridge/OFString+NSObject.h ================================================================== --- src/bridge/OFString+NSObject.h +++ src/bridge/OFString+NSObject.h @@ -32,11 +32,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFString_NSObject_reference; +extern int _OFString_NSObject_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/encodings/codepage-437.m ================================================================== --- src/encodings/codepage-437.m +++ src/encodings/codepage-437.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFCodepage437Table[] = { +const OFChar16 _OFCodepage437Table[] OF_VISIBILITY_HIDDEN = { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, @@ -39,12 +39,12 @@ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 }; -const size_t OFCodepage437TableOffset = - 256 - (sizeof(OFCodepage437Table) / sizeof(*OFCodepage437Table)); +const size_t _OFCodepage437TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFCodepage437Table) / sizeof(*_OFCodepage437Table)); static const unsigned char page0[] = { 0xFF, 0xAD, 0x9B, 0x9C, 0x00, 0x9D, 0x00, 0x00, 0x00, 0x00, 0xA6, 0xAE, 0xAA, 0x00, 0x00, 0x00, 0xF8, 0xF1, 0xFD, 0x00, 0x00, 0xE6, 0x00, 0xFA, @@ -130,12 +130,12 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE }; static const uint8_t page25Start = 0x00; -bool -OFUnicodeToCodepage437(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToCodepage437(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/codepage-850.m ================================================================== --- src/encodings/codepage-850.m +++ src/encodings/codepage-850.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFCodepage850Table[] = { +const OFChar16 _OFCodepage850Table[] OF_VISIBILITY_HIDDEN = { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, @@ -39,13 +39,12 @@ 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 }; -const size_t OFCodepage850TableOffset = - 256 - (sizeof(OFCodepage850Table) / sizeof(*OFCodepage850Table)); - +const size_t _OFCodepage850TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFCodepage850Table) / sizeof(*_OFCodepage850Table)); static const unsigned char page0[] = { 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5, 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE, 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA, @@ -106,12 +105,12 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE }; static const uint8_t page25Start = 0x00; -bool -OFUnicodeToCodepage850(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToCodepage850(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/codepage-858.m ================================================================== --- src/encodings/codepage-858.m +++ src/encodings/codepage-858.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFCodepage858Table[] = { +const OFChar16 _OFCodepage858Table[] OF_VISIBILITY_HIDDEN = { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192, 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, @@ -39,13 +39,12 @@ 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0 }; -const size_t OFCodepage858TableOffset = - 256 - (sizeof(OFCodepage858Table) / sizeof(*OFCodepage858Table)); - +const size_t _OFCodepage858TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFCodepage858Table) / sizeof(*_OFCodepage858Table)); static const unsigned char page0[] = { 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5, 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE, 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA, @@ -112,12 +111,12 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE }; static const uint8_t page25Start = 0x00; -bool -OFUnicodeToCodepage858(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToCodepage858(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/iso-8859-15.m ================================================================== --- src/encodings/iso-8859-15.m +++ src/encodings/iso-8859-15.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFISO8859_15Table[] = { +const OFChar16 _OFISO8859_15Table[] OF_VISIBILITY_HIDDEN = { 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AC, 0x00A5, 0x0160, 0x00A7, 0x0161, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x017D, 0x00B5, 0x00B6, 0x00B7, 0x017E, 0x00B9, 0x00BA, 0x00BB, 0x0152, 0x0153, 0x0178, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, @@ -35,12 +35,12 @@ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF }; -const size_t OFISO8859_15TableOffset = - 256 - (sizeof(OFISO8859_15Table) / sizeof(*OFISO8859_15Table)); +const size_t _OFISO8859_15TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFISO8859_15Table) / sizeof(*_OFISO8859_15Table)); static const unsigned char page0[] = { 0x00, 0xA5, 0x00, 0xA7, 0x00, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0x00, 0xB5, 0xB6, 0xB7, 0x00, 0xB9, 0xBA, 0xBB, @@ -61,12 +61,12 @@ static const unsigned char page20[] = { 0xA4 }; static const uint8_t page20Start = 0xAC; -bool -OFUnicodeToISO8859_15(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToISO8859_15(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/iso-8859-2.m ================================================================== --- src/encodings/iso-8859-2.m +++ src/encodings/iso-8859-2.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFISO8859_2Table[] = { +const OFChar16 _OFISO8859_2Table[] OF_VISIBILITY_HIDDEN = { 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, @@ -35,12 +35,12 @@ 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 }; -const size_t OFISO8859_2TableOffset = - 256 - (sizeof(OFISO8859_2Table) / sizeof(*OFISO8859_2Table)); +const size_t _OFISO8859_2TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFISO8859_2Table) / sizeof(*_OFISO8859_2Table)); static const unsigned char page0[] = { 0xA0, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00, 0xA7, 0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00, @@ -81,12 +81,12 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xFF, 0x00, 0xB2, 0x00, 0xBD }; static const uint8_t page2Start = 0xC7; -bool -OFUnicodeToISO8859_2(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToISO8859_2(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/iso-8859-3.m ================================================================== --- src/encodings/iso-8859-3.m +++ src/encodings/iso-8859-3.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFISO8859_3Table[] = { +const OFChar16 _OFISO8859_3Table[] OF_VISIBILITY_HIDDEN = { 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0xFFFF, 0x0124, 0x00A7, 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0xFFFF, 0x017B, 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7, 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0xFFFF, 0x017C, 0x00C0, 0x00C1, 0x00C2, 0xFFFF, 0x00C4, 0x010A, 0x0108, 0x00C7, @@ -35,12 +35,12 @@ 0x00E0, 0x00E1, 0x00E2, 0xFFFF, 0x00E4, 0x010B, 0x0109, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0xFFFF, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7, 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9 }; -const size_t OFISO8859_3TableOffset = - 256 - (sizeof(OFISO8859_3Table) / sizeof(*OFISO8859_3Table)); +const size_t _OFISO8859_3TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFISO8859_3Table) / sizeof(*_OFISO8859_3Table)); static const unsigned char page0[] = { 0xA0, 0x00, 0x00, 0xA3, 0xA4, 0x00, 0x00, 0xA7, 0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00, 0xB0, 0x00, 0xB2, 0xB3, 0xB4, 0xB5, 0x00, 0xB7, @@ -78,12 +78,12 @@ static const unsigned char page2[] = { 0xA2, 0xFF }; static const uint8_t page2Start = 0xD8; -bool -OFUnicodeToISO8859_3(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToISO8859_3(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/koi8-r.m ================================================================== --- src/encodings/koi8-r.m +++ src/encodings/koi8-r.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFKOI8RTable[] = { +const OFChar16 _OFKOI8RTable[] OF_VISIBILITY_HIDDEN = { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7, 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, @@ -39,12 +39,12 @@ 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A }; -const size_t OFKOI8RTableOffset = - 256 - (sizeof(OFKOI8RTable) / sizeof(*OFKOI8RTable)); +const size_t _OFKOI8RTableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFKOI8RTable) / sizeof(*_OFKOI8RTable)); static const unsigned char page0[] = { 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x00, 0x9D, 0x00, 0x00, 0x00, 0x00, 0x9E, @@ -116,12 +116,12 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94 }; static const uint8_t page25Start = 0x00; -bool -OFUnicodeToKOI8R(const OFUnichar *input, unsigned char *output, size_t length, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToKOI8R(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/koi8-u.m ================================================================== --- src/encodings/koi8-u.m +++ src/encodings/koi8-u.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFKOI8UTable[] = { +const OFChar16 _OFKOI8UTable[] OF_VISIBILITY_HIDDEN = { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7, 0x2550, 0x2551, 0x2552, 0x0451, 0x0454, 0x2554, 0x0456, 0x0457, @@ -39,12 +39,12 @@ 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A }; -const size_t OFKOI8UTableOffset = - 256 - (sizeof(OFKOI8UTable) / sizeof(*OFKOI8UTable)); +const size_t _OFKOI8UTableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFKOI8UTable) / sizeof(*_OFKOI8UTable)); static const unsigned char page0[] = { 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x00, 0x9D, 0x00, 0x00, 0x00, 0x00, 0x9E, @@ -124,12 +124,12 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94 }; static const uint8_t page25Start = 0x00; -bool -OFUnicodeToKOI8U(const OFUnichar *input, unsigned char *output, size_t length, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToKOI8U(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/mac-roman.m ================================================================== --- src/encodings/mac-roman.m +++ src/encodings/mac-roman.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFMacRomanTable[] = { +const OFChar16 _OFMacRomanTable[] OF_VISIBILITY_HIDDEN = { 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3, 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC, 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF, @@ -39,12 +39,12 @@ 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4, 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC, 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7 }; -const size_t OFMacRomanTableOffset = - 256 - (sizeof(OFMacRomanTable) / sizeof(*OFMacRomanTable)); +const size_t _OFMacRomanTableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFMacRomanTable) / sizeof(*_OFMacRomanTable)); static const unsigned char page0[] = { 0xCA, 0xC1, 0xA2, 0xA3, 0x00, 0xB4, 0x00, 0xA4, 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8, 0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1, @@ -150,12 +150,12 @@ static const unsigned char pageFB[] = { 0xDE, 0xDF }; static const uint8_t pageFBStart = 0x01; -bool -OFUnicodeToMacRoman(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToMacRoman(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/windows-1251.m ================================================================== --- src/encodings/windows-1251.m +++ src/encodings/windows-1251.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFWindows1251Table[] = { +const OFChar16 _OFWindows1251Table[] OF_VISIBILITY_HIDDEN = { 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, 0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0xFFFF, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F, 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7, @@ -39,12 +39,12 @@ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F }; -const size_t OFWindows1251TableOffset = - 256 - (sizeof(OFWindows1251Table) / sizeof(*OFWindows1251Table)); +const size_t _OFWindows1251TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFWindows1251Table) / sizeof(*_OFWindows1251Table)); static const unsigned char page0[] = { 0xA0, 0x00, 0x00, 0x00, 0xA4, 0x00, 0xA6, 0xA7, 0x00, 0xA9, 0x00, 0xAB, 0xAC, 0xAD, 0xAE, 0x00, 0xB0, 0xB1, 0x00, 0x00, 0x00, 0xB5, 0xB6, 0xB7, @@ -103,12 +103,12 @@ 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99 }; static const uint8_t page21Start = 0x16; -bool -OFUnicodeToWindows1251(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToWindows1251(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/encodings/windows-1252.m ================================================================== --- src/encodings/windows-1252.m +++ src/encodings/windows-1252.m @@ -21,11 +21,11 @@ #import "OFString.h" #import "common.h" -const OFChar16 OFWindows1252Table[] = { +const OFChar16 _OFWindows1252Table[] OF_VISIBILITY_HIDDEN = { 0x20AC, 0xFFFF, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFF, 0x017D, 0xFFFF, 0xFFFF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFF, 0x017E, 0x0178, 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, @@ -39,12 +39,12 @@ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF }; -const size_t OFWindows1252TableOffset = - 256 - (sizeof(OFWindows1252Table) / sizeof(*OFWindows1252Table)); +const size_t _OFWindows1252TableOffset OF_VISIBILITY_HIDDEN = + 256 - (sizeof(_OFWindows1252Table) / sizeof(*_OFWindows1252Table)); static const unsigned char page0[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -99,12 +99,12 @@ static const unsigned char page21[] = { 0x99 }; static const uint8_t page21Start = 0x22; -bool -OFUnicodeToWindows1252(const OFUnichar *input, unsigned char *output, +bool OF_VISIBILITY_HIDDEN +_OFUnicodeToWindows1252(const OFUnichar *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { OFUnichar c = input[i]; Index: src/exceptions/OFCreateWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFCreateWindowsRegistryKeyFailedException.m +++ src/exceptions/OFCreateWindowsRegistryKeyFailedException.m @@ -82,8 +82,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Failed to create subkey at path %@: %@", - _path, OFWindowsStatusToString(_status)]; + _path, _OFWindowsStatusToString(_status)]; } @end Index: src/exceptions/OFDNSQueryFailedException.h ================================================================== --- src/exceptions/OFDNSQueryFailedException.h +++ src/exceptions/OFDNSQueryFailedException.h @@ -73,12 +73,12 @@ @end #ifdef __cplusplus extern "C" { #endif -extern OFString *OFDNSResolverErrorCodeDescription( - OFDNSResolverErrorCode errorCode); +extern OFString *_OFDNSResolverErrorCodeDescription( + OFDNSResolverErrorCode errorCode) OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/exceptions/OFDNSQueryFailedException.m ================================================================== --- src/exceptions/OFDNSQueryFailedException.m +++ src/exceptions/OFDNSQueryFailedException.m @@ -21,11 +21,11 @@ #import "OFDNSQueryFailedException.h" #import "OFString.h" OFString * -OFDNSResolverErrorCodeDescription(OFDNSResolverErrorCode errorCode) +_OFDNSResolverErrorCodeDescription(OFDNSResolverErrorCode errorCode) { switch (errorCode) { case OFDNSResolverErrorCodeTimeout: return @"The query timed out."; case OFDNSResolverErrorCodeCanceled: @@ -98,8 +98,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"DNS query %@ could not be performed: %@", - _query, OFDNSResolverErrorCodeDescription(_errorCode)]; + _query, _OFDNSResolverErrorCodeDescription(_errorCode)]; } @end Index: src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m +++ src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m @@ -69,8 +69,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Failed to delete subkey at path %@: %@", - _subkeyPath, OFWindowsStatusToString(_status)]; + _subkeyPath, _OFWindowsStatusToString(_status)]; } @end Index: src/exceptions/OFDeleteWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFDeleteWindowsRegistryValueFailedException.m +++ src/exceptions/OFDeleteWindowsRegistryValueFailedException.m @@ -69,8 +69,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Failed to delete value named %@: %@", - _valueName, OFWindowsStatusToString(_status)]; + _valueName, _OFWindowsStatusToString(_status)]; } @end Index: src/exceptions/OFException.h ================================================================== --- src/exceptions/OFException.h +++ src/exceptions/OFException.h @@ -22,10 +22,12 @@ #ifdef OF_WINDOWS # include #endif OF_ASSUME_NONNULL_BEGIN + +/** @file */ @class OFArray OF_GENERIC(ObjectType); @class OFString; @class OFValue; @@ -190,14 +192,26 @@ @end #ifdef __cplusplus extern "C" { #endif +/** + * @brief Converts the specified error number (from ``) to a string. + * + * Unlike the system function `strerror`, this function is always thread-safe. + * + * As an addition, on Windows, it is also able to convert socket error numbers + * to string. + * + * @param errNo The error number to convert to a string + * @return A string describing the error + */ extern OFString *OFStrError(int errNo); + #ifdef OF_WINDOWS -extern OFString *OFWindowsStatusToString(LSTATUS status); +extern OFString *_OFWindowsStatusToString(LSTATUS status) OF_VISIBILITY_HIDDEN; #endif #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -214,11 +214,11 @@ return ret; } #ifdef OF_WINDOWS OFString * -OFWindowsStatusToString(LSTATUS status) +_OFWindowsStatusToString(LSTATUS status) { OFString *string = nil; void *buffer; if ([OFSystemInfo isWindowsNT]) { Index: src/exceptions/OFGetWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFGetWindowsRegistryValueFailedException.m +++ src/exceptions/OFGetWindowsRegistryValueFailedException.m @@ -72,8 +72,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Failed to get value named %@: %@", - _valueName, OFWindowsStatusToString(_status)]; + _valueName, _OFWindowsStatusToString(_status)]; } @end Index: src/exceptions/OFOpenWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFOpenWindowsRegistryKeyFailedException.m +++ src/exceptions/OFOpenWindowsRegistryKeyFailedException.m @@ -80,8 +80,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Failed to open subkey at path %@: %@", - _path, OFWindowsStatusToString(_status)]; + _path, _OFWindowsStatusToString(_status)]; } @end Index: src/exceptions/OFResolveHostFailedException.m ================================================================== --- src/exceptions/OFResolveHostFailedException.m +++ src/exceptions/OFResolveHostFailedException.m @@ -73,8 +73,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"The host %@ could not be resolved: %@", - _host, OFDNSResolverErrorCodeDescription(_errorCode)]; + _host, _OFDNSResolverErrorCodeDescription(_errorCode)]; } @end Index: src/exceptions/OFSetWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFSetWindowsRegistryValueFailedException.m +++ src/exceptions/OFSetWindowsRegistryValueFailedException.m @@ -78,8 +78,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Failed to set value named %@ of type %u: %@", - _valueName, _type, OFWindowsStatusToString(_status)]; + _valueName, _type, _OFWindowsStatusToString(_status)]; } @end Index: src/exceptions/OFTLSHandshakeFailedException.h ================================================================== --- src/exceptions/OFTLSHandshakeFailedException.h +++ src/exceptions/OFTLSHandshakeFailedException.h @@ -28,11 +28,11 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern int _OFTLSHandshakeFailedException_reference; +extern int _OFTLSHandshakeFailedException_reference OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif /** Index: src/forwarding/forwarding-arm-elf.S ================================================================== --- src/forwarding/forwarding-arm-elf.S +++ src/forwarding/forwarding-arm-elf.S @@ -53,11 +53,16 @@ mov r12, r0 ldr r0, [sp, #0] mov r1, r4 ldr r2, [sp, #4] +#ifdef HAVE_BLX blx r12 +#else + mov lr, pc + bx r12 +#endif cmp r0, #0 beq 0f ldr r1, [sp, #0] cmp r0, r1 @@ -109,11 +114,16 @@ mov r12, r0 ldr r0, [sp, #4] mov r1, r4 ldr r2, [sp, #8] +#ifdef HAVE_BLX blx r12 +#else + mov lr, pc + bx r12 +#endif cmp r0, #0 beq 0f ldr r1, [sp, #4] cmp r0, r1 Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -36,10 +36,12 @@ #include #include #include #include + +/** @file */ #include "platform.h" #ifdef OF_OBJFW_RUNTIME # ifdef OF_COMPILING_OBJFW @@ -95,17 +97,19 @@ # define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1)) # define OF_UNLIKELY(cond) (__builtin_expect(!!(cond), 0)) # define OF_CONST_FUNC __attribute__((__const__)) # define OF_NO_RETURN_FUNC __attribute__((__noreturn__)) # define OF_WEAK_REF(sym) __attribute__((__weakref__(sym))) +# define OF_VISIBILITY_HIDDEN __attribute__((__visibility__("hidden"))) #else # define OF_INLINE inline # define OF_LIKELY(cond) (cond) # define OF_UNLIKELY(cond) (cond) # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC # define OF_WEAK_REF(sym) +# define OF_VISIBILITY_HIDDEN #endif #if __STDC_VERSION__ >= 201112L # define OF_ALIGN(size) _Alignas(size) # define OF_ALIGNOF(type) _Alignof(type) @@ -467,26 +471,26 @@ #define OF_DESTRUCTOR(prio) \ static void __attribute__((__destructor__(prio))) \ OF_PREPROCESSOR_CONCAT(destructor, __LINE__)(void) static OF_INLINE uint16_t OF_CONST_FUNC -OFByteSwap16Const(uint16_t i) +_OFByteSwap16Const(uint16_t i) { return (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; } static OF_INLINE uint32_t OF_CONST_FUNC -OFByteSwap32Const(uint32_t i) +_OFByteSwap32Const(uint32_t i) { return (i & UINT32_C(0xFF000000)) >> 24 | (i & UINT32_C(0x00FF0000)) >> 8 | (i & UINT32_C(0x0000FF00)) << 8 | (i & UINT32_C(0x000000FF)) << 24; } static OF_INLINE uint64_t OF_CONST_FUNC -OFByteSwap64Const(uint64_t i) +_OFByteSwap64Const(uint64_t i) { return (i & UINT64_C(0xFF00000000000000)) >> 56 | (i & UINT64_C(0x00FF000000000000)) >> 40 | (i & UINT64_C(0x0000FF0000000000)) >> 24 | (i & UINT64_C(0x000000FF00000000)) >> 8 | @@ -495,11 +499,11 @@ (i & UINT64_C(0x000000000000FF00)) << 40 | (i & UINT64_C(0x00000000000000FF)) << 56; } static OF_INLINE uint16_t OF_CONST_FUNC -OFByteSwap16NonConst(uint16_t i) +_OFByteSwap16NonConst(uint16_t i) { #if defined(OF_HAVE_BUILTIN_BSWAP16) return __builtin_bswap16(i); #elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) __asm__ ( @@ -526,11 +530,11 @@ #endif return i; } static OF_INLINE uint32_t OF_CONST_FUNC -OFByteSwap32NonConst(uint32_t i) +_OFByteSwap32NonConst(uint32_t i) { #if defined(OF_HAVE_BUILTIN_BSWAP32) return __builtin_bswap32(i); #elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) __asm__ ( @@ -559,11 +563,11 @@ #endif return i; } static OF_INLINE uint64_t OF_CONST_FUNC -OFByteSwap64NonConst(uint64_t i) +_OFByteSwap64NonConst(uint64_t i) { #if defined(OF_HAVE_BUILTIN_BSWAP64) return __builtin_bswap64(i); #elif defined(OF_AMD64) && defined(__GNUC__) __asm__ ( @@ -578,86 +582,239 @@ "xchg{l} { %%eax, %%edx | edx, eax }" : "=A" (i) : "0" (i) ); #else - i = (uint64_t)OFByteSwap32NonConst( + i = (uint64_t)_OFByteSwap32NonConst( (uint32_t)(i & UINT32_C(0xFFFFFFFF))) << 32 | - OFByteSwap32NonConst((uint32_t)(i >> 32)); + _OFByteSwap32NonConst((uint32_t)(i >> 32)); #endif return i; } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(DOXYGEN) +/** + * @brief Byte swaps the specified 16 bit integer. + * + * @param i The integer to byte swap + * @return The byte swapped integer + */ # define OFByteSwap16(i) \ - (__builtin_constant_p(i) ? OFByteSwap16Const(i) : OFByteSwap16NonConst(i)) + (__builtin_constant_p(i) ? _OFByteSwap16Const(i) : _OFByteSwap16NonConst(i)) + +/** + * @brief Byte swaps the specified 32 bit integer. + * + * @param i The integer to byte swap + * @return The byte swapped integer + */ # define OFByteSwap32(i) \ - (__builtin_constant_p(i) ? OFByteSwap32Const(i) : OFByteSwap32NonConst(i)) + (__builtin_constant_p(i) ? _OFByteSwap32Const(i) : _OFByteSwap32NonConst(i)) + +/** + * @brief Byte swaps the specified 64 bit integer. + * + * @param i The integer to byte swap + * @return The byte swapped integer + */ # define OFByteSwap64(i) \ - (__builtin_constant_p(i) ? OFByteSwap64Const(i) : OFByteSwap64NonConst(i)) + (__builtin_constant_p(i) ? _OFByteSwap64Const(i) : _OFByteSwap64NonConst(i)) #else -# define OFByteSwap16(i) OFByteSwap16Const(i) -# define OFByteSwap32(i) OFByteSwap32Const(i) -# define OFByteSwap64(i) OFByteSwap64Const(i) +# define OFByteSwap16(i) _OFByteSwap16Const(i) +# define OFByteSwap32(i) _OFByteSwap32Const(i) +# define OFByteSwap64(i) _OFByteSwap64Const(i) #endif -static OF_INLINE uint32_t -OFFloatToRawUInt32(float f) +/** + * @brief Bit-converts the specified float to a uint32_t. + * + * @param f The float to bit-convert + * @return The float bit-converted to a uint32_t + */ +static OF_INLINE uint32_t OF_CONST_FUNC +OFBitConvertFloatToUInt32(float f) { uint32_t ret; memcpy(&ret, &f, 4); return ret; } -static OF_INLINE float -OFRawUInt32ToFloat(uint32_t uInt32) +/** + * @brief Bit-converts the specified uint32_t to a float. + * + * @param uInt32 The uint32_t to bit-convert + * @return The uint32_t bit-converted to a float + */ +static OF_INLINE float OF_CONST_FUNC +OFBitConvertUInt32ToFloat(uint32_t uInt32) { float ret; memcpy(&ret, &uInt32, 4); return ret; } -static OF_INLINE uint64_t -OFDoubleToRawUInt64(double d) +/** + * @brief Bit-converts the specified double to a uint64_t. + * + * @param d The double to bit-convert + * @return The double bit-converted to a uint64_t + */ +static OF_INLINE uint64_t OF_CONST_FUNC +OFBitConvertDoubleToUInt64(double d) { uint64_t ret; memcpy(&ret, &d, 8); return ret; } -static OF_INLINE double -OFRawUInt64ToDouble(uint64_t uInt64) +/** + * @brief Bit-converts the specified uint64_t to a double. + * + * @param uInt64 The uint64_t to bit-convert + * @return The uint64_t bit-converted to a double + */ +static OF_INLINE double OF_CONST_FUNC +OFBitConvertUInt64ToDouble(uint64_t uInt64) { double ret; memcpy(&ret, &uInt64, 8); return ret; } +/** + * @brief Byte swaps the specified float. + * + * @param f The float to byte swap + * @return The byte swapped float + */ static OF_INLINE float OF_CONST_FUNC OFByteSwapFloat(float f) { - return OFRawUInt32ToFloat(OFByteSwap32(OFFloatToRawUInt32(f))); + return OFBitConvertUInt32ToFloat(OFByteSwap32( + OFBitConvertFloatToUInt32(f))); } +/** + * @brief Byte swaps the specified double. + * + * @param d The double to byte swap + * @return The byte swapped double + */ static OF_INLINE double OF_CONST_FUNC OFByteSwapDouble(double d) { - return OFRawUInt64ToDouble(OFByteSwap64(OFDoubleToRawUInt64(d))); + return OFBitConvertUInt64ToDouble(OFByteSwap64( + OFBitConvertDoubleToUInt64(d))); } -#ifdef OF_BIG_ENDIAN +#if defined(OF_BIG_ENDIAN) || defined(DOXYGEN) +/** + * @brief Converts the specified 16 bit integer from big endian to native + * endian. + * + * @param i The 16 bit integer to convert + * @return The 16 bit integer converted to native endian + */ # define OFFromBigEndian16(i) (i) + +/** + * @brief Converts the specified 32 bit integer from big endian to native + * endian. + * + * @param i The 32 bit integer to convert + * @return The 32 bit integer converted to native endian + */ # define OFFromBigEndian32(i) (i) + +/** + * @brief Converts the specified 64 bit integer from big endian to native + * endian. + * + * @param i The 64 bit integer to convert + * @return The 64 bit integer converted to native endian + */ # define OFFromBigEndian64(i) (i) + +/** + * @brief Converts the specified 16 bit integer from little endian to native + * endian. + * + * @param i The 16 bit integer to convert + * @return The 16 bit integer converted to native endian + */ # define OFFromLittleEndian16(i) OFByteSwap16(i) + +/** + * @brief Converts the specified 32 bit integer from little endian to native + * endian. + * + * @param i The 32 bit integer to convert + * @return The 32 bit integer converted to native endian + */ # define OFFromLittleEndian32(i) OFByteSwap32(i) + +/** + * @brief Converts the specified 64 bit integer from little endian to native + * endian. + * + * @param i The 64 bit integer to convert + * @return The 64 bit integer converted to native endian + */ # define OFFromLittleEndian64(i) OFByteSwap64(i) + +/** + * @brief Converts the specified 16 bit integer from native endian to big + * endian. + * + * @param i The 16 bit integer to convert + * @return The 16 bit integer converted to big endian + */ # define OFToBigEndian16(i) (i) + +/** + * @brief Converts the specified 32 bit integer from native endian to big + * endian. + * + * @param i The 32 bit integer to convert + * @return The 32 bit integer converted to big endian + */ # define OFToBigEndian32(i) (i) + +/** + * @brief Converts the specified 64 bit integer from native endian to big + * endian. + * + * @param i The 64 bit integer to convert + * @return The 64 bit integer converted to big endian + */ # define OFToBigEndian64(i) (i) + +/** + * @brief Converts the specified 16 bit integer from native endian to little + * endian. + * + * @param i The 16 bit integer to convert + * @return The 16 bit integer converted to little endian + */ # define OFToLittleEndian16(i) OFByteSwap16(i) + +/** + * @brief Converts the specified 32 bit integer from native endian to little + * endian. + * + * @param i The 32 bit integer to convert + * @return The 32 bit integer converted to little endian + */ # define OFToLittleEndian32(i) OFByteSwap32(i) + +/** + * @brief Converts the specified 64 bit integer from native endian to little + * endian. + * + * @param i The 64 bit integer to convert + * @return The 64 bit integer converted to little endian + */ # define OFToLittleEndian64(i) OFByteSwap64(i) #else # define OFFromBigEndian16(i) OFByteSwap16(i) # define OFFromBigEndian32(i) OFByteSwap32(i) # define OFFromBigEndian64(i) OFByteSwap64(i) @@ -670,18 +827,73 @@ # define OFToLittleEndian16(i) (i) # define OFToLittleEndian32(i) (i) # define OFToLittleEndian64(i) (i) #endif -#ifdef OF_FLOAT_BIG_ENDIAN +#if defined(OF_FLOAT_BIG_ENDIAN) || defined(DOXYGEN) +/** + * @brief Converts the specified float from big endian to native endian. + * + * @param f The float to convert + * @return The float converted to native endian + */ # define OFFromBigEndianFloat(f) (f) + +/** + * @brief Converts the specified double from big endian to native endian. + * + * @param d The double to convert + * @return The double converted to native endian + */ # define OFFromBigEndianDouble(d) (d) + +/** + * @brief Converts the specified float from little endian to native endian. + * + * @param f The float to convert + * @return The float converted to native endian + */ # define OFFromLittleEndianFloat(f) OFByteSwapFloat(f) + +/** + * @brief Converts the specified double from little endian to native endian. + * + * @param d The double to convert + * @return The double converted to native endian + */ # define OFFromLittleEndianDouble(d) OFByteSwapDouble(d) + +/** + * @brief Converts the specified float from native endian to big endian. + * + * @param f The float to convert + * @return The float converted to big endian + */ # define OFToBigEndianFloat(f) (f) + +/** + * @brief Converts the specified double from native endian to big endian. + * + * @param d The double to convert + * @return The double converted to big endian + */ # define OFToBigEndianDouble(d) (d) + +/** + * @brief Converts the specified float from native endian to little endian. + * + * @param f The float to convert + * @return The float converted to little endian + */ # define OFToLittleEndianFloat(f) OFByteSwapFloat(f) + +/** + * @brief Converts the specified double from native endian to little endian. + * + * @param d The double to convert + * @return The double converted to little endian + */ # define OFToLittleEndianDouble(d) OFByteSwapDouble(d) #else # define OFFromBigEndianFloat(f) OFByteSwapFloat(f) # define OFFromBigEndianDouble(d) OFByteSwapDouble(d) # define OFFromLittleEndianFloat(f) (f) @@ -690,21 +902,43 @@ # define OFToBigEndianDouble(d) OFByteSwapDouble(d) # define OFToLittleEndianFloat(f) (f) # define OFToLittleEndianDouble(d) (d) #endif +/** + * @brief Rotates the specified value left by the specified amount of bits. + * + * @param value The value to rotate + * @param bits The number of bits to rotate left the value by + * @return The value rotated left by the specified amount of bits + */ #define OFRotateLeft(value, bits) \ (((bits) % (sizeof(value) * 8)) > 0 \ ? ((value) << ((bits) % (sizeof(value) * 8))) | \ ((value) >> (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8)))) \ : (value)) + +/** + * @brief Rotates the specified value right by the specified amount of bits. + * + * @param value The value to rotate + * @param bits The number of bits to rotate right the value by + * @return The value rotated right by the specified amount of bits + */ #define OFRotateRight(value, bits) \ (((bits) % (sizeof(value) * 8)) > 0 \ ? ((value) >> ((bits) % (sizeof(value) * 8))) | \ ((value) << (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8)))) \ : (value)) +/** + * @brief Rounds up the specified value to the specified power of two. + * + * @param pow2 The power of 2 to round up to + * @param value The value to round up to the specified power of two + * @return The specified value rounded up to the specified power of two + */ #define OFRoundUpToPowerOf2(pow2, value) \ (((value) + (pow2) - 1) & ~((pow2) - 1)) static OF_INLINE bool OFBitsetIsSet(unsigned char *_Nonnull storage, size_t idx) Index: src/platform.h ================================================================== --- src/platform.h +++ src/platform.h @@ -27,11 +27,11 @@ # elif !__LITTLE_ENDIAN__ # error OF_UNIVERSAL defined, but neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__! # endif #endif -#if defined(__x86_64__) || defined(__amd64__) +#if (defined(__x86_64__) || defined(__amd64__)) && defined(__LP64__) # define OF_AMD64 #elif defined(__i386__) # define OF_X86 #elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) # define OF_POWERPC64 Index: src/platform/AmigaOS/OFPlainCondition.m ================================================================== --- src/platform/AmigaOS/OFPlainCondition.m +++ src/platform/AmigaOS/OFPlainCondition.m @@ -89,11 +89,11 @@ int OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition, OFPlainMutex *mutex, ULONG *signalMask) { - struct OFPlainConditionWaitingTask waitingTask = { + struct _OFPlainConditionWaitingTask waitingTask = { .task = FindTask(NULL), .sigBit = AllocSignal(-1) }; int error = 0; ULONG mask; @@ -140,11 +140,11 @@ int OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition, OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask) { - struct OFPlainConditionWaitingTask waitingTask = { + struct _OFPlainConditionWaitingTask waitingTask = { .task = FindTask(NULL), .sigBit = AllocSignal(-1) }; struct MsgPort port = { .mp_Node = { Index: src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m ================================================================== --- src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m +++ src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m @@ -246,11 +246,11 @@ # endif [addresses addItem: &address]; next: -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN +# if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) && !defined(OF_NETBSD) if (current->ifr_addr.sa_len > sizeof(struct sockaddr)) buffer += sizeof(struct ifreq) - sizeof(struct sockaddr) + current->ifr_addr.sa_len; else Index: src/platform/Windows/OFWin32ConsoleStdIOStream.m ================================================================== --- src/platform/Windows/OFWin32ConsoleStdIOStream.m +++ src/platform/Windows/OFWin32ConsoleStdIOStream.m @@ -178,11 +178,11 @@ (((_incompleteUTF16Surrogate & 0x3FF) << 10) | (UTF16[0] & 0x3FF)) + 0x10000; char UTF8[4]; size_t UTF8Len; - if ((UTF8Len = OFUTF8StringEncode(c, UTF8)) == 0) + if ((UTF8Len = _OFUTF8StringEncode(c, UTF8)) == 0) @throw [OFInvalidEncodingException exception]; if (UTF8Len <= length) { memcpy(buffer, UTF8, UTF8Len); j += UTF8Len; @@ -235,11 +235,11 @@ 0x10000; i++; } - if ((UTF8Len = OFUTF8StringEncode(c, UTF8)) == 0) + if ((UTF8Len = _OFUTF8StringEncode(c, UTF8)) == 0) @throw [OFInvalidEncodingException exception]; if (j + UTF8Len <= length) { memcpy(buffer + j, UTF8, UTF8Len); j += UTF8Len; @@ -276,11 +276,11 @@ OFChar16 UTF16[2]; ssize_t UTF8Len; size_t toCopy; DWORD UTF16Len, bytesWritten; - UTF8Len = -OFUTF8StringDecode( + UTF8Len = -_OFUTF8StringDecode( _incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c); OFEnsure(UTF8Len > 0); toCopy = UTF8Len - _incompleteUTF8SurrogateLen; @@ -292,11 +292,11 @@ _incompleteUTF8SurrogateLen += toCopy; if (_incompleteUTF8SurrogateLen < (size_t)UTF8Len) return 0; - UTF8Len = OFUTF8StringDecode( + UTF8Len = _OFUTF8StringDecode( _incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c); if (UTF8Len <= 0 || c > 0x10FFFF) { OFAssert(UTF8Len == 0 || UTF8Len < -4); @@ -364,11 +364,11 @@ while (i < length) { OFUnichar c; ssize_t UTF8Len; - UTF8Len = OFUTF8StringDecode(buffer + i, length - i, + UTF8Len = _OFUTF8StringDecode(buffer + i, length - i, &c); if (UTF8Len < 0 && UTF8Len >= -4) { OFEnsure(length - i < 4); Index: src/runtime/ObjFWRT.h ================================================================== --- src/runtime/ObjFWRT.h +++ src/runtime/ObjFWRT.h @@ -194,11 +194,10 @@ } objc_associationPolicy; #ifdef __cplusplus extern "C" { #endif - /** * @brief Registers a selector with the specified name with the runtime. * * @param name The name for the selector to register * @return The registered selector Index: src/test/OTAssert.h ================================================================== --- src/test/OTAssert.h +++ src/test/OTAssert.h @@ -31,11 +31,11 @@ * @param condition The condition to check * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssert(condition, ...) \ - OTAssertImpl(self, _cmd, condition, @#condition, \ + _OTAssertImpl(self, _cmd, condition, @#condition, \ @__FILE__, __LINE__, ## __VA_ARGS__, nil) /** * @brief Asserts that the specified condition is true. * @@ -198,16 +198,17 @@ * * @param ... An optional format string to print why the test was skipped, * followed by optional arguments */ #define OTSkip(...) \ - OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil) + _OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil) #ifdef __cplusplus extern "C" { #endif -extern void OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, - OFString *file, size_t line, ...); -extern void OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...); +extern void _OTAssertImpl(id testCase, SEL test, bool condition, + OFString *check, OFString *file, size_t line, ...); +extern void _OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, + ...); #ifdef __cplusplus } #endif Index: src/test/OTAssert.m ================================================================== --- src/test/OTAssert.m +++ src/test/OTAssert.m @@ -23,11 +23,11 @@ #import "OTAssertionFailedException.h" #import "OTTestSkippedException.h" void -OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, +_OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, OFString *file, size_t line, ...) { va_list arguments; OFConstantString *format; OFString *message = nil; @@ -48,11 +48,11 @@ @throw [OTAssertionFailedException exceptionWithCondition: check message: message]; } void -OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...) +_OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...) { va_list arguments; OFConstantString *format; OFString *message = nil; Index: src/unicode.h ================================================================== --- src/unicode.h +++ src/unicode.h @@ -17,24 +17,25 @@ * . */ #import "OFString.h" -#define OFUnicodeUppercaseTableSize 0x1EA -#define OFUnicodeLowercaseTableSize 0x1EA -#define OFUnicodeTitlecaseTableSize 0x1EA -#define OFUnicodeCaseFoldingTableSize 0x1EA +#define _OFUnicodeUppercaseTableSize 0x1EA +#define _OFUnicodeLowercaseTableSize 0x1EA +#define _OFUnicodeTitlecaseTableSize 0x1EA +#define _OFUnicodeCaseFoldingTableSize 0x1EA #ifdef __cplusplus extern "C" { #endif extern const OFUnichar *const _Nonnull - OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize]; + _OFUnicodeUppercaseTable[_OFUnicodeUppercaseTableSize] OF_VISIBILITY_HIDDEN; +extern const OFUnichar *const _Nonnull + _OFUnicodeLowercaseTable[_OFUnicodeLowercaseTableSize] OF_VISIBILITY_HIDDEN; extern const OFUnichar *const _Nonnull - OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize]; + _OFUnicodeTitlecaseTable[_OFUnicodeTitlecaseTableSize] OF_VISIBILITY_HIDDEN; extern const OFUnichar *const _Nonnull - OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize]; -extern const OFUnichar *const _Nonnull - OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize]; + _OFUnicodeCaseFoldingTable[_OFUnicodeCaseFoldingTableSize] + OF_VISIBILITY_HIDDEN; #ifdef __cplusplus } #endif Index: src/unicode.m ================================================================== --- src/unicode.m +++ src/unicode.m @@ -17,11 +17,11 @@ * . */ #include "config.h" -#import "OFString.h" +#import "unicode.h" static const OFUnichar emptyPage[0x100] = { 0 }; static const OFUnichar uppercasePage0[0x100] = { 0, 0, 0, 0, 0, 0, 0, 0, @@ -2121,11 +2121,11 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const OFUnichar *const OFUnicodeUppercaseTable[0x1EA] = { +const OFUnichar *const _OFUnicodeUppercaseTable[0x1EA] = { uppercasePage0, uppercasePage1, uppercasePage2, uppercasePage3, uppercasePage4, uppercasePage5, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, uppercasePage16, emptyPage, emptyPage, uppercasePage19, @@ -2247,11 +2247,11 @@ emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, uppercasePage489 }; -const OFUnichar *const OFUnicodeLowercaseTable[0x1EA] = { +const OFUnichar *const _OFUnicodeLowercaseTable[0x1EA] = { lowercasePage0, lowercasePage1, lowercasePage2, lowercasePage3, lowercasePage4, lowercasePage5, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, lowercasePage16, emptyPage, emptyPage, lowercasePage19, @@ -2373,11 +2373,11 @@ emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, lowercasePage489 }; -const OFUnichar *const OFUnicodeTitlecaseTable[0x1EA] = { +const OFUnichar *const _OFUnicodeTitlecaseTable[0x1EA] = { uppercasePage0, titlecasePage1, uppercasePage2, uppercasePage3, uppercasePage4, uppercasePage5, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, titlecasePage16, emptyPage, emptyPage, uppercasePage19, @@ -2499,11 +2499,11 @@ emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, uppercasePage489 }; -const OFUnichar *const OFUnicodeCaseFoldingTable[0x1EA] = { +const OFUnichar *const _OFUnicodeCaseFoldingTable[0x1EA] = { caseFoldingPage0, caseFoldingPage1, lowercasePage2, caseFoldingPage3, lowercasePage4, lowercasePage5, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, emptyPage, Index: tests/OFDateTests.m ================================================================== --- tests/OFDateTests.m +++ tests/OFDateTests.m @@ -54,12 +54,12 @@ { struct tm tm; int16_t timeZone; const char *dateString = "Wed, 09 Jun 2021 +0200x"; - OTAssertEqual(OFStrPTime(dateString, "%a, %d %b %Y %z", &tm, &timeZone), - dateString + 22); + OTAssertEqual(_OFStrPTime(dateString, "%a, %d %b %Y %z", &tm, + &timeZone), dateString + 22); OTAssertEqual(tm.tm_wday, 3); OTAssertEqual(tm.tm_mday, 9); OTAssertEqual(tm.tm_mon, 5); OTAssertEqual(tm.tm_year, 2021 - 1900); OTAssertEqual(timeZone, 2 * 60); Index: tests/OFFileManagerTests.m ================================================================== --- tests/OFFileManagerTests.m +++ tests/OFFileManagerTests.m @@ -306,12 +306,17 @@ IRIByAppendingPathComponent: @"destination"]; OFFileAttributes attributes; [@"test" writeToIRI: sourceIRI]; - [_fileManager linkItemAtPath: sourceIRI.fileSystemRepresentation - toPath: destinationIRI.fileSystemRepresentation]; + @try { + [_fileManager + linkItemAtPath: sourceIRI.fileSystemRepresentation + toPath: destinationIRI.fileSystemRepresentation]; + } @catch (OFNotImplementedException *e) { + OTSkip(@"Links not supported"); + } attributes = [_fileManager attributesOfItemAtIRI: destinationIRI]; OTAssertEqual(attributes.fileType, OFFileTypeRegular); OTAssertEqual(attributes.fileSize, 4); OTAssertEqualObjects([OFString stringWithContentsOfIRI: destinationIRI], @@ -348,10 +353,12 @@ @throw e; OTSkip(@"No permission to create symlink.\n" @"On Windows, only the administrator can create symbolic " @"links."); + } @catch (OFNotImplementedException *e) { + OTSkip(@"Symlinks not supported"); } attributes = [_fileManager attributesOfItemAtIRI: destinationIRI]; OTAssertEqual(attributes.fileType, OFFileTypeSymbolicLink); OTAssertEqualObjects([OFString stringWithContentsOfIRI: destinationIRI], Index: tests/OFScryptTests.m ================================================================== --- tests/OFScryptTests.m +++ tests/OFScryptTests.m @@ -150,28 +150,28 @@ - (void)testSalsa20_8Core { uint32_t salsa20Buffer[16]; memcpy(salsa20Buffer, salsa20Input, 64); - OFSalsa20_8Core(salsa20Buffer); + _OFSalsa20_8Core(salsa20Buffer); OTAssertEqual(memcmp(salsa20Buffer, salsa20Output, 64), 0); } - (void)testBlockMix { uint32_t blockMixBuffer[32]; - OFScryptBlockMix(blockMixBuffer, blockMixInput.u32, 1); + _OFScryptBlockMix(blockMixBuffer, blockMixInput.u32, 1); OTAssertEqual(memcmp(blockMixBuffer, blockMixOutput, 128), 0); } - (void)testROMix { uint32_t ROMixBuffer[32], ROMixTmp[17 * 32]; memcpy(ROMixBuffer, ROMixInput, 128); - OFScryptROMix(ROMixBuffer, 1, 16, ROMixTmp); + _OFScryptROMix(ROMixBuffer, 1, 16, ROMixTmp); OTAssertEqual(memcmp(ROMixBuffer, ROMixOutput, 128), 0); } - (void)testRFC7941TestVector1 { Index: tests/subprocess/Subprocess.m ================================================================== --- tests/subprocess/Subprocess.m +++ tests/subprocess/Subprocess.m @@ -34,14 +34,22 @@ if (![[OFApplication arguments] isEqual: [OFArray arrayWithObjects: @"tést", @"123", nil]]) [OFApplication terminateWithStatus: 1]; if (![[[OFApplication environment] objectForKey: @"tëst"] - isEqual: @"yés"]) + isEqual: @"yés"]) { [OFApplication terminateWithStatus: 2]; + } - while ((line = [OFStdIn readLine]) != nil) - [OFStdOut writeLine: line.uppercaseString]; +#ifdef OF_WINDOWS + /* On Windows 9x, closing the pipe doesn't seem to cause EOF. */ + if (![OFSystemInfo isWindowsNT]) { + if ((line = [OFStdIn readLine]) != nil) + [OFStdOut writeLine: line.uppercaseString]; + } else +#endif + while ((line = [OFStdIn readLine]) != nil) + [OFStdOut writeLine: line.uppercaseString]; [OFApplication terminate]; } @end Index: utils/ofarc/OFArc.m ================================================================== --- utils/ofarc/OFArc.m +++ utils/ofarc/OFArc.m @@ -480,19 +480,22 @@ type: type mode: mode encoding: encoding]; #ifdef OF_MACOS - @try { - OFString *attributeName = @"com.apple.quarantine"; - - _quarantine = [[[OFFileManager defaultManager] - extendedAttributeDataForName: attributeName - ofItemAtIRI: IRI] retain]; - } @catch (OFGetItemAttributesFailedException *e) { - if (e.errNo != /*ENOATTR*/ 93) - @throw e; + if ([IRI.scheme isEqual: @"file"]) { + @try { + OFString *attributeName = + @"com.apple.quarantine"; + + _quarantine = [[[OFFileManager defaultManager] + extendedAttributeDataForName: attributeName + ofItemAtIRI: IRI] retain]; + } @catch (OFGetItemAttributesFailedException *e) { + if (e.errNo != /*ENOATTR*/ 93) + @throw e; + } } #endif if (outputDir != nil) { OFFileManager *fileManager =