Index: .github/workflows/fedora-mingw.yml ================================================================== --- .github/workflows/fedora-mingw.yml +++ .github/workflows/fedora-mingw.yml @@ -10,11 +10,11 @@ triple: i686-w64-mingw32 - prefix: mingw64 triple: x86_64-w64-mingw32 - prefix: ucrt64 triple: x86_64-w64-mingw32ucrt - container: fedora:41 + container: fedora steps: - name: Install dependencies run: | sudo dnf upgrade --refresh -y sudo dnf install -y ${{matrix.prefix}}-gcc ${{matrix.prefix}}-openssl clang autoconf automake make wine DELETED .github/workflows/macos-11.yml Index: .github/workflows/macos-11.yml ================================================================== --- .github/workflows/macos-11.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: macos-11 -on: [push, pull_request] -jobs: - tests: - runs-on: macos-11 - 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 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,38 @@ * Changes of existing features or bugfixes + New features This file only contains the most significant changes. +ObjFW 1.1.5 -> ObjFW 1.1.6, 2024-08-11 + * Fixes ObjC++ with GCC. + * Adds handling of EINTR in OFKernelEventObserver. + * Fixes overriding / reusing stack arguments in super calls on x86. + * Makes headers compatible with -Wunused-parameter. + +ObjFW 1.1.4 -> ObjFW 1.1.5, 2024-07-06 + * Fixes MIPS32. + * Properly hides private symbols in the runtime so they can't be used + accidentally anymore. + +ObjFW 1.1.3 -> ObjFW 1.1.4, 2024-05-22 + * Fixes ofarc failing to extract from stdin on macOS. + * Fixes the workaround for missing blx on ARM. + * Avoids Clang's integrated assembler on MIPS64 for .S files (as it cannot + calcualte the offset between two labels). + * Fixes X32 being mistaken for AMD64. + +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: PLATFORMS.md ================================================================== --- PLATFORMS.md +++ PLATFORMS.md @@ -2,82 +2,73 @@ ========= ObjFW is known to work on the following platforms, but should run on many others as well. - AmigaOS ------- * OS Versions: 3.1, 4.1 Final Edition Update 1 * Architectures: m68k, PowerPC * Compilers: GCC 6.4.1b (amiga-gcc), GCC 8.3.0 (adtools) * Runtimes: ObjFW - Android ------- * OS Versions: 4.0.4, 4.1.2, 6.0.1 * Architectures: ARMv6, ARMv7, ARM64 * Compilers: Clang 3.3, Clang 3.8.0 * Runtimes: ObjFW - Bare metal ARM Cortex-M4 ------------------------ * Architectures: ARMv7E-M * Compilers: Clang 3.5 * Runtimes: ObjFW * Notes: Bootloader, libc (newlib) and possibly external RAM required - DOS --- * OS Versions: Windows XP DOS Emulation, DOSBox, MS-DOS 6.0, FreeDOS 1.2 * Architectures: x86 * Compilers: DJGPP GCC 4.7.3 (djdev204) * Runtimes: ObjFW - DragonFlyBSD ------------ * OS Versions: 3.0, 3.3-DEVELOPMENT * Architectures: AMD64, x86 * Compilers: GCC 4.4.7 * Runtimes: ObjFW - FreeBSD ------- * OS Versions: 9.1-rc3, 10.0 * Architectures: AMD64 * Compilers: Clang 3.1, Clang 3.3 * Runtimes: ObjFW - GNU/Hurd -------- * OS Versions: 0.9 * Architectures: i686 * Compilers: Clang 14.0.6 * Runtimes: ObjFW - Haiku ----- * OS version: r1-alpha4 * Architectures: x86 * Compilers: Clang 3.2, GCC 4.6.3 * Runtimes: ObjFW - HP-UX ----- * OS versions: 11i v1, 11i v3 @@ -85,37 +76,34 @@ * Compilers: GCC 4.7.2, GCC 7.5.0 * Runtimes: ObjFW * Notes: Exception handling on Itanium in 32 bit mode is broken, you need to use 64 bit mode by passing `OBJC="gcc -mlp64"` to `configure`. - iOS --- * Architectures: ARMv7, ARM64 * Compilers: Clang * Runtimes: Apple - Linux ----- - * Architectures: Alpha, AMD64, ARMv6, ARMv7, ARM64, Itanium, m68k, MIPS (O32), - MIPS64 (N64), RISC-V 64, PowerPC, S390x, SuperH-4, x86 - * Compilers: Clang 3.0-10.0, GCC 4.6-10.0 + * Architectures: Alpha, AMD64, ARMv5, ARMv6, ARMv7, ARM64, Itanium, + LoongArch 64, m68k, MIPS (O32), MIPS64 (N64), RISC-V 64, + PA-RISC, PowerPC, PowerPC 64, S390x, SuperH-4, x86 + * Compilers: Clang 3.0-18.1.1, GCC 4.6-14.1.1 * C libraries: glibc, musl * Runtimes: ObjFW - macOS ----- * OS Versions: 10.5, 10.7-10.15, Darling * Architectures: AMD64, PowerPC, PowerPC64, x86 * Compilers: Clang 3.1-10.0, Apple GCC 4.0.1 & 4.2.1 * Runtimes: Apple, ObjFW - MiNT ---- * OS Versions: FreeMiNT 1.19 @@ -122,19 +110,17 @@ * Architectures: m68k * Runtimes: ObjFW * Compilers: GCC 4.6.4 (MiNT 20130415) * Limitations: No shared libraries, no threads - MorphOS ------- * OS Versions: 3.14 * Architectures: PowerPC * Compilers: GCC 9.3.0 * Runtimes: ObjFW - NetBSD ------ * OS Versions: 5.1-9.0 @@ -141,20 +127,18 @@ * Architectures: AMD64, ARM, ARM (big endian, BE8 mode), MIPS (O32), PowerPC, SPARC, SPARC64, x86 * Compilers: Clang 3.0-3.2, GCC 4.1.3 & 4.5.3 & 7.4.0 * Runtimes: ObjFW - Nintendo 3DS ------------ * OS Versions: 9.2.0-20E, 10.5.0-30E / Homebrew Channel 1.1.0 * Architectures: ARM (EABI) * Compilers: GCC 5.3.0 (devkitARM release 45) * Runtimes: ObjFW * Limitations: No threads - Nintendo DS ----------- * Architectures: ARM (EABI) @@ -161,29 +145,26 @@ * Compilers: GCC 4.8.2 (devkitARM release 42) * Runtimes: ObjFW * Limitations: No threads, no sockets * Notes: File support requires an argv-compatible launcher (such as HBMenu) - Nintendo Switch --------------- * OS Versions: yuzu 1093 * Architectures: AArch64 * Compilers: GCC 12.1.0 (devkitA64 release 19) * Runtimes: ObjFW * Limitations: No sockets, no shared libraries, not tested on real hardware - OpenBSD ------- * OS Versions: 5.2-6.7 * Architectures: AMD64, MIPS64, PA-RISC, PowerPC, SPARC64 * Compilers: GCC 6.3.0, Clang 4.0 * Runtimes: ObjFW - PlayStation Portable -------------------- * OS Versions: 5.00 M33-4 @@ -190,28 +171,25 @@ * Architectures: MIPS (EABI) * Compiler: GCC 4.6.2 (devkitPSP release 16) * Runtimes: ObjFW * Limitations: No threads, no sockets - QNX --- * OS Versions: 6.5.0 * Architectures: x86 * Compilers: GCC 4.6.1 * Runtimes: ObjFW - Solaris ------- * OS Versions: OpenIndiana 2015.03, OpenIndiana 2023.04, Oracle Solaris 11.4 * Architectures: AMD64, x86 * Compilers: Clang 3.4.2, Clang 11.0.0, Clang 13.0.1, GCC 4.8.3, GCC 10.4.0 * Runtimes: ObjFW - Wii --- * OS Versions: 4.3E / Homebrew Channel 1.1.0 @@ -218,21 +196,19 @@ * Architectures: PowerPC * Compilers: GCC 4.6.3 (devkitPPC release 26) * Runtimes: ObjFW * Limitations: No threads - Wii U ----- * OS Versions: Cemu 12.26.2f * Architectures: PowerPC * Compilers: gcc version 12.1.0 (devkitPPC release 41) * Runtimes: ObjFW * Limitations: No files, no threads, no sockets, no shared libraries, not tested on real hardware - Windows ------- * OS Versions: 98 SE, NT 4.0, XP, 7, 8, 8.1, 10, 11, Wine @@ -241,11 +217,10 @@ Clang 3.9.0 from msys2 (x86), Clang 10.0 from msys2 (AMD64 & x86), Clang 14.0.4 from msys2 (AArch64) * Runtimes: ObjFW - Others ------ Basically, it should run on any POSIX system to which GCC >= 4.6 or a recent Clang version has been ported. If not, please send an e-mail with a bug report. @@ -252,11 +227,10 @@ If you successfully ran ObjFW on a platform not listed here, please send an e-mail to js@nil.im so it can be added here! If you have a platform on which ObjFW does not work, please contact me as well! - Forwarding ========== As forwarding needs hand-written assembly for each combination of CPU Index: README.md ================================================================== --- README.md +++ README.md @@ -1,427 +1,13 @@ -There are three ways you are probably reading this right now: - - * On [ObjFW](https://objfw.nil.im/)'s homepage, via Fossil's web interface - * On [GitHub](https://github.com/ObjFW/ObjFW) - * Via an editor or pager, by opening `README.md` from a clone or tarball - -ObjFW is developed using Fossil, so if you are reading this on GitHub or any -other place, you are most likely using a mirror. - - -

Table of Contents

- - * [What is ObjFW?](#what) - * [Installation](#installation) - * [License](#license) - * [Releases](#releases) - * [Cloning the repository](#cloning) - * [Building from source](#building-from-source) - * [macOS and iOS](#macos-and-ios) - * [Building as a framework](#building-framework) - * [Using the macOS or iOS framework in Xcode](#framework-in-xcode) - * [Broken Xcode versions](#broken-xcode-versions) - * [Windows](#windows) - * [Getting MSYS2](#getting-msys2) - * [Setting up MSYS2](#setting-up-msys2) - * [Getting, building and installing ObjFW](#steps-windows) - * [Nintendo DS, Nintendo 3DS and Wii](#nintendo) - * [Nintendo DS](#nintendo-ds) - * [Nintendo 3DS](#nintendo-3ds) - * [Wii](#wii) - * [Amiga](#amiga) - * [Writing your first application with ObjFW](#first-app) - * [Documentation](#documentation) - * [Bugs and feature requests](#bugs) - * [Support and community](#support) - * [Donating](#donating) - * [Thanks](#thanks) - * [Commercial use](#commercial-use) - - -

What is ObjFW?

- - ObjFW is a portable, lightweight framework for the Objective-C language. It - enables you to write an application in Objective-C that will run on any - [platform](PLATFORMS.md) supported by ObjFW without having to worry about - differences between operating systems or various frameworks you would - otherwise need if you want to be portable. - - It supports all modern Objective-C features when using Clang, but is also - compatible with GCC ≥ 4.6 to allow maximum portability. - - ObjFW is intentionally incompatible with Foundation. This has two reasons: - - * GNUstep already provides a reimplementation of Foundation, which is only - compatible to a certain degree. This means that a developer still needs to - care about differences between frameworks if they want to be portable. The - idea behind ObjFW is that a developer does not need to concern themselves - with portability and making sure their code works with multiple - frameworks: Instead, if it works it ObjFW on one platform, they can - reasonably expect it to also work with ObjFW on another platform. ObjFW - behaving differently on different operating systems (unless inevitable - because it is a platform-specific part, like the Windows Registry) is - considered a bug and will be fixed. - * Foundation predates a lot of modern Objective-C concepts. The most - prominent one is exceptions, which are only used in Foundation as a - replacement for `abort()`. This results in cumbersome error handling, - especially in initializers, which in Foundation only return `nil` on error - with no indication of what went wrong. It also means that the return of - every `init` call needs to be checked against `nil`. But in the wild, - nobody actually checks *each and every* return from `init` against `nil`, - leading to bugs. ObjFW fixes this by making exceptions a first class - citizen. - - ObjFW also comes with its own lightweight and extremely fast Objective-C - runtime, which in real world use cases was found to be significantly faster - than both GNU's and Apple's runtime. - - -

Installation

- - ObjFW packages are available for various operating systems and can be - installed as following: - - Operating System | Command - ---------------------------|--------------------------------------------- - Alpine Linux | `doas apk add objfw` - CRUX | `sudo prt-get depinst 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` - 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` - - If your operating system is not listed, you can - build ObjFW from source. - - -

License

- - ObjFW is released under the GNU Lesser General Public License version 3.0. - - If this license does not work for you, contact me and we can find a solution. - - -

Releases

- - Releases of ObjFW, as well as change logs and the accompanying documentation, - can be found [here](https://objfw.nil.im/wiki?name=Releases). - - -

Cloning the repository

- - ObjFW is developed in a [Fossil](https://fossil-scm.org) repository, with - automatic incremental exports to Git. This means you can either clone the - Fossil repository or the Git repository - it does not make a huge difference. - The main advantage of cloning the Fossil repository over cloning the Git - repository is that you also get all the tickets, wiki pages, etc. - -

Fossil

- - Clone the Fossil repository like this: - - fossil clone https://objfw.nil.im - - You can then use Fossil's web interface to browse the timeline, tickets, - wiki pages, etc.: - - cd objfw - fossil ui - - In order to verify the signature of the currently checked out checkin, you - can use: - - fossil artifact current | gpg --verify - - Please note that not all checkins are signed, as the signing key only resides - on trusted systems. This means that checkins I perform on e.g. Windows are - unsigned. However, usually it should not take long until there is another - signed checkin. Alternatively, you can go back until the last signed checkin - and review changes from there on. - -

Git

- - To clone the Git repository, use the following: - - git clone https://github.com/ObjFW/ObjFW - - Git commits are not signed, so if you want to check the signature of an - individual commit, branch head or tag, please use Fossil. - -

Building from source

- - To build ObjFW from source and install it, just run the following commands: - - ./configure - make - make check - sudo make install - - In case you checked out ObjFW from the Fossil or Git repository, you need to - run the following command first: - - ./autogen.sh - -

macOS and iOS

- -

Building as a framework

- - When building for macOS or iOS, everything is built as a `.framework` by - default if `--disable-shared` has not been specified to `./configure`. The - frameworks will end up in `$PREFIX/Library/Frameworks`. - - To build for macOS, just follow the - regular instructions above. - - To build for iOS, follow the regular instructions, but instead of - `./configure` do something like this: - - clang="xcrun --sdk iphoneos clang" - export OBJC="$clang -arch arm64e -arch arm64" - export OBJCPP="$clang -arch arm64e -E" - export IPHONEOS_DEPLOYMENT_TARGET="10.0" - ./configure --prefix=/usr/local/ios --host=arm64-apple-darwin - - To build for the iOS simulator, follow the regular instructions, but instead - of `./configure` use something like this: - - clang="xcrun --sdk iphonesimulator clang" - export OBJC="$clang -arch $(uname -m)" - export IPHONEOS_DEPLOYMENT_TARGET="10.0" - ./configure --prefix=/usr/local/iossim --host=$(uname -m)-apple-darwin - -

Using the macOS or iOS framework in Xcode

- - To use the macOS framework in Xcode, you need to add the `.framework`s to - your project and add the following flags to `Other C Flags`: - - -fconstant-string-class=OFConstantString -fno-constant-cfstrings - -

Broken Xcode versions

- - Some versions of Xcode shipped with a version of Clang that ignores - `-fconstant-string-class=OFConstantString`. This will manifest in an error - like this: - - OFAllocFailedException.m:94:10: error: cannot find interface declaration for - 'NSConstantString' - return @"Allocating an object failed!"; - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 1 error generated. - - Unfortunately, there is no workaround for this other than to - upgrade/downgrade Xcode or to build upstream Clang yourself. - - In particular, Xcode 11 Beta 1 to Beta 3 are known to be affected. While - Xcode 11 Beta 4 to Xcode 11.3 work, the bug was unfortunately reintroduced in - Xcode 11.4.1 and was only fixed in Xcode 12 Beta 1. - - You can get older versions of Xcode - [here](https://developer.apple.com/download) by clicking on "More" in the - top-right corner. - -

Windows

- - Windows is only officially supported when following these instructions, as - there are many MinGW versions that behave slightly differently and often - cause problems. - -

Getting MSYS2

- - The first thing to install is [MSYS2](https://www.msys2.org) to provide a - basic UNIX-like environment for Windows. Unfortunately, the binaries are not - signed, so make sure you download it via HTTPS. However, packages you - download and install via MSYS2 are cryptographically signed. - -

Setting up MSYS2

- - MSYS2 currently supports 7 different - [environments](https://www.msys2.org/docs/environments/). All of them except - for the one called just "MSYS" are supported, but which packages you need to - install depends on the environment(s) you want to use. If you only want to - target Windows 10 and newer, the CLANG64 and CLANG32 environments are the - recommended ones. - - For CLANG64, use: - - pacman -Syu mingw-w64-clang-x86_64-clang \ - mingw-w64-clang-x86_64-fossil \ - mingw-w64-clang-x86_64-openssl - - For CLANG32, use: - - pacman -Syu mingw-w64-clang-i686-clang \ - mingw-w64-clang-i686-fossil \ - mingw-w64-clang-i686-openssl - - For CLANGARM64, use (you need to use Fossil via another environment): - - pacman -Syu mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-openssl - - For MINGW64, use: - - pacman -Syu mingw-w64-x86_64-clang \ - mingw-w64-x86_64-fossil \ - mingw-w64-x86_64-openssl - - For MINGW32, use: - - pacman -Syu mingw-w64-i686-clang \ - mingw-w64-i686-fossil \ - mingw-w64-i686-openssl - - For UCRT64, use: - - pacman -Syu mingw-w64-ucrt-x86_64-clang \ - mingw-w64-ucrt-x86_64-fossil \ - mingw-w64-ucrt-x86_64-openssl - - When using `pacman` to install the packages, `pacman` might tell you to close - the window. If it does so, close the window, restart MSYS2 and execute the - `pacman` command again. - - There is nothing wrong with installing multiple environments, as MSYS2 has - created shortcuts for each of them in your start menu. Just make sure to use - the correct shortcut for the environment you want to use. - - Finally, install a few more things that are common between all environments: - - pacman -S autoconf automake make - -

Getting, building and installing ObjFW

- - Start the MSYS2 using the shortcut for the environment you want to use and - check out ObjFW: - - fossil clone https://objfw.nil.im - - You can also download a release tarball if you want. Now `cd` to the newly - checked out repository and build and install it: - - ./autogen.sh && ./configure && make -j16 install - - If everything was successful, you can now build projects using ObjFW for - Windows using the normal `objfw-compile` and friends. - -

Nintendo DS, Nintendo 3DS and Wii

- - Download and install [devkitPro](https://devkitpro.org/wiki/Getting_Started). - -

Nintendo DS

- - Follow the normal process, but instead of `./configure` run: - - ./configure --host=arm-none-eabi --with-nds - -

Nintendo 3DS

- - Follow the normal process, but instead of `./configure` run: - - ./configure --host=arm-none-eabi --with-3ds - -

Wii

- - Follow the normal process, but instead of `./configure` run: - - ./configure --host=powerpc-eabi --with-wii - -

Amiga

- - Install [amiga-gcc](https://github.com/bebbo/amiga-gcc). Then follow the - normal process, but instead of `./configure` run: - - ./configure --host=m68k-amigaos - - -

Writing your first application with ObjFW

- - To create your first, empty application, you can use `objfw-new`: - - objfw-new --app MyFirstApp - - This creates a file `MyFirstApp.m`. The `-[applicationDidFinishLaunching:]` - method is called as soon as ObjFW finished all initialization. Use this as - the entry point to your own code. For example, you could add the following - line there to create a "Hello World": - - [OFStdOut writeLine: @"Hello World!"]; - - You can compile your new app using `objfw-compile`: - - objfw-compile -o MyFirstApp MyFirstApp.m - - `objfw-compile` is a tool that allows building applications and libraries - using ObjFW without needing a full-blown build system. If you want to use - your own build system, you can get the necessary flags from `objfw-config`. - - -

Documentation

- - You can find the documentation for released versions of ObjFW - [here](https://objfw.nil.im/docs/). - - In order to build the documentation yourself (necessary to have documentation - for trunk / master), you need to have [Doxygen](https://www.doxygen.nl) - installed. Once installed, you can build the documentation from the root - directory of the repository: - - make docs - - -

Bugs and feature requests

- - If you find any bugs or have feature requests, please - [file a new bug](https://objfw.nil.im/tktnew) in the - [bug tracker](https://objfw.nil.im/reportlist). - - Alternatively, feel free to send a mail to js@nil.im! - - -

Support and community

- - If you have any questions about ObjFW or would like to talk to other ObjFW - users, the following venues are available: - - * The [forum](https://objfw.nil.im/forum) - * A [Matrix room](https://matrix.to/#/%23objfw:nil.im) - * A [Discord room](https://objfw.nil.im/discord), bridged to the Matrix - room above - * A [Telegram room](https://t.me/objfw), bridged to the Matrix room above - * A [Slack room](https://objfw.nil.im/slack), bridged to the Matrix room - above - * An IRC channel named `#objfw` on `irc.oftc.net` - ([Web chat](https://webchat.oftc.net/?channels=%23objfw)), bridged to the - Matrix room above - - Please don't hesitate to join any or all of those! - - -

Donating

- - If you want to donate to ObjFW, you can read about possible ways to do so - [here](https://objfw.nil.im/wiki?name=Donating). - - -

Thanks

- - * Thank you to [Jonathan Neuschäfer](https://github.com/neuschaefer) for - reviewing the *entirety* (all 84k LoC at the time) of ObjFW's codebase in - 2017! - * Thank you to [Hill Ma](https://github.com/mahiuchun) for donating an M1 Mac - Mini to the project in 2022! - - -

Commercial use

- - If for whatever reason the terms of GNU Lesser General Public License version - 3.0 don't work for you, a proprietary license for ObjFW including support is - available upon request. Just write a mail to js@nil.im and we can find a - reasonable solution for both parties. +ObjFW is a portable, lightweight framework for the Objective-C language. It +enables you to write an application in Objective-C that will run on any +platform supported by ObjFW without having to worry about differences between +operating systems or various frameworks you would otherwise need if you want to +be portable. + +It supports all modern Objective-C features when using Clang, but is also +compatible with GCC ≥ 4.6 to allow maximum portability. + +ObjFW is intentionally incompatible with Foundation. + +You can read more about ObjFW on its [homepage](https://objfw.nil.im), +including how to install and use it. 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.6, 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.6) 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 = 3 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 = 3 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/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -130,11 +130,11 @@ &_NSConcreteStackBlock, &_NSConcreteGlobalBlock, &_NSConcreteMallocBlock, NULL } }; -static struct objc_module module = { +static struct _objc_module module = { 8, sizeof(module), NULL, (struct objc_symtab *)&symtab }; OF_CONSTRUCTOR() { 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/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -49,11 +49,11 @@ /* FIXME: Optimize */ if (![string hasPrefix: @" "] && ![string hasPrefix: @"\t"] && ![string hasPrefix: @"\f"] && ![string hasSuffix: @" "] && ![string hasSuffix: @"\t"] && ![string hasSuffix: @"\f"] && - ![string containsString: @"\""]) + ![string containsString: @"\""] && ![string containsString: @"="]) return string; mutableString = [[string mutableCopy] autorelease]; [mutableString replaceOccurrencesOfString: @"\\" withString: @"\\\\"]; @@ -63,32 +63,10 @@ [mutableString replaceOccurrencesOfString: @"\"" withString: @"\\\""]; [mutableString insertString: @"\"" atIndex: 0]; [mutableString appendString: @"\""]; - [mutableString makeImmutable]; - - return mutableString; -} - -static OFString * -unescapeString(OFString *string) -{ - OFMutableString *mutableString; - - if (![string hasPrefix: @"\""] || ![string hasSuffix: @"\""]) - return string; - - string = [string substringWithRange: OFMakeRange(1, string.length - 2)]; - mutableString = [[string mutableCopy] autorelease]; - - [mutableString replaceOccurrencesOfString: @"\\f" withString: @"\f"]; - [mutableString replaceOccurrencesOfString: @"\\r" withString: @"\r"]; - [mutableString replaceOccurrencesOfString: @"\\n" withString: @"\n"]; - [mutableString replaceOccurrencesOfString: @"\\\"" withString: @"\""]; - [mutableString replaceOccurrencesOfString: @"\\\\" withString: @"\\"]; - [mutableString makeImmutable]; return mutableString; } @@ -149,39 +127,133 @@ [_name release]; [_lines release]; [super dealloc]; } + +static void +parseQuoted(const char **cString, const char **start, size_t *length) +{ + bool inEscape = false; + + (*cString)++; + *start = *cString; + + while (**cString != '\0') { + if (inEscape) + inEscape = false; + else { + if (**cString == '\\') + inEscape = true; + else if (**cString == '"') + break; + } + (*cString)++; + } + if (**cString == '\0') + @throw [OFInvalidFormatException exception]; + + *length = *cString - *start; + + (*cString)++; + + while (OFASCIIIsSpace(**cString)) + (*cString)++; +} + +static void +unescapeMutableString(OFMutableString *string) +{ + [string replaceOccurrencesOfString: @"\\f" withString: @"\f"]; + [string replaceOccurrencesOfString: @"\\r" withString: @"\r"]; + [string replaceOccurrencesOfString: @"\\n" withString: @"\n"]; + [string replaceOccurrencesOfString: @"\\\"" withString: @"\""]; + [string replaceOccurrencesOfString: @"\\\\" withString: @"\\"]; +} - (void)of_parseLine: (OFString *)line { - if (![line hasPrefix: @";"]) { - OFINICategoryPair *pair = - [[[OFINICategoryPair alloc] init] autorelease]; - OFString *key, *value; - size_t pos; - - if ((pos = [line rangeOfString: @"="].location) == OFNotFound) - @throw [OFInvalidFormatException exception]; - - key = unescapeString([line substringToIndex: pos] - .stringByDeletingEnclosingWhitespaces); - value = unescapeString([line substringFromIndex: pos + 1] - .stringByDeletingEnclosingWhitespaces); - - pair->_key = [key copy]; - pair->_value = [value copy]; - - [_lines addObject: pair]; - } else { + void *pool = objc_autoreleasePoolPush(); + const char *cString = line.UTF8String; + bool keyIsQuoted = false, valueIsQuoted = false; + const char *keyStart, *valueStart; + size_t keyLength, valueLength; + OFMutableString *key, *value; + OFINICategoryPair *pair; + + while (OFASCIIIsSpace(*cString)) + cString++; + + if (*cString == ';' || *cString == '#') { OFINICategoryComment *comment = [[[OFINICategoryComment alloc] init] autorelease]; - comment->_comment = [line copy]; - [_lines addObject: comment]; + return; + } + + if (*cString == '"') { + keyIsQuoted = true; + parseQuoted(&cString, &keyStart, &keyLength); + } else { + keyStart = cString; + + while (*cString != '=' && *cString != '\0') + cString++; + + keyLength = cString - keyStart; + } + + if (*cString != '=') + @throw [OFInvalidFormatException exception]; + cString++; + + while (OFASCIIIsSpace(*cString)) + cString++; + + if (*cString == '"') { + valueIsQuoted = true; + parseQuoted(&cString, &valueStart, &valueLength); + } else { + valueStart = cString; + + while (*cString != '\0') + cString++; + + valueLength = cString - valueStart; + } + + while (*cString != '\0') { + if (!OFASCIIIsSpace(*cString)) + @throw [OFInvalidFormatException exception]; + + cString++; } + + key = [OFMutableString stringWithUTF8String: keyStart + length: keyLength]; + value = [OFMutableString stringWithUTF8String: valueStart + length: valueLength]; + + if (keyIsQuoted) + unescapeMutableString(key); + else + [key deleteEnclosingWhitespaces]; + if (valueIsQuoted) + unescapeMutableString(value); + else + [value deleteEnclosingWhitespaces]; + + [key makeImmutable]; + [value makeImmutable]; + + pair = [[[OFINICategoryPair alloc] init] autorelease]; + pair->_key = [key copy]; + pair->_value = [value copy]; + [_lines addObject: pair]; + + objc_autoreleasePoolPop(pool); } - (OFString *)stringValueForKey: (OFString *)key { return [self stringValueForKey: key defaultValue: nil]; @@ -477,14 +549,16 @@ first: (bool)first { if (_lines.count == 0) return false; - if (first) - [stream writeFormat: @"[%@]\r\n", _name]; - else - [stream writeFormat: @"\r\n[%@]\r\n", _name]; + if (_name.length > 0) { + if (first) + [stream writeFormat: @"[%@]\r\n", _name]; + else + [stream writeFormat: @"\r\n[%@]\r\n", _name]; + } for (id line in _lines) { if ([line isKindOfClass: [OFINICategoryComment class]]) { OFINICategoryComment *comment = line; [stream writeFormat: @"%@\r\n", comment->_comment]; Index: src/OFINIFile.m ================================================================== --- src/OFINIFile.m +++ src/OFINIFile.m @@ -77,11 +77,12 @@ - (instancetype)initWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { self = [super init]; @try { - _categories = [[OFMutableArray alloc] init]; + _categories = [[OFMutableArray alloc] initWithObject: + [[[OFINICategory alloc] of_initWithName: @""] autorelease]]; [self of_parseIRI: IRI encoding: encoding]; } @catch (id e) { [self release]; @throw e; @@ -144,16 +145,19 @@ if (![line hasSuffix: @"]"]) @throw [OFInvalidFormatException exception]; categoryName = [line substringWithRange: OFMakeRange(1, line.length - 2)]; + if (categoryName.length == 0) + @throw [OFInvalidFormatException exception]; + category = [[[OFINICategory alloc] of_initWithName: categoryName] autorelease]; [_categories addObject: category]; } else { if (category == nil) - @throw [OFInvalidFormatException exception]; + category = [self categoryForName: @""]; [category of_parseLine: line]; } } 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 @@ -264,15 +264,30 @@ _waitingTask = NULL; } Permit(); #elif defined(OF_HAVE_PIPE) - OFEnsure(write(_cancelFD[1], "", 1) > 0); + do { + if (write(_cancelFD[1], "", 1) == 1) + break; + + OFEnsure(errno == EINTR); + } while (true); #elif defined(OF_WII) - OFEnsure(sendto(_cancelFD[1], "", 1, 0, - (struct sockaddr *)&_cancelAddr, 8) > 0); + do { + if (sendto(_cancelFD[1], "", 1, 0, + (struct sockaddr *)&_cancelAddr, 8) == 1) + break; + + OFEnsure(_OFSocketErrNo() == EINTR); + } while (true); #else - OFEnsure(sendto(_cancelFD[1], (void *)"", 1, 0, - (struct sockaddr *)&_cancelAddr, sizeof(_cancelAddr)) > 0); + do { + if (sendto(_cancelFD[1], (void *)"", 1, 0, + (struct sockaddr *)&_cancelAddr, sizeof(_cancelAddr)) == 1) + break; + + OFEnsure(_OFSocketErrNo() == EINTR); + } while (true); #endif } @end 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]; @@ -344,22 +344,23 @@ } } - (void)appendString: (OFString *)string { + const char *UTF8String; size_t UTF8StringLength; if (string == nil) @throw [OFInvalidArgumentException exception]; + UTF8String = string.UTF8String; UTF8StringLength = string.UTF8StringLength; _s->hasHash = false; _s->cString = OFResizeMemory(_s->cString, _s->cStringLength + UTF8StringLength + 1, 1); - memcpy(_s->cString + _s->cStringLength, string.UTF8String, - UTF8StringLength); + memcpy(_s->cString + _s->cStringLength, UTF8String, UTF8StringLength); _s->cStringLength += UTF8StringLength; _s->length += string.length; _s->cString[_s->cStringLength] = 0; @@ -366,12 +367,20 @@ if ([string isKindOfClass: [OFUTF8String class]] || [string isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)string)->_s->isUTF8) _s->isUTF8 = true; - } else - _s->isUTF8 = true; + } else { + switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, + NULL)) { + case 1: + _s->isUTF8 = true; + break; + case -1: + @throw [OFInvalidEncodingException exception]; + } + } } - (void)appendCharacters: (const OFUnichar *)characters length: (size_t)length { char *tmp = OFAllocMemory((length * 4) + 1, 1); @@ -379,11 +388,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 +425,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]; @@ -428,38 +438,49 @@ } } - (void)insertString: (OFString *)string atIndex: (size_t)idx { - size_t newCStringLength; + const char *UTF8String; + size_t UTF8StringLength, newCStringLength; 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; + UTF8String = string.UTF8String; + UTF8StringLength = string.UTF8StringLength; + + newCStringLength = _s->cStringLength + UTF8StringLength; _s->hasHash = false; _s->cString = OFResizeMemory(_s->cString, newCStringLength + 1, 1); - memmove(_s->cString + idx + string.UTF8StringLength, - _s->cString + idx, _s->cStringLength - idx); - memcpy(_s->cString + idx, string.UTF8String, - string.UTF8StringLength); + memmove(_s->cString + idx + UTF8StringLength, _s->cString + idx, + _s->cStringLength - idx); + memcpy(_s->cString + idx, UTF8String, UTF8StringLength); _s->cString[newCStringLength] = '\0'; _s->cStringLength = newCStringLength; _s->length += string.length; if ([string isKindOfClass: [OFUTF8String class]] || [string isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)string)->_s->isUTF8) _s->isUTF8 = true; - } else - _s->isUTF8 = true; + } else { + switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, + NULL)) { + case 1: + _s->isUTF8 = true; + break; + case -1: + @throw [OFInvalidEncodingException exception]; + } + } } - (void)deleteCharactersInRange: (OFRange)range { size_t start = range.location; @@ -467,13 +488,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); @@ -494,10 +515,12 @@ withString: (OFString *)replacement { size_t start = range.location; size_t end = range.location + range.length; size_t newCStringLength, newLength; + const char *replacementString; + size_t replacementLength; if (replacement == nil) @throw [OFInvalidArgumentException exception]; if (range.length > SIZE_MAX - range.location || end > _s->length) @@ -504,18 +527,21 @@ @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; + replacementString = replacement.UTF8String; + replacementLength = replacement.UTF8StringLength; + + newCStringLength = + _s->cStringLength - (end - start) + replacementLength; _s->hasHash = false; /* * If the new string is bigger, we need to resize it first so we can * memmove() the rest of the string to the end. @@ -526,14 +552,13 @@ */ if (newCStringLength > _s->cStringLength) _s->cString = OFResizeMemory(_s->cString, newCStringLength + 1, 1); - memmove(_s->cString + start + replacement.UTF8StringLength, - _s->cString + end, _s->cStringLength - end); - memcpy(_s->cString + start, replacement.UTF8String, - replacement.UTF8StringLength); + memmove(_s->cString + start + replacementLength, _s->cString + end, + _s->cStringLength - end); + memcpy(_s->cString + start, replacementString, replacementLength); _s->cString[newCStringLength] = '\0'; /* * If the new string is smaller, we can safely resize it now as we're * done with memmove(). @@ -547,12 +572,20 @@ if ([replacement isKindOfClass: [OFUTF8String class]] || [replacement isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)replacement)->_s->isUTF8) _s->isUTF8 = true; - } else - _s->isUTF8 = true; + } else { + switch (_OFUTF8StringCheck(replacementString, replacementLength, + NULL)) { + case 1: + _s->isUTF8 = true; + break; + case -1: + @throw [OFInvalidEncodingException exception]; + } + } } - (void)replaceOccurrencesOfString: (OFString *)string withString: (OFString *)replacement options: (int)options @@ -571,13 +604,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) @@ -632,12 +665,20 @@ if ([replacement isKindOfClass: [OFUTF8String class]] || [replacement isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)replacement)->_s->isUTF8) _s->isUTF8 = true; - } else - _s->isUTF8 = true; + } else { + switch (_OFUTF8StringCheck(replacementString, replacementLength, + NULL)) { + case 1: + _s->isUTF8 = true; + break; + case -1: + @throw [OFInvalidEncodingException exception]; + } + } } - (void)deleteLeadingWhitespaces { size_t i; 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,16 +266,24 @@ #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) + (void)spinlock; + return 0; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return pthread_spin_destroy(spinlock); #else return OFPlainMutexFree(spinlock); #endif } 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 @@ -20,10 +20,12 @@ #include "config.h" #ifdef HAVE_FCNTL_H # include #endif + +#include #import "OFUNIXDatagramSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" @@ -34,14 +36,15 @@ @implementation OFUNIXDatagramSocket @dynamic delegate; - (OFSocketAddress)bindToPath: (OFString *)path { +#ifndef OF_HURD OFSocketAddress address; -#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) +# if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; -#endif +# endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if (path != nil) @@ -54,23 +57,23 @@ 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 SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); -#endif +# 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 @@ -79,7 +82,17 @@ errNo: errNo]; } } return address; +#else + /* + * Datagram UNIX sockets on Hurd are broken and don't return the sender + * correctly when using recvfrom(). + */ + @throw [OFBindUNIXSocketFailedException + exceptionWithPath: path + socket: self + errNo: EAFNOSUPPORT]; +#endif } @end 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 *_Nullable) + 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]; } @@ -358,23 +358,26 @@ unsigned char character = (unsigned char)cString[i]; OFUnichar unichar; char buffer[4]; size_t byteLength; - if (character < tableOffset) { - _s->cString[j++] = cString[i]; - continue; - } - - unichar = table[character - tableOffset]; + if (character >= tableOffset) + unichar = table[character - tableOffset]; + else + unichar = character; if (unichar == 0xFFFF) @throw [OFInvalidEncodingException exception]; + + if (unichar < 0x7F) { + _s->cString[j++] = (char)unichar; + continue; + } _s->isUTF8 = true; - byteLength = OFUTF8StringEncode(unichar, buffer); + byteLength = _OFUTF8StringEncode(unichar, buffer); if (byteLength == 0) @throw [OFInvalidEncodingException exception]; _s->cStringLength += byteLength - 1; _s->cString = OFResizeMemory(_s->cString, @@ -415,11 +418,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: @@ -443,22 +446,29 @@ @try { _s = &_storage; _s->cStringLength = string.UTF8StringLength; - - if ([string isKindOfClass: [OFUTF8String class]] || - [string isKindOfClass: [OFMutableUTF8String class]]) - _s->isUTF8 = ((OFUTF8String *)string)->_s->isUTF8; - else - _s->isUTF8 = true; - _s->length = string.length; _s->cString = OFAllocMemory(_s->cStringLength + 1, 1); memcpy(_s->cString, string.UTF8String, _s->cStringLength + 1); _s->freeWhenDone = true; + + if ([string isKindOfClass: [OFUTF8String class]] || + [string isKindOfClass: [OFMutableUTF8String class]]) + _s->isUTF8 = ((OFUTF8String *)string)->_s->isUTF8; + else { + switch (_OFUTF8StringCheck(_s->cString, + _s->cStringLength, NULL)) { + case 1: + _s->isUTF8 = true; + break; + case -1: + @throw [OFInvalidEncodingException exception]; + } + } } @catch (id e) { [self release]; @throw e; } @@ -479,11 +489,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 +575,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 +631,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 +684,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 +885,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 +940,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 +969,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 +1007,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 +1081,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 +1175,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 +1210,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/forwarding/forwarding-mips-elf.S ================================================================== --- src/forwarding/forwarding-mips-elf.S +++ src/forwarding/forwarding-mips-elf.S @@ -66,11 +66,11 @@ sw $a0, 28($sp) sw $a1, 32($sp) sw $a2, 36($sp) sw $a3, 40($sp) #ifdef OF_MIPS_EABI - /* For some reason, $a4-$a8 are not always defined */ + /* For some reason, $a4-$a7 are not always defined */ sw $8, 44($sp) sw $9, 48($sp) sw $10, 52($sp) sw $11, 56($sp) @@ -161,11 +161,11 @@ lw $s0, 20($sp) lw $ra, 16($sp) addiu $sp, $sp, 96 - j_pic of_method_not_found + j_pic OFMethodNotFound .type OFForward, %function .size OFForward, .-OFForward OFForward_stret: #ifdef OF_PIC @@ -287,11 +287,11 @@ lw $s0, 20($sp) lw $ra, 16($sp) addiu $sp, $sp, 96 - j_pic of_method_not_found_stret + j_pic OFMethodNotFound_stret .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: #ifdef OF_PIC 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/OFOnce.m ================================================================== --- src/runtime/OFOnce.m +++ src/runtime/OFOnce.m @@ -20,6 +20,11 @@ #include "config.h" #import "ObjFWRT.h" #import "private.h" +#import "OFOnce.h" + +extern void OFOnce(OFOnceControl *control, OFOnceFunction function) + OF_VISIBILITY_HIDDEN; + #include "../OFOnce.m" Index: src/runtime/OFPlainMutex.m ================================================================== --- src/runtime/OFPlainMutex.m +++ src/runtime/OFPlainMutex.m @@ -20,6 +20,24 @@ #include "config.h" #import "ObjFWRT.h" #import "private.h" +#import "OFPlainMutex.h" + +extern int OFPlainMutexNew(OFPlainMutex *mutex) OF_VISIBILITY_HIDDEN; +extern int OFPlainMutexLock(OFPlainMutex *mutex) OF_VISIBILITY_HIDDEN; +extern int OFPlainMutexTryLock(OFPlainMutex *mutex) OF_VISIBILITY_HIDDEN; +extern int OFPlainMutexUnlock(OFPlainMutex *mutex) OF_VISIBILITY_HIDDEN; +extern int OFPlainMutexFree(OFPlainMutex *mutex) OF_VISIBILITY_HIDDEN; +extern int OFPlainRecursiveMutexNew(OFPlainRecursiveMutex *rmutex) + OF_VISIBILITY_HIDDEN; +extern int OFPlainRecursiveMutexLock(OFPlainRecursiveMutex *rmutex) + OF_VISIBILITY_HIDDEN; +extern int OFPlainRecursiveMutexTryLock(OFPlainRecursiveMutex *rmutex) + OF_VISIBILITY_HIDDEN; +extern int OFPlainRecursiveMutexUnlock(OFPlainRecursiveMutex *rmutex) + OF_VISIBILITY_HIDDEN; +extern int OFPlainRecursiveMutexFree(OFPlainRecursiveMutex *rmutex) + OF_VISIBILITY_HIDDEN; + #include "../OFPlainMutex.m" Index: src/runtime/OFTLSKey.m ================================================================== --- src/runtime/OFTLSKey.m +++ src/runtime/OFTLSKey.m @@ -20,6 +20,11 @@ #include "config.h" #import "ObjFWRT.h" #import "private.h" +#import "OFTLSKey.h" + +extern int OFTLSKeyNew(OFTLSKey *key) OF_VISIBILITY_HIDDEN; +extern int OFTLSKeyFree(OFTLSKey key) OF_VISIBILITY_HIDDEN; + #include "../OFTLSKey.m" 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 @@ -701,12 +700,12 @@ * Used by the compiler, but can also be called manually. * * These declarations are also required to prevent Clang's implicit * declarations which include __declspec(dllimport) on Windows. */ -struct objc_module; -extern void __objc_exec_class(struct objc_module *_Nonnull module); +struct _objc_module; +extern void __objc_exec_class(struct _objc_module *_Nonnull module); extern IMP _Nonnull objc_msg_lookup(id _Nullable object, SEL _Nonnull selector); extern IMP _Nonnull objc_msg_lookup_stret(id _Nullable object, SEL _Nonnull selector); extern IMP _Nonnull objc_msg_lookup_super(struct objc_super *_Nonnull super, SEL _Nonnull selector); Index: src/runtime/init.m ================================================================== --- src/runtime/init.m +++ src/runtime/init.m @@ -21,11 +21,11 @@ #import "ObjFWRT.h" #import "private.h" void -__objc_exec_class(struct objc_module *module) +__objc_exec_class(struct _objc_module *module) { objc_globalMutex_lock(); objc_registerAllSelectors(module->symtab); objc_registerAllClasses(module->symtab); Index: src/runtime/lookup-asm/lookup-asm-x86-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86-elf.S @@ -95,14 +95,21 @@ movl 4(%esp), %edx movl (%edx), %eax testl %eax, %eax jz .LreturnNilMethod + subl $16, %esp + movl %eax, (%esp) + movl 24(%esp), %eax movl %eax, 4(%esp) - mov 4(%edx), %edx - mov 32(%edx), %edx - jmp .Lmain_\lookup + + movl 4(%edx), %edx + movl 32(%edx), %edx + call .Lmain_\lookup + + addl $16, %esp + ret .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound Index: src/runtime/lookup-asm/lookup-asm-x86-win32.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-win32.S +++ src/runtime/lookup-asm/lookup-asm-x86-win32.S @@ -81,17 +81,24 @@ \name: _CET_ENDBR movl 4(%esp), %edx movl (%edx), %eax - test %eax, %eax + testl %eax, %eax jz .LreturnNilMethod + subl $16, %esp + movl %eax, (%esp) + movl 24(%esp), %eax movl %eax, 4(%esp) + movl 4(%edx), %edx movl 32(%edx), %edx - jmp .Lmain_\lookup + call .Lmain_\lookup + + addl $16, %esp + ret .def \name .scl 2 .type 32 .endef .endm Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -179,11 +179,11 @@ uint16_t classDefsCount; uint16_t categoryDefsCount; void *_Nonnull defs[1]; }; -struct objc_module { +struct _objc_module { unsigned long version; /* 9 = non-fragile */ unsigned long size; const char *_Nullable name; struct objc_symtab *_Nonnull symtab; }; @@ -217,64 +217,77 @@ IMP _Nullable buckets[256]; #endif } *_Nonnull buckets[256]; }; -extern void objc_registerAllCategories(struct objc_symtab *_Nonnull); +extern void objc_registerAllCategories(struct objc_symtab *_Nonnull) + OF_VISIBILITY_HIDDEN; extern struct objc_category *_Nullable *_Nullable - objc_categoriesForClass(Class _Nonnull); -extern void objc_unregisterAllCategories(void); -extern void objc_initializeClass(Class _Nonnull); -extern void objc_updateDTable(Class _Nonnull); -extern void objc_registerAllClasses(struct objc_symtab *_Nonnull); -extern Class _Nullable objc_classnameToClass(const char *_Nonnull, bool); -extern void objc_unregisterClass(Class _Nonnull); -extern void objc_unregisterAllClasses(void); -extern uint32_t objc_string_hash(const void *_Nonnull); -extern bool objc_string_equal(const void *_Nonnull, const void *_Nonnull); + objc_categoriesForClass(Class _Nonnull) OF_VISIBILITY_HIDDEN; +extern void objc_unregisterAllCategories(void) OF_VISIBILITY_HIDDEN; +extern void objc_initializeClass(Class _Nonnull) OF_VISIBILITY_HIDDEN; +extern void objc_updateDTable(Class _Nonnull) OF_VISIBILITY_HIDDEN; +extern void objc_registerAllClasses(struct objc_symtab *_Nonnull) + OF_VISIBILITY_HIDDEN; +extern Class _Nullable objc_classnameToClass(const char *_Nonnull, bool) + OF_VISIBILITY_HIDDEN; +extern void objc_unregisterClass(Class _Nonnull) OF_VISIBILITY_HIDDEN; +extern void objc_unregisterAllClasses(void) OF_VISIBILITY_HIDDEN; +extern uint32_t objc_string_hash(const void *_Nonnull) OF_VISIBILITY_HIDDEN; +extern bool objc_string_equal(const void *_Nonnull, const void *_Nonnull) + OF_VISIBILITY_HIDDEN; extern struct objc_hashtable *_Nonnull objc_hashtable_new( - objc_hashtable_hash_func, objc_hashtable_equal_func, uint32_t); -extern struct objc_hashtable_bucket objc_deletedBucket; + objc_hashtable_hash_func, objc_hashtable_equal_func, uint32_t) + OF_VISIBILITY_HIDDEN; +extern struct objc_hashtable_bucket objc_deletedBucket OF_VISIBILITY_HIDDEN; extern void objc_hashtable_set(struct objc_hashtable *_Nonnull, - const void *_Nonnull, const void *_Nonnull); + const void *_Nonnull, const void *_Nonnull) OF_VISIBILITY_HIDDEN; extern void *_Nullable objc_hashtable_get(struct objc_hashtable *_Nonnull, - const void *_Nonnull); + const void *_Nonnull) OF_VISIBILITY_HIDDEN; extern void objc_hashtable_delete(struct objc_hashtable *_Nonnull, - const void *_Nonnull); -extern void objc_hashtable_free(struct objc_hashtable *_Nonnull); -extern void objc_registerSelector(struct objc_selector *_Nonnull); -extern void objc_registerAllSelectors(struct objc_symtab *_Nonnull); -extern void objc_unregisterAllSelectors(void); -extern struct objc_sparsearray *_Nonnull objc_sparsearray_new(uint8_t); + const void *_Nonnull) OF_VISIBILITY_HIDDEN; +extern void objc_hashtable_free(struct objc_hashtable *_Nonnull) + OF_VISIBILITY_HIDDEN; +extern void objc_registerSelector(struct objc_selector *_Nonnull) + OF_VISIBILITY_HIDDEN; +extern void objc_registerAllSelectors(struct objc_symtab *_Nonnull) + OF_VISIBILITY_HIDDEN; +extern void objc_unregisterAllSelectors(void) OF_VISIBILITY_HIDDEN; +extern struct objc_sparsearray *_Nonnull objc_sparsearray_new(uint8_t) + OF_VISIBILITY_HIDDEN; extern void *_Nullable objc_sparsearray_get(struct objc_sparsearray *_Nonnull, - uintptr_t); + uintptr_t) OF_VISIBILITY_HIDDEN; extern void objc_sparsearray_set(struct objc_sparsearray *_Nonnull, uintptr_t, - void *_Nullable); -extern void objc_sparsearray_free(struct objc_sparsearray *_Nonnull); -extern struct objc_dtable *_Nonnull objc_dtable_new(void); + void *_Nullable) OF_VISIBILITY_HIDDEN; +extern void objc_sparsearray_free(struct objc_sparsearray *_Nonnull) + OF_VISIBILITY_HIDDEN; +extern struct objc_dtable *_Nonnull objc_dtable_new(void) OF_VISIBILITY_HIDDEN; extern void objc_dtable_copy(struct objc_dtable *_Nonnull, - struct objc_dtable *_Nonnull); + struct objc_dtable *_Nonnull) OF_VISIBILITY_HIDDEN; extern void objc_dtable_set(struct objc_dtable *_Nonnull, uint32_t, - IMP _Nullable); -extern void objc_dtable_free(struct objc_dtable *_Nonnull); -extern void objc_dtable_cleanup(void); -extern void objc_initStaticInstances(struct objc_symtab *_Nonnull); -extern void objc_forgetPendingStaticInstances(void); -extern void objc_zeroWeakReferences(id _Nonnull); -extern Class _Nullable object_getTaggedPointerClass(id _Nonnull); + IMP _Nullable) OF_VISIBILITY_HIDDEN; +extern void objc_dtable_free(struct objc_dtable *_Nonnull) OF_VISIBILITY_HIDDEN; +extern void objc_dtable_cleanup(void) OF_VISIBILITY_HIDDEN; +extern void objc_initStaticInstances(struct objc_symtab *_Nonnull) + OF_VISIBILITY_HIDDEN; +extern void objc_forgetPendingStaticInstances(void) OF_VISIBILITY_HIDDEN; +extern void objc_zeroWeakReferences(id _Nonnull) OF_VISIBILITY_HIDDEN; +extern Class _Nullable object_getTaggedPointerClass(id _Nonnull) + OF_VISIBILITY_HIDDEN; #ifdef OF_HAVE_THREADS -extern void objc_globalMutex_lock(void); -extern void objc_globalMutex_unlock(void); -extern void objc_globalMutex_free(void); +extern void objc_globalMutex_lock(void) OF_VISIBILITY_HIDDEN; +extern void objc_globalMutex_unlock(void) OF_VISIBILITY_HIDDEN; +extern void objc_globalMutex_free(void) OF_VISIBILITY_HIDDEN; #else # define objc_globalMutex_lock() # define objc_globalMutex_unlock() # define objc_globalMutex_free() #endif -extern char *_Nullable objc_strdup(const char *_Nonnull string); +extern char *_Nullable objc_strdup(const char *_Nonnull string) + OF_VISIBILITY_HIDDEN; -static inline IMP _Nullable +static OF_INLINE IMP _Nullable objc_dtable_get(const struct objc_dtable *_Nonnull dtable, uint32_t idx) { #ifdef OF_SELUID24 uint8_t i = idx >> 16; uint8_t j = idx >> 8; @@ -288,11 +301,11 @@ return dtable->buckets[i]->buckets[j]; #endif } extern void OF_NO_RETURN_FUNC objc_error(const char *_Nonnull title, - const char *_Nonnull format, ...); + const char *_Nonnull format, ...) OF_VISIBILITY_HIDDEN; #define OBJC_ERROR(...) \ objc_error("ObjFWRT @ " __FILE__ ":" OF_STRINGIFY(__LINE__), \ __VA_ARGS__) #if defined(OF_ELF) 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/OFINIFileTests.m ================================================================== --- tests/OFINIFileTests.m +++ tests/OFINIFileTests.m @@ -19,10 +19,12 @@ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" + +#import "OFEmbeddedIRIHandler.h" @interface OFINIFileTests: OTTestCase { OFINIFile *_file; } @@ -107,21 +109,25 @@ [OFArray array]); } - (void)testWriteToIRIEncoding { - OFString *expectedOutput = @"[tests]\r\n" + OFString *expectedOutput = @"; Comment in global category\r\n" + @"global=yes\r\n" + @"\r\n" + @"[tests]\r\n" @"foo=baz\r\n" @"foobar=baz\r\n" @";comment\r\n" @"new=new\r\n" @"\r\n" @"[foobar]\r\n" - @";foobarcomment\r\n" + @"#foobarcomment\r\n" @"qux=\" asd\"\r\n" @"quxquxqux=\"hello\\\"wörld\"\r\n" @"qux2=\"a\\f\"\r\n" + @"\"asd=asd\"=foobar\r\n" @"qux3=a\fb\r\n" @"\r\n" @"[types]\r\n" @"integer=16\r\n" @"bool=false\r\n" 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/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -254,12 +254,13 @@ #ifdef HAVE_ISO_8859_15 - (void)testStringWithCStringEncodingISO8859_15 { OTAssertEqualObjects([self.stringClass - stringWithCString: "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE" - encoding: OFStringEncodingISO8859_15], @"€ŠšŽžŒœŸ"); + stringWithCString: "a\x80\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE" + encoding: OFStringEncodingISO8859_15], + @"a\xC2\x80€ŠšŽžŒœŸ"); } #endif #ifdef HAVE_WINDOWS_1252 - (void)testStringWithCStringEncodingWindows1252 Index: tests/plugin/TestPlugin.m ================================================================== --- tests/plugin/TestPlugin.m +++ tests/plugin/TestPlugin.m @@ -19,30 +19,10 @@ #include "config.h" #import "TestPlugin.h" -#ifdef OF_OBJFW_RUNTIME -# import "runtime/private.h" - -OF_DESTRUCTOR() -{ - Class class = objc_getClass("TestPlugin"); - - if (class == Nil) - /* - * musl has broken dlclose(): Instead of calling the destructor - * on dlclose(), they call it on exit(). This of course means - * that our tests might have already called objc_deinit() and - * the class is already gone. - */ - return; - - objc_unregisterClass(class); -} -#endif - @implementation TestPlugin - (int)test: (int)num { return num * 2; } 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: tests/testfile.ini ================================================================== --- tests/testfile.ini +++ tests/testfile.ini @@ -1,16 +1,20 @@ +; Comment in global category +global=yes + [tests] foo = bar foobar=baz ;comment [foobar] -;foobarcomment +#foobarcomment qux=" asd" "quxqux " = asd quxquxqux="hello\"wörld" qux2="a\f" +"asd=asd"=foobar [types] integer = 0x20 bool = true float = 0.5 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 =