├── .clang-format ├── .github ├── FUNDING.yml ├── disabled-workflows │ └── mayhem.yml └── workflows │ ├── cifuzz.yml │ └── container-images.yml ├── .gitignore ├── .mailmap ├── CMakeLists.txt ├── COPYING ├── Containerfile ├── Dockerfile ├── README.md ├── fuzz ├── README ├── corpus │ ├── corpus-config-234910329 │ ├── corpus-h2_huffman-1 │ ├── corpus-h2_huffman-2 │ ├── corpus-h2_huffman-3 │ ├── corpus-pattern-1 │ ├── corpus-pattern-2 │ ├── corpus-pattern-3 │ ├── corpus-pattern-4 │ ├── corpus-request-1012502954 │ ├── corpus-request-1025202362 │ ├── corpus-request-1036140795 │ ├── corpus-request-1067854538 │ ├── corpus-request-1102520059 │ ├── corpus-request-1117142618 │ ├── corpus-request-1129566413 │ ├── corpus-request-1139901474 │ ├── corpus-request-116087764 │ ├── corpus-request-1186452551 │ ├── corpus-request-1231192379 │ ├── corpus-request-1239036029 │ ├── corpus-request-1244316437 │ ├── corpus-request-1264095060 │ ├── corpus-request-1285228804 │ ├── corpus-request-1335354340 │ ├── corpus-request-1350573793 │ ├── corpus-request-1365180540 │ ├── corpus-request-1374344043 │ ├── corpus-request-1376710097 │ ├── corpus-request-137806862 │ ├── corpus-request-1398295499 │ ├── corpus-request-1409959708 │ ├── corpus-request-1424268980 │ ├── corpus-request-1433925857 │ ├── corpus-request-1450573622 │ ├── corpus-request-1476153275 │ ├── corpus-request-1494613810 │ ├── corpus-request-1504569917 │ ├── corpus-request-1548233367 │ ├── corpus-request-159259470 │ ├── corpus-request-1600028624 │ ├── corpus-request-1605894428 │ ├── corpus-request-1605908235 │ ├── corpus-request-1626276121 │ ├── corpus-request-1631518149 │ ├── corpus-request-1649760492 │ ├── corpus-request-1714636915 │ ├── corpus-request-1726956429 │ ├── corpus-request-1749698586 │ ├── corpus-request-1780695788 │ ├── corpus-request-1827336327 │ ├── corpus-request-184803526 │ ├── corpus-request-187309218 │ ├── corpus-request-1884661237 │ ├── corpus-request-1889947178 │ ├── corpus-request-1909002904 │ ├── corpus-request-1911165193 │ ├── corpus-request-1939964443 │ ├── corpus-request-1957747793 │ ├── corpus-request-1973594324 │ ├── corpus-request-1975960378 │ ├── corpus-request-2114738097 │ ├── corpus-request-2130794395 │ ├── corpus-request-213975407 │ ├── corpus-request-269455306 │ ├── corpus-request-321123 │ ├── corpus-request-3298283 │ ├── corpus-request-338888228 │ ├── corpus-request-356426808 │ ├── corpus-request-364228444 │ ├── corpus-request-387346491 │ ├── corpus-request-412776091 │ ├── corpus-request-42999170 │ ├── corpus-request-439493451 │ ├── corpus-request-511702305 │ ├── corpus-request-515530019 │ ├── corpus-request-524872353 │ ├── corpus-request-532670688 │ ├── corpus-request-593209441 │ ├── corpus-request-603570492 │ ├── corpus-request-631704567 │ ├── corpus-request-653468858 │ ├── corpus-request-654887343 │ ├── corpus-request-709393584 │ ├── corpus-request-745425661 │ ├── corpus-request-752392754 │ ├── corpus-request-76065818 │ ├── corpus-request-771151432 │ ├── corpus-request-805750846 │ ├── corpus-request-846930886 │ ├── corpus-request-8936987 │ ├── corpus-request-933110197 │ ├── corpus-request-943947739 │ ├── corpus-request-945117276 │ ├── corpus-request-959997301 │ ├── corpus-request-968338082 │ ├── corpus-request-971899228 │ └── corpus-template-1 ├── disabled │ ├── README │ ├── clusterfuzz-testcase-request_fuzzer-5091179189764096 │ ├── clusterfuzz-testcase-request_fuzzer-5689112759107584 │ ├── crash-61ff81c30aa3c76e78afea62b2e3bd1dfa49e854 │ ├── crash-96cb33f2b70df83e63d2c6b2e571bd0c17b4adb3 │ └── crash-bd24b5eed9697284d0d67356e1b489b9e2e17ff6 ├── mayhem │ ├── Dockerfile │ ├── Dockerfile.dockerignore │ ├── build.sh │ ├── config_fuzzer.mayhemfile │ ├── h2_huffman_fuzzer.mayhemfile │ ├── pattern_fuzzer.mayhemfile │ ├── request_fuzzer.mayhemfile │ └── template_fuzzer.mayhemfile ├── regression │ ├── README │ ├── clusterfuzz-testcase-minimized-config_fuzzer-5462763322277888 │ ├── clusterfuzz-testcase-minimized-h2_huffman_fuzzer-4703583657918464 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-4811721351954432 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5191405204406272 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5636210766118912 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5649134389821440 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5652010562486272 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5658117347475456 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5717480481226752 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5723694463844352 │ ├── clusterfuzz-testcase-minimized-request_fuzzer-5729298679332864 │ ├── clusterfuzz-testcase-minimized-template_fuzzer-6208074244227072 │ ├── clusterfuzz-testcase-request_fuzzer-5675545829834752 │ └── request_fuzzer-crash-9df31650ba7cf7fa3aae24d59b3e0a335ab6c23a └── request_fuzzer.dict ├── lwan.conf ├── src ├── 3rdparty │ └── libucontext │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── NEWS │ │ ├── README.md │ │ ├── VERSION │ │ ├── arch │ │ ├── aarch64 │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── arm │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── common │ │ │ ├── common-defs.h │ │ │ ├── common-trampoline.c │ │ │ └── include │ │ │ │ └── libucontext │ │ │ │ └── bits.h │ │ ├── loongarch64 │ │ │ ├── defs.h │ │ │ ├── freestanding │ │ │ │ └── bits.h │ │ │ ├── getcontext.S │ │ │ ├── makecontext.S │ │ │ ├── setcontext.S │ │ │ ├── startcontext.S │ │ │ └── swapcontext.S │ │ ├── m68k │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── mips │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.S │ │ │ ├── setcontext.S │ │ │ ├── startcontext.S │ │ │ └── swapcontext.S │ │ ├── mips64 │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.S │ │ │ ├── setcontext.S │ │ │ ├── startcontext.S │ │ │ └── swapcontext.S │ │ ├── or1k │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── ppc │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── makecontext.c │ │ │ ├── retfromsyscall.c │ │ │ ├── setcontext.S │ │ │ ├── startcontext.S │ │ │ └── swapcontext.S │ │ ├── ppc64 │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── makecontext.c │ │ │ ├── retfromsyscall.c │ │ │ ├── setcontext.S │ │ │ ├── startcontext.S │ │ │ └── swapcontext.S │ │ ├── riscv32 │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── riscv64 │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── s390x │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── startcontext.S │ │ │ └── swapcontext.S │ │ ├── sh │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── x86 │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ │ └── libucontext │ │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ └── x86_64 │ │ │ ├── defs.h │ │ │ ├── getcontext.S │ │ │ ├── include │ │ │ └── libucontext │ │ │ │ └── bits.h │ │ │ ├── makecontext.c │ │ │ ├── setcontext.S │ │ │ ├── swapcontext.S │ │ │ └── trampoline.c │ │ ├── doc │ │ ├── libucontext.scd │ │ └── meson.build │ │ ├── examples │ │ └── cooperative_threading.c │ │ ├── include │ │ └── libucontext │ │ │ └── libucontext.h │ │ ├── libucontext.pc.in │ │ ├── libucontext_posix.c │ │ ├── meson.build │ │ ├── meson_options.txt │ │ ├── test_libucontext.c │ │ └── test_libucontext_posix.c ├── CMakeLists.txt ├── bin │ ├── CMakeLists.txt │ ├── fuzz │ │ ├── config_fuzzer.cc │ │ ├── h2_huffman_fuzzer.cc │ │ ├── pattern_fuzzer.cc │ │ ├── request_fuzzer.cc │ │ └── template_fuzzer.cc │ ├── lwan │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── testrunner │ │ ├── CMakeLists.txt │ │ ├── main.c │ │ ├── test.lua │ │ └── testrunner.conf │ └── tools │ │ ├── CMakeLists.txt │ │ ├── COPYING.weighttp │ │ ├── bin2hex.c │ │ ├── configdump.c │ │ ├── mime.types │ │ ├── mimegen.c │ │ ├── statuslookupgen.c │ │ └── weighttp.c ├── cmake │ ├── CodeCoverage.cmake │ ├── EnableCFlag.cmake │ ├── GitVersionDetect.cmake │ ├── TrySanitizer.cmake │ ├── lwan-build-config.h.cmake │ └── lwan.pc.cmake ├── lib │ ├── CMakeLists.txt │ ├── base64.c │ ├── base64.h │ ├── hash.c │ ├── hash.h │ ├── int-to-str.c │ ├── int-to-str.h │ ├── liblwan.sym │ ├── list.c │ ├── list.h │ ├── lwan-arena.c │ ├── lwan-arena.h │ ├── lwan-array.c │ ├── lwan-array.h │ ├── lwan-cache.c │ ├── lwan-cache.h │ ├── lwan-config.c │ ├── lwan-config.h │ ├── lwan-coro.c │ ├── lwan-coro.h │ ├── lwan-h2-huffman.c │ ├── lwan-http-authorize.c │ ├── lwan-http-authorize.h │ ├── lwan-http-status.h │ ├── lwan-io-wrappers.c │ ├── lwan-io-wrappers.h │ ├── lwan-job.c │ ├── lwan-lua.c │ ├── lwan-lua.h │ ├── lwan-mod-fastcgi.c │ ├── lwan-mod-fastcgi.h │ ├── lwan-mod-lua.c │ ├── lwan-mod-lua.h │ ├── lwan-mod-redirect.c │ ├── lwan-mod-redirect.h │ ├── lwan-mod-response.c │ ├── lwan-mod-response.h │ ├── lwan-mod-rewrite.c │ ├── lwan-mod-rewrite.h │ ├── lwan-mod-serve-files.c │ ├── lwan-mod-serve-files.h │ ├── lwan-private.h │ ├── lwan-pubsub.c │ ├── lwan-pubsub.h │ ├── lwan-readahead.c │ ├── lwan-request.c │ ├── lwan-response.c │ ├── lwan-socket.c │ ├── lwan-status.c │ ├── lwan-status.h │ ├── lwan-straitjacket.c │ ├── lwan-strbuf.c │ ├── lwan-strbuf.h │ ├── lwan-tables.c │ ├── lwan-template.c │ ├── lwan-template.h │ ├── lwan-thread.c │ ├── lwan-time.c │ ├── lwan-tq.c │ ├── lwan-tq.h │ ├── lwan-trie.c │ ├── lwan-trie.h │ ├── lwan-websocket.c │ ├── lwan.c │ ├── lwan.h │ ├── missing-epoll.c │ ├── missing-pthread.c │ ├── missing.c │ ├── missing │ │ ├── assert.h │ │ ├── endian.h │ │ ├── fcntl.h │ │ ├── ioprio.h │ │ ├── libproc.h │ │ ├── limits.h │ │ ├── linux │ │ │ └── capability.h │ │ ├── pthread.h │ │ ├── pwd.h │ │ ├── stdio.h │ │ ├── stdlib.h │ │ ├── string.h │ │ ├── sys │ │ │ ├── epoll.h │ │ │ ├── ioctl.h │ │ │ ├── mman.h │ │ │ ├── sendfile.h │ │ │ ├── socket.h │ │ │ ├── syscall.h │ │ │ ├── sysctl.h │ │ │ ├── types.h │ │ │ └── vfs.h │ │ ├── time.h │ │ └── unistd.h │ ├── patterns.c │ ├── patterns.h │ ├── realpathat.c │ ├── realpathat.h │ ├── response-template.html │ ├── ringbuffer.h │ ├── sd-daemon.c │ ├── sd-daemon.h │ ├── servefile-template.html │ ├── sha1.c │ ├── sha1.h │ ├── timeout.c │ └── timeout.h ├── samples │ ├── CMakeLists.txt │ ├── asyncawait │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── chatr │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── clock │ │ ├── CMakeLists.txt │ │ ├── blocks.c │ │ ├── blocks.h │ │ ├── font │ │ │ ├── colonE.xbm │ │ │ ├── eightE.xbm │ │ │ ├── fiveE.xbm │ │ │ ├── fourE.xbm │ │ │ ├── nineE.xbm │ │ │ ├── oneE.xbm │ │ │ ├── sevenE.xbm │ │ │ ├── sixE.xbm │ │ │ ├── slashE.xbm │ │ │ ├── threeE.xbm │ │ │ ├── twoE.xbm │ │ │ └── zeroE.xbm │ │ ├── gifenc.c │ │ ├── gifenc.h │ │ ├── main.c │ │ ├── numbers.c │ │ ├── numbers.h │ │ ├── pong.c │ │ ├── pong.h │ │ ├── xdaliclock.c │ │ └── xdaliclock.h │ ├── forthsalon │ │ ├── CMakeLists.txt │ │ ├── forth.c │ │ ├── forth.h │ │ ├── gif.h │ │ └── main.c │ ├── freegeoip │ │ ├── CMakeLists.txt │ │ └── freegeoip.c │ ├── hello-no-meta │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── hello │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── pastebin │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── send-money-json-api │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── smolsite │ │ ├── CMakeLists.txt │ │ ├── index.html │ │ ├── junzip.c │ │ ├── junzip.h │ │ ├── main.c │ │ ├── qrcodegen.c │ │ ├── qrcodegen.h │ │ └── smolsite.html │ ├── techempower │ │ ├── CMakeLists.txt │ │ ├── database.c │ │ ├── database.h │ │ ├── json.c │ │ ├── json.h │ │ ├── json.lua │ │ ├── techempower.c │ │ ├── techempower.conf │ │ └── techempower.db │ └── websocket │ │ ├── CMakeLists.txt │ │ ├── index.html │ │ └── main.c └── scripts │ ├── benchmark.py │ ├── gentables.py │ ├── huffman-table.txt │ └── testsuite.py └── wwwroot ├── 100.html ├── icons ├── README.TXT ├── back.gif ├── file.gif └── folder.gif ├── index.html └── zero /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: lpereira 4 | -------------------------------------------------------------------------------- /.github/workflows/cifuzz.yml: -------------------------------------------------------------------------------- 1 | name: CIFuzz 2 | on: [pull_request] 3 | jobs: 4 | Fuzzing: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Build Fuzzers 8 | id: build 9 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 10 | with: 11 | oss-fuzz-project-name: 'lwan' 12 | dry-run: false 13 | language: c++ 14 | - name: Run Fuzzers 15 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 16 | with: 17 | oss-fuzz-project-name: 'lwan' 18 | fuzz-seconds: 300 19 | dry-run: false 20 | language: c++ 21 | - name: Upload Crash 22 | uses: actions/upload-artifact@v3 23 | if: failure() && steps.build.outcome == 'success' 24 | with: 25 | name: artifacts 26 | path: ./out/artifacts 27 | -------------------------------------------------------------------------------- /.github/workflows/container-images.yml: -------------------------------------------------------------------------------- 1 | name: Build and publish lwan container images 2 | 3 | on: 4 | release: 5 | types: [published] 6 | workflow_dispatch: 7 | 8 | env: 9 | REGISTRY: ghcr.io 10 | IMAGE_NAME: ${{ github.repository }} 11 | 12 | jobs: 13 | build-and-push-image: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | contents: read 17 | packages: write 18 | 19 | steps: 20 | - name: Checkout repository 21 | uses: actions/checkout@v2 22 | 23 | - name: Build image 24 | id: build-image 25 | uses: redhat-actions/buildah-build@v2 26 | with: 27 | image: ${{ env.IMAGE_NAME }} 28 | tags: latest ${{ github.event.release.tag_name }} 29 | dockerfiles: | 30 | ./Containerfile 31 | 32 | - name: Push to ghcr.io 33 | id: push-to-ghcr 34 | uses: redhat-actions/push-to-registry@v2 35 | with: 36 | registry: ${{ env.REGISTRY }} 37 | username: ${{ github.actor }} 38 | password: ${{ secrets.GITHUB_TOKEN }} 39 | image: ${{ steps.build-image.outputs.image }} 40 | tags: ${{ steps.build-image.outputs.tags }} 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | DEADJOE 3 | *.o 4 | build/* 5 | .gitignore 6 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | L. Pereira -------------------------------------------------------------------------------- /Containerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/alpine:3.14.2 AS build 2 | RUN apk add --no-cache gcc make musl-dev cmake pkgconfig linux-headers \ 3 | luajit-dev sqlite-dev zlib-dev brotli-dev zstd-dev 4 | COPY . /lwan 5 | WORKDIR /lwan/build 6 | RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DMTUNE_NATIVE=OFF 7 | RUN make -j 8 | 9 | FROM docker.io/library/alpine:3.14.2 10 | RUN apk add --no-cache luajit sqlite zlib brotli zstd-dev 11 | COPY --from=build /lwan/build/src/bin/lwan/lwan . 12 | COPY --from=build /lwan/lwan.conf . 13 | EXPOSE 8080 14 | VOLUME /wwwroot 15 | ENTRYPOINT ["/lwan"] -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | Containerfile -------------------------------------------------------------------------------- /fuzz/README: -------------------------------------------------------------------------------- 1 | `http.dict' has been copied from the h2o web server project: 2 | https://github.com/h2o/h2o/blob/c14554e7/fuzz/http.dict 3 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-h2_huffman-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/corpus/corpus-h2_huffman-1 -------------------------------------------------------------------------------- /fuzz/corpus/corpus-h2_huffman-2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/corpus/corpus-h2_huffman-2 -------------------------------------------------------------------------------- /fuzz/corpus/corpus-h2_huffman-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/corpus/corpus-h2_huffman-3 -------------------------------------------------------------------------------- /fuzz/corpus/corpus-pattern-1: -------------------------------------------------------------------------------- 1 | lua/rewrite/7x6 -------------------------------------------------------------------------------- /fuzz/corpus/corpus-pattern-2: -------------------------------------------------------------------------------- 1 | lua/redir/6x7 -------------------------------------------------------------------------------- /fuzz/corpus/corpus-pattern-3: -------------------------------------------------------------------------------- 1 | bar/42/test -------------------------------------------------------------------------------- /fuzz/corpus/corpus-pattern-4: -------------------------------------------------------------------------------- 1 | foo/1234x5678 -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1012502954: -------------------------------------------------------------------------------- 1 | GET /redirect307 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1025202362: -------------------------------------------------------------------------------- 1 | GET /admin HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Authorization: Basic bm9zdWNoOnVzZXI= 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1036140795: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Range: bytes=-100 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1067854538: -------------------------------------------------------------------------------- 1 | POST /post/big HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Content-Type: x-test/trololo 8 | Content-Length: 203 9 | 10 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1102520059: -------------------------------------------------------------------------------- 1 | GET /admin HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Authorization: Basic Zm9vYmFyOnRlc3QxMjM= 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1117142618: -------------------------------------------------------------------------------- 1 | GET /lua/hello?name=foo HTTP/1.1 2 | Host: localhost:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1129566413: -------------------------------------------------------------------------------- 1 | GET /100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1139901474: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0006 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-116087764: -------------------------------------------------------------------------------- 1 | GET / FROG/1.0 2 | 3 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1186452551: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0001 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1231192379: -------------------------------------------------------------------------------- 1 | GET /lua/invalid_code HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1239036029: -------------------------------------------------------------------------------- 1 | GET /hello?name=name000a HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1244316437: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0002 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1264095060: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Range: bytes=0-50 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1285228804: -------------------------------------------------------------------------------- 1 | GET /customhdr?hdr=Marco HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Marco: Polo 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1335354340: -------------------------------------------------------------------------------- 1 | GET /pattern/foo/1234x5678 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1350573793: -------------------------------------------------------------------------------- 1 | GET /hello?name=name000d HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1365180540: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1374344043: -------------------------------------------------------------------------------- 1 | HEAD /100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foobar 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1376710097: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Range: bytes=0-40000 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-137806862: -------------------------------------------------------------------------------- 1 | GET /icons HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foobar 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1398295499: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1409959708: -------------------------------------------------------------------------------- 1 | GET /lua/cookie HTTP/1.1 2 | Host: localhost:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Cookie: FOO=BAR 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1424268980: -------------------------------------------------------------------------------- 1 | GET /100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: deflote 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1433925857: -------------------------------------------------------------------------------- 1 | GET / HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1450573622: -------------------------------------------------------------------------------- 1 | GET /pattern/lua/redir/6x7 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1476153275: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0004 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1494613810: -------------------------------------------------------------------------------- 1 | GET /pattern/bar/42/test HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1504569917: -------------------------------------------------------------------------------- 1 | PROXY TCP4 192.168.242.221 192.168.242.242 56324 31337 2 | GET /proxy HTTP/1.1 3 | Connection: keep-alive 4 | Host: 192.168.0.11 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1548233367: -------------------------------------------------------------------------------- 1 | HEAD /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foobar 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-159259470: -------------------------------------------------------------------------------- 1 | GET /proxy HTTP/1.1 2 | Connection: keep-alive 3 | Host: 192.168.0.11 4 | 5 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1600028624: -------------------------------------------------------------------------------- 1 | GET /hello?name=testsuite HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1605894428: -------------------------------------------------------------------------------- 1 | GET /hello?name=name000f HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1605908235: -------------------------------------------------------------------------------- 1 | GET /hello?name=name000c HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1626276121: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0007 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1631518149: -------------------------------------------------------------------------------- 1 | GET /lua/hello HTTP/1.1 2 | Host: localhost:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1649760492: -------------------------------------------------------------------------------- 1 | GET /admin HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1714636915: -------------------------------------------------------------------------------- 1 | GET /hello HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1726956429: -------------------------------------------------------------------------------- 1 | GET /100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1749698586: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Range: bytes=50-0 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1780695788: -------------------------------------------------------------------------------- 1 | HEAD /icons/ HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1827336327: -------------------------------------------------------------------------------- 1 | GET /../../../../../../../../../etc/passwd HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-184803526: -------------------------------------------------------------------------------- 1 | GET /100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foo,bar,deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-187309218: -------------------------------------------------------------------------------- 1 | GET /ws HTTP/1.1 2 | Host: localhost:8080 3 | User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0 4 | Accept: */* 5 | Accept-Language: en-US,en;q=0.5 6 | Accept-Encoding: gzip, deflate 7 | Sec-WebSocket-Version: 13 8 | Origin: http://localhost:8080 9 | Sec-WebSocket-Extensions: permessage-deflate 10 | Sec-WebSocket-Key: YNDTJflH7V1X70XY2XHR0A== 11 | DNT: 1 12 | Connection: keep-alive, Upgrade 13 | Pragma: no-cache 14 | Cache-Control: no-cache 15 | Upgrade: websocket 16 | 17 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1884661237: -------------------------------------------------------------------------------- 1 | GET /hello?name=name000b HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1889947178: -------------------------------------------------------------------------------- 1 | HEAD /icons HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1909002904: -------------------------------------------------------------------------------- 1 | POST /post/big HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Content-Type: x-test/trololo 8 | Content-Length: 23 9 | 10 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1911165193: -------------------------------------------------------------------------------- 1 | GET / HTTP/2.0 2 | 3 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1939964443: -------------------------------------------------------------------------------- 1 | POST /post/big HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Content-Type: x-test/trololo 8 | Content-Length: 2003 9 | 10 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1957747793: -------------------------------------------------------------------------------- 1 | GET /admin HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Authorization: Basic Zm9vOnRlc3QxMjM= 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1973594324: -------------------------------------------------------------------------------- 1 | GET /chunked HTTP/1.1 2 | Host: localhost:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-1975960378: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Range: bytes=50- 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-2114738097: -------------------------------------------------------------------------------- 1 | HEAD /hello HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foobar 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-2130794395: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0009 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-213975407: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0005 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-269455306: -------------------------------------------------------------------------------- 1 | GET /hello?key=&otherkey=&name=testsuite&dump_vars=1 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-321123: -------------------------------------------------------------------------------- 1 | PROXY TCP4 192.168.242.221 192.168.242.242 56324 31337 2 | GET /hello HTTP/1.1 3 | Host: 127.0.0.1:8080 4 | User-Agent: python-requests/2.21.0 5 | Accept-Encoding: gzip, deflate 6 | Accept: */* 7 | Connection: keep-alive 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-3298283: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | QUIT 5 | !  6 | GET /hello HTTP/1.1 7 | Host: 127.0.0.1:8080 8 | User-Agent: python-requests/2.21.0 9 | Accept-Encoding: gzip, deflate 10 | Accept: */* 11 | Connection: keep-alive 12 | 13 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-338888228: -------------------------------------------------------------------------------- 1 | asldkfjg238045tgqwdcjv1li 2u4ftw dfjkb12345t 2 | 3 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-356426808: -------------------------------------------------------------------------------- 1 | HEAD / HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-364228444: -------------------------------------------------------------------------------- 1 | GET /hello?dump_vars=1 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Cookie: OTHERCOOKIE=some cookie value; SOMECOOKIE=1c330301-89e4-408a-bf6c-ce107efe8a27; foo=bar 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-387346491: -------------------------------------------------------------------------------- 1 | GET http://example.com HTTP/1.0 2 | 3 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-412776091: -------------------------------------------------------------------------------- 1 | GET /100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foo, bar, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-42999170: -------------------------------------------------------------------------------- 1 | GET /icons/ HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foobar 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-439493451: -------------------------------------------------------------------------------- 1 | GET /inline HTTP/1.1 2 | Host: localhost:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-511702305: -------------------------------------------------------------------------------- 1 | GET /icons HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-515530019: -------------------------------------------------------------------------------- 1 | GET /lua/brew_coffee HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-524872353: -------------------------------------------------------------------------------- 1 | GET /read-env/user HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-532670688: -------------------------------------------------------------------------------- 1 | POST /post/blend HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Content-Length: 23 8 | Content-Type: application/json 9 | 10 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-593209441: -------------------------------------------------------------------------------- 1 | GET /100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foobar 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-603570492: -------------------------------------------------------------------------------- 1 | GET //////////100.html HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-631704567: -------------------------------------------------------------------------------- 1 | POST /hello?dump_vars=1 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Content-Length: 25 8 | Content-Type: application/x-www-form-urlencoded 9 | 10 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-653468858: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0008 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-654887343: -------------------------------------------------------------------------------- 1 | GET /pattern/lua/rewrite/7x6 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-709393584: -------------------------------------------------------------------------------- 1 | HEAD /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-745425661: -------------------------------------------------------------------------------- 1 | GET /sleep?ms=1500 HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-752392754: -------------------------------------------------------------------------------- 1 | GET /icons/non-existent-file.png HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-76065818: -------------------------------------------------------------------------------- 1 | GET /hello?name=name000e HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-771151432: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0000 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-805750846: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: foobar 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-846930886: -------------------------------------------------------------------------------- 1 | GET /brew-coffee HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-8936987: -------------------------------------------------------------------------------- 1 | GET / 2 | 3 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-933110197: -------------------------------------------------------------------------------- 1 | GET /customhdr?hdr=Polo HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Marco: Polo 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-943947739: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Range: bytes=50-50 8 | 9 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-945117276: -------------------------------------------------------------------------------- 1 | HEAD /icons/back.gif HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-959997301: -------------------------------------------------------------------------------- 1 | GET //////////etc/passwd HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-968338082: -------------------------------------------------------------------------------- 1 | GET /elsewhere HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | 8 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-request-971899228: -------------------------------------------------------------------------------- 1 | GET /hello?name=name0003 HTTP/1.1 2 | Host: localhost 3 | Connection: keep-alive 4 | Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7 5 | 6 | -------------------------------------------------------------------------------- /fuzz/corpus/corpus-template-1: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{rel_path?}} Index of {{rel_path}}{{/rel_path?}} 4 | {{^rel_path?}} Index of /{{/rel_path?}} 5 | 10 | 11 | 12 | {{rel_path?}}

Index of {{rel_path}}

{{/rel_path?}} 13 | {{^rel_path?}}

Index of /

{{/rel_path?}} 14 | {{readme?}}
{{readme}}
{{/readme?}} 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {{#file_list}} 27 | 28 | 29 | 30 | 31 | 32 | 33 | {{/file_list}} 34 | {{^#file_list}} 35 | 36 | 37 | 38 | {{/file_list}} 39 |
Parent directory
 File nameTypeSize
{{file_list.icon_alt}}{{{file_list.name}}}{{file_list.type}}{{file_list.size}}{{file_list.unit}}
Empty directory.
40 | 41 | 42 | -------------------------------------------------------------------------------- /fuzz/disabled/README: -------------------------------------------------------------------------------- 1 | This directory contains some inputs that crashed Lwan previously, 2 | but for reasons I can't investigate right now, are hanging the 3 | test harness. 4 | 5 | They're still kept here for future investigations. 6 | -------------------------------------------------------------------------------- /fuzz/disabled/clusterfuzz-testcase-request_fuzzer-5091179189764096: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/disabled/clusterfuzz-testcase-request_fuzzer-5091179189764096 -------------------------------------------------------------------------------- /fuzz/disabled/clusterfuzz-testcase-request_fuzzer-5689112759107584: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/disabled/clusterfuzz-testcase-request_fuzzer-5689112759107584 -------------------------------------------------------------------------------- /fuzz/disabled/crash-61ff81c30aa3c76e78afea62b2e3bd1dfa49e854: -------------------------------------------------------------------------------- 1 | POST -------------------------------------------------------------------------------- /fuzz/disabled/crash-96cb33f2b70df83e63d2c6b2e571bd0c17b4adb3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/disabled/crash-96cb33f2b70df83e63d2c6b2e571bd0c17b4adb3 -------------------------------------------------------------------------------- /fuzz/disabled/crash-bd24b5eed9697284d0d67356e1b489b9e2e17ff6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/disabled/crash-bd24b5eed9697284d0d67356e1b489b9e2e17ff6 -------------------------------------------------------------------------------- /fuzz/mayhem/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | ################################################################################ 16 | 17 | FROM gcr.io/oss-fuzz-base/base-builder 18 | RUN apt-get update 19 | RUN apt-get install -y build-essential cmake git ninja-build zlib1g-dev 20 | 21 | COPY . lwan 22 | RUN rm -rf lwan/mayhem 23 | WORKDIR lwan 24 | 25 | COPY fuzz/mayhem/build.sh $SRC/ 26 | 27 | ENV FUZZING_LANGUAGE=c++ SANITIZER=address 28 | RUN compile -------------------------------------------------------------------------------- /fuzz/mayhem/Dockerfile.dockerignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/mayhem/Dockerfile.dockerignore -------------------------------------------------------------------------------- /fuzz/mayhem/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -euv 2 | # Copyright 2019 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | ################################################################################ 17 | 18 | 19 | mkdir -p $WORK/lwan 20 | cd $WORK/lwan 21 | 22 | cmake -GNinja \ 23 | -DCMAKE_BUILD_TYPE=Debug \ 24 | -DCMAKE_C_COMPILER="${CC}" \ 25 | -DCMAKE_C_FLAGS="${CFLAGS}" \ 26 | $SRC/lwan/ 27 | 28 | ninja -v liblwan.a 29 | 30 | cp $SRC/lwan/fuzz/*.dict $OUT/ 31 | 32 | for fuzzer in $SRC/lwan/src/bin/fuzz/*_fuzzer.cc; do 33 | executable=$(basename $fuzzer .cc) 34 | corpus_base=$(basename $fuzzer _fuzzer.cc) 35 | 36 | zip -jr $OUT/${executable}_seed_corpus.zip $SRC/lwan/fuzz/corpus/corpus-${corpus_base}-* 37 | 38 | $CXX $CXXFLAGS -std=c++11 \ 39 | -Wl,-whole-archive $WORK/lwan/src/lib/liblwan.a -Wl,-no-whole-archive \ 40 | -I$SRC/lwan/src/lib $fuzzer \ 41 | $LIB_FUZZING_ENGINE -lpthread -lz \ 42 | -o $OUT/$executable 43 | done 44 | -------------------------------------------------------------------------------- /fuzz/mayhem/config_fuzzer.mayhemfile: -------------------------------------------------------------------------------- 1 | project: PROJECT 2 | target: config_fuzzer 3 | cmds: 4 | - cmd: /out/config_fuzzer 5 | -------------------------------------------------------------------------------- /fuzz/mayhem/h2_huffman_fuzzer.mayhemfile: -------------------------------------------------------------------------------- 1 | project: PROJECT 2 | target: h2_huffman_fuzzer 3 | cmds: 4 | - cmd: /out/h2_huffman_fuzzer 5 | -------------------------------------------------------------------------------- /fuzz/mayhem/pattern_fuzzer.mayhemfile: -------------------------------------------------------------------------------- 1 | project: PROJECT 2 | target: pattern_fuzzer 3 | cmds: 4 | - cmd: /out/pattern_fuzzer 5 | -------------------------------------------------------------------------------- /fuzz/mayhem/request_fuzzer.mayhemfile: -------------------------------------------------------------------------------- 1 | project: PROJECT 2 | target: request_fuzzer 3 | cmds: 4 | - cmd: /out/request_fuzzer 5 | -------------------------------------------------------------------------------- /fuzz/mayhem/template_fuzzer.mayhemfile: -------------------------------------------------------------------------------- 1 | project: PROJECT 2 | target: template_fuzzer 3 | cmds: 4 | - cmd: /out/template_fuzzer 5 | -------------------------------------------------------------------------------- /fuzz/regression/README: -------------------------------------------------------------------------------- 1 | This directory contains files that managed to crash something in Lwan 2 | after being fuzzed. They have been committed alongside the fix, so 3 | it's easier to find them with git blame. 4 | 5 | -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-config_fuzzer-5462763322277888: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/regression/clusterfuzz-testcase-minimized-config_fuzzer-5462763322277888 -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-h2_huffman_fuzzer-4703583657918464: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/regression/clusterfuzz-testcase-minimized-h2_huffman_fuzzer-4703583657918464 -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-4811721351954432: -------------------------------------------------------------------------------- 1 | GET / HTTP/1.0 Cookie: N 2 | 3 | -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5191405204406272: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5191405204406272 -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5636210766118912: -------------------------------------------------------------------------------- 1 | GET / HTTP/1.1 2 | 3 | -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5649134389821440: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5649134389821440 -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5652010562486272: -------------------------------------------------------------------------------- 1 | 2 | 3 | GET / HTTP/1.0 Rang : -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5658117347475456: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5658117347475456 -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5717480481226752: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5717480481226752 -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-request_fuzzer-5723694463844352: -------------------------------------------------------------------------------- 1 | GET /ws-write HTTP/1.1 Conn : Upg Upgrade: websocket Sec-WebSocket-Key: 2 | 3 | -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-minimized-template_fuzzer-6208074244227072: -------------------------------------------------------------------------------- 1 | {{#readme -------------------------------------------------------------------------------- /fuzz/regression/clusterfuzz-testcase-request_fuzzer-5675545829834752: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/fuzz/regression/clusterfuzz-testcase-request_fuzzer-5675545829834752 -------------------------------------------------------------------------------- /fuzz/regression/request_fuzzer-crash-9df31650ba7cf7fa3aae24d59b3e0a335ab6c23a: -------------------------------------------------------------------------------- 1 | GET /zero HTTP/1.1 2 | Host: 127.0.0.1:8080 3 | User-Agent: python-requests/2.21.0 4 | Accept-Encoding: gzip, deflate 5 | Accept: */* 6 | Connection: keep-alive 7 | Range: bytes=50- 8 | 9 | -------------------------------------------------------------------------------- /lwan.conf: -------------------------------------------------------------------------------- 1 | # Timeout in seconds to keep a connection alive. 2 | keep_alive_timeout = 15 3 | 4 | # Set to true to not print any debugging messages. (Only effective in 5 | # release builds.) 6 | quiet = false 7 | 8 | # Value of "Expires" header. Default is 1 month and 1 week. 9 | expires = 1M 1w 10 | 11 | # Number of I/O threads. Default (0) is number of online CPUs. 12 | threads = 0 13 | 14 | # Disable HAProxy's PROXY protocol by default. Only enable if needed. 15 | proxy_protocol = false 16 | 17 | # Enable straitjacket by default. The `drop_capabilities` option is `true` 18 | # by default. Other options may require more privileges. 19 | straitjacket 20 | 21 | listener *:8080 22 | 23 | #tls_listener *:8081 { 24 | # cert = /path/to/cert.pem 25 | # key = /path/to/key.pem 26 | #} 27 | 28 | site { 29 | serve_files / { 30 | path = ./wwwroot 31 | 32 | # When requesting for file.ext, look for a smaller/newer file.ext.gz, 33 | # and serve that instead if `Accept-Encoding: gzip` is in the 34 | # request headers. 35 | serve precompressed files = true 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018-2022 Ariadne Conill 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | This software is provided 'as is' and without any warranty, express or 8 | implied. In no event shall the authors be liable for any damages arising 9 | from the use of this software. 10 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/VERSION: -------------------------------------------------------------------------------- 1 | 1.2 -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/aarch64/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_AARCH64_DEFS_H 2 | #define __ARCH_AARCH64_DEFS_H 3 | 4 | #define REG_SZ (8) 5 | #define MCONTEXT_GREGS (184) 6 | 7 | #define R0_OFFSET REG_OFFSET(0) 8 | 9 | #define SP_OFFSET 432 10 | #define PC_OFFSET 440 11 | #define PSTATE_OFFSET 448 12 | #define FPSIMD_CONTEXT_OFFSET 464 13 | 14 | #ifndef FPSIMD_MAGIC 15 | # define FPSIMD_MAGIC 0x46508001 16 | #endif 17 | 18 | #ifndef ESR_MAGIC 19 | # define ESR_MAGIC 0x45535201 20 | #endif 21 | 22 | #define FETCH_LINKPTR(dest) \ 23 | asm("mov %0, x19" : "=r" ((dest))) 24 | 25 | #include "common-defs.h" 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/aarch64/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long libucontext_greg_t; 5 | typedef unsigned long libucontext_gregset_t[34]; 6 | 7 | typedef struct { 8 | __uint128_t vregs[32]; 9 | unsigned int fpsr; 10 | unsigned int fpcr; 11 | } libucontext_fpregset_t; 12 | 13 | typedef struct sigcontext { 14 | unsigned long fault_address; 15 | unsigned long regs[31]; 16 | unsigned long sp, pc, pstate; 17 | long double __reserved[256]; 18 | } libucontext_mcontext_t; 19 | 20 | typedef struct { 21 | void *ss_sp; 22 | int ss_flags; 23 | size_t ss_size; 24 | } libucontext_stack_t; 25 | 26 | typedef struct libucontext_ucontext { 27 | unsigned long uc_flags; 28 | struct libucontext_ucontext *uc_link; 29 | libucontext_stack_t uc_stack; 30 | unsigned char __pad[136]; 31 | libucontext_mcontext_t uc_mcontext; 32 | } libucontext_ucontext_t; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/aarch64/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | .global PROC_NAME(libucontext_setcontext); 19 | .align 2; 20 | TYPE(libucontext_setcontext) 21 | ENT(libucontext_setcontext) 22 | PROC_NAME(libucontext_setcontext): 23 | /* restore GPRs */ 24 | ldp x18, x19, [x0, #REG_OFFSET(18)] 25 | ldp x20, x21, [x0, #REG_OFFSET(20)] 26 | ldp x22, x23, [x0, #REG_OFFSET(22)] 27 | ldp x24, x25, [x0, #REG_OFFSET(24)] 28 | ldp x26, x27, [x0, #REG_OFFSET(26)] 29 | ldp x28, x29, [x0, #REG_OFFSET(28)] 30 | ldr x30, [x0, #REG_OFFSET(30)] 31 | 32 | /* save current stack pointer */ 33 | ldr x2, [x0, #SP_OFFSET] 34 | mov sp, x2 35 | 36 | add x2, x0, #FPSIMD_CONTEXT_OFFSET 37 | ldp q8, q9, [x2, #144] 38 | ldp q10, q11, [x2, #176] 39 | ldp q12, q13, [x2, #208] 40 | ldp q14, q15, [x2, #240] 41 | 42 | /* save current program counter in link register */ 43 | ldr x16, [x0, #PC_OFFSET] 44 | 45 | /* restore args */ 46 | ldp x2, x3, [x0, #REG_OFFSET(2)] 47 | ldp x4, x5, [x0, #REG_OFFSET(4)] 48 | ldp x6, x7, [x0, #REG_OFFSET(6)] 49 | ldp x0, x1, [x0, #REG_OFFSET(0)] 50 | 51 | /* jump to new PC */ 52 | br x16 53 | END(libucontext_setcontext) 54 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/aarch64/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/arm/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_ARM_DEFS_H 2 | 3 | #define REG_SZ (4) 4 | #define MCONTEXT_GREGS (32) 5 | #define VFP_MAGIC_OFFSET (232) 6 | #define VFP_D8_OFFSET (304) 7 | 8 | #define TYPE(__proc) .type __proc, %function; 9 | 10 | #define FETCH_LINKPTR(dest) \ 11 | asm("movs %0, r4" : "=r" ((dest))) 12 | 13 | #include "common-defs.h" 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/arm/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | /* copy all of the current registers into the ucontext structure */ 20 | add r1, r0, #REG_OFFSET(4) 21 | stmia r1, {r4-r12} 22 | str r13, [r0, #REG_OFFSET(13)] 23 | str r14, [r0, #REG_OFFSET(15)] 24 | 25 | #ifndef FORCE_SOFT_FLOAT 26 | #ifndef FORCE_HARD_FLOAT 27 | /* test for vfp, set kernel-defined magic number in uc_regspace */ 28 | push {r0-r1,fp,lr} 29 | mov r0, #16 30 | bl getauxval 31 | tst r0, #64 32 | pop {r0-r1,fp,lr} 33 | moveq r2, #0 34 | ldrne r2, =#0x56465001 35 | str r2, [r0, #VFP_MAGIC_OFFSET] 36 | beq 1f 37 | #endif 38 | /* if vfp detected, save d8-d15 */ 39 | .fpu vfp 40 | add r1, r0, #VFP_D8_OFFSET 41 | vstmia r1, {d8-d15} 42 | .fpu softvfp 43 | 1: 44 | #endif 45 | 46 | /* return 0 */ 47 | mov r0, #0 48 | mov pc, lr 49 | END(libucontext_getcontext) 50 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/arm/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef int libucontext_greg_t, libucontext_gregset_t[18]; 5 | 6 | typedef struct { 7 | unsigned long trap_no, error_code, oldmask; 8 | unsigned long arm_r0, arm_r1, arm_r2, arm_r3; 9 | unsigned long arm_r4, arm_r5, arm_r6, arm_r7; 10 | unsigned long arm_r8, arm_r9, arm_r10, arm_fp; 11 | unsigned long arm_ip, arm_sp, arm_lr, arm_pc; 12 | unsigned long arm_cpsr, fault_address; 13 | } libucontext_mcontext_t; 14 | 15 | typedef struct { 16 | void *ss_sp; 17 | int ss_flags; 18 | size_t ss_size; 19 | } libucontext_stack_t; 20 | 21 | typedef struct libucontext_ucontext { 22 | unsigned long uc_flags; 23 | struct libucontext_ucontext *uc_link; 24 | libucontext_stack_t uc_stack; 25 | libucontext_mcontext_t uc_mcontext; 26 | unsigned long uc_sigmask[128 / sizeof(long)]; 27 | unsigned long long uc_regspace[64]; 28 | } libucontext_ucontext_t; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/arm/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | #ifndef FORCE_SOFT_FLOAT 20 | #ifndef FORCE_HARD_FLOAT 21 | /* test for vfp magic number set by getcontext */ 22 | ldr r2, [r0, #VFP_MAGIC_OFFSET] 23 | ldr r3, =#0x56465001 24 | cmp r2, r3 25 | bne 1f 26 | #endif 27 | /* if vfp in use, restore d8-d15 from uc_regspace */ 28 | .fpu vfp 29 | add r14, r0, #VFP_D8_OFFSET 30 | vldmia r14, {d8-d15} 31 | .fpu softvfp 32 | 1: 33 | #endif 34 | 35 | /* copy all of the current registers into the ucontext structure */ 36 | add r14, r0, #REG_OFFSET(0) 37 | ldmia r14, {r0-r12} 38 | ldr r13, [r14, #52] 39 | add r14, r14, #56 40 | 41 | /* load link register and jump to new context */ 42 | ldmia r14, {r14, pc} 43 | END(libucontext_setcontext) 44 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/arm/swapcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(swapcontext, libucontext_swapcontext) 16 | ALIAS(__swapcontext, libucontext_swapcontext) 17 | 18 | FUNC(libucontext_swapcontext) 19 | /* copy all of the current registers into the ucontext structure */ 20 | add r2, r0, #REG_OFFSET(0) 21 | stmia r2, {r0-r12} 22 | str r13, [r0,#REG_OFFSET(13)] 23 | str r14, [r0,#REG_OFFSET(15)] 24 | 25 | #ifndef FORCE_SOFT_FLOAT 26 | #ifndef FORCE_HARD_FLOAT 27 | /* test for vfp magic number, copy to other ucontext */ 28 | ldr r3, [r1, #VFP_MAGIC_OFFSET] 29 | ldr r4, =#0x56465001 30 | str r3, [r0, #VFP_MAGIC_OFFSET] 31 | cmp r3, r4 32 | bne 1f 33 | #endif 34 | /* if vfp in use, save and restore d8-d15 */ 35 | .fpu vfp 36 | add r2, r0, #VFP_D8_OFFSET 37 | vstmia r2, {d8-d15} 38 | 39 | add r14, r1, #VFP_D8_OFFSET 40 | vldmia r14, {d8-d15} 41 | .fpu softvfp 42 | 1: 43 | #endif 44 | 45 | /* load new registers from the second ucontext structure */ 46 | add r14, r1, #REG_OFFSET(0) 47 | ldmia r14, {r0-r12} 48 | ldr r13, [r14, #52] 49 | add r14, r14, #56 50 | ldmia r14, {r14, pc} 51 | END(libucontext_swapcontext) 52 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/arm/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/common/common-defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_COMMON_COMMON_DEFS_H 2 | #define __ARCH_COMMON_COMMON_DEFS_H 3 | 4 | #ifndef SETUP_FRAME 5 | # define SETUP_FRAME(__proc) 6 | #endif 7 | 8 | #ifndef PUSH_FRAME 9 | # define PUSH_FRAME(__proc) 10 | #endif 11 | 12 | #ifndef POP_FRAME 13 | # define POP_FRAME(__proc) 14 | #endif 15 | 16 | #ifndef ENT 17 | # define ENT(__proc) 18 | #endif 19 | 20 | #ifndef TYPE 21 | # ifdef __clang__ 22 | # define TYPE(__proc) // .type not supported 23 | # else 24 | # define TYPE(__proc) .type __proc, @function; 25 | #endif 26 | #endif 27 | 28 | #ifndef PROC_NAME 29 | # ifdef __MACH__ 30 | # define PROC_NAME(__proc) _ ## __proc 31 | # else 32 | # define PROC_NAME(__proc) __proc 33 | # endif 34 | #endif 35 | 36 | #define FUNC(__proc) \ 37 | .global PROC_NAME(__proc); \ 38 | .align 2; \ 39 | TYPE(__proc) \ 40 | ENT(__proc) \ 41 | PROC_NAME(__proc): \ 42 | SETUP_FRAME(__proc) 43 | #ifdef __clang__ 44 | #define END(__proc) 45 | #else 46 | #define END(__proc) \ 47 | .end __proc; \ 48 | .size __proc,.-__proc; 49 | #endif 50 | 51 | #ifdef EXPORT_UNPREFIXED 52 | #define ALIAS(__alias, __real) \ 53 | .weak __alias; \ 54 | __alias = __real; 55 | #else 56 | #define ALIAS(...) 57 | #endif 58 | 59 | #define REG_OFFSET(__reg) (MCONTEXT_GREGS + ((__reg) * REG_SZ)) 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/common/common-trampoline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | __attribute__ ((visibility ("hidden"))) 18 | void 19 | libucontext_trampoline(void) 20 | { 21 | register libucontext_ucontext_t *uc_link = NULL; 22 | 23 | FETCH_LINKPTR(uc_link); 24 | 25 | if (uc_link == NULL) 26 | exit(0); 27 | 28 | libucontext_setcontext(uc_link); 29 | } 30 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/common/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | #ifndef FREESTANDING 5 | 6 | #include 7 | 8 | typedef greg_t libucontext_greg_t; 9 | typedef ucontext_t libucontext_ucontext_t; 10 | 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/loongarch64/freestanding/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long long libucontext_greg_t, libucontext_gregset_t[32]; 5 | 6 | /* Container for all general registers. */ 7 | typedef __loongarch_mc_gp_state gregset_t; 8 | 9 | /* Container for floating-point state. */ 10 | typedef union __loongarch_mc_fp_state fpregset_t; 11 | 12 | union __loongarch_mc_fp_state { 13 | unsigned int __val32[256 / 32]; 14 | unsigned long long __val64[256 / 64]; 15 | }; 16 | 17 | typedef struct mcontext_t { 18 | unsigned long long __pc; 19 | unsigned long long __gregs[32]; 20 | unsigned int __flags; 21 | 22 | unsigned int __fcsr; 23 | unsigned int __vcsr; 24 | unsigned long long __fcc; 25 | union __loongarch_mc_fp_state __fpregs[32] __attribute__((__aligned__ (32))); 26 | 27 | unsigned int __reserved; 28 | } mcontext_t; 29 | 30 | typedef struct { 31 | void *ss_sp; 32 | int ss_flags; 33 | size_t ss_size; 34 | } libucontext_stack_t; 35 | 36 | typedef struct libucontext_ucontext { 37 | unsigned long uc_flags; 38 | struct libucontext_ucontext *uc_link; 39 | libucontext_stack_t uc_stack; 40 | libucontext_mcontext_t uc_mcontext; 41 | } libucontext_ucontext_t; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/loongarch64/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Peng Fan 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #define LOCALSZ (1) 14 | 15 | #include "defs.h" 16 | 17 | ALIAS(getcontext, libucontext_getcontext) 18 | 19 | FUNC(libucontext_getcontext) 20 | /* copy $sp, $fp to temporary registers so we don't clobber them */ 21 | move $a2, $sp 22 | move $a3, $fp 23 | 24 | PUSH_FRAME(libucontext_getcontext) 25 | 26 | /* set registers */ 27 | st.d $s0, $a0, REG_OFFSET(23) 28 | st.d $s1, $a0, REG_OFFSET(24) 29 | st.d $s2, $a0, REG_OFFSET(25) 30 | st.d $s3, $a0, REG_OFFSET(26) 31 | st.d $s4, $a0, REG_OFFSET(27) 32 | st.d $s5, $a0, REG_OFFSET(28) 33 | st.d $s6, $a0, REG_OFFSET(29) 34 | st.d $s7, $a0, REG_OFFSET(30) 35 | st.d $s8, $a0, REG_OFFSET(31) 36 | 37 | st.d $a2, $a0, REG_OFFSET(3) 38 | st.d $a3, $a0, REG_OFFSET(22) 39 | st.d $ra, $a0, REG_OFFSET(1) 40 | 41 | st.d $ra, $a0, (MCONTEXT_PC) 42 | 43 | POP_FRAME(libucontext_getcontext) 44 | 45 | jr $ra 46 | END(libucontext_getcontext) 47 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/loongarch64/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Peng Fan 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #define LOCALSZ (1) 14 | 15 | #include "defs.h" 16 | 17 | ALIAS(setcontext, libucontext_setcontext) 18 | 19 | FUNC(libucontext_setcontext) 20 | PUSH_FRAME(libucontext_setcontext) 21 | 22 | /* move the context to $v0, in LA, $v0 = $a0 = $4 */ 23 | move $t5, $a0 24 | 25 | /* load the registers */ 26 | ld.d $a0, $t5, REG_OFFSET(4) 27 | ld.d $a1, $t5, REG_OFFSET(5) 28 | ld.d $a2, $t5, REG_OFFSET(6) 29 | ld.d $a3, $t5, REG_OFFSET(7) 30 | ld.d $a4, $t5, REG_OFFSET(8) 31 | ld.d $a5, $t5, REG_OFFSET(9) 32 | ld.d $a6, $t5, REG_OFFSET(10) 33 | ld.d $a7, $t5, REG_OFFSET(11) 34 | 35 | ld.d $s0, $t5, REG_OFFSET(23) 36 | ld.d $s1, $t5, REG_OFFSET(24) 37 | ld.d $s2, $t5, REG_OFFSET(25) 38 | ld.d $s3, $t5, REG_OFFSET(26) 39 | ld.d $s4, $t5, REG_OFFSET(27) 40 | ld.d $s5, $t5, REG_OFFSET(28) 41 | ld.d $s6, $t5, REG_OFFSET(29) 42 | ld.d $s7, $t5, REG_OFFSET(30) 43 | ld.d $s8, $t5, REG_OFFSET(31) 44 | 45 | ld.d $sp, $t5, REG_OFFSET(3) 46 | ld.d $fp, $t5, REG_OFFSET(22) 47 | ld.d $ra, $t5, REG_OFFSET(1) 48 | 49 | ld.d $t8, $t5, (MCONTEXT_PC) 50 | 51 | jr $t8 52 | move $v0, $zero 53 | 54 | POP_FRAME(libucontext_setcontext) 55 | END(libucontext_setcontext) 56 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/loongarch64/startcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Peng Fan 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #define LOCALSZ (4) 14 | 15 | #include "defs.h" 16 | 17 | FUNC(libucontext_trampoline) 18 | 19 | /* call setcontext */ 20 | move $a0, $s0 21 | /* we receive our initial ucontext in $s0, so if $s0 is nil, bail */ 22 | beqz $s0, no_linked_context 23 | 24 | la.got $t8, libucontext_setcontext 25 | 26 | jr $t8 27 | 28 | no_linked_context: 29 | move $a0, $zero 30 | la.global $t8, exit 31 | jr $t8 32 | 33 | END(libucontext_trampoline) 34 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/m68k/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_M68K_DEFS_H 2 | #define __ARCH_M68K_DEFS_H 3 | 4 | #define REG_SZ (4) 5 | #define MCONTEXT_GREGS (24) 6 | 7 | #define REG_D0 (0) 8 | #define REG_D1 (1) 9 | #define REG_D2 (2) 10 | #define REG_D3 (3) 11 | #define REG_D4 (4) 12 | #define REG_D5 (5) 13 | #define REG_D6 (6) 14 | #define REG_D7 (7) 15 | #define REG_A0 (8) 16 | #define REG_A1 (9) 17 | #define REG_A2 (10) 18 | #define REG_A3 (11) 19 | #define REG_A4 (12) 20 | #define REG_A5 (13) 21 | #define REG_A6 (14) 22 | #define REG_A7 (15) 23 | #define REG_SP (15) 24 | #define REG_PC (16) 25 | #define REG_PS (17) 26 | 27 | #define PC_OFFSET REG_OFFSET(REG_PC) 28 | 29 | #define FETCH_LINKPTR(dest) \ 30 | asm("mov.l (%%sp, %%d7.l * 4), %0" :: "r" ((dest))) 31 | 32 | #include "common-defs.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/m68k/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | move.l 4(%sp), %a0 /* load ucontext_t pointer from stack */ 20 | 21 | movem.l %d2-%d7, REG_OFFSET(REG_D2)(%a0) /* preserve $d2 through $d7 */ 22 | movem.l %a2-%a6, REG_OFFSET(REG_A2)(%a0) /* preserve $a2 through $a6 */ 23 | 24 | lea 4(%sp), %a1 /* load stack pointer into $a1 */ 25 | move.l %a1, REG_OFFSET(REG_SP)(%a0) /* store $a1 in ucontext */ 26 | move.l (%sp), REG_OFFSET(REG_PC)(%a0) /* store return address in ucontext's PC register */ 27 | 28 | clr.l %d0 /* return 0 */ 29 | rts 30 | END(libucontext_getcontext) 31 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/m68k/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef struct sigaltstack { 5 | void *ss_sp; 6 | int ss_flags; 7 | size_t ss_size; 8 | } libucontext_stack_t; 9 | 10 | typedef int libucontext_greg_t, libucontext_gregset_t[18]; 11 | typedef struct { 12 | int f_pcr, f_psr, f_fpiaddr, f_fpregs[8][3]; 13 | } libucontext_fpregset_t; 14 | 15 | typedef struct { 16 | int version; 17 | libucontext_gregset_t gregs; 18 | libucontext_fpregset_t fpregs; 19 | } libucontext_mcontext_t; 20 | 21 | typedef struct libucontext_ucontext { 22 | unsigned long uc_flags; 23 | struct libucontext_ucontext *uc_link; 24 | libucontext_stack_t uc_stack; 25 | libucontext_mcontext_t uc_mcontext; 26 | } libucontext_ucontext_t; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/m68k/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | move.l 4(%sp), %a0 /* load ucontext_t pointer from stack */ 20 | 21 | move.l REG_OFFSET(REG_SP)(%a0), %sp /* load new stack pointer */ 22 | 23 | movem.l REG_OFFSET(REG_D2)(%a0), %d2-%d7 /* load $d2 through $d7 */ 24 | movem.l REG_OFFSET(REG_A2)(%a0), %a2-%a6 /* load $a2 through $a6 */ 25 | 26 | clr.l %d0 /* clear $d0 */ 27 | 28 | move.l REG_OFFSET(REG_PC)(%a0), %a1 /* load jump target */ 29 | 30 | jmp (%a1) /* jump to *$a1 */ 31 | END(libucontext_setcontext) 32 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/m68k/swapcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(swapcontext, libucontext_swapcontext) 16 | ALIAS(__swapcontext, libucontext_swapcontext) 17 | 18 | FUNC(libucontext_swapcontext) 19 | move.l 4(%sp), %a0 /* load save ucontext_t pointer from stack */ 20 | 21 | movem.l %d2-%d7, REG_OFFSET(REG_D2)(%a0) /* preserve $d2 through $d7 */ 22 | movem.l %a2-%a6, REG_OFFSET(REG_A2)(%a0) /* preserve $a2 through $a6 */ 23 | 24 | lea 4(%sp), %a1 /* load stack pointer into $a1 */ 25 | move.l %a1, REG_OFFSET(REG_SP)(%a0) /* store $a1 in ucontext */ 26 | move.l (%sp), REG_OFFSET(REG_PC)(%a0) /* store return address in ucontext's PC register */ 27 | 28 | move.l 8(%sp), %a0 /* load new ucontext_t pointer from stack */ 29 | 30 | move.l REG_OFFSET(REG_SP)(%a0), %sp /* load new stack pointer */ 31 | 32 | movem.l REG_OFFSET(REG_D2)(%a0), %d2-%d7 /* load $d2 through $d7 */ 33 | movem.l REG_OFFSET(REG_A2)(%a0), %a2-%a6 /* load $a2 through $a6 */ 34 | 35 | clr.l %d0 /* clear $d0 */ 36 | 37 | move.l REG_OFFSET(REG_PC)(%a0), %a1 /* load jump target */ 38 | 39 | jmp (%a1) /* jump to *$a1 */ 40 | END(libucontext_swapcontext) 41 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/m68k/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | LOCALSZ = 1 14 | 15 | #include "defs.h" 16 | 17 | ALIAS(getcontext, libucontext_getcontext) 18 | ALIAS(__getcontext, libucontext_getcontext) 19 | 20 | FUNC(libucontext_getcontext) 21 | /* copy $gp, $sp, $fp to temporary registers so we don't clobber them */ 22 | move $a2, $gp 23 | move $a3, $sp 24 | move $a1, $fp 25 | 26 | PUSH_FRAME(libucontext_getcontext) 27 | 28 | /* set registers */ 29 | sw $s0, REG_OFFSET(16)($a0) 30 | sw $s1, REG_OFFSET(17)($a0) 31 | sw $s2, REG_OFFSET(18)($a0) 32 | sw $s3, REG_OFFSET(19)($a0) 33 | sw $s4, REG_OFFSET(20)($a0) 34 | sw $s5, REG_OFFSET(21)($a0) 35 | sw $s6, REG_OFFSET(22)($a0) 36 | sw $s7, REG_OFFSET(23)($a0) 37 | 38 | sw $a2, REG_OFFSET(28)($a0) 39 | sw $a3, REG_OFFSET(29)($a0) 40 | sw $a1, REG_OFFSET(30)($a0) 41 | sw $ra, REG_OFFSET(31)($a0) 42 | sw $ra, (MCONTEXT_PC)($a0) 43 | 44 | POP_FRAME(libucontext_getcontext) 45 | 46 | jr $ra 47 | END(libucontext_getcontext) 48 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long long libucontext_greg_t, libucontext_gregset_t[32]; 5 | 6 | typedef struct { 7 | unsigned regmask, status; 8 | unsigned long long pc, gregs[32], fpregs[32]; 9 | unsigned ownedfp, fpc_csr, fpc_eir, used_math, dsp; 10 | unsigned long long mdhi, mdlo; 11 | unsigned long hi1, lo1, hi2, lo2, hi3, lo3; 12 | } libucontext_mcontext_t; 13 | 14 | typedef struct { 15 | void *ss_sp; 16 | size_t ss_size; 17 | int ss_flags; 18 | } libucontext_stack_t; 19 | 20 | typedef struct libucontext_ucontext { 21 | unsigned long uc_flags; 22 | struct libucontext_ucontext *uc_link; 23 | libucontext_stack_t uc_stack; 24 | libucontext_mcontext_t uc_mcontext; 25 | } libucontext_ucontext_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | LOCALSZ = 1 14 | 15 | #include "defs.h" 16 | 17 | ALIAS(setcontext, libucontext_setcontext) 18 | ALIAS(__setcontext, libucontext_setcontext) 19 | 20 | FUNC(libucontext_setcontext) 21 | PUSH_FRAME(libucontext_setcontext) 22 | 23 | /* move the context to $v0 */ 24 | move $v0, $a0 25 | 26 | /* load the registers */ 27 | lw $a0, REG_OFFSET(4)($v0) 28 | lw $a1, REG_OFFSET(5)($v0) 29 | lw $a2, REG_OFFSET(6)($v0) 30 | lw $a3, REG_OFFSET(7)($v0) 31 | 32 | lw $s0, REG_OFFSET(16)($v0) 33 | lw $s1, REG_OFFSET(17)($v0) 34 | lw $s2, REG_OFFSET(18)($v0) 35 | lw $s3, REG_OFFSET(19)($v0) 36 | lw $s4, REG_OFFSET(20)($v0) 37 | lw $s5, REG_OFFSET(21)($v0) 38 | lw $s6, REG_OFFSET(22)($v0) 39 | lw $s7, REG_OFFSET(23)($v0) 40 | 41 | lw $gp, REG_OFFSET(28)($v0) 42 | lw $sp, REG_OFFSET(29)($v0) 43 | lw $fp, REG_OFFSET(30)($v0) 44 | lw $ra, REG_OFFSET(31)($v0) 45 | lw $t9, (MCONTEXT_PC)($v0) 46 | 47 | move $v0, $zero 48 | jr $t9 49 | 50 | POP_FRAME(libucontext_setcontext) 51 | END(libucontext_setcontext) 52 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips/startcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | LOCALSZ = 1 14 | 15 | #include "defs.h" 16 | 17 | .hidden libucontext_trampoline 18 | FUNC(libucontext_trampoline) 19 | move $gp, $s1 20 | 21 | /* we receive our initial ucontext in $s0, so if $s0 is nil, bail */ 22 | beqz $s0, no_linked_context 23 | 24 | /* call setcontext */ 25 | move $a0, $s0 26 | la $t9, PROC_NAME(libucontext_setcontext) 27 | 28 | jr $t9 29 | 30 | no_linked_context: 31 | move $a0, $zero 32 | la $t9, exit 33 | jalr $t9 34 | nop 35 | END(libucontext_trampoline) 36 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips64/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | LOCALSZ = 1 14 | 15 | #include "defs.h" 16 | 17 | ALIAS(getcontext, libucontext_getcontext) 18 | ALIAS(__getcontext, libucontext_getcontext) 19 | 20 | FUNC(libucontext_getcontext) 21 | /* copy $gp, $sp, $fp to temporary registers so we don't clobber them */ 22 | move $a2, $gp 23 | move $a3, $sp 24 | move $a4, $fp 25 | 26 | PUSH_FRAME(libucontext_getcontext) 27 | 28 | /* set registers */ 29 | sd $s0, REG_OFFSET(16)($a0) 30 | sd $s1, REG_OFFSET(17)($a0) 31 | sd $s2, REG_OFFSET(18)($a0) 32 | sd $s3, REG_OFFSET(19)($a0) 33 | sd $s4, REG_OFFSET(20)($a0) 34 | sd $s5, REG_OFFSET(21)($a0) 35 | sd $s6, REG_OFFSET(22)($a0) 36 | sd $s7, REG_OFFSET(23)($a0) 37 | 38 | sd $a2, REG_OFFSET(28)($a0) 39 | sd $a3, REG_OFFSET(29)($a0) 40 | sd $a4, REG_OFFSET(30)($a0) 41 | sd $ra, REG_OFFSET(31)($a0) 42 | sd $ra, (MCONTEXT_PC)($a0) 43 | 44 | POP_FRAME(libucontext_getcontext) 45 | 46 | jr $ra 47 | END(libucontext_getcontext) 48 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips64/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long long libucontext_greg_t, libucontext_gregset_t[32]; 5 | 6 | typedef struct { 7 | union { 8 | double fp_dregs[32]; 9 | struct { 10 | float _fp_fregs; 11 | unsigned _fp_pad; 12 | } fp_fregs[32]; 13 | } fp_r; 14 | } libucontext_fpregset_t; 15 | 16 | typedef struct { 17 | libucontext_gregset_t gregs; 18 | libucontext_fpregset_t fpregs; 19 | libucontext_greg_t mdhi; 20 | libucontext_greg_t hi1; 21 | libucontext_greg_t hi2; 22 | libucontext_greg_t hi3; 23 | libucontext_greg_t mdlo; 24 | libucontext_greg_t lo1; 25 | libucontext_greg_t lo2; 26 | libucontext_greg_t lo3; 27 | libucontext_greg_t pc; 28 | unsigned int fpc_csr; 29 | unsigned int used_math; 30 | unsigned int dsp; 31 | unsigned int reserved; 32 | } libucontext_mcontext_t; 33 | 34 | typedef struct { 35 | void *ss_sp; 36 | size_t ss_size; 37 | int ss_flags; 38 | } libucontext_stack_t; 39 | 40 | typedef struct libucontext_ucontext { 41 | unsigned long uc_flags; 42 | struct libucontext_ucontext *uc_link; 43 | libucontext_stack_t uc_stack; 44 | libucontext_mcontext_t uc_mcontext; 45 | } libucontext_ucontext_t; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips64/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | LOCALSZ = 1 14 | 15 | #include "defs.h" 16 | 17 | ALIAS(setcontext, libucontext_setcontext) 18 | ALIAS(__setcontext, libucontext_setcontext) 19 | 20 | FUNC(libucontext_setcontext) 21 | PUSH_FRAME(libucontext_setcontext) 22 | 23 | /* move the context to $v0 */ 24 | move $v0, $a0 25 | 26 | /* load the registers */ 27 | ld $a0, REG_OFFSET(4)($v0) 28 | ld $a1, REG_OFFSET(5)($v0) 29 | ld $a2, REG_OFFSET(6)($v0) 30 | ld $a3, REG_OFFSET(7)($v0) 31 | ld $a4, REG_OFFSET(8)($v0) 32 | ld $a5, REG_OFFSET(9)($v0) 33 | ld $a6, REG_OFFSET(10)($v0) 34 | ld $a7, REG_OFFSET(11)($v0) 35 | 36 | ld $s0, REG_OFFSET(16)($v0) 37 | ld $s1, REG_OFFSET(17)($v0) 38 | ld $s2, REG_OFFSET(18)($v0) 39 | ld $s3, REG_OFFSET(19)($v0) 40 | ld $s4, REG_OFFSET(20)($v0) 41 | ld $s5, REG_OFFSET(21)($v0) 42 | ld $s6, REG_OFFSET(22)($v0) 43 | ld $s7, REG_OFFSET(23)($v0) 44 | 45 | ld $gp, REG_OFFSET(28)($v0) 46 | ld $sp, REG_OFFSET(29)($v0) 47 | ld $fp, REG_OFFSET(30)($v0) 48 | ld $ra, REG_OFFSET(31)($v0) 49 | ld $t9, (MCONTEXT_PC)($v0) 50 | 51 | move $v0, $zero 52 | jr $t9 53 | 54 | POP_FRAME(libucontext_setcontext) 55 | END(libucontext_setcontext) 56 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/mips64/startcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | LOCALSZ = 1 14 | 15 | #include "defs.h" 16 | 17 | .hidden libucontext_trampoline 18 | FUNC(libucontext_trampoline) 19 | move $gp, $s1 20 | 21 | /* we receive our initial ucontext in $s0, so if $s0 is nil, bail */ 22 | beqz $s0, no_linked_context 23 | 24 | /* call setcontext */ 25 | move $a0, $s0 26 | dla $t9, PROC_NAME(libucontext_setcontext) 27 | 28 | jr $t9 29 | 30 | no_linked_context: 31 | move $a0, $zero 32 | dla $t9, exit 33 | jalr $t9 34 | nop 35 | END(libucontext_trampoline) 36 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/or1k/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_OR1K_DEFS_H 2 | #define __ARCH_OR1K_DEFS_H 3 | 4 | #define REG_SZ (4) 5 | #define MCONTEXT_GREGS (20) 6 | 7 | #define REG_SP (1) 8 | #define REG_FP (2) 9 | #define REG_RA (9) 10 | #define REG_SA (11) 11 | #define REG_LR (14) 12 | #define REG_PC (33) 13 | #define REG_SR (34) 14 | 15 | #define PC_OFFSET REG_OFFSET(REG_PC) 16 | 17 | #define FETCH_LINKPTR(dest) \ 18 | asm("l.ori %0, r14, 0" :: "r" ((dest))) 19 | 20 | #include "common-defs.h" 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/or1k/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | l.sw REG_OFFSET(1)(r3), r1 /* store r1 and r2 */ 20 | l.sw REG_OFFSET(2)(r3), r2 21 | 22 | l.sw REG_OFFSET(9)(r3), r9 /* store r9 to both r9 and r11 in the context */ 23 | l.sw REG_OFFSET(11)(r3), r9 24 | 25 | l.sw REG_OFFSET(10)(r3), r10 /* store r10 for TLS */ 26 | 27 | l.sw REG_OFFSET(14)(r3), r14 /* store r14 through r30 even */ 28 | l.sw REG_OFFSET(16)(r3), r16 29 | l.sw REG_OFFSET(18)(r3), r18 30 | l.sw REG_OFFSET(20)(r3), r20 31 | l.sw REG_OFFSET(22)(r3), r22 32 | l.sw REG_OFFSET(24)(r3), r24 33 | l.sw REG_OFFSET(26)(r3), r26 34 | l.sw REG_OFFSET(28)(r3), r28 35 | l.sw REG_OFFSET(30)(r3), r30 36 | 37 | l.jr r9 38 | l.ori r11, r0, 0 39 | END(libucontext_getcontext) 40 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/or1k/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef struct sigaltstack { 5 | void *ss_sp; 6 | int ss_flags; 7 | size_t ss_size; 8 | } libucontext_stack_t; 9 | 10 | typedef int libucontext_greg_t, libucontext_gregset_t[32]; 11 | 12 | typedef struct { 13 | struct { 14 | libucontext_gregset_t gpr; 15 | libucontext_greg_t pc; 16 | libucontext_greg_t sr; 17 | } regs; 18 | unsigned long oldmask; 19 | } libucontext_mcontext_t; 20 | 21 | typedef struct libucontext_ucontext { 22 | unsigned long uc_flags; 23 | struct libucontext_ucontext *uc_link; 24 | libucontext_stack_t uc_stack; 25 | libucontext_mcontext_t uc_mcontext; 26 | } libucontext_ucontext_t; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/or1k/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | l.ori r30, r3, 0 /* avoid clobbering r3 by copying to r30 */ 20 | 21 | l.lwz r3, REG_OFFSET(3)(r30) /* restore r3-r8 (argument registers) */ 22 | l.lwz r4, REG_OFFSET(4)(r30) 23 | l.lwz r5, REG_OFFSET(5)(r30) 24 | l.lwz r6, REG_OFFSET(6)(r30) 25 | l.lwz r7, REG_OFFSET(7)(r30) 26 | l.lwz r8, REG_OFFSET(8)(r30) 27 | 28 | l.lwz r1, REG_OFFSET(1)(r30) /* restore stack/frame pointers */ 29 | l.lwz r2, REG_OFFSET(2)(r30) 30 | 31 | l.lwz r9, REG_OFFSET(9)(r30) /* restore link register and starting address register */ 32 | l.lwz r11, REG_OFFSET(11)(r30) 33 | 34 | l.lwz r10, REG_OFFSET(10)(r30) /* restore TLS register */ 35 | 36 | l.lwz r14, REG_OFFSET(14)(r30) /* restore r14-r30, even only */ 37 | l.lwz r16, REG_OFFSET(16)(r30) 38 | l.lwz r18, REG_OFFSET(18)(r30) 39 | l.lwz r20, REG_OFFSET(20)(r30) 40 | l.lwz r22, REG_OFFSET(22)(r30) 41 | l.lwz r24, REG_OFFSET(24)(r30) 42 | l.lwz r26, REG_OFFSET(26)(r30) 43 | l.lwz r28, REG_OFFSET(28)(r30) 44 | l.lwz r30, REG_OFFSET(30)(r30) 45 | 46 | l.jr r11 /* jump to new starting address */ 47 | l.ori r11, r0, 0 48 | END(libucontext_setcontext) 49 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/or1k/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_PPC_DEFS_H 2 | #define __ARCH_PPC_DEFS_H 3 | 4 | #define REG_R0 (0) 5 | #define REG_R1 (1) 6 | #define REG_R2 (2) 7 | #define REG_R3 (3) 8 | #define REG_R4 (4) 9 | #define REG_R5 (5) 10 | #define REG_R6 (6) 11 | #define REG_R7 (7) 12 | #define REG_R8 (8) 13 | #define REG_R9 (9) 14 | #define REG_R10 (10) 15 | #define REG_R11 (11) 16 | #define REG_R12 (12) 17 | #define REG_R13 (13) 18 | #define REG_R14 (14) 19 | #define REG_R15 (15) 20 | #define REG_R16 (16) 21 | #define REG_R17 (17) 22 | #define REG_R18 (18) 23 | #define REG_R19 (19) 24 | #define REG_R20 (20) 25 | #define REG_R21 (21) 26 | #define REG_R22 (22) 27 | #define REG_R23 (23) 28 | #define REG_R24 (24) 29 | #define REG_R25 (25) 30 | #define REG_R26 (26) 31 | #define REG_R27 (27) 32 | #define REG_R28 (28) 33 | #define REG_R29 (29) 34 | #define REG_R30 (30) 35 | #define REG_R31 (31) 36 | #define REG_R32 (32) 37 | #define REG_R33 (33) 38 | #define REG_R34 (34) 39 | #define REG_R35 (35) 40 | #define REG_R36 (36) 41 | #define REG_R37 (37) 42 | #define REG_R38 (38) 43 | #define REG_R39 (39) 44 | #define REG_R40 (40) 45 | #define REG_R41 (41) 46 | #define REG_R42 (42) 47 | #define REG_R43 (43) 48 | #define REG_R44 (44) 49 | #define REG_R45 (45) 50 | #define REG_R46 (46) 51 | #define REG_R47 (47) 52 | 53 | /* sp register is actually %r1 */ 54 | #define REG_SP REG_R1 55 | 56 | /* nip register is actually %srr0 (r32) */ 57 | #define REG_NIP REG_R32 58 | 59 | /* lnk register is actually r32 */ 60 | #define REG_LNK REG_R36 61 | 62 | #include "common-defs.h" 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Bobby Bingham 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | .hidden __libucontext_swapcontext 19 | FUNC(libucontext_getcontext) 20 | li 4, 0 21 | b __libucontext_swapcontext@local 22 | END(libucontext_getcontext) 23 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc/retfromsyscall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Ariadne Conill 3 | * Copyright (c) 2019 Bobby Bingham 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * This software is provided 'as is' and without any warranty, express or 10 | * implied. In no event shall the authors be liable for any damages arising 11 | * from the use of this software. 12 | */ 13 | 14 | #include 15 | 16 | __attribute__ ((visibility ("hidden"))) 17 | int __retfromsyscall(long retval) 18 | { 19 | if (retval < 0) { 20 | errno = -retval; 21 | return -1; 22 | } 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Bobby Bingham 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | .hidden __libucontext_swapcontext 19 | FUNC(libucontext_setcontext) 20 | mr 4, 3 21 | li 3, 0 22 | b __libucontext_swapcontext@local 23 | END(libucontext_setcontext) 24 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc/startcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | .hidden libucontext_trampoline 16 | FUNC(libucontext_trampoline) 17 | /* get the proper context into position and test for NULL */ 18 | mr. 3,31 19 | 20 | /* if we have no linked context, lets get out of here */ 21 | beq no_linked_context 22 | 23 | /* jump to setcontext */ 24 | bl libucontext_setcontext@local 25 | 26 | no_linked_context: 27 | b exit@GOT 28 | END(libucontext_trampoline) 29 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc/swapcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Bobby Bingham 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | ALIAS(swapcontext, __libucontext_swapcontext) 16 | ALIAS(__swapcontext, __libucontext_swapcontext) 17 | 18 | /* make sure this is visible regardless of EXPORT_UNPREFIXED */ 19 | .weak libucontext_swapcontext 20 | libucontext_swapcontext = __libucontext_swapcontext 21 | 22 | FUNC(__libucontext_swapcontext) 23 | li 0, 249 # SYS_swapcontext 24 | li 5, 1184 # sizeof(ucontext_t) 25 | sc 26 | 27 | .hidden __retfromsyscall 28 | b __retfromsyscall@local 29 | END(__libucontext_swapcontext) 30 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc64/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_PPC_DEFS_H 2 | #define __ARCH_PPC_DEFS_H 3 | 4 | #define REG_R0 (0) 5 | #define REG_R1 (1) 6 | #define REG_R2 (2) 7 | #define REG_R3 (3) 8 | #define REG_R4 (4) 9 | #define REG_R5 (5) 10 | #define REG_R6 (6) 11 | #define REG_R7 (7) 12 | #define REG_R8 (8) 13 | #define REG_R9 (9) 14 | #define REG_R10 (10) 15 | #define REG_R11 (11) 16 | #define REG_R12 (12) 17 | #define REG_R13 (13) 18 | #define REG_R14 (14) 19 | #define REG_R15 (15) 20 | #define REG_R16 (16) 21 | #define REG_R17 (17) 22 | #define REG_R18 (18) 23 | #define REG_R19 (19) 24 | #define REG_R20 (20) 25 | #define REG_R21 (21) 26 | #define REG_R22 (22) 27 | #define REG_R23 (23) 28 | #define REG_R24 (24) 29 | #define REG_R25 (25) 30 | #define REG_R26 (26) 31 | #define REG_R27 (27) 32 | #define REG_R28 (28) 33 | #define REG_R29 (29) 34 | #define REG_R30 (30) 35 | #define REG_R31 (31) 36 | #define REG_R32 (32) 37 | #define REG_R33 (33) 38 | #define REG_R34 (34) 39 | #define REG_R35 (35) 40 | #define REG_R36 (36) 41 | #define REG_R37 (37) 42 | #define REG_R38 (38) 43 | #define REG_R39 (39) 44 | #define REG_R40 (40) 45 | #define REG_R41 (41) 46 | #define REG_R42 (42) 47 | #define REG_R43 (43) 48 | #define REG_R44 (44) 49 | #define REG_R45 (45) 50 | #define REG_R46 (46) 51 | #define REG_R47 (47) 52 | 53 | /* sp register is actually %r1 */ 54 | #define REG_SP REG_R1 55 | 56 | /* nip register is actually %srr0 (r32) */ 57 | #define REG_NIP REG_R32 58 | 59 | /* entry register is actually %r12 */ 60 | #define REG_ENTRY REG_R12 61 | 62 | /* lnk register is actually %r36 */ 63 | #define REG_LNK REG_R36 64 | 65 | #include "common-defs.h" 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc64/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Bobby Bingham 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | .hidden __libucontext_swapcontext 19 | FUNC(libucontext_getcontext) 20 | addis 2, 12, .TOC.-libucontext_getcontext@ha 21 | addi 2, 12, .TOC.-libucontext_getcontext@l 22 | 23 | .localentry libucontext_getcontext,.-libucontext_getcontext 24 | 25 | li 4, 0 26 | b __libucontext_swapcontext 27 | END(libucontext_getcontext) 28 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc64/retfromsyscall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Ariadne Conill 3 | * Copyright (c) 2019 Bobby Bingham 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * This software is provided 'as is' and without any warranty, express or 10 | * implied. In no event shall the authors be liable for any damages arising 11 | * from the use of this software. 12 | */ 13 | 14 | #include 15 | 16 | __attribute__ ((visibility ("hidden"))) 17 | int __retfromsyscall(long retval) 18 | { 19 | if (retval < 0) { 20 | errno = -retval; 21 | return -1; 22 | } 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc64/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Bobby Bingham 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | .hidden __libucontext_swapcontext 19 | FUNC(libucontext_setcontext) 20 | addis 2, 12, .TOC.-libucontext_setcontext@ha 21 | addi 2, 12, .TOC.-libucontext_setcontext@l 22 | 23 | .localentry libucontext_setcontext,.-libucontext_setcontext 24 | 25 | mr 4, 3 26 | li 3, 0 27 | b __libucontext_swapcontext 28 | END(libucontext_setcontext) 29 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc64/startcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | .hidden libucontext_trampoline 16 | FUNC(libucontext_trampoline) 17 | cmpdi 31,0 /* test if ucontext link pointer is null */ 18 | beq no_linked_context /* if it is, exit */ 19 | 20 | /* now, call SYS_swapcontext */ 21 | mr 4,31 /* ucp is in r31 */ 22 | li 3,0 /* don't care about restoring, set oucp to NULL */ 23 | li 5,1696 /* sizeof(ucontext_t) */ 24 | li 0,249 /* SYS_swapcontext */ 25 | sc 26 | 27 | /* we should not wind back up here, if we do, exit with -1 */ 28 | li 3,-1 29 | 30 | no_linked_context: 31 | b exit@GOT 32 | nop 33 | END(libucontext_trampoline) 34 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/ppc64/swapcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Bobby Bingham 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "common-defs.h" 14 | 15 | ALIAS(swapcontext, __libucontext_swapcontext) 16 | ALIAS(__swapcontext, __libucontext_swapcontext) 17 | 18 | /* make sure this is visible regardless of EXPORT_UNPREFIXED */ 19 | .weak libucontext_swapcontext 20 | libucontext_swapcontext = __libucontext_swapcontext 21 | 22 | FUNC(__libucontext_swapcontext) 23 | addis 2, 12, .TOC.-__libucontext_swapcontext@ha 24 | addi 2, 12, .TOC.-__libucontext_swapcontext@l 25 | 26 | .localentry __libucontext_swapcontext,.-__libucontext_swapcontext 27 | 28 | li 0, 249 # SYS_swapcontext 29 | li 5, 1696 # sizeof(ucontext_t) 30 | sc 31 | 32 | .hidden __retfromsyscall 33 | b __retfromsyscall 34 | END(__libucontext_swapcontext) 35 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv32/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_RISCV64_DEFS_H 2 | #define __ARCH_RISCV64_DEFS_H 3 | 4 | #define REG_SZ (4) 5 | #define MCONTEXT_GREGS (160) 6 | 7 | /* program counter is saved in x0 as well as x1, similar to mips */ 8 | #ifndef REG_PC 9 | #define REG_PC (0) 10 | #endif 11 | 12 | #ifndef REG_RA 13 | #define REG_RA (1) 14 | #endif 15 | 16 | #ifndef REG_SP 17 | #define REG_SP (2) 18 | #endif 19 | 20 | #ifndef REG_S0 21 | #define REG_S0 (8) 22 | #endif 23 | 24 | #define REG_S1 (9) 25 | 26 | #ifndef REG_A0 27 | #define REG_A0 (10) 28 | #endif 29 | 30 | #define REG_A1 (11) 31 | #define REG_A2 (12) 32 | #define REG_A3 (13) 33 | #define REG_A4 (14) 34 | #define REG_A5 (15) 35 | #define REG_A6 (16) 36 | #define REG_A7 (17) 37 | #define REG_S2 (18) 38 | #define REG_S3 (19) 39 | #define REG_S4 (20) 40 | #define REG_S5 (21) 41 | #define REG_S6 (22) 42 | #define REG_S7 (23) 43 | #define REG_S8 (24) 44 | #define REG_S9 (25) 45 | #define REG_S10 (26) 46 | #define REG_S11 (27) 47 | 48 | #define PC_OFFSET REG_OFFSET(REG_PC) 49 | 50 | #define FETCH_LINKPTR(dest) \ 51 | asm("mv %0, s1" : "=r" ((dest))) 52 | 53 | #include "common-defs.h" 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv32/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | sw ra, REG_OFFSET(REG_PC)(a0) 20 | sw ra, REG_OFFSET(REG_RA)(a0) 21 | sw sp, REG_OFFSET(REG_SP)(a0) 22 | 23 | /* first saved register block */ 24 | sw s0, REG_OFFSET(REG_S0)(a0) 25 | sw s1, REG_OFFSET(REG_S1)(a0) 26 | 27 | /* return register block */ 28 | sw a0, REG_OFFSET(REG_A0)(a0) 29 | sw a1, REG_OFFSET(REG_A1)(a0) 30 | 31 | /* second saved register block */ 32 | sw s2, REG_OFFSET(REG_S2)(a0) 33 | sw s3, REG_OFFSET(REG_S3)(a0) 34 | sw s4, REG_OFFSET(REG_S4)(a0) 35 | sw s5, REG_OFFSET(REG_S5)(a0) 36 | sw s6, REG_OFFSET(REG_S6)(a0) 37 | sw s7, REG_OFFSET(REG_S7)(a0) 38 | sw s8, REG_OFFSET(REG_S8)(a0) 39 | sw s9, REG_OFFSET(REG_S9)(a0) 40 | sw s10, REG_OFFSET(REG_S10)(a0) 41 | sw s11, REG_OFFSET(REG_S11)(a0) 42 | 43 | /* done saving, return */ 44 | ret 45 | END(libucontext_getcontext) 46 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv32/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long libucontext_greg_t; 5 | typedef unsigned long libucontext__riscv_mc_gp_state[32]; 6 | 7 | struct libucontext__riscv_mc_f_ext_state { 8 | unsigned int __f[32]; 9 | unsigned int __fcsr; 10 | }; 11 | 12 | struct libucontext__riscv_mc_d_ext_state { 13 | unsigned long long __f[32]; 14 | unsigned int __fcsr; 15 | }; 16 | 17 | struct libucontext__riscv_mc_q_ext_state { 18 | unsigned long long __f[64] __attribute__((aligned(16))); 19 | unsigned int __fcsr; 20 | unsigned int __reserved[3]; 21 | }; 22 | 23 | union libucontext__riscv_mc_fp_state { 24 | struct libucontext__riscv_mc_f_ext_state __f; 25 | struct libucontext__riscv_mc_d_ext_state __d; 26 | struct libucontext__riscv_mc_q_ext_state __q; 27 | }; 28 | 29 | typedef struct libucontext_mcontext { 30 | libucontext__riscv_mc_gp_state __gregs; 31 | union libucontext__riscv_mc_fp_state __fpregs; 32 | } libucontext_mcontext_t; 33 | 34 | typedef struct { 35 | void *ss_sp; 36 | int ss_flags; 37 | size_t ss_size; 38 | } libucontext_stack_t; 39 | 40 | typedef struct libucontext_ucontext { 41 | unsigned long uc_flags; 42 | struct libucontext_ucontext *uc_link; 43 | libucontext_stack_t uc_stack; 44 | unsigned char __pad[128]; 45 | libucontext_mcontext_t uc_mcontext; 46 | } libucontext_ucontext_t; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv32/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | /* move $a0 to $t0 to avoid clobbering. */ 20 | mv t0, a0 21 | 22 | lw t1, PC_OFFSET(t0) 23 | lw ra, REG_OFFSET(REG_RA)(t0) 24 | lw sp, REG_OFFSET(REG_SP)(t0) 25 | 26 | /* first saved register block */ 27 | lw s0, REG_OFFSET(REG_S0)(t0) 28 | lw s1, REG_OFFSET(REG_S1)(t0) 29 | 30 | /* return register block */ 31 | lw a0, REG_OFFSET(REG_A0)(t0) 32 | lw a1, REG_OFFSET(REG_A1)(t0) 33 | 34 | /* argument register block */ 35 | lw a2, REG_OFFSET(REG_A2)(t0) 36 | lw a3, REG_OFFSET(REG_A3)(t0) 37 | lw a4, REG_OFFSET(REG_A4)(t0) 38 | lw a5, REG_OFFSET(REG_A5)(t0) 39 | lw a6, REG_OFFSET(REG_A6)(t0) 40 | lw a7, REG_OFFSET(REG_A7)(t0) 41 | 42 | /* second saved register block */ 43 | lw s2, REG_OFFSET(REG_S2)(t0) 44 | lw s3, REG_OFFSET(REG_S3)(t0) 45 | lw s4, REG_OFFSET(REG_S4)(t0) 46 | lw s5, REG_OFFSET(REG_S5)(t0) 47 | lw s6, REG_OFFSET(REG_S6)(t0) 48 | lw s7, REG_OFFSET(REG_S7)(t0) 49 | lw s8, REG_OFFSET(REG_S8)(t0) 50 | lw s9, REG_OFFSET(REG_S9)(t0) 51 | lw s10, REG_OFFSET(REG_S10)(t0) 52 | lw s11, REG_OFFSET(REG_S11)(t0) 53 | 54 | /* done restoring, jump to new pc in S1 */ 55 | jr t1 56 | END(libucontext_setcontext) 57 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv32/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv64/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_RISCV64_DEFS_H 2 | #define __ARCH_RISCV64_DEFS_H 3 | 4 | #define REG_SZ (8) 5 | #define MCONTEXT_GREGS (176) 6 | 7 | /* program counter is saved in x0 as well as x1, similar to mips */ 8 | #ifndef REG_PC 9 | #define REG_PC (0) 10 | #endif 11 | 12 | #ifndef REG_RA 13 | #define REG_RA (1) 14 | #endif 15 | 16 | #ifndef REG_SP 17 | #define REG_SP (2) 18 | #endif 19 | 20 | #ifndef REG_S0 21 | #define REG_S0 (8) 22 | #endif 23 | 24 | #define REG_S1 (9) 25 | 26 | #ifndef REG_A0 27 | #define REG_A0 (10) 28 | #endif 29 | 30 | #define REG_A1 (11) 31 | #define REG_A2 (12) 32 | #define REG_A3 (13) 33 | #define REG_A4 (14) 34 | #define REG_A5 (15) 35 | #define REG_A6 (16) 36 | #define REG_A7 (17) 37 | #define REG_S2 (18) 38 | #define REG_S3 (19) 39 | #define REG_S4 (20) 40 | #define REG_S5 (21) 41 | #define REG_S6 (22) 42 | #define REG_S7 (23) 43 | #define REG_S8 (24) 44 | #define REG_S9 (25) 45 | #define REG_S10 (26) 46 | #define REG_S11 (27) 47 | 48 | #define PC_OFFSET REG_OFFSET(REG_PC) 49 | 50 | #define FETCH_LINKPTR(dest) \ 51 | asm("mv %0, s1" : "=r" ((dest))) 52 | 53 | #include "common-defs.h" 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv64/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | sd ra, REG_OFFSET(REG_PC)(a0) 20 | sd ra, REG_OFFSET(REG_RA)(a0) 21 | sd sp, REG_OFFSET(REG_SP)(a0) 22 | 23 | /* first saved register block */ 24 | sd s0, REG_OFFSET(REG_S0)(a0) 25 | sd s1, REG_OFFSET(REG_S1)(a0) 26 | 27 | /* return register block */ 28 | sd a0, REG_OFFSET(REG_A0)(a0) 29 | sd a1, REG_OFFSET(REG_A1)(a0) 30 | 31 | /* second saved register block */ 32 | sd s2, REG_OFFSET(REG_S2)(a0) 33 | sd s3, REG_OFFSET(REG_S3)(a0) 34 | sd s4, REG_OFFSET(REG_S4)(a0) 35 | sd s5, REG_OFFSET(REG_S5)(a0) 36 | sd s6, REG_OFFSET(REG_S6)(a0) 37 | sd s7, REG_OFFSET(REG_S7)(a0) 38 | sd s8, REG_OFFSET(REG_S8)(a0) 39 | sd s9, REG_OFFSET(REG_S9)(a0) 40 | sd s10, REG_OFFSET(REG_S10)(a0) 41 | sd s11, REG_OFFSET(REG_S11)(a0) 42 | 43 | /* done saving, return */ 44 | ret 45 | END(libucontext_getcontext) 46 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv64/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long libucontext_greg_t; 5 | typedef unsigned long libucontext__riscv_mc_gp_state[32]; 6 | 7 | struct libucontext__riscv_mc_f_ext_state { 8 | unsigned int __f[32]; 9 | unsigned int __fcsr; 10 | }; 11 | 12 | struct libucontext__riscv_mc_d_ext_state { 13 | unsigned long long __f[32]; 14 | unsigned int __fcsr; 15 | }; 16 | 17 | struct libucontext__riscv_mc_q_ext_state { 18 | unsigned long long __f[64] __attribute__((aligned(16))); 19 | unsigned int __fcsr; 20 | unsigned int __reserved[3]; 21 | }; 22 | 23 | union libucontext__riscv_mc_fp_state { 24 | struct libucontext__riscv_mc_f_ext_state __f; 25 | struct libucontext__riscv_mc_d_ext_state __d; 26 | struct libucontext__riscv_mc_q_ext_state __q; 27 | }; 28 | 29 | typedef struct libucontext_mcontext { 30 | libucontext__riscv_mc_gp_state __gregs; 31 | union libucontext__riscv_mc_fp_state __fpregs; 32 | } libucontext_mcontext_t; 33 | 34 | typedef struct { 35 | void *ss_sp; 36 | int ss_flags; 37 | size_t ss_size; 38 | } libucontext_stack_t; 39 | 40 | typedef struct libucontext_ucontext { 41 | unsigned long uc_flags; 42 | struct libucontext_ucontext *uc_link; 43 | libucontext_stack_t uc_stack; 44 | unsigned char __pad[128]; 45 | libucontext_mcontext_t uc_mcontext; 46 | } libucontext_ucontext_t; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv64/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | /* move $a0 to $t0 to avoid clobbering. */ 20 | mv t0, a0 21 | 22 | ld t1, PC_OFFSET(t0) 23 | ld ra, REG_OFFSET(REG_RA)(t0) 24 | ld sp, REG_OFFSET(REG_SP)(t0) 25 | 26 | /* first saved register block */ 27 | ld s0, REG_OFFSET(REG_S0)(t0) 28 | ld s1, REG_OFFSET(REG_S1)(t0) 29 | 30 | /* return register block */ 31 | ld a0, REG_OFFSET(REG_A0)(t0) 32 | ld a1, REG_OFFSET(REG_A1)(t0) 33 | 34 | /* argument register block */ 35 | ld a2, REG_OFFSET(REG_A2)(t0) 36 | ld a3, REG_OFFSET(REG_A3)(t0) 37 | ld a4, REG_OFFSET(REG_A4)(t0) 38 | ld a5, REG_OFFSET(REG_A5)(t0) 39 | ld a6, REG_OFFSET(REG_A6)(t0) 40 | ld a7, REG_OFFSET(REG_A7)(t0) 41 | 42 | /* second saved register block */ 43 | ld s2, REG_OFFSET(REG_S2)(t0) 44 | ld s3, REG_OFFSET(REG_S3)(t0) 45 | ld s4, REG_OFFSET(REG_S4)(t0) 46 | ld s5, REG_OFFSET(REG_S5)(t0) 47 | ld s6, REG_OFFSET(REG_S6)(t0) 48 | ld s7, REG_OFFSET(REG_S7)(t0) 49 | ld s8, REG_OFFSET(REG_S8)(t0) 50 | ld s9, REG_OFFSET(REG_S9)(t0) 51 | ld s10, REG_OFFSET(REG_S10)(t0) 52 | ld s11, REG_OFFSET(REG_S11)(t0) 53 | 54 | /* done restoring, jump to new pc in S1 */ 55 | jr t1 56 | END(libucontext_setcontext) 57 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/riscv64/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/s390x/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_S390X_DEFS_H 2 | #define __ARCH_S390X_DEFS_H 3 | 4 | #define REG_SZ (8) 5 | #define AREG_SZ (4) 6 | 7 | #define MCONTEXT_GREGS (56) 8 | #define MCONTEXT_AREGS (184) 9 | #define MCONTEXT_FPREGS (248) 10 | 11 | #define AREG_OFFSET(__reg) (MCONTEXT_AREGS + ((__reg) * AREG_SZ)) 12 | 13 | #include "common-defs.h" 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/s390x/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | lgr %r1, %r2 /* use %r1 as our working register */ 20 | la %r2, 0 /* we will return 0 */ 21 | 22 | stam %a0, %a15, AREG_OFFSET(0)(%r1) /* store access registers */ 23 | stmg %r0, %r15, REG_OFFSET(0)(%r1) /* store general-purpose registers */ 24 | 25 | br %r14 /* return to where we came from */ 26 | END(libucontext_getcontext) 27 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/s390x/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long libucontext_greg_t, libucontext_gregset_t[27]; 5 | 6 | typedef struct { 7 | unsigned long mask; 8 | unsigned long addr; 9 | } libucontext_psw_t; 10 | 11 | typedef union { 12 | double d; 13 | float f; 14 | } libucontext_fpreg_t; 15 | 16 | typedef struct { 17 | unsigned fpc; 18 | libucontext_fpreg_t fprs[16]; 19 | } libucontext_fpregset_t; 20 | 21 | typedef struct { 22 | libucontext_psw_t psw; 23 | unsigned long gregs[16]; 24 | unsigned aregs[16]; 25 | libucontext_fpregset_t fpregs; 26 | } libucontext_mcontext_t; 27 | 28 | typedef struct { 29 | void *ss_sp; 30 | int ss_flags; 31 | size_t ss_size; 32 | } libucontext_stack_t; 33 | 34 | typedef struct libucontext_ucontext { 35 | unsigned long uc_flags; 36 | struct libucontext_ucontext *uc_link; 37 | libucontext_stack_t uc_stack; 38 | libucontext_mcontext_t uc_mcontext; 39 | } libucontext_ucontext_t; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/s390x/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | lgr %r1, %r2 /* use %r1 as our working register */ 20 | 21 | lam %a2, %a15, AREG_OFFSET(2)(%r1) /* load access registers, but skip %a0 and %a1 which are for TLS */ 22 | lmg %r0, %r15, REG_OFFSET(0)(%r1) /* store general-purpose registers */ 23 | 24 | br %r14 /* return to new link register address */ 25 | END(libucontext_setcontext) 26 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/s390x/startcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | .hidden libucontext_trampoline 16 | FUNC(libucontext_trampoline) 17 | basr %r14, %r7 /* run function pointer (%r7) and return here */ 18 | ltgr %r8, %r8 /* check to see if uc_link (%r8) is null */ 19 | 20 | jz no_linked_context /* if we have no linked context, prepare to exit */ 21 | 22 | lgr %r2, %r8 /* copy the uc_link structure address to %r2 */ 23 | br %r9 /* call setcontext */ 24 | 25 | no_linked_context: 26 | la %r2, 0 /* return 0 */ 27 | brasl %r14, exit@plt /* call exit */ 28 | 29 | j .+2 /* crash if exit returns */ 30 | END(libucontext_trampoline) 31 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/s390x/swapcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(swapcontext, libucontext_swapcontext) 16 | ALIAS(__swapcontext, libucontext_swapcontext) 17 | 18 | FUNC(libucontext_swapcontext) 19 | lgr %r1, %r2 /* use %r1 to save current context to */ 20 | lgr %r0, %r3 /* use %r0 for source context */ 21 | 22 | stam %a0, %a15, AREG_OFFSET(0)(%r1) /* store access registers */ 23 | stmg %r0, %r15, REG_OFFSET(0)(%r1) /* store general-purpose registers */ 24 | 25 | lgr %r2, %r0 /* swap %r0 to %r2 (XXX: figure out why it hates loading from %r0) */ 26 | lam %a2, %a15, AREG_OFFSET(2)(%r2) /* load access registers, but skip %a0 and %a1 which are for TLS */ 27 | lmg %r0, %r15, REG_OFFSET(0)(%r2) /* load general-purpose registers */ 28 | 29 | br %r14 /* return to new link register address */ 30 | END(libucontext_swapcontext) 31 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/sh/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_SH4_DEFS_H 2 | #define __ARCH_SH4_DEFS_H 3 | 4 | #define REG_SZ (4) 5 | #define MCONTEXT_GREGS (24) 6 | 7 | #define REG_SP (15) 8 | #define REG_PC (16) 9 | #define REG_PR (17) 10 | #define REG_SR (18) 11 | #define REG_GBR (19) 12 | #define REG_MACH (20) 13 | #define REG_MACL (21) 14 | 15 | #define FETCH_LINKPTR(dest) \ 16 | asm("mov r8, %0" : "=r" (dest)); 17 | 18 | #include "common-defs.h" 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/sh/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | mov r4, r0 /* move r4 to r0, and increment by REG_OFFSET(REG_MACL) + REG_SZ. */ 20 | add #(REG_OFFSET(REG_MACL + 1)), r0 21 | 22 | sts.l macl, @-r0 /* save macl/mach registers */ 23 | sts.l mach, @-r0 24 | 25 | stc.l gbr, @-r0 /* save gbr register */ 26 | 27 | movt r1 /* load T-flag into r1 */ 28 | mov.l r1, @-r0 /* save T-flag as SR register */ 29 | 30 | sts.l pr, @-r0 /* save current PR */ 31 | sts.l pr, @-r0 /* save current PR as PC as well */ 32 | 33 | mov.l r15, @-r0 /* preserve registers backwards, from r15 to r1 */ 34 | mov.l r14, @-r0 35 | mov.l r13, @-r0 36 | mov.l r12, @-r0 37 | mov.l r11, @-r0 38 | mov.l r10, @-r0 39 | mov.l r9, @-r0 40 | mov.l r8, @-r0 41 | mov.l r7, @-r0 42 | mov.l r6, @-r0 43 | mov.l r5, @-r0 44 | mov.l r4, @-r0 45 | mov.l r3, @-r0 46 | mov.l r2, @-r0 47 | mov.l r1, @-r0 48 | 49 | mov r0, r1 50 | mov #0, r0 51 | 52 | mov.l r0, @-r1 /* preserve r0 as explicit zero */ 53 | 54 | mov #0, r0 /* set return value as zero */ 55 | rts 56 | END(libucontext_getcontext) 57 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/sh/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | typedef unsigned long libucontext_greg_t, libucontext_gregset_t[16]; 5 | typedef unsigned long libucontext_freg_t, libucontext_fpregset_t[16]; 6 | typedef struct sigcontext { 7 | unsigned long oldmask; 8 | unsigned long gregs[16]; 9 | unsigned long pc, pr, sr; 10 | unsigned long gbr, mach, macl; 11 | unsigned long fpregs[16]; 12 | unsigned long xfpregs[16]; 13 | unsigned int fpscr, fpul, ownedfp; 14 | } libucontext_mcontext_t; 15 | 16 | typedef struct { 17 | void *ss_sp; 18 | int ss_flags; 19 | size_t ss_size; 20 | } libucontext_stack_t; 21 | 22 | typedef struct libucontext_ucontext { 23 | unsigned long uc_flags; 24 | struct libucontext_ucontext *uc_link; 25 | libucontext_stack_t uc_stack; 26 | libucontext_mcontext_t uc_mcontext; 27 | } libucontext_ucontext_t; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/sh/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_X86_DEFS_H 2 | #define __ARCH_X86_DEFS_H 3 | 4 | #ifndef REG_GS 5 | # define REG_GS (0) 6 | #endif 7 | 8 | #ifndef REG_FS 9 | # define REG_FS (1) 10 | #endif 11 | 12 | #ifndef REG_ES 13 | # define REG_ES (2) 14 | #endif 15 | 16 | #ifndef REG_DS 17 | # define REG_DS (3) 18 | #endif 19 | 20 | #ifndef REG_EDI 21 | # define REG_EDI (4) 22 | #endif 23 | 24 | #ifndef REG_ESI 25 | # define REG_ESI (5) 26 | #endif 27 | 28 | #ifndef REG_EBP 29 | # define REG_EBP (6) 30 | #endif 31 | 32 | #ifndef REG_ESP 33 | # define REG_ESP (7) 34 | #endif 35 | 36 | #ifndef REG_EBX 37 | # define REG_EBX (8) 38 | #endif 39 | 40 | #ifndef REG_EDX 41 | # define REG_EDX (9) 42 | #endif 43 | 44 | #ifndef REG_ECX 45 | # define REG_ECX (10) 46 | #endif 47 | 48 | #ifndef REG_EAX 49 | # define REG_EAX (11) 50 | #endif 51 | 52 | #ifndef REG_EIP 53 | # define REG_EIP (14) 54 | #endif 55 | 56 | #define REG_SZ (4) 57 | 58 | #define MCONTEXT_GREGS (20) 59 | 60 | #define FETCH_LINKPTR(dest) \ 61 | asm("movl (%%esp, %%ebx, 4), %0" : "=r" ((dest))); 62 | 63 | #include "common-defs.h" 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86/getcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(getcontext, libucontext_getcontext) 16 | ALIAS(__getcontext, libucontext_getcontext) 17 | 18 | FUNC(libucontext_getcontext) 19 | /* load address of the ucontext structure */ 20 | movl 4(%esp), %eax 21 | 22 | /* EAX is not a preserved register */ 23 | movl $0, REG_OFFSET(REG_EAX)(%eax) 24 | 25 | /* copy all of the current registers into the ucontext structure */ 26 | movl %ecx, REG_OFFSET(REG_ECX)(%eax) 27 | movl %ebx, REG_OFFSET(REG_EBX)(%eax) 28 | movl %edx, REG_OFFSET(REG_EDX)(%eax) 29 | movl %edi, REG_OFFSET(REG_EDI)(%eax) 30 | movl %esi, REG_OFFSET(REG_ESI)(%eax) 31 | movl %ebp, REG_OFFSET(REG_EBP)(%eax) 32 | 33 | /* the first argument on the stack is the jump target (%eip), so we store it in the EIP 34 | register in the ucontext structure. */ 35 | movl (%esp), %ecx 36 | movl %ecx, REG_OFFSET(REG_EIP)(%eax) 37 | 38 | /* take the stack pointer address (%esp) offsetting by 4 to skip over the jump target. */ 39 | leal 4(%esp), %ecx 40 | movl %ecx, REG_OFFSET(REG_ESP)(%eax) 41 | 42 | /* finally, save the FS segment register */ 43 | xorl %ecx, %ecx 44 | movw %fs, %cx 45 | movl %ecx, REG_OFFSET(REG_FS)(%eax) 46 | 47 | /* we're all done here, return 0 */ 48 | xorl %eax, %eax 49 | ret 50 | END(libucontext_getcontext) 51 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_BITS_H 2 | #define LIBUCONTEXT_BITS_H 3 | 4 | #define REG_GS (0) 5 | #define REG_FS (1) 6 | #define REG_ES (2) 7 | #define REG_DS (3) 8 | #define REG_EDI (4) 9 | #define REG_ESI (5) 10 | #define REG_EBP (6) 11 | #define REG_ESP (7) 12 | #define REG_EBX (8) 13 | #define REG_EDX (9) 14 | #define REG_ECX (10) 15 | #define REG_EAX (11) 16 | #define REG_EIP (14) 17 | 18 | typedef int libucontext_greg_t, libucontext_gregset_t[19]; 19 | 20 | typedef struct libucontext_fpstate { 21 | unsigned long cw, sw, tag, ipoff, cssel, dataoff, datasel; 22 | struct { 23 | unsigned short significand[4], exponent; 24 | } _st[8]; 25 | unsigned long status; 26 | } *libucontext_fpregset_t; 27 | 28 | typedef struct { 29 | libucontext_gregset_t gregs; 30 | libucontext_fpregset_t fpregs; 31 | unsigned long oldmask, cr2; 32 | } libucontext_mcontext_t; 33 | 34 | typedef struct { 35 | void *ss_sp; 36 | int ss_flags; 37 | size_t ss_size; 38 | } libucontext_stack_t; 39 | 40 | typedef struct libucontext_ucontext { 41 | unsigned long uc_flags; 42 | struct libucontext_ucontext *uc_link; 43 | libucontext_stack_t uc_stack; 44 | libucontext_mcontext_t uc_mcontext; 45 | } libucontext_ucontext_t; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | /* load address of the ucontext structure */ 20 | movl 4(%esp), %eax 21 | 22 | /* set up the FS segment register */ 23 | movl REG_OFFSET(REG_FS)(%eax), %ecx 24 | movw %cx, %fs 25 | 26 | /* fetch the new EIP */ 27 | movl REG_OFFSET(REG_EIP)(%eax), %ecx 28 | 29 | /* set up the new stack pointer */ 30 | movl REG_OFFSET(REG_ESP)(%eax), %esp 31 | 32 | /* push the return address onto the stack */ 33 | pushl %ecx 34 | 35 | /* set all of the registers */ 36 | movl REG_OFFSET(REG_EBX)(%eax), %ebx 37 | movl REG_OFFSET(REG_ECX)(%eax), %ecx 38 | movl REG_OFFSET(REG_EDX)(%eax), %edx 39 | movl REG_OFFSET(REG_EBP)(%eax), %ebp 40 | movl REG_OFFSET(REG_EDI)(%eax), %edi 41 | movl REG_OFFSET(REG_ESI)(%eax), %esi 42 | movl REG_OFFSET(REG_EAX)(%eax), %eax 43 | 44 | ret 45 | END(libucontext_setcontext) 46 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86_64/include/libucontext/bits.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef LIBUCONTEXT_BITS_H 4 | #define LIBUCONTEXT_BITS_H 5 | 6 | #define REG_R8 (0) 7 | #define REG_R9 (1) 8 | #define REG_R10 (2) 9 | #define REG_R11 (3) 10 | #define REG_R12 (4) 11 | #define REG_R13 (5) 12 | #define REG_R14 (6) 13 | #define REG_R15 (7) 14 | #define REG_RDI (8) 15 | #define REG_RSI (9) 16 | #define REG_RBP (10) 17 | #define REG_RBX (11) 18 | #define REG_RDX (12) 19 | #define REG_RAX (13) 20 | #define REG_RCX (14) 21 | #define REG_RSP (15) 22 | #define REG_RIP (16) 23 | #define REG_EFL (17) 24 | #define REG_CSGSFS (18) 25 | #define REG_ERR (19) 26 | #define REG_TRAPNO (20) 27 | #define REG_OLDMASK (21) 28 | #define REG_CR2 (22) 29 | 30 | typedef long long libucontext_greg_t, libucontext_gregset_t[23]; 31 | 32 | typedef struct libucontext_fpstate { 33 | unsigned short cwd, swd, ftw, fop; 34 | unsigned long long rip, rdp; 35 | unsigned mxcsr, mxcr_mask; 36 | struct { 37 | unsigned short significand[4], exponent, padding[3]; 38 | } _st[8]; 39 | struct { 40 | unsigned element[4]; 41 | } _xmm[16]; 42 | unsigned padding[24]; 43 | } *libucontext_fpregset_t; 44 | 45 | typedef struct { 46 | libucontext_gregset_t gregs; 47 | libucontext_fpregset_t fpregs; 48 | unsigned long long __reserved1[8]; 49 | } libucontext_mcontext_t; 50 | 51 | typedef struct { 52 | void *ss_sp; 53 | int ss_flags; 54 | size_t ss_size; 55 | } libucontext_stack_t; 56 | 57 | typedef struct libucontext_ucontext { 58 | unsigned long uc_flags; 59 | struct libucontext_ucontext *uc_link; 60 | libucontext_stack_t uc_stack; 61 | libucontext_mcontext_t uc_mcontext; 62 | } libucontext_ucontext_t; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86_64/setcontext.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | ALIAS(setcontext, libucontext_setcontext) 16 | ALIAS(__setcontext, libucontext_setcontext) 17 | 18 | FUNC(libucontext_setcontext) 19 | /* set all of the registers */ 20 | movq REG_OFFSET(REG_R8)(%rdi), %r8 21 | movq REG_OFFSET(REG_R9)(%rdi), %r9 22 | movq REG_OFFSET(REG_R10)(%rdi), %r10 23 | movq REG_OFFSET(REG_R11)(%rdi), %r11 24 | movq REG_OFFSET(REG_R12)(%rdi), %r12 25 | movq REG_OFFSET(REG_R13)(%rdi), %r13 26 | movq REG_OFFSET(REG_R14)(%rdi), %r14 27 | movq REG_OFFSET(REG_R15)(%rdi), %r15 28 | movq REG_OFFSET(REG_RSI)(%rdi), %rsi 29 | movq REG_OFFSET(REG_RBP)(%rdi), %rbp 30 | movq REG_OFFSET(REG_RBX)(%rdi), %rbx 31 | movq REG_OFFSET(REG_RDX)(%rdi), %rdx 32 | movq REG_OFFSET(REG_RAX)(%rdi), %rax 33 | movq REG_OFFSET(REG_RCX)(%rdi), %rcx 34 | movq REG_OFFSET(REG_RSP)(%rdi), %rsp 35 | 36 | /* set the jump target by pushing it to the stack. 37 | ret will pop the new %rip from the stack, causing us to jump there. */ 38 | pushq REG_OFFSET(REG_RIP)(%rdi) 39 | 40 | /* finally, set %rdi correctly. */ 41 | movq REG_OFFSET(REG_RDI)(%rdi), %rdi 42 | 43 | /* we're all done here, return 0 */ 44 | xorl %eax, %eax 45 | ret 46 | END(libucontext_setcontext) 47 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/arch/x86_64/trampoline.c: -------------------------------------------------------------------------------- 1 | #include "defs.h" 2 | #include 3 | #include "common-trampoline.c" 4 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/doc/meson.build: -------------------------------------------------------------------------------- 1 | scdoc = find_program('scdoc', required: true) 2 | 3 | custom_target( 4 | 'libucontext.3', 5 | output: 'libucontext.3', 6 | input: 'libucontext.scd', 7 | command: [ scdoc ], 8 | feed: true, 9 | capture: true, 10 | install: true, 11 | install_dir: get_option('mandir') / 'man3' 12 | ) 13 | 14 | if meson.version().version_compare('>=0.61.0') 15 | foreach link : [ 'get', 'make', 'set', 'swap' ] 16 | install_symlink('libucontext_' + link + 'context.3', 17 | pointing_to: 'libucontext.3', 18 | install_dir: get_option('mandir') / 'man3' 19 | ) 20 | endforeach 21 | endif 22 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/include/libucontext/libucontext.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUCONTEXT_LIBUCONTEXT_H 2 | #define LIBUCONTEXT_LIBUCONTEXT_H 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | int libucontext_getcontext(libucontext_ucontext_t *); 12 | void libucontext_makecontext(libucontext_ucontext_t *, void (*)(), int, ...); 13 | int libucontext_setcontext(const libucontext_ucontext_t *); 14 | int libucontext_swapcontext(libucontext_ucontext_t *, const libucontext_ucontext_t *); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/libucontext.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@LIBUCONTEXT_SHARED_LIBDIR@ 2 | static_libdir=@LIBUCONTEXT_STATIC_LIBDIR@ 3 | includedir=@LIBUCONTEXT_INCLUDEDIR@ 4 | 5 | Name: libucontext 6 | Version: @LIBUCONTEXT_VERSION@ 7 | Description: ucontext library implementation (standalone) 8 | Libs: -L${libdir} -L${static_libdir} -lucontext 9 | Cflags: -I${includedir} 10 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/libucontext_posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Ariadne Conill 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * This software is provided 'as is' and without any warranty, express or 9 | * implied. In no event shall the authors be liable for any damages arising 10 | * from the use of this software. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef FREESTANDING 19 | # error libucontext_posix cannot be built in FREESTANDING mode. 20 | #endif 21 | 22 | #ifdef DEBUG 23 | # define TRACE(...) fprintf(stderr, "TRACE: " __VA_ARGS__) 24 | #else 25 | # define TRACE(...) 26 | #endif 27 | 28 | int 29 | getcontext(libucontext_ucontext_t *ucp) 30 | { 31 | TRACE("getcontext(%p)\n", ucp); 32 | 33 | if (sigprocmask(SIG_SETMASK, NULL, &ucp->uc_sigmask)) 34 | return -1; 35 | 36 | return libucontext_getcontext(ucp); 37 | } 38 | 39 | int 40 | setcontext(const libucontext_ucontext_t *ucp) 41 | { 42 | TRACE("setcontext(%p)\n", ucp); 43 | 44 | if (sigprocmask(SIG_SETMASK, &ucp->uc_sigmask, NULL)) 45 | return -1; 46 | 47 | return libucontext_setcontext(ucp); 48 | } 49 | 50 | int 51 | swapcontext(libucontext_ucontext_t *oucp, const libucontext_ucontext_t *ucp) 52 | { 53 | TRACE("swapcontext(%p, %p)\n", oucp, ucp); 54 | 55 | if (sigprocmask(SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask)) 56 | return -1; 57 | 58 | return libucontext_swapcontext(oucp, ucp); 59 | } 60 | -------------------------------------------------------------------------------- /src/3rdparty/libucontext/meson_options.txt: -------------------------------------------------------------------------------- 1 | option('freestanding', type : 'boolean', value : false, 2 | description: 'Do not use system headers') 3 | option('export_unprefixed', type : 'boolean', value : true, 4 | description: 'Export POSIX 2004 ucontext names as alises') 5 | option('cpu', type : 'string', value : '', 6 | description: 'Target CPU architecture for cross compile') 7 | option('docs', type : 'boolean', value : false, 8 | description: 'Build and install man pages') 9 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(lib) 2 | add_subdirectory(bin) 3 | add_subdirectory(samples) 4 | -------------------------------------------------------------------------------- /src/bin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(tools) 2 | 3 | if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Coverage") 4 | add_subdirectory(lwan) 5 | endif() 6 | 7 | add_subdirectory(testrunner) 8 | -------------------------------------------------------------------------------- /src/bin/fuzz/h2_huffman_fuzzer.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" { 5 | bool lwan_h2_huffman_decode_for_fuzzing(const uint8_t *input, 6 | size_t input_len); 7 | 8 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 9 | { 10 | return lwan_h2_huffman_decode_for_fuzzing(data, size) == true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/bin/fuzz/pattern_fuzzer.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" { 6 | #include "patterns.h" 7 | #include "lwan-private.h" 8 | } 9 | 10 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 11 | { 12 | struct str_find sf[16]; 13 | static uint8_t static_data[32768]; 14 | struct config *config; 15 | struct config_line line; 16 | int indent_level = 0; 17 | const char *errmsg; 18 | 19 | if (size == 0) 20 | return 1; 21 | 22 | if (size > sizeof(static_data)) 23 | size = sizeof(static_data); 24 | memcpy(static_data, data, size); 25 | static_data[size - 1] = '\0'; 26 | 27 | LWAN_NO_DISCARD(str_find((char *)static_data, "foo/(%d+)(%a)(%d+)", sf, 28 | N_ELEMENTS(sf), &errmsg)); 29 | LWAN_NO_DISCARD(str_find((char *)static_data, "bar/(%d+)/test", sf, 30 | N_ELEMENTS(sf), &errmsg)); 31 | LWAN_NO_DISCARD(str_find((char *)static_data, "lua/rewrite/(%d+)x(%d+)", sf, 32 | N_ELEMENTS(sf), &errmsg)); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /src/bin/fuzz/request_fuzzer.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" int fuzz_parse_http_request(const uint8_t *, size_t); 4 | 5 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 6 | { 7 | return fuzz_parse_http_request(data, size); 8 | } 9 | -------------------------------------------------------------------------------- /src/bin/lwan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(BEFORE ${CMAKE_BINARY_DIR}) 2 | 3 | add_executable(lwan main.c) 4 | 5 | target_link_libraries(lwan 6 | ${LWAN_COMMON_LIBS} 7 | ${ADDITIONAL_LIBRARIES} 8 | ) 9 | 10 | INSTALL(TARGETS lwan DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) 11 | -------------------------------------------------------------------------------- /src/bin/testrunner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(BEFORE ${CMAKE_BINARY_DIR}) 2 | 3 | add_executable(testrunner main.c) 4 | 5 | target_link_libraries(testrunner 6 | ${LWAN_COMMON_LIBS} 7 | ${ADDITIONAL_LIBRARIES} 8 | ) 9 | 10 | if (${CMAKE_BUILD_TYPE} MATCHES "Coverage") 11 | include(CodeCoverage) 12 | 13 | if (Python3_Interpreter_FOUND) 14 | setup_target_for_coverage_lcov( 15 | NAME generate-coverage 16 | EXECUTABLE ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/scripts/testsuite.py -v ${CMAKE_BINARY_DIR} 17 | DEPENDENCIES testrunner 18 | BASE_DIRECTORY "${CMAKE_SOURCE_DIR}" 19 | ) 20 | message(STATUS "Python found; generate-coverage target enabled") 21 | else () 22 | message(STATUS "Python not found; coverage report disabled") 23 | endif() 24 | endif () 25 | -------------------------------------------------------------------------------- /src/bin/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (CMAKE_CROSSCOMPILING) 2 | set(IMPORT_EXECUTABLES "IMPORTFILE-NOTFILE" CACHE FILEPATH "Point it to the export file from a native build") 3 | include(${IMPORT_EXECUTABLES}) 4 | else () 5 | add_executable(mimegen 6 | mimegen.c 7 | ${CMAKE_SOURCE_DIR}/src/lib/hash.c 8 | ${CMAKE_SOURCE_DIR}/src/lib/missing.c 9 | ${CMAKE_SOURCE_DIR}/src/lib/lwan-status.c 10 | ) 11 | if (LWAN_HAVE_BROTLI) 12 | message(STATUS "Using Brotli for mimegen") 13 | target_link_libraries(mimegen ${BROTLI_LDFLAGS}) 14 | elseif (LWAN_HAVE_ZSTD) 15 | message(STATUS "Using Zstd for mimegen") 16 | target_link_libraries(mimegen ${ZSTD_LDFLAGS}) 17 | else () 18 | find_library(ZOPFLI_LIBRARY NAMES zopfli PATHS /usr/lib /usr/local/lib) 19 | if (ZOPFLI_LIBRARY) 20 | message(STATUS "Using Zopfli (${ZOPFLI_LIBRARY}) for mimegen") 21 | target_link_libraries(mimegen ${ZOPFLI_LIBRARY}) 22 | target_compile_definitions(mimegen PUBLIC -DLWAN_HAVE_ZOPFLI=1) 23 | else () 24 | message(STATUS "Using zlib (${ZLIB_LIBRARIES}) for mimegen") 25 | target_link_libraries(mimegen ${ZLIB_LIBRARIES}) 26 | endif () 27 | endif () 28 | 29 | add_executable(bin2hex 30 | bin2hex.c 31 | ) 32 | 33 | add_executable(configdump 34 | configdump.c 35 | ${CMAKE_SOURCE_DIR}/src/lib/lwan-config.c 36 | ${CMAKE_SOURCE_DIR}/src/lib/lwan-status.c 37 | ${CMAKE_SOURCE_DIR}/src/lib/lwan-strbuf.c 38 | ${CMAKE_SOURCE_DIR}/src/lib/missing.c 39 | ${CMAKE_SOURCE_DIR}/src/lib/hash.c 40 | ) 41 | 42 | add_executable(weighttp weighttp.c) 43 | target_link_libraries(weighttp ${CMAKE_THREAD_LIBS_INIT}) 44 | 45 | add_executable(statuslookupgen statuslookupgen.c) 46 | 47 | export(TARGETS statuslookupgen weighttp configdump mimegen bin2hex FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake) 48 | endif () 49 | -------------------------------------------------------------------------------- /src/bin/tools/COPYING.weighttp: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Glue Logic LLC. All rights reserved. code()gluelogic.com 2 | 3 | License: MIT License (see below) 4 | 5 | ================ 6 | 7 | This rewrite is based on weighttp by Thomas Porzelt 8 | git://git.lighttpd.net/weighttp 9 | https://github.com/lighttpd/weighttp/ 10 | 11 | ================ 12 | 13 | The MIT License 14 | 15 | Copyright (c) 2009-2011 Thomas Porzelt 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /src/cmake/EnableCFlag.cmake: -------------------------------------------------------------------------------- 1 | macro (enable_c_flag_if_avail _flag _append_to_var _set_var) 2 | check_c_compiler_flag(${_flag} ${_set_var}) 3 | 4 | if (${_set_var}) 5 | set(${_append_to_var} "${${_append_to_var}} ${_flag}") 6 | endif () 7 | endmacro () 8 | 9 | macro (enable_warning_if_supported _flag) 10 | enable_c_flag_if_avail(${_flag} CMAKE_C_FLAGS "supports ${_flag}") 11 | endmacro () 12 | -------------------------------------------------------------------------------- /src/cmake/TrySanitizer.cmake: -------------------------------------------------------------------------------- 1 | macro(try_sanitizer _type) 2 | set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) 3 | 4 | set(SANITIZER_FLAG "-fsanitize=${_type}") 5 | set(CMAKE_REQUIRED_FLAGS "-Werror ${SANITIZER_FLAG}") 6 | 7 | check_c_compiler_flag(${SANITIZER_FLAG} HAVE_SANITIZER) 8 | 9 | set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) 10 | unset(OLD_CMAKE_REQUIRED_FLAGS) 11 | 12 | if (HAVE_SANITIZER) 13 | message(STATUS "Building with ${_type} sanitizer") 14 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${SANITIZER_FLAG}") 15 | 16 | string(TOUPPER ${_type} SANITIZER_NAME) 17 | set(LWAN_HAVE_${SANITIZER_NAME}_SANITIZER 1) 18 | endif () 19 | 20 | unset(HAVE_SANITIZER) 21 | unset(SANITIZER_FLAG) 22 | endmacro () 23 | -------------------------------------------------------------------------------- /src/cmake/lwan.pc.cmake: -------------------------------------------------------------------------------- 1 | Name: ${PROJECT_NAME} 2 | Description: ${PROJECT_DESCRIPTION} 3 | Version: ${PROJECT_VERSION} 4 | Requires: ${PKG_CONFIG_REQUIRES} 5 | prefix=${CMAKE_INSTALL_PREFIX} 6 | includedir=${PKG_CONFIG_INCLUDEDIR} 7 | libdir=${PKG_CONFIG_LIBDIR} 8 | Libs: ${PKG_CONFIG_LIBS} 9 | Cflags: ${PKG_CONFIG_CFLAGS} -include ${PKG_CONFIG_INCLUDEDIR}/lwan-build-config.h 10 | -------------------------------------------------------------------------------- /src/lib/base64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | unsigned char *base64_encode(const unsigned char *src, size_t len, 7 | size_t *out_len); 8 | unsigned char *base64_decode(const unsigned char *src, size_t len, 9 | size_t *out_len); 10 | 11 | bool base64_validate(const unsigned char *src, size_t len); 12 | 13 | static inline size_t base64_encoded_len(size_t decoded_len) 14 | { 15 | /* This counts the padding bytes (by rounding to the next multiple of 4). */ 16 | return ((4u * decoded_len / 3u) + 3u) & ~3u; 17 | } 18 | -------------------------------------------------------------------------------- /src/lib/int-to-str.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | #define INT_TO_STR_BUFFER_SIZE (3 * sizeof(size_t)) 25 | 26 | char *int_to_string(ssize_t value, 27 | char buffer[static INT_TO_STR_BUFFER_SIZE], 28 | size_t *len); 29 | char *uint_to_string(size_t value, 30 | char buffer[static INT_TO_STR_BUFFER_SIZE], 31 | size_t *len); 32 | 33 | const char *uint_to_string_2_digits(size_t value) __attribute__((pure)); 34 | -------------------------------------------------------------------------------- /src/lib/lwan-arena.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2024 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "lwan-array.h" 24 | #include "lwan-coro.h" 25 | 26 | DEFINE_ARRAY_TYPE_INLINEFIRST(ptr_array, void *) 27 | 28 | struct arena { 29 | struct ptr_array ptrs; 30 | 31 | struct { 32 | void *ptr; 33 | size_t remaining; 34 | } bump_ptr_alloc; 35 | }; 36 | 37 | void arena_init(struct arena *a); 38 | struct arena *coro_arena_new(struct coro *coro); 39 | void arena_reset(struct arena *a); 40 | 41 | void *arena_alloc(struct arena *a, const size_t sz); 42 | -------------------------------------------------------------------------------- /src/lib/lwan-http-authorize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2014 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "lwan.h" 24 | 25 | bool lwan_http_authorize_init(void); 26 | void lwan_http_authorize_shutdown(void); 27 | 28 | bool lwan_http_authorize(struct lwan_request *request, 29 | const char *realm, 30 | const char *password_file); 31 | 32 | static inline bool 33 | lwan_http_authorize_urlmap(struct lwan_request *request, 34 | const struct lwan_url_map *url_map) 35 | { 36 | return lwan_http_authorize(request, url_map->authorization.realm, 37 | url_map->authorization.password_file); 38 | } 39 | -------------------------------------------------------------------------------- /src/lib/lwan-mod-lua.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2017 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "lwan.h" 23 | 24 | struct lwan_lua_settings { 25 | const char *default_type; 26 | const char *script_file; 27 | const char *script; 28 | unsigned int cache_period; 29 | }; 30 | 31 | LWAN_MODULE_FORWARD_DECL(lua); 32 | 33 | #define LUA(default_type_) \ 34 | .module = LWAN_MODULE_REF(lua), \ 35 | .args = ((struct lwan_lua_settings[]) {{ \ 36 | .default_type = default_type_ \ 37 | }}), \ 38 | .flags = 0 39 | -------------------------------------------------------------------------------- /src/lib/lwan-mod-redirect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2014 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "lwan.h" 24 | 25 | struct lwan_redirect_settings { 26 | char *to; 27 | enum lwan_http_status code; 28 | }; 29 | 30 | LWAN_MODULE_FORWARD_DECL(redirect) 31 | 32 | #define REDIRECT_CODE(to_, code_) \ 33 | .module = LWAN_MODULE_REF(redirect), \ 34 | .args = ((struct lwan_redirect_settings[]) {{ \ 35 | .to = (to_), \ 36 | .code = (code_), \ 37 | }}), \ 38 | .flags = (enum lwan_handler_flags)0 39 | 40 | #define REDIRECT(to_) REDIRECT_CODE((to_), HTTP_MOVED_PERMANENTLY) 41 | -------------------------------------------------------------------------------- /src/lib/lwan-mod-response.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2017 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "lwan.h" 23 | 24 | struct lwan_response_settings { 25 | enum lwan_http_status code; 26 | }; 27 | 28 | LWAN_MODULE_FORWARD_DECL(response) 29 | 30 | #define RESPONSE(code_) \ 31 | .module = LWAN_MODULE_REF(response), \ 32 | .args = ((struct lwan_response_settings[]) {{ \ 33 | .code = code_ \ 34 | }}), \ 35 | .flags = 0 36 | -------------------------------------------------------------------------------- /src/lib/lwan-mod-rewrite.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2014 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "lwan.h" 23 | 24 | LWAN_MODULE_FORWARD_DECL(rewrite) 25 | -------------------------------------------------------------------------------- /src/lib/lwan-tq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2019 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | struct timeout_queue { 24 | const struct lwan *lwan; 25 | struct lwan_connection *conns; 26 | struct lwan_connection head; 27 | struct timeout timeout; 28 | unsigned int current_time; 29 | unsigned int move_to_last_bump; 30 | }; 31 | 32 | void timeout_queue_init(struct timeout_queue *tq, const struct lwan *l); 33 | 34 | void timeout_queue_insert(struct timeout_queue *tq, 35 | struct lwan_connection *new_node); 36 | void timeout_queue_expire(struct timeout_queue *tq, struct lwan_connection *node); 37 | void timeout_queue_move_to_last(struct timeout_queue *tq, 38 | struct lwan_connection *conn); 39 | 40 | void timeout_queue_expire_waiting(struct timeout_queue *tq); 41 | void timeout_queue_expire_all(struct timeout_queue *tq); 42 | 43 | bool timeout_queue_empty(struct timeout_queue *tq); 44 | -------------------------------------------------------------------------------- /src/lib/lwan-trie.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | struct lwan_trie_node; 27 | 28 | struct lwan_trie { 29 | struct lwan_trie_node *root; 30 | void (*free_node)(void *data); 31 | }; 32 | 33 | bool lwan_trie_init(struct lwan_trie *trie, void (*free_node)(void *data)); 34 | void lwan_trie_destroy(struct lwan_trie *trie); 35 | 36 | void lwan_trie_add(struct lwan_trie *trie, const char *key, void *data); 37 | 38 | void *lwan_trie_lookup_prefix(struct lwan_trie *trie, const char *key); 39 | -------------------------------------------------------------------------------- /src/lib/missing/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include_next 21 | 22 | #ifndef MISSING_ASSERT_H 23 | #define MISSING_ASSERT_H 24 | 25 | #undef static_assert 26 | #if defined(LWAN_HAVE_STATIC_ASSERT) 27 | # define static_assert(expr, msg) _Static_assert(expr, msg) 28 | #else 29 | # define static_assert(expr, msg) 30 | #endif 31 | 32 | /* Macro to enable self-test on startup in debug builds. 33 | * Details: https://tia.mat.br/posts/2023/12/11/self-test.html */ 34 | #if defined(NDEBUG) 35 | #define LWAN_SELF_TEST(name) \ 36 | __attribute__((unused)) static void self_test_##name(void) 37 | #else 38 | #define LWAN_SELF_TEST(name) \ 39 | __attribute__((constructor)) static void self_test_##name(void) 40 | #endif 41 | 42 | #endif /* MISSING_ASSERT_H */ 43 | -------------------------------------------------------------------------------- /src/lib/missing/ioprio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2018 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | #if defined(__linux__) && defined(SYS_ioprio_set) 27 | 28 | #define IOPRIO_WHO_PROCESS 1 29 | #define IOPRIO_CLASS_IDLE 3 30 | #define IOPRIO_PRIO_VALUE(class, data) (((class) << 13) | (data)) 31 | 32 | static inline int ioprio_set(int which, int who, int ioprio) 33 | { 34 | return (int)syscall(SYS_ioprio_set, which, who, ioprio); 35 | } 36 | 37 | #else 38 | 39 | #define IOPRIO_WHO_PROCESS 0 40 | #define IOPRIO_PRIO_VALUE(arg1, arg2) 0 41 | #define IOPRIO_CLASS_IDLE 0 42 | 43 | static inline int ioprio_set(int which __attribute__((unused)), 44 | int who __attribute__((unused)), 45 | int ioprio __attribute__((unused))) 46 | { 47 | return 0; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/lib/missing/libproc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #if defined(__APPLE__) 22 | #include_next 23 | #else 24 | #include 25 | #include 26 | 27 | int proc_pidpath(pid_t pid, void *buffer, size_t buffersize); 28 | #endif 29 | -------------------------------------------------------------------------------- /src/lib/missing/limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_LIMITS_H 24 | #define MISSING_LIMITS_H 25 | 26 | #ifndef PATH_MAX 27 | # define PATH_MAX 4096 28 | #endif 29 | 30 | #ifndef OPEN_MAX 31 | # include 32 | # ifdef NOFILE 33 | # define OPEN_MAX NOFILE 34 | # else 35 | # define OPEN_MAX 65535 36 | # endif 37 | #endif 38 | 39 | #ifndef OFF_MAX 40 | # include 41 | #if SIZE_MAX == ULLONG_MAX 42 | # define OFF_MAX LLONG_MAX 43 | #else 44 | # define OFF_MAX LONG_MAX 45 | #endif 46 | #endif 47 | 48 | #ifndef PAGE_SIZE 49 | # include 50 | # ifndef PAGE_SIZE 51 | # ifdef EXEC_PAGESIZE 52 | # define PAGE_SIZE EXEC_PAGESIZE 53 | # else 54 | # define PAGE_SIZE 4096 55 | # endif 56 | # endif 57 | #endif 58 | 59 | #endif /* MISSING_LIMITS_H */ 60 | -------------------------------------------------------------------------------- /src/lib/missing/linux/capability.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2018 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #ifndef __MISSING_CAPABILITY_H__ 22 | #define __MISSING_CAPABILITY_H__ 23 | 24 | #if defined(__linux__) && defined(LWAN_HAVE_LINUX_CAPABILITY) 25 | 26 | #include_next 27 | #include 28 | #include 29 | #include 30 | 31 | static inline int capset(struct __user_cap_header_struct *header, 32 | struct __user_cap_data_struct *data) 33 | { 34 | #if defined(SYS_capset) 35 | return (int)syscall(SYS_capset, header, data); 36 | #else 37 | return 0; 38 | #endif 39 | } 40 | 41 | #else 42 | struct __user_cap_data_struct { 43 | unsigned int effective, permitted, inheritable; 44 | }; 45 | 46 | struct __user_cap_header_struct { 47 | #define _LINUX_CAPABILITY_VERSION_1 0 48 | unsigned int version; 49 | int pid; 50 | }; 51 | 52 | int capset(struct __user_cap_header_struct *header, 53 | struct __user_cap_data_struct *data); 54 | 55 | #endif 56 | 57 | #endif /* __MISSING_CAPABILITY_H__ */ 58 | -------------------------------------------------------------------------------- /src/lib/missing/pthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_PTHREAD_H 24 | #define MISSING_PTHREAD_H 25 | 26 | #ifndef LWAN_HAVE_PTHREADBARRIER 27 | typedef int pthread_barrierattr_t; 28 | typedef struct pthread_barrier { 29 | unsigned int count; 30 | unsigned int in; 31 | pthread_mutex_t mutex; 32 | pthread_cond_t cond; 33 | } pthread_barrier_t; 34 | 35 | int pthread_barrier_init(pthread_barrier_t *restrict barrier, 36 | const pthread_barrierattr_t *restrict attr, 37 | unsigned int count); 38 | int pthread_barrier_destroy(pthread_barrier_t *barrier); 39 | int pthread_barrier_wait(pthread_barrier_t *barrier); 40 | #endif 41 | 42 | #if defined(__FreeBSD__) || defined(__OpenBSD__) 43 | #include 44 | #endif 45 | 46 | #ifndef LWAN_HAVE_PTHREAD_SET_NAME_NP 47 | int pthread_set_name_np(pthread_t thread, const char *name); 48 | #endif 49 | 50 | #endif /* MISSING_PTHREAD_H */ 51 | -------------------------------------------------------------------------------- /src/lib/missing/pwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2019 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_PWD_H 24 | #define MISSING_PWD_H 25 | 26 | #ifndef NSS_BUFLEN_PASSWD 27 | #define NSS_BUFLEN_PASSWD 1024 28 | #endif 29 | 30 | #endif /* MISSING_PWD_H */ 31 | -------------------------------------------------------------------------------- /src/lib/missing/stdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2019 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_STDIO_H 24 | #define MISSING_STDIO_H 25 | 26 | #if !defined(LWAN_HAVE_FWRITE_UNLOCKED) 27 | size_t fwrite_unlocked(const void *ptr, size_t size, size_t n, FILE *stream); 28 | #endif 29 | 30 | #endif /* MISSING_STDIO_H */ 31 | -------------------------------------------------------------------------------- /src/lib/missing/sys/epoll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #if !defined(LWAN_HAVE_EPOLL) 22 | #pragma once 23 | #include 24 | 25 | enum epoll_event_flag { 26 | EPOLLIN = 1 << 0, 27 | EPOLLOUT = 1 << 1, 28 | EPOLLONESHOT = 1 << 2, 29 | EPOLLRDHUP = 1 << 3, 30 | EPOLLERR = 1 << 4, 31 | EPOLLET = 1 << 5, 32 | EPOLLHUP = EPOLLRDHUP 33 | }; 34 | 35 | enum epoll_op { EPOLL_CTL_ADD, EPOLL_CTL_MOD, EPOLL_CTL_DEL }; 36 | 37 | enum epoll_create_flags { EPOLL_CLOEXEC = 1 << 0 }; 38 | 39 | struct epoll_event { 40 | uint32_t events; 41 | union { 42 | void *ptr; 43 | int fd; 44 | uint32_t u32; 45 | uint64_t u64; 46 | } data; 47 | }; 48 | 49 | int epoll_create1(int flags); 50 | int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); 51 | int epoll_wait(int epfd, 52 | struct epoll_event *events, 53 | int maxevents, 54 | int timeout); 55 | 56 | #else 57 | #include_next 58 | #endif 59 | -------------------------------------------------------------------------------- /src/lib/missing/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2019 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_SYS_IOCTL_H 24 | #define MISSING_SYS_IOCTL_H 25 | 26 | #ifndef TIOCOUTQ 27 | 28 | #ifdef FIONWRITE /* FreeBSD, ... */ 29 | #define TIOCOUTQ FIONWRITE 30 | #else 31 | #define TIOCOUTQ 0 32 | #endif /* FIONWRITE */ 33 | 34 | #endif /* TIOCOUTQ */ 35 | 36 | #endif /* MISSING_SYS_IOCTL_H */ 37 | 38 | -------------------------------------------------------------------------------- /src/lib/missing/sys/mman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef _MISSING_MMAN_H_ 24 | #define _MISSING_MMAN_H_ 25 | 26 | #ifndef MAP_HUGETLB 27 | #define MAP_HUGETLB 0 28 | #endif 29 | 30 | #endif /* _MISSING_MMAN_H_ */ 31 | -------------------------------------------------------------------------------- /src/lib/missing/sys/sendfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #if defined(__FreeBSD__) || defined(__APPLE__) 22 | #include 23 | #elif defined(__OpenBSD__) 24 | /* OpenBSD has no sendfile(); implement the Lwan wrapper directly in 25 | * lwan-io-wrappers.c */ 26 | #else 27 | #include_next 28 | #endif 29 | -------------------------------------------------------------------------------- /src/lib/missing/sys/socket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_SYS_SOCKET_H 24 | #define MISSING_SYS_SOCKET_H 25 | 26 | #ifndef MSG_MORE 27 | #define MSG_MORE 0 28 | #endif 29 | 30 | #ifndef MSG_NOSIGNAL 31 | #define MSG_NOSIGNAL 0 32 | #endif 33 | 34 | #ifndef SOCK_CLOEXEC 35 | #define SOCK_CLOEXEC 0 36 | #endif 37 | 38 | #ifndef SOCK_NONBLOCK 39 | #define SOCK_NONBLOCK 00004000 40 | #endif 41 | 42 | #ifndef SOMAXCONN 43 | #define SOMAXCONN 128 44 | #endif 45 | 46 | #ifndef LWAN_HAVE_ACCEPT4 47 | int accept4(int sock, struct sockaddr *addr, socklen_t *addrlen, int flags); 48 | #endif 49 | 50 | #endif /* MISSING_SYS_SOCKET_H */ 51 | -------------------------------------------------------------------------------- /src/lib/missing/sys/syscall.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #ifndef __CYGWIN__ 22 | #include_next 23 | #endif 24 | -------------------------------------------------------------------------------- /src/lib/missing/sys/sysctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2025 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) 22 | #include_next 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /src/lib/missing/sys/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_SYS_TYPES_H 24 | #define MISSING_SYS_TYPES_H 25 | 26 | #ifndef LWAN_HAVE_GETTID 27 | pid_t gettid(void); 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/lib/missing/sys/vfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2020 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) 22 | #include 23 | #include 24 | #elif defined(__linux__) 25 | #include_next 26 | #include 27 | #endif 28 | 29 | #ifndef _MISSING_VFS_H_ 30 | #define _MISSING_VFS_H_ 31 | 32 | #if !defined(LWAN_HAVE_STATFS) 33 | struct statfs { 34 | int f_type; 35 | }; 36 | 37 | int statfs(const char *path, struct statfs *buf); 38 | #endif 39 | 40 | #ifndef TMPFS_MAGIC 41 | #define TMPFS_MAGIC 0xbebacafe 42 | #endif 43 | 44 | #endif /* _MISSING_VFS_H_ */ 45 | -------------------------------------------------------------------------------- /src/lib/missing/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_TIME_H 24 | #define MISSING_TIME_H 25 | 26 | #ifndef LWAN_HAVE_CLOCK_GETTIME 27 | typedef int clockid_t; 28 | int clock_gettime(clockid_t clk_id, struct timespec *ts); 29 | #endif 30 | 31 | #if !defined(CLOCK_MONOTONIC_COARSE) && defined(CLOCK_MONOTONIC_FAST) 32 | # define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST /* FreeBSD */ 33 | #elif !defined(CLOCK_MONOTONIC_COARSE) && defined(CLOCK_MONOTONIC_RAW_APPROX) 34 | # define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_RAW_APPROX /* New-ish macOS */ 35 | #elif !defined(CLOCK_MONOTONIC_COARSE) 36 | # if defined(CLOCK_MONOTONIC) 37 | # define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC 38 | # else 39 | # define CLOCK_MONOTONIC_COARSE 0xbebac0ca /* Old macOS, usually */ 40 | # endif 41 | #endif 42 | 43 | #if !defined(CLOCK_MONOTONIC) 44 | #define CLOCK_MONOTONIC 0xbebacafe 45 | #endif 46 | 47 | #endif /* MISSING_TIME_H */ 48 | -------------------------------------------------------------------------------- /src/lib/missing/unistd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2012 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #include_next 22 | 23 | #ifndef MISSING_UNISTD_H 24 | #define MISSING_UNISTD_H 25 | 26 | #ifndef LWAN_HAVE_PIPE2 27 | int pipe2(int pipefd[2], int flags); 28 | #endif 29 | 30 | #if defined(__APPLE__) 31 | int setresuid(uid_t ruid, uid_t euid, uid_t suid) 32 | __attribute__((warn_unused_result)); 33 | int setresgid(gid_t rgid, gid_t egid, gid_t sgid) 34 | __attribute__((warn_unused_result)); 35 | int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) 36 | __attribute__((warn_unused_result)); 37 | int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) 38 | __attribute__((warn_unused_result)); 39 | #endif 40 | 41 | #if !defined(LWAN_HAVE_GET_CURRENT_DIR_NAME) 42 | char *get_current_dir_name(void); 43 | #endif 44 | 45 | #if defined(__APPLE__) 46 | /* getrandom() is defined in on macOS */ 47 | #include 48 | #endif 49 | 50 | #endif /* MISSING_UNISTD_H */ 51 | -------------------------------------------------------------------------------- /src/lib/patterns.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: patterns.h,v 1.2 2015/06/26 17:26:29 semarie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2015 Reyk Floeter 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef PATTERNS_H 20 | #define PATTERNS_H 21 | 22 | #include 23 | 24 | #define MAXCAPTURES 32 /* Max no. of allowed captures in pattern */ 25 | #define MAXCCALLS 200 /* Max recusion depth in pattern matching */ 26 | #define MAXREPETITION 0xfffff /* Max for repetition items */ 27 | 28 | struct str_find { 29 | off_t sm_so; /* start offset of match */ 30 | off_t sm_eo; /* end offset of match */ 31 | }; 32 | 33 | struct str_match { 34 | char **sm_match; /* allocated array of matched strings */ 35 | int sm_nmatch; /* number of elements in array */ 36 | }; 37 | 38 | int str_find(const char *, const char *, struct str_find *, size_t, 39 | const char **); 40 | int str_match(const char *, const char *, struct str_match *, 41 | const char **); 42 | void str_match_free(struct str_match *); 43 | 44 | #endif /* PATTERNS_H */ 45 | -------------------------------------------------------------------------------- /src/lib/realpathat.h: -------------------------------------------------------------------------------- 1 | /* -at() version of realpath() 2 | Copyright (C) 2012 L. A. F. Pereira 3 | 4 | Based on: return the canonical absolute name of a given file. 5 | Copyright (C) 1996-2002,2004,2005,2006,2008 Free Software Foundation, Inc. 6 | This file is part of the GNU C Library. 7 | 8 | The GNU C Library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | The GNU C Library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with the GNU C Library; if not, see 20 | . */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | char *realpathat(int dirfd, char *dirfdpath, const char *name, char *resolved); 27 | char *realpathat2(int dirfd, char *dirfdpath, const char *name, char *resolved, 28 | struct stat *st); 29 | 30 | -------------------------------------------------------------------------------- /src/lib/response-template.html: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 |
16 |
17 |

{{short_message}}

18 |
19 |

{{long_message}}

20 |
21 |
22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /src/lib/servefile-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{rel_path?}} Index of {{rel_path}}{{/rel_path?}} 4 | {{^rel_path?}} Index of /{{/rel_path?}} 5 | 10 | 11 | 12 | {{rel_path?}}

Index of {{rel_path}}

{{/rel_path?}} 13 | {{^rel_path?}}

Index of /

{{/rel_path?}} 14 | {{readme?}}
{{readme}}
{{/readme?}} 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {{#file_list}} 27 | 28 | 29 | 30 | 31 | 32 | 33 | {{/file_list}} 34 | {{^#file_list}} 35 | 36 | 37 | 38 | {{/file_list}} 39 |
Parent directory
 File nameTypeSize
{{file_list.icon_alt}}{{{file_list.name}}}{{file_list.type}}{{file_list.size}}{{file_list.unit}}
Empty directory.
40 | 41 | 42 | -------------------------------------------------------------------------------- /src/lib/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | SHA-1 in C 3 | By Steve Reid 4 | 100% Public Domain 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | typedef struct { 13 | size_t count[2]; 14 | uint32_t state[5]; 15 | unsigned char buffer[64]; 16 | } sha1_context; 17 | 18 | void sha1_init(sha1_context* context); 19 | void sha1_update(sha1_context* context, const unsigned char* data, size_t len); 20 | void sha1_finalize(sha1_context* context, unsigned char digest[20]); 21 | -------------------------------------------------------------------------------- /src/samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Coverage") 2 | add_subdirectory(freegeoip) 3 | add_subdirectory(hello) 4 | add_subdirectory(hello-no-meta) 5 | add_subdirectory(clock) 6 | add_subdirectory(websocket) 7 | add_subdirectory(asyncawait) 8 | add_subdirectory(pastebin) 9 | add_subdirectory(smolsite) 10 | add_subdirectory(send-money-json-api) 11 | add_subdirectory(forthsalon) 12 | endif() 13 | 14 | add_subdirectory(techempower) 15 | -------------------------------------------------------------------------------- /src/samples/asyncawait/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(asyncawait 2 | main.c 3 | ) 4 | 5 | target_link_libraries(asyncawait 6 | ${LWAN_COMMON_LIBS} 7 | ${ADDITIONAL_LIBRARIES} 8 | ) 9 | -------------------------------------------------------------------------------- /src/samples/chatr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(chatr 2 | main.c 3 | ../techempower/json.c 4 | ) 5 | 6 | target_link_libraries(chatr 7 | ${LWAN_COMMON_LIBS} 8 | ${ADDITIONAL_LIBRARIES} 9 | ) 10 | -------------------------------------------------------------------------------- /src/samples/clock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(clock 2 | main.c 3 | gifenc.c 4 | xdaliclock.c 5 | numbers.c 6 | blocks.c 7 | pong.c 8 | ) 9 | 10 | target_link_libraries(clock 11 | ${LWAN_COMMON_LIBS} 12 | ${ADDITIONAL_LIBRARIES} 13 | m 14 | ) 15 | -------------------------------------------------------------------------------- /src/samples/clock/blocks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "gifenc.h" 7 | 8 | struct block_state { 9 | int num_to_draw; 10 | int block_index; 11 | int fall_index; 12 | int x_shift; 13 | }; 14 | 15 | struct blocks { 16 | struct block_state states[4]; 17 | int last_digits[4]; 18 | ge_GIF *gif; 19 | }; 20 | 21 | void blocks_init(struct blocks *blocks, ge_GIF *gif); 22 | uint64_t blocks_draw(struct blocks *blocks, bool odd_second); 23 | -------------------------------------------------------------------------------- /src/samples/clock/font/colonE.xbm: -------------------------------------------------------------------------------- 1 | #define colonE_width 25 2 | #define colonE_height 64 3 | static unsigned char colonE_bits[] = { 4 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9 | 0x00,0x00,0xfe,0x00,0x00,0x00,0xff,0x03,0x00,0x80,0xff,0x07,0x00,0xc0,0xff, 10 | 0x07,0x00,0xc0,0xff,0x0f,0x00,0xc0,0xff,0x0f,0x00,0xe0,0xff,0x0f,0x00,0xe0, 11 | 0xff,0x0f,0x00,0xe0,0xff,0x0f,0x00,0xc0,0xff,0x0f,0x00,0xc0,0xff,0x0f,0x00, 12 | 0xc0,0xff,0x07,0x00,0x80,0xff,0x07,0x00,0x00,0xff,0x03,0x00,0x00,0xfc,0x00, 13 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 15 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 16 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00, 17 | 0x00,0x00,0xfe,0x01,0x00,0x00,0xff,0x03,0x00,0x80,0xff,0x07,0x00,0xc0,0xff, 18 | 0x0f,0x00,0xc0,0xff,0x0f,0x00,0xe0,0xff,0x0f,0x00,0xe0,0xff,0x0f,0x00,0xe0, 19 | 0xff,0x0f,0x00,0xe0,0xff,0x0f,0x00,0xc0,0xff,0x0f,0x00,0xc0,0xff,0x0f,0x00, 20 | 0x80,0xff,0x07,0x00,0x80,0xff,0x03,0x00,0x00,0xfe,0x01,0x00,0x00,0x78,0x00, 21 | 0x00}; 22 | -------------------------------------------------------------------------------- /src/samples/clock/font/slashE.xbm: -------------------------------------------------------------------------------- 1 | #define slashE_width 25 2 | #define slashE_height 64 3 | static unsigned char slashE_bits[] = { 4 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0x7f,0x00,0xfc,0xff, 14 | 0x7f,0x00,0xfc,0xff,0x7f,0x00,0xfc,0xff,0x7f,0x00,0xfc,0xff,0x7f,0x00,0xfc, 15 | 0xff,0x7f,0x00,0xfc,0xff,0x7f,0x00,0xfc,0xff,0x7f,0x00,0xfc,0xff,0x7f,0x00, 16 | 0xfc,0xff,0x7f,0x00,0xfc,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 17 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 18 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 19 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 20 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 21 | 0x00}; 22 | -------------------------------------------------------------------------------- /src/samples/clock/gifenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * All of the source code and documentation for gifenc is released into the 3 | * public domain and provided without warranty of any kind. 4 | * 5 | * Author: Marcel Rodrigues 6 | */ 7 | 8 | #ifndef GIFENC_H 9 | #define GIFENC_H 10 | 11 | #include 12 | #include 13 | 14 | typedef struct ge_GIF { 15 | struct lwan_strbuf *buf; 16 | uint16_t w, h; 17 | int depth; 18 | int offset; 19 | int nframes; 20 | uint8_t *frame, *back; 21 | uint32_t partial; 22 | uint8_t buffer[0xFF]; 23 | } ge_GIF; 24 | 25 | ge_GIF *ge_new_gif(struct lwan_strbuf *buf, 26 | uint16_t width, 27 | uint16_t height, 28 | uint8_t *palette, 29 | int depth, 30 | int loop); 31 | void ge_add_frame(ge_GIF *gif, uint16_t delay); 32 | struct lwan_strbuf *ge_close_gif(ge_GIF *gif); 33 | 34 | #endif /* GIFENC_H */ 35 | -------------------------------------------------------------------------------- /src/samples/clock/numbers.c: -------------------------------------------------------------------------------- 1 | /* Dali Clock - a melting digital clock for PalmOS. 2 | * Copyright (c) 1991-2010 Jamie Zawinski 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software and its 5 | * documentation for any purpose is hereby granted without fee, provided that 6 | * the above copyright notice appear in all copies and that both that 7 | * copyright notice and this permission notice appear in supporting 8 | * documentation. No representations are made about the suitability of this 9 | * software for any purpose. It is provided "as is" without express or 10 | * implied warranty. 11 | */ 12 | 13 | #ifdef LWAN_HAVE_CONFIG_H 14 | #include "config.h" 15 | #endif 16 | 17 | #include "numbers.h" 18 | 19 | #include "font/colonE.xbm" 20 | #include "font/eightE.xbm" 21 | #include "font/fiveE.xbm" 22 | #include "font/fourE.xbm" 23 | #include "font/nineE.xbm" 24 | #include "font/oneE.xbm" 25 | #include "font/sevenE.xbm" 26 | #include "font/sixE.xbm" 27 | #include "font/slashE.xbm" 28 | #include "font/threeE.xbm" 29 | #include "font/twoE.xbm" 30 | #include "font/zeroE.xbm" 31 | FONT(E); 32 | 33 | const struct raw_number *get_raw_numbers(void) { return numbers_E; } 34 | -------------------------------------------------------------------------------- /src/samples/clock/xdaliclock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "gifenc.h" 5 | 6 | struct xdaliclock; 7 | 8 | struct xdaliclock *xdaliclock_new(ge_GIF *gif); 9 | void xdaliclock_free(struct xdaliclock *xdaliclock); 10 | 11 | void xdaliclock_update(struct xdaliclock *xdaliclock); 12 | uint32_t xdaliclock_get_frame_time(const struct xdaliclock *xdc); 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/samples/forthsalon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(forth 2 | forth.c 3 | ) 4 | 5 | target_compile_options(forth PRIVATE -DMAIN -DDUMP_CODE) 6 | 7 | target_link_libraries(forth 8 | ${LWAN_COMMON_LIBS} 9 | ${ADDITIONAL_LIBRARIES} 10 | m 11 | ) 12 | 13 | add_executable(forthsalon 14 | forth.c 15 | main.c 16 | ) 17 | 18 | target_compile_options(forthsalon PRIVATE -DDUMP_CODE) 19 | 20 | target_link_libraries(forthsalon 21 | ${LWAN_COMMON_LIBS} 22 | ${ADDITIONAL_LIBRARIES} 23 | m 24 | ) 25 | -------------------------------------------------------------------------------- /src/samples/forthsalon/forth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2025 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 | * USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | struct forth_ctx; 24 | 25 | struct forth_vars { 26 | double x, y; 27 | double t, dt; 28 | 29 | double memory[16]; 30 | 31 | double *final_r_stack_ptr; 32 | double *final_d_stack_ptr; 33 | }; 34 | 35 | bool forth_run(struct forth_ctx *ctx, struct forth_vars *vars); 36 | bool forth_parse_string(struct forth_ctx *ctx, const char *code); 37 | void forth_free(struct forth_ctx *ctx); 38 | struct forth_ctx *forth_new(void); 39 | size_t forth_d_stack_len(const struct forth_ctx *ctx, 40 | const struct forth_vars *vars); 41 | double forth_d_stack_pop(struct forth_vars *vars); 42 | -------------------------------------------------------------------------------- /src/samples/freegeoip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(FindPkgConfig) 2 | pkg_check_modules(SQLITE sqlite3>=3.6.20) 3 | 4 | if (SQLITE_FOUND) 5 | include_directories(BEFORE ${CMAKE_BINARY_DIR}) 6 | 7 | add_executable(freegeoip 8 | freegeoip.c 9 | ) 10 | 11 | target_link_libraries(freegeoip 12 | ${LWAN_COMMON_LIBS} 13 | ${ADDITIONAL_LIBRARIES} 14 | ${SQLITE_LIBRARIES} 15 | ${SQLITE_LDFLAGS} 16 | ) 17 | include_directories(${SQLITE_INCLUDE_DIRS}) 18 | else () 19 | message(STATUS "Freegeoip sample application not being built: SQLite not found") 20 | endif () 21 | -------------------------------------------------------------------------------- /src/samples/hello-no-meta/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(hello-no-meta 2 | main.c 3 | ) 4 | 5 | target_link_libraries(hello-no-meta 6 | ${LWAN_COMMON_LIBS} 7 | ${ADDITIONAL_LIBRARIES} 8 | ) 9 | -------------------------------------------------------------------------------- /src/samples/hello/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(hello 2 | main.c 3 | ) 4 | 5 | target_link_libraries(hello 6 | ${LWAN_COMMON_LIBS} 7 | ${ADDITIONAL_LIBRARIES} 8 | ) 9 | -------------------------------------------------------------------------------- /src/samples/hello/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lwan - web server 3 | * Copyright (c) 2018 L. A. F. Pereira 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "lwan.h" 21 | 22 | LWAN_HANDLER_ROUTE(hello_world, "/") 23 | { 24 | static const char message[] = "Hello, World!"; 25 | 26 | response->mime_type = "text/plain"; 27 | lwan_strbuf_set_static(response->buffer, message, sizeof(message) - 1); 28 | 29 | return HTTP_OK; 30 | } 31 | 32 | int main(void) { return lwan_main(); } 33 | -------------------------------------------------------------------------------- /src/samples/pastebin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(pastebin 2 | main.c 3 | ) 4 | 5 | target_link_libraries(pastebin 6 | ${LWAN_COMMON_LIBS} 7 | ${ADDITIONAL_LIBRARIES} 8 | ) 9 | -------------------------------------------------------------------------------- /src/samples/send-money-json-api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(send-money-json-api 2 | main.c 3 | ../techempower/json.c 4 | ) 5 | 6 | target_link_libraries(send-money-json-api 7 | ${LWAN_COMMON_LIBS} 8 | ${ADDITIONAL_LIBRARIES} 9 | ) 10 | -------------------------------------------------------------------------------- /src/samples/techempower/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(FindPkgConfig) 2 | pkg_check_modules(SQLITE sqlite3>=3.6.20) 3 | pkg_check_modules(MARIADB mariadb>=3.3) 4 | 5 | if (MARIADB_FOUND AND SQLITE_FOUND) 6 | add_executable(techempower 7 | techempower.c 8 | json.c 9 | database.c 10 | ) 11 | 12 | target_link_libraries(techempower 13 | ${LWAN_COMMON_LIBS} 14 | ${ADDITIONAL_LIBRARIES} 15 | ${SQLITE_LIBRARIES} 16 | ${SQLITE_LDFLAGS} 17 | ${MARIADB_LDFLAGS} 18 | ${MARIADB_LIBRARIES} 19 | ) 20 | include_directories(${SQLITE_INCLUDE_DIRS} ${MARIADB_INCLUDE_DIRS}) 21 | include_directories(BEFORE ${CMAKE_BINARY_DIR}) 22 | 23 | if (${CMAKE_BUILD_TYPE} MATCHES "Coverage") 24 | if (Python3_Interpreter_FOUND) 25 | add_dependencies(generate-coverage techempower) 26 | endif() 27 | endif () 28 | else () 29 | message(STATUS "Not building benchmark suite: database libraries not found.") 30 | endif () 31 | -------------------------------------------------------------------------------- /src/samples/techempower/techempower.conf: -------------------------------------------------------------------------------- 1 | listener *:8080 2 | 3 | site { 4 | # For main TWFB benchmarks 5 | &plaintext /plaintext 6 | &json /json 7 | &db /db 8 | &queries /queries 9 | &cached_queries /cached-queries 10 | &fortunes /fortunes 11 | 12 | # For Lua version of TWFB benchmarks 13 | lua /lua. { 14 | default_type = text/plain 15 | cache period = 1h 16 | script='''local json = require "json" 17 | 18 | function handle_get_plaintext(req) 19 | req:set_response("Hello, World!") 20 | end 21 | 22 | function handle_get_json(req) 23 | req:set_headers({["Content-Type"]="application/json"}) 24 | req:set_response(json.encode({message="Hello, World!"})) 25 | end''' 26 | } 27 | 28 | # For test harness 29 | &quit_lwan /quit-lwan 30 | &plaintext /hello 31 | } 32 | -------------------------------------------------------------------------------- /src/samples/techempower/techempower.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/src/samples/techempower/techempower.db -------------------------------------------------------------------------------- /src/samples/websocket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(websocket 2 | main.c 3 | ) 4 | 5 | target_link_libraries(websocket 6 | ${LWAN_COMMON_LIBS} 7 | ${ADDITIONAL_LIBRARIES} 8 | ) 9 | 10 | add_custom_command( 11 | OUTPUT ${CMAKE_BINARY_DIR}/websocket-sample.h 12 | COMMAND bin2hex 13 | ${CMAKE_SOURCE_DIR}/src/samples/websocket/index.html index_html > ${CMAKE_BINARY_DIR}/websocket-sample.h 14 | DEPENDS ${CMAKE_SOURCE_DIR}/src/samples/websocket/index.html 15 | bin2hex 16 | COMMENT "Bundling websocket sample index" 17 | ) 18 | add_custom_target(generate_websocket_sample 19 | DEPENDS ${CMAKE_BINARY_DIR}/websocket-sample.h 20 | ) 21 | 22 | add_dependencies(websocket generate_websocket_sample) 23 | -------------------------------------------------------------------------------- /wwwroot/100.html: -------------------------------------------------------------------------------- 1 | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -------------------------------------------------------------------------------- /wwwroot/icons/README.TXT: -------------------------------------------------------------------------------- 1 | Public Domain Icons 2 | ------------------- 3 | 4 | These icons were originally made for Mosaic for X and have been included in 5 | the NCSA httpd and Apache server distributions in the past. They are in the 6 | public domain and may be freely included in any application. The originals 7 | were done by Kevin Hughes (kevinh@kevcom.com). Andy Polyakov tuned the icon 8 | colors and added few new images. 9 | 10 | If you'd like to contribute additions to this set, contact the httpd 11 | documentation project http://httpd.apache.org/docs-project/. 12 | 13 | Almost all of these icons are 20x22 pixels in size. There are alternative 14 | icons in the "small" directory that are 16x16 in size, provided by Mike 15 | Brown (mike@hyperreal.org). 16 | -------------------------------------------------------------------------------- /wwwroot/icons/back.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/wwwroot/icons/back.gif -------------------------------------------------------------------------------- /wwwroot/icons/file.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/wwwroot/icons/file.gif -------------------------------------------------------------------------------- /wwwroot/icons/folder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpereira/lwan/0927e3eb8f08ab8a4e238bcb7cc2388f6082163b/wwwroot/icons/folder.gif -------------------------------------------------------------------------------- /wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 27 | 28 | 29 |
30 |

It works!

31 |
32 | 33 | 34 | --------------------------------------------------------------------------------