Index: .fossil-settings/clean-glob
==================================================================
--- .fossil-settings/clean-glob
+++ .fossil-settings/clean-glob
@@ -6,10 +6,11 @@
*.exe
*.framework
*.library
*.map
*.o
+*.sl
*.so
*.so.*
*/.deps
.deps
aclocal.m4
@@ -21,17 +22,19 @@
config.log
config.status
configure
docs
extra.mk
-generators/gen_tables
+generators/library/gen_libraries
+generators/unicode/gen_tables
src/Info.plist
src/bridge/Info.plist
+src/libobjfw.*
src/objfw-defs.h
src/runtime/Info.plist
-src/runtime/amiga-library-functable.inc
-src/runtime/inline.h
+src/runtime/libobjfwrt.*
+src/tls/Info.plist
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/objc_sync/objc_sync
@@ -44,6 +47,5 @@
utils/objfw-config
utils/ofarc/ofarc
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp
-utils/ofsock/ofsock
Index: .fossil-settings/ignore-glob
==================================================================
--- .fossil-settings/ignore-glob
+++ .fossil-settings/ignore-glob
@@ -7,10 +7,11 @@
*.framework
*.library
*.map
*.o
*.orig
+*.sl
*.so
*.so.*
*/.deps
.deps
.git
@@ -23,17 +24,19 @@
config.log
config.status
configure
docs
extra.mk
-generators/gen_tables
+generators/library/gen_libraries
+generators/unicode/gen_tables
src/Info.plist
src/bridge/Info.plist
+src/libobjfw.*
src/objfw-defs.h
src/runtime/Info.plist
-src/runtime/amiga-library-functable.inc
-src/runtime/inline.h
+src/runtime/libobjfwrt.*
+src/tls/Info.plist
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
@@ -49,6 +52,5 @@
utils/objfw-config
utils/ofarc/ofarc
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp
-utils/ofsock/ofsock
Index: .github/ISSUE_TEMPLATE/config.yml
==================================================================
--- .github/ISSUE_TEMPLATE/config.yml
+++ .github/ISSUE_TEMPLATE/config.yml
@@ -13,9 +13,29 @@
about: Please use this if you have questions or want support.
- name: ObjFW Matrix Room
url: https://matrix.to/#/%23objfw:nil.im
about: Please use this for interactive questions and support.
- name: ObjFW IRC Channel
- url: https://webchat.freenode.net/?channels=objfw
+ url: https://webchat.oftc.net/?channels=%23objfw
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
+ - name: ObjFW Slack Channel
+ url: https://objfw.nil.im/slack
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
+ - name: ObjFW Discord Channel
+ url: https://objfw.nil.im/discord
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
+ - name: ObjFW Telegram Room
+ url: https://t.me/objfw
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
+ - name: ObjFW Gitter Room
+ url: https://gitter.im/ObjFW/ObjFW
about:
Please use this for interactive questions and support - it is bridged to
the Matrix room above.
ADDED .github/workflows/amiga-gcc.yml
Index: .github/workflows/amiga-gcc.yml
==================================================================
--- /dev/null
+++ .github/workflows/amiga-gcc.yml
@@ -0,0 +1,37 @@
+name: amiga-gcc
+on: [push, pull_request]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --disable-amiga-lib
+ steps:
+ - name: Install dependencies
+ run: docker pull amigadev/crosstools:m68k-amigaos
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: |
+ docker run \
+ -e PATH="/opt/m68k-amigaos/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ amigadev/crosstools:m68k-amigaos \
+ sh -c 'cd /objfw && ./configure --host=m68k-amigaos ${{ matrix.configure_flags }}'
+ - name: make
+ run: |
+ docker run \
+ -e PATH="/opt/m68k-amigaos/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ amigadev/crosstools:m68k-amigaos \
+ sh -c "cd /objfw && make -j$(nproc)"
+ - name: make install
+ run: |
+ docker run \
+ -e PATH="/opt/m68k-amigaos/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ amigadev/crosstools:m68k-amigaos \
+ sh -c "cd /objfw && make -j$(nproc)"
ADDED .github/workflows/ios.yml
Index: .github/workflows/ios.yml
==================================================================
--- /dev/null
+++ .github/workflows/ios.yml
@@ -0,0 +1,35 @@
+name: ios
+on: [push, pull_request]
+jobs:
+ build:
+ runs-on: macos-latest
+ strategy:
+ matrix:
+ arch:
+ - arm64
+ - x86_64
+ configure_flags:
+ -
+ - --disable-shared
+ steps:
+ - name: Install dependencies
+ run: brew install autoconf automake
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: |
+ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
+ if [ "${{ matrix.arch}}" = "x86_64" ]; then
+ sdk="iphonesimulator"
+ else
+ sdk="iphoneos"
+ fi
+ export OBJC="clang -isysroot $(xcrun --sdk $sdk --show-sdk-path)"
+ export OBJC="$OBJC -arch ${{ matrix.arch }}"
+ ./configure --host=${{ matrix.arch }}-apple-darwin \
+ ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(sysctl -n hw.logicalcpu)
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/macos-10.15.yml
Index: .github/workflows/macos-10.15.yml
==================================================================
--- /dev/null
+++ .github/workflows/macos-10.15.yml
@@ -0,0 +1,31 @@
+name: macos-10.15
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: macos-10.15
+ 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@v2
+ - 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-11.yml
Index: .github/workflows/macos-11.yml
==================================================================
--- /dev/null
+++ .github/workflows/macos-11.yml
@@ -0,0 +1,31 @@
+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@v2
+ - 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/morphos.yml
Index: .github/workflows/morphos.yml
==================================================================
--- /dev/null
+++ .github/workflows/morphos.yml
@@ -0,0 +1,37 @@
+name: morphos
+on: [push, pull_request]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --disable-amiga-lib
+ steps:
+ - name: Install dependencies
+ run: docker pull amigadev/crosstools:ppc-morphos
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: |
+ docker run \
+ -e PATH="/opt/ppc-morphos/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ amigadev/crosstools:ppc-morphos \
+ sh -c 'cd /objfw && ./configure --host=ppc-morphos ${{ matrix.configure_flags }}'
+ - name: make
+ run: |
+ docker run \
+ -e PATH="/opt/ppc-morphos/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ amigadev/crosstools:ppc-morphos \
+ sh -c "cd /objfw && make -j$(nproc)"
+ - name: make install
+ run: |
+ docker run \
+ -e PATH="/opt/ppc-morphos/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ amigadev/crosstools:ppc-morphos \
+ sh -c "cd /objfw && make -j$(nproc)"
ADDED .github/workflows/nintendo-3ds.yml
Index: .github/workflows/nintendo-3ds.yml
==================================================================
--- /dev/null
+++ .github/workflows/nintendo-3ds.yml
@@ -0,0 +1,35 @@
+name: nintendo-3ds
+on: [push, pull_request]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install dependencies
+ run: docker pull devkitpro/devkitarm
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitarm \
+ sh -c 'cd /objfw && ./configure --host=arm-none-eabi --with-3ds'
+ - name: make
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitarm \
+ sh -c "cd /objfw && make -j$(nproc)"
+ - name: make install
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitarm \
+ sh -c "cd /objfw && make -j$(nproc)"
ADDED .github/workflows/nintendo-ds.yml
Index: .github/workflows/nintendo-ds.yml
==================================================================
--- /dev/null
+++ .github/workflows/nintendo-ds.yml
@@ -0,0 +1,35 @@
+name: nintendo-ds
+on: [push, pull_request]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install dependencies
+ run: docker pull devkitpro/devkitarm
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitarm \
+ sh -c 'cd /objfw && ./configure --host=arm-none-eabi --with-nds'
+ - name: make
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitarm \
+ sh -c "cd /objfw && make -j$(nproc)"
+ - name: make install
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitarm \
+ sh -c "cd /objfw && make -j$(nproc)"
ADDED .github/workflows/ubuntu-18.04-32bit.yml
Index: .github/workflows/ubuntu-18.04-32bit.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-18.04-32bit.yml
@@ -0,0 +1,37 @@
+name: ubuntu-18.04, 32 bit
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-18.04
+ strategy:
+ matrix:
+ configure_flags:
+ - --without-tls
+ - --without-tls --enable-seluid24
+ - --without-tls --disable-compiler-tls
+ - --without-tls --disable-threads
+ - --without-tls --disable-threads --disable-sockets
+ - --without-tls --disable-threads --disable-files
+ - --without-tls --disable-threads --disable-sockets --disable-files
+ - --without-tls --disable-sockets
+ - --without-tls --disable-sockets --disable-files
+ - --without-tls --disable-files
+ - --without-tls --disable-shared
+ - --without-tls --disable-shared --enable-seluid24
+ - --without-tls --disable-compiler-tls --disable-threads
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install gcc-multilib
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure OBJC="clang -m32" ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/ubuntu-18.04-gcc-32bit.yml
Index: .github/workflows/ubuntu-18.04-gcc-32bit.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-18.04-gcc-32bit.yml
@@ -0,0 +1,37 @@
+name: ubuntu-18.04, GCC, 32 bit
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-18.04
+ strategy:
+ matrix:
+ configure_flags:
+ - --without-tls
+ - --without-tls --enable-seluid24
+ - --without-tls --disable-compiler-tls
+ - --without-tls --disable-threads
+ - --without-tls --disable-threads --disable-sockets
+ - --without-tls --disable-threads --disable-files
+ - --without-tls --disable-threads --disable-sockets --disable-files
+ - --without-tls --disable-sockets
+ - --without-tls --disable-sockets --disable-files
+ - --without-tls --disable-files
+ - --without-tls --disable-shared
+ - --without-tls --disable-shared --enable-seluid24
+ - --without-tls --disable-compiler-tls --disable-threads
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install gcc-multilib gobjc
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure OBJC="gcc -m32" ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/ubuntu-18.04-gcc.yml
Index: .github/workflows/ubuntu-18.04-gcc.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-18.04-gcc.yml
@@ -0,0 +1,39 @@
+name: ubuntu-18.04, GCC
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-18.04
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --enable-seluid24
+ - --disable-compiler-tls
+ - --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
+ - --disable-shared --enable-seluid24
+ - --disable-compiler-tls --disable-threads
+ - --with-tls=gnutls
+ - --with-tls=gnutls --disable-shared
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install gobjc libssl-dev gnutls-dev
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure OBJC="gcc" ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/ubuntu-18.04.yml
Index: .github/workflows/ubuntu-18.04.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-18.04.yml
@@ -0,0 +1,39 @@
+name: ubuntu-18.04
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-18.04
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --enable-seluid24
+ - --disable-compiler-tls
+ - --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
+ - --disable-shared --enable-seluid24
+ - --disable-compiler-tls --disable-threads
+ - --with-tls=gnutls
+ - --with-tls=gnutls --disable-shared
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install libssl-dev gnutls-dev
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/ubuntu-20.04-32bit.yml
Index: .github/workflows/ubuntu-20.04-32bit.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-20.04-32bit.yml
@@ -0,0 +1,37 @@
+name: ubuntu-20.04, 32 bit
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ configure_flags:
+ - --without-tls
+ - --without-tls --enable-seluid24
+ - --without-tls --disable-compiler-tls
+ - --without-tls --disable-threads
+ - --without-tls --disable-threads --disable-sockets
+ - --without-tls --disable-threads --disable-files
+ - --without-tls --disable-threads --disable-sockets --disable-files
+ - --without-tls --disable-sockets
+ - --without-tls --disable-sockets --disable-files
+ - --without-tls --disable-files
+ - --without-tls --disable-shared
+ - --without-tls --disable-shared --enable-seluid24
+ - --without-tls --disable-compiler-tls --disable-threads
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install gcc-multilib
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure OBJC="clang -m32" ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/ubuntu-20.04-gcc-32bit.yml
Index: .github/workflows/ubuntu-20.04-gcc-32bit.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-20.04-gcc-32bit.yml
@@ -0,0 +1,37 @@
+name: ubuntu-20.04, GCC, 32 bit
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ configure_flags:
+ - --without-tls
+ - --without-tls --enable-seluid24
+ - --without-tls --disable-compiler-tls
+ - --without-tls --disable-threads
+ - --without-tls --disable-threads --disable-sockets
+ - --without-tls --disable-threads --disable-files
+ - --without-tls --disable-threads --disable-sockets --disable-files
+ - --without-tls --disable-sockets
+ - --without-tls --disable-sockets --disable-files
+ - --without-tls --disable-files
+ - --without-tls --disable-shared
+ - --without-tls --disable-shared --enable-seluid24
+ - --without-tls --disable-compiler-tls --disable-threads
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install gcc-multilib gobjc
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure OBJC="gcc -m32" ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/ubuntu-20.04-gcc.yml
Index: .github/workflows/ubuntu-20.04-gcc.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-20.04-gcc.yml
@@ -0,0 +1,39 @@
+name: ubuntu-20.04, GCC
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --enable-seluid24
+ - --disable-compiler-tls
+ - --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
+ - --disable-shared --enable-seluid24
+ - --disable-compiler-tls --disable-threads
+ - --with-tls=gnutls
+ - --with-tls=gnutls --disable-shared
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install gobjc libssl-dev gnutls-dev
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure OBJC="gcc" ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/ubuntu-20.04.yml
Index: .github/workflows/ubuntu-20.04.yml
==================================================================
--- /dev/null
+++ .github/workflows/ubuntu-20.04.yml
@@ -0,0 +1,39 @@
+name: ubuntu-20.04
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --enable-seluid24
+ - --disable-compiler-tls
+ - --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
+ - --disable-shared --enable-seluid24
+ - --disable-compiler-tls --disable-threads
+ - --with-tls=gnutls
+ - --with-tls=gnutls --disable-shared
+ steps:
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install libssl-dev gnutls-dev
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure ${{ matrix.configure_flags }}
+ - name: make
+ run: make -j$(nproc)
+ - name: make check
+ run: make check
+ - name: make install
+ run: sudo make install
ADDED .github/workflows/wii.yml
Index: .github/workflows/wii.yml
==================================================================
--- /dev/null
+++ .github/workflows/wii.yml
@@ -0,0 +1,35 @@
+name: wii
+on: [push, pull_request]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install dependencies
+ run: docker pull devkitpro/devkitppc
+ - uses: actions/checkout@v2
+ - name: autogen.sh
+ run: ./autogen.sh
+ - name: configure
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitppc \
+ sh -c 'cd /objfw && ./configure --host=powerpc-eabi --with-wii'
+ - name: make
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitppc \
+ sh -c "cd /objfw && make -j$(nproc)"
+ - name: make install
+ run: |
+ docker run \
+ -e DEVKITPRO=/opt/devkitpro \
+ -e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \
+ -v "$PWD:/objfw" \
+ devkitpro/devkitppc \
+ sh -c "cd /objfw && make -j$(nproc)"
Index: .gitignore
==================================================================
--- .gitignore
+++ .gitignore
@@ -7,10 +7,11 @@
*.framework
*.library
*.map
*.o
*.orig
+*.sl
*.so
*.so.*
.deps
.fslckout
_FOSSIL_
@@ -23,17 +24,19 @@
config.log
config.status
configure
docs
extra.mk
-generators/gen_tables
+generators/library/gen_libraries
+generators/unicode/gen_tables
src/Info.plist
src/bridge/Info.plist
+src/libobjfw.*
src/objfw-defs.h
src/runtime/Info.plist
-src/runtime/amiga-library-functable.inc
-src/runtime/inline.h
+src/runtime/libobjfwrt.*
+src/tls/Info.plist
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
@@ -49,6 +52,5 @@
utils/objfw-config
utils/ofarc/ofarc
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp
-utils/ofsock/ofsock
DELETED .travis.yml
Index: .travis.yml
==================================================================
--- .travis.yml
+++ /dev/null
@@ -1,250 +0,0 @@
-language: c
-
-matrix:
- include:
- # Linux
- - os: linux
- compiler: clang
- dist: precise
- sudo: required
-
- - os: linux
- compiler: gcc
- dist: precise
- sudo: required
-
- - os: linux
- arch: arm64
- compiler: clang
- dist: precise
- sudo: required
-
- - os: linux
- arch: arm64
- compiler: gcc
- dist: precise
- sudo: required
-
- - os: linux
- arch: ppc64le
- compiler: clang
- dist: precise
- sudo: required
-
- - os: linux
- arch: ppc64le
- compiler: gcc
- dist: precise
- sudo: required
-
- # Clang seems to have broken exceptions on s390x
- #- os: linux
- # arch: s390x
- # compiler: clang
- # dist: precise
- # sudo: required
-
- - os: linux
- arch: s390x
- compiler: gcc
- dist: precise
- sudo: required
-
- - os: linux
- compiler: clang
- dist: trusty
- sudo: required
-
- - os: linux
- compiler: gcc
- dist: trusty
- sudo: required
-
- - os: linux
- compiler: clang
- dist: xenial
- sudo: required
-
- - os: linux
- compiler: gcc
- dist: xenial
- sudo: required
-
- - os: linux
- compiler: clang
- dist: bionic
- sudo: required
-
- - os: linux
- compiler: gcc
- dist: bionic
- sudo: required
-
- # macOS
- - os: osx
- osx_image: xcode11.2
- language: objective-c
- env:
- - no32bit=1
- - noruntime=1 # Broken compiler in this version of Xcode
- - os: osx
- osx_image: xcode11.1
- language: objective-c
- env:
- - no32bit=1
- - noruntime=1 # Broken compiler in this version of Xcode
- - os: osx
- osx_image: xcode11
- language: objective-c
- env:
- - no32bit=1
- - noruntime=1 # Broken compiler in this version of Xcode
- - os: osx
- osx_image: xcode10.3
- language: objective-c
- env:
- - no32bit=1
- - os: osx
- osx_image: xcode10.2
- language: objective-c
- env:
- - no32bit=1
- - os: osx
- osx_image: xcode10.1
- language: objective-c
- - os: osx
- osx_image: xcode10
- language: objective-c
- - os: osx
- osx_image: xcode9.4
- language: objective-c
- - os: osx
- osx_image: xcode9.3
- language: objective-c
- - os: osx
- osx_image: xcode9.2
- language: objective-c
- - os: osx
- osx_image: xcode9.1
- language: objective-c
- - os: osx
- osx_image: xcode9
- language: objective-c
- - os: osx
- osx_image: xcode8.3
- language: objective-c
- - os: osx
- osx_image: xcode8
- language: objective-c
- - os: osx
- osx_image: xcode7.3
- language: objective-c
-
- # iOS
- - os: osx
- osx_image: xcode11.2
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode11.1
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode11
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode10.3
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode10.2
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode10.1
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode10
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode9.4
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode9.3
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode9.2
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode9.1
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode9
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode8.3
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode8
- language: objective-c
- env:
- - config=ios
- - os: osx
- osx_image: xcode7.3
- language: objective-c
- env:
- - config=ios
-
- # AmigaOS
- - os: linux
- dist: trusty
- env:
- - config=amigaos
-
- # Nintendo 3DS
- - os: linux
- dist: bionic
- env:
- - config=nintendo_3ds
-
- # Nintendo DS
- - os: linux
- dist: bionic
- env:
- - config=nintendo_ds
-
- # Nintendo Wii
- - os: linux
- dist: bionic
- env:
- - config=wii
-
-services: docker
-
-before_install:
- - .travis/before_install.sh
-
-script:
- - .travis/script.sh
DELETED .travis/before_install.sh
Index: .travis/before_install.sh
==================================================================
--- .travis/before_install.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-if [ "$TRAVIS_OS_NAME" = "linux" -a -z "$config" ]; then
- case "$TRAVIS_CPU_ARCH" in
- amd64 | s390x)
- pkgs="gobjc-multilib"
- ;;
- *)
- pkgs="gobjc"
- ;;
- esac
-
- pkgs="$pkgs libsctp-dev"
-
- if grep precise /etc/lsb-release >/dev/null; then
- pkgs="$pkgs ipx"
- fi
-
- # We don't need any of them and they're often broken.
- sudo rm -f /etc/apt/sources.list.d/*
-
- if ! sudo apt-get -qq update >/tmp/apt_log 2>&1; then
- cat /tmp/apt_log
- exit 1
- fi
-
- if ! sudo apt-get -qq install -y $pkgs >>/tmp/apt_log 2>&1; then
- cat /tmp/apt_log
- exit 1
- fi
-
- if grep precise /etc/lsb-release >/dev/null; then
- sudo ipx_internal_net add 1234 123456
- fi
-fi
-
-if [ "$config" = "nintendo_3ds" -o "$config" = "nintendo_ds" ]; then
- docker pull devkitpro/devkitarm
-fi
-
-if [ "$config" = "wii" ]; then
- docker pull devkitpro/devkitppc
-fi
-
-if [ "$config" = "amigaos" ]; then
- wget -q https://franke.ms/download/amiga-gcc.tgz
- tar -C / -xzf amiga-gcc.tgz
-fi
DELETED .travis/build.sh
Index: .travis/build.sh
==================================================================
--- .travis/build.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-cd $(dirname $0)/..
-
-echo ">> Configuring with $@"
-if ! ./configure ac_cv_path_TPUT= "$@"; then
- cat config.log
- exit 1
-fi
-
-echo ">> Building (configured with $@)"
-if ! make -j4 >/tmp/make_log 2>&1; then
- cat /tmp/make_log
- exit 1
-fi
-
-echo ">> Installing (configured with $@)"
-if ! sudo PATH="$PATH" make install >/tmp/install_log 2>&1; then
- cat /tmp/install_log
- exit 1
-fi
DELETED .travis/script.sh
Index: .travis/script.sh
==================================================================
--- .travis/script.sh
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/bin/sh
-build() {
- if ! git clean -fxd >/tmp/clean_log 2>&1; then
- cat /tmp/clean_log
- exit 1
- fi
-
- ./autogen.sh || exit 1
- .travis/build.sh "$@" || exit 1
-}
-
-if [ "$TRAVIS_OS_NAME" = "linux" -a -z "$config" ]; then
- build_32_64() {
- build OBJC="$CC" $@
-
- case "$TRAVIS_CPU_ARCH" in
- amd64)
- build OBJC="$CC -m32" \
- --host=i686-pc-linux-gnu $@
- ;;
- s390x)
- build OBJC="$CC -m31" \
- --host=s390-pc-linux-gnu $@
- ;;
- esac
- }
-
- build_32_64
- build_32_64 --enable-seluid24
- build_32_64 --disable-compiler-tls
-
- # The following are not CPU-dependent, so only run them on amd64
- if [ "$TRAVIS_CPU_ARCH" = "amd64" ]; then
- build_32_64 --disable-threads
- build_32_64 --disable-threads --disable-sockets
- build_32_64 --disable-threads --disable-files
- build_32_64 --disable-threads --disable-sockets --disable-files
- build_32_64 --disable-sockets
- build_32_64 --disable-sockets --disable-files
- build_32_64 --disable-files
- build_32_64 --disable-shared
- build_32_64 --disable-shared --enable-seluid24
- build_32_64 --disable-compiler-tls --disable-threads
- fi
-fi
-
-if [ "$TRAVIS_OS_NAME" = "osx" -a -z "$config" ]; then
- build_mac_32_64() {
- build $@
-
- if [ -z "$no32bit" ]; then
- build OBJC="clang -m32" --host=i386-apple-darwin $@
- fi
- }
-
- if xcodebuild -version | grep 'Xcode 6' >/dev/null; then
- export CPPFLAGS="-D_Null_unspecified=__null_unspecified"
- export CPPFLAGS="$CPPFLAGS -D_Nullable=__nullable"
- export CPPFLAGS="$CPPFLAGS -D_Nonnull=__nonnull"
- fi
-
- build_mac_32_64
- build_mac_32_64 --disable-threads
- build_mac_32_64 --disable-threads --disable-sockets
- build_mac_32_64 --disable-threads --disable-files
- build_mac_32_64 --disable-threads --disable-sockets --disable-files
- build_mac_32_64 --disable-sockets
- build_mac_32_64 --disable-sockets --disable-files
- build_mac_32_64 --disable-files
- build_mac_32_64 --disable-shared
-
- if [ -z "$noruntime" ]; then
- build_mac_32_64 --enable-runtime
- build_mac_32_64 --enable-runtime --enable-seluid24
- build_mac_32_64 --enable-runtime --disable-threads
- build_mac_32_64 --enable-runtime --disable-threads \
- --disable-sockets
- build_mac_32_64 --enable-runtime --disable-threads \
- --disable-files
- build_mac_32_64 --enable-runtime --disable-threads \
- --disable-sockets --disable-files
- build_mac_32_64 --enable-runtime --disable-sockets
- build_mac_32_64 --enable-runtime --disable-sockets \
- --disable-files
- build_mac_32_64 --enable-runtime --disable-files
- build_mac_32_64 --enable-runtime --disable-shared
- build_mac_32_64 --enable-runtime --disable-shared \
- --enable-seluid24
- fi
-fi
-
-if [ "$config" = "ios" ]; then
- if xcodebuild -version | grep 'Xcode 6' >/dev/null; then
- export CPPFLAGS="-D_Null_unspecified=__null_unspecified"
- export CPPFLAGS="$CPPFLAGS -D_Nullable=__nullable"
- export CPPFLAGS="$CPPFLAGS -D_Nonnull=__nonnull"
- fi
-
- export IPHONEOS_DEPLOYMENT_TARGET="9.0"
- clang="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
- export OBJC="$clang -arch armv7 -arch arm64"
- export OBJCPP="$clang -arch armv7 -E"
- build --host=arm-apple-darwin --enable-static
-
- sysroot="$(xcrun --sdk iphonesimulator --show-sdk-path)"
- clang="clang -isysroot $sysroot"
- export OBJC="$clang -arch i386 -arch x86_64"
- export OBJCPP="$clang -arch i386 -E"
- build WRAPPER=true --host=i386-apple-darwin --enable-static
-fi
-
-if [ "$config" = "amigaos" ]; then
- export PATH="/opt/amiga/bin:$PATH"
-
- build --host=m68k-amigaos
- build --host=m68k-amigaos --disable-amiga-lib
- build --host=m68k-amigaos --enable-static
-fi
-
-if [ "$config" = "nintendo_3ds" ]; then
- ./autogen.sh
- docker run -e DEVKITPRO=/opt/devkitpro \
- -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
- -v $TRAVIS_BUILD_DIR:/objfw devkitpro/devkitarm \
- /objfw/.travis/build.sh --host=arm-none-eabi --with-3ds
-fi
-
-if [ "$config" = "nintendo_ds" ]; then
- ./autogen.sh
- docker run -e DEVKITPRO=/opt/devkitpro \
- -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
- -v $TRAVIS_BUILD_DIR:/objfw devkitpro/devkitarm \
- /objfw/.travis/build.sh --host=arm-none-eabi --with-nds
-fi
-
-if [ "$config" = "wii" ]; then
- ./autogen.sh
- docker run -e DEVKITPRO=/opt/devkitpro \
- -e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \
- -v $TRAVIS_BUILD_DIR:/objfw devkitpro/devkitppc \
- /objfw/.travis/build.sh ac_cv_prog_wiiload= \
- --host=powerpc-eabi --with-wii
-fi
Index: Doxyfile
==================================================================
--- Doxyfile
+++ Doxyfile
@@ -1,14 +1,18 @@
PROJECT_NAME = "ObjFW"
OUTPUT_DIRECTORY = docs/
INPUT = src src/exceptions src/runtime
FILE_PATTERNS = *.h *.m
HTML_OUTPUT = .
+HAVE_DOT = NO
GENERATE_LATEX = NO
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = YES
+TYPEDEF_HIDES_STRUCT = YES
PREDEFINED = __OBJC__ \
+ _Nonnull \
+ _Nullable \
DOXYGEN \
OF_BOXABLE \
OF_CONSUMED \
OF_DESIGNATED_INITIALIZER \
OF_GENERIC(...)= \
Index: Makefile
==================================================================
--- Makefile
+++ Makefile
@@ -14,21 +14,23 @@
.PHONY: docs release
utils tests: src
+check: tests
+ cd tests && ${MAKE} -s run
+
docs:
rm -fr docs
doxygen >/dev/null
release: docs
echo "Generating tarball for version ${PACKAGE_VERSION}..."
rm -fr objfw-${PACKAGE_VERSION} objfw-${PACKAGE_VERSION}.tar \
objfw-${PACKAGE_VERSION}.tar.gz
fossil tarball --name objfw-${PACKAGE_VERSION} current - \
- --exclude '.cirrus*,.fossil*,.git*,.travis*' | \
- ofarc -ttgz -xq -
+ --exclude '.cirrus*,.fossil*,.git*' | ofarc -ttgz -xq -
cp configure config.h.in objfw-${PACKAGE_VERSION}/
ofarc -cq objfw-${PACKAGE_VERSION}.tar \
$$(find objfw-${PACKAGE_VERSION} | sort)
rm -fr objfw-${PACKAGE_VERSION}
gzip -9 objfw-${PACKAGE_VERSION}.tar
Index: PLATFORMS.md
==================================================================
--- PLATFORMS.md
+++ PLATFORMS.md
@@ -65,10 +65,21 @@
* OS version: r1-alpha4
* Architectures: x86
* Compilers: Clang 3.2, GCC 4.6.3
* Runtimes: ObjFW
+
+HP-UX
+-----
+
+ * OS versions: 11i v1 (PA-RISC 2.0), 11i v3 (Itanium)
+ * Architectures: Itanium, PA-RISC 2.0
+ * 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
@@ -92,19 +103,28 @@
* OS Versions: 10.5, 10.7-10.15, Darling
* Architectures: PowerPC, PowerPC64, x86, x86_64
* Compilers: Clang 3.1-10.0, Apple GCC 4.0.1 & 4.2.1
* Runtimes: Apple, ObjFW
+
+MiNT
+----
+
+ * OS Versions: FreeMiNT 1.19
+ * Architectures: m68k
+ * Runtimes: ObjFW
+ * Compilers: GCC 4.6.4 (MiNT 20130415)
+ * Limitations: No shared libraries, no threads
+
MorphOS
-------
- * OS Versions: 3.9-3.11
+ * OS Versions: 3.14
* Architectures: PowerPC
- * Compilers: GCC 5.3.0, GCC 5.4.0
+ * Compilers: GCC 9.3.0
* Runtimes: ObjFW
- * Notes: libnix and ixemul are both supported
NetBSD
------
@@ -183,16 +203,17 @@
Windows
-------
- * OS Versions: 98 SE, NT 4.0, XP (x86), 7 (x64), 8 (x64), 8.1 (x64), 10,
+ * OS Versions: 98 SE, NT 4.0, XP (x86), 7 (x64), 8 (x64), 8.1 (x64), 10, 11,
Wine (x86 & x64)
- * Architectures: x86, x86_64
+ * Architectures: x86, x86_64, AArch64
* Compilers: GCC 5.3.0 & 6.2.0 from msys2 (x86 & x64),
Clang 3.9.0 from msys2 (x86),
- Clang 10.0 from msys2 (x86 & x86_64)
+ Clang 10.0 from msys2 (x86 & x86_64),
+ Clang 14.0.4 from msys2 (AArch64)
* Runtimes: ObjFW
Others
------
Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -1,10 +1,10 @@
There are three ways you are probably reading this right now:
- * On [ObjFW](https://objfw.nil.im/)'s homepage, via Fossil
+ * 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 checkout or tarball
+ * 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.
@@ -19,12 +19,11 @@
* [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)
- * [Updating MSYS2](#updating-msys2)
- * [Installing MinGW-w64 using MSYS2](#installing-mingw-w64)
+ * [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)
@@ -31,10 +30,12 @@
* [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?
@@ -106,17 +107,16 @@
Fossil
Clone the Fossil repository like this:
- $ fossil clone https://objfw.nil.im objfw.fossil
- $ mkdir objfw && cd objfw
- $ fossil open ../objfw.fossil
+ $ 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
It's also possible to open the same local repository multiple times, so that
you have multiple working directories all backed by the same local
repository.
@@ -123,10 +123,16 @@
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:
@@ -139,11 +145,12 @@
To install ObjFW, just run the following commands:
$ ./configure
$ make
- $ make install
+ $ 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
@@ -151,27 +158,33 @@
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`.
+ default if `--disable-shared` has not been specified to `./configure`. The
+ frameworks will end up in `$PREFIX/Library/Frameworks`.
- To build for iOS, use something like this:
+ 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="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
$ export OBJC="$clang -arch armv7 -arch arm64"
$ export OBJCPP="$clang -arch armv7 -E"
$ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
- $ ./configure --prefix=/usr/local/ios --host=arm-apple-darwin
+ $ ./configure --prefix=/usr/local/ios --host=arm64-apple-darwin
- To build for the iOS simulator, use something like this:
+ To build for the iOS simulator, follow the regular instructions, but instead
+ of `./configure` use something like this:
$ clang="clang -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)"
- $ export OBJC="$clang -arch i386 -arch x86_64"
- $ export OBJCPP="$clang -arch i386 -E"
+ $ export OBJC="$clang -arch arm64 -arch x86_64"
+ $ export OBJCPP="$clang -arch arm64 -E"
$ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
- $ ./configure --prefix=/usr/local/iossim --host=i386-apple-darwin
+ $ ./configure --prefix=/usr/local/iossim --host=arm64-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`:
@@ -209,73 +222,61 @@
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 and there is no way to verify their integrity, so only download this
- from a trusted connection. Everything else you will download using MSYS2
- later will be cryptographically signed.
-
-Updating MSYS2
-
- The first thing to do is updating MSYS2. It is important to update things in
- a certain order, as `pacman` (the package manager MSYS2 uses, which comes
- from Arch Linux) does not know about a few things that are special on
- Windows.
-
- First, update the mirror list:
-
- $ pacman -Sy pacman-mirrors
-
- Then proceed to update the `msys2-runtime` itself, `bash` and `pacman`:
-
- $ pacman -S msys2-runtime bash pacman mintty
-
- Now close the current window and restart MSYS2, as the current window is now
- defunct. In a new MSYS2 window, update the rest of MSYS2:
-
- $ pacman -Su
-
- Now you have a fully updated MSYS2. Whenever you want to update MSYS2,
- proceed in this order. Notice that the first `pacman` invocation includes
- `-y` to actually fetch a new list of packages.
-
-Installing MinGW-w64 using MSYS2
-
- Now it's time to install MinGW-w64. If you want to build 32 bit binaries:
-
- $ pacman -S mingw-w64-i686-clang mingw-w64-i686-gcc-objc
-
- For 64 bit binaries:
-
- $ pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-gcc-objc
-
- There is nothing wrong with installing them both, as MSYS2 has created two
- entries in your start menu: `MinGW-w64 Win32 Shell` and
- `MinGW-w64 Win64 Shell`. So if you want to build for 32 or 64 bit, you just
- start the correct shell.
-
- Finally, install a few more things needed to build ObjFW:
-
- $ pacman -S autoconf automake fossil make
+ 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 5 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.
+
+ For MINGW64, use:
+
+ $ pacman -Syu mingw-w64-x86_64-clang mingw-w64-x86_64-fossil
+
+ For UCRT64, use:
+
+ $ pacman -Syu mingw-w64-ucrt-x86_64-clang mingw-w64-ucrt-x86_64-fossil
+
+ For CLANG64, use:
+
+ $ pacman -Syu mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-fossil
+
+ For MINGW32, use:
+
+ $ pacman -Syu mingw-w64-i686-clang mingw-w64-i686-fossil
+
+ 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 MinGW-w64 Win32 or Win64 Shell (depening on what version you want
- to build - do *not* use the MSYS2 Shell shortcut, but use the MinGW-w64 Win32
- or Win64 Shell shortcut instead!) and check out ObjFW:
-
- $ fossil clone https://objfw.nil.im objfw.fossil
- $ mkdir objfw && cd objfw
- $ fossil open ../objfw.fossil
-
- You can also download a release tarball if you want. Now go to the newly
+ 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 successfully, you can now build projects using ObjFW for
+ 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).
@@ -315,11 +316,11 @@
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":
- [of_stdout writeLine: @"Hello World!"];
+ [OFStdOut writeLine: @"Hello World!"];
You can compile your new app using `objfw-compile`:
$ objfw-compile -o MyFirstApp MyFirstApp.m
@@ -336,11 +337,11 @@
In order to build the documentation yourself (necessary to have documentation
for trunk / master), you need to have [Doxygen](https://www.doxygen.nl)
installed. Once installed, you can build the documentation from the root
directory of the repository:
- $ doxygen >/dev/null
+ $ make docs
Bugs and feature requests
If you find any bugs or have feature requests, please
@@ -354,19 +355,41 @@
If you have any questions about ObjFW or would like to talk to other ObjFW
users, the following venues are available:
* The [forum](https://objfw.nil.im/forum)
- * A [Matrix](https://matrix.to/#/%23objfw:nil.im) room
- * An [IRC channel](irc://chat.freenode.net/#objfw) on Freenode (`#objfw`,
- [web chat](https://webchat.freenode.net/?channels=objfw)), bridged to the
+ * A [Matrix room](https://matrix.to/#/%23objfw:nil.im)
+ * An IRC channel named `#objfw` on `irc.oftc.net`
+ ([Web chat](https://webchat.oftc.net/?channels=%23objfw)), bridged to the
Matrix room above
+ * A [Slack channel](https://objfw.nil.im/slack), bridged to the Matrix room
+ above
+ * A [Discord channel](https://objfw.nil.im/discord), bridged to the Matrix
+ room above
+ * A [Telegram room](https://t.me/objfw), bridged to the Matrix room above
+ * A [Gitter room](https://gitter.im/ObjFW/ObjFW), bridged to the Matrix room
+ above
Please don't hesitate to join any or all of those!
+
+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!
+
Commercial use
If for whatever reason neither the terms of the QPL nor those of the GPL 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.
Index: build-aux/config.guess
==================================================================
--- build-aux/config.guess
+++ build-aux/config.guess
@@ -1,10 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2018 Free Software Foundation, Inc.
+# Copyright 1992-2019 Free Software Foundation, Inc.
-timestamp='2018-03-08'
+timestamp='2019-01-03'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
@@ -48,11 +48,11 @@
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
@@ -82,12 +82,10 @@
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
-trap 'exit 1' 1 2 15
-
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
@@ -94,38 +92,42 @@
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > "$dummy.c" ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
+tmp=
+# shellcheck disable=SC2172
+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
+
+set_cc_for_build() {
+ : "${TMPDIR=/tmp}"
+ # shellcheck disable=SC2039
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
+ dummy=$tmp/dummy
+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
+ ,,) echo "int x;" > "$dummy.c"
+ for driver in cc gcc c89 c99 ; do
+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$driver"
+ break
+ fi
+ done
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+ esac
+}
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+if test -f /.attbin/uname ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
@@ -136,11 +138,11 @@
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
- eval "$set_cc_for_build"
+ set_cc_for_build
cat <<-EOF > "$dummy.c"
#include
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
@@ -178,17 +180,20 @@
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
"/sbin/$sysctl" 2>/dev/null || \
"/usr/sbin/$sysctl" 2>/dev/null || \
echo unknown)`
case "$UNAME_MACHINE_ARCH" in
+ aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
- earmv*)
- arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+ earm*)
+ arch="${UNAME_MACHINE_ARCH#e}"
+ arch="${arch%eb}"
+ arch="${arch%hf}"
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
machine="${arch}${endian}"-unknown
;;
*) machine="$UNAME_MACHINE_ARCH"-unknown ;;
esac
@@ -197,11 +202,11 @@
case "$UNAME_MACHINE_ARCH" in
earm*)
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval "$set_cc_for_build"
+ set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
@@ -215,11 +220,11 @@
;;
esac
# Determine ABI tags.
case "$UNAME_MACHINE_ARCH" in
earm*)
- expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+ expr='s/v[0-9]//;s/earm/-eabi/;s/eb$//'
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
@@ -235,11 +240,11 @@
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "$machine-${os}${release}${abi}"
+ echo "$machine-${os}${release}${abi-}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
exit ;;
@@ -381,17 +386,30 @@
exit ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
+ set_cc_for_build
+ SUN_ARCH=sparc
+ # If there is a compiler, see if it is configured for 64-bit objects.
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+ # This test works for both compilers.
+ if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+ if (echo '#ifdef __sparcv9'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH=sparcv9
+ fi
+ fi
+ echo "$SUN_ARCH"-sun-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux"$UNAME_RELEASE"
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
@@ -480,11 +498,11 @@
exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix"$UNAME_RELEASE"
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
@@ -577,11 +595,11 @@
fi
echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#include
main()
{
@@ -658,11 +676,11 @@
'') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
esac ;;
esac
fi
if [ "$HP_ARCH" = "" ]; then
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#define _HPUX_SOURCE
#include
#include
@@ -698,11 +716,11 @@
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ "$HP_ARCH" = hppa2.0w ]
then
- eval "$set_cc_for_build"
+ set_cc_for_build
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
# generating 64-bit code. GNU and HP use different nomenclature:
#
@@ -724,11 +742,11 @@
ia64:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux"$HPUX_REV"
exit ;;
3050*:HI-UX:*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#include
int
main ()
{
@@ -837,10 +855,21 @@
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi"$UNAME_RELEASE"
exit ;;
*:BSD/OS:*:*)
echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
+ exit ;;
+ arm:FreeBSD:*:*)
+ UNAME_PROCESSOR=`uname -p`
+ set_cc_for_build
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
+ else
+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
+ fi
exit ;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
case "$UNAME_PROCESSOR" in
amd64)
@@ -879,11 +908,11 @@
esac ;;
i*:UWIN*:*)
echo "$UNAME_MACHINE"-pc-uwin
exit ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
+ echo x86_64-pc-cygwin
exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
*:GNU:*:*)
@@ -892,12 +921,12 @@
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
exit ;;
- i*86:Minix:*:*)
- echo "$UNAME_MACHINE"-pc-minix
+ *:Minix:*:*)
+ echo "$UNAME_MACHINE"-unknown-minix
exit ;;
aarch64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
aarch64_be:Linux:*:*)
@@ -920,11 +949,11 @@
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arm*:Linux:*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
else
@@ -969,11 +998,11 @@
exit ;;
m68*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
#undef ${UNAME_MACHINE}
#undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
@@ -1283,11 +1312,11 @@
*:Rhapsody:*:*)
echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- eval "$set_cc_for_build"
+ set_cc_for_build
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
@@ -1356,10 +1385,11 @@
exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
+ # shellcheck disable=SC2154
if test "$cputype" = 386; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
@@ -1412,10 +1442,13 @@
echo "$UNAME_MACHINE"-unknown-esx
exit ;;
amd64:Isilon\ OneFS:*:*)
echo x86_64-unknown-onefs
exit ;;
+ *:Unleashed:*:*)
+ echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE"
+ exit ;;
esac
echo "$0: unable to guess system type" >&2
case "$UNAME_MACHINE:$UNAME_SYSTEM" in
Index: build-aux/config.sub
==================================================================
--- build-aux/config.sub
+++ build-aux/config.sub
@@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2018 Free Software Foundation, Inc.
+# Copyright 1992-2019 Free Software Foundation, Inc.
-timestamp='2018-03-08'
+timestamp='2019-01-05'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
@@ -65,11 +65,11 @@
Report bugs and patches to ."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
@@ -87,11 +87,11 @@
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
- echo "$me: invalid option $1$help"
+ echo "$me: invalid option $1$help" >&2
exit 1 ;;
*local*)
# First pass through any local machine types.
echo "$1"
@@ -108,1431 +108,1418 @@
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
- linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
- knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
- kopensolaris*-gnu* | cloudabi*-eabi* | \
- storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- android-linux)
- os=-linux-android
- basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
- ;;
- *)
- basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
- if [ "$basic_machine" != "$1" ]
- then os=`echo "$1" | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray | -microblaze*)
- os=
- basic_machine=$1
- ;;
- -bluegene*)
- os=-cnk
- ;;
- -sim | -cisco | -oki | -wec | -winbond)
- os=
- basic_machine=$1
- ;;
- -scout)
- ;;
- -wrs)
- os=-vxworks
- basic_machine=$1
- ;;
- -chorusos*)
- os=-chorusos
- basic_machine=$1
- ;;
- -chorusrdb)
- os=-chorusrdb
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco6)
- os=-sco5v6
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco5v6*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -udk*)
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*178)
- os=-lynxos178
- ;;
- -lynx*5)
- os=-lynxos5
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'`
- ;;
- -psos*)
- os=-psos
- ;;
- -mint | -mint[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
+# Split fields of configuration type
+# shellcheck disable=SC2162
+IFS="-" read field1 field2 field3 field4 <&2
+ exit 1
+ ;;
+ *-*-*-*)
+ basic_machine=$field1-$field2
+ os=$field3-$field4
+ ;;
+ *-*-*)
+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
+ # parts
+ maybe_os=$field2-$field3
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \
+ | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
+ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
+ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
+ | storm-chaos* | os2-emx* | rtmk-nova*)
+ basic_machine=$field1
+ os=$maybe_os
+ ;;
+ android-linux)
+ basic_machine=$field1-unknown
+ os=linux-android
+ ;;
+ *)
+ basic_machine=$field1-$field2
+ os=$field3
+ ;;
+ esac
+ ;;
+ *-*)
+ # A lone config we happen to match not fitting any pattern
+ case $field1-$field2 in
+ decstation-3100)
+ basic_machine=mips-dec
+ os=
+ ;;
+ *-*)
+ # Second component is usually, but not always the OS
+ case $field2 in
+ # Prevent following clause from handling this valid os
+ sun*os*)
+ basic_machine=$field1
+ os=$field2
+ ;;
+ # Manufacturers
+ dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
+ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
+ | unicom* | ibm* | next | hp | isi* | apollo | altos* \
+ | convergent* | ncr* | news | 32* | 3600* | 3100* \
+ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
+ | ultra | tti* | harris | dolphin | highlevel | gould \
+ | cbm | ns | masscomp | apple | axis | knuth | cray \
+ | microblaze* | sim | cisco \
+ | oki | wec | wrs | winbond)
+ basic_machine=$field1-$field2
+ os=
+ ;;
+ *)
+ basic_machine=$field1
+ os=$field2
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ *)
+ # Convert single-component short-hands not valid as part of
+ # multi-component configurations.
+ case $field1 in
+ 386bsd)
+ basic_machine=i386-pc
+ os=bsd
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=scout
+ ;;
+ alliant)
+ basic_machine=fx80-alliant
+ os=
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ os=
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=sysv
+ ;;
+ amiga)
+ basic_machine=m68k-unknown
+ os=
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ os=aros
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=linux
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=bsd
+ ;;
+ cray)
+ basic_machine=j90-cray
+ os=unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ os=
+ ;;
+ da30)
+ basic_machine=m68k-da30
+ os=
+ ;;
+ decstation | pmax | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ os=
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ os=dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=msdosdjgpp
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=ebmon
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=ose
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=go32
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=sysv3
+ ;;
+ hp300)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=hpux
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=proelf
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=mach
+ ;;
+ vsta)
+ basic_machine=i386-pc
+ os=vsta
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=linux
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=sysv
+ ;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=mingw64
+ ;;
+ mingw32)
+ basic_machine=i686-pc
+ os=mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=mingw32ce
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=morphos
+ ;;
+ moxiebox)
+ basic_machine=moxie-unknown
+ os=moxiebox
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=msdos
+ ;;
+ msys)
+ basic_machine=i686-pc
+ os=msys
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=mvs
+ ;;
+ nacl)
+ basic_machine=le32-unknown
+ os=nacl
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-pc
+ os=netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=sysv
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=nonstopux
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=os68k
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=linux
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=pw32
+ ;;
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ os=rdos
+ ;;
+ rdos32)
+ basic_machine=i386-pc
+ os=rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=coff
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=udi
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ os=
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=sysv2
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ os=
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ os=
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=sunos4
+ ;;
+ sun3)
+ basic_machine=m68k-sun
+ os=
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=sunos4
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ os=
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=solaris2
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ os=
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=unicos
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=tops20
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=vms
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=vxworks
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=mingw32
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=unicos
+ ;;
+ *)
+ basic_machine=$1
+ os=
+ ;;
+ esac
+ ;;
+esac
+
+# Decode 1-component or ad-hoc basic machines
case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | aarch64 | aarch64_be | arm64 \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arceb \
- | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
- | avr | avr32 \
- | ba \
- | be32 | be64 \
- | bfin \
- | c4x | c8051 | clipper \
- | d10v | d30v | dlx | dsp16xx \
- | e2k | epiphany \
- | fido | fr30 | frv | ft32 \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | hexagon \
- | i370 | i860 | i960 | ia16 | ia64 \
- | ip2k | iq2000 \
- | k1om \
- | le32 | le64 \
- | lm32 \
- | m32c | m32r | m32rle | m68000 | m68k | m88k \
- | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64octeon | mips64octeonel \
- | mips64orion | mips64orionel \
- | mips64r5900 | mips64r5900el \
- | mips64vr | mips64vrel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa32r6 | mipsisa32r6el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64r6 | mipsisa64r6el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipsr5900 | mipsr5900el \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | moxie \
- | mt \
- | msp430 \
- | nds32 | nds32le | nds32be \
- | nios | nios2 | nios2eb | nios2el \
- | ns16k | ns32k \
- | open8 | or1k | or1knd | or32 \
- | pdp10 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle \
- | pru \
- | pyramid \
- | riscv32 | riscv64 \
- | rl78 | rx \
- | score \
- | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
- | spu \
- | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
- | ubicom32 \
- | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
- | visium \
- | wasm32 \
- | x86 | xc16x | xstormy16 | xtensa \
- | z8k | z80)
- basic_machine=$basic_machine-unknown
- ;;
- c54x)
- basic_machine=tic54x-unknown
- ;;
- c55x)
- basic_machine=tic55x-unknown
- ;;
- c6x)
- basic_machine=tic6x-unknown
+ # Here we handle the default manufacturer of certain CPU types. It is in
+ # some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ cpu=hppa1.1
+ vendor=winbond
+ ;;
+ op50n)
+ cpu=hppa1.1
+ vendor=oki
+ ;;
+ op60c)
+ cpu=hppa1.1
+ vendor=oki
+ ;;
+ ibm*)
+ cpu=i370
+ vendor=ibm
+ ;;
+ orion105)
+ cpu=clipper
+ vendor=highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ cpu=m68k
+ vendor=apple
+ ;;
+ pmac | pmac-mpw)
+ cpu=powerpc
+ vendor=apple
+ ;;
+
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ cpu=m68000
+ vendor=att
+ ;;
+ 3b*)
+ cpu=we32k
+ vendor=att
+ ;;
+ bluegene*)
+ cpu=powerpc
+ vendor=ibm
+ os=cnk
+ ;;
+ decsystem10* | dec10*)
+ cpu=pdp10
+ vendor=dec
+ os=tops10
+ ;;
+ decsystem20* | dec20*)
+ cpu=pdp10
+ vendor=dec
+ os=tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ cpu=m68k
+ vendor=motorola
+ ;;
+ dpx2*)
+ cpu=m68k
+ vendor=bull
+ os=sysv3
+ ;;
+ encore | umax | mmax)
+ cpu=ns32k
+ vendor=encore
+ ;;
+ elxsi)
+ cpu=elxsi
+ vendor=elxsi
+ os=${os:-bsd}
+ ;;
+ fx2800)
+ cpu=i860
+ vendor=alliant
+ ;;
+ genix)
+ cpu=ns32k
+ vendor=ns
+ ;;
+ h3050r* | hiux*)
+ cpu=hppa1.1
+ vendor=hitachi
+ os=hiuxwe2
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ cpu=m68000
+ vendor=hp
+ ;;
+ hp9k3[2-9][0-9])
+ cpu=m68k
+ vendor=hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ cpu=hppa1.1
+ vendor=hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ cpu=hppa1.0
+ vendor=hp
+ ;;
+ i*86v32)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=sysv32
+ ;;
+ i*86v4*)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=sysv4
+ ;;
+ i*86v)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=sysv
+ ;;
+ i*86sol2)
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ os=solaris2
+ ;;
+ j90 | j90-cray)
+ cpu=j90
+ vendor=cray
+ os=${os:-unicos}
+ ;;
+ iris | iris4d)
+ cpu=mips
+ vendor=sgi
+ case $os in
+ irix*)
+ ;;
+ *)
+ os=irix4
+ ;;
+ esac
+ ;;
+ miniframe)
+ cpu=m68000
+ vendor=convergent
+ ;;
+ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ cpu=m68k
+ vendor=atari
+ os=mint
+ ;;
+ news-3600 | risc-news)
+ cpu=mips
+ vendor=sony
+ os=newsos
+ ;;
+ next | m*-next)
+ cpu=m68k
+ vendor=next
+ case $os in
+ nextstep* )
+ ;;
+ ns2*)
+ os=nextstep2
+ ;;
+ *)
+ os=nextstep3
+ ;;
+ esac
+ ;;
+ np1)
+ cpu=np1
+ vendor=gould
+ ;;
+ op50n-* | op60c-*)
+ cpu=hppa1.1
+ vendor=oki
+ os=proelf
+ ;;
+ pa-hitachi)
+ cpu=hppa1.1
+ vendor=hitachi
+ os=hiuxwe2
+ ;;
+ pbd)
+ cpu=sparc
+ vendor=tti
+ ;;
+ pbb)
+ cpu=m68k
+ vendor=tti
+ ;;
+ pc532)
+ cpu=ns32k
+ vendor=pc532
+ ;;
+ pn)
+ cpu=pn
+ vendor=gould
+ ;;
+ power)
+ cpu=power
+ vendor=ibm
+ ;;
+ ps2)
+ cpu=i386
+ vendor=ibm
+ ;;
+ psp)
+ cpu=mipsallegrexel
+ vendor=psp
+ ;;
+ rm[46]00)
+ cpu=mips
+ vendor=siemens
+ ;;
+ rtpc | rtpc-*)
+ cpu=romp
+ vendor=ibm
+ ;;
+ sde)
+ cpu=mipsisa32
+ vendor=sde
+ os=${os:-elf}
+ ;;
+ simso-wrs)
+ cpu=sparclite
+ vendor=wrs
+ os=vxworks
+ ;;
+ tower | tower-32)
+ cpu=m68k
+ vendor=ncr
+ ;;
+ vpp*|vx|vx-*)
+ cpu=f301
+ vendor=fujitsu
+ ;;
+ w65)
+ cpu=w65
+ vendor=wdc
+ ;;
+ w89k-*)
+ cpu=hppa1.1
+ vendor=winbond
+ os=proelf
+ ;;
+ none)
+ cpu=none
+ vendor=none
;;
leon|leon[3-9])
- basic_machine=sparc-$basic_machine
- ;;
- m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
- ;;
- ms1)
- basic_machine=mt-unknown
- ;;
-
- strongarm | thumb | xscale)
- basic_machine=arm-unknown
- ;;
- xgate)
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- xscaleeb)
- basic_machine=armeb-unknown
- ;;
-
- xscaleel)
- basic_machine=armel-unknown
- ;;
-
+ cpu=sparc
+ vendor=$basic_machine
+ ;;
+ leon-*|leon[3-9]-*)
+ cpu=sparc
+ vendor=`echo "$basic_machine" | sed 's/-.*//'`
+ ;;
+
+ *-*)
+ # shellcheck disable=SC2162
+ IFS="-" read cpu vendor <&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | aarch64-* | aarch64_be-* | arm64-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* | avr32-* \
- | ba-* \
- | be32-* | be64-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* \
- | c8051-* | clipper-* | craynv-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | e2k-* | elxsi-* \
- | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | hexagon-* \
- | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
- | ip2k-* | iq2000-* \
- | k1om-* \
- | le32-* | le64-* \
- | lm32-* \
- | m32c-* | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
- | microblaze-* | microblazeel-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64octeon-* | mips64octeonel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64r5900-* | mips64r5900el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa32r6-* | mipsisa32r6el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64r6-* | mipsisa64r6el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipsr5900-* | mipsr5900el-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | mt-* \
- | msp430-* \
- | nds32-* | nds32le-* | nds32be-* \
- | nios-* | nios2-* | nios2eb-* | nios2el-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | open8-* \
- | or1k*-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
- | pru-* \
- | pyramid-* \
- | riscv32-* | riscv64-* \
- | rl78-* | romp-* | rs6000-* | rx-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
- | tahoe-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tile*-* \
- | tron-* \
- | ubicom32-* \
- | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
- | vax-* \
- | visium-* \
- | wasm32-* \
- | we32k-* \
- | x86-* | x86_64-* | xc16x-* | xps100-* \
- | xstormy16-* | xtensa*-* \
- | ymp-* \
- | z8k-* | z80-*)
- ;;
- # Recognize the basic CPU types without company name, with glob match.
- xtensa*)
- basic_machine=$basic_machine-unknown
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 386bsd)
- basic_machine=i386-pc
- os=-bsd
- ;;
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=-udi
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=-scout
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
+ cpu=$basic_machine
+ vendor=pc
+ ;;
+ # These rules are duplicated from below for sake of the special case above;
+ # i.e. things that normalized to x86 arches should also default to "pc"
+ pc98)
+ cpu=i386
+ vendor=pc
+ ;;
+ x64 | amd64)
+ cpu=x86_64
+ vendor=pc
+ ;;
+ # Recognize the basic CPU types without company name.
+ *)
+ cpu=$basic_machine
+ vendor=unknown
+ ;;
+esac
+
+unset -v basic_machine
+
+# Decode basic machines in the full and proper CPU-Company form.
+case $cpu-$vendor in
+ # Here we handle the default manufacturer of certain CPU types in canonical form. It is in
+ # some cases the only manufacturer, in others, it is the most popular.
+ craynv-unknown)
+ vendor=cray
+ os=${os:-unicosmp}
+ ;;
+ c90-unknown | c90-cray)
+ vendor=cray
+ os=${os:-unicos}
+ ;;
+ fx80-unknown)
+ vendor=alliant
+ ;;
+ romp-unknown)
+ vendor=ibm
+ ;;
+ mmix-unknown)
+ vendor=knuth
+ ;;
+ microblaze-unknown | microblazeel-unknown)
+ vendor=xilinx
+ ;;
+ rs6000-unknown)
+ vendor=ibm
+ ;;
+ vax-unknown)
+ vendor=dec
+ ;;
+ pdp11-unknown)
+ vendor=dec
+ ;;
+ we32k-unknown)
+ vendor=att
+ ;;
+ cydra-unknown)
+ vendor=cydrome
+ ;;
+ i370-ibm*)
+ vendor=ibm
+ ;;
+ orion-unknown)
+ vendor=highlevel
+ ;;
+ xps-unknown | xps100-unknown)
+ cpu=xps100
+ vendor=honeywell
+ ;;
+
+ # Here we normalize CPU types with a missing or matching vendor
+ dpx20-unknown | dpx20-bull)
+ cpu=rs6000
+ vendor=bull
+ os=${os:-bosx}
+ ;;
+
+ # Here we normalize CPU types irrespective of the vendor
amd64-*)
- basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=-bsd
- ;;
- aros)
- basic_machine=i386-pc
- os=-aros
- ;;
- asmjs)
- basic_machine=asmjs-unknown
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- blackfin)
- basic_machine=bfin-unknown
- os=-linux
+ cpu=x86_64
;;
blackfin-*)
- basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=-linux
- ;;
- bluegene*)
- basic_machine=powerpc-ibm
- os=-cnk
+ cpu=bfin
+ os=linux
;;
c54x-*)
- basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ cpu=tic54x
;;
c55x-*)
- basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ cpu=tic55x
;;
c6x-*)
- basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- c90)
- basic_machine=c90-cray
- os=-unicos
- ;;
- cegcc)
- basic_machine=arm-unknown
- os=-cegcc
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | j90)
- basic_machine=j90-cray
- os=-unicos
- ;;
- craynv)
- basic_machine=craynv-cray
- os=-unicosmp
- ;;
- cr16 | cr16-*)
- basic_machine=cr16-unknown
- os=-elf
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=-elf
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=-tops10
- ;;
- decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=-tops20
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- dicos)
- basic_machine=i686-pc
- os=-dicos
- ;;
- djgpp)
- basic_machine=i586-pc
- os=-msdosdjgpp
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2*)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- e500v[12])
- basic_machine=powerpc-unknown
- os=$os"spe"
- ;;
- e500v[12]-*)
- basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=$os"spe"
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=-ose
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=-go32
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=-xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9])
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=-osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=-proelf
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- ;;
- i*86v32)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i*86v4*)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i*86v)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i*86sol2)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- i386mach)
- basic_machine=i386-mach
- os=-mach
- ;;
- vsta)
- basic_machine=i386-unknown
- os=-vsta
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- leon-*|leon[3-9]-*)
- basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
- ;;
- m68knommu)
- basic_machine=m68k-unknown
- os=-linux
+ cpu=tic6x
+ ;;
+ e500v[12]-*)
+ cpu=powerpc
+ os=$os"spe"
+ ;;
+ mips3*-*)
+ cpu=mips64
+ ;;
+ ms1-*)
+ cpu=mt
;;
m68knommu-*)
- basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=-linux
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- microblaze*)
- basic_machine=microblaze-xilinx
- ;;
- mingw64)
- basic_machine=x86_64-pc
- os=-mingw64
- ;;
- mingw32)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- mingw32ce)
- basic_machine=arm-unknown
- os=-mingw32ce
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
- mips3*-*)
- basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=-morphos
- ;;
- moxiebox)
- basic_machine=moxie-unknown
- os=-moxiebox
- ;;
- msdos)
- basic_machine=i386-pc
- os=-msdos
- ;;
- ms1-*)
- basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
- ;;
- msys)
- basic_machine=i686-pc
- os=-msys
- ;;
- mvs)
- basic_machine=i370-ibm
- os=-mvs
- ;;
- nacl)
- basic_machine=le32-unknown
- os=-nacl
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- netbsd386)
- basic_machine=i386-unknown
- os=-netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=-linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=-sysv
- ;;
- next | m*-next)
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=-mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=-nonstopux
- ;;
- np1)
- basic_machine=np1-gould
+ cpu=m68k
+ os=linux
+ ;;
+ m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
+ cpu=s12z
+ ;;
+ openrisc-*)
+ cpu=or32
+ ;;
+ parisc-*)
+ cpu=hppa
+ os=linux
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ cpu=i586
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
+ cpu=i686
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ cpu=i686
+ ;;
+ pentium4-*)
+ cpu=i786
+ ;;
+ pc98-*)
+ cpu=i386
+ ;;
+ ppc-* | ppcbe-*)
+ cpu=powerpc
+ ;;
+ ppcle-* | powerpclittle-*)
+ cpu=powerpcle
+ ;;
+ ppc64-*)
+ cpu=powerpc64
+ ;;
+ ppc64le-* | powerpc64little-*)
+ cpu=powerpc64le
+ ;;
+ sb1-*)
+ cpu=mipsisa64sb1
+ ;;
+ sb1el-*)
+ cpu=mipsisa64sb1el
+ ;;
+ sh5e[lb]-*)
+ cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
+ ;;
+ spur-*)
+ cpu=spur
+ ;;
+ strongarm-* | thumb-*)
+ cpu=arm
+ ;;
+ tx39-*)
+ cpu=mipstx39
+ ;;
+ tx39el-*)
+ cpu=mipstx39el
+ ;;
+ x64-*)
+ cpu=x86_64
+ ;;
+ xscale-* | xscalee[bl]-*)
+ cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
+ ;;
+
+ # Recognize the canonical CPU Types that limit and/or modify the
+ # company names they are paired with.
+ cr16-*)
+ os=${os:-elf}
+ ;;
+ crisv32-* | etraxfs*-*)
+ cpu=crisv32
+ vendor=axis
+ ;;
+ cris-* | etrax*-*)
+ cpu=cris
+ vendor=axis
+ ;;
+ crx-*)
+ os=${os:-elf}
;;
neo-tandem)
- basic_machine=neo-tandem
+ cpu=neo
+ vendor=tandem
;;
nse-tandem)
- basic_machine=nse-tandem
+ cpu=nse
+ vendor=tandem
;;
nsr-tandem)
- basic_machine=nsr-tandem
+ cpu=nsr
+ vendor=tandem
;;
nsv-tandem)
- basic_machine=nsv-tandem
+ cpu=nsv
+ vendor=tandem
;;
nsx-tandem)
- basic_machine=nsx-tandem
- ;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=-proelf
- ;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=-os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=-ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=-os68k
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- parisc)
- basic_machine=hppa-unknown
- os=-linux
- ;;
- parisc-*)
- basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=-linux
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pc98)
- basic_machine=i386-pc
- ;;
- pc98-*)
- basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
- ;;
- pentium4)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- pentium4-*)
- basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=power-ibm
- ;;
- ppc | ppcbe) basic_machine=powerpc-unknown
- ;;
- ppc-* | ppcbe-*)
- basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- ppc64) basic_machine=powerpc64-unknown
- ;;
- ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- ppc64le | powerpc64little)
- basic_machine=powerpc64le-unknown
- ;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- psp)
- basic_machine=mipsallegrexel-psp
- os=-elf
- ;;
- pw32)
- basic_machine=i586-unknown
- os=-pw32
- ;;
- rdos | rdos64)
- basic_machine=x86_64-pc
- os=-rdos
- ;;
- rdos32)
- basic_machine=i386-pc
- os=-rdos
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- s390 | s390-*)
- basic_machine=s390-ibm
- ;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=-udi
- ;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
- ;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
- ;;
- sde)
- basic_machine=mipsisa32-sde
- os=-elf
- ;;
- sei)
- basic_machine=mips-sei
- os=-seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh5el)
- basic_machine=sh5le-unknown
- ;;
- simso-wrs)
- basic_machine=sparclite-wrs
- os=-vxworks
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- st2000)
- basic_machine=m68k-tandem
- ;;
- stratus)
- basic_machine=i860-stratus
- os=-sysv4
- ;;
- strongarm-* | thumb-*)
- basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- sv1)
- basic_machine=sv1-cray
- os=-unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=-unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=-unicos
- ;;
- tile*)
- basic_machine=$basic_machine-unknown
- os=-linux-gnu
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=-tops20
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=-tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=-none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- w65*)
- basic_machine=w65-wdc
- os=-none
- ;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=-proelf
- ;;
- x64)
- basic_machine=x86_64-pc
- ;;
- xbox)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- xscale-* | xscalee[bl]-*)
- basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
- ;;
- ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
- ;;
- op50n)
- basic_machine=hppa1.1-oki
- ;;
- op60c)
- basic_machine=hppa1.1-oki
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- mmix)
- basic_machine=mmix-knuth
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
- ;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
- ;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
- ;;
+ cpu=nsx
+ vendor=tandem
+ ;;
+ s390-*)
+ cpu=s390
+ vendor=ibm
+ ;;
+ s390x-*)
+ cpu=s390x
+ vendor=ibm
+ ;;
+ tile*-*)
+ os=${os:-linux-gnu}
+ ;;
+
*)
- echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
- exit 1
+ # Recognize the canonical CPU types that are allowed with any
+ # company name.
+ case $cpu in
+ 1750a | 580 \
+ | a29k \
+ | aarch64 | aarch64_be | arm64 \
+ | abacus \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
+ | alphapca5[67] | alpha64pca5[67] \
+ | am33_2.0 \
+ | amdgcn \
+ | arc | arceb \
+ | arm | arm[lb]e | arme[lb] | armv* \
+ | avr | avr32 \
+ | asmjs \
+ | ba \
+ | be32 | be64 \
+ | bfin | bs2000 \
+ | c[123]* | c30 | [cjt]90 | c4x \
+ | c8051 | clipper | craynv | csky | cydra \
+ | d10v | d30v | dlx | dsp16xx \
+ | e2k | elxsi | epiphany \
+ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
+ | h8300 | h8500 \
+ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | hexagon \
+ | i370 | i*86 | i860 | i960 | ia16 | ia64 \
+ | ip2k | iq2000 \
+ | k1om \
+ | le32 | le64 \
+ | lm32 \
+ | m32c | m32r | m32rle \
+ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
+ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
+ | m88110 | m88k | maxq | mb | mcore | mep | metag \
+ | microblaze | microblazeel \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64eb | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa32r6 | mipsisa32r6el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64r6 | mipsisa64r6el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
+ | mipstx39 | mipstx39el \
+ | mmix \
+ | mn10200 | mn10300 \
+ | moxie \
+ | mt \
+ | msp430 \
+ | nds32 | nds32le | nds32be \
+ | nfp \
+ | nios | nios2 | nios2eb | nios2el \
+ | none | np1 | ns16k | ns32k | nvptx \
+ | open8 \
+ | or1k* \
+ | or32 \
+ | orion \
+ | picochip \
+ | pdp10 | pdp11 | pj | pjl | pn | power \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
+ | pru \
+ | pyramid \
+ | riscv | riscv32 | riscv64 \
+ | rl78 | romp | rs6000 | rx \
+ | score \
+ | sh | shl \
+ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
+ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
+ | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
+ | spu \
+ | tahoe \
+ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
+ | tron \
+ | ubicom32 \
+ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
+ | vax \
+ | visium \
+ | w65 | wasm32 \
+ | we32k \
+ | x86 | x86_64 | xc16x | xgate | xps100 \
+ | xstormy16 | xtensa* \
+ | ymp \
+ | z8k | z80)
+ ;;
+
+ *)
+ echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
+ exit 1
+ ;;
+ esac
;;
esac
# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
+case $vendor in
+ digital*)
+ vendor=dec
;;
- *-commodore*)
- basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
+ commodore*)
+ vendor=cbm
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
-if [ x"$os" != x"" ]
+if [ x$os != x ]
then
case $os in
# First match some system type aliases that might get confused
# with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -auroraux)
- os=-auroraux
+ # solaris* is a basic system type, with this one exception.
+ auroraux)
+ os=auroraux
;;
- -solaris1 | -solaris1.*)
+ bluegene*)
+ os=cnk
+ ;;
+ solaris1 | solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
- -solaris)
- os=-solaris2
+ solaris)
+ os=solaris2
;;
- -unixware*)
- os=-sysv4.2uw
+ unixware*)
+ os=sysv4.2uw
;;
- -gnu/linux*)
+ gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# es1800 is here to avoid being matched by es* (a different OS)
- -es1800*)
- os=-ose
+ es1800*)
+ os=ose
+ ;;
+ # Some version numbers need modification
+ chorusos*)
+ os=chorusos
+ ;;
+ isc)
+ os=isc2.2
+ ;;
+ sco6)
+ os=sco5v6
+ ;;
+ sco5)
+ os=sco3.2v5
+ ;;
+ sco4)
+ os=sco3.2v4
+ ;;
+ sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ ;;
+ sco3.2v[4-9]* | sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ ;;
+ scout)
+ # Don't match below
+ ;;
+ sco*)
+ os=sco3.2v2
+ ;;
+ psos*)
+ os=psos
;;
# Now accept the basic system types.
# The portable systems comes first.
# Each alternative MUST end in a * to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
- | -sym* | -kopensolaris* | -plan9* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* | -aros* | -cloudabi* | -sortix* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \
- | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* | -hcos* \
- | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
- | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
- | -linux-newlib* | -linux-musl* | -linux-uclibc* \
- | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
- | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \
- | -midnightbsd*)
+ # sysv* is not here because it comes later, after sysvr4.
+ gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
+ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
+ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
+ | sym* | kopensolaris* | plan9* \
+ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
+ | aos* | aros* | cloudabi* | sortix* \
+ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
+ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
+ | knetbsd* | mirbsd* | netbsd* \
+ | bitrig* | openbsd* | solidbsd* | libertybsd* \
+ | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
+ | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
+ | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
+ | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
+ | chorusrdb* | cegcc* | glidix* \
+ | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
+ | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
+ | linux-newlib* | linux-musl* | linux-uclibc* \
+ | uxpv* | beos* | mpeix* | udk* | moxiebox* \
+ | interix* | uwin* | mks* | rhapsody* | darwin* \
+ | openstep* | oskit* | conix* | pw32* | nonstopux* \
+ | storm-chaos* | tops10* | tenex* | tops20* | its* \
+ | os2* | vos* | palmos* | uclinux* | nucleus* \
+ | morphos* | superux* | rtmk* | windiss* \
+ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
+ | skyos* | haiku* | rdos* | toppers* | drops* | es* \
+ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
+ | midnightbsd* | amdhsa* | unleashed* | emscripten*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
- -qnx*)
- case $basic_machine in
- x86-* | i*86-*)
+ qnx*)
+ case $cpu in
+ x86 | i*86)
;;
*)
- os=-nto$os
+ os=nto-$os
;;
esac
;;
- -nto-qnx*)
+ hiux*)
+ os=hiuxwe2
;;
- -nto*)
+ nto-qnx*)
+ ;;
+ nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
- -sim | -xray | -os68k* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* \
- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
- ;;
- -mac*)
- os=`echo "$os" | sed -e 's|mac|macos|'`
- ;;
- -linux-dietlibc)
- os=-linux-dietlibc
- ;;
- -linux*)
+ sim | xray | os68k* | v88r* \
+ | windows* | osx | abug | netware* | os9* \
+ | macos* | mpw* | magic* | mmixware* | mon960* | lnews*)
+ ;;
+ linux-dietlibc)
+ os=linux-dietlibc
+ ;;
+ linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
- -sunos5*)
+ lynx*178)
+ os=lynxos178
+ ;;
+ lynx*5)
+ os=lynxos5
+ ;;
+ lynx*)
+ os=lynxos
+ ;;
+ mac*)
+ os=`echo "$os" | sed -e 's|mac|macos|'`
+ ;;
+ opened*)
+ os=openedition
+ ;;
+ os400*)
+ os=os400
+ ;;
+ sunos5*)
os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
;;
- -sunos6*)
+ sunos6*)
os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
;;
- -opened*)
- os=-openedition
- ;;
- -os400*)
- os=-os400
- ;;
- -wince*)
- os=-wince
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -atheos*)
- os=-atheos
- ;;
- -syllable*)
- os=-syllable
- ;;
- -386bsd)
- os=-bsd
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -nova*)
- os=-rtmk-nova
- ;;
- -ns2)
- os=-nextstep2
- ;;
- -nsk*)
- os=-nsk
+ wince*)
+ os=wince
+ ;;
+ utek*)
+ os=bsd
+ ;;
+ dynix*)
+ os=bsd
+ ;;
+ acis*)
+ os=aos
+ ;;
+ atheos*)
+ os=atheos
+ ;;
+ syllable*)
+ os=syllable
+ ;;
+ 386bsd)
+ os=bsd
+ ;;
+ ctix* | uts*)
+ os=sysv
+ ;;
+ nova*)
+ os=rtmk-nova
+ ;;
+ ns2)
+ os=nextstep2
+ ;;
+ nsk*)
+ os=nsk
;;
# Preserve the version number of sinix5.
- -sinix5.*)
+ sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
- -sinix*)
- os=-sysv4
- ;;
- -tpf*)
- os=-tpf
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -ose*)
- os=-ose
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
- ;;
- -zvmoe)
- os=-zvmoe
- ;;
- -dicos*)
- os=-dicos
- ;;
- -pikeos*)
+ sinix*)
+ os=sysv4
+ ;;
+ tpf*)
+ os=tpf
+ ;;
+ triton*)
+ os=sysv3
+ ;;
+ oss*)
+ os=sysv3
+ ;;
+ svr4*)
+ os=sysv4
+ ;;
+ svr3)
+ os=sysv3
+ ;;
+ sysvr4)
+ os=sysv4
+ ;;
+ # This must come after sysvr4.
+ sysv*)
+ ;;
+ ose*)
+ os=ose
+ ;;
+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ os=mint
+ ;;
+ zvmoe)
+ os=zvmoe
+ ;;
+ dicos*)
+ os=dicos
+ ;;
+ pikeos*)
# Until real need of OS specific support for
# particular features comes up, bare metal
# configurations are quite functional.
- case $basic_machine in
+ case $cpu in
arm*)
- os=-eabi
+ os=eabi
;;
*)
- os=-elf
+ os=elf
;;
esac
;;
- -nacl*)
+ nacl*)
+ ;;
+ ios)
;;
- -ios)
+ none)
;;
- -none)
+ *-eabi)
;;
*)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
exit 1
;;
esac
else
@@ -1545,261 +1532,268 @@
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
-case $basic_machine in
+case $cpu-$vendor in
score-*)
- os=-elf
+ os=elf
;;
spu-*)
- os=-elf
+ os=elf
;;
*-acorn)
- os=-riscix1.2
+ os=riscix1.2
;;
arm*-rebel)
- os=-linux
+ os=linux
;;
arm*-semi)
- os=-aout
+ os=aout
;;
c4x-* | tic4x-*)
- os=-coff
+ os=coff
;;
c8051-*)
- os=-elf
+ os=elf
+ ;;
+ clipper-intergraph)
+ os=clix
;;
hexagon-*)
- os=-elf
+ os=elf
;;
tic54x-*)
- os=-coff
+ os=coff
;;
tic55x-*)
- os=-coff
+ os=coff
;;
tic6x-*)
- os=-coff
+ os=coff
;;
# This must come before the *-dec entry.
pdp10-*)
- os=-tops20
+ os=tops20
;;
pdp11-*)
- os=-none
+ os=none
;;
*-dec | vax-*)
- os=-ultrix4.2
+ os=ultrix4.2
;;
m68*-apollo)
- os=-domain
+ os=domain
;;
i386-sun)
- os=-sunos4.0.2
+ os=sunos4.0.2
;;
m68000-sun)
- os=-sunos3
+ os=sunos3
;;
m68*-cisco)
- os=-aout
+ os=aout
;;
mep-*)
- os=-elf
+ os=elf
;;
mips*-cisco)
- os=-elf
+ os=elf
;;
mips*-*)
- os=-elf
+ os=elf
;;
or32-*)
- os=-coff
+ os=coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
+ os=sysv3
;;
sparc-* | *-sun)
- os=-sunos4.1.1
+ os=sunos4.1.1
;;
pru-*)
- os=-elf
+ os=elf
;;
*-be)
- os=-beos
+ os=beos
;;
*-ibm)
- os=-aix
+ os=aix
;;
*-knuth)
- os=-mmixware
+ os=mmixware
;;
*-wec)
- os=-proelf
+ os=proelf
;;
*-winbond)
- os=-proelf
+ os=proelf
;;
*-oki)
- os=-proelf
+ os=proelf
;;
*-hp)
- os=-hpux
+ os=hpux
;;
*-hitachi)
- os=-hiux
+ os=hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
+ os=sysv
;;
*-cbm)
- os=-amigaos
+ os=amigaos
;;
*-dg)
- os=-dgux
+ os=dgux
;;
*-dolphin)
- os=-sysv3
+ os=sysv3
;;
m68k-ccur)
- os=-rtu
+ os=rtu
;;
m88k-omron*)
- os=-luna
+ os=luna
;;
*-next)
- os=-nextstep
+ os=nextstep
;;
*-sequent)
- os=-ptx
+ os=ptx
;;
*-crds)
- os=-unos
+ os=unos
;;
*-ns)
- os=-genix
+ os=genix
;;
i370-*)
- os=-mvs
+ os=mvs
;;
*-gould)
- os=-sysv
+ os=sysv
;;
*-highlevel)
- os=-bsd
+ os=bsd
;;
*-encore)
- os=-bsd
+ os=bsd
;;
*-sgi)
- os=-irix
+ os=irix
;;
*-siemens)
- os=-sysv4
+ os=sysv4
;;
*-masscomp)
- os=-rtu
+ os=rtu
;;
f30[01]-fujitsu | f700-fujitsu)
- os=-uxpv
+ os=uxpv
;;
*-rom68k)
- os=-coff
+ os=coff
;;
*-*bug)
- os=-coff
+ os=coff
;;
*-apple)
- os=-macos
+ os=macos
;;
*-atari*)
- os=-mint
+ os=mint
+ ;;
+ *-wrs)
+ os=vxworks
;;
*)
- os=-none
+ os=none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
+case $vendor in
+ unknown)
case $os in
- -riscix*)
+ riscix*)
vendor=acorn
;;
- -sunos*)
+ sunos*)
vendor=sun
;;
- -cnk*|-aix*)
+ cnk*|-aix*)
vendor=ibm
;;
- -beos*)
+ beos*)
vendor=be
;;
- -hpux*)
+ hpux*)
vendor=hp
;;
- -mpeix*)
+ mpeix*)
vendor=hp
;;
- -hiux*)
+ hiux*)
vendor=hitachi
;;
- -unos*)
+ unos*)
vendor=crds
;;
- -dgux*)
+ dgux*)
vendor=dg
;;
- -luna*)
+ luna*)
vendor=omron
;;
- -genix*)
- vendor=ns
- ;;
- -mvs* | -opened*)
- vendor=ibm
- ;;
- -os400*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -tpf*)
- vendor=ibm
- ;;
- -vxsim* | -vxworks* | -windiss*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -hms*)
- vendor=hitachi
- ;;
- -mpw* | -macos*)
- vendor=apple
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- vendor=atari
- ;;
- -vos*)
+ genix*)
+ vendor=ns
+ ;;
+ clix*)
+ vendor=intergraph
+ ;;
+ mvs* | opened*)
+ vendor=ibm
+ ;;
+ os400*)
+ vendor=ibm
+ ;;
+ ptx*)
+ vendor=sequent
+ ;;
+ tpf*)
+ vendor=ibm
+ ;;
+ vxsim* | vxworks* | windiss*)
+ vendor=wrs
+ ;;
+ aux*)
+ vendor=apple
+ ;;
+ hms*)
+ vendor=hitachi
+ ;;
+ mpw* | macos*)
+ vendor=apple
+ ;;
+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ vendor=atari
+ ;;
+ vos*)
vendor=stratus
;;
esac
- basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
;;
esac
-echo "$basic_machine$os"
+echo "$cpu-$vendor-$os"
exit
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
Index: build-aux/install-sh
==================================================================
--- build-aux/install-sh
+++ build-aux/install-sh
@@ -1,501 +1,301 @@
#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2013-12-25.23; # UTC
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
+#
+# $NetBSD: install-sh.in,v 1.6 2012/01/11 13:07:31 hans Exp $
+# This script now also installs multiple files, but might choke on installing
+# multiple files with spaces in the file names.
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
-# 'make' implicit rules from creating a file called install from it
+# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
-tab=' '
-nl='
-'
-IFS=" $tab$nl"
-
-# Set DOITPROG to "echo" to test this script.
-
-doit=${DOITPROG-}
-doit_exec=${doit:-exec}
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-chgrpprog=${CHGRPPROG-chgrp}
-chmodprog=${CHMODPROG-chmod}
-chownprog=${CHOWNPROG-chown}
-cmpprog=${CMPPROG-cmp}
-cpprog=${CPPROG-cp}
-mkdirprog=${MKDIRPROG-mkdir}
-mvprog=${MVPROG-mv}
-rmprog=${RMPROG-rm}
-stripprog=${STRIPPROG-strip}
-
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chgrpcmd=
-chmodcmd=$chmodprog
-chowncmd=
-mvcmd=$mvprog
-rmcmd="$rmprog -f"
-stripcmd=
-
-src=
-dst=
-dir_arg=
-dst_arg=
-
-copy_on_change=false
-is_target_a_directory=possibly
-
-usage="\
-Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
- --help display this help and exit.
- --version display version info and exit.
-
- -c (ignored)
- -C install only if different (preserve the last data modification time)
- -d create directories instead of installing files.
- -g GROUP $chgrpprog installed files to GROUP.
- -m MODE $chmodprog installed files to MODE.
- -o USER $chownprog installed files to USER.
- -s $stripprog installed files.
- -t DIRECTORY install into DIRECTORY.
- -T report an error if DSTFILE is a directory.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
- RMPROG STRIPPROG
-"
-
-while test $# -ne 0; do
- case $1 in
- -c) ;;
-
- -C) copy_on_change=true;;
-
- -d) dir_arg=true;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) mode=$2
- case $mode in
- *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
- echo "$0: invalid mode: $mode" >&2
- exit 1;;
- esac
- shift;;
-
- -o) chowncmd="$chownprog $2"
- shift;;
-
- -s) stripcmd=$stripprog;;
-
- -t)
- is_target_a_directory=always
- dst_arg=$2
- # Protect names problematic for 'test' and other utilities.
- case $dst_arg in
- -* | [=\(\)!]) dst_arg=./$dst_arg;;
- esac
- shift;;
-
- -T) is_target_a_directory=never;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- --) shift
- break;;
-
- -*) echo "$0: invalid option: $1" >&2
- exit 1;;
-
- *) break;;
- esac
- shift
-done
-
-# We allow the use of options -d and -T together, by making -d
-# take the precedence; this is for compatibility with GNU install.
-
-if test -n "$dir_arg"; then
- if test -n "$dst_arg"; then
- echo "$0: target directory not allowed when installing a directory." >&2
- exit 1
- fi
-fi
-
-if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
- # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dst_arg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dst_arg"
- shift # fnord
- fi
- shift # arg
- dst_arg=$arg
- # Protect names problematic for 'test' and other utilities.
- case $dst_arg in
- -* | [=\(\)!]) dst_arg=./$dst_arg;;
- esac
- done
-fi
-
-if test $# -eq 0; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call 'install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-if test -z "$dir_arg"; then
- if test $# -gt 1 || test "$is_target_a_directory" = always; then
- if test ! -d "$dst_arg"; then
- echo "$0: $dst_arg: Is not a directory." >&2
- exit 1
- fi
- fi
-fi
-
-if test -z "$dir_arg"; then
- do_exit='(exit $ret); exit $ret'
- trap "ret=129; $do_exit" 1
- trap "ret=130; $do_exit" 2
- trap "ret=141; $do_exit" 13
- trap "ret=143; $do_exit" 15
-
- # Set umask so as not to create temps with too-generous modes.
- # However, 'strip' requires both read and write access to temps.
- case $mode in
- # Optimize common cases.
- *644) cp_umask=133;;
- *755) cp_umask=22;;
-
- *[0-7])
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw='% 200'
- fi
- cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
- *)
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw=,u+rw
- fi
- cp_umask=$mode$u_plus_rw;;
- esac
-fi
-
-for src
-do
- # Protect names problematic for 'test' and other utilities.
- case $src in
- -* | [=\(\)!]) src=./$src;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- dstdir=$dst
- test -d "$dstdir"
- dstdir_status=$?
- else
-
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dst_arg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
- dst=$dst_arg
-
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- if test "$is_target_a_directory" = never; then
- echo "$0: $dst_arg: Is a directory" >&2
- exit 1
- fi
- dstdir=$dst
- dst=$dstdir/`basename "$src"`
- dstdir_status=0
- else
- dstdir=`dirname "$dst"`
- test -d "$dstdir"
- dstdir_status=$?
- fi
- fi
-
- obsolete_mkdir_used=false
-
- if test $dstdir_status != 0; then
- case $posix_mkdir in
- '')
- # Create intermediate dirs using mode 755 as modified by the umask.
- # This is like FreeBSD 'install' as of 1997-10-28.
- umask=`umask`
- case $stripcmd.$umask in
- # Optimize common cases.
- *[2367][2367]) mkdir_umask=$umask;;
- .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
- *[0-7])
- mkdir_umask=`expr $umask + 22 \
- - $umask % 100 % 40 + $umask % 20 \
- - $umask % 10 % 4 + $umask % 2
- `;;
- *) mkdir_umask=$umask,go-w;;
- esac
-
- # With -d, create the new directory with the user-specified mode.
- # Otherwise, rely on $mkdir_umask.
- if test -n "$dir_arg"; then
- mkdir_mode=-m$mode
- else
- mkdir_mode=
- fi
-
- posix_mkdir=false
- case $umask in
- *[123567][0-7][0-7])
- # POSIX mkdir -p sets u+wx bits regardless of umask, which
- # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
- ;;
- *)
- tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
- trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
- if (umask $mkdir_umask &&
- exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
- then
- if test -z "$dir_arg" || {
- # Check for POSIX incompatibilities with -m.
- # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
- # other-writable bit of parent directory when it shouldn't.
- # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
- ls_ld_tmpdir=`ls -ld "$tmpdir"`
- case $ls_ld_tmpdir in
- d????-?r-*) different_mode=700;;
- d????-?--*) different_mode=755;;
- *) false;;
- esac &&
- $mkdirprog -m$different_mode -p -- "$tmpdir" && {
- ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
- test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
- }
- }
- then posix_mkdir=:
- fi
- rmdir "$tmpdir/d" "$tmpdir"
- else
- # Remove any dirs left behind by ancient mkdir implementations.
- rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
- fi
- trap '' 0;;
- esac;;
- esac
-
- if
- $posix_mkdir && (
- umask $mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
- )
- then :
- else
-
- # The umask is ridiculous, or mkdir does not conform to POSIX,
- # or it failed possibly due to a race condition. Create the
- # directory the slow way, step by step, checking for races as we go.
-
- case $dstdir in
- /*) prefix='/';;
- [-=\(\)!]*) prefix='./';;
- *) prefix='';;
- esac
-
- oIFS=$IFS
- IFS=/
- set -f
- set fnord $dstdir
- shift
- set +f
- IFS=$oIFS
-
- prefixes=
-
- for d
- do
- test X"$d" = X && continue
-
- prefix=$prefix$d
- if test -d "$prefix"; then
- prefixes=
- else
- if $posix_mkdir; then
- (umask=$mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
- # Don't fail if two instances are running concurrently.
- test -d "$prefix" || exit 1
- else
- case $prefix in
- *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
- *) qprefix=$prefix;;
- esac
- prefixes="$prefixes '$qprefix'"
- fi
- fi
- prefix=$prefix/
- done
-
- if test -n "$prefixes"; then
- # Don't fail if two instances are running concurrently.
- (umask $mkdir_umask &&
- eval "\$doit_exec \$mkdirprog $prefixes") ||
- test -d "$dstdir" || exit 1
- obsolete_mkdir_used=true
- fi
- fi
- fi
-
- if test -n "$dir_arg"; then
- { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
- { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
- test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
- else
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
- # Copy the file name to the temp name.
- (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
- { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
- { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
- # If -C, don't bother to copy if it wouldn't change the file.
- if $copy_on_change &&
- old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
- new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
- set -f &&
- set X $old && old=:$2:$4:$5:$6 &&
- set X $new && new=:$2:$4:$5:$6 &&
- set +f &&
- test "$old" = "$new" &&
- $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
- then
- rm -f "$dsttmp"
- else
- # Rename the file to the real destination.
- $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
- {
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- test ! -f "$dst" ||
- $doit $rmcmd -f "$dst" 2>/dev/null ||
- { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
- { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
- } ||
- { echo "$0: cannot unlink or rename $dst" >&2
- (exit 1); exit 1
- }
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dst"
- }
- fi || exit 1
-
- trap '' 0
- fi
-done
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+awkprog="${AWKPROG-awk}"
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+instcmd="$cpprog"
+instflags=""
+pathcompchmodcmd="$chmodprog 755"
+chmodcmd="$chmodprog 755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+stripflags=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+msrc=""
+dst=""
+dir_arg=""
+suffix=""
+suffixfmt=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -b) suffix=".old"
+ shift
+ continue;;
+
+ -B) suffixfmt="$2"
+ shift
+ shift
+ continue;;
+
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -m*)
+ chmodcmd="$chmodprog ${1#-m}"
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -S) stripcmd="$stripprog"
+ stripflags="-S $2 $stripflags"
+ shift
+ shift
+ continue;;
+
+ -p) instflags="-p"
+ shift
+ continue;;
+
+ *) if [ x"$msrc" = x ]
+ then
+ msrc="$dst"
+ else
+ msrc="$msrc $dst"
+ fi
+ src="$dst"
+ dst="$1"
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$dir_arg" = x ]
+then
+ dstisfile=""
+ if [ ! -d "$dst" ]
+ then
+ if [ x"$msrc" = x"$src" ]
+ then
+ dstisfile=true
+ else
+ echo "install: destination is not a directory"
+ exit 1
+ fi
+ fi
+else
+ msrc="$msrc $dst"
+fi
+
+if [ x"$msrc" = x ]
+then
+ echo "install: no destination specified"
+ exit 1
+fi
+
+for srcarg in $msrc; do
+
+if [ x"$dir_arg" != x ]; then
+
+ dstarg="$srcarg"
+else
+ dstarg="$dst"
+
+# Waiting for this to be detected by the "$instcmd $srcarg $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f "$srcarg" ]
+ then
+ doinst="$instcmd $instflags"
+ elif [ -d "$srcarg" ]
+ then
+ echo "install: $srcarg: not a regular file"
+ exit 1
+ elif [ "$srcarg" = "/dev/null" ]
+ then
+ doinst="$cpprog"
+ else
+ echo "install: $srcarg does not exist"
+ exit 1
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d "$dstarg" ]
+ then
+ dstarg="$dstarg"/`basename "$srcarg"`
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $doit $mkdirprog "${pathcomp}"
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "${pathcomp}"; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "${pathcomp}"; else true ; fi &&
+ if [ x"$pathcompchmodcmd" != x ]; then $doit $pathcompchmodcmd "${pathcomp}"; else true ; fi
+
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+ if [ x"$dir_arg" != x ]
+ then
+ if [ -d "$dstarg" ]; then
+ true
+ else
+ $doit $mkdirprog "$dstarg" &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dstarg"; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dstarg"; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dstarg"; else true ; fi
+ fi
+ else
+
+ if [ x"$dstisfile" = x ]
+ then
+ file=$srcarg
+ else
+ file=$dst
+ fi
+
+ dstfile=`basename "$file"`
+ dstfinal="$dstdir/$dstfile"
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Make a backup file name in the proper directory.
+ case x$suffixfmt in
+ *%*) suffix=`echo x |
+ $awkprog -v bname="$dstfinal" -v fmt="$suffixfmt" '
+ { cnt = 0;
+ do {
+ sfx = sprintf(fmt, cnt++);
+ name = bname sfx;
+ } while (system("test -f " name) == 0);
+ print sfx; }' -`;;
+ x) ;;
+ *) suffix="$suffixfmt";;
+ esac
+ dstbackup="$dstfinal$suffix"
+
+# Move or copy the file name to the temp name
+
+ $doit $doinst $srcarg "$dsttmp" &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripflags "$dsttmp"; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ if [ x"$suffix" != x ] && [ -f "$dstfinal" ]
+ then
+ $doit $mvcmd "$dstfinal" "$dstbackup"
+ else
+ $doit $rmcmd -f "$dstfinal"
+ fi &&
+ $doit $mvcmd "$dsttmp" "$dstfinal"
+ fi
+
+done &&
+
+
+exit 0
Index: build-aux/m4/buildsys.m4
==================================================================
--- build-aux/m4/buildsys.m4
+++ build-aux/m4/buildsys.m4
@@ -1,8 +1,8 @@
dnl
dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017,
-dnl 2018, 2020
+dnl 2018, 2020, 2021
dnl Jonathan Schleifer
dnl
dnl https://fossil.nil.im/buildsys
dnl
dnl Permission to use, copy, modify, and/or distribute this software for any
@@ -24,18 +24,28 @@
AC_DEFUN([BUILDSYS_INIT], [
AC_REQUIRE([AC_CANONICAL_BUILD])
AC_REQUIRE([AC_CANONICAL_HOST])
- case "$build_os" in
- darwin*)
- case "$host_os" in
- darwin*)
- AC_SUBST(BUILD_AND_HOST_ARE_DARWIN, yes)
- ;;
- esac
- ;;
+ AC_ARG_ENABLE(rpath,
+ AS_HELP_STRING([--disable-rpath], [do not use rpath]))
+
+ case "$build_os" in
+ darwin*)
+ case "$host_os" in
+ darwin*)
+ AC_SUBST(BUILD_AND_HOST_ARE_DARWIN, yes)
+ ;;
+ esac
+ ;;
+ esac
+
+ AC_PROG_INSTALL
+ case "$INSTALL" in
+ ./build-aux/install-sh*)
+ INSTALL="$PWD/$INSTALL"
+ ;;
esac
AC_CONFIG_COMMANDS_PRE([
AS_IF([test x"$GCC" = x"yes"],
[AC_SUBST(DEP_CFLAGS, '-MD -MF $${out%.o}.dep')])
@@ -47,11 +57,21 @@
[AC_SUBST(DEP_OBJCXXFLAGS, '-MD -MF $${out%.o}.dep')])
AC_SUBST(AMIGA_LIB_CFLAGS)
AC_SUBST(AMIGA_LIB_LDFLAGS)
- AC_PATH_PROG(TPUT, tput)
+ case "$build_os" in
+ morphos*)
+ dnl Don't use tput on MorphOS: The colored output is
+ dnl quite unreadable and in some MorphOS versions the
+ dnl output from tput is not 8-bit safe, with awk (for
+ dnl AC_SUBST) failing as a result.
+ ;;
+ *)
+ AC_PATH_PROG(TPUT, tput)
+ ;;
+ esac
AS_IF([test x"$TPUT" != x""], [
if x=$($TPUT el 2>/dev/null); then
AC_SUBST(TERM_EL, "$x")
else
@@ -110,45 +130,44 @@
])
])
AC_DEFUN([BUILDSYS_CHECK_IOS], [
case "$host_os" in
- darwin*)
- AC_MSG_CHECKING(whether host is iOS)
- AC_EGREP_CPP(yes, [
- #include
-
- #if (defined(TARGET_OS_IPHONE) && \
- TARGET_OS_IPHONE) || \
- (defined(TARGET_OS_SIMULATOR) && \
- TARGET_OS_SIMULATOR)
- yes
- #endif
- ], [
- host_is_ios="yes"
- ], [
- host_is_ios="no"
- ])
- AC_MSG_RESULT($host_is_ios)
- ;;
+ darwin*)
+ AC_MSG_CHECKING(whether host is iOS)
+ AC_EGREP_CPP(yes, [
+ #include
+
+ #if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
+ (defined(TARGET_OS_SIMULATOR) && \
+ TARGET_OS_SIMULATOR)
+ yes
+ #endif
+ ], [
+ host_is_ios="yes"
+ ], [
+ host_is_ios="no"
+ ])
+ AC_MSG_RESULT($host_is_ios)
+ ;;
esac
])
AC_DEFUN([BUILDSYS_PROG_IMPLIB], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_MSG_CHECKING(whether we need an implib)
case "$host_os" in
- cygwin* | mingw*)
- AC_MSG_RESULT(yes)
- PROG_IMPLIB_NEEDED='yes'
- PROG_IMPLIB_LDFLAGS='-Wl,--export-all-symbols,--out-implib,lib${PROG}.a'
- ;;
- *)
- AC_MSG_RESULT(no)
- PROG_IMPLIB_NEEDED='no'
- PROG_IMPLIB_LDFLAGS=''
- ;;
+ cygwin* | mingw*)
+ AC_MSG_RESULT(yes)
+ PROG_IMPLIB_NEEDED='yes'
+ PROG_IMPLIB_LDFLAGS='-Wl,--export-all-symbols,--out-implib,lib${PROG}.a'
+ ;;
+ *)
+ AC_MSG_RESULT(no)
+ PROG_IMPLIB_NEEDED='no'
+ PROG_IMPLIB_LDFLAGS=''
+ ;;
esac
AC_SUBST(PROG_IMPLIB_NEEDED)
AC_SUBST(PROG_IMPLIB_LDFLAGS)
])
@@ -156,130 +175,180 @@
AC_DEFUN([BUILDSYS_SHARED_LIB], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_MSG_CHECKING(for shared library system)
- case "$host_os" in
- darwin*)
- AC_MSG_RESULT(Darwin)
- LIB_CFLAGS='-fPIC -DPIC'
- LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
- LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib'
- LIB_PREFIX='lib'
- LIB_SUFFIX='.dylib'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}'
- PLUGIN_SUFFIX='.bundle'
- AS_IF([test x"$host_is_ios" = x"yes"], [
- LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
- ], [
- LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
- ])
- INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
- UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
- INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/'
- UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i'
- CLEAN_LIB=''
- ;;
- mingw* | cygwin*)
- AC_MSG_RESULT(MinGW / Cygwin)
- LIB_CFLAGS=''
- LIB_LDFLAGS='-shared -Wl,--export-all-symbols,--out-implib,lib${SHARED_LIB}.a'
- LIB_LDFLAGS_INSTALL_NAME=''
- LIB_PREFIX=''
- LIB_SUFFIX='.dll'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
- PLUGIN_CFLAGS=''
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.dll'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
- INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$$i.a ${DESTDIR}${libdir}/lib$$i.a'
- UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/lib$$i.a'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
- CLEAN_LIB='${SHARED_LIB}.a'
- ;;
- openbsd* | mirbsd*)
- AC_MSG_RESULT(OpenBSD)
- LIB_CFLAGS='-fPIC -DPIC'
- LIB_LDFLAGS='-shared'
- LIB_LDFLAGS_INSTALL_NAME=''
- LIB_PREFIX='lib'
- LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
- INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
- UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
- CLEAN_LIB=''
- ;;
- solaris*)
- AC_MSG_RESULT(Solaris)
- LIB_CFLAGS='-fPIC -DPIC'
- LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}.${LIB_MINOR}'
- LIB_LDFLAGS_INSTALL_NAME=''
- LIB_PREFIX='lib'
- LIB_SUFFIX='.so'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
- INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
- UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
- CLEAN_LIB=''
- ;;
- *-android*)
- AC_MSG_RESULT(Android)
- LIB_CFLAGS='-fPIC -DPIC'
- LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}'
- LIB_LDFLAGS_INSTALL_NAME=''
- LIB_PREFIX='lib'
- LIB_SUFFIX='.so'
- LDFLAGS_RPATH=''
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
- INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
- UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
- CLEAN_LIB=''
- ;;
- *)
- AC_MSG_RESULT(ELF)
- LIB_CFLAGS='-fPIC -DPIC'
- LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}'
- LIB_LDFLAGS_INSTALL_NAME=''
- LIB_PREFIX='lib'
- LIB_SUFFIX='.so'
- LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
- INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
- UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
- CLEAN_LIB=''
- ;;
+ case "$host" in
+ *-*-darwin*)
+ AC_MSG_RESULT(Darwin)
+ LIB_CFLAGS='-fPIC -DPIC'
+ LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
+ LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib'
+ LIB_PREFIX='lib'
+ LIB_SUFFIX='.dylib'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}'
+ PLUGIN_SUFFIX='.bundle'
+ AS_IF([test x"$host_is_ios" = x"yes"], [
+ LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
+ ], [
+ LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
+ ])
+ INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
+ INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/'
+ UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB=''
+ ;;
+ *-*-mingw* | *-*-cygwin*)
+ AC_MSG_RESULT(MinGW / Cygwin)
+ LIB_CFLAGS=''
+ LIB_LDFLAGS='-shared -Wl,--export-all-symbols'
+ LIB_LDFLAGS_INSTALL_NAME=''
+ LIB_PREFIX=''
+ LIB_SUFFIX='${LIB_MAJOR}.dll'
+ LINK_LIB='&& ${LN_S} $$out lib$${out%${LIB_SUFFIX}}.dll.a'
+ PLUGIN_CFLAGS=''
+ PLUGIN_LDFLAGS='-shared -Wl,--export-all-symbols'
+ PLUGIN_SUFFIX='.dll'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$${i%${LIB_SUFFIX}}.dll.a ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB='${SHARED_LIB}.a ${SHARED_LIB_NOINST}.a'
+ ;;
+ *-*-openbsd* | *-*-mirbsd*)
+ AC_MSG_RESULT(OpenBSD)
+ LIB_CFLAGS='-fPIC -DPIC'
+ LIB_LDFLAGS='-shared'
+ LIB_LDFLAGS_INSTALL_NAME=''
+ LIB_PREFIX='lib'
+ LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.so'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB=''
+ ;;
+ *-*-solaris*)
+ AC_MSG_RESULT(Solaris)
+ LIB_CFLAGS='-fPIC -DPIC'
+ LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}.${LIB_MINOR}'
+ LIB_LDFLAGS_INSTALL_NAME=''
+ LIB_PREFIX='lib'
+ LIB_SUFFIX='.so'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.so'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB=''
+ ;;
+ *-*-android*)
+ AC_MSG_RESULT(Android)
+ LIB_CFLAGS='-fPIC -DPIC'
+ LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
+ LIB_LDFLAGS_INSTALL_NAME=''
+ LIB_PREFIX='lib'
+ LIB_SUFFIX='.so'
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.so'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB=''
+ ;;
+ hppa*-*-hpux*)
+ AC_MSG_RESULT([HP-UX (PA-RISC)])
+ LIB_CFLAGS='-fPIC -DPIC'
+ LIB_LDFLAGS='-shared -Wl,+h,$$out'
+ LIB_LDFLAGS_INSTALL_NAME=''
+ LIB_PREFIX='lib'
+ LIB_SUFFIX='.${LIB_MAJOR}'
+ LINK_LIB='&& rm -f $${out%%.*}.sl && ${LN_S} $$out $${out%%.*}.sl'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,+b,${libdir}'
+ ])
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.sl'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB=''
+ ;;
+ ia64*-*-hpux*)
+ AC_MSG_RESULT([HP-UX (Itanium)])
+ LIB_CFLAGS='-fPIC -DPIC'
+ LIB_LDFLAGS='-shared -Wl,+h,$$out'
+ LIB_LDFLAGS_INSTALL_NAME=''
+ LIB_PREFIX='lib'
+ LIB_SUFFIX='.${LIB_MAJOR}'
+ LINK_LIB='&& rm -f $${out%%.*}.so && ${LN_S} $$out $${out%%.*}.so'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,+b,${libdir}'
+ ])
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.so'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.so'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.so'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB=''
+ ;;
+ *)
+ AC_MSG_RESULT(ELF)
+ LIB_CFLAGS='-fPIC -DPIC'
+ LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
+ LIB_LDFLAGS_INSTALL_NAME=''
+ LIB_PREFIX='lib'
+ LIB_SUFFIX='.so'
+ AS_IF([test x"$enable_rpath" != x"no"], [
+ LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
+ ])
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.so'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
+ UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ CLEAN_LIB=''
+ ;;
esac
AC_SUBST(LIB_CFLAGS)
AC_SUBST(LIB_LDFLAGS)
AC_SUBST(LIB_LDFLAGS_INSTALL_NAME)
AC_SUBST(LIB_PREFIX)
AC_SUBST(LIB_SUFFIX)
+ AC_SUBST(LINK_LIB)
AC_SUBST(LDFLAGS_RPATH)
AC_SUBST(PLUGIN_CFLAGS)
AC_SUBST(PLUGIN_LDFLAGS)
AC_SUBST(PLUGIN_SUFFIX)
AC_SUBST(LINK_PLUGIN)
@@ -296,21 +365,22 @@
AC_REQUIRE([BUILDSYS_SHARED_LIB])
AC_CHECK_TOOL(CODESIGN, codesign)
case "$host_os" in
- darwin*)
- AS_IF([test x"$host_is_ios" = x"yes"], [
- FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
- FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}'
- ], [
- FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
- FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}'
- ])
-
- AC_SUBST(FRAMEWORK_LDFLAGS)
- AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME)
-
- $1
- ;;
+ darwin*)
+ AS_IF([test x"$host_is_ios" = x"yes"], [
+ FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
+ FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}'
+ ], [
+ FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
+ FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}'
+ ])
+
+ AC_SUBST(FRAMEWORK_LDFLAGS)
+ AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME)
+ AC_SUBST(FRAMEWORK_LIBS)
+
+ $1
+ ;;
esac
])
ADDED build-aux/m4/pkg.m4
Index: build-aux/m4/pkg.m4
==================================================================
--- /dev/null
+++ build-aux/m4/pkg.m4
@@ -0,0 +1,343 @@
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 11 (pkg-config-0.29.1)
+
+dnl Copyright © 2004 Scott James Remnant .
+dnl Copyright © 2012-2015 Dan Nicholson
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+ [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_default([$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes ],
+ [pkg_failed=yes])
+ else
+ pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ AC_MSG_RESULT([no])
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+ ])
+elif test $pkg_failed = untried; then
+ AC_MSG_RESULT([no])
+ m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see .])[]dnl
+ ])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ $3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+ [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+ [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+ [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+ [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+ [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+ [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
+
+dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
+dnl [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------
+dnl
+dnl Prepare a "--with-" configure option using the lowercase
+dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
+dnl PKG_CHECK_MODULES in a single macro.
+AC_DEFUN([PKG_WITH_MODULES],
+[
+m4_pushdef([with_arg], m4_tolower([$1]))
+
+m4_pushdef([description],
+ [m4_default([$5], [build with ]with_arg[ support])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
+
+m4_case(def_arg,
+ [yes],[m4_pushdef([with_without], [--without-]with_arg)],
+ [m4_pushdef([with_without],[--with-]with_arg)])
+
+AC_ARG_WITH(with_arg,
+ AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+ [AS_TR_SH([with_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([with_]with_arg)],
+ [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+ [auto],[PKG_CHECK_MODULES([$1],[$2],
+ [m4_n([def_action_if_found]) $3],
+ [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+])dnl PKG_WITH_MODULES
+
+dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl [DESCRIPTION], [DEFAULT])
+dnl -----------------------------------------------
+dnl
+dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
+dnl check._[VARIABLE-PREFIX] is exported as make variable.
+AC_DEFUN([PKG_HAVE_WITH_MODULES],
+[
+PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
+
+AM_CONDITIONAL([HAVE_][$1],
+ [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+])dnl PKG_HAVE_WITH_MODULES
+
+dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------------------
+dnl
+dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
+dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
+dnl and preprocessor variable.
+AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
+[
+PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
+
+AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
+ [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
+])dnl PKG_HAVE_DEFINE_WITH_MODULES
Index: buildsys.mk.in
==================================================================
--- buildsys.mk.in
+++ buildsys.mk.in
@@ -1,8 +1,8 @@
#
# Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
-# 2017, 2018, 2020
+# 2017, 2018, 2020, 2021
# Jonathan Schleifer
#
# https://fossil.nil.im/buildsys
#
# Permission to use, copy, modify, and/or distribute this software for any
@@ -54,17 +54,19 @@
LIB_CFLAGS = @LIB_CFLAGS@
LIB_LDFLAGS = @LIB_LDFLAGS@
LIB_LDFLAGS_INSTALL_NAME = @LIB_LDFLAGS_INSTALL_NAME@
LIB_PREFIX = @LIB_PREFIX@
LIB_SUFFIX = @LIB_SUFFIX@
+LINK_LIB = @LINK_LIB@
AMIGA_LIB_CFLAGS = @AMIGA_LIB_CFLAGS@
AMIGA_LIB_LDFLAGS = @AMIGA_LIB_LDFLAGS@
PLUGIN_CFLAGS = @PLUGIN_CFLAGS@
PLUGIN_LDFLAGS = @PLUGIN_LDFLAGS@
PLUGIN_SUFFIX = @PLUGIN_SUFFIX@
FRAMEWORK_LDFLAGS = @FRAMEWORK_LDFLAGS@
FRAMEWORK_LDFLAGS_INSTALL_NAME = @FRAMEWORK_LDFLAGS_INSTALL_NAME@
+FRAMEWORK_LIBS = @FRAMEWORK_LIBS@
CODESIGN = @CODESIGN@
CODESIGN_IDENTITY ?= -
CLEAN_LIB = @CLEAN_LIB@
DEP_ASFLAGS = @DEP_ASFLAGS@
DEP_CFLAGS = @DEP_CFLAGS@
@@ -146,11 +148,12 @@
${DIR_LEAVE}; \
done
depend: pre-depend
: >.deps
- for i in ${DEPS}; do \
+ for i in "" ${DEPS}; do \
+ test x"$$i" = x"" && continue; \
echo "-include \$${.CURDIR}/$$i" >>.deps; \
done
pre-depend:
@@ -180,11 +183,11 @@
fi
${SHARED_LIB} ${SHARED_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA}
${LINK_STATUS}
out="$@"; \
- if ${LD} -o $@ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LIB_LDFLAGS} ${LIB_LDFLAGS_INSTALL_NAME} ${LDFLAGS} ${LIBS}; then \
+ if ${LD} -o $@ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LIB_LDFLAGS} ${LIB_LDFLAGS_INSTALL_NAME} ${LDFLAGS} ${LIBS} ${LINK_LIB}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi
@@ -207,11 +210,11 @@
done
if test x"${includesubdir}" = x"${COPY_HEADERS_IF_SUBDIR}"; then \
for i in "" ${INCLUDES}; do \
test x"$$i" = x"" && continue; \
- ${MKDIR_P} ${COPY_HEADERS_DESTINATION} || exit $$?; \
+ ${MKDIR_P} $$(dirname ${COPY_HEADERS_DESTINATION}/$$i) || exit $$?; \
${INSTALL} -m 644 $$i ${COPY_HEADERS_DESTINATION}/$$i || exit $$?; \
done \
fi
${AMIGA_LIB} ${AMIGA_LIB_NOINST}: ${EXT_DEPS} ${AMIGA_LIB_OBJS_START} ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA}
@@ -246,16 +249,16 @@
out="$@"; \
objs=""; \
ars=""; \
for i in ${OBJS} ${OBJS_EXTRA}; do \
case $$i in \
- *.a) \
- ars="$$ars $$i" \
- ;; \
- *.o) \
- objs="$$objs $$i" \
- ;; \
+ *.a) \
+ ars="$$ars $$i" \
+ ;; \
+ *.o) \
+ objs="$$objs $$i" \
+ ;; \
esac \
done; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
@@ -293,16 +296,16 @@
out="$@"; \
objs=""; \
ars=""; \
for i in ${LIB_OBJS} ${LIB_OBJS_EXTRA}; do \
case $$i in \
- *.a) \
- ars="$$ars $$i" \
- ;; \
- *.o) \
- objs="$$objs $$i" \
- ;; \
+ *.a) \
+ ars="$$ars $$i" \
+ ;; \
+ *.o) \
+ objs="$$objs $$i" \
+ ;; \
esac \
done; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
@@ -332,16 +335,16 @@
out="$@"; \
objs=""; \
ars=""; \
for i in ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA}; do \
case $$i in \
- *.a) \
- ars="$$ars $$i" \
- ;; \
- *.o) \
- objs="$$objs $$i" \
- ;; \
+ *.a) \
+ ars="$$ars $$i" \
+ ;; \
+ *.o) \
+ objs="$$objs $$i" \
+ ;; \
esac \
done; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
@@ -728,11 +731,11 @@
if test x"${INSTALL_INCLUDES}" = x"yes"; then \
for i in "" ${INCLUDES}; do \
test x"$$i" = x"" && continue; \
${INSTALL_STATUS}; \
- if ${MKDIR_P} ${DESTDIR}${includedir}/${includesubdir} && ${INSTALL} -m 644 $$i ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
+ if ${MKDIR_P} $$(dirname ${DESTDIR}${includedir}/${includesubdir}/$$i) && ${INSTALL} -m 644 $$i ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done \
@@ -883,11 +886,11 @@
${DIR_LEAVE}; \
done
: >.deps
- for i in "" ${DEPS} ${OBJS} ${OBJS_EXTRA} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${AMIGA_LIB} ${AMIGA_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${STATIC_AMIGA_LIB} ${STATIC_AMIGA_LIB_NOINST} ${FRAMEWORK} ${PLUGIN} ${PLUGIN_NOINST} ${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \
+ for i in "" ${DEPS} ${OBJS} ${OBJS_EXTRA} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_START} ${AMIGA_LIB_OBJS_EXTRA} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${AMIGA_LIB} ${AMIGA_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${STATIC_AMIGA_LIB} ${STATIC_AMIGA_LIB_NOINST} ${FRAMEWORK} ${PLUGIN} ${PLUGIN_NOINST} ${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \
test x"$$i" = x"" && continue; \
if test -f $$i -o -d $$i; then \
if rm -fr $$i; then \
${DELETE_OK}; \
else \
Index: configure.ac
==================================================================
--- configure.ac
+++ configure.ac
@@ -1,6 +1,6 @@
-AC_INIT(ObjFW, 1.1-dev, js@nil.im)
+AC_INIT(ObjFW, 1.1dev, js@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])
@@ -17,131 +17,135 @@
BUILDSYS_INIT
AC_CANONICAL_HOST
-AC_ARG_WITH(ixemul,
- AS_HELP_STRING([--with-ixemul], [build with ixemul]))
-
dnl Used to disable checking for -pedantic on some platforms where it's broken
check_pedantic="yes"
case "$host" in
- arm-*-riscos*)
- AS_IF([test x"$OBJCFLAGS" = x""], [
- OBJCFLAGS="-O2 -g"
- ])
- flags="-mfloat-abi=softfp -mfpu=vfp -mlibscl"
- ASFLAGS="$ASFLAGS -mfloat-abi=softfp -mfpu=vfp"
- OBJCFLAGS="$OBJCFLAGS $flags"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
- LDFLAGS="$LDFLAGS $flags"
-
- enable_shared="no"
- enable_threads="no"
- enable_sockets="no"
- enable_files="no"
- ;;
- m68k-*-amigaos*)
- AS_IF([test x"$OBJCFLAGS" = x""], [
- OBJCFLAGS="-O0"
- ])
- OBJCFLAGS="$OBJCFLAGS -noixemul"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
- CPPFLAGS="$CPPFLAGS -D__NO_NET_API"
- LDFLAGS="$LDFLAGS -noixemul"
-
- enable_files="yes" # Required for reading ENV:
- enable_shared="no"
- supports_amiga_lib="yes"
-
- AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt68k.library)
- AC_SUBST(SFDC_TARGET, m68k-amigaos)
- AC_SUBST(SFD_FILE, amigaos3.sfd)
- AC_SUBST(SFDC_INLINE_H, inline.h)
- dnl For 68000, GCC emits calls to helper functions that
- dnl do not work properly in a library.
- t="-mcpu=68020 -fbaserel -noixemul"
- AC_SUBST(AMIGA_LIB_CFLAGS, "$t -ffreestanding")
- AC_SUBST(AMIGA_LIB_LDFLAGS,
- "$t -resident -nostartfiles")
- ])
-
- AC_SUBST(LIBBASES_M, libbases.m)
- ;;
- powerpc-*-amigaos*)
- CPPFLAGS="$CPPFLAGS -D__USE_INLINE__"
-
- enable_files="yes" # Required for reading ENV:
- enable_shared="no"
-
- AC_SUBST(LIBBASES_M, libbases.m)
- ;;
- *-morphos*)
- AS_IF([test x"$with_ixemul" != x"yes"], [
- AS_IF([test x"$OBJCFLAGS" = x""], [
- OBJCFLAGS="-O2 -g"
- ])
- OBJCFLAGS="$OBJCFLAGS -noixemul"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
- LDFLAGS="$LDFLAGS -noixemul"
- enable_files="yes" # Required for reading ENV:
- supports_amiga_lib="yes"
- check_pedantic="no" # Breaks generated inlines
-
- AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt.library)
- AC_SUBST(CVINCLUDE_INLINE_H, inline.h)
- t="-mresident32 -ffreestanding -noixemul"
- AC_SUBST(AMIGA_LIB_CFLAGS, $t)
- t="-mresident32 -nostartfiles -nodefaultlibs"
- t="$t -noixemul -lc"
- AC_SUBST(AMIGA_LIB_LDFLAGS, $t)
- ])
-
- AC_SUBST(LIBBASES_M, libbases.m)
- ])
-
- enable_shared="no"
- enable_threads="no"
- ;;
- *-msdosdjgpp*)
- enable_shared="no"
- enable_threads="no"
- enable_sockets="no"
- ;;
- *-*-mingw*)
- LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
- LIBS="$LIBS -lversion"
-
- AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}')
- ;;
- *-psp-*)
- AS_IF([test x"$DEVKITPSP" = x""], [
- AC_MSG_ERROR(
- [DEVKITPSP is not set! Please set DEVKITPSP.])
- ])
-
- AS_IF([test x"$OBJCFLAGS" = x""], [
- OBJCFLAGS="-O2"
- ])
- OBJCFLAGS="$OBJCFLAGS -G0"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -G0"
- CPPFLAGS="$CPPFLAGS -I$DEVKITPSP/psp/sdk/include"
- LDFLAGS="$LDFLAGS -G0"
- LIBS="$LIBS -L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay"
- LIBS="$LIBS -lpspge -lpspctrl -lpspsdk -lc -lpspnet"
- LIBS="$LIBS -lpspnet_inet -lpspnet_apctl -lpspnet_resolver"
- LIBS="$LIBS -lpsputility -lpspuser -lpspkernel -lgcc -lpsplibc"
- enable_shared="no"
- enable_threads="no" # TODO
- enable_sockets="no" # TODO
- check_pedantic="no"
-
- AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
- ;;
+arm-*-riscos*)
+ AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"])
+ flags="-mfloat-abi=softfp -mfpu=vfp -mlibscl"
+ ASFLAGS="$ASFLAGS -mfloat-abi=softfp -mfpu=vfp"
+ OBJCFLAGS="$OBJCFLAGS $flags"
+ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags"
+ LDFLAGS="$LDFLAGS $flags"
+
+ enable_shared="no"
+ enable_threads="no"
+ enable_sockets="no"
+ enable_files="no"
+ ;;
+m68k-*-amigaos*)
+ AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O0"])
+ OBJCFLAGS="$OBJCFLAGS -noixemul"
+ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
+ CPPFLAGS="$CPPFLAGS -D__NO_NET_API"
+ LDFLAGS="$LDFLAGS -noixemul"
+ LIBS="$LIBS -ldebug"
+
+ enable_files="yes" # Required for reading ENV:
+ enable_shared="no"
+ with_tls="no"
+ supports_amiga_lib="yes"
+
+ AS_IF([test x"$enable_amiga_lib" != x"no"], [
+ AC_SUBST(OBJFWRT_AMIGA_LIB,
+ ['objfwrt${OBJFWRT_LIB_MAJOR}.library'])
+ dnl For 68000, GCC emits calls to helper functions that
+ dnl do not work properly in a library.
+ t="-mcpu=68020 -fbaserel -noixemul -ffreestanding"
+ AC_SUBST(AMIGA_LIB_CFLAGS, $t)
+ t="$t -resident -nostartfiles -nodefaultlibs -ldebug -lc"
+ AC_SUBST(AMIGA_LIB_LDFLAGS, $t)
+ ])
+
+ AC_SUBST(LIBBASES_M, libbases.m)
+ ;;
+powerpc-*-amigaos*)
+ CPPFLAGS="$CPPFLAGS -D__USE_INLINE__"
+
+ enable_files="yes" # Required for reading ENV:
+ enable_shared="no"
+ with_tls="no"
+
+ AC_SUBST(LIBBASES_M, libbases.m)
+ ;;
+*-morphos*)
+ AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"])
+ OBJCFLAGS="$OBJCFLAGS -noixemul"
+ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul"
+ LDFLAGS="$LDFLAGS -noixemul"
+ LIBS="$LIBS -ldebug"
+
+ enable_files="yes" # Required for reading ENV:
+ enable_shared="no"
+ supports_amiga_lib="yes"
+
+ AS_IF([test x"$enable_amiga_lib" != x"no"], [
+ AC_SUBST(OBJFWRT_AMIGA_LIB,
+ ['objfwrt${OBJFW_LIB_MAJOR}ppc.library'])
+ t="-mresident32 -ffreestanding -noixemul"
+ AC_SUBST(AMIGA_LIB_CFLAGS, $t)
+ t="-mresident32 -nostartfiles -nodefaultlibs -noixemul -ldebug"
+ AC_SUBST(AMIGA_LIB_LDFLAGS, "$t -lc")
+ ])
+
+ AC_SUBST(LIBBASES_M, libbases.m)
+ ;;
+*-msdosdjgpp*)
+ enable_shared="no"
+ enable_threads="no"
+ enable_sockets="no"
+ ;;
+*-*-mingw*)
+ LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
+ LIBS="$LIBS -lversion"
+
+ AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}')
+ ;;
+*-psp-*)
+ AS_IF([test x"$DEVKITPSP" = x""], [
+ AC_MSG_ERROR([DEVKITPSP is not set! Please set DEVKITPSP.])
+ ])
+
+ AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"])
+ OBJCFLAGS="$OBJCFLAGS -G0"
+ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -G0"
+ CPPFLAGS="$CPPFLAGS -I$DEVKITPSP/psp/sdk/include"
+ LDFLAGS="$LDFLAGS -G0"
+ LIBS="$LIBS -L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay"
+ LIBS="$LIBS -lpspge -lpspctrl -lpspsdk -lc -lpspnet"
+ LIBS="$LIBS -lpspnet_inet -lpspnet_apctl -lpspnet_resolver"
+ LIBS="$LIBS -lpsputility -lpspuser -lpspkernel -lgcc -lpsplibc"
+ enable_shared="no"
+ enable_threads="no" # TODO
+ enable_sockets="no" # TODO
+ check_pedantic="no"
+
+ AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
+ ;;
+hppa*-*-hpux*)
+ dnl Don't default to -g: It creates errors from the assembler and breaks
+ dnl exceptions.
+ AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"])
+ dnl HP-UX 11.11's inttypes.h defines UINTPTR_MAX etc. to nothing. GCC's
+ dnl stdint.h defines those correctly, but if inttypes.h gets included
+ dnl after something included stdint.h, it gets broken again. Therefore,
+ dnl always include inttypes.h as the very first thing.
+ dnl We need to put this into OBJCFLAGS and not CPPFLAGS as CPPFLAGS are
+ dnl also used for .S files.
+ OBJCFLAGS="$OBJCFLAGS -include inttypes.h"
+ dnl We need -latomic for GCC's atomics to work.
+ LIBS="$LIBS -latomic"
+ ;;
+*-*-mint*)
+ enable_shared="no"
+ enable_threads="no" # TODO
+ with_tls="no"
+ ;;
esac
AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [
dnl Hack to make configure find these on DOS.
: ${AR:=ar.exe}
@@ -148,14 +152,23 @@
: ${GREP:=grep.exe}
: ${RANLIB:=ranlib.exe}
])
AC_LANG([Objective C])
-AC_PROG_OBJC([clang egcc gcc])
+case "$host_os" in
+morphos*)
+ dnl Don't use clang on MorphOS - it does not support baserel, which is
+ dnl required for the .library.
+ potential_compilers="gcc"
+ ;;
+*)
+ potential_compilers="clang egcc gcc"
+ ;;
+esac
+AC_PROG_OBJC($potential_compilers)
AC_PROG_OBJCPP
AC_PROG_LN_S
-AC_PROG_INSTALL
AC_PROG_EGREP
BUILDSYS_CHECK_IOS
AC_ARG_WITH(wii,
@@ -173,10 +186,11 @@
LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc"
TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte"
enable_shared="no"
enable_threads="no" # TODO
+ with_tls="no"
AC_DEFINE(OF_WII, 1, [Whether we are compiling for Wii])
AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])
@@ -244,10 +258,11 @@
LDFLAGS="$LDFLAGS -specs=3dsx.specs -march=armv6k -mtune=mpcore"
LDFLAGS="$LDFLAGS -mfloat-abi=hard -mtp=soft -mword-relocations"
LIBS="$LIBS -L$DEVKITPRO/libctru/lib -lctru"
enable_shared="no"
enable_threads="no" # TODO
+ with_tls="no"
check_pedantic="no"
AC_DEFINE(OF_NINTENDO_3DS, 1,
[Whether we are compiling for Nintendo 3DS])
AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
@@ -262,44 +277,34 @@
dnl amiga-gcc requires -fexceptions in LDFLAGS in order to link in the glue code
dnl for registering the frames.
LDFLAGS="$LDFLAGS -fexceptions"
case "$OBJC" in
- *clang*)
- case "$host" in
- dnl Clang generates MIPS assembly not accepted by GNU
- dnl as, however, Clang's integrated assembler doesn't
- dnl accept everything used in ObjFW's assembly files.
- dnl Therefore, use the integrated assembler for ObjC
- dnl files, but not for assembly files.
- mips*-*-*)
- flag="-integrated-as"
- OBJCFLAGS="$OBJCFLAGS $flag"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
- ;;
- dnl Don't use -no-integrated-as on Darwin. It breaks
- dnl building for the iOS simulator.
- i?86-*-darwin* | x86_64-*-darwin*)
- ;;
- dnl Many older Clang versions don't support jmp short.
- i?86-*-* | x86_64-*-*)
- ASFLAGS="$ASFLAGS -no-integrated-as"
- ;;
- dnl Clang's assembler on Windows is not complete yet
- dnl and cannot compile all .S files.
- *-*-mingw*)
- ASFLAGS="$ASFLAGS -no-integrated-as"
- ;;
- dnl Clang generates assembly output on SPARC64 that
- dnl OpenBSD's assembler does not accept.
- sparc64-*-*openbsd*)
- flag="-integrated-as"
- OBJCFLAGS="$OBJCFLAGS $flag"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
- ;;
- esac
- ;;
+*clang*)
+ case "$host" in
+ mips*-*-*)
+ 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.
+ 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
+ dnl for the iOS simulator.
+ ;;
+ sparc64-*-*openbsd*)
+ dnl Clang generates assembly output on SPARC64 that OpenBSD's
+ dnl assembler does not accept.
+ flag="-integrated-as"
+ OBJCFLAGS="$OBJCFLAGS $flag"
+ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
+ ;;
+ esac
+ ;;
esac
AX_CHECK_COMPILER_FLAGS(-std=gnu11, [
OBJCFLAGS="$OBJCFLAGS -std=gnu11"
], [
@@ -309,18 +314,11 @@
AX_CHECK_COMPILER_FLAGS(-std=gnu99,
[OBJCFLAGS="$OBJCFLAGS -std=gnu99"])
])
])
-case "$build_os" in
- morphos*)
- # MorphOS 3.10 has a buggy ixemul that does not work with -pipe.
- ;;
- *)
- AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
- ;;
-esac
+AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-cfstrings, [
flag="-Xclang -fno-constant-cfstrings"
OBJCFLAGS="$OBJCFLAGS $flag"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
@@ -341,35 +339,36 @@
[OBJCFLAGS="$OBJCFLAGS -Wobjc-missing-property-synthesis"])
AX_CHECK_COMPILER_FLAGS([-Wmissing-method-return-type -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wmissing-method-return-type"])
case "$host" in
- m68k-*-amigaos*)
- dnl The inline headers generate code that triggers
- dnl -Wpointer-sign.
- OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign"
- ;;
+m68k-*-amigaos*)
+ dnl The inline headers generate code that triggers -Wpointer-sign.
+ OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign"
+ ;;
esac
AC_MSG_CHECKING(whether Objective C compiler supports properties)
-AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- id bar;
- }
-
- @property (nonatomic, retain) id bar;
- @end
-], [
- Foo *foo = (id)0;
- [foo setBar: (id)0];
- foo = [foo bar];
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ id bar;
+ }
+
+ @property (nonatomic, retain) id bar;
+ @end
+ ], [[
+ Foo *foo = (id)0;
+ [foo setBar: (id)0];
+ foo = [foo bar];
+ ]])
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_ERROR(Compiler does not support properties!)
@@ -382,17 +381,12 @@
AS_HELP_STRING([--disable-shared], [do not build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")
AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a")
- AC_SUBST(EXCEPTIONS_EXCEPTIONS_LIB_A, "exceptions/exceptions.lib.a")
AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a")
- AC_SUBST(FORWARDING_FORWARDING_LIB_A, "forwarding/forwarding.lib.a")
- AC_SUBST(INVOCATION_LIB_A, "invocation.lib.a")
- AC_SUBST(INVOCATION_INVOCATION_LIB_A, "invocation/invocation.lib.a")
AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a")
- AC_SUBST(LOOKUP_ASM_LOOKUP_ASM_LIB_A, "lookup-asm/lookup-asm.lib.a")
BUILDSYS_FRAMEWORK([
AC_SUBST(OBJFW_FRAMEWORK, "ObjFW.framework")
build_framework="yes"
])
@@ -412,26 +406,26 @@
])
AC_ARG_ENABLE(amiga-lib,
AS_HELP_STRING([--disable-amiga-lib], [do not build Amiga library]))
AS_IF([test x"$supports_amiga_lib" != x"yes"], [enable_amiga_lib="no"])
-
-AS_IF([test x"$enable_shared" = x"no" -a x"$enable_amiga_lib" = x"no"], [
- enable_static="yes"
+AS_IF([test x"$enable_amiga_lib" != x"no"], [
+ AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
+ AC_SUBST(EXCEPTIONS_A, "exceptions.a")
+ AC_SUBST(FORWARDING_A, "forwarding.a")
+ AC_SUBST(LOOKUP_ASM_AMIGALIB_A, "lookup-asm.amigalib.a")
])
AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library]))
-AS_IF([test x"$enable_static" = x"yes" -o x"$enable_amiga_lib" != x"no"], [
+AS_IF([test x"$enable_shared" = x"no" -a x"$enable_amiga_lib" = x"no"], [
+ enable_static="yes"
+])
+AS_IF([test x"$enable_static" = x"yes"], [
AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
AC_SUBST(EXCEPTIONS_A, "exceptions.a")
- AC_SUBST(EXCEPTIONS_EXCEPTIONS_A, "exceptions/exceptions.a")
AC_SUBST(FORWARDING_A, "forwarding.a")
- AC_SUBST(FORWARDING_FORWARDING_A, "forwarding/forwarding.a")
- AC_SUBST(INVOCATION_A, "invocation.a")
- AC_SUBST(INVOCATION_INVOCATION_A, "invocation/invocation.a")
AC_SUBST(LOOKUP_ASM_A, "lookup-asm.a")
- AC_SUBST(LOOKUP_ASM_LOOKUP_ASM_A, "lookup-asm/lookup-asm.a")
])
AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
AS_IF([test x"$enable_files" != x"no" -a x"$PLUGIN_SUFFIX" != x""], [
AC_SUBST(USE_SRCS_PLUGINS, '${SRCS_PLUGINS}')
@@ -453,11 +447,11 @@
AC_MSG_CHECKING(whether we need -D_GNU_SOURCE)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
#if defined(__GLIBC__) || defined(__MINGW32__) || \
- defined(__NEWLIB__) || defined(__MORPHOS__)
+ defined(__NEWLIB__) || defined(__MORPHOS__) || defined(__MINT__)
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
@@ -465,13 +459,13 @@
], [
AC_MSG_RESULT(no)
])
case "$host_os" in
- solaris*)
- CPPFLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS $CPPFLAGS"
- ;;
+solaris*)
+ CPPFLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS $CPPFLAGS"
+ ;;
esac
objc_runtime="ObjFW runtime"
AC_CHECK_HEADER(objc/objc.h)
AC_MSG_CHECKING(which Objective C runtime to use)
@@ -497,19 +491,19 @@
])
])
AC_MSG_RESULT($objc_runtime)
case "$objc_runtime" in
- "ObjFW runtime")
- AC_DEFINE(OF_OBJFW_RUNTIME, 1,
- [Whether we use the ObjFW runtime])
-
- AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported])
-
- old_OBJCFLAGS="$OBJCFLAGS"
- OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw"
- AC_TRY_LINK([
+"ObjFW runtime")
+ AC_DEFINE(OF_OBJFW_RUNTIME, 1, [Whether we use the ObjFW runtime])
+
+ AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported])
+
+ old_OBJCFLAGS="$OBJCFLAGS"
+ OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw"
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
#ifdef __has_attribute
# if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
# endif
#endif
@@ -531,205 +525,217 @@
void
__objc_exec_class(void *module)
{
}
- ], [
+ ], [[
[Test test];
- ], [
- flag="-Xclang -fobjc-runtime=objfw"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
- AC_MSG_RESULT(yes)
- ], [
- flag="-fgnu-runtime"
- OBJCFLAGS="$old_OBJCFLAGS $flag"
- OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
- AC_MSG_RESULT(no)
- old_compiler="yes"
- ])
-
- AC_SUBST(RUNTIME, "runtime")
- AC_CONFIG_FILES(src/runtime/Info.plist)
-
- AS_IF([test x"$enable_shared" != x"no"], [
- AC_SUBST(OBJFWRT_SHARED_LIB,
- "${LIB_PREFIX}objfwrt${LIB_SUFFIX}")
- ])
-
- AS_IF([test x"$enable_static" = x"yes"], [
- AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a")
- ])
-
- AS_IF([test x"$build_framework" = x"yes"], [
- AC_SUBST(OBJFWRT_FRAMEWORK, "ObjFWRT.framework")
- AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-framework ObjFWRT")
- ])
-
- AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(RUNTIME_LIBS, "-lobjfwrt.library")
- AC_SUBST(LINKLIB, linklib)
- tmp="../src/runtime/linklib/libobjfwrt.library.a"
- AC_SUBST(LIBOBJFWRT_DEP, "$tmp")
- AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../$tmp")
- ], [
- AC_SUBST(RUNTIME_LIBS, "-lobjfwrt")
- ])
-
- AS_IF([test x"$enable_shared" = x"no" \
- -a x"$enable_amiga_lib" = x"no"], [
- tmp="../src/runtime/libobjfwrt.a"
- AC_SUBST(LIBOBJFWRT_DEP, "$tmp")
- AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../$tmp")
- ])
-
- AS_IF([test x"$enable_seluid24" = x"yes"], [
- AC_DEFINE(OF_SELUID24, 1,
- [Whether to use 24 bit selector UIDs])
- ])
-
- AC_MSG_CHECKING(for exception type)
- AC_TRY_COMPILE([
+ ]])
+ ], [
+ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang -fobjc-runtime=objfw"
+ AC_MSG_RESULT(yes)
+ ], [
+ OBJCFLAGS="$old_OBJCFLAGS -fgnu-runtime"
+ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -fgnu-runtime"
+ AC_MSG_RESULT(no)
+ old_compiler="yes"
+ ])
+
+ AC_SUBST(RUNTIME, "runtime")
+ AC_CONFIG_FILES(src/runtime/Info.plist)
+
+ AS_IF([test x"$enable_shared" != x"no"], [
+ AC_SUBST(OBJFWRT_SHARED_LIB,
+ "${LIB_PREFIX}objfwrt${LIB_SUFFIX}")
+ ])
+
+ AS_IF([test x"$enable_static" = x"yes"], [
+ AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a")
+ ])
+
+ AS_IF([test x"$build_framework" = x"yes"], [
+ AC_SUBST(OBJFWRT_FRAMEWORK, "ObjFWRT.framework")
+ AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-framework ObjFWRT")
+ ])
+
+ AS_IF([test x"$enable_amiga_lib" != x"no"], [
+ AC_SUBST(RUNTIME_LIBS, "-lobjfwrt.library")
+ AC_SUBST(LINKLIB, linklib)
+ tmp="../src/runtime/linklib/libobjfwrt.library.a"
+ AC_SUBST(LIBOBJFWRT_DEP, "$tmp")
+ AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../$tmp")
+ ], [
+ AC_SUBST(RUNTIME_LIBS, "-lobjfwrt")
+ ])
+
+ AS_IF([test x"$enable_shared" = x"no" \
+ -a x"$enable_amiga_lib" = x"no"], [
+ AC_SUBST(LIBOBJFWRT_DEP, "../src/runtime/libobjfwrt.a")
+ AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../../src/runtime/libobjfwrt.a")
+ ])
+
+ AS_IF([test x"$enable_seluid24" = x"yes"], [
+ AC_DEFINE(OF_SELUID24, 1, [Whether to use 24 bit selector UIDs])
+ ])
+
+ AC_MSG_CHECKING(for exception type)
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
extern void foo();
], [
@try {
foo();
} @finally {
foo();
}
- ], [
- AS_IF([$EGREP __gnu_objc_personality_v0 \
- conftest.$ac_objext >/dev/null], [
- exception_type="DWARF"
- ])
- AS_IF([$EGREP __gnu_objc_personality_sj0 \
- conftest.$ac_objext >/dev/null], [
- exception_type="SjLj"
- ])
- AS_IF([$EGREP __gnu_objc_personality_seh0 \
- conftest.$ac_objext >/dev/null], [
- exception_type="SEH"
- ])
-
- raise_exception="_Unwind_RaiseException"
-
- case "$exception_type" in
- DWARF)
- AC_DEFINE(HAVE_DWARF_EXCEPTIONS, 1,
- [Whether DWARF exceptions are used])
- ;;
- SjLj)
- AC_DEFINE(HAVE_SJLJ_EXCEPTIONS, 1,
- [Whether SjLj exceptions are used])
- raise_exception="_Unwind_SjLj_RaiseException"
- ;;
- SEH)
- AC_DEFINE(HAVE_SEH_EXCEPTIONS, 1,
- [Whether SEH exceptions are used])
- ;;
- *)
- AC_MSG_RESULT(unknown)
- AC_MSG_ERROR([Exception type not detected!])
- ;;
- esac
-
- AC_MSG_RESULT($exception_type)
- ], [
- AC_MSG_RESULT(exceptions unavailable!)
- AC_MSG_ERROR([Exceptions not accepted by compiler!])
- ])
-
- AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc], [
- dnl c++abi requires pthread on OpenBSD
- AS_IF([test x"$ac_lib" = x"c++abi"], [
- LIBS="$LIBS -lpthread"
- ])
- ], [
- AC_MSG_ERROR([$raise_exception missing!])
- ], [-lpthread])
-
- AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase)
- ;;
- "Apple runtime")
- AC_DEFINE(OF_APPLE_RUNTIME, 1,
- [Whether we use the Apple ObjC runtime])
-
- AC_CHECK_LIB(objc, objc_msgSend, [
- AC_SUBST(RUNTIME_LIBS, "-lobjc")
- AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-lobjc")
- ], [
- AC_MSG_ERROR([libobjc not found!])
- ])
-
- AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [
- AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m")
- ])
- AC_CHECK_FUNC(objc_constructInstance, [], [
- AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m")
- ])
- ;;
-esac
-
-AC_CHECK_FUNCS(_Unwind_Backtrace)
-
-case "$host_os" in
- darwin*)
- AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])
- AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
- AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjc"])
- AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK,
- ["-Wl,-reexport-lobjc"])
- LDFLAGS="$LDFLAGS -Wl,-U,_NSFoundationVersionNumber"
- ])
-
- AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [
- AS_IF([test x"$exception_type" = x"DWARF"], [
- LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_v0"
- ])
- AS_IF([test x"$exception_type" = x"SjLj"], [
- LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_sj0"
- ])
- AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjfwrt"])
- AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK,
- ["-Wl,-reexport_framework,ObjFWRT"])
- ])
-
- AC_CHECK_HEADERS(sysdir.h)
- AC_CHECK_FUNCS(sysdir_start_search_path_enumeration)
-
- AS_IF([test x"$host_is_ios" = x"yes"], [
- AC_SUBST(TESTS_STATIC_LIB, tests.a)
- TESTS_LIBS="$TESTS_LIBS -framework CoreFoundation"
- ])
- ;;
+ ])
+ ], [
+ AS_IF([$EGREP __gnu_objc_personality_v0 conftest.$ac_objext \
+ >/dev/null], [
+ exception_type="DWARF"
+ ])
+ AS_IF([$EGREP __gnu_objc_personality_sj0 conftest.$ac_objext \
+ >/dev/null], [
+ exception_type="SjLj"
+ ])
+ AS_IF([$EGREP __gnu_objc_personality_seh0 conftest.$ac_objext \
+ >/dev/null], [
+ exception_type="SEH"
+ ])
+
+ case "$exception_type" in
+ DWARF)
+ AC_DEFINE(HAVE_DWARF_EXCEPTIONS, 1,
+ [Whether DWARF exceptions are used])
+ raise_exception="_Unwind_RaiseException"
+ ;;
+ SjLj)
+ AC_DEFINE(HAVE_SJLJ_EXCEPTIONS, 1,
+ [Whether SjLj exceptions are used])
+ raise_exception="_Unwind_SjLj_RaiseException"
+ ;;
+ SEH)
+ AC_DEFINE(HAVE_SEH_EXCEPTIONS, 1,
+ [Whether SEH exceptions are used])
+ raise_exception="_Unwind_RaiseException"
+ ;;
+ *)
+ AC_MSG_RESULT(unknown)
+ AC_MSG_ERROR([Exception type not detected!])
+ ;;
+ esac
+
+ AC_MSG_RESULT($exception_type)
+ ], [
+ AC_MSG_RESULT(exceptions unavailable!)
+ AC_MSG_ERROR([Exceptions not accepted by compiler!])
+ ])
+
+ AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc unwind], [
+ dnl c++abi requires pthread on OpenBSD
+ AS_IF([test x"$ac_lib" = x"c++abi"], [LIBS="$LIBS -lpthread"])
+ ], [
+ AC_MSG_ERROR([$raise_exception missing!])
+ ], [-lpthread])
+
+ AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase)
+ ;;
+"Apple runtime")
+ AC_DEFINE(OF_APPLE_RUNTIME, 1, [Whether we use the Apple ObjC runtime])
+
+ AC_CHECK_LIB(objc, objc_msgSend, [
+ AC_SUBST(RUNTIME_LIBS, "-lobjc")
+ AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-lobjc")
+ ], [
+ AC_MSG_ERROR([libobjc not found!])
+ ])
+
+ old_OBJCFLAGS="$OBJCFLAGS"
+ OBJCFLAGS="$OBJCFLAGS -lobjc"
+
+ AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [
+ AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m")
+ ])
+ AC_CHECK_FUNC(objc_constructInstance, [], [
+ AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m")
+ ])
+
+ OBJCFLAGS="$old_OBJCFLAGS"
+ ;;
+esac
+
+case "$host_os" in
+mint*)
+ dnl _Unwind_Backtrace crashes on MiNT
+ ;;
+hpux*)
+ dnl _Unwind_Backtrace() returns complete garbage on HP-UX.
+ ;;
+*)
+ AC_CHECK_FUNCS(_Unwind_Backtrace)
+ ;;
+esac
+
+case "$host_os" in
+darwin*)
+ AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])
+ AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
+ AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjc"])
+ AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK, ["-Wl,-reexport-lobjc"])
+ LDFLAGS="$LDFLAGS -Wl,-U,_NSFoundationVersionNumber"
+ ])
+
+ AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [
+ AS_IF([test x"$exception_type" = x"DWARF"], [
+ LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_v0"
+ ])
+ AS_IF([test x"$exception_type" = x"SjLj"], [
+ LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_sj0"
+ ])
+ AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjfwrt"])
+ AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK,
+ ["-Wl,-reexport_framework,ObjFWRT"])
+ ])
+
+ AC_CHECK_HEADERS(sysdir.h)
+ AC_CHECK_FUNCS(sysdir_start_search_path_enumeration)
+
+ AS_IF([test x"$host_is_ios" = x"yes"], [
+ AC_SUBST(TESTS_STATIC_LIB, tests.a)
+ TESTS_LIBS="$TESTS_LIBS -framework CoreFoundation"
+ ])
+ ;;
esac
AC_MSG_CHECKING(whether Objective C compiler supports ARC)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fobjc-arc -fobjc-arc-exceptions"
-AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- }
-
- + (id)alloc;
- @end
-
- @implementation Foo
- + (id)alloc
- {
- return (id)0;
- }
- @end
-], [
- __weak id foo = [Foo alloc];
- (void)foo;
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ }
+
+ + (id)alloc;
+ @end
+
+ @implementation Foo
+ + (id)alloc
+ {
+ return (id)0;
+ }
+ @end
+ ], [[
+ __weak id foo = [Foo alloc];
+ (void)foo;
+ ]])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(COMPILER_SUPPORTS_ARC, 1, [Whether the compiler supports ARC])
AC_SUBST(RUNTIME_ARC_TESTS_M, RuntimeARCTests.m)
], [
@@ -742,39 +748,10 @@
])
AS_IF([test x"$ac_cv_c_bigendian" = x"universal"], [
AC_DEFINE(OF_UNIVERSAL, 1, [Whether we are building a universal binary])
])
-AC_MSG_CHECKING(for SIZE_MAX)
-AC_EGREP_CPP(egrep_cpp_yes, [
- #include
- #include
-
- #ifdef SIZE_MAX
- egrep_cpp_yes
- #endif
-], [
- AC_MSG_RESULT(yes)
-], [
- AC_MSG_RESULT(no)
- AC_MSG_CHECKING(for SIZE_T_MAX)
- AC_EGREP_CPP(egrep_cpp_yes, [
- #include
- #include
-
- #ifdef SIZE_T_MAX
- egrep_cpp_yes
- #endif
- ], [
- AC_MSG_RESULT(yes)
- size_max="SIZE_T_MAX"
- ], [
- AC_MSG_RESULT(no)
- size_max="(~(size_t)0)"
- ])
- AC_DEFINE_UNQUOTED(SIZE_MAX, $size_max, [Maximum value for size_t])
-])
AC_MSG_CHECKING(for SSIZE_MAX)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
#include
@@ -783,12 +760,11 @@
#endif
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
- AC_DEFINE(SSIZE_MAX, [((ssize_t)(SIZE_MAX / 2))],
- [Maximum value for ssize_t])
+ AC_DEFINE(SSIZE_MAX, [(SIZE_MAX / 2)], [Maximum value for ssize_t])
])
AC_MSG_CHECKING(for UINTPTR_MAX)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
#include
@@ -798,11 +774,13 @@
#endif
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
- AC_DEFINE(UINTPTR_MAX, [(~(uintptr_t)0)], [Maximum value for uintptr_t])
+ AC_CHECK_SIZEOF(uintptr_t)
+ AC_DEFINE(UINTPTR_MAX,
+ [(SIZEOF_UINTPTR_T * CHAR_BIT)], [Maximum value for uintptr_t])
])
AC_CHECK_HEADER(inttypes.h,
[AC_DEFINE(OF_HAVE_INTTYPES_H, 1, [Whether we have inttypes.h])])
@@ -825,13 +803,14 @@
[Floating point implementation does not conform to IEEE 754!])])
AC_MSG_CHECKING(for floating point endianess)
fp_endianess="unknown"
AS_IF([test x"$ac_cv_c_bigendian" != x"universal"], [
- AC_TRY_COMPILE([
- double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259;
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259;
+ ])
], [
AS_IF([$EGREP BigEnd conftest.$ac_objext >/dev/null], [
AC_DEFINE(OF_FLOAT_BIG_ENDIAN, 1,
[Whether floats are big endian])
fp_endianess="big endian"
@@ -847,74 +826,53 @@
AC_MSG_RESULT($fp_endianess)
AS_IF([test x"$fp_endianess" = x"unknown"], [
AC_MSG_ERROR(
[Floating point implementation does not conform to IEEE 754!])])
-AC_MSG_CHECKING(for INFINITY)
-AC_TRY_COMPILE([
- #include
- #include
-], [
- printf("%f", INFINITY);
-], [
- AC_MSG_RESULT(yes)
-], [
- AC_MSG_RESULT(no)
-
- AC_MSG_CHECKING(for __builtin_inf)
- AC_TRY_COMPILE([
- #include
- ], [
- printf("%f", __builtin_inf());
- ], [
- AC_MSG_RESULT(yes)
- AC_DEFINE(INFINITY, [(__builtin_inf())],
- [Workaround for missing INFINITY])
- ], [
- AC_MSG_RESULT(no)
-
- AC_MSG_ERROR([Neither INFINITY or __builtin_inf was found!])
- ])
-])
-
case "$host_cpu" in
- arm* | earm*)
- AC_MSG_CHECKING(for VFP2 or above)
- AC_TRY_COMPILE([], [
+arm* | earm*)
+ AC_MSG_CHECKING(for VFP2 or above)
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([], [
#if !defined(__arm64__) && !defined(__aarch64__) && \
!defined(__ARM64_ARCH_8__)
__asm__ __volatile__ (
"vstmdb sp!, {d0-d7}"
);
#endif
- ], [
- AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above])
- AC_MSG_RESULT(yes)
- ], [
- AC_MSG_RESULT(no)
])
- ;;
+ ], [
+ AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above])
+ AC_MSG_RESULT(yes)
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+ ;;
esac
AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex")
+AC_CHECK_FUNCS(strtof truncf)
+
AC_CHECK_FUNC(asprintf, [
case "$host" in
- *-*-mingw*)
- dnl asprintf from MinGW is broken on older Windows
- dnl versions
- have_asprintf="no"
- ;;
- *-psp-*)
- dnl asprintf is broken on the PSP
- have_asprintf="no"
- ;;
- *)
- have_asprintf="yes"
- AC_DEFINE(HAVE_ASPRINTF, 1,
- [Whether we have asprintf()])
+ *-*-mint*)
+ dnl asprintf is not in headers
+ have_asprintf="no"
+ ;;
+ *-*-mingw*)
+ dnl asprintf from MinGW is broken on older Windows versions
+ have_asprintf="no"
+ ;;
+ *-psp-*)
+ dnl asprintf is broken on the PSP
+ have_asprintf="no"
+ ;;
+ *)
+ have_asprintf="yes"
+ AC_DEFINE(HAVE_ASPRINTF, 1, [Whether we have asprintf()])
;;
esac
], [
have_asprintf="no"
])
@@ -931,58 +889,54 @@
AC_DEFUN([ENCODING_FLAG], [
AC_ARG_ENABLE($1,
AS_HELP_STRING([--disable-$1],
[Disables support for $3]))
AS_IF([test x"$enable_$2" != x"no"], [
- AC_DEFINE($4, 1,
- [Whether we have support for $3])
- ENCODINGS_SRCS="$ENCODINGS_SRCS $2.m"
+ AC_DEFINE($4, 1, [Whether we have support for $3])
+ ENCODINGS_SRCS="$ENCODINGS_SRCS $1.m"
])
])
ENCODING_FLAG(codepage-437, codepage_437, [Codepage 437], HAVE_CODEPAGE_437)
ENCODING_FLAG(codepage-850, codepage_850, [Codepage 850], HAVE_CODEPAGE_850)
ENCODING_FLAG(codepage-858, codepage_858, [Codepage 858], HAVE_CODEPAGE_858)
-ENCODING_FLAG(iso-8859-2, iso_8859-2, [ISO 8859-2], HAVE_ISO_8859_2)
-ENCODING_FLAG(iso-8859-3, iso_8859-3, [ISO 8859-3], HAVE_ISO_8859_3)
-ENCODING_FLAG(iso-8859-15, iso_8859-15, [ISO 8859-15], HAVE_ISO_8859_15)
-ENCODING_FLAG(koi8-r, koi8-r, [KOI8-R], HAVE_KOI8_R)
-ENCODING_FLAG(koi8-u, koi8-u, [KOI8-U], HAVE_KOI8_U)
+ENCODING_FLAG(iso-8859-2, iso_8859_2, [ISO 8859-2], HAVE_ISO_8859_2)
+ENCODING_FLAG(iso-8859-3, iso_8859_3, [ISO 8859-3], HAVE_ISO_8859_3)
+ENCODING_FLAG(iso-8859-15, iso_8859_15, [ISO 8859-15], HAVE_ISO_8859_15)
+ENCODING_FLAG(koi8-r, koi8_r, [KOI8-R], HAVE_KOI8_R)
+ENCODING_FLAG(koi8-u, koi8_u, [KOI8-U], HAVE_KOI8_U)
ENCODING_FLAG(mac-roman, mac_roman, [Mac Roman encoding], HAVE_MAC_ROMAN)
-ENCODING_FLAG(windows-1251, windows-1251, [Windows-1251], HAVE_WINDOWS_1251)
-ENCODING_FLAG(windows-1252, windows-1252, [Windows-1252], HAVE_WINDOWS_1252)
+ENCODING_FLAG(windows-1251, windows_1251, [Windows-1251], HAVE_WINDOWS_1251)
+ENCODING_FLAG(windows-1252, windows_1252, [Windows-1252], HAVE_WINDOWS_1252)
+AS_IF([test x"$ENCODINGS_SRCS" = x""], [
+ ENCODINGS_SRCS="dummy.m"
+])
AC_SUBST(ENCODINGS_SRCS)
-AS_IF([test x"$ENCODINGS_SRCS" != x""], [
- AC_SUBST(ENCODINGS, "encodings")
-
- AS_IF([test x"$enable_shared" != x"no"], [
- AC_SUBST(ENCODINGS_LIB_A, "encodings.lib.a")
- AC_SUBST(ENCODINGS_ENCODINGS_LIB_A, "encodings/encodings.lib.a")
- ])
- AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
- AC_SUBST(ENCODINGS_A, "encodings.a")
- AC_SUBST(ENCODINGS_ENCODINGS_A, "encodings/encodings.a")
- ])
+AS_IF([test x"$enable_shared" != x"no"], [
+ AC_SUBST(ENCODINGS_LIB_A, "encodings.lib.a")
+])
+AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
+ AC_SUBST(ENCODINGS_A, "encodings.a")
])
AC_CHECK_FUNCS(arc4random arc4random_buf getrandom random, break)
AS_IF([test x"$host_os" != x"morphos"], [
AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl")
])
AC_CHECK_HEADERS_ONCE(dlfcn.h)
case "$host_os" in
- netbsd*)
- dnl dladdr exists on NetBSD, but it is completely broken.
- dnl When using it with code that uses __thread, it freezes the
- dnl process so that it has to be killed using SIGKILL.
- dnl When disabling __thread, it doesn't freeze, but all symbols
- dnl are wrong.
- ;;
- *)
- AC_CHECK_FUNCS(dladdr)
- ;;
+netbsd*)
+ dnl dladdr exists on NetBSD, but it is completely broken.
+ dnl When using it with code that uses __thread, it freezes the process
+ dnl so that it has to be killed using SIGKILL.
+ dnl When disabling __thread, it doesn't freeze, but all symbols are
+ dnl wrong.
+ ;;
+*)
+ AC_CHECK_FUNCS(dladdr)
+ ;;
esac
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_FUNCS(mmap mlock)
@@ -1007,28 +961,32 @@
CPPFLAGS="$CPPFLAGS -Wp,-pthread"
], [
CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
])
- AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread")
+ AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
- AC_TRY_LINK([
- #include
- ], [
- pthread_create(NULL, NULL, NULL, NULL);
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ pthread_create(NULL, NULL, NULL, NULL);
+ ])
], [], [
AC_MSG_ERROR(No supported threads found!)
])
AC_DEFINE(OF_HAVE_PTHREADS, 1, [Whether we have pthreads])
- AC_TRY_COMPILE([
- #include
- ], [
- pthread_mutexattr_t attr;
- pthread_mutexattr_settype(&attr,
- PTHREAD_MUTEX_RECURSIVE);
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_settype(&attr,
+ PTHREAD_MUTEX_RECURSIVE);
+ ])
], [
AC_DEFINE(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES, 1,
[If pthread mutexes can be recursive])
])
@@ -1051,45 +1009,55 @@
;;
esac
AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads])
AC_SUBST(USE_SRCS_THREADS, '${SRCS_THREADS}')
+ AC_SUBST(OBJC_SYNC, objc_sync)
AC_ARG_ENABLE(compiler-tls,
AS_HELP_STRING([--disable-compiler-tls],
[disable compiler thread local storage]))
case "$host" in
- aarch64*-*-android*)
- # Compiler TLS is broken on AArch64 Android with Clang
- enable_compiler_tls="no"
- ;;
- m68k-*-amigaos | powerpc-*-amigaos)
- # Compiler TLS is broken on AmigaOS
- enable_compiler_tls="no"
- ;;
+ aarch64*-*-android*)
+ dnl Compiler TLS is broken on AArch64 Android with Clang
+ enable_compiler_tls="no"
+ ;;
+ m68k-*-amigaos* | powerpc-*-amigaos*)
+ dnl Compiler TLS is broken on AmigaOS
+ enable_compiler_tls="no"
+ ;;
+ *-*-morphos*)
+ dnl Compiler TLS needs helpers that we don't want in the
+ dnl .library
+ enable_compiler_tls="no"
+ ;;
esac
AS_IF([test x"$enable_compiler_tls" != x"no"], [
AC_CHECK_HEADER(threads.h, [
AC_DEFINE(OF_HAVE_THREADS_H, 1,
[Whether we have threads.h])
])
AC_MSG_CHECKING(whether _Thread_local works)
- AC_TRY_LINK([
- static _Thread_local int x = 0;
- ], [
- x++;
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ static _Thread_local int x = 0;
+ ], [
+ x++;
+ ])
], [
AS_IF([test x"$enable_shared" != x"no"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fPIC"
- AC_TRY_COMPILE([
- static _Thread_local int x = 0;
- ], [
- x++;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ static _Thread_local int x = 0;
+ ], [
+ x++;
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE__THREAD_LOCAL, 1,
[Whether _Thread_local works])
have_thread_local="yes"
@@ -1107,27 +1075,33 @@
AC_MSG_RESULT(no)
])
AS_IF([test x"$have_thread_local" != x"yes"], [
AC_MSG_CHECKING(whether __thread works)
- AC_TRY_LINK([
- /* It seems __thread is buggy with GCC 4.1 */
- #if __GNUC__ == 4 && __GNUC_MINOR__ < 2
- # error buggy
- #endif
-
- __thread int x = 0;
- ], [
- x++;
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ /*
+ * It seems __thread is buggy with
+ * GCC 4.1 */
+ #if __GNUC__ == 4 && __GNUC_MINOR__ < 2
+ # error buggy
+ #endif
+
+ __thread int x = 0;
+ ], [
+ x++;
+ ])
], [
AS_IF([test x"$enable_shared" != x"no"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fPIC"
- AC_TRY_COMPILE([
- __thread int x = 0;
- ], [
- x++;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ __thread int x = 0;
+ ], [
+ x++;
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE___THREAD, 1,
[Whether __thread works]
)
@@ -1162,20 +1136,22 @@
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether __atomic_* works)
- AC_TRY_LINK([
- #include
- #include
- ], [
- int32_t i, j;
- if (__atomic_add_fetch(&i, 1, __ATOMIC_RELAXED))
- j = __atomic_sub_fetch(&i, 1, __ATOMIC_RELAXED);
- while (!__atomic_compare_exchange_n(&i, &j, 1, false,
- __ATOMIC_RELAXED, __ATOMIC_RELAXED));
- __atomic_thread_fence(__ATOMIC_SEQ_CST);
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+ ], [
+ int32_t i, j;
+ if (__atomic_add_fetch(&i, 1, __ATOMIC_RELAXED))
+ j = __atomic_sub_fetch(&i, 1, __ATOMIC_RELAXED);
+ while (!__atomic_compare_exchange_n(&i, &j, 1, false,
+ __ATOMIC_RELAXED, __ATOMIC_RELAXED));
+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
+ ])
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && \
atomic_ops="__atomic_* builtins"
AC_DEFINE(OF_HAVE_ATOMIC_BUILTINS, 1,
@@ -1183,15 +1159,19 @@
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether __sync_* works)
- AC_TRY_LINK([#include ], [
- int32_t i, j;
- if (__sync_add_and_fetch(&i, 1))
- j = __sync_sub_and_fetch(&i, 1);
- while (!__sync_bool_compare_and_swap(&i, 0, 1));
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ int32_t i, j;
+ if (__sync_add_and_fetch(&i, 1))
+ j = __sync_sub_and_fetch(&i, 1);
+ while (!__sync_bool_compare_and_swap(&i, 0, 1));
+ ])
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && \
atomic_ops="__sync_* builtins"
AC_DEFINE(OF_HAVE_SYNC_BUILTINS, 1,
@@ -1224,20 +1204,19 @@
AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}')
AC_SUBST(OFARC, "ofarc")
AC_SUBST(OFHASH, "ofhash")
case "$host_os" in
- msdosdjgpp*)
- dnl DJGPP has the type, but it's not really usable.
- ;;
- *)
- AC_CHECK_TYPE(off64_t, [
- AC_DEFINE(OF_HAVE_OFF64_T, 1,
- [Whether we have off64_t])
- AC_CHECK_FUNCS([lseek64 lstat64 open64 stat64])
- ])
- ;;
+ msdosdjgpp*)
+ dnl DJGPP has the type, but it's not really usable.
+ ;;
+ *)
+ AC_CHECK_TYPE(off64_t, [
+ AC_DEFINE(OF_HAVE_OFF64_T, 1, [Whether we have off64_t])
+ AC_CHECK_FUNCS([lseek64 lstat64 open64 stat64])
+ ])
+ ;;
esac
AC_CHECK_HEADERS([pwd.h grp.h])
AC_CHECK_FUNC(chmod, [
AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()])
@@ -1257,53 +1236,70 @@
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(for readdir_r)
- AC_TRY_COMPILE([
- #include
- ], [
- DIR *dir = 0;
- struct dirent entry, *result;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ DIR *dir = 0;
+ struct dirent entry, *result;
- readdir_r(dir, &entry, &result);
+ readdir_r(dir, &entry, &result);
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_READDIR_R, 1, [Whether we have readdir_r()])
], [
AC_MSG_RESULT(no)
])
OBJCFLAGS="$old_OBJCFLAGS"
])
-AC_CHECK_HEADERS(fcntl.h dirent.h)
-AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep fcntl])
+AC_CHECK_HEADERS(dirent.h)
+AC_CHECK_FUNCS([sysconf gmtime_r localtime_r])
+
+case "$host_os" in
+amigaos* | morphos*)
+ dnl We don't want fcntl() or nanosleep() on AmigaOS / MorphOS, despite
+ dnl a symbol existing. The reason is that we cannot use fcntl() for
+ dnl sockets and that nanosleep() is yet another function that uses
+ dnl errno, so would need to be passed from the linklib.
+ ;;
+*)
+ AC_CHECK_HEADERS(fcntl.h)
+ AC_CHECK_FUNCS([fcntl nanosleep])
+ ;;
+esac
AC_CHECK_HEADERS(xlocale.h)
AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l])
AS_IF([test x"$gnu_source" != x"yes" -a \( \
x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \
x"$ac_cv_func_asprintf_l" = x"yes" \)], [
AC_MSG_CHECKING(whether *_l functions need _GNU_SOURCE)
- AC_TRY_COMPILE([
- #include
- #include
-
- #include
- #ifdef HAVE_XLOCALE_H
- # include
- #endif
- ], [
- #ifdef HAVE_STRTOD_L
- (void)strtod_l;
- #endif
- #ifdef HAVE_STRTOF_L
- (void)strtof_l;
- #endif
- #ifdef HAVE_ASPRINTF_L
- (void)asprintf_l;
- #endif
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+
+ #include
+ #ifdef HAVE_XLOCALE_H
+ # include
+ #endif
+ ], [
+ #ifdef HAVE_STRTOD_L
+ (void)strtod_l;
+ #endif
+ #ifdef HAVE_STRTOF_L
+ (void)strtof_l;
+ #endif
+ #ifdef HAVE_ASPRINTF_L
+ (void)asprintf_l;
+ #endif
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
@@ -1312,17 +1308,19 @@
dnl This check needs to happen after the above, as _GNU_SOURCE can change the
dnl return type.
AC_CHECK_FUNCS(strerror_r, [
AC_MSG_CHECKING(for return type of strerror_r)
- AC_TRY_COMPILE([
- #include
- #include
- ], [
- switch (strerror_r(0, NULL, 0)) {
- case 0:;
- }
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+ ], [
+ switch (strerror_r(0, NULL, 0)) {
+ case 0:;
+ }
+ ])
], [
AC_MSG_RESULT(int)
], [
AC_MSG_RESULT(char *)
AC_DEFINE(STRERROR_R_RETURNS_CHARP, 1,
@@ -1331,38 +1329,32 @@
])
AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_FUNCS(uname)
-case "$host_os" in
- amigaos*)
- ;;
- *)
- AC_CHECK_FUNC(pipe, [
- AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()])
- ])
- ;;
-esac
+AC_CHECK_FUNC(pipe, [
+ AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()])
+])
AC_ARG_ENABLE(sockets,
AS_HELP_STRING([--disable-sockets], [disable socket support]))
AS_IF([test x"$enable_sockets" != x"no"], [
AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets])
AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}')
case "$host_os" in
- amigaos*)
- ;;
- haiku*)
- LIBS="$LIBS -lnetwork"
- ;;
- mingw*)
- LIBS="$LIBS -lws2_32 -liphlpapi"
- ;;
- *)
- AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
- ;;
+ amigaos* | morphos*)
+ ;;
+ haiku*)
+ LIBS="$LIBS -lnetwork"
+ ;;
+ mingw*)
+ LIBS="$LIBS -lws2_32 -liphlpapi"
+ ;;
+ *)
+ AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
+ ;;
esac
AC_CHECK_HEADER(sys/socket.h, [
AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1,
[Whether we have sys/socket.h])
@@ -1373,21 +1365,18 @@
])
AC_CHECK_HEADER(netinet/tcp.h, [
AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
[Whether we have netinet/tcp.h])
])
- AC_CHECK_HEADER(netinet/sctp.h, [
- AC_DEFINE(OF_HAVE_SCTP, 1, [Whether we have SCTP])
- AC_DEFINE(OF_HAVE_NETINET_SCTP_H, 1,
- [Whether we have netinet/sctp.h])
- AC_SUBST(USE_SRCS_SCTP, '${SRCS_SCTP}')
- ])
AC_CHECK_HEADERS([arpa/inet.h netdb.h])
AC_CHECK_HEADER(netipx/ipx.h, [
AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1,
[Whether we have netipx/ipx.h])
])
+ AC_CHECK_HEADER(sys/un.h, [
+ AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h])
+ ])
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
@@ -1413,10 +1402,13 @@
#endif
], [
AC_DEFINE(OF_HAVE_IPV6, 1, [Whether we have IPv6])
])
], [
+ dnl Work around a bug in autoconf 2.61 that creates a broken
+ dnl configure if this branch is empty.
+ :
], [
#ifdef _WIN32
typedef int BOOL;
#endif
@@ -1505,10 +1497,44 @@
], [
AC_DEFINE(OF_HAVE_IPX, 1, [Whether we have IPX/SPX])
AC_SUBST(USE_SRCS_IPX, '${SRCS_IPX}')
])
])
+
+ AC_CHECK_HEADERS(afunix.h, [
+ AC_DEFINE(OF_HAVE_AFUNIX_H, 1, [Whether we have afunix.h])
+ ], [], [
+ #ifdef _WIN32
+ # include
+ #endif
+ ])
+ AC_CHECK_MEMBER(struct sockaddr_un.sun_path, [
+ AC_DEFINE(OF_HAVE_UNIX_SOCKETS, 1,
+ [Whether we have UNIX sockets])
+ AC_SUBST(USE_SRCS_UNIX_SOCKETS, '${SRCS_UNIX_SOCKETS}')
+ ], [], [
+ #ifdef OF_HAVE_SYS_TYPES_H
+ # include
+ #endif
+ #ifdef OF_HAVE_SYS_UN_H
+ # include
+ #endif
+ #ifdef _WIN32
+ # include
+ #endif
+ #ifdef HAVE_AFUNIX_H
+ # include
+ #endif
+
+ #ifdef __morphos__
+ # error MorphOS has the struct but does not support it
+ #endif
+
+ #ifdef __MINT__
+ # error Gives invalid argument at runtime
+ #endif
+ ])
AC_CHECK_FUNCS(paccept accept4, break)
AC_CHECK_FUNCS(kqueue1 kqueue, [
AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue])
@@ -1535,47 +1561,153 @@
"OFPollKernelEventObserver.m")
])
])
case "$host_os" in
- amigaos* | mingw* | morphos*)
+ amigaos* | mingw* | morphos*)
+ AC_DEFINE(HAVE_SELECT, 1, [Whether we have select() or similar])
+ AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M,
+ "OFSelectKernelEventObserver.m")
+ ;;
+ *)
+ AC_CHECK_HEADERS(sys/select.h)
+ AC_CHECK_FUNC(select, [
AC_DEFINE(HAVE_SELECT, 1,
[Whether we have select() or similar])
AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M,
"OFSelectKernelEventObserver.m")
+ ])
+ ;;
+ esac
+
+ AC_ARG_WITH(tls,
+ AS_HELP_STRING([--with-tls], [
+ enable TLS support using the specified library
+ (yes, openssl, gnutls, securetransport or no)]))
+ AS_IF([test x"$with_tls" = x""], [with_tls="yes"])
+ tls_support="no"
+
+ AS_IF([test x"$with_tls" = x"securetransport" \
+ -o x"$with_tls" = x"yes"], [
+ AC_CHECK_HEADERS(Security/SecureTransport.h, [
+ old_LIBS="$LIBS"
+ LIBS="-framework Security -framework Foundation $LIBS"
+
+ AC_CHECK_FUNC(SSLHandshake, [
+ AC_DEFINE(HAVE_SECURE_TRANSPORT, 1,
+ [Whether we have Secure Transport])
+
+ tls_support="Secure Transport"
+ TLS_LIBS="-framework Foundation $TLS_LIBS"
+ TLS_LIBS="-framework Security $TLS_LIBS"
+
+ AC_SUBST(OF_SECURE_TRANSPORT_TLS_STREAM_M,
+ "OFSecureTransportTLSStream.m")
+
+ AC_CHECK_FUNCS(SSLCreateContext)
+ ], [])
+
+ LIBS="$old_LIBS"
+ ])
+ ])
+
+ AS_IF([test x"$with_tls" = x"openssl" \
+ -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
+ case "$host_os" in
+ morphos*)
+ ssl="ssl_shared"
+ crypto="crypto_shared"
;;
*)
- AC_CHECK_HEADERS(sys/select.h)
- AC_CHECK_FUNC(select, [
- AC_DEFINE(HAVE_SELECT, 1,
- [Whether we have select() or similar])
- AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M,
- "OFSelectKernelEventObserver.m")
- ])
+ ssl="ssl"
+ crypto="crypto"
;;
- esac
+ esac
+
+ AC_CHECK_LIB($ssl, SSL_set1_host, [
+ AC_CHECK_HEADER(openssl/ssl.h, [
+ AC_DEFINE(HAVE_OPENSSL, 1,
+ [Whether we have OpenSSL])
+
+ tls_support="OpenSSL"
+ TLS_LIBS="-l$ssl -l$crypto $TLS_LIBS"
+
+ AC_SUBST(OF_OPENSSL_TLS_STREAM_M,
+ "OFOpenSSLTLSStream.m")
+ ])
+ ], [], [-l$crypto])
+ ])
+
+ AS_IF([test x"$with_tls" = x"gnutls" \
+ -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
+ PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [
+ AC_DEFINE(HAVE_GNUTLS, 1, [Whether we have GnuTLS])
+
+ tls_support="GnuTLS"
+ TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS"
+ TLS_LIBS="$gnutls_LIBS $TLS_LIBS"
+
+ AC_SUBST(OF_GNUTLS_TLS_STREAM_M, "OFGnuTLSTLSStream.m")
+ ], [
+ dnl Disable default action-if-not-found, which exits
+ dnl configure with an error.
+ :
+ ])
+ ])
+
+ AS_IF([test x"$tls_support" != x"no"], [
+ AC_SUBST(TLS, "tls")
+ AC_SUBST(TLS_CPPFLAGS)
+ AC_SUBST(TLS_LIBS)
+ AC_DEFINE(HAVE_TLS_SUPPORT, 1,
+ [Whether we have an implementation for TLS])
+ AC_CONFIG_FILES(src/tls/Info.plist)
+
+ OFHTTP_LIBS="-lobjfwtls $TLS_LIBS $OFHTTP_LIBS"
+
+ AS_IF([test x"$enable_shared" != x"no"], [
+ AC_SUBST(OBJFWTLS_SHARED_LIB,
+ "${LIB_PREFIX}objfwtls${LIB_SUFFIX}")
+ ])
+ AS_IF([test x"$enable_static" = x"yes" \
+ -o x"$enable_shared" = x"no"], [
+ AC_SUBST(OBJFWTLS_STATIC_LIB, "libobjfwtls.a")
+ ])
+ AS_IF([test x"$build_framework" = x"yes"], [
+ AC_SUBST(OBJFWTLS_FRAMEWORK, "ObjFWTLS.framework")
+ ])
+ ])
+
+ AS_IF([test x"$with_tls" != x"no" -a x"$tls_support" = x"no"], [
+ AC_MSG_ERROR(m4_normalize([
+ No TLS implementation was found. Please install OpenSSL,
+ GnuTLS or use --without-tls.
+ ]))
+ ])
AS_IF([test x"$enable_threads" != x"no"], [
AC_SUBST(OF_HTTP_CLIENT_TESTS_M, "OFHTTPClientTests.m")
])
AC_SUBST(OFDNS, "ofdns")
AS_IF([test x"$enable_files" != x"no"], [
AC_SUBST(OFHTTP, "ofhttp")
+ AC_SUBST(OFHTTP_LIBS)
])
- AC_SUBST(OFSOCK, "ofsock")
])
AC_DEFUN([CHECK_BUILTIN_BSWAP], [
AC_MSG_CHECKING(for __builtin_bswap$1)
- AC_TRY_LINK([
- #include
- #include
- #include
- ], [
- uint$1_t i = errno;
- printf("%d", (int)__builtin_bswap$1(i));
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+ #include
+ ], [
+ uint$1_t i = errno;
+ printf("%d", (int)__builtin_bswap$1(i));
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE_BUILTIN_BSWAP$1, 1,
[Whether we have __builtin_bswap$1])
], [
@@ -1584,49 +1716,66 @@
])
CHECK_BUILTIN_BSWAP(16)
CHECK_BUILTIN_BSWAP(32)
CHECK_BUILTIN_BSWAP(64)
-case "$host" in
- arm*-apple-darwin*)
- have_processes="no"
- ;;
- *-*-mingw*)
- have_processes="yes"
- ;;
- *-*-msdosdjgpp*)
- have_processes="no"
- ;;
- *)
- AC_HEADER_SYS_WAIT
- AC_CHECK_FUNCS(kill)
-
- AC_CHECK_FUNCS(posix_spawnp, [
- AS_IF([test x"$ac_cv_func_kill" = x"yes"], [
- have_processes="yes"
-
- AC_CHECK_HEADERS(spawn.h)
- ])
- ], [
- AC_CHECK_FUNCS([vfork dup2 execvp _exit], [
- AS_IF([test x"$ac_cv_func_vfork" = x"yes" \
- -a x"$ac_cv_func_pipe" = x"yes" \
- -a x"$ac_cv_func_dup2" = x"yes" \
- -a x"$ac_cv_func_execvp" = x"yes" \
- -a x"$ac_cv_func_kill" = x"yes" \
- -a x"$ac_cv_func__exit" = x"yes"], [
- have_processes="yes"
- ])
- ], [
- break
- ])
- ])
- ;;
-esac
-AS_IF([test x"$have_processes" = x"yes"], [
- AC_SUBST(OF_PROCESS_M, "OFProcess.m")
- AC_DEFINE(OF_HAVE_PROCESSES, 1, [Whether we have processes])
+case "$host_os" in
+darwin*)
+ AC_MSG_CHECKING(whether we are compiling for macOS)
+ AC_EGREP_CPP(egrep_cpp_yes, [
+ #include
+
+ #if (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) && \
+ (!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR)
+ egrep_cpp_yes
+ #endif
+ ], [
+ AC_MSG_RESULT(yes)
+ have_subprocesses="yes"
+
+ AC_CHECK_FUNCS(posix_spawnp)
+ AC_CHECK_HEADERS(spawn.h)
+ ], [
+ AC_MSG_RESULT(no)
+ have_subprocesses="no"
+ ])
+ ;;
+mingw*)
+ have_subprocesses="yes"
+ ;;
+msdosdjgpp*)
+ have_subprocesses="no"
+ ;;
+*)
+ AC_HEADER_SYS_WAIT
+ AC_CHECK_FUNCS(kill)
+
+ AC_CHECK_FUNCS(posix_spawnp, [
+ AS_IF([test x"$ac_cv_func_kill" = x"yes"], [
+ have_subprocesses="yes"
+
+ AC_CHECK_HEADERS(spawn.h)
+ ])
+ ], [
+ AC_CHECK_FUNCS([vfork dup2 execvp _exit], [
+ AS_IF([test x"$ac_cv_func_vfork" = x"yes" \
+ -a x"$ac_cv_func_pipe" = x"yes" \
+ -a x"$ac_cv_func_dup2" = x"yes" \
+ -a x"$ac_cv_func_execvp" = x"yes" \
+ -a x"$ac_cv_func_kill" = x"yes" \
+ -a x"$ac_cv_func__exit" = x"yes"], [
+ have_subprocesses="yes"
+ ])
+ ], [
+ break
+ ])
+ ])
+ ;;
+esac
+AS_IF([test x"$have_subprocesses" = x"yes"], [
+ AC_SUBST(OF_SUBPROCESS_M, "OFSubprocess.m")
+ AC_DEFINE(OF_HAVE_SUBPROCESSES, 1, [Whether we have subprocesses])
])
AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h])
AC_CHECK_FUNCS(isatty)
@@ -1658,13 +1807,15 @@
dnl which in old glibc versions uses __block. This is worked around in the code
dnl by providing a wrapper for unistd.h which takes care of this.
AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Xclang -fblocks"
-AC_TRY_COMPILE([], [
- int (^foo)(int bar);
- foo = ^ (int bar) { return 0; }
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([], [
+ int (^foo)(int bar);
+ foo = ^ (int bar) { return 0; }
+ ])
], [
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang -fblocks"
AC_SUBST(OF_BLOCK_TESTS_M, "OFBlockTests.m")
AC_MSG_RESULT(yes)
], [
@@ -1674,63 +1825,66 @@
AS_IF([test x"$GOBJC" = x"yes"], [
OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror"
AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
- AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- }
- @end
-
- static struct {
- struct objc_class *_isa;
- } object;
- ], [
- Foo *test = (Foo *)&object;
- (void)test; /* Get rid of unused variable warning */
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ }
+ @end
+
+ static struct {
+ struct objc_class *_isa;
+ } object;
+ ], [
+ Foo *test = (Foo *)&object;
+ (void)test; /* Get rid of unused variable warning */
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-strict-aliasing"
])
AC_MSG_CHECKING(
whether we need -Wno-unused-property-ivar due to Clang bugs)
- AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- Foo *_foo;
- }
-
- @property (readonly, nonatomic) Foo *foo;
-
- + (Foo *)foo;
- @end
-
- @implementation Foo
- @synthesize foo = _foo;
-
- + (Foo *)foo
- {
- return (Foo *)0;
- }
- @end
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ Foo *_foo;
+ }
+
+ @property (readonly, nonatomic) Foo *foo;
+
+ + (Foo *)foo;
+ @end
+
+ @implementation Foo
+ @synthesize foo = _foo;
+
+ + (Foo *)foo
+ {
+ return (Foo *)0;
+ }
+ @end
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-unused-property-ivar"
@@ -1737,30 +1891,31 @@
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wcast-align"
AC_MSG_CHECKING(whether -Wcast-align is buggy)
- AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- }
- @end
-
- @implementation Foo
- - (void)foo
- {
- struct objc_class *c = _isa;
- (void)c;
- }
- @end
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ }
+ @end
+
+ @implementation Foo
+ - (void)foo
+ {
+ struct objc_class *c = _isa;
+ (void)c;
+ }
+ @end
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
@@ -1767,93 +1922,103 @@
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wunreachable-code"
AC_MSG_CHECKING(whether -Wunreachable-code can be used)
- AC_TRY_COMPILE([
- #include
-
- typedef void *SEL;
-
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Object
- - (void)doesNotRecognizeSelector: (SEL)selector
- #ifdef __clang__
- __attribute__((__noreturn__))
- #endif
- ;
- - (void)dealloc;
- @end
-
- @interface Foo: Object
- @end
-
- void
- test(void)
- {
- if (sizeof(int) == 4)
- __asm__ ("");
- else if (sizeof(int) == 8)
- __asm__ ("");
- else
- abort();
- }
-
- /*
- * Unfortunately, this cannot be shorter, as it only works when
- * it is used inside a macro.
- */
- #ifdef __clang__
- # define OF_DEALLOC_UNSUPPORTED \
- [self doesNotRecognizeSelector: _cmd]; \
- \
- abort(); \
- \
- _Pragma("clang diagnostic push ignore \"-Wunreachable-code\""); \
- [super dealloc]; \
- _Pragma("clang diagnostic pop");
- #else
- # define OF_DEALLOC_UNSUPPORTED \
- [self doesNotRecognizeSelector: _cmd]; \
- \
- abort(); \
- \
- [super dealloc];
- #endif
-
- @implementation Foo
- - (void)dealloc
- {
- OF_DEALLOC_UNSUPPORTED
- }
- @end
- ], [], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+ #include
+
+ struct objc_selector;
+ typedef const struct objc_selector *SEL;
+
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Object
+ - (void)doesNotRecognizeSelector: (SEL)selector
+ #ifdef __clang__
+ __attribute__((__noreturn__))
+ #endif
+ ;
+ - (void)dealloc;
+ @end
+
+ @interface Foo: Object
+ @end
+
+ void
+ test(void)
+ {
+ if (sizeof(int) == 4)
+ __asm__ ("");
+ else if (sizeof(int) == 8)
+ __asm__ ("");
+ else
+ abort();
+ }
+
+ /*
+ * Unfortunately, this cannot be shorter, as it only
+ * works when it is used inside a macro.
+ */
+ #ifdef __clang__
+ # define OF_DEALLOC_UNSUPPORTED \
+ [self doesNotRecognizeSelector: _cmd]; \
+ \
+ abort(); \
+ \
+ _Pragma("clang diagnostic push ignore \
+ \"-Wunreachable-code\""); \
+ [super dealloc]; \
+ _Pragma("clang diagnostic pop");
+ #else
+ # define OF_DEALLOC_UNSUPPORTED \
+ [self doesNotRecognizeSelector: _cmd]; \
+ \
+ abort(); \
+ \
+ [super dealloc];
+ #endif
+
+ @implementation Foo
+ - (void)dealloc
+ {
+ OF_DEALLOC_UNSUPPORTED
+ }
+ @end
+ ]])
+ ], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wdocumentation"
AC_MSG_CHECKING(whether -Wdocumentation works correctly)
- AC_TRY_COMPILE([
- /**
- * @class Test conftest.m conftest.m
- */
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Test
- @end
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ /**
+ * @class Test conftest.m conftest.m
+ */
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Test
+ @end
+
+ /**
+ * @struct Foo conftest.m conftest.m
+ */
+ typedef struct {} Foo;
+ ])
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
@@ -1861,55 +2026,59 @@
AS_IF([test x"$check_pedantic" = x"yes"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -pedantic"
AC_MSG_CHECKING(whether -pedantic is buggy)
- AC_TRY_COMPILE([
- #include
-
- #include
-
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- void *foo;
- }
- @end
-
- @interface Bar: Foo
- - (void)assert;
- @end
-
- @implementation Bar
- - (void)assert
- {
- /*
- * Some versions of glibc break with -pedantic
- * when using assert.
- */
- assert(1);
- }
- @end
- ], [], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ #include
+
+ #include
+
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ void *foo;
+ }
+ @end
+
+ @interface Bar: Foo
+ - (void)assert;
+ @end
+
+ @implementation Bar
+ - (void)assert
+ {
+ /*
+ * Some versions of glibc break with
+ * -pedantic when using assert.
+ */
+ assert(1);
+ }
+ @end
+ ])
+ ], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
])
])
AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [
AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant)
- AC_TRY_COMPILE([
- #include
- ], [
- complex float f = 0.5 + 0.5 * I;
- (void)f;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ complex float f = 0.5 + 0.5 * I;
+ (void)f;
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-gnu-imaginary-constant"
@@ -1919,20 +2088,19 @@
AS_IF([test x"$cross_compiling" = x"yes"], [
AC_SUBST(BIN_PREFIX, "${host_alias}-")
case "$host" in
- i?86-*-mingw*)
- AC_CHECK_PROG(WINE, wine, wine)
- ;;
- x86_64-*-mingw*)
- AC_CHECK_PROG(WINE, wine64, wine64)
- ;;
+ i?86-*-mingw*)
+ AC_CHECK_PROG(WINE, wine, wine)
+ ;;
+ x86_64-*-mingw*)
+ AC_CHECK_PROG(WINE, wine64, wine64)
+ ;;
esac
AS_IF([test x"$WINE" != x""], [
- AC_SUBST(RUN_TESTS, "run")
AC_SUBST(WRAPPER, "$WINE")
])
AS_IF([test x"$with_wii" = x"yes"], [
dnl Keep this lowercase, as WIILOAD is a variable used by
@@ -1942,17 +2110,19 @@
AS_IF([test x"$wiiload" != x""], [
AC_SUBST(WRAPPER, "$wiiload")
])
])
-], [
- AC_SUBST(RUN_TESTS, "run")
])
AC_ARG_WITH(fish_completions,
AS_HELP_STRING([--with-fish-completions],
[install completions for the fish shell]))
+AS_IF([test x"$with_fish_completions" = x""], [
+ AC_CHECK_PROG(FISH, fish, fish)
+ AS_IF([test x"$FISH" != x""], [with_fish_completions="yes"])
+])
AS_IF([test x"$with_fish_completions" = x"yes"], [
AC_SUBST(FISH_COMPLETIONS, fish)
])
dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
Index: extra.mk.in
==================================================================
--- extra.mk.in
+++ extra.mk.in
@@ -1,91 +1,88 @@
OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@
OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@
OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@
-OBJFW_LIB_MAJOR = 9
-OBJFW_LIB_MINOR = 1
+OBJFW_LIB_MAJOR = 0
+OBJFW_LIB_MINOR = 0
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_AMIGA_LIB = @OBJFWRT_AMIGA_LIB@
-OBJFWRT_LIB_MAJOR = 1
+OBJFWRT_LIB_MAJOR = 0
OBJFWRT_LIB_MINOR = 0
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@
+OBJFWTLS_SHARED_LIB = @OBJFWTLS_SHARED_LIB@
+OBJFWTLS_STATIC_LIB = @OBJFWTLS_STATIC_LIB@
+OBJFWTLS_FRAMEWORK = @OBJFWTLS_FRAMEWORK@
+
BIN_PREFIX = @BIN_PREFIX@
BRIDGE = @BRIDGE@
CVINCLUDE_INLINE_H = @CVINCLUDE_INLINE_H@
-ENCODINGS = @ENCODINGS@
ENCODINGS_A = @ENCODINGS_A@
-ENCODINGS_ENCODINGS_A = @ENCODINGS_ENCODINGS_A@
-ENCODINGS_ENCODINGS_LIB_A = @ENCODINGS_ENCODINGS_LIB_A@
ENCODINGS_LIB_A = @ENCODINGS_LIB_A@
ENCODINGS_SRCS = @ENCODINGS_SRCS@
EXCEPTIONS_A = @EXCEPTIONS_A@
-EXCEPTIONS_EXCEPTIONS_A = @EXCEPTIONS_EXCEPTIONS_A@
-EXCEPTIONS_EXCEPTIONS_LIB_A = @EXCEPTIONS_EXCEPTIONS_LIB_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
FISH_COMPLETIONS = @FISH_COMPLETIONS@
FORWARDING_A = @FORWARDING_A@
-FORWARDING_FORWARDING_A = @FORWARDING_FORWARDING_A@
-FORWARDING_FORWARDING_LIB_A = @FORWARDING_FORWARDING_LIB_A@
FORWARDING_LIB_A = @FORWARDING_LIB_A@
-INVOCATION_A = @INVOCATION_A@
-INVOCATION_INVOCATION_A = @INVOCATION_INVOCATION_A@
-INVOCATION_INVOCATION_LIB_A = @INVOCATION_INVOCATION_LIB_A@
-INVOCATION_LIB_A = @INVOCATION_LIB_A@
LIBBASES_M = @LIBBASES_M@
LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@
LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@
LIBOBJFW_DEP = @LIBOBJFW_DEP@
LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@
LINKLIB = @LINKLIB@
LOOKUP_ASM_A = @LOOKUP_ASM_A@
+LOOKUP_ASM_AMIGALIB_A = @LOOKUP_ASM_AMIGALIB_A@
LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@
-LOOKUP_ASM_LOOKUP_ASM_A = @LOOKUP_ASM_LOOKUP_ASM_A@
-LOOKUP_ASM_LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LOOKUP_ASM_LIB_A@
MAP_LDFLAGS = @MAP_LDFLAGS@
+OBJC_SYNC = @OBJC_SYNC@
OFARC = @OFARC@
OFDNS = @OFDNS@
OFHASH = @OFHASH@
OFHTTP = @OFHTTP@
-OFSOCK = @OFSOCK@
+OFHTTP_LIBS = @OFHTTP_LIBS@
OF_BLOCK_TESTS_M = @OF_BLOCK_TESTS_M@
OF_EPOLL_KERNEL_EVENT_OBSERVER_M = @OF_EPOLL_KERNEL_EVENT_OBSERVER_M@
+OF_GNUTLS_TLS_STREAM_M = @OF_GNUTLS_TLS_STREAM_M@
OF_HTTP_CLIENT_TESTS_M = @OF_HTTP_CLIENT_TESTS_M@
OF_KQUEUE_KERNEL_EVENT_OBSERVER_M = @OF_KQUEUE_KERNEL_EVENT_OBSERVER_M@
+OF_OPENSSL_TLS_STREAM_M = @OF_OPENSSL_TLS_STREAM_M@
OF_POLL_KERNEL_EVENT_OBSERVER_M = @OF_POLL_KERNEL_EVENT_OBSERVER_M@
-OF_PROCESS_M = @OF_PROCESS_M@
-OF_SCTP_SOCKET_M = @OF_SCTP_SOCKET_M@
+OF_SECURE_TRANSPORT_TLS_STREAM_M = @OF_SECURE_TRANSPORT_TLS_STREAM_M@
OF_SELECT_KERNEL_EVENT_OBSERVER_M = @OF_SELECT_KERNEL_EVENT_OBSERVER_M@
+OF_SUBPROCESS_M = @OF_SUBPROCESS_M@
REEXPORT_RUNTIME = @REEXPORT_RUNTIME@
REEXPORT_RUNTIME_FRAMEWORK = @REEXPORT_RUNTIME_FRAMEWORK@
RUNTIME = @RUNTIME@
RUNTIME_ARC_TESTS_M = @RUNTIME_ARC_TESTS_M@
RUNTIME_AUTORELEASE_M = @RUNTIME_AUTORELEASE_M@
RUNTIME_FRAMEWORK_LIBS = @RUNTIME_FRAMEWORK_LIBS@
RUNTIME_INSTANCE_M = @RUNTIME_INSTANCE_M@
RUNTIME_LIBS = @RUNTIME_LIBS@
-RUN_TESTS = @RUN_TESTS@
SFDC_INLINE_H = @SFDC_INLINE_H@
SFDC_TARGET = @SFDC_TARGET@
SFD_FILE = @SFD_FILE@
TESTPLUGIN = @TESTPLUGIN@
TESTPLUGIN_LIBS = @TESTPLUGIN_LIBS@
TESTS_LIBS = @TESTS_LIBS@
TESTS_STATIC_LIB = @TESTS_STATIC_LIB@
+TLS = @TLS@
+TLS_CPPFLAGS = @TLS_CPPFLAGS@
+TLS_LIBS = @TLS_LIBS@
UNICODE_M = @UNICODE_M@
USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@
USE_SRCS_FILES = @USE_SRCS_FILES@
USE_SRCS_IPX = @USE_SRCS_IPX@
USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@
-USE_SRCS_SCTP = @USE_SRCS_SCTP@
USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@
USE_SRCS_THREADS = @USE_SRCS_THREADS@
+USE_SRCS_UNIX_SOCKETS = @USE_SRCS_UNIX_SOCKETS@
USE_SRCS_WINDOWS = @USE_SRCS_WINDOWS@
WRAPPER = @WRAPPER@
DELETED generators/Makefile
Index: generators/Makefile
==================================================================
--- generators/Makefile
+++ /dev/null
@@ -1,67 +0,0 @@
-include ../extra.mk
-
-PROG_NOINST = gen_tables${PROG_SUFFIX}
-SRCS = TableGenerator.m
-
-.PHONY: run
-run: all
- rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
- rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
- rm -f objfw.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
- rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}
- rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}
- rm -f objfwrt.dll libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib
- rm -f ${OBJFWRT_AMIGA_LIB}
- if test -f ../src/libobjfw.so; then \
- ${LN_S} ../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
- ${LN_S} ../src/libobjfw.so \
- libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
- elif test -f ../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \
- ${LN_S} ../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \
- libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
- fi
- if test -f ../src/objfw.dll; then \
- ${LN_S} ../src/objfw.dll objfw.dll; \
- fi
- if test -f ../src/libobjfw.dylib; then \
- ${LN_S} ../src/libobjfw.dylib \
- libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
- fi
- if test -f ../src/runtime/libobjfwrt.so; then \
- ${LN_S} ../src/runtime/libobjfwrt.so \
- libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
- ${LN_S} ../src/runtime/libobjfwrt.so \
- libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
- elif test -f ../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \
- ${LN_S} ../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
- fi
- if test -f ../src/runtime/objfwrt.dll; then \
- ${LN_S} ../src/runtime/objfwrt.dll objfwrt.dll; \
- fi
- if test -f ../src/runtime/libobjfwrt.dylib; then \
- ${LN_S} ../src/runtime/libobjfwrt.dylib \
- libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
- fi
- if test -f ../src/runtime/${OBJFWRT_AMIGA_LIB}; then \
- ${LN_S} ../src/runtime/${OBJFWRT_AMIGA_LIB} \
- ${OBJFWRT_AMIGA_LIB}; \
- fi
- LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
- DYLD_FRAMEWORK_PATH=../src:../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \
- DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
- LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \
- ASAN_OPTIONS=allocator_may_return_null=1 \
- ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \
- rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \
- rm -f objfw.so.${OBJFW_LIB_MAJOR_MINOR} objfw.dll; \
- rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
- rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
- rm -f objfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} objfwrt.dll; \
- rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
- exit $$EXIT
-
-include ../buildsys.mk
-
-CPPFLAGS += -I../src -I../src/exceptions -I../src/runtime -I..
-LIBS := -L../src -lobjfw -L../src/runtime ${RUNTIME_LIBS} ${LIBS}
-LD = ${OBJC}
DELETED generators/TableGenerator.h
Index: generators/TableGenerator.h
==================================================================
--- generators/TableGenerator.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFHTTPClient.h"
-
-@class OFString;
-
-@interface TableGenerator: OFObject
-{
- OFHTTPClient *_HTTPClient;
- of_unichar_t _uppercaseTable[0x110000];
- of_unichar_t _lowercaseTable[0x110000];
- of_unichar_t _titlecaseTable[0x110000];
- of_unichar_t _casefoldingTable[0x110000];
- OFString *_decompositionTable[0x110000];
- OFString *_decompositionCompatTable[0x110000];
- char _uppercaseTableUsed[0x1100];
- char _lowercaseTableUsed[0x1100];
- char _titlecaseTableUsed[0x1100];
- char _casefoldingTableUsed[0x1100];
- char _decompositionTableUsed[0x1100];
- char _decompositionCompatTableUsed[0x1100];
- size_t _uppercaseTableSize;
- size_t _lowercaseTableSize;
- size_t _titlecaseTableSize;
- size_t _casefoldingTableSize;
- size_t _decompositionTableSize;
- size_t _decompositionCompatTableSize;
- enum {
- STATE_UNICODE_DATA,
- STATE_CASE_FOLDING
- } _state;
-}
-
-- (void)parseUnicodeData: (OFHTTPResponse *)response;
-- (void)parseCaseFolding: (OFHTTPResponse *)response;
-- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table;
-- (void)writeFiles;
-- (void)writeTablesToFile: (OFString *)path;
-- (void)writeHeaderToFile: (OFString *)path;
-@end
DELETED generators/TableGenerator.m
Index: generators/TableGenerator.m
==================================================================
--- generators/TableGenerator.m
+++ /dev/null
@@ -1,776 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#include
-
-#import "OFString.h"
-#import "OFArray.h"
-#import "OFApplication.h"
-#import "OFURL.h"
-#import "OFHTTPRequest.h"
-#import "OFHTTPResponse.h"
-#import "OFHTTPClient.h"
-#import "OFFile.h"
-#import "OFStdIOStream.h"
-
-#import "OFOutOfRangeException.h"
-
-#import "TableGenerator.h"
-#import "copyright.h"
-
-#define UNICODE_DATA_URL \
- @"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt"
-#define CASE_FOLDING_URL \
- @"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt"
-
-OF_APPLICATION_DELEGATE(TableGenerator)
-
-@implementation TableGenerator
-- (instancetype)init
-{
- self = [super init];
-
- @try {
- _HTTPClient = [[OFHTTPClient alloc] init];
- _HTTPClient.delegate = self;
-
- _uppercaseTableSize = SIZE_MAX;
- _lowercaseTableSize = SIZE_MAX;
- _titlecaseTableSize = SIZE_MAX;
- _casefoldingTableSize = SIZE_MAX;
- _decompositionTableSize = SIZE_MAX;
- _decompositionCompatTableSize = SIZE_MAX;
- } @catch (id e) {
- @throw e;
- [self release];
- }
-
- return self;
-}
-
-- (void)applicationDidFinishLaunching
-{
- OFHTTPRequest *request;
-
- [of_stdout writeString: @"Downloading UnicodeData.txt…"];
- _state = STATE_UNICODE_DATA;
- request = [OFHTTPRequest requestWithURL:
- [OFURL URLWithString: UNICODE_DATA_URL]];
- [_HTTPClient asyncPerformRequest: request];
-}
-
-- (void)client: (OFHTTPClient *)client
- didPerformRequest: (OFHTTPRequest *)request
- response: (OFHTTPResponse *)response
- exception: (id)exception
-{
- if (exception != nil)
- @throw exception;
-
- [of_stdout writeLine: @" done"];
-
- switch (_state) {
- case STATE_UNICODE_DATA:
- [self parseUnicodeData: response];
- break;
- case STATE_CASE_FOLDING:
- [self parseCaseFolding: response];
- break;
- }
-}
-
-- (void)parseUnicodeData: (OFHTTPResponse *)response
-{
- OFString *line;
- OFHTTPRequest *request;
-
- [of_stdout writeString: @"Parsing UnicodeData.txt…"];
-
- while ((line = [response readLine]) != nil) {
- void *pool2;
- OFArray OF_GENERIC(OFString *) *components;
- of_unichar_t codePoint;
-
- if (line.length == 0)
- continue;
-
- pool2 = objc_autoreleasePoolPush();
-
- components = [line componentsSeparatedByString: @";"];
- if (components.count != 15) {
- of_log(@"Invalid line: %@\n", line);
- [OFApplication terminateWithStatus: 1];
- }
-
- codePoint = (of_unichar_t)[[components objectAtIndex: 0]
- unsignedLongLongValueWithBase: 16];
-
- if (codePoint > 0x10FFFF)
- @throw [OFOutOfRangeException exception];
-
- _uppercaseTable[codePoint] = (of_unichar_t)[[components
- objectAtIndex: 12] unsignedLongLongValueWithBase: 16];
- _lowercaseTable[codePoint] = (of_unichar_t)[[components
- objectAtIndex: 13] unsignedLongLongValueWithBase: 16];
- _titlecaseTable[codePoint] = (of_unichar_t)[[components
- objectAtIndex: 14] unsignedLongLongValueWithBase: 16];
-
- if ([[components objectAtIndex: 5] length] > 0) {
- OFArray *decomposed = [[components objectAtIndex: 5]
- componentsSeparatedByString: @" "];
- bool compat = false;
- OFMutableString *string;
-
- if ([decomposed.firstObject hasPrefix: @"<"]) {
- decomposed = [decomposed objectsInRange:
- of_range(1, decomposed.count - 1)];
- compat = true;
- }
-
- string = [OFMutableString string];
-
- for (OFString *character in decomposed) {
- of_unichar_t unichar = (of_unichar_t)[character
- unsignedLongLongValueWithBase: 16];
-
- [string appendCharacters: &unichar
- length: 1];
- }
-
- [string makeImmutable];
-
- if (!compat)
- _decompositionTable[codePoint] = [string copy];
- _decompositionCompatTable[codePoint] = [string copy];
- }
-
- objc_autoreleasePoolPop(pool2);
- }
-
- [self applyDecompositionRecursivelyForTable: _decompositionTable];
- [self applyDecompositionRecursivelyForTable: _decompositionCompatTable];
-
- [of_stdout writeLine: @" done"];
-
- [of_stdout writeString: @"Downloading CaseFolding.txt…"];
- _state = STATE_CASE_FOLDING;
- request = [OFHTTPRequest requestWithURL:
- [OFURL URLWithString: CASE_FOLDING_URL]];
- [_HTTPClient asyncPerformRequest: request];
-}
-
-- (void)parseCaseFolding: (OFHTTPResponse *)response
-{
- OFString *line;
-
- [of_stdout writeString: @"Parsing CaseFolding.txt…"];
-
- while ((line = [response readLine]) != nil) {
- void *pool2;
- OFArray OF_GENERIC(OFString *) *components;
- of_unichar_t codePoint;
-
- if (line.length == 0 || [line hasPrefix: @"#"])
- continue;
-
- pool2 = objc_autoreleasePoolPush();
-
- components = [line componentsSeparatedByString: @"; "];
- if (components.count != 4) {
- of_log(@"Invalid line: %s\n", line);
- [OFApplication terminateWithStatus: 1];
- }
-
- if (![[components objectAtIndex: 1] isEqual: @"S"] &&
- ![[components objectAtIndex: 1] isEqual: @"C"])
- continue;
-
- codePoint = (of_unichar_t)[[components objectAtIndex: 0]
- unsignedLongLongValueWithBase: 16];
-
- if (codePoint > 0x10FFFF)
- @throw [OFOutOfRangeException exception];
-
- _casefoldingTable[codePoint] = (of_unichar_t)[[components
- objectAtIndex: 2] unsignedLongLongValueWithBase: 16];
-
- objc_autoreleasePoolPop(pool2);
- }
-
- [of_stdout writeLine: @" done"];
-
- [self writeFiles];
-}
-
-- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table
-{
- bool done;
-
- do {
- done = true;
-
- for (of_unichar_t i = 0; i < 0x110000; i++) {
- void *pool;
- const of_unichar_t *characters;
- size_t length;
- OFMutableString *replacement;
- bool changed = false;
-
- if (table[i] == nil)
- continue;
-
- pool = objc_autoreleasePoolPush();
- characters = table[i].characters;
- length = table[i].length;
- replacement = [OFMutableString string];
-
- for (size_t j = 0; j < length; j++) {
- if (characters[j] > 0x10FFFF)
- @throw [OFOutOfRangeException
- exception];
-
- if (table[characters[j]] == nil)
- [replacement
- appendCharacters: &characters[j]
- length: 1];
- else {
- [replacement
- appendString: table[characters[j]]];
- changed = true;
- }
- }
-
- [replacement makeImmutable];
-
- if (changed) {
- [table[i] release];
- table[i] = [replacement copy];
-
- done = false;
- }
-
- objc_autoreleasePoolPop(pool);
- }
- } while (!done);
-}
-
-- (void)writeFiles
-{
- OFURL *URL;
-
- [of_stdout writeString: @"Writing files…"];
-
- URL = [OFURL fileURLWithPath: @"../src/unicode.m"];
- [self writeTablesToFile: URL.fileSystemRepresentation];
-
- URL = [OFURL fileURLWithPath: @"../src/unicode.h"];
- [self writeHeaderToFile: URL.fileSystemRepresentation];
-
- [of_stdout writeLine: @" done"];
-
- [OFApplication terminate];
-}
-
-- (void)writeTablesToFile: (OFString *)path
-{
- void *pool = objc_autoreleasePoolPush();
- OFFile *file = [OFFile fileWithPath: path
- mode: @"w"];
-
- [file writeString: COPYRIGHT
- @"#include \"config.h\"\n"
- @"\n"
- @"#import \"OFString.h\"\n\n"
- @"static const of_unichar_t emptyPage[0x100] = { 0 };\n"
- @"static const char *emptyDecompositionPage[0x100] = { NULL };\n"
- @"\n"];
-
- /* Write uppercasePage%u */
- for (of_unichar_t i = 0; i < 0x110000; i += 0x100) {
- bool isEmpty = true;
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if (_uppercaseTable[j] != 0) {
- isEmpty = false;
- _uppercaseTableSize = i >> 8;
- _uppercaseTableUsed[_uppercaseTableSize] = 1;
- break;
- }
- }
-
- if (!isEmpty) {
- void *pool2 = objc_autoreleasePoolPush();
-
- [file writeFormat: @"static const of_unichar_t "
- @"uppercasePage%u[0x100] = {\n",
- i >> 8];
-
- for (of_unichar_t j = i; j < i + 0x100; j += 8)
- [file writeFormat:
- @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
- _uppercaseTable[j],
- _uppercaseTable[j + 1],
- _uppercaseTable[j + 2],
- _uppercaseTable[j + 3],
- _uppercaseTable[j + 4],
- _uppercaseTable[j + 5],
- _uppercaseTable[j + 6],
- _uppercaseTable[j + 7]];
-
- [file writeString: @"};\n\n"];
-
- objc_autoreleasePoolPop(pool2);
- }
- }
-
- /* Write lowercasePage%u */
- for (of_unichar_t i = 0; i < 0x110000; i += 0x100) {
- bool isEmpty = true;
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if (_lowercaseTable[j] != 0) {
- isEmpty = false;
- _lowercaseTableSize = i >> 8;
- _lowercaseTableUsed[_lowercaseTableSize] = 1;
- break;
- }
- }
-
- if (!isEmpty) {
- void *pool2 = objc_autoreleasePoolPush();
-
- [file writeFormat: @"static const of_unichar_t "
- @"lowercasePage%u[0x100] = {\n",
- i >> 8];
-
- for (of_unichar_t j = i; j < i + 0x100; j += 8)
- [file writeFormat:
- @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
- _lowercaseTable[j],
- _lowercaseTable[j + 1],
- _lowercaseTable[j + 2],
- _lowercaseTable[j + 3],
- _lowercaseTable[j + 4],
- _lowercaseTable[j + 5],
- _lowercaseTable[j + 6],
- _lowercaseTable[j + 7]];
-
- [file writeString: @"};\n\n"];
-
- objc_autoreleasePoolPop(pool2);
- }
- }
-
- /* Write titlecasePage%u if it does NOT match uppercasePage%u */
- for (of_unichar_t i = 0; i < 0x110000; i += 0x100) {
- bool isEmpty = true;
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if (_titlecaseTable[j] != 0) {
- isEmpty = !memcmp(_uppercaseTable + i,
- _titlecaseTable + i,
- 256 * sizeof(of_unichar_t));
- _titlecaseTableSize = i >> 8;
- _titlecaseTableUsed[_titlecaseTableSize] =
- (isEmpty ? 2 : 1);
- break;
- }
- }
-
- if (!isEmpty) {
- void *pool2 = objc_autoreleasePoolPush();
-
- [file writeFormat: @"static const of_unichar_t "
- @"titlecasePage%u[0x100] = {\n",
- i >> 8];
-
- for (of_unichar_t j = i; j < i + 0x100; j += 8)
- [file writeFormat:
- @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
- _titlecaseTable[j],
- _titlecaseTable[j + 1],
- _titlecaseTable[j + 2],
- _titlecaseTable[j + 3],
- _titlecaseTable[j + 4],
- _titlecaseTable[j + 5],
- _titlecaseTable[j + 6],
- _titlecaseTable[j + 7]];
-
- [file writeString: @"};\n\n"];
-
- objc_autoreleasePoolPop(pool2);
- }
- }
-
- /* Write casefoldingPage%u if it does NOT match lowercasePage%u */
- for (of_unichar_t i = 0; i < 0x110000; i += 0x100) {
- bool isEmpty = true;
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if (_casefoldingTable[j] != 0) {
- isEmpty = !memcmp(_lowercaseTable + i,
- _casefoldingTable + i,
- 256 * sizeof(of_unichar_t));
- _casefoldingTableSize = i >> 8;
- _casefoldingTableUsed[_casefoldingTableSize] =
- (isEmpty ? 2 : 1);
- break;
- }
- }
-
- if (!isEmpty) {
- void *pool2 = objc_autoreleasePoolPush();
-
- [file writeFormat: @"static const of_unichar_t "
- @"casefoldingPage%u[0x100] = {\n",
- i >> 8];
-
- for (of_unichar_t j = i; j < i + 0x100; j += 8)
- [file writeFormat:
- @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
- _casefoldingTable[j],
- _casefoldingTable[j + 1],
- _casefoldingTable[j + 2],
- _casefoldingTable[j + 3],
- _casefoldingTable[j + 4],
- _casefoldingTable[j + 5],
- _casefoldingTable[j + 6],
- _casefoldingTable[j + 7]];
-
- [file writeString: @"};\n\n"];
-
- objc_autoreleasePoolPop(pool2);
- }
- }
-
- /* Write decompositionPage%u */
- for (of_unichar_t i = 0; i < 0x110000; i += 0x100) {
- bool isEmpty = true;
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if (_decompositionTable[j] != nil) {
- isEmpty = false;
- _decompositionTableSize = i >> 8;
- _decompositionTableUsed[
- _decompositionTableSize] = 1;
- break;
- }
- }
-
- if (!isEmpty) {
- void *pool2 = objc_autoreleasePoolPush();
-
- [file writeFormat: @"static const char *const "
- @"decompositionPage%u[0x100] = {\n",
- i >> 8];
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if ((j - i) % 2 == 0)
- [file writeString: @"\t"];
- else
- [file writeString: @" "];
-
- if (_decompositionTable[j] != nil) {
- const char *UTF8String =
- _decompositionTable[j].UTF8String;
- size_t length = _decompositionTable[j]
- .UTF8StringLength;
-
- [file writeString: @"\""];
-
- for (size_t k = 0; k < length; k++)
- [file writeFormat:
- @"\\x%02X",
- (uint8_t)UTF8String[k]];
-
- [file writeString: @"\","];
- } else
- [file writeString: @"NULL,"];
-
- if ((j - i) % 2 == 1)
- [file writeString: @"\n"];
- }
-
- [file writeString: @"};\n\n"];
-
- objc_autoreleasePoolPop(pool2);
- }
- }
-
- /* Write decompCompatPage%u if it does NOT match decompositionPage%u */
- for (of_unichar_t i = 0; i < 0x110000; i += 0x100) {
- bool isEmpty = true;
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if (_decompositionCompatTable[j] != 0) {
- /*
- * We bulk-compare pointers via memcmp here.
- * This is safe, as we always set the same
- * pointer in both tables if both are the same.
- */
- isEmpty = !memcmp(_decompositionTable + i,
- _decompositionCompatTable + i,
- 256 * sizeof(const char *));
- _decompositionCompatTableSize = i >> 8;
- _decompositionCompatTableUsed[
- _decompositionCompatTableSize] =
- (isEmpty ? 2 : 1);
-
- break;
- }
- }
-
- if (!isEmpty) {
- void *pool2 = objc_autoreleasePoolPush();
-
- [file writeFormat: @"static const char *const "
- @"decompCompatPage%u[0x100] = {\n",
- i >> 8];
-
- for (of_unichar_t j = i; j < i + 0x100; j++) {
- if ((j - i) % 2 == 0)
- [file writeString: @"\t"];
- else
- [file writeString: @" "];
-
- if (_decompositionCompatTable[j] != nil) {
- const char *UTF8String =
- _decompositionCompatTable[j]
- .UTF8String;
- size_t length =
- _decompositionCompatTable[j]
- .UTF8StringLength;
-
- [file writeString: @"\""];
-
- for (size_t k = 0; k < length; k++)
- [file writeFormat:
- @"\\x%02X",
- (uint8_t)UTF8String[k]];
-
- [file writeString: @"\","];
- } else
- [file writeString: @"NULL,"];
-
- if ((j - i) % 2 == 1)
- [file writeString: @"\n"];
- }
-
- [file writeString: @"};\n\n"];
-
- objc_autoreleasePoolPop(pool2);
- }
- }
-
- /*
- * Those are currently set to the last index.
- * But from now on, we need the size.
- */
- _uppercaseTableSize++;
- _lowercaseTableSize++;
- _titlecaseTableSize++;
- _casefoldingTableSize++;
- _decompositionTableSize++;
- _decompositionCompatTableSize++;
-
- /* Write of_unicode_uppercase_table */
- [file writeFormat: @"const of_unichar_t *const "
- @"of_unicode_uppercase_table[0x%X] = {\n\t",
- _uppercaseTableSize];
-
- for (of_unichar_t i = 0; i < _uppercaseTableSize; i++) {
- if (_uppercaseTableUsed[i])
- [file writeFormat: @"uppercasePage%u", i];
- else
- [file writeString: @"emptyPage"];
-
- if (i + 1 < _uppercaseTableSize) {
- if ((i + 1) % 4 == 0)
- [file writeString: @",\n\t"];
- else
- [file writeString: @", "];
- }
- }
-
- [file writeString: @"\n};\n\n"];
-
- /* Write of_unicode_lowercase_table */
- [file writeFormat: @"const of_unichar_t *const "
- @"of_unicode_lowercase_table[0x%X] = {\n\t",
- _lowercaseTableSize];
-
- for (of_unichar_t i = 0; i < _lowercaseTableSize; i++) {
- if (_lowercaseTableUsed[i])
- [file writeFormat: @"lowercasePage%u", i];
- else
- [file writeString: @"emptyPage"];
-
- if (i + 1 < _lowercaseTableSize) {
- if ((i + 1) % 4 == 0)
- [file writeString: @",\n\t"];
- else
- [file writeString: @", "];
- }
- }
-
- [file writeString: @"\n};\n\n"];
-
- /* Write of_unicode_titlecase_table */
- [file writeFormat: @"const of_unichar_t *const "
- @"of_unicode_titlecase_table[0x%X] = {\n\t",
- _titlecaseTableSize];
-
- for (of_unichar_t i = 0; i < _titlecaseTableSize; i++) {
- if (_titlecaseTableUsed[i] == 1)
- [file writeFormat: @"titlecasePage%u", i];
- else if (_titlecaseTableUsed[i] == 2)
- [file writeFormat: @"uppercasePage%u", i];
- else
- [file writeString: @"emptyPage"];
-
- if (i + 1 < _titlecaseTableSize) {
- if ((i + 1) % 4 == 0)
- [file writeString: @",\n\t"];
- else
- [file writeString: @", "];
- }
- }
-
- [file writeString: @"\n};\n\n"];
-
- /* Write of_unicode_casefolding_table */
- [file writeFormat: @"const of_unichar_t *const "
- @"of_unicode_casefolding_table[0x%X] = {\n\t",
- _casefoldingTableSize];
-
- for (of_unichar_t i = 0; i < _casefoldingTableSize; i++) {
- if (_casefoldingTableUsed[i] == 1)
- [file writeFormat: @"casefoldingPage%u", i];
- else if (_casefoldingTableUsed[i] == 2)
- [file writeFormat: @"lowercasePage%u", i];
- else
- [file writeString: @"emptyPage"];
-
- if (i + 1 < _casefoldingTableSize) {
- if ((i + 1) % 3 == 0)
- [file writeString: @",\n\t"];
- else
- [file writeString: @", "];
- }
- }
-
- [file writeString: @"\n};\n\n"];
-
- /* Write of_unicode_decomposition_table */
- [file writeFormat: @"const char *const "
- @"*of_unicode_decomposition_table[0x%X] = {\n\t",
- _decompositionTableSize];
-
- for (of_unichar_t i = 0; i < _decompositionTableSize; i++) {
- if (_decompositionTableUsed[i])
- [file writeFormat: @"decompositionPage%u", i];
- else
- [file writeString: @"emptyDecompositionPage"];
-
- if (i + 1 < _decompositionTableSize) {
- if ((i + 1) % 3 == 0)
- [file writeString: @",\n\t"];
- else
- [file writeString: @", "];
- }
- }
-
- [file writeString: @"\n};\n\n"];
-
- /* Write of_unicode_decomposition_compat_table */
- [file writeFormat: @"const char *const "
- @"*of_unicode_decomposition_compat_table[0x%X] = {"
- @"\n\t",
- _decompositionCompatTableSize];
-
- for (of_unichar_t i = 0; i < _decompositionCompatTableSize; i++) {
- if (_decompositionCompatTableUsed[i] == 1)
- [file writeFormat: @"decompCompatPage%u", i];
- else if (_decompositionCompatTableUsed[i] == 2)
- [file writeFormat: @"decompositionPage%u", i];
- else
- [file writeString: @"emptyDecompositionPage"];
-
- if (i + 1 < _decompositionCompatTableSize) {
- if ((i + 1) % 3 == 0)
- [file writeString: @",\n\t"];
- else
- [file writeString: @", "];
- }
- }
-
- [file writeString: @"\n};\n"];
-
- objc_autoreleasePoolPop(pool);
-}
-
-- (void)writeHeaderToFile: (OFString *)path
-{
- void *pool = objc_autoreleasePoolPush();
- OFFile *file = [OFFile fileWithPath: path
- mode: @"w"];
-
- [file writeString: COPYRIGHT
- @"#import \"OFString.h\"\n\n"];
-
- [file writeFormat:
- @"#define OF_UNICODE_UPPERCASE_TABLE_SIZE 0x%X\n"
- @"#define OF_UNICODE_LOWERCASE_TABLE_SIZE 0x%X\n"
- @"#define OF_UNICODE_TITLECASE_TABLE_SIZE 0x%X\n"
- @"#define OF_UNICODE_CASEFOLDING_TABLE_SIZE 0x%X\n"
- @"#define OF_UNICODE_DECOMPOSITION_TABLE_SIZE 0x%X\n"
- @"#define OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE 0x%X\n\n",
- _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize,
- _casefoldingTableSize, _decompositionTableSize,
- _decompositionCompatTableSize];
-
- [file writeString:
- @"#ifdef __cplusplus\n"
- @"extern \"C\" {\n"
- @"#endif\n"
- @"extern const of_unichar_t *const _Nonnull\n"
- @" of_unicode_uppercase_table["
- @"OF_UNICODE_UPPERCASE_TABLE_SIZE];\n"
- @"extern const of_unichar_t *const _Nonnull\n"
- @" of_unicode_lowercase_table["
- @"OF_UNICODE_LOWERCASE_TABLE_SIZE];\n"
- @"extern const of_unichar_t *const _Nonnull\n"
- @" of_unicode_titlecase_table["
- @"OF_UNICODE_TITLECASE_TABLE_SIZE];\n"
- @"extern const of_unichar_t *const _Nonnull\n"
- @" of_unicode_casefolding_table["
- @"OF_UNICODE_CASEFOLDING_TABLE_SIZE];\n"
- @"extern const char *const _Nullable *const _Nonnull\n"
- @" of_unicode_decomposition_table["
- @"OF_UNICODE_DECOMPOSITION_TABLE_SIZE];\n"
- @"extern const char *const _Nullable *const _Nonnull\n"
- @" of_unicode_decomposition_compat_table["
- @"OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE];\n"
- @"#ifdef __cplusplus\n"
- @"}\n"
- @"#endif\n"];
-
- objc_autoreleasePoolPop(pool);
-}
-@end
DELETED generators/copyright.h
Index: generators/copyright.h
==================================================================
--- generators/copyright.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFString.h"
-
-#define COPYRIGHT \
- @"/*\n" \
- @" * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, " \
- @"2017,\n" \
- @" * 2018, 2019, 2020\n" \
- @" * Jonathan Schleifer \n" \
- @" *\n" \
- @" * All rights reserved.\n" \
- @" *\n" \
- @" * This file is part of ObjFW. It may be distributed under the terms " \
- @"of the\n" \
- @" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \
- @"included in\n" \
- @" * the packaging of this file.\n" \
- @" *\n" \
- @" * Alternatively, it may be distributed under the terms of the GNU " \
- @"General\n" \
- @" * Public License, either version 2 or 3, which can be found in the " \
- @"file\n" \
- @" * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the " \
- @"packaging of this\n" \
- @" * file.\n" \
- @" */\n" \
- @"\n"
ADDED generators/library/FuncArrayGenerator.h
Index: generators/library/FuncArrayGenerator.h
==================================================================
--- /dev/null
+++ generators/library/FuncArrayGenerator.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFObject.h"
+
+#import "OFStream.h"
+#import "OFXMLElement.h"
+
+@interface FuncArrayGenerator: OFObject
+{
+ OFXMLElement *_library;
+ OFStream *_include;
+}
+
+- (instancetype)initWithLibrary: (OFXMLElement *)library
+ include: (OFStream *)include;
+- (void)generate;
+@end
ADDED generators/library/FuncArrayGenerator.m
Index: generators/library/FuncArrayGenerator.m
==================================================================
--- /dev/null
+++ generators/library/FuncArrayGenerator.m
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFArray.h"
+#import "OFXMLAttribute.h"
+
+#import "FuncArrayGenerator.h"
+
+#import "OFInvalidFormatException.h"
+#import "OFUnsupportedVersionException.h"
+
+#import "copyright.h"
+
+@implementation FuncArrayGenerator
+- (instancetype)initWithLibrary: (OFXMLElement *)library
+ include: (OFStream *)include
+{
+ self = [super init];
+
+ @try {
+ OFXMLAttribute *version;
+
+ if (![library.name isEqual: @"amiga-library"] ||
+ library.namespace != nil)
+ @throw [OFInvalidFormatException exception];
+
+ if ((version = [library attributeForName: @"version"]) == nil)
+ @throw [OFInvalidFormatException exception];
+
+ if (![version.stringValue isEqual: @"1.0"])
+ @throw [OFUnsupportedVersionException
+ exceptionWithVersion: version.stringValue];
+
+ _library = [library retain];
+ _include = [include retain];
+ } @catch (id e) {
+ [self release];
+ @throw e;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_library release];
+ [_include release];
+
+ [super dealloc];
+}
+
+- (void)generate
+{
+ [_include writeString: COPYRIGHT];
+ [_include writeString:
+ @"/* This file is automatically generated from amiga-library.xml */"
+ @"\n\n"];
+
+ for (OFXMLElement *function in [_library elementsForName: @"function"])
+ [_include writeFormat:
+ @"(CONST_APTR)glue_%@,\n",
+ [function attributeForName: @"name"].stringValue];
+}
+@end
ADDED generators/library/GlueGenerator.h
Index: generators/library/GlueGenerator.h
==================================================================
--- /dev/null
+++ generators/library/GlueGenerator.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFObject.h"
+
+#import "OFStream.h"
+#import "OFXMLElement.h"
+
+@interface GlueGenerator: OFObject
+{
+ OFXMLElement *_library;
+ OFStream *_header, *_impl;
+}
+
+- (instancetype)initWithLibrary: (OFXMLElement *)library
+ header: (OFStream *)header
+ implementation: (OFStream *)implementation;
+- (void)generate;
+@end
ADDED generators/library/GlueGenerator.m
Index: generators/library/GlueGenerator.m
==================================================================
--- /dev/null
+++ generators/library/GlueGenerator.m
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFArray.h"
+#import "OFXMLAttribute.h"
+
+#import "GlueGenerator.h"
+
+#import "OFInvalidFormatException.h"
+#import "OFUnsupportedVersionException.h"
+
+#import "copyright.h"
+
+@implementation GlueGenerator
+- (instancetype)initWithLibrary: (OFXMLElement *)library
+ header: (OFStream *)header
+ implementation: (OFStream *)impl
+{
+ self = [super init];
+
+ @try {
+ OFXMLAttribute *version;
+
+ if (![library.name isEqual: @"amiga-library"] ||
+ library.namespace != nil)
+ @throw [OFInvalidFormatException exception];
+
+ if ((version = [library attributeForName: @"version"]) == nil)
+ @throw [OFInvalidFormatException exception];
+
+ if (![version.stringValue isEqual: @"1.0"])
+ @throw [OFUnsupportedVersionException
+ exceptionWithVersion: version.stringValue];
+
+ _library = [library retain];
+ _header = [header retain];
+ _impl = [impl retain];
+ } @catch (id e) {
+ [self release];
+ @throw e;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_library release];
+ [_header release];
+ [_impl release];
+
+ [super dealloc];
+}
+
+- (void)generate
+{
+ [_header writeString: COPYRIGHT];
+ [_impl writeString: COPYRIGHT];
+
+ [_header writeString:
+ @"/* This file is automatically generated from amiga-library.xml */"
+ @"\n\n"];
+
+ [_impl writeString:
+ @"/* This file is automatically generated from amiga-library.xml */"
+ @"\n\n"
+ @"#include \"config.h\"\n"
+ @"\n"
+ @"#import \"amiga-glue.h\"\n"
+ @"\n"];
+
+ for (OFXMLElement *include in [_library elementsForName: @"include"])
+ [_header writeFormat: @"#import \"%@\"\n", include.stringValue];
+
+ [_header writeString:
+ @"\n"
+ @"#ifdef OF_AMIGAOS_M68K\n"
+ @"# define PPC_PARAMS(...) (void)\n"
+ @"# define M68K_ARG(type, name, reg)\t\t\\\n"
+ @"\tregister type reg##name __asm__(#reg);\t\\\n"
+ @"\ttype name = reg##name;\n"
+ @"#else\n"
+ @"# define PPC_PARAMS(...) (__VA_ARGS__)\n"
+ @"# define M68K_ARG(...)\n"
+ @"#endif\n"
+ @"\n"];
+ [_impl writeString:
+ @"#ifdef OF_MORPHOS\n"
+ @"/* All __saveds functions in this file need to use the SysV "
+ @"ABI */\n"
+ @"__asm__ (\n"
+ @" \".section .text\\n\"\n"
+ @" \".align 2\\n\"\n"
+ @" \"__restore_r13:\\n\"\n"
+ @" \"\tlwz\t%r13, 44(%r12)\\n\"\n"
+ @" \"\tblr\\n\"\n"
+ @");\n"
+ @"#endif\n"];
+
+ for (OFXMLElement *function in
+ [_library elementsForName: @"function"]) {
+ OFString *name =
+ [function attributeForName: @"name"].stringValue;
+ OFString *returnType =
+ [function attributeForName: @"return-type"].stringValue;
+ OFArray OF_GENERIC(OFXMLElement *) *arguments =
+ [function elementsForName: @"argument"];
+ size_t argumentIndex;
+
+ if (returnType == nil)
+ returnType = @"void";
+
+ [_header writeFormat:
+ @"extern %@%@glue_%@",
+ returnType,
+ (![returnType hasSuffix: @"*"] ? @" " : @""),
+ name];
+
+ [_impl writeFormat: @"\n"
+ @"%@ __saveds\n"
+ @"glue_%@",
+ returnType, name];
+
+ if (arguments.count > 0) {
+ [_header writeString: @" PPC_PARAMS("];
+ [_impl writeString: @" PPC_PARAMS("];
+ } else {
+ [_header writeString: @"(void"];
+ [_impl writeString: @"(void"];
+ }
+
+ argumentIndex = 0;
+ for (OFXMLElement *argument in arguments) {
+ OFString *argName =
+ [argument attributeForName: @"name"].stringValue;
+ OFString *argType =
+ [argument attributeForName: @"type"].stringValue;
+
+ if (argumentIndex++ > 0) {
+ [_header writeString: @", "];
+ [_impl writeString: @", "];
+ }
+
+ [_header writeString: argType];
+ [_impl writeString: argType];
+ if (![argType hasSuffix: @"*"]) {
+ [_header writeString: @" "];
+ [_impl writeString: @" "];
+ }
+ [_header writeString: argName];
+ [_impl writeString: argName];
+ }
+
+ [_header writeString: @");\n"];
+
+ [_impl writeString: @")\n{\n"];
+ for (OFXMLElement *argument in arguments) {
+ OFString *argName =
+ [argument attributeForName: @"name"].stringValue;
+ OFString *argType =
+ [argument attributeForName: @"type"].stringValue;
+ OFString *m68kReg = [argument
+ attributeForName: @"m68k-reg"].stringValue;
+
+ [_impl writeFormat: @"\tM68K_ARG(%@, %@, %@)\n",
+ argType, argName, m68kReg];
+ }
+
+ if (arguments.count > 0)
+ [_impl writeString: @"\n"];
+
+ if (![returnType isEqual: @"void"])
+ [_impl writeString: @"\treturn "];
+ else
+ [_impl writeString: @"\t"];
+
+ [_impl writeFormat: @"%@(", name];
+
+ argumentIndex = 0;
+ for (OFXMLElement *argument in arguments) {
+ OFString *argName =
+ [argument attributeForName: @"name"].stringValue;
+
+ if (argumentIndex++ > 0)
+ [_impl writeString: @", "];
+
+ [_impl writeString: argName];
+ }
+
+ [_impl writeString: @");\n}\n"];
+ }
+}
+@end
ADDED generators/library/LibraryGenerator.m
Index: generators/library/LibraryGenerator.m
==================================================================
--- /dev/null
+++ generators/library/LibraryGenerator.m
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFApplication.h"
+#import "OFFile.h"
+#import "OFFileManager.h"
+#import "OFURL.h"
+#import "OFXMLElement.h"
+
+#import "FuncArrayGenerator.h"
+#import "GlueGenerator.h"
+#import "LinkLibGenerator.h"
+
+@interface LibraryGenerator: OFObject
+@end
+
+OF_APPLICATION_DELEGATE(LibraryGenerator)
+
+@implementation LibraryGenerator
+- (void)applicationDidFinishLaunching
+{
+ OFURL *sourcesURL = [[OFFileManager defaultManager].currentDirectoryURL
+ URLByAppendingPathComponent: @"../../src"];
+ OFURL *runtimeLibraryURL = [sourcesURL
+ URLByAppendingPathComponent: @"runtime/amiga-library.xml"];
+ OFURL *runtimeLinkLibURL = [sourcesURL
+ URLByAppendingPathComponent: @"runtime/linklib/linklib.m"];
+ OFURL *runtimeGlueHeaderURL = [sourcesURL
+ URLByAppendingPathComponent: @"runtime/amiga-glue.h"];
+ OFURL *runtimeGlueURL = [sourcesURL
+ URLByAppendingPathComponent: @"runtime/amiga-glue.m"];
+ OFURL *runtimeFuncArrayURL = [sourcesURL
+ URLByAppendingPathComponent: @"runtime/amiga-funcarray.inc"];
+ OFXMLElement *runtimeLibrary = [OFXMLElement elementWithStream:
+ [OFFile fileWithPath: runtimeLibraryURL.fileSystemRepresentation
+ mode: @"r"]];
+ OFFile *runtimeLinkLib =
+ [OFFile fileWithPath: runtimeLinkLibURL.fileSystemRepresentation
+ mode: @"w"];
+ OFFile *runtimeGlueHeader =
+ [OFFile fileWithPath: runtimeGlueHeaderURL.fileSystemRepresentation
+ mode: @"w"];
+ OFFile *runtimeGlue =
+ [OFFile fileWithPath: runtimeGlueURL.fileSystemRepresentation
+ mode: @"w"];
+ OFFile *runtimeFuncArray =
+ [OFFile fileWithPath: runtimeFuncArrayURL.fileSystemRepresentation
+ mode: @"w"];
+ LinkLibGenerator *runtimeLinkLibGenerator = [[[LinkLibGenerator alloc]
+ initWithLibrary: runtimeLibrary
+ implementation: runtimeLinkLib] autorelease];
+ GlueGenerator *runtimeGlueGenerator = [[[GlueGenerator alloc]
+ initWithLibrary: runtimeLibrary
+ header: runtimeGlueHeader
+ implementation: runtimeGlue] autorelease];
+ FuncArrayGenerator *runtimeFuncArrayGenerator;
+ runtimeFuncArrayGenerator = [[[FuncArrayGenerator alloc]
+ initWithLibrary: runtimeLibrary
+ include: runtimeFuncArray] autorelease];
+
+ [runtimeLinkLibGenerator generate];
+ [runtimeGlueGenerator generate];
+ [runtimeFuncArrayGenerator generate];
+
+ [OFApplication terminate];
+}
+@end
ADDED generators/library/LinkLibGenerator.h
Index: generators/library/LinkLibGenerator.h
==================================================================
--- /dev/null
+++ generators/library/LinkLibGenerator.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFObject.h"
+#import "OFStream.h"
+#import "OFXMLElement.h"
+
+@interface LinkLibGenerator: OFObject
+{
+ OFXMLElement *_library;
+ OFStream *_impl;
+}
+
+- (instancetype)initWithLibrary: (OFXMLElement *)library
+ implementation: (OFStream *)impl;
+- (void)generate;
+@end
ADDED generators/library/LinkLibGenerator.m
Index: generators/library/LinkLibGenerator.m
==================================================================
--- /dev/null
+++ generators/library/LinkLibGenerator.m
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFArray.h"
+#import "OFXMLAttribute.h"
+
+#import "LinkLibGenerator.h"
+
+#import "OFInvalidFormatException.h"
+#import "OFUnsupportedVersionException.h"
+
+#import "copyright.h"
+
+@implementation LinkLibGenerator
+- (instancetype)initWithLibrary: (OFXMLElement *)library
+ implementation: (OFStream *)impl
+{
+ self = [super init];
+
+ @try {
+ OFXMLAttribute *version;
+
+ if (![library.name isEqual: @"amiga-library"] ||
+ library.namespace != nil)
+ @throw [OFInvalidFormatException exception];
+
+ if ((version = [library attributeForName: @"version"]) == nil)
+ @throw [OFInvalidFormatException exception];
+
+ if (![version.stringValue isEqual: @"1.0"])
+ @throw [OFUnsupportedVersionException
+ exceptionWithVersion: version.stringValue];
+
+ _library = [library retain];
+ _impl = [impl retain];
+ } @catch (id e) {
+ [self release];
+ @throw e;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_library release];
+ [_impl release];
+
+ [super dealloc];
+}
+
+- (void)generate
+{
+ OFString *libBase = [_library attributeForName: @"base"].stringValue;
+ OFArray OF_GENERIC(OFXMLElement *) *functions;
+ size_t funcIndex = 0;
+
+ [_impl writeString: COPYRIGHT];
+ [_impl writeString:
+ @"/* This file is automatically generated from amiga-library.xml */"
+ @"\n\n"
+ @"#include \"config.h\"\n"
+ @"\n"];
+
+ for (OFXMLElement *include in [_library elementsForName: @"include"])
+ [_impl writeFormat: @"#import \"%@\"\n",
+ include.stringValue];
+
+ [_impl writeFormat: @"\n"
+ @"extern struct Library *%@;\n"
+ @"\n",
+ libBase];
+
+ functions = [_library elementsForName: @"function"];
+ for (OFXMLElement *function in functions) {
+ OFString *name =
+ [function attributeForName: @"name"].stringValue;
+ OFString *returnType =
+ [function attributeForName: @"return-type"].stringValue;
+ OFArray OF_GENERIC(OFXMLElement *) *arguments =
+ [function elementsForName: @"argument"];
+ size_t argumentIndex;
+
+ if (returnType == nil)
+ returnType = @"void";
+
+ [_impl writeFormat: @"%@\n%@(", returnType, name];
+
+ argumentIndex = 0;
+ for (OFXMLElement *argument in
+ [function elementsForName: @"argument"]) {
+ OFString *argName =
+ [argument attributeForName: @"name"].stringValue;
+ OFString *argType =
+ [argument attributeForName: @"type"].stringValue;
+
+ if (argumentIndex++ > 0)
+ [_impl writeString: @", "];
+
+ [_impl writeString: argType];
+ if (![argType hasSuffix: @"*"])
+ [_impl writeString: @" "];
+ [_impl writeString: argName];
+ }
+
+ [_impl writeFormat:
+ @")\n"
+ @"{\n"
+ @"#if defined(OF_AMIGAOS_M68K)\n"
+ @"\tregister struct Library *a6 __asm__(\"a6\") = %@;\n"
+ @"\t(void)a6;\n"
+ @"\t", libBase];
+
+ if (![returnType isEqual: @"void"])
+ [_impl writeString: @"return "];
+
+ [_impl writeString: @"(("];
+ [_impl writeString: returnType];
+ if (![returnType hasSuffix: @"*"])
+ [_impl writeString: @" "];
+ [_impl writeString: @"(*)("];
+
+ argumentIndex = 0;
+ for (OFXMLElement *argument in arguments) {
+ OFString *argType =
+ [argument attributeForName: @"type"].stringValue;
+ OFString *m68kReg = [argument
+ attributeForName: @"m68k-reg"].stringValue;
+
+ if (argumentIndex++ > 0)
+ [_impl writeString: @", "];
+
+ [_impl writeString: argType];
+ if (![argType hasSuffix: @"*"])
+ [_impl writeString: @" "];
+ [_impl writeFormat: @"__asm__(\"%@\")",
+ m68kReg];
+ }
+
+ [_impl writeFormat: @"))(((uintptr_t)%@) - %zu))(",
+ libBase, 30 + funcIndex * 6];
+
+ argumentIndex = 0;
+ for (OFXMLElement *argument in
+ [function elementsForName: @"argument"]) {
+ OFString *argName =
+ [argument attributeForName: @"name"].stringValue;
+
+ if (argumentIndex++ > 0)
+ [_impl writeString: @", "];
+
+ [_impl writeString: argName];
+ }
+
+ [_impl writeFormat: @");\n"
+ @"#elif defined(OF_MORPHOS)\n"
+ @"\t__asm__ __volatile__ (\n"
+ @"\t \"mr\t\t%%%%r12, %%0\"\n"
+ @"\t :: \"r\"(%@) : \"r12\"\n"
+ @"\t);\n"
+ @"\n"
+ @"\t",
+ libBase, libBase];
+
+ if (![returnType isEqual: @"void"])
+ [_impl writeString: @"return "];
+
+ [_impl writeString: @"__extension__ (("];
+ [_impl writeString: returnType];
+ if (![returnType hasSuffix: @"*"])
+ [_impl writeString: @" "];
+ [_impl writeString: @"(*)("];
+
+ argumentIndex = 0;
+ for (OFXMLElement *argument in arguments) {
+ OFString *argType =
+ [argument attributeForName: @"type"].stringValue;
+
+ if (argumentIndex++ > 0)
+ [_impl writeString: @", "];
+
+ [_impl writeString: argType];
+ }
+
+ [_impl writeFormat: @"))*(void **)(((uintptr_t)%@) - %zu))(",
+ libBase, 28 + funcIndex * 6];
+
+ argumentIndex = 0;
+ for (OFXMLElement *argument in
+ [function elementsForName: @"argument"]) {
+ OFString *argName =
+ [argument attributeForName: @"name"].stringValue;
+
+ if (argumentIndex++ > 0)
+ [_impl writeString: @", "];
+
+ [_impl writeString: argName];
+ }
+
+ [_impl writeString: @");\n"
+ @"#endif\n"];
+
+ if ([function attributeForName: @"noreturn"] != nil)
+ [_impl writeString: @"\n\tOF_UNREACHABLE\n"];
+
+ [_impl writeString: @"}\n"];
+
+ if (++funcIndex < functions.count)
+ [_impl writeString: @"\n"];
+ }
+}
+@end
ADDED generators/library/Makefile
Index: generators/library/Makefile
==================================================================
--- /dev/null
+++ generators/library/Makefile
@@ -0,0 +1,75 @@
+include ../../extra.mk
+
+PROG_NOINST = gen_libraries${PROG_SUFFIX}
+SRCS = FuncArrayGenerator.m \
+ GlueGenerator.m \
+ LibraryGenerator.m \
+ LinkLibGenerator.m
+
+include ../../buildsys.mk
+
+.PHONY: run
+run: all
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
+ rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}
+ rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll
+ rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib
+ rm -f ${OBJFWRT_AMIGA_LIB}
+ if test -f ../../src/libobjfw.so; then \
+ ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
+ ${LN_S} ../../src/libobjfw.so \
+ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
+ elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \
+ ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \
+ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
+ fi
+ if test -f ../../src/objfw${OBJFW_LIB_MAJOR}.dll; then \
+ ${LN_S} ../../src/objfw${OBJFW_LIB_MAJOR}.dll \
+ objfw${OBJFW_LIB_MAJOR}.dll; \
+ fi
+ if test -f ../../src/libobjfw.dylib; then \
+ ${LN_S} ../../src/libobjfw.dylib \
+ libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
+ fi
+ if test -f ../../src/runtime/libobjfwrt.so; then \
+ ${LN_S} ../../src/runtime/libobjfwrt.so \
+ libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
+ ${LN_S} ../../src/runtime/libobjfwrt.so \
+ libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
+ elif test -f ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \
+ ${LN_S} ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
+ fi
+ if test -f ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll; then \
+ ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \
+ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
+ fi
+ if test -f ../../src/runtime/libobjfwrt.dylib; then \
+ ${LN_S} ../../src/runtime/libobjfwrt.dylib \
+ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
+ fi
+ if test -f ../../src/runtime/${OBJFWRT_AMIGA_LIB}; then \
+ ${LN_S} ../../src/runtime/${OBJFWRT_AMIGA_LIB} \
+ ${OBJFWRT_AMIGA_LIB}; \
+ fi
+ LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
+ DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \
+ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
+ LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \
+ ASAN_OPTIONS=allocator_may_return_null=1 \
+ ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
+ rm -f objfw${OBJFW_LIB_MAJOR}.dll; \
+ rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
+ rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
+ rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
+ exit $$EXIT
+
+CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../..
+LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS}
+LD = ${OBJC}
ADDED generators/library/copyright.h
Index: generators/library/copyright.h
==================================================================
--- /dev/null
+++ generators/library/copyright.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFString.h"
+
+#define COPYRIGHT \
+ @"/*\n" \
+ @" * Copyright (c) 2008-2022 Jonathan Schleifer \n" \
+ @" *\n" \
+ @" * All rights reserved.\n" \
+ @" *\n" \
+ @" * This file is part of ObjFW. It may be distributed under the terms " \
+ @"of the\n" \
+ @" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \
+ @"included in\n" \
+ @" * the packaging of this file.\n" \
+ @" *\n" \
+ @" * Alternatively, it may be distributed under the terms of the GNU " \
+ @"General\n" \
+ @" * Public License, either version 2 or 3, which can be found in the " \
+ @"file\n" \
+ @" * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the " \
+ @"packaging of this\n" \
+ @" * file.\n" \
+ @" */\n" \
+ @"\n"
ADDED generators/unicode/Makefile
Index: generators/unicode/Makefile
==================================================================
--- /dev/null
+++ generators/unicode/Makefile
@@ -0,0 +1,72 @@
+include ../../extra.mk
+
+PROG_NOINST = gen_tables${PROG_SUFFIX}
+SRCS = TableGenerator.m
+
+include ../../buildsys.mk
+
+.PHONY: run
+run: all
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
+ rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}
+ rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll
+ rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib
+ rm -f ${OBJFWRT_AMIGA_LIB}
+ if test -f ../../src/libobjfw.so; then \
+ ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
+ ${LN_S} ../../src/libobjfw.so \
+ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
+ elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \
+ ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \
+ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
+ fi
+ if test -f ../../src/objfw${OBJFW_LIB_MAJOR}.dll; then \
+ ${LN_S} ../../src/objfw${OBJFW_LIB_MAJOR}.dll \
+ objfw${OBJFW_LIB_MAJOR}.dll; \
+ fi
+ if test -f ../../src/libobjfw.dylib; then \
+ ${LN_S} ../../src/libobjfw.dylib \
+ libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
+ fi
+ if test -f ../../src/runtime/libobjfwrt.so; then \
+ ${LN_S} ../../src/runtime/libobjfwrt.so \
+ libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
+ ${LN_S} ../../src/runtime/libobjfwrt.so \
+ libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
+ elif test -f ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \
+ ${LN_S} ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
+ fi
+ if test -f ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll; then \
+ ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \
+ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
+ fi
+ if test -f ../../src/runtime/libobjfwrt.dylib; then \
+ ${LN_S} ../../src/runtime/libobjfwrt.dylib \
+ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
+ fi
+ if test -f ../../src/runtime/${OBJFWRT_AMIGA_LIB}; then \
+ ${LN_S} ../../src/runtime/${OBJFWRT_AMIGA_LIB} \
+ ${OBJFWRT_AMIGA_LIB}; \
+ fi
+ LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
+ DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \
+ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
+ LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \
+ ASAN_OPTIONS=allocator_may_return_null=1 \
+ ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \
+ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
+ rm -f objfw${OBJFW_LIB_MAJOR}.dll; \
+ rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
+ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
+ rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
+ rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
+ exit $$EXIT
+
+CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../..
+LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS}
+LD = ${OBJC}
ADDED generators/unicode/TableGenerator.h
Index: generators/unicode/TableGenerator.h
==================================================================
--- /dev/null
+++ generators/unicode/TableGenerator.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFObject.h"
+#import "OFHTTPClient.h"
+
+@class OFString;
+
+@interface TableGenerator: OFObject
+{
+ OFHTTPClient *_HTTPClient;
+ OFUnichar _uppercaseTable[0x110000];
+ OFUnichar _lowercaseTable[0x110000];
+ OFUnichar _titlecaseTable[0x110000];
+ OFUnichar _caseFoldingTable[0x110000];
+ OFString *_decompositionTable[0x110000];
+ OFString *_decompositionCompatTable[0x110000];
+ char _uppercaseTableUsed[0x1100];
+ char _lowercaseTableUsed[0x1100];
+ char _titlecaseTableUsed[0x1100];
+ char _caseFoldingTableUsed[0x1100];
+ char _decompositionTableUsed[0x1100];
+ char _decompositionCompatTableUsed[0x1100];
+ size_t _uppercaseTableSize;
+ size_t _lowercaseTableSize;
+ size_t _titlecaseTableSize;
+ size_t _caseFoldingTableSize;
+ size_t _decompositionTableSize;
+ size_t _decompositionCompatTableSize;
+ enum {
+ stateUnicodeData,
+ stateCaseFolding
+ } _state;
+}
+
+- (void)parseUnicodeData: (OFHTTPResponse *)response;
+- (void)parseCaseFolding: (OFHTTPResponse *)response;
+- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table;
+- (void)writeFiles;
+- (void)writeTablesToFile: (OFString *)path;
+- (void)writeHeaderToFile: (OFString *)path;
+@end
ADDED generators/unicode/TableGenerator.m
Index: generators/unicode/TableGenerator.m
==================================================================
--- /dev/null
+++ generators/unicode/TableGenerator.m
@@ -0,0 +1,770 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#include
+
+#import "OFString.h"
+#import "OFArray.h"
+#import "OFApplication.h"
+#import "OFURL.h"
+#import "OFHTTPRequest.h"
+#import "OFHTTPResponse.h"
+#import "OFHTTPClient.h"
+#import "OFFile.h"
+#import "OFStdIOStream.h"
+
+#import "OFOutOfRangeException.h"
+
+#import "TableGenerator.h"
+#import "copyright.h"
+
+static OFString *const unicodeDataURL =
+ @"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt";
+static OFString *const caseFoldingURL =
+ @"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt";
+
+OF_APPLICATION_DELEGATE(TableGenerator)
+
+@implementation TableGenerator
+- (instancetype)init
+{
+ self = [super init];
+
+ @try {
+ _HTTPClient = [[OFHTTPClient alloc] init];
+ _HTTPClient.delegate = self;
+
+ _uppercaseTableSize = SIZE_MAX;
+ _lowercaseTableSize = SIZE_MAX;
+ _titlecaseTableSize = SIZE_MAX;
+ _caseFoldingTableSize = SIZE_MAX;
+ _decompositionTableSize = SIZE_MAX;
+ _decompositionCompatTableSize = SIZE_MAX;
+ } @catch (id e) {
+ [self release];
+ @throw e;
+ }
+
+ return self;
+}
+
+- (void)applicationDidFinishLaunching
+{
+ OFHTTPRequest *request;
+
+ [OFStdOut writeString: @"Downloading UnicodeData.txt…"];
+ _state = stateUnicodeData;
+ request = [OFHTTPRequest requestWithURL:
+ [OFURL URLWithString: unicodeDataURL]];
+ [_HTTPClient asyncPerformRequest: request];
+}
+
+- (void)client: (OFHTTPClient *)client
+ didPerformRequest: (OFHTTPRequest *)request
+ response: (OFHTTPResponse *)response
+ exception: (id)exception
+{
+ if (exception != nil)
+ @throw exception;
+
+ [OFStdOut writeLine: @" done"];
+
+ switch (_state) {
+ case stateUnicodeData:
+ [self parseUnicodeData: response];
+ break;
+ case stateCaseFolding:
+ [self parseCaseFolding: response];
+ break;
+ }
+}
+
+- (void)parseUnicodeData: (OFHTTPResponse *)response
+{
+ OFString *line;
+ OFHTTPRequest *request;
+
+ [OFStdOut writeString: @"Parsing UnicodeData.txt…"];
+
+ while ((line = [response readLine]) != nil) {
+ void *pool2;
+ OFArray OF_GENERIC(OFString *) *components;
+ OFUnichar codePoint;
+
+ if (line.length == 0)
+ continue;
+
+ pool2 = objc_autoreleasePoolPush();
+
+ components = [line componentsSeparatedByString: @";"];
+ if (components.count != 15) {
+ OFLog(@"Invalid line: %@\n", line);
+ [OFApplication terminateWithStatus: 1];
+ }
+
+ codePoint = (OFUnichar)[[components objectAtIndex: 0]
+ unsignedLongLongValueWithBase: 16];
+
+ if (codePoint > 0x10FFFF)
+ @throw [OFOutOfRangeException exception];
+
+ _uppercaseTable[codePoint] = (OFUnichar)[[components
+ objectAtIndex: 12] unsignedLongLongValueWithBase: 16];
+ _lowercaseTable[codePoint] = (OFUnichar)[[components
+ objectAtIndex: 13] unsignedLongLongValueWithBase: 16];
+ _titlecaseTable[codePoint] = (OFUnichar)[[components
+ objectAtIndex: 14] unsignedLongLongValueWithBase: 16];
+
+ if ([[components objectAtIndex: 5] length] > 0) {
+ OFArray *decomposed = [[components objectAtIndex: 5]
+ componentsSeparatedByString: @" "];
+ bool compat = false;
+ OFMutableString *string;
+
+ if ([decomposed.firstObject hasPrefix: @"<"]) {
+ decomposed = [decomposed objectsInRange:
+ OFRangeMake(1, decomposed.count - 1)];
+ compat = true;
+ }
+
+ string = [OFMutableString string];
+
+ for (OFString *character in decomposed) {
+ OFUnichar unichar = (OFUnichar)[character
+ unsignedLongLongValueWithBase: 16];
+
+ [string appendCharacters: &unichar
+ length: 1];
+ }
+
+ [string makeImmutable];
+
+ if (!compat)
+ _decompositionTable[codePoint] = [string copy];
+ _decompositionCompatTable[codePoint] = [string copy];
+ }
+
+ objc_autoreleasePoolPop(pool2);
+ }
+
+ [self applyDecompositionRecursivelyForTable: _decompositionTable];
+ [self applyDecompositionRecursivelyForTable: _decompositionCompatTable];
+
+ [OFStdOut writeLine: @" done"];
+
+ [OFStdOut writeString: @"Downloading CaseFolding.txt…"];
+ _state = stateCaseFolding;
+ request = [OFHTTPRequest requestWithURL:
+ [OFURL URLWithString: caseFoldingURL]];
+ [_HTTPClient asyncPerformRequest: request];
+}
+
+- (void)parseCaseFolding: (OFHTTPResponse *)response
+{
+ OFString *line;
+
+ [OFStdOut writeString: @"Parsing CaseFolding.txt…"];
+
+ while ((line = [response readLine]) != nil) {
+ void *pool2;
+ OFArray OF_GENERIC(OFString *) *components;
+ OFUnichar codePoint;
+
+ if (line.length == 0 || [line hasPrefix: @"#"])
+ continue;
+
+ pool2 = objc_autoreleasePoolPush();
+
+ components = [line componentsSeparatedByString: @"; "];
+ if (components.count != 4) {
+ OFLog(@"Invalid line: %s\n", line);
+ [OFApplication terminateWithStatus: 1];
+ }
+
+ if (![[components objectAtIndex: 1] isEqual: @"S"] &&
+ ![[components objectAtIndex: 1] isEqual: @"C"])
+ continue;
+
+ codePoint = (OFUnichar)[[components objectAtIndex: 0]
+ unsignedLongLongValueWithBase: 16];
+
+ if (codePoint > 0x10FFFF)
+ @throw [OFOutOfRangeException exception];
+
+ _caseFoldingTable[codePoint] = (OFUnichar)[[components
+ objectAtIndex: 2] unsignedLongLongValueWithBase: 16];
+
+ objc_autoreleasePoolPop(pool2);
+ }
+
+ [OFStdOut writeLine: @" done"];
+
+ [self writeFiles];
+}
+
+- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table
+{
+ bool done;
+
+ do {
+ done = true;
+
+ for (OFUnichar i = 0; i < 0x110000; i++) {
+ void *pool;
+ const OFUnichar *characters;
+ size_t length;
+ OFMutableString *replacement;
+ bool changed = false;
+
+ if (table[i] == nil)
+ continue;
+
+ pool = objc_autoreleasePoolPush();
+ characters = table[i].characters;
+ length = table[i].length;
+ replacement = [OFMutableString string];
+
+ for (size_t j = 0; j < length; j++) {
+ if (characters[j] > 0x10FFFF)
+ @throw [OFOutOfRangeException
+ exception];
+
+ if (table[characters[j]] == nil)
+ [replacement
+ appendCharacters: &characters[j]
+ length: 1];
+ else {
+ [replacement
+ appendString: table[characters[j]]];
+ changed = true;
+ }
+ }
+
+ [replacement makeImmutable];
+
+ if (changed) {
+ [table[i] release];
+ table[i] = [replacement copy];
+
+ done = false;
+ }
+
+ objc_autoreleasePoolPop(pool);
+ }
+ } while (!done);
+}
+
+- (void)writeFiles
+{
+ OFURL *URL;
+
+ [OFStdOut writeString: @"Writing files…"];
+
+ URL = [OFURL fileURLWithPath: @"../../src/unicode.m"];
+ [self writeTablesToFile: URL.fileSystemRepresentation];
+
+ URL = [OFURL fileURLWithPath: @"../../src/unicode.h"];
+ [self writeHeaderToFile: URL.fileSystemRepresentation];
+
+ [OFStdOut writeLine: @" done"];
+
+ [OFApplication terminate];
+}
+
+- (void)writeTablesToFile: (OFString *)path
+{
+ void *pool = objc_autoreleasePoolPush();
+ OFFile *file = [OFFile fileWithPath: path
+ mode: @"w"];
+
+ [file writeString: COPYRIGHT
+ @"#include \"config.h\"\n"
+ @"\n"
+ @"#import \"OFString.h\"\n\n"
+ @"static const OFUnichar emptyPage[0x100] = { 0 };\n"
+ @"static const char *emptyDecompositionPage[0x100] = { NULL };\n"
+ @"\n"];
+
+ /* Write uppercasePage%u */
+ for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
+ bool isEmpty = true;
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if (_uppercaseTable[j] != 0) {
+ isEmpty = false;
+ _uppercaseTableSize = i >> 8;
+ _uppercaseTableUsed[_uppercaseTableSize] = 1;
+ break;
+ }
+ }
+
+ if (!isEmpty) {
+ void *pool2 = objc_autoreleasePoolPush();
+
+ [file writeFormat: @"static const OFUnichar "
+ @"uppercasePage%u[0x100] = {\n",
+ i >> 8];
+
+ for (OFUnichar j = i; j < i + 0x100; j += 8)
+ [file writeFormat:
+ @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
+ _uppercaseTable[j],
+ _uppercaseTable[j + 1],
+ _uppercaseTable[j + 2],
+ _uppercaseTable[j + 3],
+ _uppercaseTable[j + 4],
+ _uppercaseTable[j + 5],
+ _uppercaseTable[j + 6],
+ _uppercaseTable[j + 7]];
+
+ [file writeString: @"};\n\n"];
+
+ objc_autoreleasePoolPop(pool2);
+ }
+ }
+
+ /* Write lowercasePage%u */
+ for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
+ bool isEmpty = true;
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if (_lowercaseTable[j] != 0) {
+ isEmpty = false;
+ _lowercaseTableSize = i >> 8;
+ _lowercaseTableUsed[_lowercaseTableSize] = 1;
+ break;
+ }
+ }
+
+ if (!isEmpty) {
+ void *pool2 = objc_autoreleasePoolPush();
+
+ [file writeFormat: @"static const OFUnichar "
+ @"lowercasePage%u[0x100] = {\n",
+ i >> 8];
+
+ for (OFUnichar j = i; j < i + 0x100; j += 8)
+ [file writeFormat:
+ @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
+ _lowercaseTable[j],
+ _lowercaseTable[j + 1],
+ _lowercaseTable[j + 2],
+ _lowercaseTable[j + 3],
+ _lowercaseTable[j + 4],
+ _lowercaseTable[j + 5],
+ _lowercaseTable[j + 6],
+ _lowercaseTable[j + 7]];
+
+ [file writeString: @"};\n\n"];
+
+ objc_autoreleasePoolPop(pool2);
+ }
+ }
+
+ /* Write titlecasePage%u if it does NOT match uppercasePage%u */
+ for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
+ bool isEmpty = true;
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if (_titlecaseTable[j] != 0) {
+ isEmpty = !memcmp(_uppercaseTable + i,
+ _titlecaseTable + i,
+ 256 * sizeof(OFUnichar));
+ _titlecaseTableSize = i >> 8;
+ _titlecaseTableUsed[_titlecaseTableSize] =
+ (isEmpty ? 2 : 1);
+ break;
+ }
+ }
+
+ if (!isEmpty) {
+ void *pool2 = objc_autoreleasePoolPush();
+
+ [file writeFormat: @"static const OFUnichar "
+ @"titlecasePage%u[0x100] = {\n",
+ i >> 8];
+
+ for (OFUnichar j = i; j < i + 0x100; j += 8)
+ [file writeFormat:
+ @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
+ _titlecaseTable[j],
+ _titlecaseTable[j + 1],
+ _titlecaseTable[j + 2],
+ _titlecaseTable[j + 3],
+ _titlecaseTable[j + 4],
+ _titlecaseTable[j + 5],
+ _titlecaseTable[j + 6],
+ _titlecaseTable[j + 7]];
+
+ [file writeString: @"};\n\n"];
+
+ objc_autoreleasePoolPop(pool2);
+ }
+ }
+
+ /* Write caseFoldingPage%u if it does NOT match lowercasePage%u */
+ for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
+ bool isEmpty = true;
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if (_caseFoldingTable[j] != 0) {
+ isEmpty = !memcmp(_lowercaseTable + i,
+ _caseFoldingTable + i,
+ 256 * sizeof(OFUnichar));
+ _caseFoldingTableSize = i >> 8;
+ _caseFoldingTableUsed[_caseFoldingTableSize] =
+ (isEmpty ? 2 : 1);
+ break;
+ }
+ }
+
+ if (!isEmpty) {
+ void *pool2 = objc_autoreleasePoolPush();
+
+ [file writeFormat: @"static const OFUnichar "
+ @"caseFoldingPage%u[0x100] = {\n",
+ i >> 8];
+
+ for (OFUnichar j = i; j < i + 0x100; j += 8)
+ [file writeFormat:
+ @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
+ _caseFoldingTable[j],
+ _caseFoldingTable[j + 1],
+ _caseFoldingTable[j + 2],
+ _caseFoldingTable[j + 3],
+ _caseFoldingTable[j + 4],
+ _caseFoldingTable[j + 5],
+ _caseFoldingTable[j + 6],
+ _caseFoldingTable[j + 7]];
+
+ [file writeString: @"};\n\n"];
+
+ objc_autoreleasePoolPop(pool2);
+ }
+ }
+
+ /* Write decompositionPage%u */
+ for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
+ bool isEmpty = true;
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if (_decompositionTable[j] != nil) {
+ isEmpty = false;
+ _decompositionTableSize = i >> 8;
+ _decompositionTableUsed[
+ _decompositionTableSize] = 1;
+ break;
+ }
+ }
+
+ if (!isEmpty) {
+ void *pool2 = objc_autoreleasePoolPush();
+
+ [file writeFormat: @"static const char *const "
+ @"decompositionPage%u[0x100] = {\n",
+ i >> 8];
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if ((j - i) % 2 == 0)
+ [file writeString: @"\t"];
+ else
+ [file writeString: @" "];
+
+ if (_decompositionTable[j] != nil) {
+ const char *UTF8String =
+ _decompositionTable[j].UTF8String;
+ size_t length = _decompositionTable[j]
+ .UTF8StringLength;
+
+ [file writeString: @"\""];
+
+ for (size_t k = 0; k < length; k++)
+ [file writeFormat:
+ @"\\x%02X",
+ (uint8_t)UTF8String[k]];
+
+ [file writeString: @"\","];
+ } else
+ [file writeString: @"NULL,"];
+
+ if ((j - i) % 2 == 1)
+ [file writeString: @"\n"];
+ }
+
+ [file writeString: @"};\n\n"];
+
+ objc_autoreleasePoolPop(pool2);
+ }
+ }
+
+ /* Write decompCompatPage%u if it does NOT match decompositionPage%u */
+ for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
+ bool isEmpty = true;
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if (_decompositionCompatTable[j] != 0) {
+ /*
+ * We bulk-compare pointers via memcmp here.
+ * This is safe, as we always set the same
+ * pointer in both tables if both are the same.
+ */
+ isEmpty = !memcmp(_decompositionTable + i,
+ _decompositionCompatTable + i,
+ 256 * sizeof(const char *));
+ _decompositionCompatTableSize = i >> 8;
+ _decompositionCompatTableUsed[
+ _decompositionCompatTableSize] =
+ (isEmpty ? 2 : 1);
+
+ break;
+ }
+ }
+
+ if (!isEmpty) {
+ void *pool2 = objc_autoreleasePoolPush();
+
+ [file writeFormat: @"static const char *const "
+ @"decompCompatPage%u[0x100] = {\n",
+ i >> 8];
+
+ for (OFUnichar j = i; j < i + 0x100; j++) {
+ if ((j - i) % 2 == 0)
+ [file writeString: @"\t"];
+ else
+ [file writeString: @" "];
+
+ if (_decompositionCompatTable[j] != nil) {
+ const char *UTF8String =
+ _decompositionCompatTable[j]
+ .UTF8String;
+ size_t length =
+ _decompositionCompatTable[j]
+ .UTF8StringLength;
+
+ [file writeString: @"\""];
+
+ for (size_t k = 0; k < length; k++)
+ [file writeFormat:
+ @"\\x%02X",
+ (uint8_t)UTF8String[k]];
+
+ [file writeString: @"\","];
+ } else
+ [file writeString: @"NULL,"];
+
+ if ((j - i) % 2 == 1)
+ [file writeString: @"\n"];
+ }
+
+ [file writeString: @"};\n\n"];
+
+ objc_autoreleasePoolPop(pool2);
+ }
+ }
+
+ /*
+ * Those are currently set to the last index.
+ * But from now on, we need the size.
+ */
+ _uppercaseTableSize++;
+ _lowercaseTableSize++;
+ _titlecaseTableSize++;
+ _caseFoldingTableSize++;
+ _decompositionTableSize++;
+ _decompositionCompatTableSize++;
+
+ /* Write OFUnicodeUppercaseTable */
+ [file writeFormat: @"const OFUnichar *const "
+ @"OFUnicodeUppercaseTable[0x%X] = {\n\t",
+ _uppercaseTableSize];
+
+ for (OFUnichar i = 0; i < _uppercaseTableSize; i++) {
+ if (_uppercaseTableUsed[i])
+ [file writeFormat: @"uppercasePage%u", i];
+ else
+ [file writeString: @"emptyPage"];
+
+ if (i + 1 < _uppercaseTableSize) {
+ if ((i + 1) % 4 == 0)
+ [file writeString: @",\n\t"];
+ else
+ [file writeString: @", "];
+ }
+ }
+
+ [file writeString: @"\n};\n\n"];
+
+ /* Write OFUnicodeLowercaseTable */
+ [file writeFormat: @"const OFUnichar *const "
+ @"OFUnicodeLowercaseTable[0x%X] = {\n\t",
+ _lowercaseTableSize];
+
+ for (OFUnichar i = 0; i < _lowercaseTableSize; i++) {
+ if (_lowercaseTableUsed[i])
+ [file writeFormat: @"lowercasePage%u", i];
+ else
+ [file writeString: @"emptyPage"];
+
+ if (i + 1 < _lowercaseTableSize) {
+ if ((i + 1) % 4 == 0)
+ [file writeString: @",\n\t"];
+ else
+ [file writeString: @", "];
+ }
+ }
+
+ [file writeString: @"\n};\n\n"];
+
+ /* Write OFUnicodeTitlecaseTable */
+ [file writeFormat: @"const OFUnichar *const "
+ @"OFUnicodeTitlecaseTable[0x%X] = {\n\t",
+ _titlecaseTableSize];
+
+ for (OFUnichar i = 0; i < _titlecaseTableSize; i++) {
+ if (_titlecaseTableUsed[i] == 1)
+ [file writeFormat: @"titlecasePage%u", i];
+ else if (_titlecaseTableUsed[i] == 2)
+ [file writeFormat: @"uppercasePage%u", i];
+ else
+ [file writeString: @"emptyPage"];
+
+ if (i + 1 < _titlecaseTableSize) {
+ if ((i + 1) % 4 == 0)
+ [file writeString: @",\n\t"];
+ else
+ [file writeString: @", "];
+ }
+ }
+
+ [file writeString: @"\n};\n\n"];
+
+ /* Write OFUnicodeCaseFoldingTable */
+ [file writeFormat: @"const OFUnichar *const "
+ @"OFUnicodeCaseFoldingTable[0x%X] = {\n\t",
+ _caseFoldingTableSize];
+
+ for (OFUnichar i = 0; i < _caseFoldingTableSize; i++) {
+ if (_caseFoldingTableUsed[i] == 1)
+ [file writeFormat: @"caseFoldingPage%u", i];
+ else if (_caseFoldingTableUsed[i] == 2)
+ [file writeFormat: @"lowercasePage%u", i];
+ else
+ [file writeString: @"emptyPage"];
+
+ if (i + 1 < _caseFoldingTableSize) {
+ if ((i + 1) % 3 == 0)
+ [file writeString: @",\n\t"];
+ else
+ [file writeString: @", "];
+ }
+ }
+
+ [file writeString: @"\n};\n\n"];
+
+ /* Write OFUnicodeDecompositionTable */
+ [file writeFormat: @"const char *const "
+ @"*OFUnicodeDecompositionTable[0x%X] = {\n\t",
+ _decompositionTableSize];
+
+ for (OFUnichar i = 0; i < _decompositionTableSize; i++) {
+ if (_decompositionTableUsed[i])
+ [file writeFormat: @"decompositionPage%u", i];
+ else
+ [file writeString: @"emptyDecompositionPage"];
+
+ if (i + 1 < _decompositionTableSize) {
+ if ((i + 1) % 3 == 0)
+ [file writeString: @",\n\t"];
+ else
+ [file writeString: @", "];
+ }
+ }
+
+ [file writeString: @"\n};\n\n"];
+
+ /* Write OFUnicodeDecompositionCompatTable */
+ [file writeFormat: @"const char *const "
+ @"*OFUnicodeDecompositionCompatTable[0x%X] = {"
+ @"\n\t",
+ _decompositionCompatTableSize];
+
+ for (OFUnichar i = 0; i < _decompositionCompatTableSize; i++) {
+ if (_decompositionCompatTableUsed[i] == 1)
+ [file writeFormat: @"decompCompatPage%u", i];
+ else if (_decompositionCompatTableUsed[i] == 2)
+ [file writeFormat: @"decompositionPage%u", i];
+ else
+ [file writeString: @"emptyDecompositionPage"];
+
+ if (i + 1 < _decompositionCompatTableSize) {
+ if ((i + 1) % 3 == 0)
+ [file writeString: @",\n\t"];
+ else
+ [file writeString: @", "];
+ }
+ }
+
+ [file writeString: @"\n};\n"];
+
+ objc_autoreleasePoolPop(pool);
+}
+
+- (void)writeHeaderToFile: (OFString *)path
+{
+ void *pool = objc_autoreleasePoolPush();
+ OFFile *file = [OFFile fileWithPath: path
+ mode: @"w"];
+
+ [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"
+ @"#define OFUnicodeDecompositionTableSize 0x%X\n"
+ @"#define OFUnicodeDecompositionCompatTableSize 0x%X\n\n",
+ _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize,
+ _caseFoldingTableSize, _decompositionTableSize,
+ _decompositionCompatTableSize];
+
+ [file writeString:
+ @"#ifdef __cplusplus\n"
+ @"extern \"C\" {\n"
+ @"#endif\n"
+ @"extern const OFUnichar *const _Nonnull\n"
+ @" OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize];\n"
+ @"extern const OFUnichar *const _Nonnull\n"
+ @" OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize];\n"
+ @"extern const OFUnichar *const _Nonnull\n"
+ @" OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize];\n"
+ @"extern const OFUnichar *const _Nonnull\n"
+ @" OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize];\n"
+ @"extern const char *const _Nullable *const _Nonnull\n"
+ @" OFUnicodeDecompositionTable["
+ @"OFUnicodeDecompositionTableSize];\n"
+ @"extern const char *const _Nullable *const _Nonnull\n"
+ @" OFUnicodeDecompositionCompatTable["
+ @"OFUnicodeDecompositionCompatTableSize];\n"
+ @"#ifdef __cplusplus\n"
+ @"}\n"
+ @"#endif\n"];
+
+ objc_autoreleasePoolPop(pool);
+}
+@end
ADDED generators/unicode/copyright.h
Index: generators/unicode/copyright.h
==================================================================
--- /dev/null
+++ generators/unicode/copyright.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFString.h"
+
+#define COPYRIGHT \
+ @"/*\n" \
+ @" * Copyright (c) 2008-2022 Jonathan Schleifer \n" \
+ @" *\n" \
+ @" * All rights reserved.\n" \
+ @" *\n" \
+ @" * This file is part of ObjFW. It may be distributed under the terms " \
+ @"of the\n" \
+ @" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \
+ @"included in\n" \
+ @" * the packaging of this file.\n" \
+ @" *\n" \
+ @" * Alternatively, it may be distributed under the terms of the GNU " \
+ @"General\n" \
+ @" * Public License, either version 2 or 3, which can be found in the " \
+ @"file\n" \
+ @" * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the " \
+ @"packaging of this\n" \
+ @" * file.\n" \
+ @" */\n" \
+ @"\n"
ADDED objfw.spec
Index: objfw.spec
==================================================================
--- /dev/null
+++ objfw.spec
@@ -0,0 +1,248 @@
+%global libobjfw_major 0
+%global libobjfw_minor 0
+%global libobjfwrt_major 0
+%global libobjfwrt_minor 0
+%global libobjfwtls_major 0
+%global libobjfwtls_minor 0
+%if 0%{?suse_version}
+%global libobjfw_pkgname libobjfw%{libobjfw_major}
+%global libobjfwrt_pkgname libobjfwrt%{libobjfwrt_major}
+%global libobjfwtls_pkgname libobjfwtls%{libobjfwtls_major}
+%else
+%global libobjfw_pkgname libobjfw
+%global libobjfwrt_pkgname libobjfwrt
+%global libobjfwtls_pkgname libobjfwtls
+%endif
+
+Name: objfw
+Version: 1.1dev
+Release: 1%{?dist}
+Summary: Portable, lightweight framework for the Objective-C language
+
+%if 0%{?suse_version}
+License: QPL-1.0 or GPL-3.0 or GPL-2.0
+Group: Development/Languages/C and C++
+%else
+License: QPL or GPLv3 or GPLv2
+%endif
+URL: https://objfw.nil.im
+Source0: objfw-%{version}.tar.gz
+
+BuildRequires: autoconf
+BuildRequires: automake
+BuildRequires: clang
+BuildRequires: make
+BuildRequires: pkgconfig(openssl)
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfw_pkgname}-devel = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}-devel = %{version}-%{release}
+Requires: ofarc%{_isa} = %{version}-%{release}
+Requires: ofdns%{_isa} = %{version}-%{release}
+Requires: ofhash%{_isa} = %{version}-%{release}
+Requires: ofhttp%{_isa} = %{version}-%{release}
+
+%description
+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 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.
+
+%package -n %{libobjfw_pkgname}
+Summary: ObjFW library
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n %{libobjfw_pkgname}
+The %{libobjfw_pkgname} package contains the library needed by programs using
+ObjFW.
+
+%package -n %{libobjfw_pkgname}-devel
+Summary: Header files, libraries and tools for %{libobjfw_pkgname}
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}-devel = %{version}-%{release}
+
+%description -n %{libobjfw_pkgname}-devel
+The %{libobjfw_pkgname}-devel package contains the header files, libraries and
+tools to develop programs using ObjFW.
+
+%package -n %{libobjfwrt_pkgname}
+Summary: ObjFW Objective-C runtime library
+
+%description -n %{libobjfwrt_pkgname}
+The %{libobjfwrt_pkgname} package contains ObjFW's Objective-C runtime library.
+
+%package -n %{libobjfwrt_pkgname}-devel
+Summary: Header files and libraries for %{libobjfwrt_pkgname}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n %{libobjfwrt_pkgname}-devel
+The %{libobjfwrt_pkgname}-devel package contains header files and libraries for
+ObjFW's Objective-C runtime library.
+
+%package -n %{libobjfwtls_pkgname}
+Summary: TLS support for ObjFW
+Requires: openssl%{_isa} >= 1.1.1
+
+%description -n %{libobjfwtls_pkgname}
+The %{libobjfwtls_pkgname} package contains TLS support for ObjFW
+
+%package -n %{libobjfwtls_pkgname}-devel
+Summary: Header files and libraries for %{libobjfwtls_pkgname}
+Requires: %{libobjfwtls_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n %{libobjfwtls_pkgname}-devel
+The %{libobjfwtls_pkgname}-devel package contains header files and libraries
+for TLS support for ObjFW.
+
+%package -n ofarc
+Summary: Utility for handling ZIP, Tar and LHA archives
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofarc
+ofarc is a multi-format archive utility that allows creating, listing,
+extracting and modifying ZIP, Tar and LHA archives using ObjFW's classes for
+various archive types.
+
+%package -n ofdns
+Summary: Utility for performing DNS requests on the command line
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofdns
+ofdns is an utility for performing DNS requests on the command line using
+ObjFW's DNS resolver.
+
+%package -n ofhash
+Summary: Utility to hash files with various cryptographic hash functions
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofhash
+ofhash is an utility to hash files with various cryptographic hash functions
+(even using different algorithms at once) using ObjFW's classes for various
+cryptographic hashes.
+
+%package -n ofhttp
+Summary: Command line downloader for HTTP(S)
+Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
+Requires: %{libobjfwtls_pkgname}%{_isa} = %{version}-%{release}
+
+%description -n ofhttp
+ofhttp is a command line downloader for HTTP and HTTPS (via ObjOpenSSL) using
+ObjFW's OFHTTPClient class. It supports all features one would expect from a
+modern command line downloader such as resuming of downloads, using a SOCKS5
+proxy, a modern terminal-based UI, etc.
+
+%prep
+%autosetup
+./autogen.sh
+
+%build
+%configure OBJC=clang --disable-rpath
+%make_build
+
+%install
+%make_install
+
+%check
+make -C tests run
+
+%if 0%{?suse_version}
+%post -n %{libobjfw_pkgname} -p /sbin/ldconfig
+%postun -n %{libobjfw_pkgname} -p /sbin/ldconfig
+%post -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
+%postun -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
+%endif
+
+%files
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfw_pkgname}
+%{_libdir}/libobjfw.so.%{libobjfw_major}
+%{_libdir}/libobjfw.so.%{libobjfw_major}.%{libobjfw_minor}.0
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfw_pkgname}-devel
+%{_libdir}/libobjfw.so
+%dir %{_includedir}/ObjFW
+%{_includedir}/ObjFW
+%{_bindir}/objfw-compile
+%{_bindir}/objfw-config
+%{_bindir}/objfw-new
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfwrt_pkgname}
+%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}
+%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}.%{libobjfwrt_minor}.0
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfwrt_pkgname}-devel
+%{_libdir}/libobjfwrt.so
+%{_includedir}/ObjFWRT/ObjFWRT.h
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfwtls_pkgname}
+%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}
+%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}.%{libobjfwtls_minor}.0
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n %{libobjfwtls_pkgname}-devel
+%{_libdir}/libobjfwtls.so
+%{_includedir}/ObjFWTLS/ObjFWTLS.h
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofarc
+%{_bindir}/ofarc
+%{_datadir}/ofarc/lang/de.json
+%{_datadir}/ofarc/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofdns
+%{_bindir}/ofdns
+%{_datadir}/ofdns/lang/de.json
+%{_datadir}/ofdns/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofhash
+%{_bindir}/ofhash
+%{_datadir}/ofhash/lang/de.json
+%{_datadir}/ofhash/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
+
+%files -n ofhttp
+%{_bindir}/ofhttp
+%{_datadir}/ofhttp/lang/de.json
+%{_datadir}/ofhttp/lang/languages.json
+%license LICENSE.QPL
+%license LICENSE.GPLv3
+%license LICENSE.GPLv2
Index: src/Makefile
==================================================================
--- src/Makefile
+++ src/Makefile
@@ -1,38 +1,26 @@
include ../extra.mk
-SUBDIRS = ${RUNTIME} exceptions ${ENCODINGS} forwarding invocation
-SUBDIRS_AFTER = ${BRIDGE}
+SUBDIRS = ${RUNTIME} exceptions encodings forwarding
+SUBDIRS_AFTER = ${BRIDGE} ${TLS}
DISTCLEAN = Info.plist objfw-defs.h
SHARED_LIB = ${OBJFW_SHARED_LIB}
STATIC_LIB = ${OBJFW_STATIC_LIB}
FRAMEWORK = ${OBJFW_FRAMEWORK}
LIB_MAJOR = ${OBJFW_LIB_MAJOR}
LIB_MINOR = ${OBJFW_LIB_MINOR}
-SRCS = OFASN1BitString.m \
- OFASN1Boolean.m \
- OFASN1Enumerated.m \
- OFASN1IA5String.m \
- OFASN1Integer.m \
- OFASN1NumericString.m \
- OFASN1ObjectIdentifier.m \
- OFASN1OctetString.m \
- OFASN1PrintableString.m \
- OFASN1UTF8String.m \
- OFASN1Value.m \
- OFApplication.m \
+SRCS = OFApplication.m \
OFArray.m \
OFBlock.m \
OFCharacterSet.m \
OFColor.m \
OFConstantString.m \
OFCountedSet.m \
OFData.m \
- OFData+ASN1DERParsing.m \
- OFData+CryptoHashing.m \
+ OFData+CryptographicHashing.m \
OFData+MessagePackParsing.m \
OFDate.m \
OFDictionary.m \
OFEnumerator.m \
OFFileManager.m \
@@ -43,12 +31,12 @@
OFInvocation.m \
OFLHAArchive.m \
OFLHAArchiveEntry.m \
OFList.m \
OFLocale.m \
- OFMapTable.m \
OFMD5Hash.m \
+ OFMapTable.m \
OFMessagePackExtension.m \
OFMethodSignature.m \
OFMutableArray.m \
OFMutableData.m \
OFMutableDictionary.m \
@@ -58,50 +46,56 @@
OFMutableString.m \
OFMutableTarArchiveEntry.m \
OFMutableTriple.m \
OFMutableURL.m \
OFMutableZIPArchiveEntry.m \
+ OFNotification.m \
+ OFNotificationCenter.m \
OFNull.m \
OFNumber.m \
OFObject.m \
OFObject+KeyValueCoding.m \
OFObject+Serialization.m \
+ OFOnce.m \
OFOptionsParser.m \
+ OFPBKDF2.m \
OFPair.m \
- ${OF_PROCESS_M} \
OFRIPEMD160Hash.m \
OFRunLoop.m \
- OFSandbox.m \
- OFSecureData.m \
- OFSeekableStream.m \
- OFSet.m \
OFSHA1Hash.m \
OFSHA224Hash.m \
OFSHA224Or256Hash.m \
OFSHA256Hash.m \
OFSHA384Hash.m \
OFSHA384Or512Hash.m \
OFSHA512Hash.m \
+ OFScrypt.m \
+ OFSecureData.m \
+ OFSeekableStream.m \
+ OFSerialization.m \
+ OFSet.m \
OFSortedList.m \
OFStdIOStream.m \
OFStream.m \
OFString.m \
- OFString+CryptoHashing.m \
+ OFString+CryptographicHashing.m \
OFString+JSONParsing.m \
OFString+PropertyListParsing.m \
OFString+Serialization.m \
OFString+URLEncoding.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
+ ${OF_SUBPROCESS_M} \
OFSystemInfo.m \
OFTarArchive.m \
OFTarArchiveEntry.m \
OFThread.m \
OFTimer.m \
OFTriple.m \
OFURL.m \
OFURLHandler.m \
+ OFUUID.m \
OFValue.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
@@ -108,23 +102,13 @@
OFXMLElement.m \
OFXMLElement+Serialization.m \
OFXMLElementBuilder.m \
OFXMLNode.m \
OFXMLParser.m \
- OFXMLProcessingInstructions.m \
+ OFXMLProcessingInstruction.m \
OFZIPArchive.m \
OFZIPArchiveEntry.m \
- base64.m \
- crc16.m \
- crc32.m \
- huffman_tree.m \
- of_asprintf.m \
- of_strptime.m \
- once.m \
- pbkdf2.m \
- scrypt.m \
- ${UNICODE_M} \
${USE_SRCS_FILES} \
${USE_SRCS_PLUGINS} \
${USE_SRCS_SOCKETS} \
${USE_SRCS_THREADS} \
${USE_SRCS_WINDOWS}
@@ -131,15 +115,11 @@
SRCS_FILES = OFFile.m \
OFINICategory.m \
OFINIFile.m \
OFSettings.m \
OFString+PathAdditions.m
-SRCS_IPX = OFIPXSocket.m \
- OFSPXSocket.m \
- OFSPXStreamSocket.m
SRCS_PLUGINS = OFPlugin.m
-SRCS_SCTP = OFSCTPSocket.m
SRCS_SOCKETS = OFDNSQuery.m \
OFDNSResolver.m \
OFDNSResourceRecord.m \
OFDNSResponse.m \
OFDatagramSocket.m \
@@ -148,58 +128,62 @@
OFHTTPCookieManager.m \
OFHTTPRequest.m \
OFHTTPResponse.m \
OFHTTPServer.m \
OFSequencedPacketSocket.m \
+ OFSocket.m \
OFStreamSocket.m \
OFTCPSocket.m \
+ OFTLSStream.m \
OFUDPSocket.m \
- socket.m \
${USE_SRCS_IPX} \
- ${USE_SRCS_SCTP}
+ ${USE_SRCS_UNIX_SOCKETS}
+SRCS_IPX = OFIPXSocket.m \
+ OFSPXSocket.m \
+ OFSPXStreamSocket.m
+SRCS_UNIX_SOCKETS = OFUNIXDatagramSocket.m \
+ OFUNIXStreamSocket.m
SRCS_THREADS = OFCondition.m \
OFMutex.m \
+ OFPlainCondition.m \
+ OFPlainMutex.m \
+ OFPlainThread.m \
OFRecursiveMutex.m \
- OFThreadPool.m \
- condition.m \
- mutex.m \
- thread.m \
- tlskey.m
+ OFTLSKey.m
SRCS_WINDOWS = OFWin32ConsoleStdIOStream.m \
OFWindowsRegistryKey.m
-INCLUDES_ATOMIC = atomic.h \
- atomic_builtins.h \
- atomic_no_threads.h \
- atomic_osatomic.h \
- atomic_powerpc.h \
- atomic_sync_builtins.h \
- atomic_x86.h
+INCLUDES_ATOMIC = OFAtomic.h \
+ platform/GCC4/OFAtomic.h \
+ platform/GCC4.7/OFAtomic.h \
+ platform/PowerPC/OFAtomic.h \
+ platform/macOS/OFAtomic.h \
+ platform/x86/OFAtomic.h
INCLUDES := ${SRCS:.m=.h} \
- OFASN1DERRepresentation.h \
OFCollection.h \
- OFCryptoHash.h \
+ OFCryptographicHash.h \
OFJSONRepresentation.h \
OFKernelEventObserver.h \
OFKeyValueCoding.h \
OFLocking.h \
OFMessagePackRepresentation.h \
- OFSerialization.h \
- OFTLSSocket.h \
ObjFW.h \
- block.h \
macros.h \
objfw-defs.h \
platform.h \
${USE_INCLUDES_ATOMIC}
-SRCS += OFAdjacentArray.m \
+SRCS += OFASPrintF.m \
+ OFAdjacentArray.m \
OFAdjacentSubarray.m \
+ OFBase64.m \
OFBitSetCharacterSet.m \
OFBytesValue.m \
+ OFCRC16.m \
+ OFCRC32.m \
OFCountedMapTableSet.m \
- OFDimensionValue.m \
+ OFHuffmanTree.m \
OFInvertedCharacterSet.m \
OFLHADecompressingStream.m \
OFMapTableDictionary.m \
OFMapTableSet.m \
OFMutableAdjacentArray.m \
@@ -209,39 +193,39 @@
OFNonretainedObjectValue.m \
OFPointValue.m \
OFPointerValue.m \
OFRangeCharacterSet.m \
OFRangeValue.m \
- OFRectangleValue.m \
+ OFRectValue.m \
+ OFSandbox.m \
+ OFSizeValue.m \
+ OFStrPTime.m \
OFSubarray.m \
OFUTF8String.m \
${LIBBASES_M} \
${RUNTIME_AUTORELEASE_M} \
- ${RUNTIME_INSTANCE_M}
+ ${RUNTIME_INSTANCE_M} \
+ ${UNICODE_M}
SRCS_FILES += OFFileURLHandler.m \
OFINIFileSettings.m
SRCS_SOCKETS += OFDNSResolverSettings.m \
+ ${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \
OFHTTPURLHandler.m \
OFHostAddressResolver.m \
OFIPSocketAsyncConnector.m \
OFKernelEventObserver.m \
- ${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \
${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \
${OF_POLL_KERNEL_EVENT_OBSERVER_M} \
${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \
OFTCPSocketSOCKS5Connector.m
-OBJS_EXTRA = ${RUNTIME_RUNTIME_A} \
- ${EXCEPTIONS_EXCEPTIONS_A} \
- ${ENCODINGS_ENCODINGS_A} \
- ${FORWARDING_FORWARDING_A} \
- ${INVOCATION_INVOCATION_A}
-LIB_OBJS_EXTRA = ${RUNTIME_RUNTIME_LIB_A} \
- ${EXCEPTIONS_EXCEPTIONS_LIB_A} \
- ${ENCODINGS_ENCODINGS_LIB_A} \
- ${FORWARDING_FORWARDING_LIB_A} \
- ${INVOCATION_INVOCATION_LIB_A}
+OBJS_EXTRA = exceptions/exceptions.a \
+ encodings/encodings.a \
+ forwarding/forwarding.a
+LIB_OBJS_EXTRA = exceptions/exceptions.lib.a \
+ encodings/encodings.lib.a \
+ forwarding/forwarding.lib.a
include ../buildsys.mk
CPPFLAGS += -I. -I.. -Iexceptions -Iruntime
LD = ${OBJC}
DELETED src/OFASN1BitString.h
Index: src/OFASN1BitString.h
==================================================================
--- src/OFASN1BitString.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1DERRepresentation.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFData;
-
-/**
- * @brief An ASN.1 BitString.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1BitString: OFObject
-{
- OFData *_bitStringValue;
- size_t _bitStringLength;
-}
-
-/**
- * @brief The BitString value.
- */
-@property (readonly, nonatomic) OFData *bitStringValue;
-
-/**
- * @brief The length of the BitString in bits.
- */
-@property (readonly, nonatomic) size_t bitStringLength;
-
-/**
- * @brief Creates an ASN.1 BitString with the specified BitString value and
- * length.
- *
- * @param bitStringValue The value of the BitString
- * @param bitStringLength The length of the BitString in bits
- * @return A new, autoreleased OFASN1BitString
- */
-+ (instancetype)bitStringWithBitStringValue: (OFData *)bitStringValue
- bitStringLength: (size_t)bitStringLength;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated ASN.1 BitString with the specified
- * BitString value and length.
- *
- * @param bitStringValue The value of the BitString
- * @param bitStringLength The length of the BitString in bits
- * @return An initialized OFASN1BitString
- */
-- (instancetype)initWithBitStringValue: (OFData *)bitStringValue
- bitStringLength: (size_t)bitStringLength
- OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 BitString with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1BitString
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1BitString.m
Index: src/OFASN1BitString.m
==================================================================
--- src/OFASN1BitString.m
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1BitString.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFInvalidFormatException.h"
-#import "OFOutOfRangeException.h"
-
-@implementation OFASN1BitString
-@synthesize bitStringValue = _bitStringValue;
-@synthesize bitStringLength = _bitStringLength;
-
-+ (instancetype)bitStringWithBitStringValue: (OFData *)bitStringValue
- bitStringLength: (size_t)bitStringLength
-{
- return [[[self alloc]
- initWithBitStringValue: bitStringValue
- bitStringLength: bitStringLength] autorelease];
-}
-
-- (instancetype)initWithBitStringValue: (OFData *)bitStringValue
- bitStringLength: (size_t)bitStringLength
-{
- self = [super init];
-
- @try {
- if (bitStringValue.count * bitStringValue.itemSize !=
- OF_ROUND_UP_POW2(8, bitStringLength) / 8)
- @throw [OFInvalidFormatException exception];
-
- _bitStringValue = [bitStringValue copy];
- _bitStringLength = bitStringLength;
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- void *pool = objc_autoreleasePoolPush();
- OFData *bitStringValue;
- size_t bitStringLength;
-
- @try {
- unsigned char unusedBits;
- size_t count = DEREncodedContents.count;
-
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_BIT_STRING || constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1 || count == 0)
- @throw [OFInvalidFormatException exception];
-
- unusedBits =
- *(unsigned char *)[DEREncodedContents itemAtIndex: 0];
-
- if (unusedBits > 7)
- @throw [OFInvalidFormatException exception];
-
- /*
- * Can't have any bits of the last byte unused if we have no
- * byte.
- */
- if (count == 1 && unusedBits != 0)
- @throw [OFInvalidFormatException exception];
-
- if (SIZE_MAX / 8 < count - 1)
- @throw [OFOutOfRangeException exception];
-
- bitStringLength = (count - 1) * 8;
- bitStringValue = [DEREncodedContents subdataWithRange:
- of_range(1, count - 1)];
-
- if (unusedBits != 0)
- bitStringLength -= unusedBits;
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- self = [self initWithBitStringValue: bitStringValue
- bitStringLength: bitStringLength];
-
- objc_autoreleasePoolPop(pool);
-
- return self;
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_bitStringValue release];
-
- [super dealloc];
-}
-
-- (OFData *)ASN1DERRepresentation
-{
- size_t bitStringValueCount = [_bitStringValue count];
- size_t roundedUpLength = OF_ROUND_UP_POW2(8, _bitStringLength);
- unsigned char unusedBits = roundedUpLength - _bitStringLength;
- unsigned char header[] = {
- OF_ASN1_TAG_NUMBER_BIT_STRING,
- bitStringValueCount + 1,
- unusedBits
- };
- OFMutableData *data;
-
- if (bitStringValueCount + 1 > UINT8_MAX ||
- bitStringValueCount != roundedUpLength / 8)
- @throw [OFInvalidFormatException exception];
-
- data = [OFMutableData
- dataWithCapacity: sizeof(header) + bitStringValueCount];
- [data addItems: header
- count: sizeof(header)];
- [data addItems: [_bitStringValue items]
- count: bitStringValueCount];
-
- [data makeImmutable];
-
- return data;
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1BitString *bitString;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1BitString class]])
- return false;
-
- bitString = object;
-
- if (![bitString->_bitStringValue isEqual: _bitStringValue])
- return false;
- if (bitString->_bitStringLength != _bitStringLength)
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _bitStringValue.hash + (unsigned long)_bitStringLength;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _bitStringValue, _bitStringLength];
-}
-@end
DELETED src/OFASN1Boolean.h
Index: src/OFASN1Boolean.h
==================================================================
--- src/OFASN1Boolean.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1DERRepresentation.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-/**
- * @brief An ASN.1 Boolean.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1Boolean: OFObject
-{
- bool _booleanValue;
-}
-
-/**
- * @brief The Boolean value.
- */
-@property (readonly, nonatomic) bool booleanValue;
-
-/**
- * @brief Creates an ASN.1 Boolean with the specified Boolean value.
- *
- * @param booleanValue The value of the Boolean
- * @return A new, autoreleased OFASN1Boolean
- */
-+ (instancetype)booleanWithBooleanValue: (bool)booleanValue;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated ASN.1 Boolean with the specified
- * Boolean value.
- *
- * @param booleanValue The value of the Boolean
- * @return An initialized OFASN1Boolean
- */
-- (instancetype)initWithBooleanValue: (bool)booleanValue
- OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 Boolean with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1Boolean
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1Boolean.m
Index: src/OFASN1Boolean.m
==================================================================
--- src/OFASN1Boolean.m
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1Boolean.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFInvalidFormatException.h"
-
-@implementation OFASN1Boolean
-@synthesize booleanValue = _booleanValue;
-
-+ (instancetype)booleanWithBooleanValue: (bool)booleanValue
-{
- return [[[self alloc] initWithBooleanValue: booleanValue] autorelease];
-}
-
-- (instancetype)initWithBooleanValue: (bool)booleanValue
-{
- self = [super init];
-
- _booleanValue = booleanValue;
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- unsigned char value;
-
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_BOOLEAN || constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1 ||
- DEREncodedContents.count != 1)
- @throw [OFInvalidFormatException exception];
-
- value = *(unsigned char *)[DEREncodedContents itemAtIndex: 0];
-
- if (value != 0 && value != 0xFF)
- @throw [OFInvalidFormatException exception];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return [self initWithBooleanValue: !!value];
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (OFData *)ASN1DERRepresentation
-{
- char buffer[] = {
- OF_ASN1_TAG_NUMBER_BOOLEAN,
- 1,
- (_booleanValue ? 0xFF : 0x00)
- };
-
- return [OFData dataWithItems: buffer
- count: sizeof(buffer)];
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1Boolean *boolean;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1Boolean class]])
- return false;
-
- boolean = object;
-
- if (boolean->_booleanValue != _booleanValue)
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _booleanValue;
-}
-
-- (OFString *)description
-{
- return (_booleanValue
- ? @""
- : @"");
-}
-@end
DELETED src/OFASN1DERRepresentation.h
Index: src/OFASN1DERRepresentation.h
==================================================================
--- src/OFASN1DERRepresentation.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFData;
-
-/**
- * @protocol OFASN1DERRepresentation \
- * OFASN1DERRepresentation.h ObjFW/OFASN1DERRepresentation.h
- *
- * @brief A protocol implemented by classes that support encoding to ASN.1 DER
- * representation.
- */
-@protocol OFASN1DERRepresentation
-/**
- * @brief The object in ASN.1 DER representation.
- */
-@property (readonly, nonatomic) OFData *ASN1DERRepresentation;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1Enumerated.h
Index: src/OFASN1Enumerated.h
==================================================================
--- src/OFASN1Enumerated.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-/**
- * @brief An ASN.1 Enumerated.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1Enumerated: OFObject
-{
- long long _longLongValue;
-}
-
-/**
- * @brief The integer value.
- */
-@property (readonly, nonatomic) long long longLongValue;
-
-/**
- * @brief Creates an ASN.1 Enumerated with the specified integer value.
- *
- * @param value The `long long` value of the Enumerated
- * @return A new, autoreleased OFASN1Enumerated
- */
-+ (instancetype)enumeratedWithLongLong: (long long)value;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated ASN.1 Enumerated with the specified
- * integer value.
- *
- * @param value The `long long` value of the Enumerated
- * @return An initialized OFASN1Enumerated
- */
-- (instancetype)initWithLongLong: (long long)value OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 Enumerated with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1Enumerated
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1Enumerated.m
Index: src/OFASN1Enumerated.m
==================================================================
--- src/OFASN1Enumerated.m
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1Enumerated.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-
-extern long long of_asn1_der_integer_parse(const unsigned char *buffer,
- size_t length);
-
-@implementation OFASN1Enumerated
-@synthesize longLongValue = _longLongValue;
-
-+ (instancetype)enumeratedWithLongLong: (long long)value
-{
- return [[[self alloc] initWithLongLong: value] autorelease];
-}
-
-- (instancetype)initWithLongLong: (long long)value
-{
- self = [super init];
-
- _longLongValue = value;
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- long long value;
-
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_ENUMERATED || constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidArgumentException exception];
-
- value = of_asn1_der_integer_parse(
- DEREncodedContents.items, DEREncodedContents.count);
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return [self initWithLongLong: value];
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1Enumerated *enumerated;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1Enumerated class]])
- return false;
-
- enumerated = object;
-
- if (enumerated->_longLongValue != _longLongValue)
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return (unsigned long)_longLongValue;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _longLongValue];
-}
-@end
DELETED src/OFASN1IA5String.h
Index: src/OFASN1IA5String.h
==================================================================
--- src/OFASN1IA5String.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFString;
-
-/**
- * @brief An ASN.1 IA5String.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1IA5String: OFObject
-{
- OFString *_IA5StringValue;
-}
-
-/**
- * @brief The IA5String value.
- */
-@property (readonly, nonatomic) OFString *IA5StringValue;
-
-/**
- * @brief The string value.
- */
-@property (readonly, nonatomic) OFString *stringValue;
-
-/**
- * @brief Creates an IA5String with the specified string value.
- *
- * @param stringValue The string value of the IA5String
- * @return A new, autoreleased OFASN1IA5String
- */
-+ (instancetype)stringWithStringValue: (OFString *)stringValue;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated IA5String with the specified string
- * value.
- *
- * @param stringValue The string value of the IA5String
- * @return An initialized OFASN1IA5String
- */
-- (instancetype)initWithStringValue: (OFString *)stringValue
- OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 IA5String with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1IA5String
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1IA5String.m
Index: src/OFASN1IA5String.m
==================================================================
--- src/OFASN1IA5String.m
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1IA5String.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-
-@implementation OFASN1IA5String
-@synthesize IA5StringValue = _IA5StringValue;
-
-+ (instancetype)stringWithStringValue: (OFString *)stringValue
-{
- return [[[self alloc] initWithStringValue: stringValue] autorelease];
-}
-
-- (instancetype)initWithStringValue: (OFString *)stringValue
-{
- self = [super init];
-
- @try {
- _IA5StringValue = [stringValue copy];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- void *pool = objc_autoreleasePoolPush();
- OFString *IA5StringValue;
-
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_IA5_STRING || constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidArgumentException exception];
-
- IA5StringValue = [OFString
- stringWithCString: DEREncodedContents.items
- encoding: OF_STRING_ENCODING_ASCII
- length: DEREncodedContents.count];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- self = [self initWithStringValue: IA5StringValue];
-
- objc_autoreleasePoolPop(pool);
-
- return self;
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_IA5StringValue release];
-
- [super dealloc];
-}
-
-- (OFString *)stringValue
-{
- return self.IA5StringValue;
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1IA5String *IA5String;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1IA5String class]])
- return false;
-
- IA5String = object;
-
- if (![IA5String->_IA5StringValue isEqual: _IA5StringValue])
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _IA5StringValue.hash;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _IA5StringValue];
-}
-@end
DELETED src/OFASN1Integer.h
Index: src/OFASN1Integer.h
==================================================================
--- src/OFASN1Integer.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-/**
- * @brief An ASN.1 Integer.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1Integer: OFObject
-{
- long long _longLongValue;
-}
-
-/**
- * @brief The Integer value.
- */
-@property (readonly, nonatomic) long long longLongValue;
-
-/**
- * @brief Creates an ASN.1 Integer with the specified integer value.
- *
- * @param value The `long long` value of the Integer
- * @return A new, autoreleased OFASN1Integer
- */
-+ (instancetype)integerWithLongLong: (long long)value;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated ASN.1 Integer with the specified
- * integer value.
- *
- * @param value The `long long` value of the Integer
- * @return An initialized OFASN1Integer
- */
-- (instancetype)initWithLongLong: (long long)value OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 Integer with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1Integer
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1Integer.m
Index: src/OFASN1Integer.m
==================================================================
--- src/OFASN1Integer.m
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1Integer.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFInvalidFormatException.h"
-#import "OFOutOfRangeException.h"
-
-long long
-of_asn1_der_integer_parse(const unsigned char *buffer, size_t length)
-{
- unsigned long long value = 0;
-
- /* TODO: Support for big numbers */
- if (length > sizeof(unsigned long long) &&
- (length != sizeof(unsigned long long) + 1 || buffer[0] != 0))
- @throw [OFOutOfRangeException exception];
-
- if (length >= 2 && ((buffer[0] == 0 && !(buffer[1] & 0x80)) ||
- (buffer[0] == 0xFF && buffer[1] & 0x80)))
- @throw [OFInvalidFormatException exception];
-
- if (length >= 1 && buffer[0] & 0x80)
- value = ~0ull;
-
- while (length--)
- value = (value << 8) | *buffer++;
-
- return value;
-}
-
-@implementation OFASN1Integer
-@synthesize longLongValue = _longLongValue;
-
-+ (instancetype)integerWithLongLong: (long long)value
-{
- return [[[self alloc] initWithLongLong: value] autorelease];
-}
-
-- (instancetype)initWithLongLong: (long long)value
-{
- self = [super init];
-
- _longLongValue = value;
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- long long value;
-
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_INTEGER || constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidArgumentException exception];
-
- value = of_asn1_der_integer_parse(
- DEREncodedContents.items, DEREncodedContents.count);
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return [self initWithLongLong: value];
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1Integer *integer;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1Integer class]])
- return false;
-
- integer = object;
-
- if (integer->_longLongValue != _longLongValue)
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return (unsigned long)_longLongValue;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _longLongValue];
-}
-@end
DELETED src/OFASN1NumericString.h
Index: src/OFASN1NumericString.h
==================================================================
--- src/OFASN1NumericString.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFString;
-
-/**
- * @brief An ASN.1 NumericString.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1NumericString: OFObject
-{
- OFString *_numericStringValue;
-}
-
-/**
- * @brief The NumericString value.
- */
-@property (readonly, nonatomic) OFString *numericStringValue;
-
-/**
- * @brief The string value.
- */
-@property (readonly, nonatomic) OFString *stringValue;
-
-/**
- * @brief Creates an NumericString with the specified string value.
- *
- * @param stringValue The string value of the NumericString
- * @return A new, autoreleased OFASN1NumericString
- */
-+ (instancetype)stringWithStringValue: (OFString *)stringValue;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated NumericString with the specified
- * string value.
- *
- * @param stringValue The string value of the NumericString
- * @return An initialized OFASN1NumericString
- */
-- (instancetype)initWithStringValue: (OFString *)stringValue
- OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 NumericString with the
- * specified arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized ASN.1 NumericString
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1NumericString.m
Index: src/OFASN1NumericString.m
==================================================================
--- src/OFASN1NumericString.m
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1NumericString.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFInvalidEncodingException.h"
-
-@implementation OFASN1NumericString
-@synthesize numericStringValue = _numericStringValue;
-
-+ (instancetype)stringWithStringValue: (OFString *)stringValue
-{
- return [[[self alloc] initWithStringValue: stringValue] autorelease];
-}
-
-- (instancetype)initWithStringValue: (OFString *)stringValue
-{
- self = [super init];
-
- @try {
- void *pool = objc_autoreleasePoolPush();
- const char *cString = stringValue.UTF8String;
- size_t length = stringValue.UTF8StringLength;
-
- for (size_t i = 0; i < length; i++)
- if (!of_ascii_isdigit(cString[i]) && cString[i] != ' ')
- @throw [OFInvalidEncodingException exception];
-
- _numericStringValue = [stringValue copy];
-
- objc_autoreleasePoolPop(pool);
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- void *pool = objc_autoreleasePoolPush();
- OFString *numericStringValue;
-
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_NUMERIC_STRING ||
- constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidArgumentException exception];
-
- numericStringValue = [OFString
- stringWithCString: DEREncodedContents.items
- encoding: OF_STRING_ENCODING_ASCII
- length: DEREncodedContents.count];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- self = [self initWithStringValue: numericStringValue];
-
- objc_autoreleasePoolPop(pool);
-
- return self;
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_numericStringValue release];
-
- [super dealloc];
-}
-
-- (OFString *)stringValue
-{
- return self.numericStringValue;
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1NumericString *numericString;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1NumericString class]])
- return false;
-
- numericString = object;
-
- if (![numericString->_numericStringValue isEqual: _numericStringValue])
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _numericStringValue.hash;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _numericStringValue];
-}
-@end
DELETED src/OFASN1ObjectIdentifier.h
Index: src/OFASN1ObjectIdentifier.h
==================================================================
--- src/OFASN1ObjectIdentifier.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFArray OF_GENERIC(ObjetType);
-@class OFNumber;
-
-/**
- * @brief An ASN.1 ObjectIdentifier.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1ObjectIdentifier: OFObject
-{
- OFArray OF_GENERIC(OFNumber *) *_subidentifiers;
-}
-
-/**
- * @brief The subidentifiers of the ObjectIdentifier.
- */
-@property (readonly, nonatomic) OFArray OF_GENERIC(OFNumber *) *subidentifiers;
-
-/**
- * @brief Creates an ASN.1 ObjectIdentifier with the specified subidentifiers.
- *
- * @param subidentifiers The subidentifiers of the ASN.1 ObjectIdentifier
- * @return A new, autoreleased OFASN1ObjectIdentifier
- */
-+ (instancetype)objectIdentifierWithSubidentifiers:
- (OFArray OF_GENERIC(OFNumber *) *)subidentifiers;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated ASN.1 ObjectIdentifier with the
- * specified subidentifiers.
- *
- * @param subidentifiers The subidentifiers of the ASN.1 ObjectIdentifier
- * @return An initialized OFASN1ObjectIdentifier
- */
-- (instancetype)initWithSubidentifiers:
- (OFArray OF_GENERIC(OFNumber *) *)subidentifiers OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 ObjectIdentifier with the
- * specified arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1ObjectIdentifier
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1ObjectIdentifier.m
Index: src/OFASN1ObjectIdentifier.m
==================================================================
--- src/OFASN1ObjectIdentifier.m
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1ObjectIdentifier.h"
-#import "OFArray.h"
-#import "OFData.h"
-#import "OFNumber.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFInvalidFormatException.h"
-#import "OFOutOfRangeException.h"
-
-@implementation OFASN1ObjectIdentifier
-@synthesize subidentifiers = _subidentifiers;
-
-+ (instancetype)objectIdentifierWithSubidentifiers:
- (OFArray OF_GENERIC(OFNumber *) *)subidentifiers
-{
- return [[[self alloc]
- initWithSubidentifiers: subidentifiers] autorelease];
-}
-
-- (instancetype)initWithSubidentifiers:
- (OFArray OF_GENERIC(OFNumber *) *)subidentifiers
-{
- self = [super init];
-
- @try {
- if (subidentifiers.count < 1)
- @throw [OFInvalidFormatException exception];
-
- switch ([[subidentifiers objectAtIndex: 0] longLongValue]) {
- case 0:
- case 1:
- case 2:
- break;
- default:
- @throw [OFInvalidFormatException exception];
- }
-
- _subidentifiers = [subidentifiers copy];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- void *pool = objc_autoreleasePoolPush();
- OFMutableArray OF_GENERIC(OFNumber *) *subidentifiers;
-
- @try {
- const unsigned char *items = DEREncodedContents.items;
- size_t count = DEREncodedContents.count;
- unsigned long long value = 0;
- uint_fast8_t bits = 0;
-
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER ||
- constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1 || count == 0)
- @throw [OFInvalidArgumentException exception];
-
- subidentifiers = [OFMutableArray array];
-
- for (size_t i = 0; i < count; i++) {
- if (bits == 0 && items[i] == 0x80)
- @throw [OFInvalidFormatException exception];
-
- value = (value << 7) | (items[i] & 0x7F);
- bits += 7;
-
- if (bits > sizeof(unsigned long long) * 8)
- @throw [OFOutOfRangeException exception];
-
- if (items[i] & 0x80)
- continue;
-
- if (subidentifiers.count == 0) {
- if (value < 40)
- [subidentifiers addObject:
- [OFNumber numberWithInt: 0]];
- else if (value < 80) {
- [subidentifiers addObject:
- [OFNumber numberWithInt: 1]];
- value -= 40;
- } else {
- [subidentifiers addObject:
- [OFNumber numberWithInt: 2]];
- value -= 80;
- }
- }
-
- [subidentifiers addObject:
- [OFNumber numberWithUnsignedLongLong: value]];
-
- value = 0;
- bits = 0;
- }
-
- if (items[count - 1] & 0x80)
- @throw [OFInvalidFormatException exception];
-
- [subidentifiers makeImmutable];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- self = [self initWithSubidentifiers: subidentifiers];
-
- objc_autoreleasePoolPop(pool);
-
- return self;
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_subidentifiers release];
-
- [super dealloc];
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1ObjectIdentifier *objectIdentifier;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1ObjectIdentifier class]])
- return false;
-
- objectIdentifier = object;
-
- if (![objectIdentifier->_subidentifiers isEqual: _subidentifiers])
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _subidentifiers.hash;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat:
- @"",
- [_subidentifiers componentsJoinedByString: @"."]];
-}
-@end
DELETED src/OFASN1OctetString.h
Index: src/OFASN1OctetString.h
==================================================================
--- src/OFASN1OctetString.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFData;
-
-/**
- * @brief An ASN.1 OctetString.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1OctetString: OFObject
-{
- OFData *_octetStringValue;
-}
-
-/**
- * @brief The OctetString value.
- */
-@property (readonly, nonatomic) OFData *octetStringValue;
-
-/**
- * @brief Creates an OctetString with the specified value.
- *
- * @param octetStringValue The OctetString value
- * @return A new, autoreleased OFASN1OctetString
- */
-+ (instancetype)octetStringWithOctetStringValue: (OFData *)octetStringValue;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated OctetString with the specified
- * value.
- *
- * @param octetStringValue The OctetString value
- * @return An initialized OFASN1OctetString
- */
-- (instancetype)initWithOctetStringValue: (OFData *)octetStringValue
- OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 OctetString with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized ASN.1 OctetString
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1OctetString.m
Index: src/OFASN1OctetString.m
==================================================================
--- src/OFASN1OctetString.m
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1OctetString.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-
-@implementation OFASN1OctetString
-@synthesize octetStringValue = _octetStringValue;
-
-+ (instancetype)octetStringWithOctetStringValue: (OFData *)octetStringValue
-{
- return [[[self alloc]
- initWithOctetStringValue: octetStringValue] autorelease];
-}
-
-- (instancetype)initWithOctetStringValue: (OFData *)octetStringValue
-{
- self = [super init];
-
- @try {
- _octetStringValue = [octetStringValue copy];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_OCTET_STRING ||
- constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidArgumentException exception];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return [self initWithOctetStringValue: DEREncodedContents];
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_octetStringValue release];
-
- [super dealloc];
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1OctetString *octetString;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1OctetString class]])
- return false;
-
- octetString = object;
-
- if (![octetString->_octetStringValue isEqual: _octetStringValue])
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _octetStringValue.hash;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _octetStringValue];
-}
-@end
DELETED src/OFASN1PrintableString.h
Index: src/OFASN1PrintableString.h
==================================================================
--- src/OFASN1PrintableString.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFString;
-
-/**
- * @brief An ASN.1 PrintableString.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1PrintableString: OFObject
-{
- OFString *_printableStringValue;
-}
-
-/**
- * @brief The PrintableString value.
- */
-@property (readonly, nonatomic) OFString *printableStringValue;
-
-/**
- * @brief The string value.
- */
-@property (readonly, nonatomic) OFString *stringValue;
-
-/**
- * @brief Creates a PrintableString with the specified string value.
- *
- * @param stringValue The string value of the PrintableString
- * @return A new, autoreleased OFASN1PrintableString
- */
-+ (instancetype)stringWithStringValue: (OFString *)stringValue;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated PrintableString with the specified
- * string value.
- *
- * @param stringValue The string value of the PrintableString
- * @return An initialized OFASN1PrintableString
- */
-- (instancetype)initWithStringValue: (OFString *)stringValue
- OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 PrintableString with the
- * specified arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1PrintableString
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1PrintableString.m
Index: src/OFASN1PrintableString.m
==================================================================
--- src/OFASN1PrintableString.m
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1PrintableString.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFInvalidEncodingException.h"
-
-@implementation OFASN1PrintableString
-@synthesize printableStringValue = _printableStringValue;
-
-+ (instancetype)stringWithStringValue: (OFString *)stringValue
-{
- return [[[self alloc] initWithStringValue: stringValue] autorelease];
-}
-
-- (instancetype)initWithStringValue: (OFString *)stringValue
-{
- self = [super init];
-
- @try {
- void *pool = objc_autoreleasePoolPush();
- const char *cString = stringValue.UTF8String;
- size_t length = stringValue.UTF8StringLength;
-
- for (size_t i = 0; i < length; i++) {
- if (of_ascii_isalnum(cString[i]))
- continue;
-
- switch (cString[i]) {
- case ' ':
- case '\'':
- case '(':
- case ')':
- case '+':
- case ',':
- case '-':
- case '.':
- case '/':
- case ':':
- case '=':
- case '?':
- continue;
- default:
- @throw [OFInvalidEncodingException exception];
- }
- }
-
- _printableStringValue = [stringValue copy];
-
- objc_autoreleasePoolPop(pool);
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- void *pool = objc_autoreleasePoolPush();
- OFString *printableStringValue;
-
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_PRINTABLE_STRING ||
- constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidArgumentException exception];
-
- printableStringValue = [OFString
- stringWithCString: DEREncodedContents.items
- encoding: OF_STRING_ENCODING_ASCII
- length: DEREncodedContents.count];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- self = [self initWithStringValue: printableStringValue];
-
- objc_autoreleasePoolPop(pool);
-
- return self;
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_printableStringValue release];
-
- [super dealloc];
-}
-
-- (OFString *)stringValue
-{
- return self.printableStringValue;
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1PrintableString *printableString;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1PrintableString class]])
- return false;
-
- printableString = object;
-
- if (![printableString->_printableStringValue isEqual:
- _printableStringValue])
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _printableStringValue.hash;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _printableStringValue];
-}
-@end
DELETED src/OFASN1UTF8String.h
Index: src/OFASN1UTF8String.h
==================================================================
--- src/OFASN1UTF8String.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-#import "OFASN1Value.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@class OFString;
-
-/**
- * @brief An ASN.1 UTF8String.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1UTF8String: OFObject
-{
- OFString *_UTF8StringValue;
-}
-
-/**
- * @brief The UTF8String value.
- */
-@property (readonly, nonatomic) OFString *UTF8StringValue;
-
-/**
- * @brief The string value.
- */
-@property (readonly, nonatomic) OFString *stringValue;
-
-/**
- * @brief Creates a UTF8String with the specified string value.
- *
- * @param stringValue The string value of the UTF8String
- * @return A new, autoreleased OFASN1UTF8String
- */
-+ (instancetype)stringWithStringValue: (OFString *)stringValue;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated UTF8String with the specified
- * string value.
- *
- * @param stringValue The string value of the UTF8String
- * @return An initialized OFASN1UTF8String
- */
-- (instancetype)initWithStringValue: (OFString *)stringValue
- OF_DESIGNATED_INITIALIZER;
-
-/**
- * @brief Initializes an already allocated ASN.1 UTF8String with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized OFASN1UTF8String
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1UTF8String.m
Index: src/OFASN1UTF8String.m
==================================================================
--- src/OFASN1UTF8String.m
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1UTF8String.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidArgumentException.h"
-
-@implementation OFASN1UTF8String
-@synthesize UTF8StringValue = _UTF8StringValue;
-
-+ (instancetype)stringWithStringValue: (OFString *)stringValue
-{
- return [[[self alloc] initWithStringValue: stringValue] autorelease];
-}
-
-- (instancetype)initWithStringValue: (OFString *)stringValue
-{
- self = [super init];
-
- @try {
- _UTF8StringValue = [stringValue copy];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- void *pool = objc_autoreleasePoolPush();
- OFString *UTF8StringValue;
-
- @try {
- if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
- tagNumber != OF_ASN1_TAG_NUMBER_UTF8_STRING || constructed)
- @throw [OFInvalidArgumentException exception];
-
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidArgumentException exception];
-
- UTF8StringValue = [OFString
- stringWithUTF8String: DEREncodedContents.items
- length: DEREncodedContents.count];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- self = [self initWithStringValue: UTF8StringValue];
-
- objc_autoreleasePoolPop(pool);
-
- return self;
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_UTF8StringValue release];
-
- [super dealloc];
-}
-
-- (OFString *)stringValue
-{
- return self.UTF8StringValue;
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1UTF8String *UTF8String;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1UTF8String class]])
- return false;
-
- UTF8String = object;
-
- if (![UTF8String->_UTF8StringValue isEqual: _UTF8StringValue])
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- return _UTF8StringValue.hash;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat: @"",
- _UTF8StringValue];
-}
-@end
DELETED src/OFASN1Value.h
Index: src/OFASN1Value.h
==================================================================
--- src/OFASN1Value.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-/** @file */
-
-@class OFData;
-
-/**
- * @brief ASN.1 tag class.
- */
-typedef enum {
- /** Universal */
- OF_ASN1_TAG_CLASS_UNIVERSAL = 0x0,
- /** Application */
- OF_ASN1_TAG_CLASS_APPLICATION = 0x1,
- /** Context specific */
- OF_ASN1_TAG_CLASS_CONTEXT_SPECIFIC = 0x2,
- /** Private */
- OF_ASN1_TAG_CLASS_PRIVATE = 0x3
-} of_asn1_tag_class_t;
-
-/**
- * @brief ASN.1 tag number.
- */
-typedef enum {
- /** Boolean */
- OF_ASN1_TAG_NUMBER_BOOLEAN = 0x01,
- /** Integer */
- OF_ASN1_TAG_NUMBER_INTEGER = 0x02,
- /** Bit string */
- OF_ASN1_TAG_NUMBER_BIT_STRING = 0x03,
- /** Octet string */
- OF_ASN1_TAG_NUMBER_OCTET_STRING = 0x04,
- /** Null */
- OF_ASN1_TAG_NUMBER_NULL = 0x05,
- /** Object Identifier */
- OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER = 0x06,
- /** Enumerated */
- OF_ASN1_TAG_NUMBER_ENUMERATED = 0x0A,
- /** UTF-8 string */
- OF_ASN1_TAG_NUMBER_UTF8_STRING = 0x0C,
- /** Sequence */
- OF_ASN1_TAG_NUMBER_SEQUENCE = 0x10,
- /** Set */
- OF_ASN1_TAG_NUMBER_SET = 0x11,
- /** NumericString */
- OF_ASN1_TAG_NUMBER_NUMERIC_STRING = 0x12,
- /** PrintableString */
- OF_ASN1_TAG_NUMBER_PRINTABLE_STRING = 0x13,
- /** IA5String */
- OF_ASN1_TAG_NUMBER_IA5_STRING = 0x16
-} of_asn1_tag_number_t;
-
-/**
- * @brief A class representing an ASN.1 value.
- */
-OF_SUBCLASSING_RESTRICTED
-@interface OFASN1Value: OFObject
-{
- of_asn1_tag_class_t _tagClass;
- of_asn1_tag_number_t _tagNumber;
- bool _constructed;
- OFData *_DEREncodedContents;
-}
-
-/**
- * @brief The tag class of the value's type.
- */
-@property (readonly, nonatomic) of_asn1_tag_class_t tagClass;
-
-/**
- * @brief The tag number of the value's type.
- */
-@property (readonly, nonatomic) of_asn1_tag_number_t tagNumber;
-
-/**
- * @brief Whether the value if of a constructed type.
- */
-@property (readonly, nonatomic, getter=isConstructed) bool constructed;
-
-/**
- * @brief The DER-encoded contents octets of the value.
- */
-@property (readonly, nonatomic) OFData *DEREncodedContents;
-
-/**
- * @brief Creates a new ASN.1 value with the specified arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return A new ASN.1 value
- */
-+ (instancetype)valueWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Initializes an already allocated ASN.1 value with the specified
- * arguments.
- *
- * @param tagClass The tag class of the value's type
- * @param tagNumber The tag number of the value's type
- * @param constructed Whether the value if of a constructed type
- * @param DEREncodedContents The DER-encoded contents octets of the value.
- * @return An initialized ASN.1 value
- */
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
- OF_DESIGNATED_INITIALIZER;
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFASN1Value.m
Index: src/OFASN1Value.m
==================================================================
--- src/OFASN1Value.m
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFASN1Value.h"
-#import "OFData.h"
-#import "OFString.h"
-
-#import "OFInvalidFormatException.h"
-
-@implementation OFASN1Value
-@synthesize tagClass = _tagClass, tagNumber = _tagNumber;
-@synthesize constructed = _constructed;
-@synthesize DEREncodedContents = _DEREncodedContents;
-
-+ (instancetype)valueWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- return [[[self alloc]
- initWithTagClass: tagClass
- tagNumber: tagNumber
- constructed: constructed
- DEREncodedContents: DEREncodedContents] autorelease];
-}
-
-- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
- tagNumber: (of_asn1_tag_number_t)tagNumber
- constructed: (bool)constructed
- DEREncodedContents: (OFData *)DEREncodedContents
-{
- self = [super init];
-
- @try {
- if (DEREncodedContents.itemSize != 1)
- @throw [OFInvalidFormatException exception];
-
- _tagClass = tagClass;
- _tagNumber = tagNumber;
- _constructed = constructed;
- _DEREncodedContents = [DEREncodedContents copy];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (instancetype)init
-{
- OF_INVALID_INIT_METHOD
-}
-
-- (void)dealloc
-{
- [_DEREncodedContents release];
-
- [super dealloc];
-}
-
-- (bool)isEqual: (id)object
-{
- OFASN1Value *value;
-
- if (object == self)
- return true;
-
- if (![object isKindOfClass: [OFASN1Value class]])
- return false;
-
- value = object;
-
- if (value->_tagClass != _tagClass)
- return false;
- if (value->_tagNumber != _tagNumber)
- return false;
- if (value->_constructed != _constructed)
- return false;
- if (![value->_DEREncodedContents isEqual: _DEREncodedContents])
- return false;
-
- return true;
-}
-
-- (unsigned long)hash
-{
- uint32_t hash;
-
- OF_HASH_INIT(hash);
-
- OF_HASH_ADD(hash, _tagClass & 0xFF);
- OF_HASH_ADD(hash, _tagNumber & 0xFF);
- OF_HASH_ADD(hash, _constructed);
- OF_HASH_ADD_HASH(hash, _DEREncodedContents.hash);
-
- OF_HASH_FINALIZE(hash);
-
- return hash;
-}
-
-- (OFString *)description
-{
- return [OFString stringWithFormat:
- @"",
- _tagClass, _tagNumber, _constructed,
- _DEREncodedContents.description];
-}
-@end
ADDED src/OFASPrintF.h
Index: src/OFASPrintF.h
==================================================================
--- /dev/null
+++ src/OFASPrintF.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
+
+#include
+
+#import "macros.h"
+
+OF_ASSUME_NONNULL_BEGIN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int OFVASPrintF(
+ char *_Nullable *_Nonnull, const char *_Nonnull, va_list);
+#ifdef __cplusplus
+}
+#endif
+
+OF_ASSUME_NONNULL_END
ADDED src/OFASPrintF.m
Index: src/OFASPrintF.m
==================================================================
--- /dev/null
+++ src/OFASPrintF.m
@@ -0,0 +1,783 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#ifdef HAVE_WCHAR_H
+# include
+#endif
+
+#ifdef HAVE_ASPRINTF_L
+# include
+#endif
+#ifdef HAVE_XLOCALE_H
+# include
+#endif
+
+#ifdef OF_HAVE_SYS_TYPES_H
+# include
+#endif
+
+#import "OFString.h"
+#import "OFLocale.h"
+
+#import "OFInitializationFailedException.h"
+
+#define maxSubformatLen 64
+
+#ifndef HAVE_ASPRINTF
+/*
+ * (v)asprintf might be declared, but HAVE_ASPRINTF not defined because
+ * configure determined it is broken. In this case, we must make sure there is
+ * no name clash.
+ */
+# define asprintf asprintf_
+# define vasprintf vasprintf_
+#endif
+
+struct Context {
+ const char *format;
+ size_t formatLen;
+ char subformat[maxSubformatLen + 1];
+ size_t subformatLen;
+ va_list arguments;
+ char *buffer;
+ size_t bufferLen;
+ size_t i, last;
+ enum {
+ stateString,
+ stateFormatFlags,
+ stateFormatFieldWidth,
+ stateFormatLengthModifier,
+ stateFormatConversionSpecifier
+ } state;
+ enum {
+ lengthModifierNone,
+ lengthModifierHH,
+ lengthModifierH,
+ lengthModifierL,
+ lengthModifierLL,
+ lengthModifierJ,
+ lengthModifierZ,
+ lengthModifierT,
+ lengthModifierCapitalL
+ } lengthModifier;
+ bool useLocale;
+};
+
+#ifdef HAVE_ASPRINTF_L
+static locale_t cLocale;
+
+OF_CONSTRUCTOR()
+{
+ if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL)
+ @throw [OFInitializationFailedException exception];
+}
+#endif
+
+#ifndef HAVE_ASPRINTF
+static int
+vasprintf(char **string, const char *format, va_list arguments)
+{
+ int length;
+ size_t bufferLength = 128;
+
+ *string = NULL;
+
+ for (;;) {
+ free(*string);
+
+ if ((*string = malloc(bufferLength)) == NULL)
+ return -1;
+
+ length = vsnprintf(*string, bufferLength - 1, format,
+ arguments);
+
+ if (length >= 0 && (size_t)length < bufferLength - 1)
+ break;
+
+ if (bufferLength > INT_MAX / 2) {
+ free(*string);
+ return -1;
+ }
+
+ bufferLength <<= 1;
+ }
+
+ if (length > 0 && (size_t)length != bufferLength - 1) {
+ char *resized = realloc(*string, length + 1);
+
+ /* Ignore if making it smaller failed. */
+ if (resized != NULL)
+ *string = resized;
+ }
+
+ return length;
+}
+
+static int
+asprintf(char **string, const char *format, ...)
+{
+ int ret;
+ va_list arguments;
+
+ va_start(arguments, format);
+ ret = vasprintf(string, format, arguments);
+ va_end(arguments);
+
+ return ret;
+}
+#endif
+
+static bool
+appendString(struct Context *ctx, const char *append, size_t appendLen)
+{
+ char *newBuf;
+
+ if (appendLen == 0)
+ return true;
+
+ if ((newBuf = realloc(ctx->buffer,
+ ctx->bufferLen + appendLen + 1)) == NULL)
+ return false;
+
+ memcpy(newBuf + ctx->bufferLen, append, appendLen);
+
+ ctx->buffer = newBuf;
+ ctx->bufferLen += appendLen;
+
+ return true;
+}
+
+static bool
+appendSubformat(struct Context *ctx, const char *subformat,
+ size_t subformatLen)
+{
+ if (ctx->subformatLen + subformatLen > maxSubformatLen)
+ return false;
+
+ memcpy(ctx->subformat + ctx->subformatLen, subformat, subformatLen);
+ ctx->subformatLen += subformatLen;
+ ctx->subformat[ctx->subformatLen] = 0;
+
+ return true;
+}
+
+static bool
+stringState(struct Context *ctx)
+{
+ if (ctx->format[ctx->i] == '%') {
+ if (ctx->i > 0)
+ if (!appendString(ctx, ctx->format + ctx->last,
+ ctx->i - ctx->last))
+ return false;
+
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+
+ ctx->last = ctx->i + 1;
+ ctx->state = stateFormatFlags;
+ }
+
+ return true;
+}
+
+static bool
+formatFlagsState(struct Context *ctx)
+{
+ switch (ctx->format[ctx->i]) {
+ case '-':
+ case '+':
+ case ' ':
+ case '#':
+ case '0':
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+
+ break;
+ case ',':
+ /* ObjFW extension: Use decimal point from locale */
+ ctx->useLocale = true;
+ break;
+ default:
+ ctx->state = stateFormatFieldWidth;
+ ctx->i--;
+
+ break;
+ }
+
+ return true;
+}
+
+static bool
+formatFieldWidthState(struct Context *ctx)
+{
+ if ((ctx->format[ctx->i] >= '0' && ctx->format[ctx->i] <= '9') ||
+ ctx->format[ctx->i] == '*' || ctx->format[ctx->i] == '.') {
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+ } else {
+ ctx->state = stateFormatLengthModifier;
+ ctx->i--;
+ }
+
+ return true;
+}
+
+static bool
+formatLengthModifierState(struct Context *ctx)
+{
+ /* Only one allowed */
+ switch (ctx->format[ctx->i]) {
+ case 'h': /* and also hh */
+ if (ctx->formatLen > ctx->i + 1 &&
+ ctx->format[ctx->i + 1] == 'h') {
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 2))
+ return false;
+
+ ctx->i++;
+ ctx->lengthModifier = lengthModifierHH;
+ } else {
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+
+ ctx->lengthModifier = lengthModifierH;
+ }
+
+ break;
+ case 'l': /* and also ll */
+ if (ctx->formatLen > ctx->i + 1 &&
+ ctx->format[ctx->i + 1] == 'l') {
+#ifndef OF_WINDOWS
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 2))
+ return false;
+#else
+ if (!appendSubformat(ctx, "I64", 3))
+ return false;
+#endif
+
+ ctx->i++;
+ ctx->lengthModifier = lengthModifierLL;
+ } else {
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+
+ ctx->lengthModifier = lengthModifierL;
+ }
+
+ break;
+ case 'j':
+#if defined(OF_WINDOWS)
+ if (!appendSubformat(ctx, "I64", 3))
+ return false;
+#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX)
+ if (!appendSubformat(ctx, "ll", 2))
+ return false;
+#else
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+#endif
+
+ ctx->lengthModifier = lengthModifierJ;
+
+ break;
+ case 'z':
+#if defined(OF_WINDOWS)
+ if (sizeof(size_t) == 8)
+ if (!appendSubformat(ctx, "I64", 3))
+ return false;
+#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX)
+ if (!appendSubformat(ctx, "l", 1))
+ return false;
+#else
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+#endif
+
+ ctx->lengthModifier = lengthModifierZ;
+
+ break;
+ case 't':
+#if defined(OF_WINDOWS)
+ if (sizeof(ptrdiff_t) == 8)
+ if (!appendSubformat(ctx, "I64", 3))
+ return false;
+#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX)
+ if (!appendSubformat(ctx, "l", 1))
+ return false;
+#else
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+#endif
+
+ ctx->lengthModifier = lengthModifierT;
+
+ break;
+ case 'L':
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+
+ ctx->lengthModifier = lengthModifierCapitalL;
+
+ break;
+#ifdef OF_WINDOWS
+ case 'I': /* win32 strangeness (I64 instead of ll or j) */
+ if (ctx->formatLen > ctx->i + 2 &&
+ ctx->format[ctx->i + 1] == '6' &&
+ ctx->format[ctx->i + 2] == '4') {
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 3))
+ return false;
+
+ ctx->i += 2;
+ ctx->lengthModifier = lengthModifierLL;
+ } else
+ ctx->i--;
+
+ break;
+#endif
+#ifdef OF_IOS
+ case 'q': /* iOS uses this for PRI?64 */
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+
+ ctx->lengthModifier = lengthModifierLL;
+
+ break;
+#endif
+ default:
+ ctx->i--;
+
+ break;
+ }
+
+ ctx->state = stateFormatConversionSpecifier;
+ return true;
+}
+
+static bool
+formatConversionSpecifierState(struct Context *ctx)
+{
+ char *tmp = NULL;
+ int tmpLen = 0;
+#ifndef HAVE_ASPRINTF_L
+ OFString *point;
+#endif
+
+ if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
+ return false;
+
+ switch (ctx->format[ctx->i]) {
+ case '@':
+ if (ctx->lengthModifier != lengthModifierNone)
+ return false;
+
+ ctx->subformat[ctx->subformatLen - 1] = 's';
+
+ @try {
+ id object;
+
+ if ((object = va_arg(ctx->arguments, id)) != nil) {
+ void *pool = objc_autoreleasePoolPush();
+
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ [object description].UTF8String);
+
+ objc_autoreleasePoolPop(pool);
+ } else
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ "(nil)");
+ } @catch (id e) {
+ free(ctx->buffer);
+ @throw e;
+ }
+
+ break;
+ case 'C':
+ if (ctx->lengthModifier != lengthModifierNone)
+ return false;
+
+ ctx->subformat[ctx->subformatLen - 1] = 's';
+
+ {
+ char buffer[5];
+ size_t len = OFUTF8StringEncode(
+ va_arg(ctx->arguments, OFUnichar), buffer);
+
+ if (len == 0)
+ return false;
+
+ buffer[len] = 0;
+ tmpLen = asprintf(&tmp, ctx->subformat, buffer);
+ }
+
+ break;
+ case 'S':
+ if (ctx->lengthModifier != lengthModifierNone)
+ return false;
+
+ ctx->subformat[ctx->subformatLen - 1] = 's';
+
+ {
+ const OFUnichar *arg =
+ va_arg(ctx->arguments, const OFUnichar *);
+ size_t j, len = OFUTF32StringLength(arg);
+ char *buffer;
+
+ if (SIZE_MAX / 4 < len || (SIZE_MAX / 4) - len < 1)
+ return false;
+
+ 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],
+ buffer + j);
+
+ if (clen == 0) {
+ free(buffer);
+ return false;
+ }
+
+ j += clen;
+ }
+ buffer[j] = 0;
+
+ tmpLen = asprintf(&tmp, ctx->subformat, buffer);
+
+ free(buffer);
+ }
+
+ break;
+ case 'd':
+ case 'i':
+ switch (ctx->lengthModifier) {
+ case lengthModifierNone:
+ case lengthModifierHH:
+ case lengthModifierH:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, int));
+ break;
+ case lengthModifierL:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, long));
+ break;
+ case lengthModifierLL:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, long long));
+ break;
+ case lengthModifierJ:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, intmax_t));
+ break;
+ case lengthModifierZ:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, ssize_t));
+ break;
+ case lengthModifierT:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, ptrdiff_t));
+ break;
+ default:
+ return false;
+ }
+
+ break;
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ switch (ctx->lengthModifier) {
+ case lengthModifierNone:
+ case lengthModifierHH:
+ case lengthModifierH:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, unsigned int));
+ break;
+ case lengthModifierL:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, unsigned long));
+ break;
+ case lengthModifierLL:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, unsigned long long));
+ break;
+ case lengthModifierJ:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, uintmax_t));
+ break;
+ case lengthModifierZ:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, size_t));
+ break;
+ case lengthModifierT:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, ptrdiff_t));
+ break;
+ default:
+ return false;
+ }
+
+ break;
+ case 'f':
+ case 'F':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ case 'a':
+ case 'A':
+ switch (ctx->lengthModifier) {
+ case lengthModifierNone:
+ case lengthModifierL:
+#ifdef HAVE_ASPRINTF_L
+ if (!ctx->useLocale)
+ tmpLen = asprintf_l(&tmp, cLocale,
+ ctx->subformat,
+ va_arg(ctx->arguments, double));
+ else
+#endif
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, double));
+ break;
+ case lengthModifierCapitalL:
+#ifdef HAVE_ASPRINTF_L
+ if (!ctx->useLocale)
+ tmpLen = asprintf_l(&tmp, cLocale,
+ ctx->subformat,
+ va_arg(ctx->arguments, long double));
+ else
+#endif
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, long double));
+ break;
+ default:
+ return false;
+ }
+
+#ifndef HAVE_ASPRINTF_L
+ if (tmpLen == -1)
+ return false;
+
+ /*
+ * If there's no asprintf_l, we have no other choice than to
+ * use this ugly hack to replace the locale's decimal point
+ * back to ".".
+ */
+ point = [OFLocale decimalPoint];
+
+ if (!ctx->useLocale && point != nil && ![point isEqual: @"."]) {
+ void *pool = objc_autoreleasePoolPush();
+ char *tmp2;
+
+ @try {
+ OFMutableString *tmpStr = [OFMutableString
+ stringWithUTF8String: tmp
+ length: tmpLen];
+ [tmpStr replaceOccurrencesOfString: point
+ withString: @"."];
+
+ if (tmpStr.UTF8StringLength > INT_MAX)
+ return false;
+
+ tmpLen = (int)tmpStr.UTF8StringLength;
+ tmp2 = malloc(tmpLen);
+ memcpy(tmp2, tmpStr.UTF8String, tmpLen);
+ } @finally {
+ free(tmp);
+ objc_autoreleasePoolPop(pool);
+ }
+
+ tmp = tmp2;
+ }
+#endif
+
+ break;
+ case 'c':
+ switch (ctx->lengthModifier) {
+ case lengthModifierNone:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, int));
+ break;
+ case lengthModifierL:
+#ifdef HAVE_WCHAR_H
+# if WINT_MAX >= INT_MAX
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, wint_t));
+# else
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, int));
+# endif
+ break;
+#endif
+ default:
+ return false;
+ }
+
+ break;
+ case 's':
+ switch (ctx->lengthModifier) {
+ case lengthModifierNone:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, const char *));
+ break;
+#ifdef HAVE_WCHAR_T
+ case lengthModifierL:
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, const wchar_t *));
+ break;
+#endif
+ default:
+ return false;
+ }
+
+ break;
+ case 'p':
+ if (ctx->lengthModifier != lengthModifierNone)
+ return false;
+
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, void *));
+
+ break;
+ case 'n':
+ switch (ctx->lengthModifier) {
+ case lengthModifierNone:
+ *va_arg(ctx->arguments, int *) = (int)ctx->bufferLen;
+ break;
+ case lengthModifierHH:
+ *va_arg(ctx->arguments, signed char *) =
+ (signed char)ctx->bufferLen;
+ break;
+ case lengthModifierH:
+ *va_arg(ctx->arguments, short *) =
+ (short)ctx->bufferLen;
+ break;
+ case lengthModifierL:
+ *va_arg(ctx->arguments, long *) =
+ (long)ctx->bufferLen;
+ break;
+ case lengthModifierLL:
+ *va_arg(ctx->arguments, long long *) =
+ (long long)ctx->bufferLen;
+ break;
+ case lengthModifierJ:
+ *va_arg(ctx->arguments, intmax_t *) =
+ (intmax_t)ctx->bufferLen;
+ break;
+ case lengthModifierZ:
+ *va_arg(ctx->arguments, size_t *) =
+ (size_t)ctx->bufferLen;
+ break;
+ case lengthModifierT:
+ *va_arg(ctx->arguments, ptrdiff_t *) =
+ (ptrdiff_t)ctx->bufferLen;
+ break;
+ default:
+ return false;
+ }
+
+ break;
+ case '%':
+ if (ctx->lengthModifier != lengthModifierNone)
+ return false;
+
+ if (!appendString(ctx, "%", 1))
+ return false;
+
+ break;
+ default:
+ return false;
+ }
+
+ if (tmpLen == -1)
+ return false;
+
+ if (tmp != NULL) {
+ if (!appendString(ctx, tmp, tmpLen)) {
+ free(tmp);
+ return false;
+ }
+
+ free(tmp);
+ }
+
+ memset(ctx->subformat, 0, maxSubformatLen);
+ ctx->subformatLen = 0;
+ ctx->lengthModifier = lengthModifierNone;
+ ctx->useLocale = false;
+
+ ctx->last = ctx->i + 1;
+ ctx->state = stateString;
+
+ return true;
+}
+
+static bool (*states[])(struct Context *) = {
+ stringState,
+ formatFlagsState,
+ formatFieldWidthState,
+ formatLengthModifierState,
+ formatConversionSpecifierState
+};
+
+int
+OFVASPrintF(char **string, const char *format, va_list arguments)
+{
+ struct Context ctx;
+
+ ctx.format = format;
+ ctx.formatLen = strlen(format);
+ memset(ctx.subformat, 0, maxSubformatLen + 1);
+ ctx.subformatLen = 0;
+ va_copy(ctx.arguments, arguments);
+ ctx.bufferLen = 0;
+ ctx.last = 0;
+ ctx.state = stateString;
+ ctx.lengthModifier = lengthModifierNone;
+ ctx.useLocale = false;
+
+ if ((ctx.buffer = malloc(1)) == NULL)
+ return -1;
+
+ for (ctx.i = 0; ctx.i < ctx.formatLen; ctx.i++) {
+ if (!states[ctx.state](&ctx)) {
+ free(ctx.buffer);
+ return -1;
+ }
+ }
+
+ if (ctx.state != stateString) {
+ free(ctx.buffer);
+ return -1;
+ }
+
+ if (!appendString(&ctx, ctx.format + ctx.last,
+ ctx.formatLen - ctx.last)) {
+ free(ctx.buffer);
+ return -1;
+ }
+
+ ctx.buffer[ctx.bufferLen] = 0;
+
+ *string = ctx.buffer;
+ return (ctx.bufferLen <= INT_MAX ? (int)ctx.bufferLen : -1);
+}
Index: src/OFAdjacentArray.h
==================================================================
--- src/OFAdjacentArray.h
+++ src/OFAdjacentArray.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFAdjacentArray.m
==================================================================
--- src/OFAdjacentArray.m
+++ src/OFAdjacentArray.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -61,12 +59,11 @@
}
return self;
}
-- (instancetype)initWithObject: (id)firstObject
- arguments: (va_list)arguments
+- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
@@ -109,12 +106,11 @@
@try {
for (size_t i = 0; i < count; i++)
[objects[i] retain];
- [_array addItems: objects
- count: count];
+ [_array addItems: objects count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
/* Prevent double-release of objects */
@@ -126,12 +122,11 @@
}
return self;
}
-- (instancetype)initWithObjects: (id const *)objects
- count: (size_t)count
+- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
self = [self init];
@try {
bool ok = true;
@@ -144,12 +139,11 @@
}
if (!ok)
@throw [OFInvalidArgumentException exception];
- [_array addItems: objects
- count: count];
+ [_array addItems: objects count: count];
} @catch (id e) {
for (size_t i = 0; i < count; i++)
[objects[i] release];
[self release];
@@ -166,15 +160,15 @@
@try {
void *pool = objc_autoreleasePoolPush();
if ((![element.name isEqual: @"OFArray"] &&
![element.name isEqual: @"OFMutableArray"]) ||
- ![element.namespace isEqual: OF_SERIALIZATION_NS])
+ ![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
- [element elementsForNamespace: OF_SERIALIZATION_NS]) {
+ [element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
id object;
object = child.objectByDeserializing;
[_array addItem: &object];
@@ -210,12 +204,11 @@
- (id)objectAtIndexedSubscript: (size_t)idx
{
return *((id *)[_array itemAtIndex: idx]);
}
-- (void)getObjects: (id *)buffer
- inRange: (of_range_t)range
+- (void)getObjects: (id *)buffer inRange: (OFRange)range
{
id const *objects = _array.items;
size_t count = _array.count;
if (range.length > SIZE_MAX - range.location ||
@@ -230,42 +223,42 @@
{
id const *objects;
size_t count;
if (object == nil)
- return OF_NOT_FOUND;
+ return OFNotFound;
objects = _array.items;
count = _array.count;
for (size_t i = 0; i < count; i++)
if ([objects[i] isEqual: object])
return i;
- return OF_NOT_FOUND;
+ return OFNotFound;
}
- (size_t)indexOfObjectIdenticalTo: (id)object
{
id const *objects;
size_t count;
if (object == nil)
- return OF_NOT_FOUND;
+ return OFNotFound;
objects = _array.items;
count = _array.count;
for (size_t i = 0; i < count; i++)
if (objects[i] == object)
return i;
- return OF_NOT_FOUND;
+ return OFNotFound;
}
-- (OFArray *)objectsInRange: (of_range_t)range
+- (OFArray *)objectsInRange: (OFRange)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _array.count)
@throw [OFOutOfRangeException exception];
@@ -272,12 +265,11 @@
if ([self isKindOfClass: [OFMutableArray class]])
return [OFArray
arrayWithObjects: (id *)_array.items + range.location
count: range.length];
- return [OFAdjacentSubarray arrayWithArray: self
- range: range];
+ return [OFAdjacentSubarray arrayWithArray: self range: range];
}
- (bool)isEqual: (id)object
{
OFArray *otherArray;
@@ -310,23 +302,23 @@
- (unsigned long)hash
{
id const *objects = _array.items;
size_t count = _array.count;
- uint32_t hash;
+ unsigned long hash;
- OF_HASH_INIT(hash);
+ OFHashInit(&hash);
for (size_t i = 0; i < count; i++)
- OF_HASH_ADD_HASH(hash, [objects[i] hash]);
+ OFHashAddHash(&hash, [objects[i] hash]);
- OF_HASH_FINALIZE(hash);
+ OFHashFinalize(&hash);
return hash;
}
-- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state
+- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count_
{
size_t count = _array.count;
@@ -348,11 +340,11 @@
return (int)count;
}
#ifdef OF_HAVE_BLOCKS
-- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
+- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block
{
id const *objects = _array.items;
size_t count = _array.count;
bool stop = false;
Index: src/OFAdjacentSubarray.h
==================================================================
--- src/OFAdjacentSubarray.h
+++ src/OFAdjacentSubarray.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFAdjacentSubarray.m
==================================================================
--- src/OFAdjacentSubarray.m
+++ src/OFAdjacentSubarray.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -53,15 +51,15 @@
return true;
}
#ifdef OF_HAVE_BLOCKS
-- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
+- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block
{
id const *objects = self.objects;
bool stop = false;
for (size_t i = 0; i < _range.length && !stop; i++)
block(objects[i], i, &stop);
}
#endif
@end
Index: src/OFApplication.h
==================================================================
--- src/OFApplication.h
+++ src/OFApplication.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -16,10 +14,11 @@
*/
#include
#import "OFObject.h"
+#import "OFNotification.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
@@ -28,10 +27,15 @@
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
@class OFSandbox;
@class OFString;
+/**
+ * @brief A notification that will be sent when the application will terminate.
+ */
+extern const OFNotificationName OFApplicationWillTerminateNotification;
+
/**
* @brief Specify the class to be used as the application delegate.
*
* An instance of this class will be created and act as the application
* delegate.
@@ -52,16 +56,16 @@
* [OFApplication terminate];
* }
* @end
* @endcode
*/
-#define OF_APPLICATION_DELEGATE(class_) \
- int \
- main(int argc, char *argv[]) \
- { \
- return of_application_main(&argc, &argv, \
- (class_ *)[[class_ alloc] init]); \
+#define OF_APPLICATION_DELEGATE(class_) \
+ int \
+ main(int argc, char *argv[]) \
+ { \
+ return OFApplicationMain(&argc, &argv, \
+ (class_ *)[[class_ alloc] init]); \
}
#ifdef OF_HAVE_PLEDGE
# define OF_HAVE_SANDBOX
#endif
@@ -145,10 +149,14 @@
* @brief A class which represents the application as an object.
*
* In order to create a new OFApplication, you should create a class conforming
* to the optional @ref OFApplicationDelegate protocol and put
* `OF_APPLICATION_DELEGATE(NameOfYourClass)` in the .m file of that class.
+ *
+ * When the application is about to be terminated,
+ * @ref OFApplicationDelegate#applicationWillTerminate will be called on the
+ * delegate and an @ref OFApplicationWillTerminateNotification will be sent.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFApplication: OFObject
{
OFString *_programName;
@@ -200,18 +208,11 @@
*/
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
id delegate;
#ifdef OF_HAVE_SANDBOX
-/**
- * @brief The sandbox currently active for this application.
- */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFSandbox *activeSandbox;
-
-/**
- * @brief The sandbox currently active for child processes of this application.
- */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
OFSandbox *activeSandboxForChildProcesses;
#endif
/**
@@ -253,41 +254,12 @@
* @param status The status with which the application will terminate
*/
+ (void)terminateWithStatus: (int)status OF_NO_RETURN;
#ifdef OF_HAVE_SANDBOX
-/**
- * @brief Activates the specified sandbox for the application.
- *
- * This is only available if `OF_HAVE_SANDBOX` is defined.
- *
- * @warning If you allow `exec()`, but do not call
- * @ref activateSandboxForChildProcesses:, an `exec()`'d process does
- * not have its permissions restricted!
- *
- * @note Once a sandbox has been activated, you cannot activate a different
- * sandbox. You can however change the active sandbox and reactivate it.
- *
- * @param sandbox The sandbox to activate
- */
-+ (void)activateSandbox: (OFSandbox *)sandbox;
-
-/**
- * @brief Activates the specified sandbox for child processes of the
- * application.
- *
- * This is only available if `OF_HAVE_SANDBOX` is defined.
- *
- * `unveiledPaths` on the sandbox must *not* be empty, otherwise an
- * @ref OFInvalidArgumentException is raised.
- *
- * @note Once a sandbox has been activated, you cannot activate a different
- * sandbox. You can however change the active sandbox and reactivate it.
- *
- * @param sandbox The sandbox to activate
- */
-+ (void)activateSandboxForChildProcesses: (OFSandbox *)sandbox;
++ (void)of_activateSandbox: (OFSandbox *)sandbox;
++ (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox;
#endif
- (instancetype)init OF_UNAVAILABLE;
/**
@@ -310,49 +282,20 @@
* @param status The status with which the application will terminate
*/
- (void)terminateWithStatus: (int)status OF_NO_RETURN;
#ifdef OF_HAVE_SANDBOX
-/**
- * @brief Activates the specified sandbox for the application.
- *
- * This is only available if `OF_HAVE_SANDBOX` is defined.
- *
- * @warning If you allow `exec()`, but do not call
- * @ref activateSandboxForChildProcesses:, an `exec()`'d process does
- * not have its permissions restricted!
- *
- * @note Once a sandbox has been activated, you cannot activate a different
- * sandbox. You can however change the active sandbox and reactivate it.
- *
- * @param sandbox The sandbox to activate
- */
-- (void)activateSandbox: (OFSandbox *)sandbox;
-
-/**
- * @brief Activates the specified sandbox for child processes of the
- * application.
- *
- * This is only available if `OF_HAVE_SANDBOX` is defined.
- *
- * `unveiledPaths` on the sandbox must *not* be empty, otherwise an
- * @ref OFInvalidArgumentException is raised.
- *
- * @note Once a sandbox has been activated, you cannot activate a different
- * sandbox. You can however change the active sandbox and reactivate it.
- *
- * @param sandbox The sandbox to activate
- */
-- (void)activateSandboxForChildProcesses: (OFSandbox *)sandbox;
+- (void)of_activateSandbox: (OFSandbox *)sandbox;
+- (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox;
#endif
@end
#ifdef __cplusplus
extern "C" {
#endif
-extern int of_application_main(int *_Nonnull,
- char *_Nullable *_Nonnull[_Nonnull], id );
+extern int OFApplicationMain(int *_Nonnull, char *_Nullable *_Nonnull[_Nonnull],
+ id );
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
Index: src/OFApplication.m
==================================================================
--- src/OFApplication.m
+++ src/OFApplication.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -32,10 +30,11 @@
#ifdef OF_AMIGAOS
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFLocale.h"
+#import "OFNotificationCenter.h"
#import "OFPair.h"
#import "OFRunLoop+Private.h"
#import "OFRunLoop.h"
#import "OFSandbox.h"
#import "OFString.h"
@@ -73,39 +72,46 @@
#endif
OF_DIRECT_MEMBERS
@interface OFApplication ()
- (instancetype)of_init OF_METHOD_FAMILY(init);
+- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv;
+#ifdef OF_WINDOWS
- (void)of_setArgumentCount: (int *)argc
- andArgumentValues: (char **[])argv;
-#ifdef OF_WINDOWS
-- (void)of_setArgumentCount: (int)argc
- andWideArgumentValues: (wchar_t *[])argv;
+ andArgumentValues: (char **[])argv
+ andWideArgumentCount: (int)wargc
+ andWideArgumentValues: (wchar_t *[])wargv;
#endif
- (void)of_run;
@end
+const OFNotificationName OFApplicationWillTerminateNotification =
+ @"OFApplicationWillTerminateNotification";
static OFApplication *app = nil;
static void
atexitHandler(void)
{
id delegate = app.delegate;
+
+ [[OFNotificationCenter defaultCenter]
+ postNotificationName: OFApplicationWillTerminateNotification
+ object: app];
if ([delegate respondsToSelector: @selector(applicationWillTerminate)])
[delegate applicationWillTerminate];
[delegate release];
-#if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && defined(OF_AMIGAOS)
- of_socket_deinit();
+#if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \
+ defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
+ OFSocketDeinit();
#endif
}
int
-of_application_main(int *argc, char **argv[],
- id delegate)
+OFApplicationMain(int *argc, char **argv[], id delegate)
{
#ifdef OF_WINDOWS
wchar_t **wargv, **wenvp;
int wargc, si = 0;
#endif
@@ -115,16 +121,17 @@
app = [[OFApplication alloc] of_init];
#ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT]) {
__wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si);
- [app of_setArgumentCount: wargc
+ [app of_setArgumentCount: argc
+ andArgumentValues: argv
+ andWideArgumentCount: wargc
andWideArgumentValues: wargv];
} else
#endif
- [app of_setArgumentCount: argc
- andArgumentValues: argv];
+ [app of_setArgumentCount: argc andArgumentValues: argv];
app.delegate = delegate;
[app of_run];
@@ -199,18 +206,18 @@
OF_UNREACHABLE
#endif
}
#ifdef OF_HAVE_SANDBOX
-+ (void)activateSandbox: (OFSandbox *)sandbox
++ (void)of_activateSandbox: (OFSandbox *)sandbox
{
- [app activateSandbox: sandbox];
+ [app of_activateSandbox: sandbox];
}
-+ (void)activateSandboxForChildProcesses: (OFSandbox *)sandbox
++ (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox
{
- [app activateSandboxForChildProcesses: sandbox];
+ [app of_activateSandboxForChildProcesses: sandbox];
}
#endif
- (instancetype)init
{
@@ -226,19 +233,19 @@
atexit(atexitHandler);
#if defined(OF_WINDOWS)
if ([OFSystemInfo isWindowsNT]) {
- of_char16_t *env, *env0;
+ OFChar16 *env, *env0;
env = env0 = GetEnvironmentStringsW();
while (*env != 0) {
void *pool = objc_autoreleasePoolPush();
OFString *tmp, *key, *value;
size_t length, pos;
- length = of_string_utf16_length(env);
+ length = OFUTF16StringLength(env);
tmp = [OFString stringWithUTF16String: env
length: length];
env += length + 1;
/*
@@ -250,22 +257,20 @@
objc_autoreleasePoolPop(pool);
continue;
}
pos = [tmp rangeOfString: @"="].location;
- if (pos == OF_NOT_FOUND) {
+ if (pos == OFNotFound) {
fprintf(stderr,
"Warning: Invalid environment "
"variable: %s\n", tmp.UTF8String);
continue;
}
key = [tmp substringToIndex: pos];
- value = [tmp substringFromRange: pos + 1];
-
- [_environment setObject: value
- forKey: key];
+ value = [tmp substringFromIndex: pos + 1];
+ [_environment setObject: value forKey: key];
objc_autoreleasePoolPop(pool);
}
FreeEnvironmentStringsW(env0);
@@ -294,22 +299,20 @@
objc_autoreleasePoolPop(pool);
continue;
}
pos = [tmp rangeOfString: @"="].location;
- if (pos == OF_NOT_FOUND) {
+ if (pos == OFNotFound) {
fprintf(stderr,
"Warning: Invalid environment "
"variable: %s\n", tmp.UTF8String);
continue;
}
key = [tmp substringToIndex: pos];
value = [tmp substringFromIndex: pos + 1];
-
- [_environment setObject: value
- forKey: key];
+ [_environment setObject: value forKey: key];
objc_autoreleasePoolPop(pool);
}
FreeEnvironmentStringsA(env0);
@@ -317,11 +320,11 @@
#elif defined(OF_AMIGAOS)
void *pool = objc_autoreleasePoolPush();
OFFileManager *fileManager = [OFFileManager defaultManager];
OFArray *envContents =
[fileManager contentsOfDirectoryAtPath: @"ENV:"];
- const of_string_encoding_t encoding = [OFLocale encoding];
+ OFStringEncoding encoding = [OFLocale encoding];
struct Process *proc;
struct LocalVar *firstLocalVar;
for (OFString *name in envContents) {
void *pool2 = objc_autoreleasePoolPush();
@@ -334,17 +337,15 @@
path = [@"ENV:" stringByAppendingString: name];
if ([fileManager directoryExistsAtPath: path])
continue;
- file = [OFFile fileWithPath: path
- mode: @"r"];
+ file = [OFFile fileWithPath: path mode: @"r"];
value = [file readLineWithEncoding: encoding];
if (value != nil)
- [_environment setObject: value
- forKey: name];
+ [_environment setObject: value forKey: name];
objc_autoreleasePoolPop(pool2);
}
/* Local variables override global variables */
@@ -373,13 +374,11 @@
encoding: encoding];
value = [OFString
stringWithCString: (const char *)iter->lv_Value
encoding: encoding
length: length];
-
- [_environment setObject: value
- forKey: key];
+ [_environment setObject: value forKey: key];
}
objc_autoreleasePoolPop(pool);
#elif !defined(OF_IOS)
# ifndef OF_MACOS
@@ -387,12 +386,11 @@
# else
char **env = *_NSGetEnviron();
# endif
if (env != NULL) {
- const of_string_encoding_t encoding =
- [OFLocale encoding];
+ OFStringEncoding encoding = [OFLocale encoding];
for (; *env != NULL; env++) {
void *pool = objc_autoreleasePoolPush();
OFString *key, *value;
char *sep;
@@ -408,13 +406,11 @@
encoding: encoding
length: sep - *env];
value = [OFString
stringWithCString: sep + 1
encoding: encoding];
-
- [_environment setObject: value
- forKey: key];
+ [_environment setObject: value forKey: key];
objc_autoreleasePoolPop(pool);
}
}
#else
@@ -430,40 +426,35 @@
if ((env = getenv("HOME")) != NULL) {
OFString *home = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
- [_environment setObject: home
- forKey: @"HOME"];
+ [_environment setObject: home forKey: @"HOME"];
}
if ((env = getenv("PATH")) != NULL) {
OFString *path = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
- [_environment setObject: path
- forKey: @"PATH"];
+ [_environment setObject: path forKey: @"PATH"];
}
if ((env = getenv("SHELL")) != NULL) {
OFString *shell = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
- [_environment setObject: shell
- forKey: @"SHELL"];
+ [_environment setObject: shell forKey: @"SHELL"];
}
if ((env = getenv("TMPDIR")) != NULL) {
OFString *tmpdir = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
- [_environment setObject: tmpdir
- forKey: @"TMPDIR"];
+ [_environment setObject: tmpdir forKey: @"TMPDIR"];
}
if ((env = getenv("USER")) != NULL) {
OFString *user = [[[OFString alloc]
initWithUTF8StringNoCopy: env
freeWhenDone: false] autorelease];
- [_environment setObject: user
- forKey: @"USER"];
+ [_environment setObject: user forKey: @"USER"];
}
objc_autoreleasePoolPop(pool);
#endif
@@ -482,16 +473,15 @@
[_environment release];
[super dealloc];
}
-- (void)of_setArgumentCount: (int *)argc
- andArgumentValues: (char ***)argv
+- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
- of_string_encoding_t encoding;
+ OFStringEncoding encoding;
_argc = argc;
_argv = argv;
encoding = [OFLocale encoding];
@@ -516,34 +506,38 @@
objc_autoreleasePoolPop(pool);
}
#ifdef OF_WINDOWS
-- (void)of_setArgumentCount: (int)argc
- andWideArgumentValues: (wchar_t **)argv
+- (void)of_setArgumentCount: (int *)argc
+ andArgumentValues: (char **[])argv
+ andWideArgumentCount: (int)wargc
+ andWideArgumentValues: (wchar_t *[])wargv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
- if (argc > 0) {
- _programName = [[OFString alloc] initWithUTF16String: argv[0]];
+ _argc = argc;
+ _argv = argv;
+
+ if (wargc > 0) {
+ _programName = [[OFString alloc] initWithUTF16String: wargv[0]];
arguments = [[OFMutableArray alloc] init];
- for (int i = 1; i < argc; i++)
+ for (int i = 1; i < wargc; i++)
[arguments addObject:
- [OFString stringWithUTF16String: argv[i]]];
+ [OFString stringWithUTF16String: wargv[i]]];
[arguments makeImmutable];
_arguments = arguments;
}
objc_autoreleasePoolPop(pool);
}
#endif
-- (void)getArgumentCount: (int **)argc
- andArgumentValues: (char ****)argv
+- (void)getArgumentCount: (int **)argc andArgumentValues: (char ****)argv
{
*argc = _argc;
*argv = _argv;
}
@@ -624,16 +618,16 @@
OF_UNREACHABLE
}
#ifdef OF_HAVE_SANDBOX
-- (void)activateSandbox: (OFSandbox *)sandbox
+- (void)of_activateSandbox: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
void *pool = objc_autoreleasePoolPush();
- of_string_encoding_t encoding = [OFLocale encoding];
- OFArray OF_GENERIC(of_sandbox_unveil_path_t) *unveiledPaths;
+ OFStringEncoding encoding = [OFLocale encoding];
+ OFArray OF_GENERIC(OFSandboxUnveilPath) *unveiledPaths;
size_t unveiledPathsCount;
const char *promises;
if (_activeSandbox != nil && sandbox != _activeSandbox)
@throw [OFInvalidArgumentException exception];
@@ -641,11 +635,11 @@
unveiledPaths = sandbox.unveiledPaths;
unveiledPathsCount = unveiledPaths.count;
for (size_t i = sandbox->_unveiledPathsIndex;
i < unveiledPathsCount; i++) {
- of_sandbox_unveil_path_t unveiledPath =
+ OFSandboxUnveilPath unveiledPath =
[unveiledPaths objectAtIndex: i];
OFString *path = unveiledPath.firstObject;
OFString *permissions = unveiledPath.secondObject;
if (path == nil || permissions == nil)
@@ -669,11 +663,11 @@
if (_activeSandbox == nil)
_activeSandbox = [sandbox retain];
# endif
}
-- (void)activateSandboxForChildProcesses: (OFSandbox *)sandbox
+- (void)of_activateSandboxForChildProcesses: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
void *pool = objc_autoreleasePoolPush();
const char *promises;
Index: src/OFArray+Private.h
==================================================================
--- src/OFArray+Private.h
+++ src/OFArray+Private.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFArray.h
==================================================================
--- src/OFArray.h
+++ src/OFArray.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -35,14 +33,29 @@
/** @file */
@class OFString;
-enum {
- OF_ARRAY_SKIP_EMPTY = 1,
- OF_ARRAY_SORT_DESCENDING = 2
-};
+/**
+ * @brief Options for joining the objects of an array.
+ *
+ * This is a bit mask.
+ */
+typedef enum {
+ /** Skip empty components */
+ OFArraySkipEmptyComponents = 1
+} OFArrayJoinOptions;
+
+/**
+ * @brief Options for sorting an array.
+ *
+ * This is a bit mask.
+ */
+typedef enum {
+ /** Sort the array descending */
+ OFArraySortDescending = 1
+} OFArraySortOptions;
#ifdef OF_HAVE_BLOCKS
/**
* @brief A block for enumerating an OFArray.
*
@@ -49,39 +62,38 @@
* @param object The current object
* @param index The index of the current object
* @param stop A pointer to a variable that can be set to true to stop the
* enumeration
*/
-typedef void (^of_array_enumeration_block_t)(id object, size_t index,
- bool *stop);
+typedef void (^OFArrayEnumerationBlock)(id object, size_t index, bool *stop);
/**
* @brief A block for filtering an OFArray.
*
* @param object The object to inspect
* @param index The index of the object to inspect
* @return Whether the object should be in the filtered array
*/
-typedef bool (^of_array_filter_block_t)(id object, size_t index);
+typedef bool (^OFArrayFilterBlock)(id object, size_t index);
/**
* @brief A block for mapping objects to objects in an OFArray.
*
* @param object The object to map
* @param index The index of the object to map
* @return The object to map to
*/
-typedef id _Nonnull (^of_array_map_block_t)(id object, size_t index);
+typedef id _Nonnull (^OFArrayMapBlock)(id object, size_t index);
/**
* @brief A block for folding an OFArray.
*
* @param left The object to which the object has been folded so far
* @param right The object that should be added to the left object
* @return The left and right side folded into one object
*/
-typedef id _Nullable (^of_array_fold_block_t)(id _Nullable left, id right);
+typedef id _Nullable (^OFArrayFoldBlock)(id _Nullable left, id right);
#endif
/**
* @class OFArray OFArray.h ObjFW/OFArray.h
*
@@ -168,13 +180,12 @@
*
* @param objects A C array of objects
* @param count The length of the C array
* @return A new autoreleased OFArray
*/
-+ (instancetype)
- arrayWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
- count: (size_t)count;
++ (instancetype)arrayWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
+ count: (size_t)count;
/**
* @brief Initializes an OFArray with the specified object.
*
* @param object An object
@@ -217,10 +228,17 @@
* @return An initialized OFArray
*/
- (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
count: (size_t)count;
+/**
+ * @brief Returns an OFEnumerator to enumerate through all objects of the array.
+ *
+ * @return An OFEnumerator to enumerate through all objects of the array
+ */
+- (OFEnumerator OF_GENERIC(ObjectType) *)objectEnumerator;
+
/**
* @brief Returns the object at the specified index in the array.
*
* @warning The returned object is *not* retained and autoreleased for
* performance reasons!
@@ -254,39 +272,38 @@
* @note A @ref OFNull value is translated to nil!
*
* @param value The value for the specified key
* @param key The key of the value to set
*/
-- (void)setValue: (nullable id)value
- forKey: (OFString *)key;
+- (void)setValue: (nullable id)value forKey: (OFString *)key;
/**
* @brief Copies the objects at the specified range to the specified buffer.
*
* @param buffer The buffer to copy the objects to
* @param range The range to copy
*/
- (void)getObjects: (ObjectType __unsafe_unretained _Nonnull *_Nonnull)buffer
- inRange: (of_range_t)range;
+ inRange: (OFRange)range;
/**
* @brief Returns the index of the first object that is equivalent to the
- * specified object or `OF_NOT_FOUND` if it was not found.
+ * specified object or `OFNotFound` if it was not found.
*
* @param object The object whose index is returned
* @return The index of the first object equivalent to the specified object
- * or `OF_NOT_FOUND` if it was not found
+ * or `OFNotFound` if it was not found
*/
- (size_t)indexOfObject: (ObjectType)object;
/**
* @brief Returns the index of the first object that has the same address as the
- * specified object or `OF_NOT_FOUND` if it was not found.
+ * specified object or `OFNotFound` if it was not found.
*
* @param object The object whose index is returned
* @return The index of the first object that has the same address as
- * the specified object or `OF_NOT_FOUND` if it was not found
+ * the specified object or `OFNotFound` if it was not found
*/
- (size_t)indexOfObjectIdenticalTo: (ObjectType)object;
/**
* @brief Checks whether the array contains an object equal to the specified
@@ -311,11 +328,11 @@
* @brief Returns the objects in the specified range as a new OFArray.
*
* @param range The range for the subarray
* @return The subarray as a new autoreleased OFArray
*/
-- (OFArray OF_GENERIC(ObjectType) *)objectsInRange: (of_range_t)range;
+- (OFArray OF_GENERIC(ObjectType) *)objectsInRange: (OFRange)range;
/**
* @brief Creates a string by joining all objects of the array.
*
* @param separator The string with which the objects should be joined
@@ -325,19 +342,15 @@
/**
* @brief Creates a string by joining all objects of the array.
*
* @param separator The string with which the objects should be joined
- * @param options Options according to which the objects should be joined.@n
- * Possible values are:
- * Value | Description
- * ----------------------|----------------------
- * `OF_ARRAY_SKIP_EMPTY` | Skip empty components
+ * @param options Options according to which the objects should be joined
* @return A string containing all objects joined by the separator
*/
- (OFString *)componentsJoinedByString: (OFString *)separator
- options: (int)options;
+ options: (OFArrayJoinOptions)options;
/**
* @brief Creates a string by calling the selector on all objects of the array
* and joining the strings returned by calling the selector.
*
@@ -352,20 +365,16 @@
* @brief Creates a string by calling the selector on all objects of the array
* and joining the strings returned by calling the selector.
*
* @param separator The string with which the objects should be joined
* @param selector The selector to perform on the objects
- * @param options Options according to which the objects should be joined.@n
- * Possible values are:
- * Value | Description
- * ----------------------|----------------------
- * `OF_ARRAY_SKIP_EMPTY` | Skip empty components
+ * @param options Options according to which the objects should be joined
* @return A string containing all objects joined by the separator
*/
- (OFString *)componentsJoinedByString: (OFString *)separator
usingSelector: (SEL)selector
- options: (int)options;
+ options: (OFArrayJoinOptions)options;
/**
* @brief Performs the specified selector on all objects in the array.
*
* @param selector The selector to perform on all objects in the array
@@ -387,36 +396,29 @@
* @brief Returns a copy of the array sorted using the specified selector and
* options.
*
* @param selector The selector to use to sort the array. It's signature
* should be the same as that of -[compare:].
- * @param options The options to use when sorting the array.@n
- * Possible values are:
- * Value | Description
- * ---------------------------|-------------------------
- * `OF_ARRAY_SORT_DESCENDING` | Sort in descending order
+ * @param options The options to use when sorting the array
* @return A sorted copy of the array
*/
-- (OFArray OF_GENERIC(ObjectType) *)sortedArrayUsingSelector: (SEL)selector
- options: (int)options;
+- (OFArray OF_GENERIC(ObjectType) *)
+ sortedArrayUsingSelector: (SEL)selector
+ options: (OFArraySortOptions)options;
#ifdef OF_HAVE_BLOCKS
/**
* @brief Returns a copy of the array sorted using the specified selector and
* options.
*
* @param comparator The comparator to use to sort the array
- * @param options The options to use when sorting the array.@n
- * Possible values are:
- * Value | Description
- * ---------------------------|-------------------------
- * `OF_ARRAY_SORT_DESCENDING` | Sort in descending order
+ * @param options The options to use when sorting the array
* @return A sorted copy of the array
*/
- (OFArray OF_GENERIC(ObjectType) *)
- sortedArrayUsingComparator: (of_comparator_t)comparator
- options: (int)options;
+ sortedArrayUsingComparator: (OFComparator)comparator
+ options: (OFArraySortOptions)options;
#endif
/**
* @brief Creates a new array with the specified object added.
*
@@ -432,33 +434,25 @@
* @return A new array with the objects from the specified array added
*/
- (OFArray OF_GENERIC(ObjectType) *)arrayByAddingObjectsFromArray:
(OFArray OF_GENERIC(ObjectType) *)array;
-/**
- * @brief Creates a new array with the specified object removed.
- *
- * @param object The object to remove
- * @return A new array with the specified object removed
- */
-- (OFArray OF_GENERIC(ObjectType) *)arrayByRemovingObject: (ObjectType)object;
-
#ifdef OF_HAVE_BLOCKS
/**
* @brief Executes a block for each object.
*
* @param block The block to execute for each object
*/
-- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block;
+- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block;
/**
* @brief Creates a new array, mapping each object using the specified block.
*
* @param block A block which maps an object for each object
* @return A new, autoreleased OFArray
*/
-- (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block;
+- (OFArray *)mappedArrayUsingBlock: (OFArrayMapBlock)block;
/**
* @brief Creates a new array, only containing the objects for which the block
* returns true.
*
@@ -465,11 +459,11 @@
* @param block A block which determines if the object should be in the new
* array
* @return A new, autoreleased OFArray
*/
- (OFArray OF_GENERIC(ObjectType) *)filteredArrayUsingBlock:
- (of_array_filter_block_t)block;
+ (OFArrayFilterBlock)block;
/**
* @brief Folds the array to a single object using the specified block.
*
* If the array is empty, it will return `nil`.
@@ -483,11 +477,11 @@
*
* @param block A block which folds two objects into one, which is called for
* all objects except the first
* @return The array folded to a single object
*/
-- (nullable id)foldUsingBlock: (of_array_fold_block_t)block;
+- (nullable id)foldUsingBlock: (OFArrayFoldBlock)block;
#endif
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# undef ObjectType
#endif
@end
Index: src/OFArray.m
==================================================================
--- src/OFArray.m
+++ src/OFArray.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -38,12 +36,13 @@
static struct {
Class isa;
} placeholder;
@interface OFArray ()
-- (OFString *)of_JSONRepresentationWithOptions: (int)options
- depth: (size_t)depth;
+- (OFString *)
+ of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
+ depth: (size_t)depth;
@end
@interface OFPlaceholderArray: OFArray
@end
@@ -195,12 +194,11 @@
{
id ret;
va_list arguments;
va_start(arguments, firstObject);
- ret = [self initWithObject: firstObject
- arguments: arguments];
+ ret = [self initWithObject: firstObject arguments: arguments];
va_end(arguments);
return ret;
}
@@ -229,32 +227,35 @@
- (size_t)count
{
OF_UNRECOGNIZED_SELECTOR
}
-- (void)getObjects: (id *)buffer
- inRange: (of_range_t)range
+- (void)getObjects: (id *)buffer inRange: (OFRange)range
{
for (size_t i = 0; i < range.length; i++)
buffer[i] = [self objectAtIndex: range.location + i];
}
- (id const *)objects
{
- OFObject *container;
- size_t count;
- id *buffer;
-
- container = [[[OFObject alloc] init] autorelease];
- count = self.count;
- buffer = [container allocMemoryWithSize: sizeof(*buffer)
- count: count];
-
- [self getObjects: buffer
- inRange: of_range(0, count)];
-
- return buffer;
+ size_t count = self.count;
+ id *buffer = OFAllocMemory(count, sizeof(id));
+ id const *ret;
+
+ @try {
+ [self getObjects: buffer inRange: OFRangeMake(0, count)];
+
+ ret = [[OFData dataWithItemsNoCopy: buffer
+ count: count
+ itemSize: sizeof(id)
+ freeWhenDone: true] items];
+ } @catch (id e) {
+ OFFreeMemory(buffer);
+ @throw e;
+ }
+
+ return ret;
}
- (id)copy
{
return [self retain];
@@ -296,60 +297,58 @@
[ret makeImmutable];
return ret;
}
-- (void)setValue: (id)value
- forKey: (OFString *)key
+- (void)setValue: (id)value forKey: (OFString *)key
{
for (id object in self)
- [object setValue: value
- forKey: key];
+ [object setValue: value forKey: key];
}
- (size_t)indexOfObject: (id)object
{
size_t i = 0;
if (object == nil)
- return OF_NOT_FOUND;
+ return OFNotFound;
for (id objectIter in self) {
if ([objectIter isEqual: object])
return i;
i++;
}
- return OF_NOT_FOUND;
+ return OFNotFound;
}
- (size_t)indexOfObjectIdenticalTo: (id)object
{
size_t i = 0;
if (object == nil)
- return OF_NOT_FOUND;
+ return OFNotFound;
for (id objectIter in self) {
if (objectIter == object)
return i;
i++;
}
- return OF_NOT_FOUND;
+ return OFNotFound;
}
- (bool)containsObject: (id)object
{
- return ([self indexOfObject: object] != OF_NOT_FOUND);
+ return ([self indexOfObject: object] != OFNotFound);
}
- (bool)containsObjectIdenticalTo: (id)object
{
- return ([self indexOfObjectIdenticalTo: object] != OF_NOT_FOUND);
+ return ([self indexOfObjectIdenticalTo: object] != OFNotFound);
}
- (id)firstObject
{
if (self.count > 0)
@@ -366,34 +365,29 @@
return [self objectAtIndex: count - 1];
return nil;
}
-- (OFArray *)objectsInRange: (of_range_t)range
+- (OFArray *)objectsInRange: (OFRange)range
{
OFArray *ret;
id *buffer;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length < self.count)
@throw [OFOutOfRangeException exception];
if (![self isKindOfClass: [OFMutableArray class]])
- return [OFSubarray arrayWithArray: self
- range: range];
+ return [OFSubarray arrayWithArray: self range: range];
- buffer = [self allocMemoryWithSize: sizeof(*buffer)
- count: range.length];
-
+ buffer = OFAllocMemory(range.length, sizeof(*buffer));
@try {
- [self getObjects: buffer
- inRange: range];
+ [self getObjects: buffer inRange: range];
- ret = [OFArray arrayWithObjects: buffer
- count: range.length];
+ ret = [OFArray arrayWithObjects: buffer count: range.length];
} @finally {
- [self freeMemory: buffer];
+ OFFreeMemory(buffer);
}
return ret;
}
@@ -403,11 +397,11 @@
usingSelector: @selector(description)
options: 0];
}
- (OFString *)componentsJoinedByString: (OFString *)separator
- options: (int)options
+ options: (OFArrayJoinOptions)options
{
return [self componentsJoinedByString: separator
usingSelector: @selector(description)
options: options];
}
@@ -420,11 +414,11 @@
options: 0];
}
- (OFString *)componentsJoinedByString: (OFString *)separator
usingSelector: (SEL)selector
- options: (int)options
+ options: (OFArrayJoinOptions)options
{
OFMutableString *ret;
if (separator == nil)
@throw [OFInvalidArgumentException exception];
@@ -432,21 +426,21 @@
if (self.count == 0)
return @"";
if (self.count == 1) {
OFString *component =
- [[self firstObject] performSelector: selector];
+ [[self objectAtIndex: 0] performSelector: selector];
if (component == nil)
@throw [OFInvalidArgumentException exception];
return component;
}
ret = [OFMutableString string];
- if (options & OF_ARRAY_SKIP_EMPTY) {
+ if (options & OFArraySkipEmptyComponents) {
for (id object in self) {
void *pool = objc_autoreleasePoolPush();
OFString *component =
[object performSelector: selector];
@@ -515,18 +509,18 @@
return true;
}
- (unsigned long)hash
{
- uint32_t hash;
+ unsigned long hash;
- OF_HASH_INIT(hash);
+ OFHashInit(&hash);
for (id object in self)
- OF_HASH_ADD_HASH(hash, [object hash]);
+ OFHashAddHash(&hash, [object hash]);
- OF_HASH_FINALIZE(hash);
+ OFHashFinalize(&hash);
return hash;
}
- (OFString *)description
@@ -540,12 +534,11 @@
pool = objc_autoreleasePoolPush();
ret = [[self componentsJoinedByString: @",\n"] mutableCopy];
@try {
[ret prependString: @"(\n"];
- [ret replaceOccurrencesOfString: @"\n"
- withString: @"\n\t"];
+ [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"];
[ret appendString: @"\n)"];
} @catch (id e) {
[ret release];
@throw e;
}
@@ -562,14 +555,14 @@
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
if ([self isKindOfClass: [OFMutableArray class]])
element = [OFXMLElement elementWithName: @"OFMutableArray"
- namespace: OF_SERIALIZATION_NS];
+ namespace: OFSerializationNS];
else
element = [OFXMLElement elementWithName: @"OFArray"
- namespace: OF_SERIALIZATION_NS];
+ namespace: OFSerializationNS];
for (id object in self) {
void *pool2 = objc_autoreleasePoolPush();
[element addChild: object.XMLElementBySerializing];
@@ -584,28 +577,28 @@
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
- return [self of_JSONRepresentationWithOptions: 0
- depth: 0];
+ return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
-- (OFString *)JSONRepresentationWithOptions: (int)options
+- (OFString *)JSONRepresentationWithOptions:
+ (OFJSONRepresentationOptions)options
{
- return [self of_JSONRepresentationWithOptions: options
- depth: 0];
+ return [self of_JSONRepresentationWithOptions: options depth: 0];
}
-- (OFString *)of_JSONRepresentationWithOptions: (int)options
- depth: (size_t)depth
+- (OFString *)
+ of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
+ depth: (size_t)depth
{
OFMutableString *JSON = [OFMutableString stringWithString: @"["];
void *pool = objc_autoreleasePoolPush();
size_t i, count = self.count;
- if (options & OF_JSON_REPRESENTATION_PRETTY) {
+ if (options & OFJSONRepresentationOptionPretty) {
OFMutableString *indentation = [OFMutableString string];
for (i = 0; i < depth; i++)
[indentation appendString: @"\t"];
@@ -666,22 +659,20 @@
if (count <= 15) {
uint8_t tmp = 0x90 | ((uint8_t)count & 0xF);
[data addItem: &tmp];
} else if (count <= UINT16_MAX) {
uint8_t type = 0xDC;
- uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)count);
+ uint16_t tmp = OFToBigEndian16((uint16_t)count);
[data addItem: &type];
- [data addItems: &tmp
- count: sizeof(tmp)];
+ [data addItems: &tmp count: sizeof(tmp)];
} else if (count <= UINT32_MAX) {
uint8_t type = 0xDD;
- uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count);
+ uint32_t tmp = OFToBigEndian32((uint32_t)count);
[data addItem: &type];
- [data addItems: &tmp
- count: sizeof(tmp)];
+ [data addItems: &tmp count: sizeof(tmp)];
} else
@throw [OFOutOfRangeException exception];
pool = objc_autoreleasePoolPush();
@@ -691,12 +682,11 @@
OFData *child;
i++;
child = [object messagePackRepresentation];
- [data addItems: child.items
- count: child.count];
+ [data addItems: child.items count: child.count];
objc_autoreleasePoolPop(pool2);
}
assert(i == count);
@@ -716,78 +706,62 @@
- (void)makeObjectsPerformSelector: (SEL)selector
withObject: (id)object
{
for (id objectIter in self)
- [objectIter performSelector: selector
- withObject: object];
+ [objectIter performSelector: selector withObject: object];
}
- (OFArray *)sortedArray
{
OFMutableArray *new = [[self mutableCopy] autorelease];
-
[new sort];
-
[new makeImmutable];
-
return new;
}
- (OFArray *)sortedArrayUsingSelector: (SEL)selector
- options: (int)options
+ options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
-
- [new sortUsingSelector: selector
- options: options];
-
+ [new sortUsingSelector: selector options: options];
[new makeImmutable];
-
return new;
}
#ifdef OF_HAVE_BLOCKS
-- (OFArray *)sortedArrayUsingComparator: (of_comparator_t)comparator
- options: (int)options
+- (OFArray *)sortedArrayUsingComparator: (OFComparator)comparator
+ options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
-
- [new sortUsingComparator: comparator
- options: options];
-
+ [new sortUsingComparator: comparator options: options];
[new makeImmutable];
-
return new;
}
#endif
- (OFArray *)reversedArray
{
OFMutableArray *new = [[self mutableCopy] autorelease];
-
[new reverse];
-
[new makeImmutable];
-
return new;
}
-- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state
+- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
- of_range_t range = of_range(state->state, count);
+ OFRange range = OFRangeMake(state->state, count);
if (range.length > SIZE_MAX - range.location)
@throw [OFOutOfRangeException exception];
if (range.location + range.length > self.count)
range.length = self.count - range.location;
- [self getObjects: objects
- inRange: range];
+ [self getObjects: objects inRange: range];
if (range.location + range.length > ULONG_MAX)
@throw [OFOutOfRangeException exception];
state->state = (unsigned long)(range.location + range.length);
@@ -802,11 +776,11 @@
return [[[OFArrayEnumerator alloc] initWithArray: self
mutationsPtr: NULL] autorelease];
}
#ifdef OF_HAVE_BLOCKS
-- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
+- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block
{
size_t i = 0;
bool stop = false;
for (id object in self) {
@@ -824,66 +798,51 @@
if (object == nil)
@throw [OFInvalidArgumentException exception];
ret = [[self mutableCopy] autorelease];
-
[ret addObject: object];
[ret makeImmutable];
return ret;
}
- (OFArray *)arrayByAddingObjectsFromArray: (OFArray *)array
{
OFMutableArray *ret = [[self mutableCopy] autorelease];
-
[ret addObjectsFromArray: array];
[ret makeImmutable];
return ret;
}
-- (OFArray *)arrayByRemovingObject: (id)object
-{
- OFMutableArray *ret = [[self mutableCopy] autorelease];
-
- [ret removeObject: object];
- [ret makeImmutable];
-
- return ret;
-}
-
#ifdef OF_HAVE_BLOCKS
-- (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block
+- (OFArray *)mappedArrayUsingBlock: (OFArrayMapBlock)block
{
OFArray *ret;
size_t count = self.count;
- id *tmp = [self allocMemoryWithSize: sizeof(id)
- count: count];
+ id *tmp = OFAllocMemory(count, sizeof(id));
@try {
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
tmp[idx] = block(object, idx);
}];
- ret = [OFArray arrayWithObjects: tmp
- count: count];
+ ret = [OFArray arrayWithObjects: tmp count: count];
} @finally {
- [self freeMemory: tmp];
+ OFFreeMemory(tmp);
}
return ret;
}
-- (OFArray *)filteredArrayUsingBlock: (of_array_filter_block_t)block
+- (OFArray *)filteredArrayUsingBlock: (OFArrayFilterBlock)block
{
OFArray *ret;
size_t count = self.count;
- id *tmp = [self allocMemoryWithSize: sizeof(id)
- count: count];
+ id *tmp = OFAllocMemory(count, sizeof(id));
@try {
__block size_t i = 0;
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
@@ -890,28 +849,27 @@
bool *stop) {
if (block(object, idx))
tmp[i++] = object;
}];
- ret = [OFArray arrayWithObjects: tmp
- count: i];
+ ret = [OFArray arrayWithObjects: tmp count: i];
} @finally {
- [self freeMemory: tmp];
+ OFFreeMemory(tmp);
}
return ret;
}
-- (id)foldUsingBlock: (of_array_fold_block_t)block
+- (id)foldUsingBlock: (OFArrayFoldBlock)block
{
size_t count = self.count;
__block id current;
if (count == 0)
return nil;
if (count == 1)
- return [[[self firstObject] retain] autorelease];
+ return [[[self objectAtIndex: 0] retain] autorelease];
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
id new;
ADDED src/OFAtomic.h
Index: src/OFAtomic.h
==================================================================
--- /dev/null
+++ src/OFAtomic.h
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include
+
+#import "macros.h"
+
+#ifndef OF_HAVE_ATOMIC_OPS
+# error No atomic operations available!
+#endif
+
+#if !defined(OF_HAVE_THREADS)
+static OF_INLINE int
+OFAtomicIntAdd(volatile int *_Nonnull p, int i)
+{
+ return (*p += i);
+}
+
+static OF_INLINE int32_t
+OFAtomicInt32Add(volatile int32_t *_Nonnull p, int32_t i)
+{
+ return (*p += i);
+}
+
+static OF_INLINE void *_Nullable
+OFAtomicPointerAdd(void *volatile _Nullable *_Nonnull p, intptr_t i)
+{
+ return (*(char *volatile *)p += i);
+}
+
+static OF_INLINE int
+OFAtomicIntSubtract(volatile int *_Nonnull p, int i)
+{
+ return (*p -= i);
+}
+
+static OF_INLINE int32_t
+OFAtomicInt32Subtract(volatile int32_t *_Nonnull p, int32_t i)
+{
+ return (*p -= i);
+}
+
+static OF_INLINE void *_Nullable
+OFAtomicPointerSubtract(void *volatile _Nullable *_Nonnull p, intptr_t i)
+{
+ return (*(char *volatile *)p -= i);
+}
+
+static OF_INLINE int
+OFAtomicIntIncrease(volatile int *_Nonnull p)
+{
+ return ++*p;
+}
+
+static OF_INLINE int32_t
+OFAtomicInt32Increase(volatile int32_t *_Nonnull p)
+{
+ return ++*p;
+}
+
+static OF_INLINE int
+OFAtomicIntDecrease(volatile int *_Nonnull p)
+{
+ return --*p;
+}
+
+static OF_INLINE int32_t
+OFAtomicInt32Decrease(volatile int32_t *_Nonnull p)
+{
+ return --*p;
+}
+
+static OF_INLINE unsigned int
+OFAtomicIntOr(volatile unsigned int *_Nonnull p, unsigned int i)
+{
+ return (*p |= i);
+}
+
+static OF_INLINE uint32_t
+OFAtomicInt32Or(volatile uint32_t *_Nonnull p, uint32_t i)
+{
+ return (*p |= i);
+}
+
+static OF_INLINE unsigned int
+OFAtomicIntAnd(volatile unsigned int *_Nonnull p, unsigned int i)
+{
+ return (*p &= i);
+}
+
+static OF_INLINE uint32_t
+OFAtomicInt32And(volatile uint32_t *_Nonnull p, uint32_t i)
+{
+ return (*p &= i);
+}
+
+static OF_INLINE unsigned int
+OFAtomicIntXor(volatile unsigned int *_Nonnull p, unsigned int i)
+{
+ return (*p ^= i);
+}
+
+static OF_INLINE uint32_t
+OFAtomicInt32Xor(volatile uint32_t *_Nonnull p, uint32_t i)
+{
+ return (*p ^= i);
+}
+
+static OF_INLINE bool
+OFAtomicIntCompareAndSwap(volatile int *_Nonnull p, int o, int n)
+{
+ if (*p == o) {
+ *p = n;
+ return true;
+ }
+
+ return false;
+}
+
+static OF_INLINE bool
+OFAtomicInt32CompareAndSwap(volatile int32_t *_Nonnull p, int32_t o, int32_t n)
+{
+ if (*p == o) {
+ *p = n;
+ return true;
+ }
+
+ return false;
+}
+
+static OF_INLINE bool
+OFAtomicPointerCompareAndSwap(void *volatile _Nullable *_Nonnull p,
+ void *_Nullable o, void *_Nullable n)
+{
+ if (*p == o) {
+ *p = n;
+ return true;
+ }
+
+ return false;
+}
+
+static OF_INLINE void
+OFMemoryBarrier(void)
+{
+ /* nop */
+}
+
+static OF_INLINE void
+OFAcquireMemoryBarrier(void)
+{
+ /* nop */
+}
+
+static OF_INLINE void
+OFReleaseMemoryBarrier(void)
+{
+ /* nop */
+}
+#elif (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
+# import "platform/x86/OFAtomic.h"
+#elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \
+ !defined(OF_AIX)
+# import "platform/PowerPC/OFAtomic.h"
+#elif defined(OF_HAVE_ATOMIC_BUILTINS)
+# import "platform/GCC4.7/OFAtomic.h"
+#elif defined(OF_HAVE_SYNC_BUILTINS)
+# import "platform/GCC4/OFAtomic.h"
+#elif defined(OF_HAVE_OSATOMIC)
+# import "platform/macOS/OFAtomic.h"
+#else
+# error No atomic operations available!
+#endif
ADDED src/OFBase64.h
Index: src/OFBase64.h
==================================================================
--- /dev/null
+++ src/OFBase64.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
+
+#import "macros.h"
+
+OF_ASSUME_NONNULL_BEGIN
+
+@class OFString;
+@class OFMutableData;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern OFString *OFBase64Encode(const void *, size_t);
+extern bool OFBase64Decode(OFMutableData *, const char *, size_t);
+#ifdef __cplusplus
+}
+#endif
+
+OF_ASSUME_NONNULL_END
ADDED src/OFBase64.m
Index: src/OFBase64.m
==================================================================
--- /dev/null
+++ src/OFBase64.m
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFBase64.h"
+#import "OFString.h"
+#import "OFData.h"
+
+static const unsigned char encodeTable[64] = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b',
+ 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
+ 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '+', '/'
+};
+
+static const signed char decodeTable[128] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54,
+ 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2,
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30,
+ 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)
+{
+ OFMutableString *ret = [OFMutableString string];
+ uint8_t *buffer = (uint8_t *)data;
+ size_t i;
+ uint8_t rest;
+ char tb[4];
+ uint32_t sb;
+
+ rest = length % 3;
+
+ for (i = 0; i < length - rest; i += 3) {
+ sb = (buffer[i] << 16) | (buffer[i + 1] << 8) | buffer[i + 2];
+
+ tb[0] = encodeTable[(sb & 0xFC0000) >> 18];
+ tb[1] = encodeTable[(sb & 0x03F000) >> 12];
+ tb[2] = encodeTable[(sb & 0x000FC0) >> 6];
+ tb[3] = encodeTable[sb & 0x00003F];
+
+ [ret appendCString: tb
+ encoding: OFStringEncodingASCII
+ length: 4];
+ }
+
+ switch (rest) {
+ case 1:
+ tb[0] = encodeTable[buffer[i] >> 2];
+ tb[1] = encodeTable[(buffer[i] & 3) << 4];
+ tb[2] = tb[3] = '=';
+
+ [ret appendCString: tb
+ encoding: OFStringEncodingASCII
+ length: 4];
+
+ break;
+ case 2:
+ sb = (buffer[i] << 16) | (buffer[i + 1] << 8);
+
+ tb[0] = encodeTable[(sb & 0xFC0000) >> 18];
+ tb[1] = encodeTable[(sb & 0x03F000) >> 12];
+ tb[2] = encodeTable[(sb & 0x000FC0) >> 6];
+ tb[3] = '=';
+
+ [ret appendCString: tb
+ encoding: OFStringEncodingASCII
+ length: 4];
+
+ break;
+ }
+
+ [ret makeImmutable];
+
+ return ret;
+}
+
+bool
+OFBase64Decode(OFMutableData *data, const char *string, size_t length)
+{
+ const uint8_t *buffer = (const uint8_t *)string;
+ size_t i;
+
+ if ((length & 3) != 0)
+ return false;
+
+ if (data.itemSize != 1)
+ return false;
+
+ for (i = 0; i < length; i += 4) {
+ uint32_t sb = 0;
+ uint8_t count = 3;
+ char db[3];
+ int8_t tmp;
+
+ if (buffer[i] > 0x7F || buffer[i + 1] > 0x7F ||
+ buffer[i + 2] > 0x7F || buffer[i + 3] > 0x7F)
+ return false;
+
+ if (buffer[i] == '=' || buffer[i + 1] == '=' ||
+ (buffer[i + 2] == '=' && buffer[i + 3] != '='))
+ return false;
+
+ if (buffer[i + 2] == '=')
+ count--;
+ if (buffer[i + 3] == '=')
+ count--;
+
+ if ((tmp = decodeTable[buffer[i]]) == -1)
+ return false;
+
+ sb |= tmp << 18;
+
+ if ((tmp = decodeTable[buffer[i + 1]]) == -1)
+ return false;
+
+ sb |= tmp << 12;
+
+ if ((tmp = decodeTable[buffer[i + 2]]) == -1)
+ return false;
+
+ sb |= tmp << 6;
+
+ if ((tmp = decodeTable[buffer[i + 3]]) == -1)
+ return false;
+
+ sb |= tmp;
+
+ db[0] = (sb & 0xFF0000) >> 16;
+ db[1] = (sb & 0x00FF00) >> 8;
+ db[2] = sb & 0x0000FF;
+
+ [data addItems: db count: count];
+ }
+
+ return true;
+}
Index: src/OFBitSetCharacterSet.h
==================================================================
--- src/OFBitSetCharacterSet.h
+++ src/OFBitSetCharacterSet.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFBitSetCharacterSet.m
==================================================================
--- src/OFBitSetCharacterSet.m
+++ src/OFBitSetCharacterSet.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -32,33 +30,33 @@
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
- const of_unichar_t *characters = string.characters;
+ const OFUnichar *characters = string.characters;
size_t length = string.length;
for (size_t i = 0; i < length; i++) {
- of_unichar_t c = characters[i];
+ OFUnichar c = characters[i];
- if (c / 8 >= _size) {
+ if (c / CHAR_BIT >= _size) {
size_t newSize;
if (UINT32_MAX - c < 1)
@throw [OFOutOfRangeException
exception];
- newSize = OF_ROUND_UP_POW2(8, c + 1) / 8;
+ newSize = OFRoundUpToPowerOf2(CHAR_BIT, c + 1) /
+ CHAR_BIT;
- _bitset = [self resizeMemory: _bitset
- size: newSize];
+ _bitset = OFResizeMemory(_bitset, newSize, 1);
memset(_bitset + _size, '\0', newSize - _size);
_size = newSize;
}
- of_bitset_set(_bitset, c);
+ OFBitsetSet(_bitset, c);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@@ -66,13 +64,20 @@
}
return self;
}
-- (bool)characterIsMember: (of_unichar_t)character
+- (void)dealloc
+{
+ OFFreeMemory(_bitset);
+
+ [super dealloc];
+}
+
+- (bool)characterIsMember: (OFUnichar)character
{
- if (character / 8 >= _size)
+ if (character / CHAR_BIT >= _size)
return false;
- return of_bitset_isset(_bitset, character);
+ return OFBitsetIsSet(_bitset, character);
}
@end
Index: src/OFBlock.h
==================================================================
--- src/OFBlock.h
+++ src/OFBlock.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -15,12 +13,10 @@
* file.
*/
#import "OFObject.h"
-#import "block.h"
-
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFBlock OFBlock.h ObjFW/OFBlock.h
*
@@ -40,7 +36,39 @@
@end
OF_SUBCLASSING_RESTRICTED
@interface OFMallocBlock: OFBlock
@end
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void *_Nullable _Block_copy(const void *_Nullable);
+extern void _Block_release(const void *_Nullable);
+
+# if defined(OF_WINDOWS) && \
+ (defined(OF_NO_SHARED) || defined(OF_COMPILING_OBJFW))
+/*
+ * Clang has implicit declarations for these, but they are dllimport. When
+ * compiling ObjFW itself or using it as a static library, these need to be
+ * dllexport. Interestingly, this still works when using it as a shared library.
+ */
+extern __declspec(dllexport) struct objc_class _NSConcreteStackBlock;
+extern __declspec(dllexport) struct objc_class _NSConcreteGlobalBlock;
+extern __declspec(dllexport) void _Block_object_assign(void *, const void *,
+ const int);
+extern __declspec(dllexport) void _Block_object_dispose(const void *,
+ const int);
+# endif
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef Block_copy
+# define Block_copy(...) \
+ ((__typeof__(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
+#endif
+#ifndef Block_release
+# define Block_release(...) _Block_release((const void *)(__VA_ARGS__))
+#endif
OF_ASSUME_NONNULL_END
Index: src/OFBlock.m
==================================================================
--- src/OFBlock.m
+++ src/OFBlock.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -20,50 +18,62 @@
#include
#include
#include
#import "OFBlock.h"
+#ifdef OF_HAVE_ATOMIC_OPS
+# import "OFAtomic.h"
+#endif
+#ifdef OF_HAVE_THREADS
+# import "OFPlainMutex.h"
+#endif
#import "OFAllocFailedException.h"
#import "OFInitializationFailedException.h"
#if defined(OF_OBJFW_RUNTIME)
# import "runtime/private.h"
#endif
-#ifdef OF_HAVE_ATOMIC_OPS
-# import "atomic.h"
-#endif
-#ifdef OF_HAVE_THREADS
-# import "mutex.h"
-#endif
-
-typedef struct of_block_byref_t of_block_byref_t;
-struct of_block_byref_t {
+struct Block {
+ Class isa;
+ int flags;
+ int reserved;
+ void (*invoke)(void *block, ...);
+ struct {
+ unsigned long reserved;
+ unsigned long size;
+ void (*_Nullable copyHelper)(void *dest, void *src);
+ void (*_Nullable disposeHelper)(void *src);
+ const char *signature;
+ } *descriptor;
+};
+
+struct Byref {
Class isa;
- of_block_byref_t *forwarding;
+ struct Byref *forwarding;
int flags;
int size;
- void (*byref_keep)(void *dest, void *src);
- void (*byref_dispose)(void *);
-};
-
-enum {
- OF_BLOCK_HAS_COPY_DISPOSE = (1 << 25),
- OF_BLOCK_HAS_CTOR = (1 << 26),
- OF_BLOCK_IS_GLOBAL = (1 << 28),
- OF_BLOCK_HAS_STRET = (1 << 29),
- OF_BLOCK_HAS_SIGNATURE = (1 << 30)
-};
-#define OF_BLOCK_REFCOUNT_MASK 0xFFFF
-
-enum {
- OF_BLOCK_FIELD_IS_OBJECT = 3,
- OF_BLOCK_FIELD_IS_BLOCK = 7,
- OF_BLOCK_FIELD_IS_BYREF = 8,
- OF_BLOCK_FIELD_IS_WEAK = 16,
- OF_BLOCK_BYREF_CALLER = 128
+ void (*keepByref)(void *dest, void *src);
+ void (*disposeByref)(void *);
+};
+
+enum {
+ OFBlockHasCopyDispose = (1 << 25),
+ OFBlockHasCtor = (1 << 26),
+ OFBlockIsGlobal = (1 << 28),
+ OFBlockHasStret = (1 << 29),
+ OFBlockHasSignature = (1 << 30)
+};
+#define OFBlockRefCountMask 0xFFFF
+
+enum {
+ OFBlockFieldIsObject = 3,
+ OFBlockFieldIsBlock = 7,
+ OFBlockFieldIsByref = 8,
+ OFBlockFieldIsWeak = 16,
+ OFBlockByrefCaller = 128
};
@protocol RetainRelease
- (instancetype)retain;
- (void)release;
@@ -76,11 +86,11 @@
sizeof(_NSConcreteStackBlock_metaclass), NULL, NULL
};
struct objc_class _NSConcreteStackBlock = {
&_NSConcreteStackBlock_metaclass, (Class)(void *)"OFBlock",
- "OFStackBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t),
+ "OFStackBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(struct Block),
NULL, NULL
};
static struct objc_class _NSConcreteGlobalBlock_metaclass = {
Nil, Nil, "OFGlobalBlock", 8, OBJC_CLASS_INFO_METACLASS,
@@ -87,11 +97,11 @@
sizeof(_NSConcreteGlobalBlock_metaclass), NULL, NULL
};
struct objc_class _NSConcreteGlobalBlock = {
&_NSConcreteGlobalBlock_metaclass, (Class)(void *)"OFBlock",
- "OFGlobalBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t),
+ "OFGlobalBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(struct Block),
NULL, NULL
};
static struct objc_class _NSConcreteMallocBlock_metaclass = {
Nil, Nil, "OFMallocBlock", 8, OBJC_CLASS_INFO_METACLASS,
@@ -98,11 +108,11 @@
sizeof(_NSConcreteMallocBlock_metaclass), NULL, NULL
};
struct objc_class _NSConcreteMallocBlock = {
&_NSConcreteMallocBlock_metaclass, (Class)(void *)"OFBlock",
- "OFMallocBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t),
+ "OFMallocBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(struct Block),
NULL, NULL
};
static struct {
unsigned long unknown;
@@ -154,23 +164,23 @@
static struct {
Class isa;
} alloc_failed_exception;
#ifndef OF_HAVE_ATOMIC_OPS
-# define NUM_SPINLOCKS 8 /* needs to be a power of 2 */
-# define SPINLOCK_HASH(p) ((uintptr_t)p >> 4) & (NUM_SPINLOCKS - 1)
-static of_spinlock_t blockSpinlocks[NUM_SPINLOCKS];
-static of_spinlock_t byrefSpinlocks[NUM_SPINLOCKS];
+# define numSpinlocks 8 /* needs to be a power of 2 */
+# define SPINLOCK_HASH(p) ((uintptr_t)p >> 4) & (numSpinlocks - 1)
+static OFSpinlock blockSpinlocks[numSpinlocks];
+static OFSpinlock byrefSpinlocks[numSpinlocks];
#endif
void *
_Block_copy(const void *block_)
{
- of_block_literal_t *block = (of_block_literal_t *)block_;
+ struct Block *block = (struct Block *)block_;
if ([(id)block isMemberOfClass: (Class)&_NSConcreteStackBlock]) {
- of_block_literal_t *copy;
+ struct Block *copy;
if ((copy = malloc(block->descriptor->size)) == NULL) {
alloc_failed_exception.isa =
[OFAllocFailedException class];
@throw (OFAllocFailedException *)
@@ -179,196 +189,196 @@
memcpy(copy, block, block->descriptor->size);
object_setClass((id)copy, (Class)&_NSConcreteMallocBlock);
copy->flags++;
- if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
- block->descriptor->copy_helper(copy, block);
+ if (block->flags & OFBlockHasCopyDispose)
+ block->descriptor->copyHelper(copy, block);
return copy;
}
if ([(id)block isMemberOfClass: (Class)&_NSConcreteMallocBlock]) {
#ifdef OF_HAVE_ATOMIC_OPS
- of_atomic_int_inc(&block->flags);
+ OFAtomicIntIncrease(&block->flags);
#else
unsigned hash = SPINLOCK_HASH(block);
- OF_ENSURE(of_spinlock_lock(&blockSpinlocks[hash]));
+ OFEnsure(OFSpinlockLock(&blockSpinlocks[hash]) == 0);
block->flags++;
- OF_ENSURE(of_spinlock_unlock(&blockSpinlocks[hash]));
+ OFEnsure(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0);
#endif
}
return block;
}
void
_Block_release(const void *block_)
{
- of_block_literal_t *block = (of_block_literal_t *)block_;
+ struct Block *block = (struct Block *)block_;
if (object_getClass((id)block) != (Class)&_NSConcreteMallocBlock)
return;
#ifdef OF_HAVE_ATOMIC_OPS
- if ((of_atomic_int_dec(&block->flags) & OF_BLOCK_REFCOUNT_MASK) == 0) {
- if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
- block->descriptor->dispose_helper(block);
+ if ((OFAtomicIntDecrease(&block->flags) & OFBlockRefCountMask) == 0) {
+ if (block->flags & OFBlockHasCopyDispose)
+ block->descriptor->disposeHelper(block);
free(block);
}
#else
unsigned hash = SPINLOCK_HASH(block);
- OF_ENSURE(of_spinlock_lock(&blockSpinlocks[hash]));
- if ((--block->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
- OF_ENSURE(of_spinlock_unlock(&blockSpinlocks[hash]));
+ OFEnsure(OFSpinlockLock(&blockSpinlocks[hash]) == 0);
+ if ((--block->flags & OFBlockRefCountMask) == 0) {
+ OFEnsure(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0);
- if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
- block->descriptor->dispose_helper(block);
+ if (block->flags & OFBlockHasCopyDispose)
+ block->descriptor->disposeHelper(block);
free(block);
return;
}
- OF_ENSURE(of_spinlock_unlock(&blockSpinlocks[hash]));
+ OFEnsure(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0);
#endif
}
void
_Block_object_assign(void *dst_, const void *src_, const int flags_)
{
- int flags = flags_ & (OF_BLOCK_FIELD_IS_BLOCK |
- OF_BLOCK_FIELD_IS_OBJECT | OF_BLOCK_FIELD_IS_BYREF);
+ int flags = flags_ & (OFBlockFieldIsBlock | OFBlockFieldIsObject |
+ OFBlockFieldIsByref);
if (src_ == NULL)
return;
switch (flags) {
- case OF_BLOCK_FIELD_IS_BLOCK:
- *(of_block_literal_t **)dst_ = _Block_copy(src_);
+ case OFBlockFieldIsBlock:
+ *(struct Block **)dst_ = _Block_copy(src_);
break;
- case OF_BLOCK_FIELD_IS_OBJECT:
- if (!(flags_ & OF_BLOCK_BYREF_CALLER))
+ case OFBlockFieldIsObject:
+ if (!(flags_ & OFBlockByrefCaller))
*(id *)dst_ = [(id)src_ retain];
break;
- case OF_BLOCK_FIELD_IS_BYREF:;
- of_block_byref_t *src = (of_block_byref_t *)src_;
- of_block_byref_t **dst = (of_block_byref_t **)dst_;
+ case OFBlockFieldIsByref:;
+ struct Byref *src = (struct Byref *)src_;
+ struct Byref **dst = (struct Byref **)dst_;
src = src->forwarding;
- if ((src->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
+ if ((src->flags & OFBlockRefCountMask) == 0) {
if ((*dst = malloc(src->size)) == NULL) {
alloc_failed_exception.isa =
[OFAllocFailedException class];
@throw (OFAllocFailedException *)
&alloc_failed_exception;
}
memcpy(*dst, src, src->size);
(*dst)->flags =
- ((*dst)->flags & ~OF_BLOCK_REFCOUNT_MASK) | 1;
+ ((*dst)->flags & ~OFBlockRefCountMask) | 1;
(*dst)->forwarding = *dst;
- if (src->flags & OF_BLOCK_HAS_COPY_DISPOSE)
- src->byref_keep(*dst, src);
+ if (src->flags & OFBlockHasCopyDispose)
+ src->keepByref(*dst, src);
#ifdef OF_HAVE_ATOMIC_OPS
- if (!of_atomic_ptr_cmpswap((void **)&src->forwarding,
- src, *dst)) {
- src->byref_dispose(*dst);
+ if (!OFAtomicPointerCompareAndSwap(
+ (void **)&src->forwarding, src, *dst)) {
+ src->disposeByref(*dst);
free(*dst);
*dst = src->forwarding;
}
#else
unsigned hash = SPINLOCK_HASH(src);
- OF_ENSURE(of_spinlock_lock(&byrefSpinlocks[hash]));
+ OFEnsure(OFSpinlockLock(&byrefSpinlocks[hash]) == 0);
if (src->forwarding == src)
src->forwarding = *dst;
else {
- src->byref_dispose(*dst);
+ src->disposeByref(*dst);
free(*dst);
*dst = src->forwarding;
}
- OF_ENSURE(of_spinlock_unlock(&byrefSpinlocks[hash]));
+ OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
#endif
} else
*dst = src;
#ifdef OF_HAVE_ATOMIC_OPS
- of_atomic_int_inc(&(*dst)->flags);
+ OFAtomicIntIncrease(&(*dst)->flags);
#else
unsigned hash = SPINLOCK_HASH(*dst);
- OF_ENSURE(of_spinlock_lock(&byrefSpinlocks[hash]));
+ OFEnsure(OFSpinlockLock(&byrefSpinlocks[hash]) == 0);
(*dst)->flags++;
- OF_ENSURE(of_spinlock_unlock(&byrefSpinlocks[hash]));
+ OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
#endif
break;
}
}
void
_Block_object_dispose(const void *object_, const int flags_)
{
- const int flags = flags_ & (OF_BLOCK_FIELD_IS_BLOCK |
- OF_BLOCK_FIELD_IS_OBJECT | OF_BLOCK_FIELD_IS_BYREF);
+ const int flags = flags_ & (OFBlockFieldIsBlock | OFBlockFieldIsObject |
+ OFBlockFieldIsByref);
if (object_ == NULL)
return;
switch (flags) {
- case OF_BLOCK_FIELD_IS_BLOCK:
+ case OFBlockFieldIsBlock:
_Block_release(object_);
break;
- case OF_BLOCK_FIELD_IS_OBJECT:
- if (!(flags_ & OF_BLOCK_BYREF_CALLER))
+ case OFBlockFieldIsObject:
+ if (!(flags_ & OFBlockByrefCaller))
[(id)object_ release];
break;
- case OF_BLOCK_FIELD_IS_BYREF:;
- of_block_byref_t *object = (of_block_byref_t *)object_;
+ case OFBlockFieldIsByref:;
+ struct Byref *object = (struct Byref *)object_;
object = object->forwarding;
#ifdef OF_HAVE_ATOMIC_OPS
- if ((of_atomic_int_dec(&object->flags) &
- OF_BLOCK_REFCOUNT_MASK) == 0) {
- if (object->flags & OF_BLOCK_HAS_COPY_DISPOSE)
- object->byref_dispose(object);
+ if ((OFAtomicIntDecrease(&object->flags) &
+ OFBlockRefCountMask) == 0) {
+ if (object->flags & OFBlockHasCopyDispose)
+ object->disposeByref(object);
free(object);
}
#else
unsigned hash = SPINLOCK_HASH(object);
- OF_ENSURE(of_spinlock_lock(&byrefSpinlocks[hash]));
- if ((--object->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
- OF_ENSURE(of_spinlock_unlock(&byrefSpinlocks[hash]));
+ OFEnsure(OFSpinlockLock(&byrefSpinlocks[hash]) == 0);
+ if ((--object->flags & OFBlockRefCountMask) == 0) {
+ OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
- if (object->flags & OF_BLOCK_HAS_COPY_DISPOSE)
- object->byref_dispose(object);
+ if (object->flags & OFBlockHasCopyDispose)
+ object->disposeByref(object);
free(object);
}
- OF_ENSURE(of_spinlock_unlock(&byrefSpinlocks[hash]));
+ OFEnsure(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0);
#endif
break;
}
}
@implementation OFBlock
+ (void)load
{
#ifndef OF_HAVE_ATOMIC_OPS
- for (size_t i = 0; i < NUM_SPINLOCKS; i++)
- if (!of_spinlock_new(&blockSpinlocks[i]) ||
- !of_spinlock_new(&byrefSpinlocks[i]))
+ for (size_t i = 0; i < numSpinlocks; i++)
+ if (OFSpinlockNew(&blockSpinlocks[i]) != 0 ||
+ OFSpinlockNew(&byrefSpinlocks[i]) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: self];
#endif
#ifdef OF_APPLE_RUNTIME
@@ -437,39 +447,10 @@
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
-- (void *)allocMemoryWithSize: (size_t)size
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)allocMemoryWithSize: (size_t)size
- count: (size_t)count
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)resizeMemory: (void *)ptr
- size: (size_t)size
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)resizeMemory: (void *)ptr
- size: (size_t)size
- count: (size_t)count
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void)freeMemory: (void *)ptr
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
- (instancetype)retain
{
if ([self isMemberOfClass: (Class)&_NSConcreteMallocBlock])
return Block_copy(self);
@@ -490,14 +471,13 @@
}
- (unsigned int)retainCount
{
if ([self isMemberOfClass: (Class)&_NSConcreteMallocBlock])
- return ((of_block_literal_t *)self)->flags &
- OF_BLOCK_REFCOUNT_MASK;
+ return ((struct Block *)self)->flags & OFBlockRefCountMask;
- return OF_RETAIN_COUNT_MAX;
+ return OFMaxRetainCount;
}
- (void)release
{
if ([self isMemberOfClass: (Class)&_NSConcreteMallocBlock])
Index: src/OFBytesValue.h
==================================================================
--- src/OFBytesValue.h
+++ src/OFBytesValue.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFBytesValue.m
==================================================================
--- src/OFBytesValue.m
+++ src/OFBytesValue.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -27,13 +25,13 @@
objCType: (const char *)objCType
{
self = [super init];
@try {
- _size = of_sizeof_type_encoding(objCType);
+ _size = OFSizeOfTypeEncoding(objCType);
_objCType = objCType;
- _bytes = [self allocMemoryWithSize: _size];
+ _bytes = OFAllocMemory(1, _size);
memcpy(_bytes, bytes, _size);
} @catch (id e) {
[self release];
@throw e;
@@ -40,14 +38,20 @@
}
return self;
}
-- (void)getValue: (void *)value
- size: (size_t)size
+- (void)dealloc
+{
+ OFFreeMemory(_bytes);
+
+ [super dealloc];
+}
+
+- (void)getValue: (void *)value size: (size_t)size
{
if (size != _size)
@throw [OFOutOfRangeException exception];
memcpy(value, _bytes, _size);
}
@end
ADDED src/OFCRC16.h
Index: src/OFCRC16.h
==================================================================
--- /dev/null
+++ src/OFCRC16.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
+
+#import "macros.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern uint16_t OFCRC16(uint16_t crc, const void *_Nonnull bytes,
+ size_t length);
+#ifdef __cplusplus
+}
+#endif
ADDED src/OFCRC16.m
Index: src/OFCRC16.m
==================================================================
--- /dev/null
+++ src/OFCRC16.m
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFCRC16.h"
+
+static const uint16_t CRC16Magic = 0xA001;
+
+uint16_t
+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];
+
+ for (uint8_t j = 0; j < 8; j++)
+ CRC = (CRC >> 1) ^ (CRC16Magic & (~(CRC & 1) + 1));
+ }
+
+ return CRC;
+}
ADDED src/OFCRC32.h
Index: src/OFCRC32.h
==================================================================
--- /dev/null
+++ src/OFCRC32.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
+
+#import "macros.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern uint32_t OFCRC32(uint32_t crc, const void *_Nonnull bytes,
+ size_t length);
+#ifdef __cplusplus
+}
+#endif
ADDED src/OFCRC32.m
Index: src/OFCRC32.m
==================================================================
--- /dev/null
+++ src/OFCRC32.m
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFCRC32.h"
+
+static const uint32_t CRC32Magic = 0xEDB88320;
+
+uint32_t
+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];
+
+ for (uint8_t j = 0; j < 8; j++)
+ CRC = (CRC >> 1) ^ (CRC32Magic & (~(CRC & 1) + 1));
+ }
+
+ return CRC;
+}
Index: src/OFCharacterSet.h
==================================================================
--- src/OFCharacterSet.h
+++ src/OFCharacterSet.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -56,11 +54,11 @@
* range.
*
* @param range The range of characters for the character set
* @return A new OFCharacterSet
*/
-+ (instancetype)characterSetWithRange: (of_range_t)range;
++ (instancetype)characterSetWithRange: (OFRange)range;
/**
* @brief A character set containing all Unicode characters in the category
* `Zs` plus CHARACTER TABULATION (U+0009).
*/
@@ -80,19 +78,19 @@
* the specified range.
*
* @param range The range of characters for the character set
* @return An initialized OFCharacterSet
*/
-- (instancetype)initWithRange: (of_range_t)range;
+- (instancetype)initWithRange: (OFRange)range;
/**
* @brief Returns whether the specified character is a member of the character
* set.
*
* @param character The character that is checked for being a member of the
* character set
* @return Whether the specified character is a member of the character set.
*/
-- (bool)characterIsMember: (of_unichar_t)character;
+- (bool)characterIsMember: (OFUnichar)character;
@end
OF_ASSUME_NONNULL_END
Index: src/OFCharacterSet.m
==================================================================
--- src/OFCharacterSet.m
+++ src/OFCharacterSet.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -18,14 +16,13 @@
#include "config.h"
#import "OFCharacterSet.h"
#import "OFBitSetCharacterSet.h"
#import "OFInvertedCharacterSet.h"
+#import "OFOnce.h"
#import "OFRangeCharacterSet.h"
-#import "once.h"
-
@interface OFPlaceholderCharacterSet: OFCharacterSet
@end
@interface OFWhitespaceCharacterSet: OFCharacterSet
@end
@@ -52,11 +49,11 @@
{
return (id)[[OFBitSetCharacterSet alloc]
initWithCharactersInString: characters];
}
-- (instancetype)initWithRange: (of_range_t)range
+- (instancetype)initWithRange: (OFRange)range
{
return (id)[[OFRangeCharacterSet alloc] initWithRange: range];
}
- (instancetype)retain
@@ -100,19 +97,19 @@
{
return [[[self alloc] initWithCharactersInString: characters]
autorelease];
}
-+ (instancetype)characterSetWithRange: (of_range_t)range
++ (instancetype)characterSetWithRange: (OFRange)range
{
return [[[self alloc] initWithRange: range] autorelease];
}
+ (OFCharacterSet *)whitespaceCharacterSet
{
- static of_once_t onceControl = OF_ONCE_INIT;
- of_once(&onceControl, initWhitespaceCharacterSet);
+ static OFOnceControl onceControl = OFOnceControlInitValue;
+ OFOnce(&onceControl, initWhitespaceCharacterSet);
return whitespaceCharacterSet;
}
- (instancetype)init
@@ -134,16 +131,16 @@
- (instancetype)initWithCharactersInString: (OFString *)characters
{
OF_INVALID_INIT_METHOD
}
-- (instancetype)initWithRange: (of_range_t)range
+- (instancetype)initWithRange: (OFRange)range
{
OF_INVALID_INIT_METHOD
}
-- (bool)characterIsMember: (of_unichar_t)character
+- (bool)characterIsMember: (OFUnichar)character
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFCharacterSet *)invertedSet
@@ -168,14 +165,14 @@
{
}
- (unsigned int)retainCount
{
- return OF_RETAIN_COUNT_MAX;
+ return OFMaxRetainCount;
}
-- (bool)characterIsMember: (of_unichar_t)character
+- (bool)characterIsMember: (OFUnichar)character
{
switch (character) {
case 0x0009:
case 0x0020:
case 0x00A0:
Index: src/OFCollection.h
==================================================================
--- src/OFCollection.h
+++ src/OFCollection.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -22,11 +20,11 @@
/**
* @protocol OFCollection OFCollection.h ObjFW/OFCollection.h
*
* @brief A protocol with methods common for all collections.
*/
-@protocol OFCollection
+@protocol OFCollection
/**
* @brief The number of objects in the collection
*/
@property (readonly, nonatomic) size_t count;
Index: src/OFColor.h
==================================================================
--- src/OFColor.h
+++ src/OFColor.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFColor.m
==================================================================
--- src/OFColor.m
+++ src/OFColor.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -16,34 +14,33 @@
*/
#include "config.h"
#import "OFColor.h"
-
-#import "once.h"
+#import "OFOnce.h"
#import "OFInvalidArgumentException.h"
@implementation OFColor
-#define PREDEFINED_COLOR(name, r, g, b) \
- static OFColor *name##Color = nil; \
- \
- static void \
- initPredefinedColor_##name(void) \
- { \
- name##Color = [[OFColor alloc] initWithRed: r \
- green: g \
- blue: b \
- alpha: 1]; \
- } \
- \
- + (OFColor *)name \
- { \
- static of_once_t onceControl = OF_ONCE_INIT; \
- of_once(&onceControl, initPredefinedColor_##name); \
- \
- return name##Color; \
+#define PREDEFINED_COLOR(name, redValue, greenValue, blueValue) \
+ static OFColor *name##Color = nil; \
+ \
+ static void \
+ initPredefinedColor_##name(void) \
+ { \
+ name##Color = [[OFColor alloc] initWithRed: redValue \
+ green: greenValue \
+ blue: blueValue \
+ alpha: 1]; \
+ } \
+ \
+ + (OFColor *)name \
+ { \
+ static OFOnceControl onceControl = OFOnceControlInitValue; \
+ OFOnce(&onceControl, initPredefinedColor_##name); \
+ \
+ return name##Color; \
}
PREDEFINED_COLOR(black, 0.00f, 0.00f, 0.00f)
PREDEFINED_COLOR(silver, 0.75f, 0.75f, 0.75f)
PREDEFINED_COLOR(grey, 0.50f, 0.50f, 0.50f)
@@ -122,32 +119,32 @@
return true;
}
- (unsigned long)hash
{
- uint32_t hash;
+ unsigned long hash;
float tmp;
- OF_HASH_INIT(hash);
-
- tmp = OF_BSWAP_FLOAT_IF_LE(_red);
- for (uint_fast8_t i = 0; i < sizeof(float); i++)
- OF_HASH_ADD(hash, ((char *)&tmp)[i]);
-
- tmp = OF_BSWAP_FLOAT_IF_LE(_green);
- for (uint_fast8_t i = 0; i < sizeof(float); i++)
- OF_HASH_ADD(hash, ((char *)&tmp)[i]);
-
- tmp = OF_BSWAP_FLOAT_IF_LE(_blue);
- for (uint_fast8_t i = 0; i < sizeof(float); i++)
- OF_HASH_ADD(hash, ((char *)&tmp)[i]);
-
- tmp = OF_BSWAP_FLOAT_IF_LE(_alpha);
- for (uint_fast8_t i = 0; i < sizeof(float); i++)
- OF_HASH_ADD(hash, ((char *)&tmp)[i]);
-
- OF_HASH_FINALIZE(hash);
+ OFHashInit(&hash);
+
+ tmp = OFToLittleEndianFloat(_red);
+ for (uint_fast8_t i = 0; i < sizeof(float); i++)
+ OFHashAdd(&hash, ((char *)&tmp)[i]);
+
+ tmp = OFToLittleEndianFloat(_green);
+ for (uint_fast8_t i = 0; i < sizeof(float); i++)
+ OFHashAdd(&hash, ((char *)&tmp)[i]);
+
+ tmp = OFToLittleEndianFloat(_blue);
+ for (uint_fast8_t i = 0; i < sizeof(float); i++)
+ OFHashAdd(&hash, ((char *)&tmp)[i]);
+
+ tmp = OFToLittleEndianFloat(_alpha);
+ for (uint_fast8_t i = 0; i < sizeof(float); i++)
+ OFHashAdd(&hash, ((char *)&tmp)[i]);
+
+ OFHashFinalize(&hash);
return hash;
}
- (void)getRed: (float *)red
Index: src/OFCondition.h
==================================================================
--- src/OFCondition.h
+++ src/OFCondition.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -14,12 +12,11 @@
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFMutex.h"
-
-#import "condition.h"
+#import "OFPlainCondition.h"
OF_ASSUME_NONNULL_BEGIN
@class OFDate;
@@ -29,11 +26,11 @@
* @brief A class implementing a condition variable for thread synchronization.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFCondition: OFMutex
{
- of_condition_t _condition;
+ OFPlainCondition _condition;
bool _conditionInitialized;
}
/**
* @brief Creates a new condition.
@@ -72,11 +69,11 @@
* to check the condition again after @ref waitForTimeInterval: returned!
*
* @param timeInterval The time interval until the timeout is reached
* @return Whether the condition has been signaled
*/
-- (bool)waitForTimeInterval: (of_time_interval_t)timeInterval;
+- (bool)waitForTimeInterval: (OFTimeInterval)timeInterval;
#ifdef OF_AMIGAOS
/**
* @brief Blocks the current thread until another thread calls @ref signal,
* @ref broadcast, the timeout is reached or an Exec Signal is received.
@@ -86,11 +83,11 @@
* @param timeInterval The time interval until the timeout is reached
* @param signalMask A pointer to a signal mask of Exec Signals to receive.
* This is modified and set to the mask of signals received.
* @return Whether the condition has been signaled or a signal received
*/
-- (bool)waitForTimeInterval: (of_time_interval_t)timeInterval
+- (bool)waitForTimeInterval: (OFTimeInterval)timeInterval
orExecSignal: (ULONG *)signalMask;
#endif
/**
* @brief Blocks the current thread until another thread calls @ref signal,
@@ -114,12 +111,11 @@
* @param date The date at which the timeout is reached
* @param signalMask A pointer to a signal mask of Exec Signals to receive.
* This is modified and set to the mask of signals received.
* @return Whether the condition has been signaled or a signal received
*/
-- (bool)waitUntilDate: (OFDate *)date
- orExecSignal: (ULONG *)signalMask;
+- (bool)waitUntilDate: (OFDate *)date orExecSignal: (ULONG *)signalMask;
#endif
/**
* @brief Signals the next waiting thread to continue.
*/
Index: src/OFCondition.m
==================================================================
--- src/OFCondition.m
+++ src/OFCondition.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -36,11 +34,11 @@
- (instancetype)init
{
self = [super init];
- if (!of_condition_new(&_condition)) {
+ if (OFPlainConditionNew(&_condition) != 0) {
Class c = self.class;
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
@@ -50,12 +48,14 @@
}
- (void)dealloc
{
if (_conditionInitialized) {
- if (!of_condition_free(&_condition)) {
- OF_ENSURE(errno == EBUSY);
+ int error = OFPlainConditionFree(&_condition);
+
+ if (error != 0) {
+ OFEnsure(error == EBUSY);
@throw [OFConditionStillWaitingException
exceptionWithCondition: self];
}
}
@@ -63,53 +63,61 @@
[super dealloc];
}
- (void)wait
{
- if (!of_condition_wait(&_condition, &_mutex))
+ int error = OFPlainConditionWait(&_condition, &_mutex);
+
+ if (error != 0)
@throw [OFConditionWaitFailedException
exceptionWithCondition: self
- errNo: errno];
+ errNo: error];
}
#ifdef OF_AMIGAOS
- (void)waitForConditionOrExecSignal: (ULONG *)signalMask
{
- if (!of_condition_wait_or_signal(&_condition, &_mutex, signalMask))
+ int error = OFPlainConditionWaitOrExecSignal(&_condition, &_mutex,
+ signalMask);
+
+ if (error != 0)
@throw [OFConditionWaitFailedException
exceptionWithCondition: self
- errNo: errno];
+ errNo: error];
}
#endif
-- (bool)waitForTimeInterval: (of_time_interval_t)timeInterval
-{
- if (!of_condition_timed_wait(&_condition, &_mutex, timeInterval)) {
- if (errno == ETIMEDOUT)
- return false;
- else
- @throw [OFConditionWaitFailedException
- exceptionWithCondition: self
- errNo: errno];
- }
+- (bool)waitForTimeInterval: (OFTimeInterval)timeInterval
+{
+ int error = OFPlainConditionTimedWait(&_condition, &_mutex,
+ timeInterval);
+
+ if (error == ETIMEDOUT)
+ return false;
+
+ if (error != 0)
+ @throw [OFConditionWaitFailedException
+ exceptionWithCondition: self
+ errNo: error];
return true;
}
#ifdef OF_AMIGAOS
-- (bool)waitForTimeInterval: (of_time_interval_t)timeInterval
+- (bool)waitForTimeInterval: (OFTimeInterval)timeInterval
orExecSignal: (ULONG *)signalMask
{
- if (!of_condition_timed_wait_or_signal(&_condition, &_mutex,
- timeInterval, signalMask)) {
- if (errno == ETIMEDOUT)
- return false;
- else
- @throw [OFConditionWaitFailedException
- exceptionWithCondition: self
- errNo: errno];
- }
+ int error = OFPlainConditionTimedWaitOrExecSignal(&_condition, &_mutex,
+ timeInterval, signalMask);
+
+ if (error == ETIMEDOUT)
+ return false;
+
+ if (error != 0)
+ @throw [OFConditionWaitFailedException
+ exceptionWithCondition: self
+ errNo: error];
return true;
}
#endif
@@ -117,29 +125,32 @@
{
return [self waitForTimeInterval: date.timeIntervalSinceNow];
}
#ifdef OF_AMIGAOS
-- (bool)waitUntilDate: (OFDate *)date
- orExecSignal: (ULONG *)signalMask
+- (bool)waitUntilDate: (OFDate *)date orExecSignal: (ULONG *)signalMask
{
return [self waitForTimeInterval: date.timeIntervalSinceNow
orExecSignal: signalMask];
}
#endif
- (void)signal
{
- if (!of_condition_signal(&_condition))
+ int error = OFPlainConditionSignal(&_condition);
+
+ if (error != 0)
@throw [OFConditionSignalFailedException
exceptionWithCondition: self
- errNo: errno];
+ errNo: error];
}
- (void)broadcast
{
- if (!of_condition_broadcast(&_condition))
+ int error = OFPlainConditionBroadcast(&_condition);
+
+ if (error != 0)
@throw [OFConditionBroadcastFailedException
exceptionWithCondition: self
- errNo: errno];
+ errNo: error];
}
@end
Index: src/OFConstantString.h
==================================================================
--- src/OFConstantString.h
+++ src/OFConstantString.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFConstantString.m
==================================================================
--- src/OFConstantString.m
+++ src/OFConstantString.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -52,39 +50,10 @@
+ (instancetype)alloc
{
OF_UNRECOGNIZED_SELECTOR
}
-- (void *)allocMemoryWithSize: (size_t)size
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)allocMemoryWithSize: (size_t)size
- count: (size_t)count
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)resizeMemory: (void *)pointer
- size: (size_t)size
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)resizeMemory: (void *)pointer
- size: (size_t)size
- count: (size_t)count
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void)freeMemory: (void *)pointer
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
- (instancetype)retain
{
return self;
}
@@ -93,11 +62,11 @@
return self;
}
- (unsigned int)retainCount
{
- return OF_RETAIN_COUNT_MAX;
+ return OFMaxRetainCount;
}
- (void)release
{
}
@@ -135,69 +104,36 @@
}
- (void)finishInitialization
{
@synchronized (self) {
- struct of_string_utf8_ivars *ivars;
+ struct OFUTF8StringIvars *ivars;
if ([self isMemberOfClass: [OFConstantUTF8String class]])
return;
- if ((ivars = calloc(1, sizeof(*ivars))) == NULL)
- @throw [OFOutOfMemoryException
- exceptionWithRequestedSize: sizeof(*ivars)];
-
+ ivars = OFAllocZeroedMemory(1, sizeof(*ivars));
ivars->cString = _cString;
ivars->cStringLength = _cStringLength;
- switch (of_string_utf8_check(ivars->cString,
- ivars->cStringLength,
- &ivars->length)) {
- case 1:
- ivars->isUTF8 = true;
- break;
- case -1:
- free(ivars);
- @throw [OFInvalidEncodingException exception];
+ switch (OFUTF8StringCheck(ivars->cString, ivars->cStringLength,
+ &ivars->length)) {
+ case 1:
+ ivars->isUTF8 = true;
+ break;
+ case -1:
+ OFFreeMemory(ivars);
+ @throw [OFInvalidEncodingException exception];
}
_cString = (char *)ivars;
object_setClass(self, [OFConstantUTF8String class]);
}
}
+ (instancetype)alloc
{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)allocMemoryWithSize: (size_t)size
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)allocMemoryWithSize: (size_t)size
- count: (size_t)count
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)resizeMemory: (void *)pointer
- size: (size_t)size
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void *)resizeMemory: (void *)pointer
- size: (size_t)size
- count: (size_t)count
-{
- OF_UNRECOGNIZED_SELECTOR
-}
-
-- (void)freeMemory: (void *)pointer
-{
OF_UNRECOGNIZED_SELECTOR
}
- (instancetype)retain
{
@@ -209,11 +145,11 @@
return self;
}
- (unsigned int)retainCount
{
- return OF_RETAIN_COUNT_MAX;
+ return OFMaxRetainCount;
}
- (void)release
{
}
@@ -230,521 +166,442 @@
/* From protocol OFCopying */
- (id)copy
{
[self finishInitialization];
-
return [self copy];
}
/* From protocol OFMutableCopying */
- (id)mutableCopy
{
[self finishInitialization];
-
return [self mutableCopy];
}
-/* From protocol OFComparing */
-- (of_comparison_result_t)compare: (id )object
+/* From protocol OFComparing, but overridden in OFString */
+- (OFComparisonResult)compare: (OFString *)string
{
[self finishInitialization];
-
- return [self compare: object];
+ return [self compare: string];
}
/* From OFObject, but reimplemented in OFString */
- (bool)isEqual: (id)object
{
[self finishInitialization];
-
return [self isEqual: object];
}
- (unsigned long)hash
{
[self finishInitialization];
-
return self.hash;
}
- (OFString *)description
{
[self finishInitialization];
-
return self.description;
}
/* From OFString */
- (const char *)UTF8String
{
[self finishInitialization];
-
return self.UTF8String;
}
- (size_t)getCString: (char *)cString_
maxLength: (size_t)maxLength
- encoding: (of_string_encoding_t)encoding
+ encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
-
return [self getCString: cString_
maxLength: maxLength
encoding: encoding];
}
-- (const char *)cStringWithEncoding: (of_string_encoding_t)encoding
+- (const char *)cStringWithEncoding: (OFStringEncoding)encoding
{
[self finishInitialization];
-
return [self cStringWithEncoding: encoding];
}
- (size_t)length
{
[self finishInitialization];
-
return self.length;
}
- (size_t)UTF8StringLength
{
[self finishInitialization];
-
return self.UTF8StringLength;
}
-- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
+- (size_t)cStringLengthWithEncoding: (OFStringEncoding)encoding
{
[self finishInitialization];
-
return [self cStringLengthWithEncoding: encoding];
}
-- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString
+- (OFComparisonResult)caseInsensitiveCompare: (OFString *)string
{
[self finishInitialization];
-
- return [self caseInsensitiveCompare: otherString];
+ return [self caseInsensitiveCompare: string];
}
-- (of_unichar_t)characterAtIndex: (size_t)idx
+- (OFUnichar)characterAtIndex: (size_t)idx
{
[self finishInitialization];
-
return [self characterAtIndex: idx];
}
-- (void)getCharacters: (of_unichar_t *)buffer
- inRange: (of_range_t)range
+- (void)getCharacters: (OFUnichar *)buffer inRange: (OFRange)range
{
[self finishInitialization];
-
- [self getCharacters: buffer
- inRange: range];
+ [self getCharacters: buffer inRange: range];
}
-- (of_range_t)rangeOfString: (OFString *)string
+- (OFRange)rangeOfString: (OFString *)string
{
[self finishInitialization];
-
return [self rangeOfString: string];
}
-- (of_range_t)rangeOfString: (OFString *)string
- options: (int)options
-{
- [self finishInitialization];
-
- return [self rangeOfString: string
- options: options];
-}
-
-- (of_range_t)rangeOfString: (OFString *)string
- options: (int)options
- range: (of_range_t)range
-{
- [self finishInitialization];
-
- return [self rangeOfString: string
- options: options
- range: range];
+- (OFRange)rangeOfString: (OFString *)string
+ options: (OFStringSearchOptions)options
+{
+ [self finishInitialization];
+ return [self rangeOfString: string options: options];
+}
+
+- (OFRange)rangeOfString: (OFString *)string
+ options: (OFStringSearchOptions)options
+ range: (OFRange)range
+{
+ [self finishInitialization];
+ return [self rangeOfString: string options: options range: range];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
{
[self finishInitialization];
-
return [self indexOfCharacterFromSet: characterSet];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
- options: (int)options
+ options: (OFStringSearchOptions)options
{
[self finishInitialization];
-
- return [self indexOfCharacterFromSet: characterSet
- options: options];
+ return [self indexOfCharacterFromSet: characterSet options: options];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
- options: (int)options
- range: (of_range_t)range
+ options: (OFStringSearchOptions)options
+ range: (OFRange)range
{
[self finishInitialization];
-
return [self indexOfCharacterFromSet: characterSet
options: options
range: range];
}
- (bool)containsString: (OFString *)string
{
[self finishInitialization];
-
return [self containsString: string];
}
- (OFString *)substringFromIndex: (size_t)idx
{
[self finishInitialization];
-
return [self substringFromIndex: idx];
}
- (OFString *)substringToIndex: (size_t)idx
{
[self finishInitialization];
-
return [self substringToIndex: idx];
}
-- (OFString *)substringWithRange: (of_range_t)range
+- (OFString *)substringWithRange: (OFRange)range
{
[self finishInitialization];
-
return [self substringWithRange: range];
}
- (OFString *)stringByAppendingString: (OFString *)string
{
[self finishInitialization];
-
return [self stringByAppendingString: string];
}
- (OFString *)stringByAppendingFormat: (OFConstantString *)format
arguments: (va_list)arguments
{
[self finishInitialization];
-
- return [self stringByAppendingFormat: format
- arguments: arguments];
+ return [self stringByAppendingFormat: format arguments: arguments];
}
- (OFString *)stringByAppendingPathComponent: (OFString *)component
{
[self finishInitialization];
-
return [self stringByAppendingPathComponent: component];
}
- (OFString *)stringByPrependingString: (OFString *)string
{
[self finishInitialization];
-
return [self stringByPrependingString: string];
}
- (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string
withString: (OFString *)replacement
{
[self finishInitialization];
-
return [self stringByReplacingOccurrencesOfString: string
withString: replacement];
}
- (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string
withString: (OFString *)replacement
options: (int)options
- range: (of_range_t)range
+ range: (OFRange)range
{
[self finishInitialization];
-
return [self stringByReplacingOccurrencesOfString: string
withString: replacement
options: options
range: range];
}
- (OFString *)uppercaseString
{
[self finishInitialization];
-
return self.uppercaseString;
}
- (OFString *)lowercaseString
{
[self finishInitialization];
-
return self.lowercaseString;
}
- (OFString *)capitalizedString
{
[self finishInitialization];
-
return self.capitalizedString;
}
- (OFString *)stringByDeletingLeadingWhitespaces
{
[self finishInitialization];
-
return self.stringByDeletingLeadingWhitespaces;
}
- (OFString *)stringByDeletingTrailingWhitespaces
{
[self finishInitialization];
-
return self.stringByDeletingTrailingWhitespaces;
}
- (OFString *)stringByDeletingEnclosingWhitespaces
{
[self finishInitialization];
-
return self.stringByDeletingEnclosingWhitespaces;
}
- (bool)hasPrefix: (OFString *)prefix
{
[self finishInitialization];
-
return [self hasPrefix: prefix];
}
- (bool)hasSuffix: (OFString *)suffix
{
[self finishInitialization];
-
return [self hasSuffix: suffix];
}
- (OFArray *)componentsSeparatedByString: (OFString *)delimiter
{
[self finishInitialization];
-
return [self componentsSeparatedByString: delimiter];
}
- (OFArray *)componentsSeparatedByString: (OFString *)delimiter
- options: (int)options
+ options: (OFStringSeparationOptions)options
{
[self finishInitialization];
-
- return [self componentsSeparatedByString: delimiter
- options: options];
+ return [self componentsSeparatedByString: delimiter options: options];
}
- (OFArray *)
componentsSeparatedByCharactersInSet: (OFCharacterSet *)characterSet
{
[self finishInitialization];
-
return [self componentsSeparatedByCharactersInSet: characterSet];
}
- (OFArray *)
componentsSeparatedByCharactersInSet: (OFCharacterSet *)characterSet
- options: (int)options
+ options: (OFStringSeparationOptions)options
{
[self finishInitialization];
-
return [self componentsSeparatedByCharactersInSet: characterSet
options: options];
}
- (OFArray *)pathComponents
{
[self finishInitialization];
-
return self.pathComponents;
}
- (OFString *)lastPathComponent
{
[self finishInitialization];
-
return self.lastPathComponent;
}
- (OFString *)stringByDeletingLastPathComponent
{
[self finishInitialization];
-
return self.stringByDeletingLastPathComponent;
}
- (long long)longLongValue
{
[self finishInitialization];
-
return self.longLongValue;
}
- (long long)longLongValueWithBase: (int)base
{
[self finishInitialization];
-
return [self longLongValueWithBase: base];
}
- (unsigned long long)unsignedLongLongValue
{
[self finishInitialization];
-
return self.unsignedLongLongValue;
}
- (unsigned long long)unsignedLongLongValueWithBase: (int)base
{
[self finishInitialization];
-
return [self unsignedLongLongValueWithBase: base];
}
- (float)floatValue
{
[self finishInitialization];
-
return self.floatValue;
}
- (double)doubleValue
{
[self finishInitialization];
-
return self.doubleValue;
}
-- (const of_unichar_t *)characters
+- (const OFUnichar *)characters
{
[self finishInitialization];
-
return self.characters;
}
-- (const of_char16_t *)UTF16String
+- (const OFChar16 *)UTF16String
{
[self finishInitialization];
-
return self.UTF16String;
}
-- (const of_char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder
+- (const OFChar16 *)UTF16StringWithByteOrder: (OFByteOrder)byteOrder
{
[self finishInitialization];
-
return [self UTF16StringWithByteOrder: byteOrder];
}
- (size_t)UTF16StringLength
{
[self finishInitialization];
-
return self.UTF16StringLength;
}
-- (const of_char32_t *)UTF32String
+- (const OFChar32 *)UTF32String
{
[self finishInitialization];
-
return self.UTF32String;
}
-- (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
+- (const OFChar32 *)UTF32StringWithByteOrder: (OFByteOrder)byteOrder
{
[self finishInitialization];
-
return [self UTF32StringWithByteOrder: byteOrder];
}
-- (OFData *)dataWithEncoding: (of_string_encoding_t)encoding
+- (OFData *)dataWithEncoding: (OFStringEncoding)encoding
{
[self finishInitialization];
-
return [self dataWithEncoding: encoding];
}
#ifdef OF_HAVE_UNICODE_TABLES
- (OFString *)decomposedStringWithCanonicalMapping
{
[self finishInitialization];
-
return self.decomposedStringWithCanonicalMapping;
}
- (OFString *)decomposedStringWithCompatibilityMapping
{
[self finishInitialization];
-
return self.decomposedStringWithCompatibilityMapping;
}
#endif
#ifdef OF_WINDOWS
- (OFString *)stringByExpandingWindowsEnvironmentStrings
{
[self finishInitialization];
-
return self.stringByExpandingWindowsEnvironmentStrings;
}
#endif
#ifdef OF_HAVE_FILES
- (void)writeToFile: (OFString *)path
{
[self finishInitialization];
-
[self writeToFile: path];
}
-- (void)writeToFile: (OFString *)path
- encoding: (of_string_encoding_t)encoding
+- (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
-
- [self writeToFile: path
- encoding: encoding];
+ [self writeToFile: path encoding: encoding];
}
#endif
- (void)writeToURL: (OFURL *)URL
{
[self finishInitialization];
-
[self writeToURL: URL];
}
-- (void)writeToURL: (OFURL *)URL
- encoding: (of_string_encoding_t)encoding
+- (void)writeToURL: (OFURL *)URL encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
-
- [self writeToURL: URL
- encoding: encoding];
+ [self writeToURL: URL encoding: encoding];
}
#ifdef OF_HAVE_BLOCKS
-- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block
+- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block
{
[self finishInitialization];
-
[self enumerateLinesUsingBlock: block];
}
#endif
@end
Index: src/OFCountedMapTableSet.h
==================================================================
--- src/OFCountedMapTableSet.h
+++ src/OFCountedMapTableSet.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
Index: src/OFCountedMapTableSet.m
==================================================================
--- src/OFCountedMapTableSet.m
+++ src/OFCountedMapTableSet.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -43,11 +41,11 @@
@try {
void *pool = objc_autoreleasePoolPush();
if ([set isKindOfClass: [OFCountedSet class]]) {
- OFCountedSet *countedSet = (OFCountedSet *)countedSet;
+ OFCountedSet *countedSet = (OFCountedSet *)set;
for (id object in countedSet) {
size_t count =
[countedSet countForObject: object];
@@ -83,12 +81,11 @@
}
return self;
}
-- (instancetype)initWithObjects: (id const *)objects
- count: (size_t)count
+- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
self = [self init];
@try {
for (size_t i = 0; i < count; i++)
@@ -99,12 +96,11 @@
}
return self;
}
-- (instancetype)initWithObject: (id)firstObject
- arguments: (va_list)arguments
+- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
self = [self init];
@try {
id object;
@@ -127,23 +123,23 @@
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: @"OFCountedSet"] ||
- ![element.namespace isEqual: OF_SERIALIZATION_NS])
+ ![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *objectElement in
[element elementsForName: @"object"
- namespace: OF_SERIALIZATION_NS]) {
+ namespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *object;
OFXMLAttribute *countAttribute;
unsigned long long count;
object = [objectElement elementsForNamespace:
- OF_SERIALIZATION_NS].firstObject;
+ OFSerializationNS].firstObject;
countAttribute =
[objectElement attributeForName: @"count"];
if (object == nil || countAttribute == nil)
@throw [OFInvalidFormatException exception];
@@ -171,12 +167,11 @@
{
return (size_t)(uintptr_t)[_mapTable objectForKey: object];
}
#ifdef OF_HAVE_BLOCKS
-- (void)enumerateObjectsAndCountUsingBlock:
- (of_counted_set_enumeration_block_t)block
+- (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block
{
@try {
[_mapTable enumerateKeysAndObjectsUsingBlock:
^ (void *key, void *object, bool *stop) {
block(key, (size_t)(uintptr_t)object, stop);
@@ -193,12 +188,11 @@
size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object];
if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1)
@throw [OFOutOfRangeException exception];
- [_mapTable setObject: (void *)(uintptr_t)(count + 1)
- forKey: object];
+ [_mapTable setObject: (void *)(uintptr_t)(count + 1) forKey: object];
}
- (void)removeObject: (id)object
{
size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object];
@@ -207,12 +201,11 @@
return;
count--;
if (count > 0)
- [_mapTable setObject: (void *)(uintptr_t)count
- forKey: object];
+ [_mapTable setObject: (void *)(uintptr_t)count forKey: object];
else
[_mapTable removeObjectForKey: object];
}
- (void)removeAllObjects
Index: src/OFCountedSet.h
==================================================================
--- src/OFCountedSet.h
+++ src/OFCountedSet.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -28,11 +26,11 @@
* @param object The current object
* @param count The count of the object
* @param stop A pointer to a variable that can be set to true to stop the
* enumeration
*/
-typedef void (^of_counted_set_enumeration_block_t)(id object, size_t count,
+typedef void (^OFCountedSetEnumerationBlock)(id object, size_t count,
bool *stop);
#endif
/**
* @class OFCountedSet OFCountedSet.h ObjFW/OFCountedSet.h
@@ -59,14 +57,13 @@
/**
* @brief Executes a block for each object in the set.
*
* @param block The block to execute for each object in the set
*/
-- (void)enumerateObjectsAndCountUsingBlock:
- (of_counted_set_enumeration_block_t)block;
+- (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block;
#endif
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# undef ObjectType
#endif
@end
OF_ASSUME_NONNULL_END
Index: src/OFCountedSet.m
==================================================================
--- src/OFCountedSet.m
+++ src/OFCountedSet.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -59,19 +57,17 @@
va_end(arguments);
return ret;
}
-- (instancetype)initWithObjects: (id const *)objects
- count: (size_t)count
+- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
return (id)[[OFCountedMapTableSet alloc] initWithObjects: objects
count: count];
}
-- (instancetype)initWithObject: (id)firstObject
- arguments: (va_list)arguments
+- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
return (id)[[OFCountedMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
@@ -160,14 +156,12 @@
if (++i < count)
[ret appendString: @",\n"];
objc_autoreleasePoolPop(pool2);
}
- [ret replaceOccurrencesOfString: @"\n"
- withString: @"\n\t"];
+ [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"];
[ret appendString: @"\n)}"];
-
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
@@ -187,11 +181,11 @@
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"OFCountedSet"
- namespace: OF_SERIALIZATION_NS];
+ namespace: OFSerializationNS];
for (id object in self) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *objectElement;
@@ -201,11 +195,11 @@
[OFString stringWithFormat: @"%zu",
[self countForObject: object]];
objectElement = [OFXMLElement
elementWithName: @"object"
- namespace: OF_SERIALIZATION_NS];
+ namespace: OFSerializationNS];
[objectElement addAttributeWithName: @"count"
stringValue: count];
[objectElement addChild: object.XMLElementBySerializing];
[element addChild: objectElement];
@@ -218,12 +212,11 @@
return [element autorelease];
}
#ifdef OF_HAVE_BLOCKS
-- (void)enumerateObjectsAndCountUsingBlock:
- (of_counted_set_enumeration_block_t)block
+- (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block
{
[self enumerateObjectsUsingBlock: ^ (id object, bool *stop) {
block(object, [self countForObject: object], stop);
}];
}
DELETED src/OFCryptoHash.h
Index: src/OFCryptoHash.h
==================================================================
--- src/OFCryptoHash.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFObject.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-/**
- * @protocol OFCryptoHash OFCryptoHash.h ObjFW/OFCryptoHash.h
- *
- * @brief A protocol for classes providing cryptographic hash functions.
- *
- * A cryptographic hash implementing this protocol can be copied. The entire
- * state is copied, allowing to calculate a new hash from there. This is
- * especially useful for generating many hashes with a common prefix.
- */
-@protocol OFCryptoHash
-#ifdef OF_HAVE_CLASS_PROPERTIES
-@property (class, readonly, nonatomic) size_t digestSize;
-@property (class, readonly, nonatomic) size_t blockSize;
-#endif
-
-/**
- * @brief The digest size of the cryptographic hash, in bytes.
- */
-@property (readonly, nonatomic) size_t digestSize;
-
-/**
- * @brief The block size of the cryptographic hash, in bytes.
- */
-@property (readonly, nonatomic) size_t blockSize;
-
-/**
- * @brief Whether data may be stored in swappable memory.
- */
-@property (readonly, nonatomic) bool allowsSwappableMemory;
-
-/**
- * @brief A boolean whether the hash has already been calculated.
- */
-@property (readonly, nonatomic, getter=isCalculated) bool calculated;
-
-/**
- * @brief A buffer containing the cryptographic hash.
- *
- * The size of the buffer depends on the hash used. The buffer is part of the
- * receiver's memory pool.
- */
-@property (readonly, nonatomic) const unsigned char *digest
- OF_RETURNS_INNER_POINTER;
-
-/**
- * @brief Creates a new cryptographic hash.
- *
- * @return A new autoreleased cryptographic hash
- */
-+ (instancetype)cryptoHashWithAllowsSwappableMemory:
- (bool)allowsSwappableMemory;
-
-/**
- * @brief Returns the digest size of the cryptographic hash, in bytes.
- *
- * @return The digest size of the cryptographic hash, in bytes
- */
-+ (size_t)digestSize;
-
-/**
- * @brief Returns the block size of the cryptographic hash, in bytes.
- *
- * @return The block size of the cryptographic hash, in bytes
- */
-+ (size_t)blockSize;
-
-/**
- * @brief Initializes an already allocated cryptographic hash.
- *
- * @return An initialized cryptographic hash
- */
-- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory;
-
-- (instancetype)init OF_UNAVAILABLE;
-
-/**
- * @brief Adds a buffer to the cryptographic hash to be calculated.
- *
- * @param buffer The buffer which should be included into the calculation
- * @param length The length of the buffer
- */
-- (void)updateWithBuffer: (const void *)buffer
- length: (size_t)length;
-
-/**
- * @brief Resets all state so that a new hash can be calculated.
- *
- * @warning This invalidates any pointer previously returned by @ref digest. If
- * you are still interested in the previous digest, you need to memcpy
- * it yourself before calling @ref reset!
- */
-- (void)reset;
-@end
-
-OF_ASSUME_NONNULL_END
ADDED src/OFCryptographicHash.h
Index: src/OFCryptographicHash.h
==================================================================
--- /dev/null
+++ src/OFCryptographicHash.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2008-2022 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFObject.h"
+
+OF_ASSUME_NONNULL_BEGIN
+
+/**
+ * @protocol OFCryptographicHash \
+ * OFCryptographicHash.h ObjFW/OFCryptographicHash.h
+ *
+ * @brief A protocol for classes providing cryptographic hash functions.
+ *
+ * A cryptographic hash implementing this protocol can be copied. The entire
+ * state is copied, allowing to calculate a new hash from there. This is
+ * especially useful for generating many hashes with a common prefix.
+ */
+@protocol OFCryptographicHash
+#ifdef OF_HAVE_CLASS_PROPERTIES
+@property (class, readonly, nonatomic) size_t digestSize;
+@property (class, readonly, nonatomic) size_t blockSize;
+#endif
+
+/**
+ * @brief The digest size of the cryptographic hash, in bytes.
+ */
+@property (readonly, nonatomic) size_t digestSize;
+
+/**
+ * @brief The block size of the cryptographic hash, in bytes.
+ */
+@property (readonly, nonatomic) size_t blockSize;
+
+/**
+ * @brief Whether data may be stored in swappable memory.
+ */
+@property (readonly, nonatomic) bool allowsSwappableMemory;
+
+/**
+ * @brief A boolean whether the hash has already been calculated.
+ */
+@property (readonly, nonatomic, getter=isCalculated) bool calculated;
+
+/**
+ * @brief A buffer containing the cryptographic hash.
+ *
+ * The size of the buffer depends on the hash used. The buffer is part of the
+ * receiver's memory pool.
+ */
+@property (readonly, nonatomic) const unsigned char *digest
+ OF_RETURNS_INNER_POINTER;
+
+/**
+ * @brief Creates a new cryptographic hash.
+ *
+ * @return A new autoreleased cryptographic hash
+ */
++ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory;
+
+/**
+ * @brief Returns the digest size of the cryptographic hash, in bytes.
+ *
+ * @return The digest size of the cryptographic hash, in bytes
+ */
++ (size_t)digestSize;
+
+/**
+ * @brief Returns the block size of the cryptographic hash, in bytes.
+ *
+ * @return The block size of the cryptographic hash, in bytes
+ */
++ (size_t)blockSize;
+
+/**
+ * @brief Initializes an already allocated cryptographic hash.
+ *
+ * @return An initialized cryptographic hash
+ */
+- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory;
+
+- (instancetype)init OF_UNAVAILABLE;
+
+/**
+ * @brief Adds a buffer to the cryptographic hash to be calculated.
+ *
+ * @param buffer The buffer which should be included into the calculation
+ * @param length The length of the buffer
+ */
+- (void)updateWithBuffer: (const void *)buffer length: (size_t)length;
+
+/**
+ * @brief Performs the final calculation of the cryptographic hash.
+ */
+- (void)calculate;
+
+/**
+ * @brief Resets all state so that a new hash can be calculated.
+ *
+ * @warning This invalidates any pointer previously returned by @ref digest. If
+ * you are still interested in the previous digest, you need to memcpy
+ * it yourself before calling @ref reset!
+ */
+- (void)reset;
+@end
+
+OF_ASSUME_NONNULL_END
Index: src/OFDNSQuery.h
==================================================================
--- src/OFDNSQuery.h
+++ src/OFDNSQuery.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -28,12 +26,12 @@
* @brief A class representing a DNS query.
*/
@interface OFDNSQuery: OFObject
{
OFString *_domainName;
- of_dns_class_t _DNSClass;
- of_dns_record_type_t _recordType;
+ OFDNSClass _DNSClass;
+ OFDNSRecordType _recordType;
OF_RESERVE_IVARS(OFDNSQuery, 4)
}
/**
* @brief The domain name of the query.
@@ -41,16 +39,16 @@
@property (readonly, nonatomic) OFString *domainName;
/**
* @brief The DNS class of the query.
*/
-@property (readonly, nonatomic) of_dns_class_t DNSClass;
+@property (readonly, nonatomic) OFDNSClass DNSClass;
/**
* @brief The record type of the query.
*/
-@property (readonly, nonatomic) of_dns_record_type_t recordType;
+@property (readonly, nonatomic) OFDNSRecordType recordType;
/**
* @brief Creates a new, autoreleased OFDNSQuery.
*
* @param domainName The domain name to query
@@ -57,12 +55,12 @@
* @param DNSClass The DNS class of the query
* @param recordType The record type of the query
* @return A new, autoreleased OFDNSQuery
*/
+ (instancetype)queryWithDomainName: (OFString *)domainName
- DNSClass: (of_dns_class_t)DNSClass
- recordType: (of_dns_record_type_t)recordType;
+ DNSClass: (OFDNSClass)DNSClass
+ recordType: (OFDNSRecordType)recordType;
/**
* @brief Initializes an already allocated OFDNSQuery.
*
* @param domainName The domain name to query
@@ -69,13 +67,13 @@
* @param DNSClass The DNS class of the query
* @param recordType The record type of the query
* @return An initialized OFDNSQuery
*/
- (instancetype)initWithDomainName: (OFString *)domainName
- DNSClass: (of_dns_class_t)DNSClass
- recordType: (of_dns_record_type_t)recordType
+ DNSClass: (OFDNSClass)DNSClass
+ recordType: (OFDNSRecordType)recordType
OF_DESIGNATED_INITIALIZER;
- (instancetype)init OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
Index: src/OFDNSQuery.m
==================================================================
--- src/OFDNSQuery.m
+++ src/OFDNSQuery.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -23,21 +21,21 @@
@implementation OFDNSQuery
@synthesize domainName = _domainName, DNSClass = _DNSClass;
@synthesize recordType = _recordType;
+ (instancetype)queryWithDomainName: (OFString *)domainName
- DNSClass: (of_dns_class_t)DNSClass
- recordType: (of_dns_record_type_t)recordType
+ DNSClass: (OFDNSClass)DNSClass
+ recordType: (OFDNSRecordType)recordType
{
return [[[self alloc] initWithDomainName: domainName
DNSClass: DNSClass
recordType: recordType] autorelease];
}
- (instancetype)initWithDomainName: (OFString *)domainName
- DNSClass: (of_dns_class_t)DNSClass
- recordType: (of_dns_record_type_t)recordType
+ DNSClass: (OFDNSClass)DNSClass
+ recordType: (OFDNSRecordType)recordType
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
@@ -93,17 +91,17 @@
return true;
}
- (unsigned long)hash
{
- uint32_t hash;
+ unsigned long hash;
- OF_HASH_INIT(hash);
- OF_HASH_ADD_HASH(hash, _domainName.hash);
- OF_HASH_ADD(hash, _DNSClass);
- OF_HASH_ADD(hash, _recordType);
- OF_HASH_FINALIZE(hash);
+ OFHashInit(&hash);
+ OFHashAddHash(&hash, _domainName.hash);
+ OFHashAdd(&hash, _DNSClass);
+ OFHashAdd(&hash, _recordType);
+ OFHashFinalize(&hash);
return hash;
}
- (id)copy
@@ -112,9 +110,9 @@
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@ %@ %@ %@>",
- self.className, _domainName, of_dns_class_to_string(_DNSClass),
- of_dns_record_type_to_string(_recordType)];
+ self.className, _domainName, OFDNSClassName(_DNSClass),
+ OFDNSRecordTypeName(_recordType)];
}
@end
Index: src/OFDNSResolver.h
==================================================================
--- src/OFDNSResolver.h
+++ src/OFDNSResolver.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -22,11 +20,11 @@
#import "OFRunLoop.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
-#define OF_DNS_RESOLVER_BUFFER_LENGTH 512
+#define OFDNSResolverBufferLength 512
@class OFArray OF_GENERIC(ObjectType);
@class OFDNSResolver;
@class OFDNSResolverContext;
@class OFDNSResolverSettings;
@@ -36,41 +34,41 @@
@class OFNumber;
@class OFTCPSocket;
@class OFUDPSocket;
/**
- * @enum of_dns_resolver_error_t OFDNSResolver.h ObjFW/OFDNSResolver.h
+ * @enum OFDNSResolverErrorCode OFDNSResolver.h ObjFW/OFDNSResolver.h
*
* @brief An enum describing why resolving a host failed.
*/
-typedef enum of_dns_resolver_error_t {
+typedef enum {
/** An unknown error */
- OF_DNS_RESOLVER_ERROR_UNKNOWN,
+ OFDNSResolverErrorCodeUnknown,
/** The query timed out */
- OF_DNS_RESOLVER_ERROR_TIMEOUT,
+ OFDNSResolverErrorCodeTimeout,
/** The query was canceled */
- OF_DNS_RESOLVER_ERROR_CANCELED,
+ OFDNSResolverErrorCodeCanceled,
/**
* No result for the specified host with the specified type and class.
*
* This is only used in situations where this is an error, e.g. when
* trying to connect to a host.
*/
- OF_DNS_RESOLVER_ERROR_NO_RESULT,
+ OFDNSResolverErrorCodeNoResult,
/** The server considered the query to be malformed */
- OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT,
+ OFDNSResolverErrorCodeServerInvalidFormat,
/** The server was unable to process due to an internal error */
- OF_DNS_RESOLVER_ERROR_SERVER_FAILURE,
+ OFDNSResolverErrorCodeServerFailure,
/** The server returned an error that the domain does not exist */
- OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR,
+ OFDNSResolverErrorCodeServerNameError,
/** The server does not have support for the requested query */
- OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED,
+ OFDNSResolverErrorCodeServerNotImplemented,
/** The server refused the query */
- OF_DNS_RESOLVER_ERROR_SERVER_REFUSED,
+ OFDNSResolverErrorCodeServerRefused,
/** There was no name server to query */
- OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER
-} of_dns_resolver_error_t;
+ OFDNSResolverErrorCodeNoNameServer
+} OFDNSResolverErrorCode;
/**
* @protocol OFDNSResolverQueryDelegate OFDNSResolver.h ObjFW/OFDNSResolver.h
*
* @brief A delegate for performed DNS queries.
@@ -101,11 +99,11 @@
* @brief This method is called when a DNS resolver resolved a host to
* addresses.
*
* @param resolver The acting resolver
* @param host The host the resolver resolved
- * @param addresses OFData containing several of_socket_address_t
+ * @param addresses OFData containing several OFSocketAddress
* @param exception The exception that occurred during resolving, or nil on
* success
*/
- (void)resolver: (OFDNSResolver *)resolver
didResolveHost: (OFString *)host
@@ -129,11 +127,11 @@
OFDNSResolverSettings *_settings;
OFUDPSocket *_IPv4Socket;
#ifdef OF_HAVE_IPV6
OFUDPSocket *_IPv6Socket;
#endif
- char _buffer[OF_DNS_RESOLVER_BUFFER_LENGTH];
+ char _buffer[OFDNSResolverBufferLength];
OFMutableDictionary OF_GENERIC(OFNumber *, OFDNSResolverContext *)
*_queries;
OFMutableDictionary OF_GENERIC(OFTCPSocket *, OFDNSResolverContext *)
*_TCPQueries;
}
@@ -165,11 +163,11 @@
/**
* @brief The timeout, in seconds, after which the next name server should be
* tried.
*/
-@property (nonatomic) of_time_interval_t timeout;
+@property (nonatomic) OFTimeInterval timeout;
/**
* @brief The number of attempts before giving up to resolve a host.
*
* Trying all name servers once is considered a single attempt.
@@ -189,11 +187,11 @@
/**
* @brief The interval in seconds in which the config should be reloaded.
*
* Setting this to 0 disables config reloading.
*/
-@property (nonatomic) of_time_interval_t configReloadInterval;
+@property (nonatomic) OFTimeInterval configReloadInterval;
/**
* @brief Creates a new, autoreleased OFDNSResolver.
*/
+ (instancetype)resolver;
@@ -218,11 +216,11 @@
* @param query The query to perform
* @param runLoopMode The run loop mode in which to resolve
* @param delegate The delegate to use for callbacks
*/
- (void)asyncPerformQuery: (OFDNSQuery *)query
- runLoopMode: (of_run_loop_mode_t)runLoopMode
+ runLoopMode: (OFRunLoopMode)runLoopMode
delegate: (id )delegate;
/**
* @brief Asynchronously resolves the specified host to socket addresses.
*
@@ -238,11 +236,11 @@
* @param host The host to resolve
* @param addressFamily The desired socket address family
* @param delegate The delegate to use for callbacks
*/
- (void)asyncResolveAddressesForHost: (OFString *)host
- addressFamily: (of_socket_address_family_t)addressFamily
+ addressFamily: (OFSocketAddressFamily)addressFamily
delegate: (id )delegate;
/**
* @brief Asynchronously resolves the specified host to socket addresses.
*
@@ -250,26 +248,26 @@
* @param addressFamily The desired socket address family
* @param runLoopMode The run loop mode in which to resolve
* @param delegate The delegate to use for callbacks
*/
- (void)asyncResolveAddressesForHost: (OFString *)host
- addressFamily: (of_socket_address_family_t)addressFamily
- runLoopMode: (of_run_loop_mode_t)runLoopMode
+ addressFamily: (OFSocketAddressFamily)addressFamily
+ runLoopMode: (OFRunLoopMode)runLoopMode
delegate: (id )delegate;
/**
* @brief Synchronously resolves the specified host to socket addresses.
*
* @param host The host to resolve
* @param addressFamily The desired socket address family
- * @return OFData containing several of_socket_address_t
+ * @return OFData containing several OFSocketAddress
*/
- (OFData *)resolveAddressesForHost: (OFString *)host
- addressFamily: (of_socket_address_family_t)addressFamily;
+ addressFamily: (OFSocketAddressFamily)addressFamily;
/**
* @brief Closes all sockets and cancels all ongoing queries.
*/
- (void)close;
@end
OF_ASSUME_NONNULL_END
Index: src/OFDNSResolver.m
==================================================================
--- src/OFDNSResolver.m
+++ src/OFDNSResolver.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -39,29 +37,28 @@
#import "OFDNSQueryFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidServerReplyException.h"
+#import "OFNotImplementedException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#ifndef SOCK_DNS
# define SOCK_DNS 0
#endif
-#define BUFFER_LENGTH OF_DNS_RESOLVER_BUFFER_LENGTH
-#define MAX_DNS_RESPONSE_LENGTH 65536
+static const size_t bufferLength = OFDNSResolverBufferLength;
+static const size_t maxDNSResponseLength = 65536;
/*
* RFC 1035 doesn't specify if pointers to pointers are allowed, and if so how
* many. Since it's unspecified, we have to assume that it might happen, but we
* also want to limit it to avoid DoS. Limiting it to 16 levels of pointers and
* immediately rejecting pointers to itself seems like a fair balance.
*/
-#define MAX_ALLOWED_POINTERS 16
-
-#define CNAME_RECURSION 3
+static const uint_fast8_t maxAllowedPointers = 16;
@interface OFDNSResolver ()
- (void)of_contextTimedOut: (OFDNSResolverContext *)context;
@end
@@ -74,11 +71,11 @@
OFDNSResolverSettings *_settings;
size_t _nameServersIndex;
unsigned int _attempt;
id _delegate;
OFData *_queryData;
- of_socket_address_t _usedNameServer;
+ OFSocketAddress _usedNameServer;
OFTCPSocket *_TCPSocket;
OFMutableData *_TCPQueryData;
void *_TCPBuffer;
size_t _responseLength;
OFTimer *_cancelTimer;
@@ -168,70 +165,70 @@
return [components componentsJoinedByString: @"."];
}
static OF_KINDOF(OFDNSResourceRecord *)
-parseResourceRecord(OFString *name, of_dns_class_t DNSClass,
- of_dns_record_type_t recordType, uint32_t TTL, const unsigned char *buffer,
+parseResourceRecord(OFString *name, OFDNSClass DNSClass,
+ OFDNSRecordType recordType, uint32_t TTL, const unsigned char *buffer,
size_t length, size_t i, uint16_t dataLength)
{
- if (recordType == OF_DNS_RECORD_TYPE_A && DNSClass == OF_DNS_CLASS_IN) {
- of_socket_address_t address;
+ if (recordType == OFDNSRecordTypeA && DNSClass == OFDNSClassIN) {
+ OFSocketAddress address;
if (dataLength != 4)
@throw [OFInvalidServerReplyException exception];
memset(&address, 0, sizeof(address));
- address.family = OF_SOCKET_ADDRESS_FAMILY_IPV4;
+ address.family = OFSocketAddressFamilyIPv4;
address.length = sizeof(address.sockaddr.in);
address.sockaddr.in.sin_family = AF_INET;
memcpy(&address.sockaddr.in.sin_addr.s_addr, buffer + i, 4);
return [[[OFADNSResourceRecord alloc]
initWithName: name
address: &address
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_NS) {
+ } else if (recordType == OFDNSRecordTypeNS) {
size_t j = i;
OFString *authoritativeHost = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
if (j != i + dataLength)
@throw [OFInvalidServerReplyException exception];
return [[[OFNSDNSResourceRecord alloc]
initWithName: name
DNSClass: DNSClass
authoritativeHost: authoritativeHost
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_CNAME) {
+ } else if (recordType == OFDNSRecordTypeCNAME) {
size_t j = i;
OFString *alias = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
if (j != i + dataLength)
@throw [OFInvalidServerReplyException exception];
return [[[OFCNAMEDNSResourceRecord alloc]
initWithName: name
DNSClass: DNSClass
alias: alias
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_SOA) {
+ } else if (recordType == OFDNSRecordTypeSOA) {
size_t j = i;
OFString *primaryNameServer = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
OFString *responsiblePerson;
uint32_t serialNumber, refreshInterval, retryInterval;
uint32_t expirationInterval, minTTL;
if (j > i + dataLength)
@throw [OFInvalidServerReplyException exception];
responsiblePerson = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
if (dataLength - (j - i) != 20)
@throw [OFInvalidServerReplyException exception];
serialNumber = (buffer[j] << 24) | (buffer[j + 1] << 16) |
@@ -256,24 +253,24 @@
refreshInterval: refreshInterval
retryInterval: retryInterval
expirationInterval: expirationInterval
minTTL: minTTL
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_PTR) {
+ } else if (recordType == OFDNSRecordTypePTR) {
size_t j = i;
OFString *domainName = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
if (j != i + dataLength)
@throw [OFInvalidServerReplyException exception];
return [[[OFPTRDNSResourceRecord alloc]
initWithName: name
DNSClass: DNSClass
domainName: domainName
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_HINFO) {
+ } else if (recordType == OFDNSRecordTypeHINFO) {
size_t j = i;
OFString *CPU = parseString(buffer, length, &j);
OFString *OS;
if (j > i + dataLength)
@@ -288,11 +285,11 @@
initWithName: name
DNSClass: DNSClass
CPU: CPU
OS: OS
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_MX) {
+ } else if (recordType == OFDNSRecordTypeMX) {
uint16_t preference;
size_t j;
OFString *mailExchange;
if (dataLength < 2)
@@ -300,11 +297,11 @@
preference = (buffer[i] << 8) | buffer[i + 1];
j = i + 2;
mailExchange = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
if (j != i + dataLength)
@throw [OFInvalidServerReplyException exception];
return [[[OFMXDNSResourceRecord alloc]
@@ -311,11 +308,11 @@
initWithName: name
DNSClass: DNSClass
preference: preference
mailExchange: mailExchange
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_TXT) {
+ } else if (recordType == OFDNSRecordTypeTXT) {
OFMutableArray *textStrings = [OFMutableArray array];
while (dataLength > 0) {
uint_fast8_t stringLength = buffer[i++];
dataLength--;
@@ -337,21 +334,21 @@
return [[[OFTXTDNSResourceRecord alloc]
initWithName: name
DNSClass: DNSClass
textStrings: textStrings
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_RP) {
+ } else if (recordType == OFDNSRecordTypeRP) {
size_t j = i;
OFString *mailbox = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
OFString *TXTDomainName;
if (j > i + dataLength)
@throw [OFInvalidServerReplyException exception];
TXTDomainName = parseName(buffer, length, &j,
- MAX_ALLOWED_POINTERS);
+ maxAllowedPointers);
if (j != i + dataLength)
@throw [OFInvalidServerReplyException exception];
return [[[OFRPDNSResourceRecord alloc]
@@ -358,19 +355,19 @@
initWithName: name
DNSClass: DNSClass
mailbox: mailbox
TXTDomainName: TXTDomainName
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_AAAA &&
- DNSClass == OF_DNS_CLASS_IN) {
- of_socket_address_t address;
+ } else if (recordType == OFDNSRecordTypeAAAA &&
+ DNSClass == OFDNSClassIN) {
+ OFSocketAddress address;
if (dataLength != 16)
@throw [OFInvalidServerReplyException exception];
memset(&address, 0, sizeof(address));
- address.family = OF_SOCKET_ADDRESS_FAMILY_IPV6;
+ address.family = OFSocketAddressFamilyIPv6;
address.length = sizeof(address.sockaddr.in6);
#ifdef AF_INET6
address.sockaddr.in6.sin6_family = AF_INET6;
#else
@@ -380,12 +377,12 @@
return [[[OFAAAADNSResourceRecord alloc]
initWithName: name
address: &address
TTL: TTL] autorelease];
- } else if (recordType == OF_DNS_RECORD_TYPE_SRV &&
- DNSClass == OF_DNS_CLASS_IN) {
+ } else if (recordType == OFDNSRecordTypeSRV &&
+ DNSClass == OFDNSClassIN) {
uint16_t priority, weight, port;
size_t j;
OFString *target;
if (dataLength < 6)
@@ -394,11 +391,11 @@
priority = (buffer[i] << 8) | buffer[i + 1];
weight = (buffer[i + 2] << 8) | buffer[i + 3];
port = (buffer[i + 4] << 8) | buffer[i + 5];
j = i + 6;
- target = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS);
+ target = parseName(buffer, length, &j, maxAllowedPointers);
if (j != i + dataLength)
@throw [OFInvalidServerReplyException exception];
return [[[OFSRVDNSResourceRecord alloc]
@@ -424,13 +421,13 @@
OFEnumerator OF_GENERIC(OFMutableArray *) *objectEnumerator;
OFMutableArray *array;
for (uint_fast16_t j = 0; j < count; j++) {
OFString *name = parseName(buffer, length, i,
- MAX_ALLOWED_POINTERS);
- of_dns_class_t DNSClass;
- of_dns_record_type_t recordType;
+ maxAllowedPointers);
+ OFDNSClass DNSClass;
+ OFDNSRecordType recordType;
uint32_t TTL;
uint16_t dataLength;
OFDNSResourceRecord *record;
if (*i + 10 > length)
@@ -453,12 +450,11 @@
array = [ret objectForKey: name];
if (array == nil) {
array = [OFMutableArray array];
- [ret setObject: array
- forKey: name];
+ [ret setObject: array forKey: name];
}
[array addObject: record];
}
@@ -491,24 +487,18 @@
queryData = [OFMutableData dataWithCapacity: 512];
/* Header */
- tmp = OF_BSWAP16_IF_LE(_ID.unsignedShortValue);
- [queryData addItems: &tmp
- count: 2];
-
+ tmp = OFToBigEndian16(_ID.unsignedShortValue);
+ [queryData addItems: &tmp count: 2];
/* RD */
- tmp = OF_BSWAP16_IF_LE(1u << 8);
- [queryData addItems: &tmp
- count: 2];
-
+ tmp = OFToBigEndian16(1u << 8);
+ [queryData addItems: &tmp count: 2];
/* QDCOUNT */
- tmp = OF_BSWAP16_IF_LE(1);
- [queryData addItems: &tmp
- count: 2];
-
+ tmp = OFToBigEndian16(1);
+ [queryData addItems: &tmp count: 2];
/* ANCOUNT, NSCOUNT and ARCOUNT */
[queryData increaseCountBy: 6];
/* Question */
@@ -526,19 +516,15 @@
[queryData addItems: component.UTF8String
count: length];
}
/* QTYPE */
- tmp = OF_BSWAP16_IF_LE(_query.recordType);
- [queryData addItems: &tmp
- count: 2];
-
+ tmp = OFToBigEndian16(_query.recordType);
+ [queryData addItems: &tmp count: 2];
/* QCLASS */
- tmp = OF_BSWAP16_IF_LE(_query.DNSClass);
- [queryData addItems: &tmp
- count: 2];
-
+ tmp = OFToBigEndian16(_query.DNSClass);
+ [queryData addItems: &tmp count: 2];
[queryData makeImmutable];
_queryData = [queryData copy];
objc_autoreleasePoolPop(pool);
@@ -557,10 +543,11 @@
[_settings release];
[_delegate release];
[_queryData release];
[_TCPSocket release];
[_TCPQueryData release];
+ OFFreeMemory(_TCPBuffer);
[_cancelTimer release];
[super dealloc];
}
@end
@@ -570,11 +557,11 @@
+ (void)initialize
{
if (self != [OFDNSResolver class])
return;
- if (!of_socket_init())
+ if (!OFSocketInit())
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
#endif
@@ -657,16 +644,16 @@
OFArray *old = _settings->_searchDomains;
_settings->_searchDomains = [searchDomains copy];
[old release];
}
-- (of_time_interval_t)timeout
+- (OFTimeInterval)timeout
{
return _settings->_timeout;
}
-- (void)setTimeout: (of_time_interval_t)timeout
+- (void)setTimeout: (OFTimeInterval)timeout
{
_settings->_timeout = timeout;
}
- (unsigned int)maxAttempts
@@ -699,28 +686,27 @@
- (void)setUsesTCP: (bool)usesTCP
{
_settings->_usesTCP = usesTCP;
}
-- (of_time_interval_t)configReloadInterval
+- (OFTimeInterval)configReloadInterval
{
return _settings->_configReloadInterval;
}
-- (void)setConfigReloadInterval: (of_time_interval_t)configReloadInterval
+- (void)setConfigReloadInterval: (OFTimeInterval)configReloadInterval
{
_settings->_configReloadInterval = configReloadInterval;
}
- (void)of_sendQueryForContext: (OFDNSResolverContext *)context
- runLoopMode: (of_run_loop_mode_t)runLoopMode
+ runLoopMode: (OFRunLoopMode)runLoopMode
{
OFUDPSocket *sock;
OFString *nameServer;
- [_queries setObject: context
- forKey: context->_ID];
+ [_queries setObject: context forKey: context->_ID];
[context->_cancelTimer invalidate];
[context->_cancelTimer release];
context->_cancelTimer = nil;
context->_cancelTimer = [[OFTimer alloc]
@@ -736,51 +722,58 @@
nameServer = [context->_settings->_nameServers
objectAtIndex: context->_nameServersIndex];
if (context->_settings->_usesTCP) {
- OF_ENSURE(context->_TCPSocket == nil);
+ OFEnsure(context->_TCPSocket == nil);
context->_TCPSocket = [[OFTCPSocket alloc] init];
- [_TCPQueries setObject: context
- forKey: context->_TCPSocket];
+ [_TCPQueries setObject: context forKey: context->_TCPSocket];
context->_TCPSocket.delegate = self;
[context->_TCPSocket asyncConnectToHost: nameServer
port: 53
runLoopMode: runLoopMode];
return;
}
- context->_usedNameServer = of_socket_address_parse_ip(nameServer, 53);
+ context->_usedNameServer = OFSocketAddressParseIP(nameServer, 53);
switch (context->_usedNameServer.family) {
#ifdef OF_HAVE_IPV6
- case OF_SOCKET_ADDRESS_FAMILY_IPV6:
+ case OFSocketAddressFamilyIPv6:
if (_IPv6Socket == nil) {
- of_socket_address_t address =
- of_socket_address_parse_ip(@"::", 0);
+ OFSocketAddress address =
+ OFSocketAddressParseIPv6(@"::", 0);
_IPv6Socket = [[OFUDPSocket alloc] init];
[_IPv6Socket of_bindToAddress: &address
extraType: SOCK_DNS];
- _IPv6Socket.canBlock = false;
+ @try {
+ _IPv6Socket.canBlock = false;
+ } @catch (OFNotImplementedException *e) {
+ /* Can't do anything about it... */
+ }
_IPv6Socket.delegate = self;
}
sock = _IPv6Socket;
break;
#endif
- case OF_SOCKET_ADDRESS_FAMILY_IPV4:
+ case OFSocketAddressFamilyIPv4:
if (_IPv4Socket == nil) {
- of_socket_address_t address =
- of_socket_address_parse_ip(@"0.0.0.0", 0);
+ OFSocketAddress address =
+ OFSocketAddressParseIPv4(@"0.0.0.0", 0);
_IPv4Socket = [[OFUDPSocket alloc] init];
[_IPv4Socket of_bindToAddress: &address
extraType: SOCK_DNS];
- _IPv4Socket.canBlock = false;
+ @try {
+ _IPv4Socket.canBlock = false;
+ } @catch (OFNotImplementedException *e) {
+ /* Can't do anything about it... */
+ }
_IPv4Socket.delegate = self;
}
sock = _IPv4Socket;
break;
@@ -790,42 +783,42 @@
[sock asyncSendData: context->_queryData
receiver: &context->_usedNameServer
runLoopMode: runLoopMode];
[sock asyncReceiveIntoBuffer: _buffer
- length: BUFFER_LENGTH
+ length: bufferLength
runLoopMode: runLoopMode];
}
- (void)asyncPerformQuery: (OFDNSQuery *)query
delegate: (id )delegate
{
[self asyncPerformQuery: query
- runLoopMode: of_run_loop_mode_default
+ runLoopMode: OFDefaultRunLoopMode
delegate: delegate];
}
- (void)asyncPerformQuery: (OFDNSQuery *)query
- runLoopMode: (of_run_loop_mode_t)runLoopMode
+ runLoopMode: (OFRunLoopMode)runLoopMode
delegate: (id )delegate
{
void *pool = objc_autoreleasePoolPush();
OFNumber *ID;
OFDNSResolverContext *context;
/* Random, unused ID */
do {
- ID = [OFNumber numberWithUnsignedShort: of_random16()];
+ ID = [OFNumber numberWithUnsignedShort: OFRandom16()];
} while ([_queries objectForKey: ID] != nil);
if (query.domainName.UTF8StringLength > 253)
@throw [OFOutOfRangeException exception];
if (_settings->_nameServers.count == 0) {
id exception = [OFDNSQueryFailedException
exceptionWithQuery: query
- error: OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER];
+ errorCode: OFDNSResolverErrorCodeNoNameServer];
[delegate resolver: self
didPerformQuery: query
response: nil
exception: exception];
return;
@@ -834,19 +827,18 @@
context = [[[OFDNSResolverContext alloc]
initWithQuery: query
ID: ID
settings: _settings
delegate: delegate] autorelease];
- [self of_sendQueryForContext: context
- runLoopMode: runLoopMode];
+ [self of_sendQueryForContext: context runLoopMode: runLoopMode];
objc_autoreleasePoolPop(pool);
}
- (void)of_contextTimedOut: (OFDNSResolverContext *)context
{
- of_run_loop_mode_t runLoopMode = [OFRunLoop currentRunLoop].currentMode;
+ OFRunLoopMode runLoopMode = [OFRunLoop currentRunLoop].currentMode;
OFDNSQueryFailedException *exception;
if (context->_TCPSocket != nil) {
context->_TCPSocket.delegate = nil;
[context->_TCPSocket cancelAsyncRequests];
@@ -858,19 +850,17 @@
}
if (context->_nameServersIndex + 1 <
context->_settings->_nameServers.count) {
context->_nameServersIndex++;
- [self of_sendQueryForContext: context
- runLoopMode: runLoopMode];
+ [self of_sendQueryForContext: context runLoopMode: runLoopMode];
return;
}
if (++context->_attempt < context->_settings->_maxAttempts) {
context->_nameServersIndex = 0;
- [self of_sendQueryForContext: context
- runLoopMode: runLoopMode];
+ [self of_sendQueryForContext: context runLoopMode: runLoopMode];
return;
}
context = [[context retain] autorelease];
[_queries removeObjectForKey: context->_ID];
@@ -878,31 +868,29 @@
/*
* Cancel any pending queries, to avoid a send being still pending and
* trying to access the query once it no longer exists.
*/
[_IPv4Socket cancelAsyncRequests];
- [_IPv4Socket asyncReceiveIntoBuffer: _buffer
- length: BUFFER_LENGTH];
+ [_IPv4Socket asyncReceiveIntoBuffer: _buffer length: bufferLength];
#ifdef OF_HAVE_IPV6
[_IPv6Socket cancelAsyncRequests];
- [_IPv6Socket asyncReceiveIntoBuffer: _buffer
- length: BUFFER_LENGTH];
+ [_IPv6Socket asyncReceiveIntoBuffer: _buffer length: bufferLength];
#endif
exception = [OFDNSQueryFailedException
exceptionWithQuery: context->_query
- error: OF_DNS_RESOLVER_ERROR_TIMEOUT];
+ errorCode: OFDNSResolverErrorCodeTimeout];
[context->_delegate resolver: self
didPerformQuery: context->_query
response: nil
exception: exception];
}
- (bool)of_handleResponseBuffer: (unsigned char *)buffer
length: (size_t)length
- sender: (const of_socket_address_t *)sender
+ sender: (const OFSocketAddress *)sender
{
OFDictionary *answerRecords = nil, *authorityRecords = nil;
OFDictionary *additionalRecords = nil;
OFDNSResponse *response = nil;
id exception = nil;
@@ -920,20 +908,20 @@
return true;
if (context->_TCPSocket != nil) {
if ([_TCPQueries objectForKey: context->_TCPSocket] != context)
return true;
- } else if (!of_socket_address_equal(sender, &context->_usedNameServer))
+ } else if (!OFSocketAddressEqual(sender, &context->_usedNameServer))
return true;
[context->_cancelTimer invalidate];
[context->_cancelTimer release];
context->_cancelTimer = nil;
[_queries removeObjectForKey: ID];
@try {
- of_dns_resolver_error_t error = 0;
+ OFDNSResolverErrorCode errorCode = 0;
bool tryNextNameServer = false;
const unsigned char *queryDataBuffer;
size_t i;
uint16_t numQuestions, numAnswers, numAuthorityRecords;
uint16_t numAdditionalRecords;
@@ -955,11 +943,11 @@
if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78))
@throw [OFInvalidServerReplyException exception];
/* TC */
if (buffer[2] & 0x02) {
- of_run_loop_mode_t runLoopMode;
+ OFRunLoopMode runLoopMode;
if (context->_settings->_usesTCP)
@throw [OFTruncatedDataException exception];
context->_settings->_usesTCP = true;
@@ -972,37 +960,37 @@
/* RCODE */
switch (buffer[3] & 0x0F) {
case 0:
break;
case 1:
- error = OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT;
+ errorCode = OFDNSResolverErrorCodeServerInvalidFormat;
break;
case 2:
- error = OF_DNS_RESOLVER_ERROR_SERVER_FAILURE;
+ errorCode = OFDNSResolverErrorCodeServerFailure;
tryNextNameServer = true;
break;
case 3:
- error = OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR;
+ errorCode = OFDNSResolverErrorCodeServerNameError;
break;
case 4:
- error = OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED;
+ errorCode = OFDNSResolverErrorCodeServerNotImplemented;
tryNextNameServer = true;
break;
case 5:
- error = OF_DNS_RESOLVER_ERROR_SERVER_REFUSED;
+ errorCode = OFDNSResolverErrorCodeServerRefused;
tryNextNameServer = true;
break;
default:
- error = OF_DNS_RESOLVER_ERROR_UNKNOWN;
+ errorCode = OFDNSResolverErrorCodeUnknown;
tryNextNameServer = true;
break;
}
if (tryNextNameServer) {
if (context->_nameServersIndex + 1 <
context->_settings->_nameServers.count) {
- of_run_loop_mode_t runLoopMode =
+ OFRunLoopMode runLoopMode =
[OFRunLoop currentRunLoop].currentMode;
context->_nameServersIndex++;
[self of_sendQueryForContext: context
@@ -1012,11 +1000,11 @@
}
if (buffer[3] & 0x0F)
@throw [OFDNSQueryFailedException
exceptionWithQuery: context->_query
- error: error];
+ errorCode: errorCode];
numQuestions = (buffer[4] << 8) | buffer[5];
numAnswers = (buffer[6] << 8) | buffer[7];
numAuthorityRecords = (buffer[8] << 8) | buffer[9];
numAdditionalRecords = (buffer[10] << 8) | buffer[11];
@@ -1028,11 +1016,11 @@
* query.
*
* TODO: Compare to our query, just in case?
*/
for (uint_fast16_t j = 0; j < numQuestions; j++) {
- parseName(buffer, length, &i, MAX_ALLOWED_POINTERS);
+ parseName(buffer, length, &i, maxAllowedPointers);
i += 4;
}
answerRecords = parseSection(buffer, length, &i, numAnswers);
authorityRecords = parseSection(buffer, length, &i,
@@ -1060,11 +1048,11 @@
}
- (bool)socket: (OFDatagramSocket *)sock
didReceiveIntoBuffer: (void *)buffer
length: (size_t)length
- sender: (const of_socket_address_t *)sender
+ sender: (const OFSocketAddress *)sender
exception: (id)exception
{
if (exception != nil)
return true;
@@ -1078,11 +1066,11 @@
port: (uint16_t)port
exception: (id)exception
{
OFDNSResolverContext *context = [_TCPQueries objectForKey: sock];
- OF_ENSURE(context != nil);
+ OFEnsure(context != nil);
if (exception != nil) {
/*
* TODO: Handle error immediately instead of waiting for the
* timer to try the next nameserver or to retry.
@@ -1102,13 +1090,12 @@
@throw [OFOutOfRangeException exception];
context->_TCPQueryData = [[OFMutableData alloc]
initWithCapacity: queryDataCount + 2];
- tmp = OF_BSWAP16_IF_LE(queryDataCount);
- [context->_TCPQueryData addItems: &tmp
- count: sizeof(tmp)];
+ tmp = OFToBigEndian16(queryDataCount);
+ [context->_TCPQueryData addItems: &tmp count: sizeof(tmp)];
[context->_TCPQueryData addItems: context->_queryData.items
count: queryDataCount];
}
[sock asyncWriteData: context->_TCPQueryData];
@@ -1120,11 +1107,11 @@
exception: (id)exception
{
OFTCPSocket *sock = (OFTCPSocket *)stream;
OFDNSResolverContext *context = [_TCPQueries objectForKey: sock];
- OF_ENSURE(context != nil);
+ OFEnsure(context != nil);
if (exception != nil) {
/*
* TODO: Handle error immediately instead of waiting for the
* timer to try the next nameserver or to retry.
@@ -1135,15 +1122,13 @@
context->_responseLength = 0;
return nil;
}
if (context->_TCPBuffer == nil)
- context->_TCPBuffer =
- [context allocMemoryWithSize: MAX_DNS_RESPONSE_LENGTH];
+ context->_TCPBuffer = OFAllocMemory(maxDNSResponseLength, 1);
- [sock asyncReadIntoBuffer: context->_TCPBuffer
- exactLength: 2];
+ [sock asyncReadIntoBuffer: context->_TCPBuffer exactLength: 2];
return nil;
}
- (bool)stream: (OFStream *)stream
didReadIntoBuffer: (void *)buffer
@@ -1151,11 +1136,11 @@
exception: (id)exception
{
OFTCPSocket *sock = (OFTCPSocket *)stream;
OFDNSResolverContext *context = [_TCPQueries objectForKey: sock];
- OF_ENSURE(context != nil);
+ OFEnsure(context != nil);
if (exception != nil) {
/*
* TODO: Handle error immediately instead of waiting for the
* timer to try the next nameserver or to retry.
@@ -1164,15 +1149,15 @@
}
if (context->_responseLength == 0) {
unsigned char *ucBuffer = buffer;
- OF_ENSURE(length == 2);
+ OFEnsure(length == 2);
context->_responseLength = (ucBuffer[0] << 8) | ucBuffer[1];
- if (context->_responseLength > MAX_DNS_RESPONSE_LENGTH)
+ if (context->_responseLength > maxDNSResponseLength)
@throw [OFOutOfRangeException exception];
if (context->_responseLength == 0)
goto done;
@@ -1186,13 +1171,11 @@
* The connection was closed before we received the entire
* response.
*/
goto done;
- [self of_handleResponseBuffer: buffer
- length: length
- sender: NULL];
+ [self of_handleResponseBuffer: buffer length: length sender: NULL];
done:
[_TCPQueries removeObjectForKey: context->_TCPSocket];
[context->_TCPSocket release];
context->_TCPSocket = nil;
@@ -1203,28 +1186,28 @@
- (void)asyncResolveAddressesForHost: (OFString *)host
delegate: (id )delegate
{
[self asyncResolveAddressesForHost: host
- addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY
- runLoopMode: of_run_loop_mode_default
+ addressFamily: OFSocketAddressFamilyAny
+ runLoopMode: OFDefaultRunLoopMode
delegate: delegate];
}
- (void)asyncResolveAddressesForHost: (OFString *)host
- addressFamily: (of_socket_address_family_t)addressFamily
+ addressFamily: (OFSocketAddressFamily)addressFamily
delegate: (id )delegate
{
[self asyncResolveAddressesForHost: host
addressFamily: addressFamily
- runLoopMode: of_run_loop_mode_default
+ runLoopMode: OFDefaultRunLoopMode
delegate: delegate];
}
- (void)asyncResolveAddressesForHost: (OFString *)host
- addressFamily: (of_socket_address_family_t)addressFamily
- runLoopMode: (of_run_loop_mode_t)runLoopMode
+ addressFamily: (OFSocketAddressFamily)addressFamily
+ runLoopMode: (OFRunLoopMode)runLoopMode
delegate: (id )delegate
{
void *pool = objc_autoreleasePoolPush();
OFHostAddressResolver *resolver = [[[OFHostAddressResolver alloc]
initWithHost: host
@@ -1238,11 +1221,11 @@
objc_autoreleasePoolPop(pool);
}
- (OFData *)resolveAddressesForHost: (OFString *)host
- addressFamily: (of_socket_address_family_t)addressFamily
+ addressFamily: (OFSocketAddressFamily)addressFamily
{
void *pool = objc_autoreleasePoolPush();
OFHostAddressResolver *resolver = [[[OFHostAddressResolver alloc]
initWithHost: host
addressFamily: addressFamily
@@ -1279,11 +1262,11 @@
while ((context = [enumerator nextObject]) != nil) {
OFDNSQueryFailedException *exception;
exception = [OFDNSQueryFailedException
exceptionWithQuery: context->_query
- error: OF_DNS_RESOLVER_ERROR_CANCELED];
+ errorCode: OFDNSResolverErrorCodeCanceled];
[context->_delegate resolver: self
didPerformQuery: context->_query
response: nil
exception: exception];
Index: src/OFDNSResolverSettings.h
==================================================================
--- src/OFDNSResolverSettings.h
+++ src/OFDNSResolverSettings.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -29,17 +27,17 @@
OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *)
*_staticHosts;
OFArray OF_GENERIC(OFString *) *_nameServers;
OFString *_Nullable _localDomain;
OFArray OF_GENERIC(OFString *) *_searchDomains;
- of_time_interval_t _timeout;
+ OFTimeInterval _timeout;
unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName;
bool _usesTCP;
- of_time_interval_t _configReloadInterval;
+ OFTimeInterval _configReloadInterval;
@protected
OFDate *_lastConfigReload;
}
- (void)reload;
@end
OF_ASSUME_NONNULL_END
Index: src/OFDNSResolverSettings.m
==================================================================
--- src/OFDNSResolverSettings.m
+++ src/OFDNSResolverSettings.m
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -24,10 +22,11 @@
#import "OFCharacterSet.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFFile.h"
#import "OFLocale.h"
+#import "OFSocket+Private.h"
#import "OFString.h"
#ifdef OF_WINDOWS
# import "OFWindowsRegistryKey.h"
#endif
@@ -47,18 +46,19 @@
# define id id_3ds
# include <3ds.h>
# undef id
#endif
-#import "socket_helpers.h"
+#ifdef OF_MORPHOS
+# include
+# include
+# include
+#endif
#if defined(OF_HAIKU)
# define HOSTS_PATH @"/system/settings/network/hosts"
# define RESOLV_CONF_PATH @"/system/settings/network/resolv.conf"
-#elif defined(OF_MORPHOS)
-# define HOSTS_PATH @"ENV:sys/net/hosts"
-# define RESOLV_CONF_PATH @"ENV:sys/net/resolv.conf"
#elif defined(OF_AMIGAOS4)
# define HOSTS_PATH @"DEVS:Internet/hosts"
#elif defined(OF_AMIGAOS)
# define HOSTS_PATH @"AmiTCP:db/hosts"
# define RESOLV_CONF_PATH @"AmiTCP:db/resolv.conf"
@@ -67,42 +67,124 @@
# define RESOLV_CONF_PATH @"/etc/resolv.conf"
#endif
#ifndef OF_WII
static OFString *
-domainFromHostname(void)
+domainFromHostname(OFString *hostname)
{
- char hostname[256];
- OFString *domain, *ret;
+ OFString *ret;
- if (gethostname(hostname, 256) != 0)
+ if (hostname == nil)
return nil;
- domain = [OFString stringWithCString: hostname
- encoding: [OFLocale encoding]];
-
@try {
- of_socket_address_parse_ip(domain, 0);
+ OFSocketAddressParseIP(hostname, 0);
/*
* If we are still here, the host name is a valid IP address.
* We can't use that as local domain.
*/
- return nil;
+ ret = nil;
} @catch (OFInvalidFormatException *e) {
/* Not an IP address -> we can use it if it contains a dot. */
- size_t pos = [domain rangeOfString: @"."].location;
+ size_t pos = [hostname rangeOfString: @"."].location;
- if (pos == OF_NOT_FOUND)
- return nil;
-
- ret = [domain substringFromIndex: pos + 1];
+ if (pos != OFNotFound)
+ ret = [hostname substringFromIndex: pos + 1];
+ else
+ ret = nil;
}
return ret;
}
#endif
+
+#if !defined(OF_WII) && !defined(OF_MORPHOS)
+static OFString *
+obtainHostname(void)
+{
+ char hostname[256];
+
+ if (gethostname(hostname, 256) != 0)
+ return nil;
+
+ return [OFString stringWithCString: hostname
+ encoding: [OFLocale encoding]];
+}
+#endif
+
+#ifdef OF_MORPHOS
+static OFString *
+arexxCommand(const char *port, const char *command)
+{
+ struct Library *RexxSysBase;
+ struct MsgPort *replyPort = NULL;
+ struct RexxMsg *msg = NULL;
+
+ if ((RexxSysBase = OpenLibrary("rexxsyslib.library", 36)) == NULL)
+ return nil;
+
+ @try {
+ struct MsgPort *rexxPort;
+
+ if ((replyPort = CreateMsgPort()) == NULL)
+ return nil;
+
+ if ((msg = CreateRexxMsg(replyPort, NULL, port)) == NULL)
+ return nil;
+
+ msg->rm_Action = RXCOMM | RXFF_RESULT;
+
+ if ((msg->rm_Args[0] = (char *)CreateArgstring(
+ command, strlen(command))) == NULL)
+ return nil;
+
+ Forbid();
+
+ if ((rexxPort = FindPort(port)) == NULL) {
+ Permit();
+ return nil;
+ }
+
+ PutMsg(rexxPort, &msg->rm_Node);
+ Permit();
+ WaitPort(replyPort);
+ GetMsg(replyPort);
+
+ if (msg->rm_Result1 != RC_OK || msg->rm_Result2 == 0)
+ return nil;
+
+ return [OFString stringWithCString: (char *)msg->rm_Result2
+ encoding: [OFLocale encoding]];
+ } @finally {
+ if (msg != NULL) {
+ if (msg->rm_Args[0] != NULL)
+ DeleteArgstring(msg->rm_Args[0]);
+ if (msg->rm_Result2 != 0)
+ DeleteArgstring((char *)msg->rm_Result2);
+
+ DeleteRexxMsg(msg);
+ }
+
+ if (replyPort != NULL)
+ DeleteMsgPort(replyPort);
+
+ CloseLibrary(RexxSysBase);
+ }
+}
+
+static OFArray OF_GENERIC(OFString *) *
+parseNetStackArray(OFString *string)
+{
+ if (![string hasPrefix: @"["] || ![string hasSuffix: @"]"])
+ return nil;
+
+ string = [string substringWithRange: OFRangeMake(1, string.length - 2)];
+
+ return [string componentsSeparatedByString: @"|"];
+}
+#endif
@implementation OFDNSResolverSettings
- (void)dealloc
{
[_staticHosts release];
@@ -161,77 +243,65 @@
#else
_configReloadInterval = 0;
#endif
}
-#if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_3DS)
+#if defined(OF_HAVE_FILES) && !defined(OF_MORPHOS) && !defined(OF_NINTENDO_3DS)
- (void)parseHosts: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFCharacterSet *whitespaceCharacterSet =
[OFCharacterSet whitespaceCharacterSet];
OFMutableDictionary *staticHosts;
OFFile *file;
OFString *line;
- OFEnumerator *enumerator;
- OFMutableArray *addresses;
@try {
- file = [OFFile fileWithPath: path
- mode: @"r"];
+ file = [OFFile fileWithPath: path mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
objc_autoreleasePoolPop(pool);
return;
}
staticHosts = [OFMutableDictionary dictionary];
while ((line = [file readLine]) != nil) {
- void *pool2 = objc_autoreleasePoolPush();
OFArray *components, *hosts;
size_t pos;
OFString *address;
pos = [line rangeOfString: @"#"].location;
- if (pos != OF_NOT_FOUND)
+ if (pos != OFNotFound)
line = [line substringToIndex: pos];
components = [line
componentsSeparatedByCharactersInSet: whitespaceCharacterSet
- options: OF_STRING_SKIP_EMPTY];
+ options: OFStringSkipEmptyComponents];
- if (components.count < 2) {
- objc_autoreleasePoolPop(pool2);
+ if (components.count < 2)
continue;
- }
address = components.firstObject;
hosts = [components objectsInRange:
- of_range(1, components.count - 1)];
+ OFRangeMake(1, components.count - 1)];
for (OFString *host in hosts) {
- addresses = [staticHosts objectForKey: host];
+ OFMutableArray *addresses =
+ [staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
- [staticHosts setObject: addresses
- forKey: host];
+ [staticHosts setObject: addresses forKey: host];
}
[addresses addObject: address];
}
-
- objc_autoreleasePoolPop(pool2);
}
-
- enumerator = [staticHosts objectEnumerator];
- while ((addresses = [enumerator nextObject]) != nil)
+ for (OFMutableArray *addresses in [staticHosts objectEnumerator])
[addresses makeImmutable];
[staticHosts makeImmutable];
-
- [_staticHosts release];
_staticHosts = [staticHosts copy];
objc_autoreleasePoolPop(pool);
}
@@ -283,12 +353,11 @@
OFMutableArray *nameServers = [[_nameServers mutableCopy] autorelease];
OFFile *file;
OFString *line;
@try {
- file = [OFFile fileWithPath: path
- mode: @"r"];
+ file = [OFFile fileWithPath: path mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
objc_autoreleasePoolPop(pool);
return;
}
@@ -300,33 +369,33 @@
size_t pos;
OFArray *components, *arguments;
OFString *option;
pos = [line indexOfCharacterFromSet: commentCharacters];
- if (pos != OF_NOT_FOUND)
+ if (pos != OFNotFound)
line = [line substringToIndex: pos];
components = [line
componentsSeparatedByCharactersInSet: whitespaceCharacterSet
- options: OF_STRING_SKIP_EMPTY];
+ options: OFStringSkipEmptyComponents];
if (components.count < 2) {
objc_autoreleasePoolPop(pool2);
continue;
}
option = components.firstObject;
arguments = [components objectsInRange:
- of_range(1, components.count - 1)];
+ OFRangeMake(1, components.count - 1)];
if ([option isEqual: @"nameserver"]) {
if (arguments.count != 1) {
objc_autoreleasePoolPop(pool2);
continue;
}
- [nameServers addObject: [arguments firstObject]];
+ [nameServers addObject: arguments.firstObject];
} else if ([option isEqual: @"domain"]) {
if (arguments.count != 1) {
objc_autoreleasePoolPop(pool2);
continue;
}
@@ -354,11 +423,11 @@
#endif
#ifdef OF_WINDOWS
- (void)obtainWindowsSystemConfig
{
- of_string_encoding_t encoding = [OFLocale encoding];
+ OFStringEncoding encoding = [OFLocale encoding];
OFMutableArray *nameServers;
/*
* We need more space than FIXED_INFO in case we have more than one
* name server, but we also want it to be properly aligned, meaning we
* can't just get a buffer of bytes. Thus, we just get space for 8.
@@ -386,16 +455,66 @@
_localDomain = [[OFString alloc]
initWithCString: fixedInfo->DomainName
encoding: encoding];
}
#endif
+
+#ifdef OF_MORPHOS
+- (void)obtainMorphOSSystemConfig
+{
+ void *pool = objc_autoreleasePoolPush();
+ OFMutableDictionary *staticHosts;
+
+ _nameServers = [parseNetStackArray(arexxCommand("NETSTACK",
+ "QUERY NAMESERVERS")) copy];
+ _localDomain = [domainFromHostname(arexxCommand("NETSTACK",
+ "QUERY HOSTNAME")) copy];
+ _searchDomains = [parseNetStackArray(arexxCommand("NETSTACK",
+ "QUERY DOMAINS")) copy];
+
+ staticHosts = [OFMutableDictionary dictionary];
+
+ for (OFString *entry in parseNetStackArray(arexxCommand("NETSTACK",
+ "QUERY HOSTS"))) {
+ OFArray *components = [entry componentsSeparatedByString: @" "];
+ OFString *address;
+ OFArray *hosts;
+
+ if (components.count < 2)
+ continue;
+
+ address = components.firstObject;
+ hosts = [components objectsInRange:
+ OFRangeMake(1, components.count - 1)];
+
+ for (OFString *host in hosts) {
+ OFMutableArray *addresses =
+ [staticHosts objectForKey: host];
+
+ if (addresses == nil) {
+ addresses = [OFMutableArray array];
+ [staticHosts setObject: addresses forKey: host];
+ }
+
+ [addresses addObject: address];
+ }
+ }
+ for (OFMutableArray *addresses in [staticHosts objectEnumerator])
+ [addresses makeImmutable];
+
+ [staticHosts makeImmutable];
+ _staticHosts = [staticHosts copy];
+
+ objc_autoreleasePoolPop(pool);
+}
+#endif
#ifdef OF_AMIGAOS4
- (void)obtainAmigaOS4SystemConfig
{
OFMutableArray *nameServers = [OFMutableArray array];
- of_string_encoding_t encoding = [OFLocale encoding];
+ OFStringEncoding encoding = [OFLocale encoding];
struct List *nameServerList = ObtainDomainNameServerList();
char buffer[MAXHOSTNAMELEN];
if (nameServerList == NULL)
@throw [OFOutOfMemoryException exception];
@@ -456,11 +575,11 @@
*/
if (optLen < sizeof(buffer.entries))
return;
for (uint_fast8_t i = 0; i < 2; i++) {
- uint32_t ip = OF_BSWAP32_IF_LE(buffer.entries[i].ip.s_addr);
+ uint32_t ip = OFFromBigEndian32(buffer.entries[i].ip.s_addr);
if (ip == 0)
continue;
[nameServers addObject: [OFString stringWithFormat:
@@ -499,19 +618,21 @@
# ifdef OF_HAVE_FILES
OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey]
openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\"
@"Tcpip\\Parameters"
securityAndAccessRights: KEY_QUERY_VALUE];
- path = [[[key stringForValue: @"DataBasePath"]
+ path = [[[key stringForValueNamed: @"DataBasePath"]
stringByAppendingPathComponent: @"hosts"]
stringByExpandingWindowsEnvironmentStrings];
if (path != nil)
[self parseHosts: path];
# endif
[self obtainWindowsSystemConfig];
+#elif defined(OF_MORPHOS)
+ [self obtainMorphOSSystemConfig];
#elif defined(OF_AMIGAOS4)
[self parseHosts: HOSTS_PATH];
[self obtainAmigaOS4SystemConfig];
#elif defined(OF_NINTENDO_3DS)
[self obtainNintendo3DSSytemConfig];
@@ -539,13 +660,13 @@
initWithObjects: @"127.0.0.1", @"::1", nil];
#else
_nameServers = [[OFArray alloc] initWithObject: @"127.0.0.1"];
#endif
-#ifndef OF_WII
+#if !defined(OF_WII) && !defined(OF_MORPHOS)
if (_localDomain == nil)
- _localDomain = [domainFromHostname() copy];
+ _localDomain = [domainFromHostname(obtainHostname()) copy];
#endif
if (_searchDomains == nil) {
if (_localDomain != nil)
_searchDomains = [[OFArray alloc]
Index: src/OFDNSResourceRecord.h
==================================================================
--- src/OFDNSResourceRecord.h
+++ src/OFDNSResourceRecord.h
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
+ * Copyright (c) 2008-2022 Jonathan Schleifer
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
@@ -14,14 +12,13 @@
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
+#import "OFSocket.h"
#import "OFString.h"
-#import "socket.h"
-
OF_ASSUME_NONNULL_BEGIN
/** @file */
@class OFArray OF_GENERIC(ObjectType);
@@ -30,55 +27,55 @@
/**
* @brief The DNS class.
*/
typedef enum {
/** IN */
- OF_DNS_CLASS_IN = 1,
+ OFDNSClassIN = 1,
/** Any class. Only for queries. */
- OF_DNS_CLASS_ANY = 255,
-} of_dns_class_t;
+ OFDNSClassAny = 255,
+} OFDNSClass;
/**
* @brief The type of a DNS resource record.
*/
typedef enum {
/** A */
- OF_DNS_RECORD_TYPE_A = 1,
+ OFDNSRecordTypeA = 1,
/** NS */
- OF_DNS_RECORD_TYPE_NS = 2,
+ OFDNSRecordTypeNS = 2,
/** CNAME */
- OF_DNS_RECORD_TYPE_CNAME = 5,
+ OFDNSRecordTypeCNAME = 5,
/** SOA */
- OF_DNS_RECORD_TYPE_SOA = 6,
+ OFDNSRecordTypeSOA = 6,
/** PTR */
- OF_DNS_RECORD_TYPE_PTR = 12,
+ OFDNSRecordTypePTR = 12,
/** HINFO */
- OF_DNS_RECORD_TYPE_HINFO = 13,
+ OFDNSRecordTypeHINFO = 13,
/** MX */
- OF_DNS_RECORD_TYPE_MX = 15,
+ OFDNSRecordTypeMX = 15,
/** TXT */
- OF_DNS_RECORD_TYPE_TXT = 16,
+ OFDNSRecordTypeTXT = 16,
/** RP */
- OF_DNS_RECORD_TYPE_RP = 17,
+ OFDNSRecordTypeRP = 17,
/** AAAA */
- OF_DNS_RECORD_TYPE_AAAA = 28,
+ OFDNSRecordTypeAAAA = 28,
/** SRV */
- OF_DNS_RECORD_TYPE_SRV = 33,
+ OFDNSRecordTypeSRV = 33,
/** All types. Only for queries. */
- OF_DNS_RECORD_TYPE_ALL = 255,
-} of_dns_record_type_t;
+ OFDNSRecordTypeAll = 255,
+} OFDNSRecordType;
/**
* @class OFDNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h
*
* @brief A class representing a DNS resource record.
*/
@interface OFDNSResourceRecord: OFObject