From 1f60d832738e1eff910fc84da730eaa7e7e33981 Mon Sep 17 00:00:00 2001 From: zhanglinhao Date: Wed, 30 Dec 2020 10:58:58 +0800 Subject: [PATCH] iTrustee SDK init --- CHANGELOG | 9 + License/LICENSE | 127 + ...Third_Party_Open_Source_Software_Notice.md | 42 + README.en.md | 56 +- README.md | 57 +- build/mk/cloud/common.mk | 36 + build/signtools/cloud/config_cloud.ini | 49 + .../signtools/cloud/rsa_public_key_cloud.pem | 11 + build/signtools/generate_signature.py | 57 + build/signtools/manifest.py | 322 ++ build/signtools/signtool_v3.py | 413 +++ build/tools/ta_link_64.ld | 221 ++ include/CA/tee_client_api.h | 186 + include/CA/tee_client_constants.h | 120 + include/CA/tee_client_list.h | 107 + include/CA/tee_client_log.h | 29 + include/CA/tee_client_type.h | 154 + include/TA/huawei_ext/crypto_wrapper.h | 582 +++ include/TA/huawei_ext/tee_crypto_hal.h | 48 + include/TA/huawei_ext/tee_ext_api.h | 100 + include/TA/huawei_ext/tee_log.h | 219 ++ include/TA/tee_arith_api.h | 477 +++ include/TA/tee_core_api.h | 85 + include/TA/tee_crypto_api.h | 724 ++++ include/TA/tee_defines.h | 370 ++ include/TA/tee_mem_mgmt_api.h | 165 + include/TA/tee_object_api.h | 290 ++ include/TA/tee_property_api.h | 189 + include/TA/tee_time_api.h | 167 + src/CA/cloud/libteec_adaptor.c | 271 ++ test/CA/helloworld/ReadMe.txt | 2 + test/CA/helloworld/ca_demo.c | 96 + test/CA/helloworld/cloud/Makefile | 23 + test/TA/helloworld/ReadMe.txt | 2 + test/TA/helloworld/cloud/Makefile | 28 + test/TA/helloworld/config.mk | 10 + test/TA/helloworld/manifest.txt | 7 + test/TA/helloworld/ta_demo.c | 156 + thirdparty/open_source/musl/libc/alloca.h | 19 + .../musl/libc/arch/aarch64/atomic_arch.h | 82 + .../musl/libc/arch/aarch64/bits/alltypes.h | 466 +++ .../musl/libc/arch/aarch64/bits/alltypes.h.in | 24 + .../musl/libc/arch/aarch64/bits/fcntl.h | 38 + .../musl/libc/arch/aarch64/bits/fenv.h | 19 + .../musl/libc/arch/aarch64/bits/float.h | 16 + .../musl/libc/arch/aarch64/bits/hwcap.h | 40 + .../musl/libc/arch/aarch64/bits/posix.h | 2 + .../musl/libc/arch/aarch64/bits/reg.h | 2 + .../musl/libc/arch/aarch64/bits/setjmp.h | 1 + .../musl/libc/arch/aarch64/bits/signal.h | 153 + .../musl/libc/arch/aarch64/bits/stat.h | 18 + .../musl/libc/arch/aarch64/bits/stdint.h | 20 + .../musl/libc/arch/aarch64/bits/syscall.h | 551 +++ .../musl/libc/arch/aarch64/bits/syscall.h.in | 292 ++ .../musl/libc/arch/aarch64/bits/user.h | 16 + .../musl/libc/arch/aarch64/crt_arch.h | 24 + .../musl/libc/arch/aarch64/fp_arch.h | 25 + .../musl/libc/arch/aarch64/kstat.h | 21 + .../musl/libc/arch/aarch64/pthread_arch.h | 12 + .../musl/libc/arch/aarch64/reloc.h | 24 + .../musl/libc/arch/aarch64/syscall_arch.h | 78 + .../musl/libc/arch/arm/bits/alltypes.h | 448 +++ .../musl/libc/arch/arm/bits/syscall.h | 715 ++++ .../musl/libc/arch/generic/bits/dirent.h | 11 + .../musl/libc/arch/generic/bits/errno.h | 134 + .../musl/libc/arch/generic/bits/fcntl.h | 40 + .../musl/libc/arch/generic/bits/fenv.h | 10 + .../musl/libc/arch/generic/bits/hwcap.h | 0 .../musl/libc/arch/generic/bits/io.h | 0 .../musl/libc/arch/generic/bits/ioctl.h | 115 + .../musl/libc/arch/generic/bits/ioctl_fix.h | 0 .../musl/libc/arch/generic/bits/ipc.h | 11 + .../musl/libc/arch/generic/bits/ipcstat.h | 1 + .../musl/libc/arch/generic/bits/kd.h | 1 + .../musl/libc/arch/generic/bits/limits.h | 0 .../musl/libc/arch/generic/bits/link.h | 1 + .../musl/libc/arch/generic/bits/mman.h | 0 .../musl/libc/arch/generic/bits/msg.h | 12 + .../musl/libc/arch/generic/bits/poll.h | 0 .../musl/libc/arch/generic/bits/ptrace.h | 0 .../musl/libc/arch/generic/bits/resource.h | 0 .../musl/libc/arch/generic/bits/sem.h | 14 + .../musl/libc/arch/generic/bits/shm.h | 24 + .../musl/libc/arch/generic/bits/socket.h | 0 .../musl/libc/arch/generic/bits/soundcard.h | 1 + .../musl/libc/arch/generic/bits/statfs.h | 7 + .../musl/libc/arch/generic/bits/termios.h | 166 + .../musl/libc/arch/generic/bits/vt.h | 1 + .../musl/libc/arch/generic/fp_arch.h | 0 thirdparty/open_source/musl/libc/arpa/inet.h | 36 + thirdparty/open_source/musl/libc/assert.h | 23 + thirdparty/open_source/musl/libc/byteswap.h | 26 + thirdparty/open_source/musl/libc/ctype.h | 75 + thirdparty/open_source/musl/libc/dlfcn.h | 46 + thirdparty/open_source/musl/libc/elf.h | 3292 +++++++++++++++++ thirdparty/open_source/musl/libc/endian.h | 80 + thirdparty/open_source/musl/libc/errno.h | 27 + thirdparty/open_source/musl/libc/fcntl.h | 216 ++ thirdparty/open_source/musl/libc/features.h | 40 + .../open_source/musl/libc/hm/hm_malloc.h | 17 + thirdparty/open_source/musl/libc/hm/hm_stat.h | 65 + .../open_source/musl/libc/hm/hongmeng.h | 15 + thirdparty/open_source/musl/libc/hm/io.h | 38 + thirdparty/open_source/musl/libc/hm/thread.h | 29 + .../open_source/musl/libc/hm/threadtypes.h | 11 + thirdparty/open_source/musl/libc/inttypes.h | 229 ++ thirdparty/open_source/musl/libc/limits.h | 164 + thirdparty/open_source/musl/libc/locale.h | 86 + thirdparty/open_source/musl/libc/malloc.h | 25 + thirdparty/open_source/musl/libc/math.h | 442 +++ thirdparty/open_source/musl/libc/netdb.h | 156 + thirdparty/open_source/musl/libc/netinet/in.h | 415 +++ .../open_source/musl/libc/netinet/tcp.h | 282 ++ thirdparty/open_source/musl/libc/poll.h | 57 + thirdparty/open_source/musl/libc/pthread.h | 243 ++ thirdparty/open_source/musl/libc/sched.h | 147 + thirdparty/open_source/musl/libc/semaphore.h | 39 + thirdparty/open_source/musl/libc/setjmp.h | 41 + thirdparty/open_source/musl/libc/signal.h | 286 ++ thirdparty/open_source/musl/libc/stdalign.h | 20 + thirdparty/open_source/musl/libc/stdarg.h | 21 + thirdparty/open_source/musl/libc/stdbool.h | 14 + thirdparty/open_source/musl/libc/stddef.h | 27 + thirdparty/open_source/musl/libc/stdint.h | 117 + thirdparty/open_source/musl/libc/stdio.h | 222 ++ thirdparty/open_source/musl/libc/stdlib.h | 175 + thirdparty/open_source/musl/libc/string.h | 105 + thirdparty/open_source/musl/libc/strings.h | 39 + thirdparty/open_source/musl/libc/sys/auxv.h | 17 + thirdparty/open_source/musl/libc/sys/cdefs.h | 22 + thirdparty/open_source/musl/libc/sys/ioctl.h | 125 + thirdparty/open_source/musl/libc/sys/mman.h | 151 + thirdparty/open_source/musl/libc/sys/param.h | 35 + thirdparty/open_source/musl/libc/sys/procfs.h | 63 + .../open_source/musl/libc/sys/resource.h | 116 + thirdparty/open_source/musl/libc/sys/select.h | 46 + thirdparty/open_source/musl/libc/sys/socket.h | 413 +++ thirdparty/open_source/musl/libc/sys/stat.h | 127 + .../open_source/musl/libc/sys/syscall.h | 6 + .../open_source/musl/libc/sys/sysmacros.h | 15 + thirdparty/open_source/musl/libc/sys/time.h | 76 + thirdparty/open_source/musl/libc/sys/times.h | 25 + thirdparty/open_source/musl/libc/sys/types.h | 85 + thirdparty/open_source/musl/libc/sys/uio.h | 48 + thirdparty/open_source/musl/libc/sys/un.h | 31 + thirdparty/open_source/musl/libc/sys/user.h | 16 + thirdparty/open_source/musl/libc/syscall.h | 1 + thirdparty/open_source/musl/libc/time.h | 168 + thirdparty/open_source/musl/libc/unistd.h | 469 +++ thirdparty/open_source/musl/libc/wchar.h | 205 + thirdparty/open_source/musl/libc/wctype.h | 79 + 151 files changed, 19316 insertions(+), 73 deletions(-) create mode 100644 CHANGELOG create mode 100755 License/LICENSE create mode 100755 License/Third_Party_Open_Source_Software_Notice.md create mode 100755 build/mk/cloud/common.mk create mode 100644 build/signtools/cloud/config_cloud.ini create mode 100644 build/signtools/cloud/rsa_public_key_cloud.pem create mode 100644 build/signtools/generate_signature.py create mode 100755 build/signtools/manifest.py create mode 100755 build/signtools/signtool_v3.py create mode 100644 build/tools/ta_link_64.ld create mode 100644 include/CA/tee_client_api.h create mode 100644 include/CA/tee_client_constants.h create mode 100644 include/CA/tee_client_list.h create mode 100644 include/CA/tee_client_log.h create mode 100644 include/CA/tee_client_type.h create mode 100755 include/TA/huawei_ext/crypto_wrapper.h create mode 100755 include/TA/huawei_ext/tee_crypto_hal.h create mode 100644 include/TA/huawei_ext/tee_ext_api.h create mode 100644 include/TA/huawei_ext/tee_log.h create mode 100755 include/TA/tee_arith_api.h create mode 100644 include/TA/tee_core_api.h create mode 100644 include/TA/tee_crypto_api.h create mode 100755 include/TA/tee_defines.h create mode 100644 include/TA/tee_mem_mgmt_api.h create mode 100644 include/TA/tee_object_api.h create mode 100644 include/TA/tee_property_api.h create mode 100644 include/TA/tee_time_api.h create mode 100644 src/CA/cloud/libteec_adaptor.c create mode 100755 test/CA/helloworld/ReadMe.txt create mode 100755 test/CA/helloworld/ca_demo.c create mode 100755 test/CA/helloworld/cloud/Makefile create mode 100755 test/TA/helloworld/ReadMe.txt create mode 100755 test/TA/helloworld/cloud/Makefile create mode 100644 test/TA/helloworld/config.mk create mode 100755 test/TA/helloworld/manifest.txt create mode 100755 test/TA/helloworld/ta_demo.c create mode 100644 thirdparty/open_source/musl/libc/alloca.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/atomic_arch.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h.in create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/fcntl.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/fenv.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/float.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/hwcap.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/posix.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/reg.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/setjmp.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/signal.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/stat.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/stdint.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h.in create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/bits/user.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/crt_arch.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/fp_arch.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/kstat.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/pthread_arch.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/reloc.h create mode 100644 thirdparty/open_source/musl/libc/arch/aarch64/syscall_arch.h create mode 100644 thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h create mode 100644 thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/dirent.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/errno.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/fcntl.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/fenv.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/hwcap.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/io.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/ioctl.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/ioctl_fix.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/ipc.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/ipcstat.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/kd.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/limits.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/link.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/mman.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/msg.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/poll.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/ptrace.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/resource.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/sem.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/shm.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/socket.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/soundcard.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/statfs.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/termios.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/bits/vt.h create mode 100644 thirdparty/open_source/musl/libc/arch/generic/fp_arch.h create mode 100644 thirdparty/open_source/musl/libc/arpa/inet.h create mode 100644 thirdparty/open_source/musl/libc/assert.h create mode 100644 thirdparty/open_source/musl/libc/byteswap.h create mode 100644 thirdparty/open_source/musl/libc/ctype.h create mode 100644 thirdparty/open_source/musl/libc/dlfcn.h create mode 100644 thirdparty/open_source/musl/libc/elf.h create mode 100644 thirdparty/open_source/musl/libc/endian.h create mode 100644 thirdparty/open_source/musl/libc/errno.h create mode 100644 thirdparty/open_source/musl/libc/fcntl.h create mode 100644 thirdparty/open_source/musl/libc/features.h create mode 100644 thirdparty/open_source/musl/libc/hm/hm_malloc.h create mode 100644 thirdparty/open_source/musl/libc/hm/hm_stat.h create mode 100644 thirdparty/open_source/musl/libc/hm/hongmeng.h create mode 100644 thirdparty/open_source/musl/libc/hm/io.h create mode 100644 thirdparty/open_source/musl/libc/hm/thread.h create mode 100644 thirdparty/open_source/musl/libc/hm/threadtypes.h create mode 100644 thirdparty/open_source/musl/libc/inttypes.h create mode 100644 thirdparty/open_source/musl/libc/limits.h create mode 100644 thirdparty/open_source/musl/libc/locale.h create mode 100644 thirdparty/open_source/musl/libc/malloc.h create mode 100644 thirdparty/open_source/musl/libc/math.h create mode 100644 thirdparty/open_source/musl/libc/netdb.h create mode 100644 thirdparty/open_source/musl/libc/netinet/in.h create mode 100644 thirdparty/open_source/musl/libc/netinet/tcp.h create mode 100644 thirdparty/open_source/musl/libc/poll.h create mode 100644 thirdparty/open_source/musl/libc/pthread.h create mode 100644 thirdparty/open_source/musl/libc/sched.h create mode 100644 thirdparty/open_source/musl/libc/semaphore.h create mode 100644 thirdparty/open_source/musl/libc/setjmp.h create mode 100644 thirdparty/open_source/musl/libc/signal.h create mode 100644 thirdparty/open_source/musl/libc/stdalign.h create mode 100644 thirdparty/open_source/musl/libc/stdarg.h create mode 100644 thirdparty/open_source/musl/libc/stdbool.h create mode 100644 thirdparty/open_source/musl/libc/stddef.h create mode 100644 thirdparty/open_source/musl/libc/stdint.h create mode 100644 thirdparty/open_source/musl/libc/stdio.h create mode 100644 thirdparty/open_source/musl/libc/stdlib.h create mode 100644 thirdparty/open_source/musl/libc/string.h create mode 100644 thirdparty/open_source/musl/libc/strings.h create mode 100644 thirdparty/open_source/musl/libc/sys/auxv.h create mode 100644 thirdparty/open_source/musl/libc/sys/cdefs.h create mode 100644 thirdparty/open_source/musl/libc/sys/ioctl.h create mode 100644 thirdparty/open_source/musl/libc/sys/mman.h create mode 100644 thirdparty/open_source/musl/libc/sys/param.h create mode 100644 thirdparty/open_source/musl/libc/sys/procfs.h create mode 100644 thirdparty/open_source/musl/libc/sys/resource.h create mode 100644 thirdparty/open_source/musl/libc/sys/select.h create mode 100644 thirdparty/open_source/musl/libc/sys/socket.h create mode 100644 thirdparty/open_source/musl/libc/sys/stat.h create mode 100644 thirdparty/open_source/musl/libc/sys/syscall.h create mode 100644 thirdparty/open_source/musl/libc/sys/sysmacros.h create mode 100644 thirdparty/open_source/musl/libc/sys/time.h create mode 100644 thirdparty/open_source/musl/libc/sys/times.h create mode 100644 thirdparty/open_source/musl/libc/sys/types.h create mode 100644 thirdparty/open_source/musl/libc/sys/uio.h create mode 100644 thirdparty/open_source/musl/libc/sys/un.h create mode 100644 thirdparty/open_source/musl/libc/sys/user.h create mode 100644 thirdparty/open_source/musl/libc/syscall.h create mode 100644 thirdparty/open_source/musl/libc/time.h create mode 100644 thirdparty/open_source/musl/libc/unistd.h create mode 100644 thirdparty/open_source/musl/libc/wchar.h create mode 100644 thirdparty/open_source/musl/libc/wctype.h diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..873c68e --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,9 @@ +v5.1.0 (Apr 2, 2020) +====== +Features: +--------- +* add support for new product(kunpeng series) + +Fixes: +------ +* fix build warnings in building 64 bits TA diff --git a/License/LICENSE b/License/LICENSE new file mode 100755 index 0000000..a7aba0e --- /dev/null +++ b/License/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第2版 + + 木兰宽松许可证, 第2版 + 2020年1月 http://license.coscl.org.cn/MulanPSL2 + + + 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: + + 0. 定义 + + “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 + + “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 + + “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 + + “法人实体”是指提交贡献的机构及其“关联实体”。 + + “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 + + 1. 授予版权许可 + + 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 + + 2. 授予专利许可 + + 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 + + 3. 无商标许可 + + “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 + + 4. 分发限制 + + 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 + + 5. 免责声明与责任限制 + + “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 + + 6. 语言 + “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 + + 条款结束 + + 如何将木兰宽松许可证,第2版,应用到您的软件 + + 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: + + 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; + + 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; + + 3, 请将如下声明文本放入每个源文件的头部注释中。 + + Copyright (c) [Year] [name of copyright holder] + [Software Name] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + + + Mulan Permissive Software License,Version 2 + + Mulan Permissive Software License,Version 2 (Mulan PSL v2) + January 2020 http://license.coscl.org.cn/MulanPSL2 + + Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: + + 0. Definition + + Software means the program and related documents which are licensed under this License and comprise all Contribution(s). + + Contribution means the copyrightable work licensed by a particular Contributor under this License. + + Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. + + Legal Entity means the entity making a Contribution and all its Affiliates. + + Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. + + 1. Grant of Copyright License + + Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. + + 2. Grant of Patent License + + Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. + + 3. No Trademark License + + No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. + + 4. Distribution Restriction + + You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. + + 5. Disclaimer of Warranty and Limitation of Liability + + THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + 6. Language + + THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. + + END OF THE TERMS AND CONDITIONS + + How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software + + To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: + + i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; + + ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; + + iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. + + + Copyright (c) [Year] [name of copyright holder] + [Software Name] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. diff --git a/License/Third_Party_Open_Source_Software_Notice.md b/License/Third_Party_Open_Source_Software_Notice.md new file mode 100755 index 0000000..6050847 --- /dev/null +++ b/License/Third_Party_Open_Source_Software_Notice.md @@ -0,0 +1,42 @@ +**OPEN SOURCE SOFTWARE NOTICE** + +Please note we provide an open source software notice along with this product and/or this product firmware (in the following just “this product”). The open source software licenses are granted by the respective right holders. And the open source licenses prevail all other license information with regard to the respective open source software contained in the product, including but not limited to End User Software Licensing Agreement. This notice is provided on behalf of Huawei Technologies Co. Ltd. and any of its local subsidiaries which may have provided this product to you in your local country. + +**Warranty Disclaimer ** + +THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + +**Copyright Notice and License Texts ** + +**Software: ** musl v1.2.0 + +**Copyright notice: ** + +Copyright © 2005-2020 Rich Felker, et al. + +**License: ** MIT License + +musl as a whole is licensed under the following standard MIT license: + +---------------------------------------------------------------------- +Copyright © 2005-2020 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +---------------------------------------------------------------------- diff --git a/README.en.md b/README.en.md index 3cd34ca..0f159e9 100644 --- a/README.en.md +++ b/README.en.md @@ -1,36 +1,20 @@ -# itrustee_sdk - -#### Description -Confidential computing framework for developing TA on itrustee OS - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +iTrustee SDK +============ + +Getting Started +--------------- +Before setup your own project, please download libboundscheck software for secure function library. +Decompress the openeuler-libboundscheck-master.zip package, then put this software to thirdparty/open_source path. +Ensure that the header file path is thirdparty/open_source/libboundscheck/include. +This software download address is https://gitee.com/openeuler/libboundscheck. + +build demo project: +$ cd test/CA/helloworld/cloud +$ make +$ cd test/TA/helloworld/cloud +$ make +copy build result CA executable file and TA binary(xxx.sec) to /vendor/bin/ +#the path "/vendor/bin/" may be changed as your opinion, make sure it consistent with the path defined in your TA's source code +$ /vendor/bin/teec_hello + +for more details please refor "iTrustee SDKֲ.chm" diff --git a/README.md b/README.md index 8fc3607..0f159e9 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,20 @@ -# itrustee_sdk - -#### 介绍 -Confidential computing framework for developing TA on itrustee OS - -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. xxxx -2. xxxx -3. xxxx - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +iTrustee SDK +============ + +Getting Started +--------------- +Before setup your own project, please download libboundscheck software for secure function library. +Decompress the openeuler-libboundscheck-master.zip package, then put this software to thirdparty/open_source path. +Ensure that the header file path is thirdparty/open_source/libboundscheck/include. +This software download address is https://gitee.com/openeuler/libboundscheck. + +build demo project: +$ cd test/CA/helloworld/cloud +$ make +$ cd test/TA/helloworld/cloud +$ make +copy build result CA executable file and TA binary(xxx.sec) to /vendor/bin/ +#the path "/vendor/bin/" may be changed as your opinion, make sure it consistent with the path defined in your TA's source code +$ /vendor/bin/teec_hello + +for more details please refor "iTrustee SDKֲ.chm" diff --git a/build/mk/cloud/common.mk b/build/mk/cloud/common.mk new file mode 100755 index 0000000..9a37b9b --- /dev/null +++ b/build/mk/cloud/common.mk @@ -0,0 +1,36 @@ +CUR_DIR=$(shell pwd) +iTrustee_SDK_PATH=${CUR_DIR}/../../../../ +SIGNTOOL_DIR=${iTrustee_SDK_PATH}/build/signtools/ + +LIBC=$(iTrustee_SDK_PATH)/thirdparty/open_source/musl +LIBSECURE=$(iTrustee_SDK_PATH)/thirdparty/open_source/libboundscheck/ + +# set compile parameters +CFLAGS := -O -W -Wall +CFLAGS += -Werror +CFLAGS += -fno-short-enums +CFLAGS += -fno-omit-frame-pointer +CFLAGS += -fstack-protector-strong +CFLAGS += -Wextra -nostdinc -nodefaultlibs +CFLAGS += -march=armv8-a -Os -Wno-main -fPIC +CFLAGS += -Wno-error=unused-parameter -Wno-error=unused-but-set-variable + +CFLAGS += -DCONFIG_AUTH_CLOUD + +# set header directory +INCLUDEDIR += -I$(LIBC)/libc \ + -I$(LIBC)/libc/arch/aarch64 \ + -I$(LIBC)/libc/arch/aarch64/bits \ + -I$(LIBC)/libc/arch/generic + +INCLUDEDIR += -I$(LIBSECURE)/include + +INCLUDEDIR += -I$(iTrustee_SDK_PATH)/include/TA/ \ + -I$(iTrustee_SDK_PATH)/include/TA/huawei_ext/ \ + +$(info "include is: "$(INCLUDEDIR)) + +# set LD flags +LDFLAGS += -s -z text -z now -z relro -z noexecstack -shared + +LDFLAGS += -T$(iTrustee_SDK_PATH)/build/tools/ta_link_64.ld diff --git a/build/signtools/cloud/config_cloud.ini b/build/signtools/cloud/config_cloud.ini new file mode 100644 index 0000000..4d70fcd --- /dev/null +++ b/build/signtools/cloud/config_cloud.ini @@ -0,0 +1,49 @@ +[config] +;0 means debug +;1 means release +;[fixed value] +releaseType = 1 +;;; +;0 means TA not installed by OTRP +;1 means TA installed by OTRP +otrpFlag = 0 +;;; +;server address for signing TA +serverIp= +;;; +;public key for encrypt TA +;[fixed value] +encryptKey = cloud/rsa_public_key_cloud.pem +;;; +;public key length +;[fixed value] +encryptKeyLen = 3072 +;;; +;0 means not sign +;1 means signed by local private +;2 means signed using native sign tool; +;3 means signed by CI +;[fixed value] +signType = 1 +;;; +;private key for signing TA +;[private key owned by yourself] +signKey = TA_cert/private_key.pem +;;; +;private key length for signing TA +;[key length should be 4096 for security enhance] +signKeyLen = 4096 +;;; +;0 means SHA256 hash type +;1 means SHA512 hash type +;[set value to 0 by default] +hashType = 0 +;;; +;0 means padding type is pkcs1v15 +;1 means padding type is PSS +;[set value to 0 by default] +paddingType = 0 +;;; +;config file +;[signed config file by Huawei] +configPath= signed_config/config diff --git a/build/signtools/cloud/rsa_public_key_cloud.pem b/build/signtools/cloud/rsa_public_key_cloud.pem new file mode 100644 index 0000000..a321f63 --- /dev/null +++ b/build/signtools/cloud/rsa_public_key_cloud.pem @@ -0,0 +1,11 @@ +-----BEGIN PUBLIC KEY----- +MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAzAPwbnbgBg7JgXERA9Bx +p7GLI1S3e1zL83RMd2+GXb6kO4yMKUL3NUCE2HhA2BtQYmLyGovx59UUcKnU58is +Xux++kH+A2shmOPjYvEFuX0Kt8tc19b8M9b/iHsY8ZmKykqia2a5U+IrECRFJo5p +DWUnl7jrHVtq78BSR1c7iXG1frrEC0AYCuqKJo/fxfmOKL0Y9mENCB3nAwjn9unD +BsO/OhkqvvB3nkeuMfNKPh4wCqtQPve13eTojbuxjX/3ePijplTI5X2Gr+n6Ximn +fYRlytQmMgMl/db0ARSKNApq9bmwzVNrnGWWZWJksdRvf6iL7t17Gs4L9AApOuC9 +WkzxPvwp5ZUqjsGd4oJGWeC6ZE6BTw2vxE+xMFI9uAKHxq9pBKkcGMa0g4fANNNV ++W+8JZGanxEXKB3y/M7BCyQAPCWOHC/RNjmRA1gczLYCPzC4pWu935UZdF1RR6zY +CD3t+FoOGGET/g4CwWgyhb5qkp65Hs6ayYt/DUAqo+yBAgMBAAE= +-----END PUBLIC KEY----- diff --git a/build/signtools/generate_signature.py b/build/signtools/generate_signature.py new file mode 100644 index 0000000..6cddfaf --- /dev/null +++ b/build/signtools/generate_signature.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# coding:utf-8 +#---------------------------------------------------------------------------- +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# iTrustee licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# Description: tools for generating a trusted application load image +# Author: Li mingjuan +# Create: 2020-10-27 +#---------------------------------------------------------------------------- + +import struct +import os +import hashlib +import subprocess + +HASH256 = 0 +HASH512 = 1 + +def gen_hash(hash_type, in_file_path, out_file_path): + in_file_size = os.path.getsize(in_file_path) + # Initialize a SHA256 object from the Python hash library + if int(hash_type) == HASH256: + hash_op = hashlib.sha256() + elif int(hash_type) == HASH512: + hash_op = hashlib.sha512() + # Set the input buffer and return the output digest + with open(in_file_path, 'rb') as in_file: + hash_op.update(in_file.read(in_file_size)) + + #-----hash file used for ras sign--- + with open(out_file_path, 'wb') as hash_fp: + # fixed hash prefix value + hash_fp.write(struct.pack('B'*19, 0x30, 0x31, 0x30, 0x0d, 0x06, \ + 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, \ + 0x05, 0x00, 0x04, 0x20)) + hash_fp.write(hash_op.digest()) + return + +def gen_ta_signature(cfg, uuid_str, raw_data_path, hash_file_path, out_file_path): + gen_hash(cfg.hash_type, raw_data_path, hash_file_path) + cmd = "openssl rsautl -sign -inkey {} -in {} -out {}".\ + format(cfg.sign_key, hash_file_path, out_file_path) + try: + subprocess.check_output(cmd.split(), shell=False) + except Exception: + print("sign operation failed") + raise RuntimeError + return + diff --git a/build/signtools/manifest.py b/build/signtools/manifest.py new file mode 100755 index 0000000..9cc2360 --- /dev/null +++ b/build/signtools/manifest.py @@ -0,0 +1,322 @@ +#!/usr/bin/env python +# coding:utf-8 +#---------------------------------------------------------------------------- +# Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. +# iTrustee licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# Description: tools for generating a trusted application load image +# Author: Li mingjuan +# Create: 2018-02-20 +#---------------------------------------------------------------------------- +import string +import struct +import uuid +import os + +PRODUCT_TA_IMAGE = 1 +PRODUCT_DYN_LIB = 2 +PRODUCT_SERVICE_IMAGE = 3 + + +class PackUuid: + # Structure object to align and package the TEE_UUID + data = struct.Struct('IHH8b') + + def __init__(self, data): + unpacked_data = (PackUuid.data).unpack(str.encode(data)) + self.unpacked_data = unpacked_data + self.time_low = unpacked_data[0] + self.time_mid = unpacked_data[1] + self.time_hi_version = unpacked_data[2] + self.clock_seq_node = unpacked_data[3] + + def print_values(self): + print("ATTRIBUTE / VALUE") + for attr, value in self.__dict__.items(): + print(attr, value) + + def get_pack_data(self): + values = [self.time_low, + self.time_mid, + self.time_hi_version, + self.clock_seq_node, + ] + + return (PackUuid.data).pack(*values) + + +#---------------------------------------------------------------------------- +# Manifest +#---------------------------------------------------------------------------- +class Manifest: + + # Structure object to align and package the Manifest + data = struct.Struct('I' * 6) + + def __init__(self, data): + unpacked_data = (Manifest.data).unpack(str.encode(data)) + self.unpacked_data = unpacked_data + self.single_instance = unpacked_data[0] + self.multi_session = unpacked_data[1] + self.multi_command = unpacked_data[2] + self.heap_size = unpacked_data[3] + self.stack_size = unpacked_data[4] + self.instancekeepalive = unpacked_data[5] + + def print_values(self): + print("ATTRIBUTE / VALUE") + for attr, value in self.__dict__.items(): + print(attr, value) + + def get_pack_data(self): + values = [self.single_instance, + self.multi_session, + self.multi_command, + self.heap_size, + self.stack_size, + self.instancekeepalive, + ] + + return (Manifest.data).pack(*values) + + +#---------------------------------------------------------------------------- +# verify property name in manifest file +#---------------------------------------------------------------------------- +def verify_property_name(str_line): + print('verify property name') + alphas = string.ascii_letters + string.digits + cont = "".join([alphas, '-', '_', '.']) + if len(str_line) > 1: + if str_line[0] not in alphas: + print('invalid first letter in property name') + return False + else: + for otherchar in str_line[1:]: + if otherchar not in cont: + print('invalid char in property name') + return False + else: + print('invalid property name') + return False + + return True + + +#---------------------------------------------------------------------------- +# verify property value in manifest file +#---------------------------------------------------------------------------- +def verify_property_value(str_line): + print('verify property value') + filt_letter = chr(0) + chr(10) + chr(13) + for thechar in str_line: + if thechar in filt_letter: + print('invalid letter in prop value') + return False + return True + + +#---------------------------------------------------------------------------- +# remove tabs and space in property value +#---------------------------------------------------------------------------- +def trailing_space_tabs(str_line): + print('trailing space tabs in value head and trail') + space_tabs = chr(9) + chr(32) + chr(160) + space_tabs_newlines = space_tabs + chr(10) + chr(13) + print('tab: {}'.format(space_tabs)) + + print('str in: {}'.format(str_line)) + index = 0 + for thechar in str_line: + if thechar in space_tabs: + index += 1 + else: + break + headvalue = str_line[index:] + + strlen = len(headvalue) + + strlen -= 1 + + while strlen > 0: + if headvalue[strlen] in space_tabs_newlines: + strlen -= 1 + else: + break + + str_ret = headvalue[0:strlen+1] + chr(10) + print('str ret: {}'.format(str_ret)) + + return str_ret + + +#---------------------------------------------------------------------------- +# verify manifest file, parse manifest file, generate a new manfiest file +#---------------------------------------------------------------------------- +def parser_manifest(manifest, manifest_data_path, mani_ext): + print('verify manifest') + target_type = PRODUCT_TA_IMAGE + + uuid_val = PackUuid('\0' * 16) + + #manifest default + manifest_val = Manifest('\0'*24) + + manifest_val.single_instance = 1 + manifest_val.multi_session = 0 + manifest_val.multi_command = 0 + manifest_val.instancekeepalive = 0 + manifest_val.heap_size = 16384 + manifest_val.stack_size = 2048 + + service_name = 'external_service' + + with open(manifest, 'r') as mani_fp, open(mani_ext, 'wb') as mani_ext_fp: + for each_line in mani_fp: + print(each_line) + if each_line.startswith("#") or not len(each_line.strip()): + continue + index = each_line.find(':', 1, len(each_line)) + + prop_name = each_line[0:index] + prop_name_t = each_line[0:index+1] + prop_value_t = each_line[index+1:] + print('name is: {}; value is: {}'.format(prop_name, prop_value_t)) + + prop_value = trailing_space_tabs(prop_value_t) + prop_len = len(prop_value) + prop_value_v = prop_value[0:prop_len-1] + print('prop value_v: {}'.format(prop_value_v)) + + if verify_property_name(prop_name) is False: + print('manifest format invalid, please check it') + return (False, 0) + + if verify_property_value(prop_value_v) is False: + print('manifest format invalid, please check it') + return (False, 0) + + # name:value to lowcase, and parse manifest + prop_name_low = prop_name.lower() + print("name lower: {}".format(prop_name_low)) + if 'gpd.ta.appid' == prop_name_low: + print("compare name is srv id") + uuid_val = uuid.UUID(prop_value_v) + print('uuid str {}'.format(uuid_val)) + print('val fields {}'.format(uuid_val.fields)) + + elif 'gpd.ta.singleinstance' == prop_name_low: + prop_value_low = prop_value_v.lower() + if 'true' == prop_value_low: + manifest_val.single_instance = 1 + elif 'false' == prop_value_low: + manifest_val.single_instance = 0 + else: + print('single_instance value error!') + + elif 'gpd.ta.multisession' == prop_name_low: + prop_value_low = prop_value_v.lower() + if 'true' == prop_value_low: + manifest_val.multi_session = 1 + elif 'false' == prop_value_low: + manifest_val.multi_session = 0 + else: + print('multi_session value error!') + + elif 'gpd.ta.multicommand' == prop_name_low: + prop_value_low = prop_value_v.lower() + if 'true' == prop_value_low: + manifest_val.multi_command = 1 + elif 'false' == prop_value_low: + manifest_val.multi_command = 0 + else: + print('multi_command value error!') + + elif 'gpd.ta.instancekeepalive' == prop_name_low: + prop_value_low = prop_value_v.lower() + if 'true' == prop_value_low: + manifest_val.instancekeepalive = 1 + elif 'false' == prop_value_low: + manifest_val.instancekeepalive = 0 + else: + print('instancekeepalive value error!') + + elif 'gpd.ta.datasize' == prop_name_low: + manifest_val.heap_size = int(prop_value_v) + print('b') + + elif 'gpd.ta.stacksize' == prop_name_low: + manifest_val.stack_size = int(prop_value_v) + print('b') + + elif 'gpd.ta.service_name' == prop_name_low: + service_name = prop_value_v + print('b') + + else: + print('b') + #write have not paresed manifest into sample.manifest file + mani_ext_fp.write(str.encode(prop_name_t)) + mani_ext_fp.write(str.encode(prop_value)) + if 'gpd.ta.is_tee_service' == prop_name_low: + prop_value_low = prop_value_v.lower() + if 'true' == prop_value_low: + target_type = PRODUCT_SERVICE_IMAGE + elif 'gpd.ta.is_lib' == prop_name_low: + prop_value_low = prop_value_v.lower() + if 'true' == prop_value_low: + target_type = PRODUCT_DYN_LIB + + #write the whole parsed manifest into sample.manifest file + + service_name_len = len(service_name) + print('service name: {}'.format(service_name)) + print('service name len: {}'.format(service_name_len)) + if service_name_len > 64: + print("service name len exceed MAX value 27") + raise RuntimeError + + # get manifest string file len + manifest_str_size = os.path.getsize(mani_ext) + print('manifest str size {}'.format(manifest_str_size)) + + # 2> manifest + service_name + print("bytes len {}".format(len(uuid_val.bytes_le))) + print("bytes len {}".format(len(manifest_val.get_pack_data()))) + print("bytes len {}".format(len(service_name))) + + # 3> unparsed manifest, string manifest + with open(mani_ext, 'rb') as string_mani_fp: + print("read manifest string size {}".format(manifest_str_size)) + manifest_string_buf = string_mani_fp.read(manifest_str_size) + print("manifest strint: {}".format(manifest_string_buf)) + + #---- write manifest parse context to manifest file + with open(manifest_data_path, 'wb') as out_manifest_fp: + out_manifest_fp.write(uuid_val.bytes_le) + out_manifest_fp.write(str.encode(service_name)) + out_manifest_fp.write(manifest_val.get_pack_data()) + + product_name = str(uuid_val) + if target_type == PRODUCT_TA_IMAGE: + print("product type is ta image") + product_name = "".join([product_name, ".sec"]) + elif target_type == PRODUCT_SERVICE_IMAGE: + print("product type is service") + product_name = "".join([product_name, service_name, "_svr.sec"]) + elif target_type == PRODUCT_DYN_LIB: + print("product type is dyn lib") + product_name = "".join([product_name, service_name, ".so.sec"]) + else: + print("invalid product type!") + raise RuntimeError + + return (True, product_name) + diff --git a/build/signtools/signtool_v3.py b/build/signtools/signtool_v3.py new file mode 100755 index 0000000..0590887 --- /dev/null +++ b/build/signtools/signtool_v3.py @@ -0,0 +1,413 @@ +#!/usr/bin/env python +# coding:utf-8 +#---------------------------------------------------------------------------- +# Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. +# iTrustee licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# Description: tools for generating a trusted application load image +# Author: Li mingjuan +# Create: 2018-02-20 +#---------------------------------------------------------------------------- + +import struct +import os +import stat +import hashlib +import binascii +import subprocess +import shutil +import getpass +import argparse + +try: + from configparser import SafeConfigParser +except ImportError: + from ConfigParser import SafeConfigParser + +from manifest import parser_manifest +from generate_signature import gen_ta_signature + +# fixed value, {1, 2} version are abandoned. +VERSION = 3 +TA_VERSION = 3 + +MAX_EXT_PROP_LEN = 152 + +MAGIC1 = 0xA5A55A5A +MAGIC2 = 0x55AA + +# ELF Definitions +ELF_TYPE = 32 +ELF_HDR_SIZE = 52 +ELF_PHDR_SIZE = 32 +ELF_INFO_MAGIC0_INDEX = 0 +ELF_INFO_MAGIC1_INDEX = 1 +ELF_INFO_MAGIC2_INDEX = 2 +ELF_INFO_MAGIC3_INDEX = 3 +#'\x7f' +ELF_INFO_MAGIC0 = 127 +#'E' +ELF_INFO_MAGIC1 = 69 +#'L' +ELF_INFO_MAGIC2 = 76 +#'F' +ELF_INFO_MAGIC3 = 70 +ELF_INFO_CLASS_INDEX = 4 +ELF_INFO_CLASS_32 = 1 +ELF_INFO_CLASS_64 = 2 +ELF_INFO_VERSION_INDEX = 6 +ELF_INFO_VERSION_CURRENT = 1 +ELF_BLOCK_ALIGN = 0x1000 + + +#---------------------------------------------------------------------------- +# Verify ELF header contents from an input ELF file +#---------------------------------------------------------------------------- +def verify_elf_header(elf_path): + elf_type = 0 + with open(elf_path, 'rb') as elf: + elf_data = struct.unpack('B'*16, elf.read(16)) + elf_type = elf_data[4] + if ((elf_data[ELF_INFO_MAGIC0_INDEX] != ELF_INFO_MAGIC0) or \ + (elf_data[ELF_INFO_MAGIC1_INDEX] != ELF_INFO_MAGIC1) or \ + (elf_data[ELF_INFO_MAGIC2_INDEX] != ELF_INFO_MAGIC2) or \ + (elf_data[ELF_INFO_MAGIC3_INDEX] != ELF_INFO_MAGIC3) or \ + (elf_data[ELF_INFO_VERSION_INDEX] != \ + ELF_INFO_VERSION_CURRENT)): + print("invalid elf header info") + raise RuntimeError + + if ((elf_type == 1 and elf_data[ELF_INFO_CLASS_INDEX] != \ + ELF_INFO_CLASS_32) or \ + (elf_type == 2 and elf_data[ELF_INFO_CLASS_INDEX] != \ + ELF_INFO_CLASS_64) or \ + (elf_type != 1 and elf_type != 2)): + print("invliad elf format") + raise RuntimeError + return + + +class Configuration: + release_type = 0 + otrp_flag = 0 + sign_type = 0 + public_key = "" + pub_key_len = 0 + server_ip = "" + config_path = "" + sign_key = "" + sign_key_len = 2048 + hash_type = 0 + padding_type = 0 + + def __init__(self, file_name): + parser = SafeConfigParser() + parser.read(file_name) + self.release_type = parser.get("config", "releaseType") + self.otrp_flag = parser.get("config", "otrpFlag") + self.sign_type = parser.get("config", "signType") + self.public_key = parser.get("config", "encryptKey") + self.pub_key_len = parser.get("config", "encryptKeyLen") + self.server_ip = parser.get("config", "serverIp") + self.config_path = parser.get("config", "configPath") + self.sign_key = parser.get("config", "signKey") + self.sign_key_len = parser.get("config", "signKeyLen") + self.hash_type = parser.get("config", "hashType") + self.padding_type = parser.get("config", "paddingType") + + +def gen_header(content_len, key_version): + return struct.pack('IHHII', MAGIC1, MAGIC2, VERSION, content_len, \ + key_version) + + +def gen_aes_key_info(cfg, iv_file_path, key_file_path, out_file_path): + rand_iv_cmd = "openssl rand -out {} 16".format(iv_file_path) + rand_key_cmd = "openssl rand -out {} 32".format(key_file_path) + try: + subprocess.check_output(rand_iv_cmd.split(), shell=False) + subprocess.check_output(rand_key_cmd.split(), shell=False) + except Exception: + print("rand operation failed") + raise RuntimeError + + os.chmod(iv_file_path, stat.S_IWUSR | stat.S_IRUSR) + os.chmod(key_file_path, stat.S_IWUSR | stat.S_IRUSR) + + sign_alg = 0 + sign_alg = sign_alg | (int(cfg.release_type) << 28) + sign_alg = sign_alg | (int(cfg.padding_type) << 27) + sign_alg = sign_alg | (int(cfg.hash_type) << 26) + if cfg.sign_key_len == "2048": + sign_alg = sign_alg | 0x00002048 + elif cfg.sign_key_len == "4096": + sign_alg = sign_alg | 0x00004096 + + print("sign_alg value is 0x%x" % sign_alg) + with open(out_file_path, 'wb') as out_file: + out_file.write(struct.pack('I', 32)) + out_file.write(struct.pack('I', 16)) + out_file.write(struct.pack('I', sign_alg)) + + with open(key_file_path, 'rb') as key_file: + out_file.write(key_file.read(32)) + + with open(iv_file_path, 'rb') as iv_file: + out_file.write(iv_file.read(16)) + + os.chmod(out_file_path, stat.S_IWUSR | stat.S_IRUSR) + return + + +def encrypt_aes_key(pubkey_path, in_path, out_path): + cmd = "openssl rsautl -encrypt -pubin -oaep -inkey {} -in {} -out {}". \ + format(pubkey_path, in_path, out_path) + try: + subprocess.check_output(cmd.split(), shell=False) + except Exception: + print("RSA encrypt operation failed") + raise RuntimeError + os.chmod(out_path, stat.S_IWUSR | stat.S_IRUSR) + return + +def gen_signature(cfg, uuid_str, raw_data_path, hash_file_path, out_file_path): + gen_ta_signature(cfg, uuid_str, raw_data_path, hash_file_path, out_file_path) + os.chmod(out_file_path, stat.S_IWUSR | stat.S_IRUSR) + return + +def gen_raw_data(manifest_data_path, manifest_ext_path, elf_file_path, \ + config_path, raw_file_path): + manifest_size = os.path.getsize(manifest_data_path) + manifest_ext_size = os.path.getsize(manifest_ext_path) + elf_size = os.path.getsize(elf_file_path) + config_size = 0 + + if manifest_ext_size > MAX_EXT_PROP_LEN: + print("too much data in \"manifest.txt\" to be handled. \ + extra string len %d" \ + % manifest_ext_size) + raise RuntimeError + + verify_elf_header(elf_file_path) + + with open(raw_file_path, 'wb') as file_op: + header = "" + if os.path.isfile(config_path): + config_size = os.path.getsize(config_path) + header = struct.pack('IIIII', TA_VERSION, manifest_size, \ + manifest_ext_size, \ + elf_size, config_size) + file_op.write(header) + + with open(manifest_data_path, 'rb') as manifest_data: + file_op.write(manifest_data.read(manifest_size)) + + with open(manifest_ext_path, 'rb') as manifest_ext: + file_op.write(manifest_ext.read(manifest_ext_size)) + + with open(elf_file_path, 'rb') as elf: + file_op.write(elf.read(elf_size)) + if config_size != 0: + with open(config_path, 'rb') as config: + file_op.write(config.read(config_size)) + return + + +def aes_encrypt(key_path, iv_path, in_file_path, out_file_path): + key_size = os.path.getsize(key_path) + with open(key_path, 'rb') as key_file: + key_data = key_file.read(key_size) + hex_key_str = binascii.b2a_hex(key_data) + + iv_size = os.path.getsize(iv_path) + with open(iv_path, 'rb') as iv_file: + iv_data = iv_file.read(iv_size) + hex_iv_str = binascii.b2a_hex(iv_data) + + cmd = "openssl enc -aes-256-cbc -in {} -out {} -K {} -iv {}".\ + format(in_file_path, out_file_path, \ + bytes.decode(hex_key_str), bytes.decode(hex_iv_str)) + try: + subprocess.check_output(cmd.split(), shell=False) + except Exception: + print("AES encrypt operation failed") + raise RuntimeError + + os.chmod(out_file_path, stat.S_IWUSR | stat.S_IRUSR) + return + + +def parser_api_level(compile_config): + default_api_level = 1 + if not os.path.exists(compile_config): + print("TA Make Config doesn't exist, ignore it") + return default_api_level + with open(compile_config) as file_op: + for line in file_op: + if line.startswith("#") or not "-DAPI_LEVEL" in line: + continue + key, value = line.strip().split("-DAPI_LEVEL=") + print("key info {}".format(key)) + print(("ta_api_level = {}".format(value))) + return value + return default_api_level + + +def update_api_level(compile_config, manifest): + data = '' + with open(manifest, 'r') as file_op: + for line in file_op: + if line.startswith("#") or not "gpd.ta.api_level" in line: + data += line + line = "\ngpd.ta.api_level:{}\n".format(parser_api_level(compile_config)) + data += line + with open(manifest, "w") as file_op: + file_op.writelines(data) + + +def update_otrp_flag(manifest): + data = '' + with open(manifest, 'r') as file_op: + for line in file_op: + if line.startswith("#") or not "gpd.ta.otrp_flag" in line: + data += line + line = "\ngpd.ta.otrp_flag:{}\n".format('true') + data += line + with open(manifest, "w") as file_op: + file_op.writelines(data) + + +def gen_data_for_sign(header, key_info, raw_file, data_sign): + key_info_len = os.path.getsize(key_info) + raw_file_len = os.path.getsize(raw_file) + + with open(data_sign, 'wb') as data_fp, \ + open(key_info, 'rb') as key_fp, open(raw_file, 'rb') as raw_fp: + data_fp.write(header) + data_fp.write(key_fp.read(key_info_len)) + data_fp.write(raw_fp.read(raw_file_len)) + + +def gen_key_version(cfg): + if cfg.pub_key_len == '3072': + return int(0x0202) + if cfg.pub_key_len == '2048': + return int(0x0002) + print("unhandled pulic key len %s" % cfg.pub_key_len) + raise RuntimeError + + +def gen_sec_image(in_path, out_path, cfg): + # temporary files + temp_path = os.path.join(in_path, "temp") + shutil.rmtree(temp_path, ignore_errors=True) + os.mkdir(temp_path) + os.chmod(temp_path, stat.S_IRWXU) + iv_file_path = os.path.join(temp_path, "iv.bin") + key_file_path = os.path.join(temp_path, "aeskey.bin") + key_info_path = os.path.join(temp_path, "KeyInfo") + enc_key_path = os.path.join(temp_path, "KeyInfo.enc") + raw_file_path = os.path.join(temp_path, "rawData") + enc_raw_path = os.path.join(temp_path, "rawData.enc") + manifest_data_path = os.path.join(temp_path, "manifestData.bin") + manifest_ext_path = os.path.join(temp_path, "manifestExt.bin") + data_for_sign_path = os.path.join(temp_path, "dataForSign.bin") + signature_path = os.path.join(temp_path, "signature.bin") + hash_path = os.path.join(temp_path, "rawDataHash.bin") + + # mandentory input files + manifest_path = os.path.join(in_path, "manifest.txt") + elf_file_path = os.path.join(in_path, "libcombine.so") + compile_config_path = os.path.join(in_path, "config.mk") + + ret, product_name = parser_manifest(manifest_path, \ + manifest_data_path, manifest_ext_path) + if ret is False: + raise RuntimeError + + update_api_level(compile_config_path, manifest_ext_path) + + if cfg.otrp_flag == 1: + print("package otrp sec file\n") + update_otrp_flag(manifest_ext_path) + + gen_raw_data(manifest_data_path, manifest_ext_path, elf_file_path, \ + cfg.config_path, raw_file_path) + + # generate AES key info to encrypt raw data + gen_aes_key_info(cfg, iv_file_path, key_file_path, key_info_path) + encrypt_aes_key(cfg.public_key, key_info_path, enc_key_path) + + aes_encrypt(key_file_path, iv_file_path, raw_file_path, enc_raw_path) + + # generate Main Header + content_len = os.path.getsize(enc_key_path) + \ + (int(cfg.sign_key_len) / 8) + \ + os.path.getsize(enc_raw_path) + key_version = gen_key_version(cfg) + header = gen_header(int(content_len), key_version) + + gen_data_for_sign(header, key_info_path, raw_file_path, data_for_sign_path) + + uuid_str = product_name[0:36] + print('uuid str {}'.format(uuid_str)) + + gen_signature(cfg, uuid_str, data_for_sign_path, hash_path, signature_path) + + sec_img_path = os.path.join(out_path, product_name) + with open(sec_img_path, 'wb') as sec_image: + # write to sec file [1.header info] + sec_image.write(header) + # write to sec file [2.AES key info] + enc_key_size = os.path.getsize(enc_key_path) + with open(enc_key_path, 'rb') as enc_key_info: + sec_image.write(enc_key_info.read(enc_key_size)) + # write to sec file [3.signature] + signature_size = os.path.getsize(signature_path) + with open(signature_path, 'rb') as signature_file: + sec_image.write(signature_file.read(signature_size)) + # write to sec file [4.encrypted raw data] + enc_raw_size = os.path.getsize(enc_raw_path) + with open(enc_raw_path, 'rb') as enc_raw_data: + sec_image.write(enc_raw_data.read(enc_raw_size)) + + print("=========================SUCCESS============================") + print("generate TA(V3 format) load image success: ") + print(sec_img_path) + print("============================================================") + + #remove temp files + shutil.rmtree(temp_path) + return + + +def main(): + sign_tool_dir = os.path.dirname(os.path.abspath(__file__)) + parser = argparse.ArgumentParser() + parser.add_argument("in_path", help="input path of data to be signed. \ + (libcombine.so; manifest.txt; ...", type=str) + parser.add_argument("out_path", help="input path of signed file. \ + (xxx.sec)", type=str) + parser.add_argument("--config", help="sign configuation file", type=str) + args = parser.parse_args() + if args.config: + cfg = Configuration(args.config) + else: + cfg = Configuration(os.path.join(sign_tool_dir, "config.ini")) + + in_path = os.path.abspath(args.in_path) + out_path = os.path.abspath(args.out_path) + os.chdir(sign_tool_dir) + gen_sec_image(in_path, out_path, cfg) + + +if __name__ == '__main__': + main() + diff --git a/build/tools/ta_link_64.ld b/build/tools/ta_link_64.ld new file mode 100644 index 0000000..d6bdad8 --- /dev/null +++ b/build/tools/ta_link_64.ld @@ -0,0 +1,221 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Description: Describe the link file for 64bits TA + * Author: He pengfei + * Create: 2019-12-03 + */ + +OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", + "elf64-littleaarch64") +OUTPUT_ARCH(aarch64) +ENTRY(_start) +SEARCH_DIR("=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/lib64"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + /* This should be the first section after program headers */ + .magic : { *(.magic) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + *(.rela.ifunc) + } + .rela.plt : + { + *(.rela.plt) + *(.rela.iplt) + } + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table + .gcc_except_table.*) } + .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } + /* These sections are generated by the Sun/Oracle C++ compiler. */ + .exception_ranges : ONLY_IF_RO { *(.exception_ranges + .exception_ranges*) } + /* Make sure the address of text segment is aligned in 4k for xom */ + . = ALIGN(0x1000); + .init : + { + KEEP (*(SORT_NONE(.init))) + } =0 + .plt : ALIGN(16) { *(.plt) *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely .text.unlikely.*) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0 + .fini : + { + KEEP (*(SORT_NONE(.fini))) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } + .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } + /* Thread Local Storage sections */ + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + KEEP (*(.preinit_array)) + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + . = DATA_SEGMENT_RELRO_END (0, .); + .data : + { + PROVIDE (__data_start = .); + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + . = .; + __bss_start = .; + __bss_start__ = .; + TA_BSS_START = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(. != 0 ? 64 / 8 : 1); + } + TA_BSS_END = .; + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(64 / 8); + . = SEGMENT_START("ldata-segment", .); + . = ALIGN(64 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + /* DWARF Extension. */ + .debug_macro 0 : { *(.debug_macro) } + .debug_addr 0 : { *(.debug_addr) } + .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/include/CA/tee_client_api.h b/include/CA/tee_client_api.h new file mode 100644 index 0000000..88c7969 --- /dev/null +++ b/include/CA/tee_client_api.h @@ -0,0 +1,186 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: HanPeng + * Create: 2013-4-22 + * Description: TEE client API definitions + */ + +#ifndef _TEE_CLIENT_API_H_ +#define _TEE_CLIENT_API_H_ + +#ifndef LOG_TAG +#define LOG_TAG NULL +#endif + +#ifdef LOG_NDEBUG +#undef LOG_NDEBUG +#endif +#define LOG_NDEBUG 0 + +#include +#include "tee_client_type.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define S_VAR_NOT_USED(variable) do { (void)(variable); } while (0) + +#define TEEC_PARAM_TYPES(param0Type, param1Type, param2Type, param3Type) \ + ((param3Type) << 12 | (param2Type) << 8 | (param1Type) << 4 | (param0Type)) + +#define TEEC_PARAM_TYPE_GET(paramTypes, index) \ + (((paramTypes) >> (4*(index))) & 0x0F) + +#define TEEC_VALUE_UNDEF 0xFFFFFFFF + +/* + * initializes a new TEE Context, forming a connection between this Client Application and the TEE + * + * @param name [IN] TEE name (unused) + * @param context [IN/OUT] pointer to TEEC_Context to be initialized + * + * @return TEEC_SUCCESS operation success + * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter + * @return TEEC_ERROR_GENERIC system error unhandled + */ +TEEC_Result TEEC_InitializeContext( + const char *name, + TEEC_Context *context); + +/* + * finalizes an initialized TEE Context, closing the connection between the Client Application and the TEE + * + * @param context [IN/OUT] pointer to TEEC_Context initialized by TEEC_InitializeContext + * + * @return void + */ +void TEEC_FinalizeContext( + TEEC_Context *context); + +/* + * opens a new Session between the Client Application and the specified Trusted Application + * + * @param context [IN/OUT] a pointer to an initialized TEE Context + * @param session [OUT] a pointer to a Session structure to be opened + * @param destination [IN] a pointer to a structure containing the UUID of the destination Trusted Application + * @param connectionMethod [IN] the method of connection to use + * @param connectionData [IN] any necessary data required to support the connection method + * @param operation [IN/OUT] a pointer to an Operation containing a set of Parameters to exchange with the + * Trusted Application + * @param returnOrigin [IN/OUT] a pointer to a variable which will contain the return origin, This field may be NULL + * if the return origin is not needed + * + * @return TEEC_SUCCESS operation success + * @return TEEC_ERROR_BAD_PARAMETERS invalid parametercontext or session or destination is NULL + * @return TEEC_ERROR_ACCESS_DENIED client Application's connection request is denied + * @return TEEC_ERROR_OUT_OF_MEMORY system resource is out of use + * @return TEEC_ERROR_TRUSTED_APP_LOAD_ERROR load Trusted Application failed + * @return others refer TEEC_ReturnCode + */ +TEEC_Result TEEC_OpenSession( + TEEC_Context *context, + TEEC_Session *session, + const TEEC_UUID *destination, + uint32_t connectionMethod, + const void *connectionData, + TEEC_Operation *operation, + uint32_t *returnOrigin); + +/* + * closes a Session which has been opened with a Trusted Application + * + * @param session [IN/OUT] pointer to a session to be closed + * + * @return void + */ +void TEEC_CloseSession( + TEEC_Session *session); + +/* + * invokes a Command within the specified Session + * + * @param session [IN/OUT] the open Session in which the command will be invoked + * @param commandID [IN] the identifier of the Command within the Trusted Application to invoke + * @param operation [IN/OUT] a pointer to a Client Application initialized TEEC_Operation structure + * @param returnOrigin [IN/OUT] a pointer to a variable which will contain the return origin + * + * @return TEEC_SUCCESS operation success + * @return TEEC_ERROR_BAD_PARAMETERS invalid parametersession is NULL or operation data invalid + * @return TEEC_ERROR_ACCESS_DENIED invoke command operation is denied + * @return TEEC_ERROR_OUT_OF_MEMORY system resource is out of use + * @return others refer TEEC_ReturnCode + */ +TEEC_Result TEEC_InvokeCommand( + TEEC_Session *session, + uint32_t commandID, + TEEC_Operation *operation, + uint32_t *returnOrigin); + +/* + * registers a block of existing Client Application memory as a block of Shared Memory within + * the scope of the specified TEE Context, in accordance with the parameters which have been set by the + * Client Application inside the sharedMem structure (don't support 0 size data) + * + * @param context [IN/OUT] a pointer to an initialized TEE Context + * @param sharedMem [IN/OUT] a pointer to a Shared Memory structure to register + * + * @return TEEC_SUCCESS operation success + * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter, context or sharedMem is NULL + */ +TEEC_Result TEEC_RegisterSharedMemory( + TEEC_Context *context, + TEEC_SharedMemory *sharedMem); + +/* + * allocates a new block of memory as a block of Shared Memory within the scope of the specified TEE Context + * size of sharedMem should not be 0 + * + * @param context [IN/OUT] a pointer to an initialized TEE Context + * @param sharedMem [IN/OUT] a pointer to a Shared Memory structure to allocate + * + * @return TEEC_SUCCESS operation success + * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter, context or sharedMem is NULL + * @return TEEC_ERROR_OUT_OF_MEMORY system resource is out of use + */ +TEEC_Result TEEC_AllocateSharedMemory( + TEEC_Context *context, + TEEC_SharedMemory *sharedMem); + +/* + * deregisters or deallocates a previously initialized block of Shared Memory + * if memory is allocated by TEEC_AllocateSharedMemory, system will free this memory + * if memory is registered by TEEC_RegisterSharedMemory, system will not free this memory + * + * @param sharedMem [IN/OUT] a pointer to a valid Shared Memory structure + * + * @return void + */ +void TEEC_ReleaseSharedMemory( + TEEC_SharedMemory *sharedMem); + +/* + * requests the cancellation of a pending open Session operation or a Command invocation operation + * this operation is not supported currently + * + * @param operation [IN/OUT] a pointer to a Client Application instantiated Operation structure + * + * @return void + */ +void TEEC_RequestCancellation( + TEEC_Operation *operation); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/CA/tee_client_constants.h b/include/CA/tee_client_constants.h new file mode 100644 index 0000000..bd55b82 --- /dev/null +++ b/include/CA/tee_client_constants.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: HanPeng + * Create: 2013-4-22 + * Description: static definitions of client API + */ + +#ifndef _TEE_CLIENT_CONSTANTS_H_ +#define _TEE_CLIENT_CONSTANTS_H_ + +enum TEEC_ReturnCode { + TEEC_SUCCESS = 0x0, /* success */ + TEEC_ERROR_INVALID_CMD, /* invalid command */ + TEEC_ERROR_SERVICE_NOT_EXIST, /* target service is not exist */ + TEEC_ERROR_SESSION_NOT_EXIST, /* session between client and service is not exist */ + TEEC_ERROR_SESSION_MAXIMUM, /* exceed max num of sessions */ + TEEC_ERROR_REGISTER_EXIST_SERVICE, /* cannot register the service which already exist */ + TEEC_ERROR_TAGET_DEAD_FATAL, /* system error occurs in TEE */ + TEEC_ERROR_READ_DATA, /* failed to read data in file */ + TEEC_ERROR_WRITE_DATA, /* failed to write data to file */ + TEEC_ERROR_TRUNCATE_OBJECT, /* data is truncated */ + TEEC_ERROR_SEEK_DATA, /* failed to seek data in file */ + TEEC_ERROR_FSYNC_DATA, /* failed to sync data in file */ + TEEC_ERROR_RENAME_OBJECT, /* failed to rename file */ + TEEC_ERROR_TRUSTED_APP_LOAD_ERROR, /* failed to load Trusted Application */ + TEEC_ERROR_GENERIC = 0xFFFF0000, /* generic error occurs */ + TEEC_ERROR_ACCESS_DENIED = 0xFFFF0001, /* permission check failed, in initilize context or + open session or invoke commnad */ + TEEC_ERROR_CANCEL = 0xFFFF0002, /* operation is already canceled */ + TEEC_ERROR_ACCESS_CONFLICT = 0xFFFF0003, /* confilct occurs in concurrent access to data, + error occurs in file operaions generally */ + TEEC_ERROR_EXCESS_DATA = 0xFFFF0004, /* exceed max data to be handled by system */ + TEEC_ERROR_BAD_FORMAT = 0xFFFF0005, /* data format is invalid, Trusted Application cannot + handle it */ + TEEC_ERROR_BAD_PARAMETERS = 0xFFFF0006, /* invalid parameters */ + TEEC_ERROR_BAD_STATE = 0xFFFF0007, /* operation failed in current state, when try to access + storage without initilize storage service */ + TEEC_ERROR_ITEM_NOT_FOUND = 0xFFFF0008, /* cannot find target item */ + TEEC_ERROR_NOT_IMPLEMENTED = 0xFFFF0009, /* request operation is not implemented */ + TEEC_ERROR_NOT_SUPPORTED = 0xFFFF000A, /* request operation is not supported */ + TEEC_ERROR_NO_DATA = 0xFFFF000B, /* no data present for current operation */ + TEEC_ERROR_OUT_OF_MEMORY = 0xFFFF000C, /* system resource if out of use */ + TEEC_ERROR_BUSY = 0xFFFF000D, /* system is too busy to handle current operation */ + TEEC_ERROR_COMMUNICATION = 0xFFFF000E, /* error occurs when client try to communicate + with Trusted Application */ + TEEC_ERROR_SECURITY = 0xFFFF000F, /* security error occurs */ + TEEC_ERROR_SHORT_BUFFER = 0xFFFF0010, /* out buffer is not enough for current request */ + TEEC_ERROR_MAC_INVALID = 0xFFFF3071, /* MAC value check failed */ + TEEC_ERROR_TARGET_DEAD = 0xFFFF3024, /* Trusted Application is crashed */ + TEEC_FAIL = 0xFFFF5002 /* reserved error code */ +}; + +enum TEEC_ReturnCodeOrigin { + TEEC_ORIGIN_API = 0x1, /* error occurs in handling client API */ + TEEC_ORIGIN_COMMS = 0x2, /* error occurs in communicating between REE and TEE */ + TEEC_ORIGIN_TEE = 0x3, /* error occurs in TEE */ + TEEC_ORIGIN_TRUSTED_APP = 0x4, /* error occurs in Trusted Application */ +}; + +enum TEEC_SharedMemCtl { + TEEC_MEM_INPUT = 0x1, /* input type of memroy */ + TEEC_MEM_OUTPUT = 0x2, /* output type of memory */ + TEEC_MEM_INOUT = 0x3, /* memory is used as both input and output */ +}; + +enum TEEC_ParamType { + TEEC_NONE = 0x0, /* unused parameter */ + TEEC_VALUE_INPUT = 0x01, /* input type of value, refer TEEC_Value */ + TEEC_VALUE_OUTPUT = 0x02, /* output type of value, refer TEEC_Value */ + TEEC_VALUE_INOUT = 0x03, /* value is used as both input and output, refer TEEC_Value */ + TEEC_MEMREF_TEMP_INPUT = 0x05, /* input type of temp memory reference, refer TEEC_TempMemoryReference */ + TEEC_MEMREF_TEMP_OUTPUT = 0x06, /* output type of temp memory reference, refer TEEC_TempMemoryReference */ + TEEC_MEMREF_TEMP_INOUT = 0x07, /* temp memory reference used as both input and output, + refer TEEC_TempMemoryReference */ + TEEC_ION_INPUT = 0x08, /* input type of icon memory reference, refer TEEC_IonReference */ + TEEC_ION_SGLIST_INPUT = 0x09, /* input type of ion memory block reference, refer TEEC_IonSglistReference */ + TEEC_MEMREF_WHOLE = 0xc, /* use whole memory block, refer TEEC_RegisteredMemoryReference */ + TEEC_MEMREF_PARTIAL_INPUT = 0xd, /* input type of memory reference, refer TEEC_RegisteredMemoryReference */ + TEEC_MEMREF_PARTIAL_OUTPUT = 0xe, /* output type of memory reference, refer TEEC_RegisteredMemoryReference */ + TEEC_MEMREF_PARTIAL_INOUT = 0xf /* memory reference used as both input and output, + refer TEEC_RegisteredMemoryReference */ +}; + +/**************************************************** + * Session Login Methods + ****************************************************/ +enum TEEC_LoginMethod { + TEEC_LOGIN_PUBLIC = 0x0, /* no Login data is provided */ + TEEC_LOGIN_USER, /* Login data about the user running the + Client Application process is provided */ + TEEC_LOGIN_GROUP, /* Login data about the group running + the Client Application process is provided */ + TEEC_LOGIN_APPLICATION = 0x4, /* Login data about the running Client + Application itself is provided */ + TEEC_LOGIN_USER_APPLICATION = 0x5, /* Login data about the user running the + Client Application and about the + Client Application itself is provided */ + TEEC_LOGIN_GROUP_APPLICATION = 0x6, /* Login data about the group running + the Client Application and about the + Client Application itself is provided */ + TEEC_LOGIN_IDENTIFY = 0x7, /* iTrustee defined login type, Login data is provided by REE system */ +}; +enum TST_CMD_ID { + TST_CMD_ID_01 = 1, + TST_CMD_ID_02, + TST_CMD_ID_03, + TST_CMD_ID_04, + TST_CMD_ID_05 +}; + +#define TEEC_PARAM_NUM 4 /* teec param max number */ +#endif diff --git a/include/CA/tee_client_list.h b/include/CA/tee_client_list.h new file mode 100644 index 0000000..6dcf4e1 --- /dev/null +++ b/include/CA/tee_client_list.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: zhangdeyao + * Create: 2013-04-22 + * Description: linked list data types and basic operations + */ + +#ifndef TEE_CLIENT_LIST_H +#define TEE_CLIENT_LIST_H + +struct ListNode { + struct ListNode *next; /* point to next node */ + struct ListNode *prev; /* point to prev node */ +}; + +#define OFFSET_OF(type, member) (unsigned long)(&(((type *)0)->member)) +#define CONTAINER_OF(pos, type, member) (type *)(((char *)(pos)) - OFFSET_OF(type, member)) + +#define LIST_DECLARE(name) \ + struct ListNode name = { \ + .next = &name, \ + .prev = &name, \ + } + +static inline void ListInit(struct ListNode *list) +{ + list->next = list; + list->prev = list; +} + +#define LIST_HEAD(list) ((list)->next) +#define LIST_TAIL(list) ((list)->prev) +#define LIST_EMPTY(list) ((list) == (list)->next) + +static inline void ListInsertHead(struct ListNode *list, struct ListNode *entry) +{ + list->next->prev = entry; + entry->next = list->next; + entry->prev = list; + list->next = entry; +} + +static inline void ListInsertTail(struct ListNode *list, struct ListNode *entry) +{ + entry->next = list; + entry->prev = list->prev; + list->prev->next = entry; + list->prev = entry; +} + +static inline void ListRemoveEntry(struct ListNode *entry) +{ + entry->prev->next = entry->next; + entry->next->prev = entry->prev; +} + +static inline struct ListNode *ListRemoveHead(struct ListNode *list) +{ + struct ListNode *entry = NULL; + if (!LIST_EMPTY(list)) { + entry = list->next; + ListRemoveEntry(entry); + } + return entry; +} + +static inline struct ListNode *ListRemoveTail(struct ListNode *list) +{ + struct ListNode *entry = NULL; + if (!LIST_EMPTY(list)) { + entry = list->prev; + ListRemoveEntry(entry); + } + return entry; +} + +#define LIST_ENTRY(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + +#define LIST_FOR_EACH(pos, list) \ + for (pos = (list)->next; pos != (list); pos = pos->next) + +#define LIST_FOR_EACH_SAFE(pos, n, list) \ + for ((pos) = (list)->next, (n) = (pos)->next; \ + (pos) != (list); \ + (pos) = (n), (n) = (pos)->next) + +#define LIST_FOR_EACH_ENTRY(pos, list, member) \ + for (pos = LIST_ENTRY((list)->next, typeof(*pos), member); \ + &pos->member != (list); \ + pos = LIST_ENTRY(pos->member.next, typeof(*pos), member)) + +#define LIST_FOR_EACH_ENTRY_SAFE(pos, n, list, member) \ + for (pos = LIST_ENTRY((list)->next, typeof(*pos), member), \ + n = LIST_ENTRY(pos->member.next, typeof(*pos), member); \ + &pos->member != (list); \ + pos = n, n = LIST_ENTRY(n->member.next, typeof(*n), member)) + +#endif diff --git a/include/CA/tee_client_log.h b/include/CA/tee_client_log.h new file mode 100644 index 0000000..b9f5f60 --- /dev/null +++ b/include/CA/tee_client_log.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: zhangdeyao + * Create: 2020-03-31 + * Description: TEE client log api + */ + +#ifndef TEE_CLIENT_LOG_H +#define TEE_CLIENT_LOG_H + +#include + +#ifdef TEEC_DEBUG +#define TEEC_Debug(...) syslog(LOG_USER | LOG_INFO, __VA_ARGS__); +#else +#define TEEC_Debug(...) +#endif + +#define TEEC_Error(...) syslog(LOG_USER | LOG_INFO, __VA_ARGS__); + +#endif diff --git a/include/CA/tee_client_type.h b/include/CA/tee_client_type.h new file mode 100644 index 0000000..e7dd709 --- /dev/null +++ b/include/CA/tee_client_type.h @@ -0,0 +1,154 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: hanpeng + * Create: 2013-04-22 + * Description: data type and structure definition according to GP + */ + +#ifndef _TEE_CLIENT_TYPE_H_ +#define _TEE_CLIENT_TYPE_H_ + +#include +#include +#include +#include "tee_client_list.h" +#include "tee_client_constants.h" + +typedef unsigned int uint32_t; + +typedef signed int int32_t; + +typedef unsigned short uint16_t; + +typedef signed short int16_t; + +typedef unsigned char uint8_t; + +typedef signed char int8_t; + +#ifndef __cplusplus +#ifndef bool +#define bool uint8_t +#endif +#endif + +#ifndef true +#define true 1 +#endif + +#ifndef false +#define false 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +typedef enum TEEC_ReturnCode TEEC_Result; + +typedef struct { + uint32_t timeLow; + uint16_t timeMid; + uint16_t timeHiAndVersion; + uint8_t clockSeqAndNode[8]; +} TEEC_UUID; + +typedef struct { + int32_t fd; + uint8_t *ta_path; + struct ListNode session_list; + struct ListNode shrd_mem_list; + struct { + void *buffer; + sem_t buffer_barrier; + } share_buffer; +} TEEC_Context; + +typedef struct { + uint32_t session_id; + TEEC_UUID service_id; + uint32_t ops_cnt; + struct ListNode head; + TEEC_Context *context; +} TEEC_Session; + +typedef struct { + void *buffer; + uint32_t size; + uint32_t flags; /* reference to TEEC_SharedMemCtl */ + uint32_t ops_cnt; + bool is_allocated; /* identify whether the memory is registered or allocated */ + struct ListNode head; + TEEC_Context *context; +} TEEC_SharedMemory; + +/* + * the corresponding param types are + * TEEC_MEMREF_TEMP_INPUT/TEEC_MEMREF_TEMP_OUTPUT/TEEC_MEMREF_TEMP_INOUT + */ +typedef struct { + void *buffer; + uint32_t size; +} TEEC_TempMemoryReference; + +/* + * the corresponding param types are + * TEEC_MEMREF_WHOLE/TEEC_MEMREF_PARTIAL_INPUT + * TEEC_MEMREF_PARTIAL_OUTPUT/TEEC_MEMREF_PARTIAL_INOUT + */ +typedef struct { + TEEC_SharedMemory *parent; + uint32_t size; + uint32_t offset; +} TEEC_RegisteredMemoryReference; + +/* + * the corresponding param types are + * TEEC_VALUE_INPUT/TEEC_VALUE_OUTPUT/TEEC_VALUE_INOUT + */ +typedef struct { + uint32_t a; + uint32_t b; +} TEEC_Value; + +typedef struct { + int ion_share_fd; + uint32_t ion_size; +} TEEC_IonReference; + +typedef union { + TEEC_TempMemoryReference tmpref; + TEEC_RegisteredMemoryReference memref; + TEEC_Value value; + TEEC_IonReference ionref; +} TEEC_Parameter; + +typedef struct { + uint32_t event_type; /* Tui event type */ + uint32_t value; /* return value, is keycode if tui event is getKeycode */ + uint32_t notch; /* notch size of the screen for tui */ + uint32_t width; /* width of foldable screen */ + uint32_t height; /* height of foldable screen */ + uint32_t fold_state; /* state of foldable screen */ + uint32_t display_state; /* one state of folded state */ + uint32_t phy_width; /* real width of the mobile */ + uint32_t phy_height; /* real height of the mobile */ +} TEEC_TUI_Parameter; + +typedef struct { + uint32_t started; /* 0 means cancel this operation, others mean to perform this operation */ + uint32_t paramTypes; /* use TEEC_PARAM_TYPES to construct this value */ + TEEC_Parameter params[TEEC_PARAM_NUM]; + TEEC_Session *session; + bool cancel_flag; +} TEEC_Operation; + +#endif diff --git a/include/TA/huawei_ext/crypto_wrapper.h b/include/TA/huawei_ext/crypto_wrapper.h new file mode 100755 index 0000000..f6f2b96 --- /dev/null +++ b/include/TA/huawei_ext/crypto_wrapper.h @@ -0,0 +1,582 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: Yaodongdong + * Create: 2019-05-29 + * Description: soft engine in boringssl + */ +#ifndef __CRYPTO_WRAPPER_H__ +#define __CRYPTO_WRAPPER_H__ + +#include +#include +#include + +#define SHA256_LEN 32 +#define OEM_KEY_LEN 16 + +#define ECC_P256_PRIV_LEN 64 +#define ECC_P256_PUB_LEN 32 +#define RSA_PUB_LEN 1024 +#define RSA_PRIV_LEN 512 +#define ATTEST_TBS_MAXSIZE 512 +#define ATTESTATION_KEY_USAGE_OFFSET 16 +#define EC_FIX_BUFFER_LEN 66 +#define SHA256_HASH_LEN 32 +#define ECC_PRIV_LEN 66 +#define ECC_PUB_LEN 66 + +/* macro in tomcrypto start */ +/* ECC domain id */ +#define NIST_P192 0 +#define NIST_P224 1 +#define NIST_P256 2 +#define NIST_P384 3 +#define NIST_P521 4 + +#define SHA1_HASH 1 +#define SHA224_HASH 2 +#define SHA256_HASH 3 +#define SHA384_HASH 4 +#define SHA512_HASH 5 +/* Algorithm id */ +#define RSA_ALG 0 +#define ECC_ALG 1 +/* macro in tomcrypto end */ +#define DIR_ENC 0 +#define DIR_DEC 1 + +#define CRYPTO_NUMBER_TWO 2 +#define CRYPTO_NUMBER_THREE 3 +#define CRYPTO_NUMBER_FOUR 4 +#define CRYPTO_NUMBER_FIVE 5 +#define CRYPTO_NUMBER_SIX 6 +#define CRYPTO_NUMBER_SEVEN 7 +#define CRYPTO_NUMBER_EIGHT 8 +#define VALIDITY_TIME_SIZE 13 +#define SECRET_KEY_MAX_LEN 64 +#define CER_PUBLIC_KEY_MAX_LEN 300 +#define VALIDITY_FIX_LEN 32 +#define KEY_USAGE_FIX_LEN 41 +#define ITEM_THREE_ADD_LEN 12 +#define ITEM_THREE_MOVE_LEN 27 +#define ITEM_TWO_ADD_LEN 23 + +/* table struct for match convert */ +typedef struct { + uint32_t src; + uint32_t dest; +} crypto_u2u; + +#define VALIDITY_TIME_SIZE 13 +typedef struct { + uint8_t start[VALIDITY_TIME_SIZE]; + uint8_t end[VALIDITY_TIME_SIZE]; +} validity_period_t; + +typedef struct { + uint32_t domain; + uint8_t x[ECC_PUB_LEN]; + uint32_t x_len; + uint8_t y[ECC_PUB_LEN]; + uint32_t y_len; +} ecc_pub_key_t; + +typedef struct { + uint32_t domain; + uint8_t r[ECC_PRIV_LEN]; + uint32_t r_len; +} ecc_priv_key_t; + +typedef struct { + uint8_t e[RSA_PUB_LEN]; + uint32_t e_len; + uint8_t n[RSA_PUB_LEN]; + uint32_t n_len; +} rsa_pub_key_t; + +typedef struct { + uint8_t e[RSA_PUB_LEN]; + uint32_t e_len; + uint8_t n[RSA_PUB_LEN]; + uint32_t n_len; + uint8_t d[RSA_PUB_LEN]; + uint32_t d_len; + uint8_t p[RSA_PRIV_LEN]; + uint32_t p_len; + uint8_t q[RSA_PRIV_LEN]; + uint32_t q_len; + uint8_t dp[RSA_PRIV_LEN]; + uint32_t dp_len; + uint8_t dq[RSA_PRIV_LEN]; + uint32_t dq_len; + uint8_t qinv[RSA_PRIV_LEN]; + uint32_t qinv_len; +} rsa_priv_key_t; + +typedef struct { + unsigned char *ou; + unsigned char *o; + unsigned char *c; + unsigned char *cn; +} dn_name_t; + +struct ec_pub_info { + uint8_t *x; + uint32_t x_len; + uint8_t *y; + uint32_t y_len; +}; + +struct ec_priv_info { + uint32_t nid; + uint8_t *r; + uint32_t r_len; +}; + +/* + * Convert the ecc public key passed in by the user into the ecc_pub_key_t structure. + * + * @param pub [OUT] The ecc public key structure + * @param in [IN] The ecc public key buffer + * @param inlen [IN] The length of ecc public key buffer + * + * @return 1: Import ecc public key success + * @return -1: Import ecc public key failed + */ +int32_t ecc_import_pub(ecc_pub_key_t *pub, const uint8_t *in, uint32_t inlen); + +/* + * Convert the ecc_pub_key_t structure passed in by the user into ecc public key buffer. + * + * @param out [OUT] The ecc public key buffer + * @param outlen [IN/OUT] The length of ecc public key buffer + * @param pub [IN] The ecc public key structure + * + * @return -1: Export ecc public key failed + * @return others: The real size of out buffer + */ +int32_t ecc_export_pub(uint8_t *out, uint32_t out_size, ecc_pub_key_t *pub); + +/* + * Read next TLV (Type-Length-Value) from ASN1 buffer. + * + * @param type [OUT] Type of TLV + * @param header_len [OUT] Length of TLV + * @param buf [IN] Input TLV + * @param buf_len [IN] Length of buf in bytes + * + * @return -1: Get next TLV failed + * @return others: Length of next TLV + */ +int32_t get_next_tlv(uint32_t *type, uint32_t *header_len, const uint8_t *buf, uint32_t buf_len); + +/* + * Convert the ecc private key passed in by the user into the ecc_priv_key_t structure. + * + * @param priv [OUT] The ecc private key structure + * @param in [IN] The ecc private key buffer + * @param inlen [IN] The length of ecc private key buffer + * + * @return -1: Import ecc private key failed + * @return others: The width of ecc private key + */ +int32_t ecc_import_priv(ecc_priv_key_t *priv, const uint8_t *in, uint32_t inlen); + +/* + * Use ECC algorithm to sign user data. + * + * @param signature [OUT] The signature of input data + * @param sig_siz [IN/OUT] The length of signature + * @param in [IN] The data to be sign + * @param in_len [IN] The length of input data + * @param priv [IN] The ecc private key structure + * + * @return -1: Sign input buffer use ecc failed + * @return others: The length of signature + */ +int32_t ecc_sign_digest(uint8_t *signature, uint32_t sig_size, uint8_t *in, uint32_t in_len, ecc_priv_key_t *priv); + +/* + * Verify the data with ECC algorithm. + * + * @param signature [IN] The signature of input data + * @param sig_len [IN] The length of signature + * @param in [IN] The input data + * @param in_len [IN] The length of input data + * @param pub [IN] The ecc public key structure + * + * @return 1: Verify digest success + * @return -1: Verify digest failed + */ +int32_t ecc_verify_digest(const uint8_t *signature, uint32_t sig_len, uint8_t *in, uint32_t in_len, ecc_pub_key_t *pub); + +/* + * Generate rsa key pair. + * @param priv [OUT] The rsa private key structure + * @param pub [OUT] The rsa public key structure + * @param e [IN] The exponent of rsa key + * @param key_size [IN] The size of rsa key + * + * @return 0: Generate rsa keypair success + * @return -1: Generate rsa keypair failed + */ +int32_t rsa_generate_keypair(rsa_priv_key_t *priv, rsa_pub_key_t *pub, uint32_t e, uint32_t key_size); + +/* + * Do rsa encryption. + * + * @param dest_data [OUT] The dest data buffer + * @param dest_len [IN/OUT] The length of dest data + * @param src_data [IN] The src data buffer + * @param src_len [IN] The length of src data + * @param pub [IN] The rsa public key structure + * @param padding [IN] The padding type of encryption + * @param hash_nid [IN] The hash_nid of encryption + * + * @return 0: Do rsa encryption success + * @return -1: Do rsa encryption failed + */ +int32_t rsa_encrypt(uint8_t *dest_data, uint32_t *dest_len, uint8_t *src_data, uint32_t src_len, rsa_pub_key_t *pub, + int32_t padding, int32_t hash_nid); + +/* + * Do rsa decryption. + * + * @param dest_data [OUT] The dest data buffer + * @param dest_len [IN/OUT] The length of dest data + * @param src_data [IN] The src data buffer + * @param src_len [IN] The length of src data + * @param priv [IN] THE rsa private key structure + * @param padding [IN] The padding type of encryption + * @param hash_nid [IN] The hash_nid of encryption + * + * @return 0: Do rsa decryption success + * @return -1: Do rsa decryption failed + */ +int32_t rsa_decrypt(uint8_t *dest_data, uint32_t *dest_len, uint8_t *src_data, uint32_t src_len, rsa_priv_key_t *priv, + uint32_t padding, int32_t hash_nid); + +/* + * Do rsa Sign digest. + * + * @param signature [OUT] The signature of input data + * @param sig_size [IN/OUT] The length of signature + * @param in [IN] The input data + * @param in_len [IN] The length of input data + * @param priv [IN] The rsa private key structure + * @param salt_len [IN] The length of salt + * @param hash_nid [IN] The hash_nid of encryption + * @param padding [IN] The padding type of encryption + * + * @return 0: Do rsa sign digest success + * @return -1: Do rsa Sign digest failed + */ +int32_t rsa_sign_digest(uint8_t *signature, uint32_t *sig_size, uint8_t *in, uint32_t in_len, rsa_priv_key_t *priv, + uint32_t salt_len, int32_t hash_nid, int32_t padding); + +/* + * Do rsa Verify digest. + * + * @param signature [IN] The signature of input data + * @param sig_size [IN] The length of signature + * @param in [IN] The input data + * @param in_len [IN] The length of input data + * @param pub [IN] The rsa public key structure + * @param salt_len [IN] The length of salt + * @param hash_nid [IN] The hash_nid of encryption + * @param padding [IN] The padding type of encryption + * + * @return 0: Do rsa verify success + * @return -1: Do rsa verify failed + */ +int32_t rsa_verify_digest(uint8_t *signature, uint32_t sig_size, uint8_t *in, uint32_t in_len, const rsa_pub_key_t *pub, + uint32_t salt_len, int32_t hash_nid, int32_t padding); + +/* + * Convert the rsa private key passed in by the user into the rsa_priv_key_t structure. + * + * @param priv [OUT] The rsa private key structure + * @param in [IN] The rsa private key buffer + * @param inlen [IN] The length of rsa private key buffer + * + * @return -1: Import rsa private key failed + * @return 0: Import rsa private key success + */ +int rsa_import_priv(rsa_priv_key_t *priv, const uint8_t *in, uint32_t in_len); + +/* + * Check the certificate revocation list. + * + * @param cert [IN] The crl buffer + * @param cert_len [IN] The length of crl buffer + * @param parent_key [IN] The public key to verify the crl + * @param parent_key_len [IN] The length of public key + * + * @return 1: Check the crl success + * @return others: Check the crl failed + */ +int x509_crl_validate(uint8_t *cert, uint32_t cert_len, uint8_t *parent_key, uint32_t parent_key_len); + +/* + * Check the x509 certificate. + * + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * @param parent_key [IN] The public key to verify the crl + * @param parent_key_len [IN] The length of public key + * + * @return 1: Check the cert success + * @return others: Check the cert failed + */ +int x509_cert_validate(uint8_t *cert, uint32_t cert_len, uint8_t *parent_key, uint32_t parent_key_len); + +/* + * Get public key from certificate. + * + * @param pub [OUT] The public key struct + * @param in [IN] The certificate buffer + * @param inlen [IN] The length of certificate buffer + * + * @return 0: Get public key success + * @return -1: Get public key failed + */ +int import_pub_from_sp(void *pub, const uint8_t *in, uint32_t inlen); + +/* + * Get public key from certificate. + * + * @param pub [OUT] The public key buffer + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return -1: Get public key failed + * @return others: The length of public key buffer + */ +int get_subject_public_key(uint8_t *pub, const uint8_t *cert, uint32_t cert_len); + +/* + * Get public key from certificate. + * + * @param pub [OUT] The public key buffer + * @param pub_size [IN/OUT] The length of public key buffer + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return -1: Get public key failed + * @return others: The length of public key buffer + */ +int get_subject_public_key_new(uint8_t *pub, uint32_t pub_size, const uint8_t *cert, uint32_t cert_len); + +/* + * Get valid date from certificate. + * + * @param vd [OUT] The valid data structure + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return 0: Get valid date success + * @return -1: Get valid data failed + */ +int get_validity_from_cert(validity_period_t *vd, uint8_t *cert, uint32_t cert_len); + +/* + * Get common name from certificate. + * + * @param name [OUT] The common name buffer + * @param name_size [IN/OUT] The length of common name buffer + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return -1: Get common name failed + * @return others: Get common name success + */ +int get_subject_CN(uint8_t *name, uint32_t name_size, const uint8_t *cert, uint32_t cert_len); + +/* + * Get organization name from certificate. + * + * @param name [OUT] The organization name buffer + * @param name_size [IN/OUT] The length of organization name buffer + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return -1: Get organization name failed + * @return others: Get organization name success + */ +int get_subject_OU(uint8_t *name, uint32_t name_size, const uint8_t *cert, uint32_t cert_len); + +/* + * Get serial number from certificate. + * + * @param serial_number [OUT] The serial number buffer + * @param serial_number_size [IN/OUT] The length of serial number buffer + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return -1: Get serial number failed + * @return others: Get serial number success + */ +int get_serial_number_from_cert(uint8_t *serial_number, uint32_t serial_number_size, uint8_t *cert, uint32_t cert_len); + +/* + * Get issuer from certificate. + * + * @param issuer [OUT] The issuer buffer + * @param issuer_size [IN/OUT] The length of issuer buffer + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return -1: Get serial number failed + * @return others: Get serial number success + */ +int get_issuer_from_cert(uint8_t *issuer, uint32_t issuer_size, uint8_t *crl, uint32_t crl_len); + +/* + * Get element number from certificate. + * + * @param elem [OUT] The element with elem_id + * @param elem_id [IN] The index of element + * @param cert [IN] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * + * @return -1: Get element failed + * @return others: The length of element + */ +int32_t get_tbs_element(uint8_t **elem, uint32_t elem_id, const uint8_t *cert, uint32_t cert_len); + +/* + * Recover the root certificate. + * + * @param cert [OUT] The certificate buffer + * @param cert_len [IN/OUT] The length of certificate buffer + * @param priv [IN] The private key structure + * @param keytype [IN] The keytype of private key + * + * @return -1: Recover root certificate failed + * @return others: Recover root certificate success + */ +int32_t recover_root_cert(uint8_t *cert, uint32_t cert_len, const void *priv, uint32_t keytype); + +/* + * Convert the rsa_pub_key_t structure passed in by the user into rsa public key buffer. + * + * @param out [OUT] The rsa public key buffer + * @param outlen [IN] The length of rsa public key buffer + * @param pub [IN] The rsa public key structure + * + * @return -1: Export rsa public key failed + * @return others: The real size of out buffer + */ +int32_t rsa_export_pub_sp(uint8_t *out, uint32_t out_size, rsa_pub_key_t *pub); + +/* + * Sign the pkcs10 certificate. + * + * @param cert [OUT] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * @param csr [IN] The certificate signing request buffer + * @param csr_len [IN] The length of certificate signing request buffer + * @param valid [IN] The valid date buffer + * @param serial_number [IN] The serial number buffer + * @param serial_length [IN] The length of serial number buffer + * @param priv [IN] The private key structure + * @param keytype [IN] The keytype of private key + * + * @return -1: Sign the pkcs10 certificate failed + * @return others: The real size of certificate + */ +int32_t sign_pkcs10(uint8_t *cert, uint32_t cert_len, + const uint8_t *csr, uint32_t csr_len, const validity_period_t *valid, + const uint8_t *serial_number, uint32_t serial_length, const void *priv, uint32_t keytype); + +/* + * Create attestation certificate with input params. + * + * @param cert [OUT] The certificate buffer + * @param cert_len [IN] The length of certificate buffer + * @param valid [IN] The valid date buffer + * @param issuer_tlv [IN] The issuer buffer + * @param issuer_tlv_len [IN] The length of issuer buffer + * @param subject_public_key [IN] The subject public key buffer + * @param subject_public_key_len [IN] The length of subject public key buffer + * @param attestation_ext [IN] The attestation extrol infor buffer + * @param attestation_ext_len [IN] The length of attestation extrol infor buffer + * @param priv_sign [IN] The private key buffer + * @param key_usage_sign_bit [IN] The usage sign falg + * @param key_usage_encrypt_bit [IN] The usage encrypt flag + * @param keytype [IN] The keytype of private key + * @param hash [IN] The hash func of digest + * + * @return -1: Create attestation certificate failed + * @return others: The real size of certificate + */ +int32_t create_attestation_cert(uint8_t *cert, uint32_t cert_len, const validity_period_t *valid, + const uint8_t *issuer_tlv, uint32_t issuer_tlv_len, + const uint8_t *subject_public_key, uint32_t subject_public_key_len, + const uint8_t *attestation_ext, uint32_t attestation_ext_len, void *priv_sign, + uint32_t key_usage_sign_bit, uint32_t key_usage_encrypt_bit, uint32_t key_type, + uint32_t hash); + +/* + * Get oem huk. + * + * @param huk [OUT] The oem huk buffer + * @param key [IN] The hmac key buffer + * @param key_size [IN] The length of hmac key buffer + * + * @return 0: Get oem huk success + * @return -1: Get oem huk failed + */ +int get_class_oem_huk(uint8_t *huk, const uint8_t *key, uint32_t key_size); + +/* + * Derive ecc public key from private key. + * + * @param priv_info [IN] The ecc_priv_key_t structure + * @param pub_info [OUT] The ecc_pub_key_t structure + * + * @return 0: Derive ecc public key success + * @return -1: Derive ecc public key failed + */ +int ecc_derive_public_key(ecc_priv_key_t *priv_info, ecc_pub_key_t *pub_info); + +/* + * Derive ecc private key from huk. + * + * @param priv [OUT] The ecc_priv_key_t structure + * @param secret [IN] The huk buffer + * @param sec_len [IN] The length of huk buffer + * + * @return 0: Derive ecc private key success + * @return -1: Derive ecc private key failed + */ +int derive_ecc_private_key_from_huk(ecc_priv_key_t *priv, const uint8_t *secret, uint32_t sec_len); + +/* + * Do aes key wrap operation. + * @param params [IN/OUT] The cdrm_params structure contains key/iv/input/output info + * + * @return TEE_SUCCESS: Do aes key wrap operation success + * @return others: Do aes key wrap operation failed + */ +TEE_Result aes_key_wrap(struct cdrm_params *params); + +/* + * Do aes key unwrap operation. + * + * @param params [IN/OUT] The cdrm_params structure contains key/iv/input/output info + * + * @return TEE_SUCCESS: Do aes key unwrap operation success + * @return others: Do aes key unwrap operation failed + */ +TEE_Result aes_key_unwrap(struct cdrm_params *params); + +#endif diff --git a/include/TA/huawei_ext/tee_crypto_hal.h b/include/TA/huawei_ext/tee_crypto_hal.h new file mode 100755 index 0000000..878794b --- /dev/null +++ b/include/TA/huawei_ext/tee_crypto_hal.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: jialingyu + * Create: 2019-01-20 + * Description: crypto hal info function + */ + +#ifndef TEE_CRYPTO_HAL_H +#define TEE_CRYPTO_HAL_H +#include "tee_crypto_api.h" +enum CRYPTO_ENGINE { + DX_CRYPTO, + EPS_CRYPTO, + SOFT_CRYPTO, + SEC_CRYPTO, + CRYPTO_ENGINE_MAX, +}; + +/* + * Set the encryption and decryption engine to operation + * + * @param operation [IN/OUT] The handle of operation + * @param crypto [IN]The engine to be set + * + * @retval TEE_SUCCESS: Set crypto engine success + * @retval TEE_ERROR_BAD_PARAMETERS: Operation is NULLi or crypto is invalid + */ +TEE_Result TEE_SetCryptoFlag(TEE_OperationHandle operation, uint32_t crypto); + +/* + * Set the encryption and decryption engine to object + * + * @param operation [IN/OUT] The handle of object + * @param crypto [IN]The engine to be set + * + * @retval TEE_SUCCESS: Set crypto engine success + * @retval TEE_ERROR_BAD_PARAMETERS: Operation is NULLi or crypto is invalid + */ +TEE_Result TEE_SetObjectFlag(TEE_ObjectHandle object, uint32_t crypto); +#endif diff --git a/include/TA/huawei_ext/tee_ext_api.h b/include/TA/huawei_ext/tee_ext_api.h new file mode 100644 index 0000000..b8b1329 --- /dev/null +++ b/include/TA/huawei_ext/tee_ext_api.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: huangjiankang + * Create: 2012-03-20 + * Description: Tee ext api header file + */ + +#ifndef TEE_EXT_API_H +#define TEE_EXT_API_H + +#include "tee_defines.h" +#include "tee_core_api.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +/* + * below definitions are defined by Platform SDK released previously + * for compatibility: + * don't make any change to the content below + */ +#define TEE_INFO_RESERVED 0xFFFFFFFF +#define TEE_RETURN_AGENT_BUFFER 0x99 +#define TEE_INVALID_AGENT 0x66 +#define TEE_AGENT_LOCK 0x33 + +#define TEE_GET_REEINFO_SUCCESS 0 +#define TEE_GET_REEINFO_FAILED 1 + +#define RESERVED_BUF_SIZE 32 +typedef struct __caller_info { + uint32_t session_type; + union { + TEE_UUID caller_uuid; + uint8_t ca_info[RESERVED_BUF_SIZE]; + } caller_identity; + uint8_t reserved[RESERVED_BUF_SIZE]; +} caller_info; + +/* + * Get caller info of current session, refer caller_info struct for more details + * + * @param caller_info_data [OUT] caller info to be returned + * @param length [IN] sizeof struct caller_info + * + * return TEE_SUCCESS operation success + * return others failed to get caller info + */ +TEE_Result TEE_EXT_GetCallerInfo(caller_info *caller_info_data, uint32_t length); + +/* + * verify TA's caller's identify + * TA can call this API to add caller's info, + * which is allowed to call this TA. + * this API is for CA in form of JAR or binary-excuteble file. + * + * @param ca_name [IN] CA caller's process name + * @param user_name [IN] CA caller's username + * + * return TEE_SUCCESS operation + * return others failed to add caller info for target CA + */ +TEE_Result addcaller_ca_exec(const char *ca_name, const char *user_name); + +/* + * TA call this API allow others TA open session with itself + * + * return TEE_SUCCESS operation success + * result others operation failed + */ +TEE_Result AddCaller_TA_all(void); + +#define SESSION_FROM_CA 0 +#define SESSION_FROM_TA 1 +#define SESSION_FROM_UNKNOWN 0xFF +/* + * get cruurent session type + * + * @return session type of current session + */ +uint32_t TEE_GetSessionType(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +#endif diff --git a/include/TA/huawei_ext/tee_log.h b/include/TA/huawei_ext/tee_log.h new file mode 100644 index 0000000..36fc1d5 --- /dev/null +++ b/include/TA/huawei_ext/tee_log.h @@ -0,0 +1,219 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: Hanpeng + * Create: 2018-12-13 + * Description: Reference of TEE log api and internal definitions + */ + +#ifndef __TEE_LOG_H +#define __TEE_LOG_H + +#include "tee_defines.h" + +#define DEBUG_TAG "[debug]" +#define INFO_TAG "[info]" +#define WARNING_TAG "[warning]" +#define ERROR_TAG "[error]" + +#define LEVEL_DEBUG 2 +#define LEVEL_WARNING 1 +#define LEVEL_ERROR 0 + +#define TAG_VERB "[verb]" +#define TAG_DEBUG "[debug]" +#define TAG_INFO "[info]" +#define TAG_WARN "[warn]" +#define TAG_ERROR "[error]" + +typedef enum { + LOG_LEVEL_ERROR = 0, + LOG_LEVEL_WARN = 1, + LOG_LEVEL_INFO = 2, + LOG_LEVEL_DEBUG = 3, + LOG_LEVEL_VERBO = 4, + LOG_LEVEL_ON = 5, +} LOG_LEVEL; + +void uart_cprintf(const char *fmt, ...); +void uart_printf_func(const char *fmt, ...); + +void tee_print(LOG_LEVEL log_level, const char *fmt, ...); +void tee_print_driver(LOG_LEVEL log_level, const char *log_tag, const char *fmt, ...); +extern const char *g_debug_prefix; + +#define TEE_LogPrintf(fmt, args...) SLog(fmt, ##args) +#ifdef LOG_ON +#ifdef DRIVER_LOG_TAG +#define tlogv(fmt, args...) \ + tee_print_driver(LOG_LEVEL_VERBO, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_VERB, __LINE__, ##args) +#define tlogd(fmt, args...) \ + tee_print_driver(LOG_LEVEL_DEBUG, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_DEBUG, __LINE__, ##args) +#define tlogi(fmt, args...) \ + tee_print_driver(LOG_LEVEL_INFO, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_INFO, __LINE__, ##args) +#define tlogw(fmt, args...) \ + tee_print_driver(LOG_LEVEL_WARN, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_WARN, __LINE__, ##args) +#else +#define tlogv(fmt, args...) tee_print(LOG_LEVEL_VERBO, "%s %d:" fmt "", TAG_VERB, __LINE__, ##args) +#define tlogd(fmt, args...) tee_print(LOG_LEVEL_DEBUG, "%s %d:" fmt "", TAG_DEBUG, __LINE__, ##args) +#define tlogi(fmt, args...) tee_print(LOG_LEVEL_INFO, "%s %d:" fmt "", TAG_INFO, __LINE__, ##args) +#define tlogw(fmt, args...) tee_print(LOG_LEVEL_WARN, "%s %d:" fmt "", TAG_WARN, __LINE__, ##args) +#endif +#else +#define tlogv(fmt, args...) \ + do { \ + } while (0) +#define tlogd(fmt, args...) \ + do { \ + } while (0) +#define tlogi(fmt, args...) \ + do { \ + } while (0) +#define tlogw(fmt, args...) \ + do { \ + } while (0) +#endif /* ENG_VERSION */ + +#ifndef TLOGE_NO_TIMESTAMP +#ifdef DRIVER_LOG_TAG +#define tloge(fmt, args...) \ + tee_print_driver(LOG_LEVEL_ERROR, DRIVER_LOG_TAG, "%s %d:" fmt " ", TAG_ERROR, __LINE__, ##args) +#else +#define tloge(fmt, args...) tee_print(LOG_LEVEL_ERROR, "%s %d:" fmt " ", TAG_ERROR, __LINE__, ##args) +#endif +#else +#define tloge(fmt, args...) printf("[%s] %s %d:" fmt " ", g_debug_prefix, TAG_ERROR, __LINE__, ##args) +#endif + +void ta_print(LOG_LEVEL log_level, const char *fmt, ...); + +#ifdef LOG_ON +#define ta_logv(fmt, args...) ta_print(LOG_LEVEL_VERBO, "%s %d: " fmt "\n", TAG_VERB, __LINE__, ##args) +#define ta_logd(fmt, args...) ta_print(LOG_LEVEL_DEBUG, "%s %d: " fmt "\n", TAG_DEBUG, __LINE__, ##args) +#define ta_logi(fmt, args...) ta_print(LOG_LEVEL_INFO, "%s %d: " fmt "\n", TAG_INFO, __LINE__, ##args) +#define ta_logw(fmt, args...) ta_print(LOG_LEVEL_WARN, "%s %d: " fmt "\n", TAG_WARN, __LINE__, ##args) +#else +#define ta_logv(fmt, args...) \ + do { \ + } while (0) +#define ta_logd(fmt, args...) \ + do { \ + } while (0) +#define ta_logi(fmt, args...) \ + do { \ + } while (0) +#define ta_logw(fmt, args...) \ + do { \ + } while (0) +#endif +#define ta_loge(fmt, args...) ta_print(LOG_LEVEL_ERROR, "%s %d: " fmt "\n", TAG_ERROR, __LINE__, ##args) + +/* in debug version users can dynamically modify the loglevel ,in release version, users have to modify the level by + * compile */ +#ifndef DEBUG_VERSION + +#ifdef TA_DEBUG +#define ta_debug(fmt, args...) uart_printf_func("%s %s: " fmt "", DEBUG_TAG, __FUNCTION__, ##args) +#else +#define ta_debug(fmt, args...) +#endif + +#else + +#define ta_debug(fmt, args...) \ + do { \ + uint32_t level; \ + level = get_value(); \ + if (level >= LEVEL_DEBUG) { \ + uart_printf_func("%s %s: " fmt "", DEBUG_TAG, __FUNCTION__, ##args); \ + } \ + } while (0) + +#define ta_warning(fmt, args...) \ + do { \ + uint32_t level; \ + level = get_value(); \ + if (level >= LEVEL_WARNING) { \ + uart_printf_func("%s %s: " fmt "", DEBUG_TAG, __FUNCTION__, ##args); \ + } \ + } while (0) + +#endif + +#define ta_info(fmt, args...) uart_printf_func("%s: " fmt "", INFO_TAG, ##args) +#define ta_error(fmt, args...) uart_printf_func("%s: " fmt " ", ERROR_TAG, ##args) +#define TA_LOG +#ifdef TA_LOG + +#define TRACE_S "[Trace]" +#define WARNING_S "[Warning]" +#define ERROR_S "[Error]" + +/* + * Print trace level's log. + * + * @param fmt [IN] assert condition. + * @param args [IN] params for format config. + * + * @return void + */ +#define SLogTrace(fmt, args...) SLog("%s: " fmt "\n", TRACE_S, ##args) + +/* + * Print warning level's log. + * + * @param fmt [IN] assert condition. + * @param args [IN] params for format config. + * + * @return void + */ +#define SLogWarning(fmt, args...) SLog("%s: " fmt "\n", WARNING_S, ##args) + +/* + * Print error level's log. + * + * @param fmt [IN] assert condition. + * @param args [IN] params for format config. + * + * @return void + */ +#define SLogError(fmt, args...) SLog("%s: " fmt "\n", ERROR_S, ##args) + +/* + * Assert api for tee log, note: should call Panic to deal, here just return + * + * @param exp [IN] Printf log's format config style. + * + * @return void + */ +#define SAssert(exp) \ + do { \ + if (!(exp)) { \ + SLog("Assertion [ %s ] Failed: File %s, Line %d\n", #exp, "__FILE__", __LINE__); \ + return 0xFFFF0001; \ + } \ + } while (0); +#else +#define SLogTrace(fmt, args...) ((void)0) +#define SLogWarning(fmt, args...) ((void)0) +#define SLogError(fmt, args...) ((void)0) +#define SAssert(exp) ((void)0) +#endif + +/* + * Output log to tee log file. + * + * @param fmt [IN] Printf log's format config style. + * + * @return void + */ +void SLog(const char *fmt, ...); +uint32_t get_value(void); +#endif diff --git a/include/TA/tee_arith_api.h b/include/TA/tee_arith_api.h new file mode 100755 index 0000000..a2159e9 --- /dev/null +++ b/include/TA/tee_arith_api.h @@ -0,0 +1,477 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: qiqingchao + * Create: 2012-01-20 + * Description: tee crypto definitions + */ + +#ifndef TEE_ARITH_API_H +#define TEE_ARITH_API_H + +#include "tee_defines.h" + +#ifndef API_LEVEL +#define API_LEVEL API_LEVEL1_0 +#endif + +/* + * below definitions are defined by Global Platform + * for compatibility: + * don't make any change to the content below + */ +typedef uint32_t TEE_BigInt; +typedef uint32_t TEE_BigIntFMM; +typedef uint32_t TEE_BigIntFMMContext; + +#define TEE_BigIntSizeInU32(n) ((((n) + 31) / 32) + 2) + +/* + * returns the size of the array of uint32_t values + * + * @param modulusSizeInBits [IN] Size of modulus in bits + * + * @return Number of bytes needed to store a TEE_BigIntFMM given a modulus of length modulusSizeInBits + */ +size_t TEE_BigIntFMMSizeInU32(size_t modulusSizeInBits); + +/* + * returns the size of the array of uint32_t values needed to represent a fast modular context + * + * @param modulusSizeInBits [IN] Size of modulus in bits + * + * @return Number of bytes needed to store a TEE_BigIntFMMContext given a modulus of length modulusSizeInBits + */ +size_t TEE_BigIntFMMContextSizeInU32(size_t modulusSizeInBits); + +/* + * initializes bigInt + * + * @param bigInt[OUT] A pointer to the TEE_BigInt to be initialized + * @param len[IN] The size in uint32_t of the memory pointed to by bigInt + * + * @return void + */ +void TEE_BigIntInit(TEE_BigInt *bigInt, size_t len); + +/* + * calculates the necessary prerequisites for the fast modular multiplication and stores them in a context. + * + * @param context[OUT] A pointer to the TEE_BigIntFMMContext to be initialized + * @param len[IN] The size in uint32_t of the memory pointed to by context + * @param modulus[IN] The modulus + * + * @return void + */ +void TEE_BigIntInitFMMContext(TEE_BigIntFMMContext *context, size_t len, const TEE_BigInt *modulus); + +#if (API_LEVEL >= API_LEVEL1_1_1) + +/* + * calculates the necessary prerequisites for the fast modular multiplication and stores them in a context. + * + * @param context[OUT] A pointer to the TEE_BigIntFMMContext to be initialized + * @param len[IN] The size in uint32_t of the memory pointed to by context + * @param modulus[IN] The modulus + * + * @return #TEE_SUCCESS success + * @return other failed + */ +TEE_Result TEE_BigIntInitFMMContext1(TEE_BigIntFMMContext *context, size_t len, const TEE_BigInt *modulus); +#endif // API_LEVEL + +/* + * initializes bigIntFMM and sets its represented value to zero. + * + * @param context[IN] A pointer to the TEE_BigIntFMM to be initialized + * @param len[IN] The size in uint32_t of the memory pointed to by bigIntFMM + * + * @return void + */ +void TEE_BigIntInitFMM(TEE_BigIntFMM *bigIntFMM, size_t len); + +/* + * converts a bufferLen byte octet string buffer into a TEE_BigInt format. + * + * @param dest [OUT] Pointer to a TEE_BigInt to hold the result + * @param buffer [IN] Pointer to the buffer containing the octet string representation of the integer + * @param bufferLen [IN] The length of *buffer in bytes + * @param sign [IN] The sign of dest is set to the sign of sign + * + * @return #TEE_SUCCESS support + * @return #TEE_ERROR_OVERFLOW If memory allocation for the dest is too small + */ +TEE_Result TEE_BigIntConvertFromOctetString(TEE_BigInt *dest, const uint8_t *buffer, size_t bufferLen, int32_t sign); + +/* + * converts the absolute value of an integer in TEE_BigInt format into an octet string + * + * @param buffer [OUT] Output buffer where converted octet string representation of the integer is written + * @param bufferLen [IN] The length of *buffer in bytes + * @param bigInt [IN] Pointer to the integer that will be converted to an octet string + * + * @return #TEE_SUCCESS support + * @return #TEE_ERROR_SHORT_BUFFER If the output buffer is too small to contain the octet string + */ +TEE_Result TEE_BigIntConvertToOctetString(void *buffer, size_t *bufferLen, const TEE_BigInt *bigInt); + +/* + * sets *dest to the value shortVal + * + * @param dest [OUT] Pointer to a TEE_BigInt to store the result + * @param shortVal [IN] Input value + * + * @return void + */ +void TEE_BigIntConvertFromS32(TEE_BigInt *dest, int32_t shortVal); + +/* + * sets *dest to the value of src, including the sign of src. + * + * @param dest [OUT] Pointer to an int32_t to store the result + * @param src [IN] Pointer to the input value + * + * @return #TEE_SUCCESS support + * @return #TEE_ERROR_OVERFLOW If src does not fit within an int32_t + */ +TEE_Result TEE_BigIntConvertToS32(int32_t *dest, const TEE_BigInt *src); + +/* + * checks whether op1>op2, op1==op2, or op1op2 + */ +int32_t TEE_BigIntCmp(const TEE_BigInt *op1, const TEE_BigInt *op2); + +/* + * checks whether op>shortVal, op==shortVal, or opshortVal + */ +int32_t TEE_BigIntCmpS32(const TEE_BigInt *op, int32_t shortVal); + +/* + * computes |dest| = |op| >> bits + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the shifted result + * @param op [IN] Pointer to the operand to be shifted + * @param bits [IN] Number of bits to shift + * + * @return void + */ +void TEE_BigIntShiftRight(TEE_BigInt *dest, const TEE_BigInt *op, size_t bits); + +/* + * returns the bitIndexth bit of the natural binary representation of |src| + * + * @param src [IN] Pointer to the integer + * @param bitIndex[IN] The offset of the bit to be read, starting at offset 0 for the least significant bit + * + * @return true The Boolean value of the bitIndexth bit in |src| is '1' + * @return false The Boolean value of the bitIndexth bit in |src| is '0' + */ +bool TEE_BigIntGetBit(const TEE_BigInt *src, uint32_t bitIndex); + +/* + * returns the number of bits in the natural binary representation of |src|; that is, the magnitude of src + * + * @param src [IN] Pointer to the integer + * + * @return 0 src equals zero + * @return others The number of bits in the natural binary representation of |src|. + */ +uint32_t TEE_BigIntGetBitCount(const TEE_BigInt *src); + +#if (API_LEVEL >= API_LEVEL1_2) +/* + * sets the bitIndexth bit of the natural binary representation of |op| to 1 or 0 + * + * @param op [IN/OUT] Pointer to the integer + * @param bitIndex [IN] The offset of the bit to be set, starting at offset 0 for the least significant bit + * @param value [IN] The bit value to set where true represents a '1' and false represents a '0' + * + * @return #TEE_SUCCESS support + * @return #TEE_ERROR_OVERFLOW If the bitIndexth bit is larger than allocated bit length of op + */ +TEE_Result TEE_BigIntSetBit(TEE_BigInt *op, uint32_t bitIndex, bool value); + +/* + * assigns the value of src to dest + * + * @param dest [OUT] Pointer to TEE_BigInt to be assigned + * @param src [IN] Pointer to the source operand + * + * @return #TEE_SUCCESS support + * @return #TEE_ERROR_OVERFLOW In case the dest operand cannot hold the value of src + */ +TEE_Result TEE_BigIntAssign(TEE_BigInt *dest, const TEE_BigInt *src); + +/* + * assigns the value of |src| to dest + * + * @param dest [OUT] Pointer to TEE_BigInt to be assigned + * @param src [IN] Pointer to the source operand + * + * @return #TEE_SUCCESS support + * @return #TEE_ERROR_OVERFLOW In case the dest operand cannot hold the value of |src| + */ +TEE_Result TEE_BigIntAbs(TEE_BigInt *dest, const TEE_BigInt *src); +#endif // API_LEVEL + +/* + * computes dest = op1 + op2 + * + * @param dest [OUT] Pointer to TEE_BigInt to store the result op1 + op2 + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * + * @return void + */ +void TEE_BigIntAdd(TEE_BigInt *dest, const TEE_BigInt *op1, const TEE_BigInt *op2); + +/* + * computes dest = op1 - op2 + * + * @param dest [OUT] Pointer to TEE_BigInt to store the result op1 - op2 + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * + * @return void + */ +void TEE_BigIntSub(TEE_BigInt *dest, const TEE_BigInt *op1, const TEE_BigInt *op2); + +/* + * negates an operand: dest = -op + * + * @param dest [OUT] PPointer to TEE_BigInt to store the result -op + * @param op [IN] Pointer to the operand to be negated + * + * @return void + */ +void TEE_BigIntNeg(TEE_BigInt *dest, const TEE_BigInt *op); + +/* + * computes dest = op1 * op2 + * + * @param dest [OUT] Pointer to TEE_BigInt to store the result op1 * op2 + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * + * @return void + */ +void TEE_BigIntMul(TEE_BigInt *dest, const TEE_BigInt *op1, const TEE_BigInt *op2); + +/* + * computes dest = op * op + * + * @param dest [OUT] Pointer to TEE_BigInt to store the result op * op + * @param op [IN] Pointer to the operand to be squared + * + * @return void + */ +void TEE_BigIntSquare(TEE_BigInt *dest, const TEE_BigInt *op); + +/* + * computes dest_r and dest_q such that op1 = dest_q * op2 + dest_r + * + * @param dest_q [OUT] Pointer to a TEE_BigInt to store the quotient + * @param dest_r [IN] Pointer to a TEE_BigInt to store the remainder + * @param op1 [OUT] Pointer to the first operand, the dividend + * @param op2 [IN] Pointer to the second operand, the divisor + * + * @return #TEE_SUCCESS operation success + * @return #TEE_ERROR_BAD_PARAMETERS If any of the parameters is NULL + */ +void TEE_BigIntDiv(TEE_BigInt *dest_q, TEE_BigInt *dest_r, const TEE_BigInt *op1, const TEE_BigInt *op2); + +/* + * computes dest = op (mod n) such that 0 <= dest < n. + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result op (mod n) + * @param op [IN] Pointer to the operand to be reduced mod n + * @param n [IN] Pointer to the modulus. Modulus SHALL be larger than 1. + * + * @return void + */ +void TEE_BigIntMod(TEE_BigInt *dest, const TEE_BigInt *op, const TEE_BigInt *n); + +/* + * computes dest = (op1 + op2) (mod n). + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result (op1 + op2)(mod n) + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * @param n [IN] Pointer to the modulus. Modulus SHALL be larger than 1 + * + * @return void + */ +void TEE_BigIntAddMod(TEE_BigInt *dest, const TEE_BigInt *op1, const TEE_BigInt *op2, const TEE_BigInt *n); + +/* + * computes dest = (op1 - op2) (mod n). + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result (op1 - op2)(mod n) + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * @param n [IN] Pointer to the modulus. Modulus SHALL be larger than 1 + * + * @return void + */ +void TEE_BigIntSubMod(TEE_BigInt *dest, const TEE_BigInt *op1, const TEE_BigInt *op2, const TEE_BigInt *n); + +/* + * computes dest = (op1 * op2) (mod n). + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result (op1 * op2)(mod n) + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * @param n [IN] Pointer to the modulus. Modulus SHALL be larger than 1 + * + * @return void + */ +void TEE_BigIntMulMod(TEE_BigInt *dest, const TEE_BigInt *op1, const TEE_BigInt *op2, const TEE_BigInt *n); + +/* + * computes dest = (op * op) (mod n). + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result (op * op)(mod n) + * @param op1 [IN] Pointer to the operand + * @param n [IN] Pointer to the modulus. Modulus SHALL be larger than 1 + * + * @return void + */ +void TEE_BigIntSquareMod(TEE_BigInt *dest, const TEE_BigInt *op, const TEE_BigInt *n); + +/* + * computes dest such that dest * op = 1 (mod n). + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result (op^-1)(mod n) + * @param op1 [IN] Pointer to the operand + * @param n [IN] Pointer to the modulus. Modulus SHALL be larger than 1 + * + * @return void + */ +void TEE_BigIntInvMod(TEE_BigInt *dest, const TEE_BigInt *op, const TEE_BigInt *n); + +/* + * determines whether gcd(op1, op2) == 1. + * + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * + * @return true if gcd(op1, op2) == 1 + * @return fast otherwise + */ +bool TEE_BigIntRelativePrime(const TEE_BigInt *op1, const TEE_BigInt *op2); + +/* + * computes the greatest common divisor of the input parameters op1 and op2. + * + * @param gcd [OUT] Pointer to TEE_BigInt to hold the greatest common divisor of op1 and op2 + * @param u [OUT] Pointer to TEE_BigInt to hold the first coefficient + * @param v [OUT] Pointer to TEE_BigInt to hold the second coefficient + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * + * @return void + */ +void TEE_BigIntComputeExtendedGcd(TEE_BigInt *gcd, TEE_BigInt *u, TEE_BigInt *v, const TEE_BigInt *op1, + const TEE_BigInt *op2); +/* + * performs a probabilistic primality test on op + * + * @param op [IN] Candidate number that is tested for primality + * @param confidenceLevel [IN] The desired confidence level for a non-conclusive test + * + * @return 0 If op is a composite number + * @return 1 If op is guaranteed to be prime + * @return -1 If the test is non-conclusive but the probability that op is composite is less than 2^(-confidenceLevel) + */ +int32_t TEE_BigIntIsProbablePrime(const TEE_BigInt *op, uint32_t confidenceLevel); + +/* + * converts src into a representation suitable for doing fast modular multiplicatio + * + * @param dest [OUT] Pointer to an initialized TEE_BigIntFMM memory area + * @param src [IN] Pointer to the TEE_BigInt to convert + * @param n [IN] Pointer to the modulus + * @param context [IN] Pointer to a context previously initialized using TEE_BigIntInitFMMContext1 + * + * @return void + */ +void TEE_BigIntConvertToFMM(TEE_BigIntFMM *dest, const TEE_BigInt *src, const TEE_BigInt *n, + const TEE_BigIntFMMContext *context); + +/* + * converts src in the fast modular multiplication representation back to a TEE_BigInt representation + * + * @param dest [OUT] Pointer to an initialized TEE_BigIntFMM memory area to hold the converted result + * @param src [IN] Pointer to a TEE_BigIntFMM holding the value in the fast modular multiplication representation + * @param n [IN] Pointer to the modulus + * @param context [IN] Pointer to a context previously initialized using TEE_BigIntInitFMMContext1 + * + * @return void + */ +void TEE_BigIntConvertFromFMM(TEE_BigInt *dest, const TEE_BigIntFMM *src, const TEE_BigInt *n, + const TEE_BigIntFMMContext *context); + +/* + * calculates dest = op1 * op2 in the fast modular multiplication representation + * + * @param dest [OUT] Pointer to TEE_BigIntFMM to hold the result op1 * op2 + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * @param n [IN] Pointer to the modulus + * @param context [IN] Pointer to a context previously initialized using TEE_BigIntInitFMMContext1 + * + * @return void + */ +void TEE_BigIntComputeFMM(TEE_BigIntFMM *dest, const TEE_BigIntFMM *op1, const TEE_BigIntFMM *op2, const TEE_BigInt *n, + const TEE_BigIntFMMContext *context); + +#if (API_LEVEL >= API_LEVEL1_1_1) +/* + * computes dest = (op1 ^ op2) (mod n). + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result (op1 ^ op2)(mod n) + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * @param n [IN] Pointer to the modulus + * @param context [IN] Pointer to a context previously initialized using TEE_BigIntInitFMMContext1 or NULL + * + * @return #TEE_SUCCESS success + * @return #TEE_ERROR_NOT_SUPPORTED If the value of n is not supported + */ +TEE_Result TEE_BigIntExpMod(TEE_BigInt *des, TEE_BigInt *op1, const TEE_BigInt *op2, const TEE_BigInt *n, + TEE_BigIntFMMContext *context); +#endif // API_LEVEL + +/* + * check whether n exists to make dest = (op1 ^ op2) (mod n). + * + * @param dest [OUT] Pointer to TEE_BigInt to hold the result (op1 ^ op2)(mod n) + * @param op1 [IN] Pointer to the first operand + * @param op2 [IN] Pointer to the second operand + * @param n [IN] Pointer to the modulus + * @param context [IN] Pointer to a context previously initialized using TEE_BigIntInitFMMContext1 or NULL + * + * @return true If the value of n is supported + * @return false If the value of n is not supported + */ +bool EXT_TEE_BigIntExpMod(TEE_BigInt *out, TEE_BigInt *in, const TEE_BigInt *exp, const TEE_BigInt *n); +#endif diff --git a/include/TA/tee_core_api.h b/include/TA/tee_core_api.h new file mode 100644 index 0000000..babbac1 --- /dev/null +++ b/include/TA/tee_core_api.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: Hanpeng + * Create: 2018-12-13 + * Description: tee core api definitions + */ +#ifndef __TEE_CORE_API_H +#define __TEE_CORE_API_H + +#include "tee_defines.h" +#ifndef _TEE_TA_SESSION_HANDLE +#define _TEE_TA_SESSION_HANDLE +typedef uint32_t TEE_TASessionHandle; +#endif + +/* + * Raises a Panic in the Trusted Application instance + * + * @param panicCode [IN] informative panic code defined by the TA + * + * @return void + */ +void TEE_Panic(TEE_Result panicCode); + +/* + * opens a new session with a Trusted Application + * + * @param destination [IN] A pointer to a TEE_UUID structure containing the UUID of the destination Trusted + * Application + * @param cancellationRequestTimeout [IN] Timeout in milliseconds or the special value + * @param paramTypes [IN] The types of all parameters passed in the operation + * @param params [IN] The parameters passed in the operation + * @param session [OUT] A pointer to a variable that will receive the client session handle + * @param returnOrigin[OUT] A pointer to a variable which will contain the return origin + * + * @return TEE_SUCCESS open session successfully + * @return TEE_ERROR_ITEM_NOT_FOUND failed to find target TA in TEE + * @return TEE_ERROR_ACCESS_DENIED access to the destination Trusted Application is denied + */ +TEE_Result TEE_OpenTASession(const TEE_UUID *destination, uint32_t cancellationRequestTimeout, uint32_t paramTypes, + TEE_Param params[TEE_PARAMS_NUM], TEE_TASessionHandle *session, uint32_t *returnOrigin); + +/* + * closes a client session opened by TEE_OpenTASession + * + * @param session [IN] session handle opened by TEE_OpenTASession + * + * @return void + */ +void TEE_CloseTASession(TEE_TASessionHandle session); + +/* + * invokes a command within a session opened between the client Trusted Application instance + * and a destination Trusted Application instance + * + * @param session [IN] An opened session handle + * @param cancellationRequestTimeout [IN] Timeout in milliseconds or the special value + * @param commandID [IN] The identifier of the Command to invoke + * @param paramTypes [IN] The types of all parameters passed in the operation + * @param params [IN] The parameters passed in the operation + * @param returnOrigin [IN] A pointer to a variable which will contain the return origin + * + * @return TEE_SUCCESS invoke operation successfully + * @return TEE_ERROR_ACCESS_DENIED invoke command to target TA is denied + */ +TEE_Result TEE_InvokeTACommand(TEE_TASessionHandle session, uint32_t cancellationRequestTimeout, uint32_t commandID, + uint32_t paramTypes, TEE_Param params[TEE_PARAMS_NUM], uint32_t *returnOrigin); + +/* not supported */ +bool TEE_GetCancellationFlag(void); + +/* not supported */ +bool TEE_UnmaskCancellation(void); + +/* not supported */ +bool TEE_MaskCancellation(void); +#endif diff --git a/include/TA/tee_crypto_api.h b/include/TA/tee_crypto_api.h new file mode 100644 index 0000000..ef4b158 --- /dev/null +++ b/include/TA/tee_crypto_api.h @@ -0,0 +1,724 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: jialingyu + * Create: 2018-12-13 + * Description: tee crypto definitions + */ + +#ifndef TEE_CRYPTO_API_H +#define TEE_CRYPTO_API_H + +#include "pthread.h" // pthread_mutex_t +#include "tee_defines.h" +#include "tee_mem_mgmt_api.h" + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define TEE_MAX_KEY_SIZE_IN_BITS (1024 * 8) + +#define SW_RSA_KEYLEN 1024 +#define TEE_DH_MAX_SIZE_OF_OTHER_INFO 64 /* bytes */ + +enum __TEE_Operation_Constants { + TEE_OPERATION_CIPHER = 0x1, + TEE_OPERATION_MAC = 3, + TEE_OPERATION_AE = 4, + TEE_OPERATION_DIGEST = 5, + TEE_OPERATION_ASYMMETRIC_CIPHER = 6, + TEE_OPERATION_ASYMMETRIC_SIGNATURE = 7, + TEE_OPERATION_KEY_DERIVATION = 8, +}; + +enum __tee_crypto_algorithm_id { + TEE_ALG_INVALID = 0x0, + TEE_ALG_AES_ECB_NOPAD = 0x10000010, + TEE_ALG_AES_CBC_NOPAD = 0x10000110, + TEE_ALG_AES_CTR = 0x10000210, + TEE_ALG_AES_CTS = 0x10000310, + TEE_ALG_AES_XTS = 0x10000410, + TEE_ALG_AES_CBC_MAC_NOPAD = 0x30000110, + TEE_ALG_AES_CBC_MAC_PKCS5 = 0x30000510, + TEE_ALG_AES_CMAC = 0x30000610, + TEE_ALG_AES_GMAC = 0x30000810, + TEE_ALG_AES_CCM = 0x40000710, + TEE_ALG_AES_GCM = 0x40000810, + TEE_ALG_DES_ECB_NOPAD = 0x10000011, + TEE_ALG_DES_CBC_NOPAD = 0x10000111, + TEE_ALG_DES_CBC_MAC_NOPAD = 0x30000111, + TEE_ALG_DES_CBC_MAC_PKCS5 = 0x30000511, + TEE_ALG_DES3_ECB_NOPAD = 0x10000013, + TEE_ALG_DES3_CBC_NOPAD = 0x10000113, + TEE_ALG_DES3_CBC_MAC_NOPAD = 0x30000113, + TEE_ALG_DES3_CBC_MAC_PKCS5 = 0x30000513, + TEE_ALG_RSASSA_PKCS1_V1_5_MD5 = 0x70001830, + TEE_ALG_RSASSA_PKCS1_V1_5_SHA1 = 0x70002830, + TEE_ALG_RSASSA_PKCS1_V1_5_SHA224 = 0x70003830, + TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 = 0x70004830, + TEE_ALG_RSASSA_PKCS1_V1_5_SHA384 = 0x70005830, + TEE_ALG_RSASSA_PKCS1_V1_5_SHA512 = 0x70006830, + TEE_ALG_RSASSA_PKCS1_PSS_MGF1_MD5 = 0x70111930, + TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1 = 0x70212930, + TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224 = 0x70313930, + TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256 = 0x70414930, + TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384 = 0x70515930, + TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512 = 0x70616930, + TEE_ALG_RSAES_PKCS1_V1_5 = 0x60000130, + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1 = 0x60210230, +#ifdef GP_SUPPORT + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224 = 0x60310230, + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256 = 0x60410230, + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384 = 0x60510230, + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 = 0x60610230, +#else + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224 = 0x60211230, + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256 = 0x60212230, + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384 = 0x60213230, + TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 = 0x60214230, +#endif + TEE_ALG_RSA_NOPAD = 0x60000030, + TEE_ALG_DSA_SHA1 = 0x70002131, + TEE_ALG_DSA_SHA224 = 0x70003131, + TEE_ALG_DSA_SHA256 = 0x70004131, + TEE_ALG_DH_DERIVE_SHARED_SECRET = 0x80000032, + TEE_ALG_MD5 = 0x50000001, + TEE_ALG_SHA1 = 0x50000002, + TEE_ALG_SHA224 = 0x50000003, + TEE_ALG_SHA256 = 0x50000004, + TEE_ALG_SHA384 = 0x50000005, + TEE_ALG_SHA512 = 0x50000006, + TEE_ALG_HMAC_MD5 = 0x30000001, + TEE_ALG_HMAC_SHA1 = 0x30000002, + TEE_ALG_HMAC_SHA224 = 0x30000003, + TEE_ALG_HMAC_SHA256 = 0x30000004, + TEE_ALG_HMAC_SHA384 = 0x30000005, + TEE_ALG_HMAC_SHA512 = 0x30000006, + TEE_ALG_HMAC_SM3 = 0x30000007, + TEE_ALG_AES_ECB_PKCS5 = 0x10000020, + TEE_ALG_AES_CBC_PKCS5 = 0x10000220, + TEE_ALG_ECDSA_SHA1 = 0x70001042, + TEE_ALG_ECDSA_SHA224 = 0x70002042, + TEE_ALG_ECDSA_SHA256 = 0x70003042, + TEE_ALG_ECDSA_SHA384 = 0x70004042, + TEE_ALG_ECDSA_SHA512 = 0x70005042, + TEE_ALG_ED25519 = 0x70005043, + TEE_ALG_ECDH_DERIVE_SHARED_SECRET = 0x80000042, + TEE_ALG_X25519 = 0x80000044, + TEE_ALG_ECC = 0x80000001, + TEE_ALG_ECDSA_P192 = 0x70001042, + TEE_ALG_ECDSA_P224 = 0x70002042, + TEE_ALG_ECDSA_P256 = 0x70003042, + TEE_ALG_ECDSA_P384 = 0x70004042, + TEE_ALG_ECDSA_P521 = 0x70005042, + TEE_ALG_ECDH_P192 = 0x80001042, + TEE_ALG_ECDH_P224 = 0x80002042, + TEE_ALG_ECDH_P256 = 0x80003042, + TEE_ALG_ECDH_P384 = 0x80004042, + TEE_ALG_ECDH_P521 = 0x80005042, + TEE_ALG_SM2_DSA_SM3 = 0x70006045, + TEE_ALG_SM2_PKE = 0x80000045, + TEE_ALG_SM3 = 0x50000007, + TEE_ALG_SM4_ECB_NOPAD = 0x10000014, + TEE_ALG_SM4_CBC_NOPAD = 0x10000114, + TEE_ALG_SM4_CTR = 0x10000214, + TEE_ALG_SM4_XTS = 0x10000414, + TEE_ALG_SM4_OFB = 0x10000514, + TEE_ALG_AES_OFB = 0x10000510, +}; + +typedef enum __tee_crypto_algorithm_id tee_crypto_algorithm_id; + +#define TEE_OPTIONAL_ELEMENT_NONE 0x00000000 + +typedef enum { + TEE_ECC_CURVE_NIST_P192 = 0x00000001, + TEE_ECC_CURVE_NIST_P224 = 0x00000002, + TEE_ECC_CURVE_NIST_P256 = 0x00000003, + TEE_ECC_CURVE_NIST_P384 = 0x00000004, + TEE_ECC_CURVE_NIST_P521 = 0x00000005, + TEE_ECC_CURVE_SM2 = 0x00000300, /* CURVE_SM2 256 bits */ + TEE_ECC_CURVE_25519 = 0x00000200, /* CURVE_25519 256 bits */ +} TEE_ECC_CURVE; + +typedef enum { + TEE_DH_HASH_SHA1_mode = 0, + TEE_DH_HASH_SHA224_mode = 1, + TEE_DH_HASH_SHA256_mode = 2, + TEE_DH_HASH_SHA384_mode = 3, + TEE_DH_HASH_SHA512_mode = 4, + TEE_DH_HASH_NumOfModes, +} TEE_DH_HASH_Mode; + +typedef enum { + TEE_DH_PKCS3_mode = 0, /* PKCS3 */ + TEE_DH_ANSI_X942_mode = 1, /* X942 */ + TEE_DH_NumOfModes, /* num of modes */ +} TEE_DH_OpMode_t; + +typedef enum { + TEE_DH_ASN1_DerivMode = 0, /* *< ASN1_DerivMode */ + TEE_DH_ConcatDerivMode = 1, /* *< ConcatDerivMode */ + TEE_DH_X963_DerivMode = TEE_DH_ConcatDerivMode, /* *< X963_DerivMode */ + TEE_DH_OMADRM_DerivMode = 2, /* *< OMADRM_DerivMode */ + TEE_DH_ISO18033_KDF1_DerivMode = 3, /* *< ISO18033_KDF1_DerivMode */ + TEE_DH_ISO18033_KDF2_DerivMode = 4, /* *< ISO18033_KDF2_DerivMode */ + TEE_DH_DerivFunc_NumOfModes, /* *< num of modes */ +} TEE_DH_DerivFuncMode; + +enum __TEE_DK_ObjectAttribute { + TEE_DK_SECRECT = 0, /* A pointer to shared secret value */ + TEE_DK_OTHER, /* A pointer to structure containing other data */ + TEE_DK_HASH_MODE, /* The enumerator ID of the HASH function to be used */ + TEE_DK_DERIVATION_MODE /* The enumerator ID of the derivation function mode */ +}; + +typedef enum __TEE_DK_ObjectAttribute tee_dk_objectattribute; + +enum __TEE_OperationMode { + TEE_MODE_ENCRYPT = 0x0, + TEE_MODE_DECRYPT, + TEE_MODE_SIGN, + TEE_MODE_VERIFY, + TEE_MODE_MAC, + TEE_MODE_DIGEST, + TEE_MODE_DERIVE +}; + +enum tee_operation_state { + TEE_OPERATION_STATE_INITIAL = 0x00000000, + TEE_OPERATION_STATE_ACTIVE = 0x00000001, +}; + +typedef uint32_t TEE_OperationMode; + +typedef struct { + uint8_t algorithm_id[TEE_DH_MAX_SIZE_OF_OTHER_INFO]; /* object ID(OID) */ + uint32_t size_of_algorithm_id; /* length of AlgorithmID */ + uint8_t party_u_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO]; /* public info of sender */ + uint32_t size_of_party_u_info; /* length of PartyUInfo */ + uint8_t party_v_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO]; /* public info of receiver */ + uint32_t size_of_party_v_info; /* length of PartyVInfo */ + uint8_t supp_priv_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO]; /* shared private info */ + uint32_t size_of_supp_priv_info; /* length of SuppPrivInfo */ + uint8_t supp_pub_info[TEE_DH_MAX_SIZE_OF_OTHER_INFO]; /* shared public info */ + uint32_t size_of_supp_pub_info; /* length of SuppPubInfo */ +} TEE_DH_OtherInfo; + +struct __TEE_OperationInfo { + uint32_t algorithm; /* #__TEE_CRYPTO_ALGORITHM_ID */ + uint32_t operationClass; /* #__TEE_Operation_Constants */ + uint32_t mode; /* #__TEE_OperationMode */ + uint32_t digestLength; + uint32_t maxKeySize; + uint32_t keySize; + uint32_t requiredKeyUsage; + uint32_t handleState; + void *keyValue; +}; + +typedef struct __TEE_OperationInfo TEE_OperationInfo; + +typedef struct { + uint32_t keySize; + uint32_t requiredKeyUsage; +} TEE_OperationInfoKey; + +typedef struct { + uint32_t algorithm; + uint32_t operationClass; + uint32_t mode; + uint32_t digestLength; + uint32_t maxKeySize; + uint32_t handleState; + uint32_t operationState; + uint32_t numberOfKeys; + TEE_OperationInfoKey keyInformation[]; +} TEE_OperationInfoMultiple; + +struct __TEE_OperationHandle { + uint32_t algorithm; /* *< #__TEE_CRYPTO_ALGORITHM_ID */ + uint32_t operationClass; /* *< #__TEE_Operation_Constants */ + uint32_t mode; /* *< #__TEE_OperationMode */ + uint32_t digestLength; + uint32_t maxKeySize; + uint32_t keySize; + uint32_t keySize2; + uint32_t requiredKeyUsage; + uint32_t handleState; + void *keyValue; + void *keyValue2; + void *crypto_ctxt; + void *hmac_rest_ctext; + void *IV; + void *publicKey; + uint32_t publicKeyLen; + void *privateKey; + uint32_t privateKeyLen; + uint32_t IVLen; + // start of DH + TEE_DH_OtherInfo *dh_otherinfo; /* #TEE_DH_OtherInfo */ + uint32_t dh_hash_mode; /* #TEE_DH_HASH_Mode */ + uint32_t dh_derive_func; /* #TEE_DH_DerivFuncMode */ + uint32_t dh_op_mode; /* #TEE_DH_OpMode_t */ + // end of DH + pthread_mutex_t operation_lock; + void *hal_info; +}; +typedef struct { + uint32_t src; + uint32_t dest; +} crypto_uint2uint; + +#define RSA_PUBKEY_MAXSIZE sizeof(CRYS_RSAUserPubKey_t) + +#define RSA_PRIVKEY_MAXSIZE sizeof(CRYS_RSAUserPrivKey_t) + +typedef struct { + void *src_data; + size_t src_len; + void *dest_data; + size_t *dest_len; +} operation_src_dest; + +typedef struct { + void *nonce; + size_t nonce_len; + uint32_t tag_len; + size_t aad_len; + size_t payload_len; +} operation_ae_init; + +typedef struct __TEE_OperationHandle *TEE_OperationHandle; + +typedef struct __TEE_OperationHandle TEE_OperationHandleVar; + +typedef struct __TEE_ObjectHandle TEE_ObjectHandleVar; + +/* + * alloc operation handle + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param algorithm [IN] #TEE_CRYPTO_ALGORITHM_ID + * @param mode [IN] #TEE_OperationMode + * @param maxKeySize [IN] The max key size + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_OUT_OF_MEMORY #TEE_OperationHandle malloc failed + * @return TEE_ERROR_NOT_SUPPORTE #TEE_CRYPTO_ALGORITHM_ID not support + * @return TEE_ERROR_GENERIC other failed + */ +TEE_Result TEE_AllocateOperation(TEE_OperationHandle *operation, uint32_t algorithm, uint32_t mode, + uint32_t maxKeySize); +/* + * free Operation handle + * + * @param operation [IN/OUT] operation handle + * + * @return void + */ +void TEE_FreeOperation(TEE_OperationHandle operation); + +/* + * get Operation Info + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param operationInfo [IN/OUT] #TEE_OperationInfo + * + * @return void + */ +void TEE_GetOperationInfo(const TEE_OperationHandle operation, TEE_OperationInfo *operationInfo); + +/* + * reset operation handle + * + * @param operation [IN/OUT] #TEE_OperationHandle + * + * @return void + */ +void TEE_ResetOperation(TEE_OperationHandle operation); + +/* + * set operation key + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param key [IN/OUT] #TEE_ObjectHandle + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_OUT_OF_MEMORY malloc key buffer failed + */ +TEE_Result TEE_SetOperationKey(TEE_OperationHandle operation, const TEE_ObjectHandle key); + +/* + * set operation key1 and key2 + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param key1 [IN/OUT] #TEE_ObjectHandle + * @param key2 [IN/OUT] #TEE_ObjectHandle + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + */ +TEE_Result TEE_SetOperationKey2(TEE_OperationHandle operation, const TEE_ObjectHandle key1, + const TEE_ObjectHandle key2); +/* + * copy src operation to dest operation + * + * @param dstOperation [IN/OUT] #TEE_OperationHandle + * @param srcOperation [IN/OUT] #TEE_OperationHandle + * + * @return void + */ +void TEE_CopyOperation(TEE_OperationHandle dstOperation, const TEE_OperationHandle srcOperation); + +/* + * init cipher context + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param IV [IN] the iv buffer, set NULL if not use + * @param IVLen [IN] the length of iv buffer + * + * @return void + */ +void TEE_CipherInit(TEE_OperationHandle operation, const void *IV, size_t IVLen); + +/* + * do cipher update + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param srcData [IN] the src data + * @param srcLen [IN] the length of src data + * @param destData [OUT] the dest data + * @param destLen [OUT] the length of dest data + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_CipherUpdate(TEE_OperationHandle operation, const void *srcData, size_t srcLen, void *destData, + size_t *destLen); +/* + * do cipher finish + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param srcData [IN] the src data + * @param srcLen [IN] the length of src data + * @param destData [OUT] the dest data + * @param destLen [OUT] the length of dest data + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_CipherDoFinal(TEE_OperationHandle operation, const void *srcData, size_t srcLen, void *destData, + size_t *destLen); +/* + * do digest update + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param chunk [IN] the chunk buffer + * @param chunkSize [IN] the length of chunk buffer + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_GENERIC other error + */ +#ifndef GP_SUPPORT + +#if (API_LEVEL >= 2) +void TEE_DigestUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize); +#else +TEE_Result TEE_DigestUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize); +#endif // API_LEVEL + +#else +void TEE_DigestUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize); +#endif + +/* + * do digest finish + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param chunk [IN] the chunk buffer + * @param chunkSize [IN] the length of chunk buffer + * @param hash [OUT] the hash buffer + * @param hashLen [OUT] the length of hash buffer + * + * @return #TEE_SUCCESS success + * @return #TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_DigestDoFinal(TEE_OperationHandle operation, const void *chunk, size_t chunkLen, void *hash, + size_t *hashLen); + +/* + * do mac init + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param IV [IN] the iv buffer, set NULL if not use + * @param IVLen [IN] the length of iv buffer + * + * @return void + */ +void TEE_MACInit(TEE_OperationHandle operation, void *IV, size_t IVLen); + +/* + * do mac update + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param chunk [IN] the chunk buffer + * @param chunkSize [IN] the length of chunk buffer + * + * @return void + */ +void TEE_MACUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize); + +/* + * do mac finish + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param message [IN] the message buffer + * @param messageLen [IN] the length of message buffer + * @param mac [OUT] the mac buffer + * @param macLen [OUT] the length of mac buffer + * + * @return #TEE_SUCCESS success + * @return #TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_MACComputeFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, void *mac, + size_t *macLen); +/* + * do mac finish and compare + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param message [IN] the message buffer + * @param messageLen [IN] the length of message buffer + * @param mac [OUT] the mac buffer + * @param macLen [OUT] the length of mac buffer + * + * @return #TEE_SUCCESS success + * @return #TEE_ERROR_GENERIC other error + * @return #TEE_ERROR_MAC_INVALID compare failed + */ +#ifndef GP_SUPPORT + +#if (API_LEVEL >= 2) +TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, const void *mac, + const size_t macLen); +#else +TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, const void *mac, + const size_t *macLen); +#endif // API_LEVEL + +#else +TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, const void *mac, + const size_t macLen); +#endif + +/* + * do derive key + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param params [IN] #TEE_Attribute + * @param paramCount [IN] the count of param + * @param derivedKey [OUT] #TEE_ObjectHandle + * + * @return void + */ +void TEE_DeriveKey(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, + TEE_ObjectHandle derivedKey); +/* + * generate random data + * + * @param randomBuffer [IN/OUT] the random buffer + * @param randomBufferLen [IN] the length of random buffer + * + * @return void + */ +void TEE_GenerateRandom(void *randomBuffer, size_t randomBufferLen); + +/* + * do ae init + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param nonce [IN] the nounce buffer + * @param nonceLen [IN] the length of nounce + * @param tagLen [IN] the length of tag + * @param AADLen [IN] the length of aad + * @param payloadLen [IN] the length of payload + * + * @return #TEE_SUCCESS success + * @return #TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_AEInit(TEE_OperationHandle operation, void *nonce, size_t nonceLen, uint32_t tagLen, size_t AADLen, + size_t payloadLen); +/* + * update ae aad + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param AADdata [IN] the aad buffer + * @param AADdataLen [IN] the length of aad buffer + * + * @return void + */ +void TEE_AEUpdateAAD(TEE_OperationHandle operation, const void *AADdata, size_t AADdataLen); + +/* + * do ae update + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param srcData [IN] the src data + * @param srcLen [IN] the length of src data + * @param destData [OUT] the dest data + * @param destLen [OUT] the length of dest data + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_AEUpdate(TEE_OperationHandle operation, void *srcData, size_t srcLen, void *destData, size_t *destLen); + +/* + * do ae encrypt + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param srcData [IN] the src data + * @param srcLen [IN] the length of src data + * @param destData [OUT] the dest data + * @param destLen [OUT] the length of dest data + * @param tag [OUT] the tag buffer + * @param tagLen [OUT] the length of tag buffer + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_AEEncryptFinal(TEE_OperationHandle operation, void *srcData, size_t srcLen, void *destData, + size_t *destLen, void *tag, size_t *tagLen); +/* + * do ae decrypt + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param srcData [IN] the src data + * @param srcLen [IN] the length of src data + * @param destData [OUT] the dest data + * @param destLen [OUT] the length of dest data + * @param tag [OUT] the tag buffer + * @param tagLen [OUT] the length of tag buffer + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_MAC_INVALID the tag is invalid + */ +TEE_Result TEE_AEDecryptFinal(TEE_OperationHandle operation, void *srcData, size_t srcLen, void *destData, + size_t *destLen, void *tag, size_t tagLen); + +/* + * do asymmetric encrypt + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param params [IN] #TEE_Attribute + * @param paramCount [IN] the count of params + * @param srcData [IN] the src data + * @param srcLen [IN] the length of src data + * @param destData [OUT] the dest data + * @param destLen [OUT] the length of dest data + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_AsymmetricEncrypt(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, + void *srcData, size_t srcLen, void *destData, size_t *destLen); + +/* + * do asymmetric decrypt + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param params [IN] #TEE_Attribute + * @param paramCount [IN] the count of params + * @param srcData [IN] the src data + * @param srcLen [IN] the length of src data + * @param destData [OUT] the dest data + * @param destLen [OUT] the length of dest data + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_GENERIC other error + * + */ +TEE_Result TEE_AsymmetricDecrypt(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, + void *srcData, size_t srcLen, void *destData, size_t *destLen); + +/* + * do asymmetric sign + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param params [IN] #TEE_Attribute + * @param paramCount [IN] the count of params + * @param digest [IN] the digest data + * @param digestLen [IN] the length of digest data + * @param signature [OUT] the signature data + * @param signatureLen [OUT] the length of signature data + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_AsymmetricSignDigest(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, + void *digest, size_t digestLen, void *signature, size_t *signatureLen); + +/* + * do asymmetric verify + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param params [IN] #TEE_Attribute + * @param paramCount [IN] the count of params + * @param digest [IN] the digest data + * @param digestLen [IN] the length of digest data + * @param signature [OUT] the signature data + * @param signatureLen [OUT] the length of signature data + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_GENERIC other error + */ +TEE_Result TEE_AsymmetricVerifyDigest(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, + void *digest, size_t digestLen, void *signature, size_t signatureLen); + +#if (API_LEVEL >= 2) + +/* + * Get Operation Info multiple + * + * @param operation [IN/OUT] #TEE_OperationHandle + * @param operationInfoMultiple [IN/OUT] #TEE_OperationInfoMultiple + * @param operationSize [IN/OUT] the size of operation handle + * + * @return TEE_SUCCESS succss + * @return TEE_ERROR_BAD_PARAMETERS the params is invalid + * @return TEE_ERROR_SHORT_BUFFER the buffer is not large enough + */ +TEE_Result TEE_GetOperationInfoMultiple(TEE_OperationHandle operation, TEE_OperationInfoMultiple *operationInfoMultiple, + const size_t *operationSize); +#endif // API_LEVEL + +#if (API_LEVEL >= 3) + +/* + * check whether the algorithm is sopported + * + * @param algId [IN] the algorithm + * @param element [IN] the element + * + * @return TEE_SUCCESS support + * @return TEE_ERROR_NOT_SUPPORTED not support + */ +TEE_Result TEE_IsAlgorithmSupported(uint32_t algId, uint32_t element); +#endif // API_LEVEL + +#endif diff --git a/include/TA/tee_defines.h b/include/TA/tee_defines.h new file mode 100755 index 0000000..e2cabe9 --- /dev/null +++ b/include/TA/tee_defines.h @@ -0,0 +1,370 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Description: Reference of TEE internal api and internal definitions + * Author: Hanpeng + * Create: 2018-12-13 + */ + +#ifndef __TEE_DEFINES_H +#define __TEE_DEFINES_H + +#include +#include +#include + +#ifndef TA_EXPORT +#define TA_EXPORT +#endif + +typedef int *tee_mutex_handle; + +#define API_LEVEL1_0 1 +#define API_LEVEL1_1_1 2 +#define API_LEVEL1_2 3 + +#define TEE_PARAMS_NUM 4 +#undef true +#define true 1 + +#undef false +#define false 0 + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define PARAM_NOT_USED(val) ((void)val) + +typedef union { + struct { + void *buffer; + size_t size; + } memref; + struct { + unsigned int a; + unsigned int b; + } value; +} TEE_Param; + +#define TEE_PARAM_TYPES(param0Type, param1Type, param2Type, param3Type) \ + (((param3Type) << 12) | ((param2Type) << 8) | ((param1Type) << 4) | (param0Type)) + +#define TEE_PARAM_TYPE_GET(paramTypes, index) (((paramTypes) >> (4U * (index))) & 0x0F) + +/* + * check validation of parameter types + * + * @param param_to_check [IN] expected parameter values + * @param valid0 [IN] first parameter type + * @param valid1 [IN] second parameter type + * @param valid2 [IN] third parameter type + * @param valid3 [IN] fourth parameter type + * + * @retval true parameter types are correct + * @retval false parameter types are incorrect + */ +static inline bool check_param_type(uint32_t param_to_check, uint32_t valid0, uint32_t valid1, uint32_t valid2, + uint32_t valid3) +{ + return (TEE_PARAM_TYPES(valid0, valid1, valid2, valid3) == param_to_check); +} + +enum TEE_ParamType { + TEE_PARAM_TYPE_NONE = 0x0, + TEE_PARAM_TYPE_VALUE_INPUT = 0x1, + TEE_PARAM_TYPE_VALUE_OUTPUT = 0x2, + TEE_PARAM_TYPE_VALUE_INOUT = 0x3, + TEE_PARAM_TYPE_MEMREF_INPUT = 0x5, + TEE_PARAM_TYPE_MEMREF_OUTPUT = 0x6, + TEE_PARAM_TYPE_MEMREF_INOUT = 0x7, + TEE_PARAM_TYPE_ION_INPUT = 0x8, + TEE_PARAM_TYPE_ION_SGLIST_INPUT = 0x9, +}; + +#define S_VAR_NOT_USED(variable) \ + do { \ + (void)(variable); \ + } while (0); + +typedef struct { + uint32_t objectType; + uint32_t objectSize; + uint32_t maxObjectSize; + uint32_t objectUsage; + uint32_t dataSize; + uint32_t dataPosition; + uint32_t handleFlags; +} TEE_ObjectInfo; + +typedef struct { + uint32_t attributeID; + union { + struct { + void *buffer; + size_t length; + } ref; + struct { + uint32_t a; + uint32_t b; + } value; + } content; +} TEE_Attribute; + +enum TEE_ObjectAttribute { + TEE_ATTR_SECRET_VALUE = 0xC0000000, + TEE_ATTR_RSA_MODULUS = 0xD0000130, + TEE_ATTR_RSA_PUBLIC_EXPONENT = 0xD0000230, + TEE_ATTR_RSA_PRIVATE_EXPONENT = 0xC0000330, + TEE_ATTR_RSA_PRIME1 = 0xC0000430, + TEE_ATTR_RSA_PRIME2 = 0xC0000530, + TEE_ATTR_RSA_EXPONENT1 = 0xC0000630, + TEE_ATTR_RSA_EXPONENT2 = 0xC0000730, + TEE_ATTR_RSA_COEFFICIENT = 0xC0000830, + TEE_ATTR_RSA_MGF1_HASH = 0xF0000830, + TEE_ATTR_DSA_PRIME = 0xD0001031, + TEE_ATTR_DSA_SUBPRIME = 0xD0001131, + TEE_ATTR_DSA_BASE = 0xD0001231, + TEE_ATTR_DSA_PUBLIC_VALUE = 0xD0000131, + TEE_ATTR_DSA_PRIVATE_VALUE = 0xC0000231, + TEE_ATTR_DH_PRIME = 0xD0001032, + TEE_ATTR_DH_SUBPRIME = 0xD0001132, + TEE_ATTR_DH_BASE = 0xD0001232, + TEE_ATTR_DH_X_BITS = 0xF0001332, + TEE_ATTR_DH_PUBLIC_VALUE = 0xD0000132, + TEE_ATTR_DH_PRIVATE_VALUE = 0xC0000232, + TEE_ATTR_RSA_OAEP_LABEL = 0xD0000930, + TEE_ATTR_RSA_PSS_SALT_LENGTH = 0xF0000A30, + TEE_ATTR_ECC_PUBLIC_VALUE_X = 0xD0000141, + TEE_ATTR_ECC_PUBLIC_VALUE_Y = 0xD0000241, + TEE_ATTR_ECC_PRIVATE_VALUE = 0xC0000341, + TEE_ATTR_ECC_CURVE = 0xF0000441, + TEE_ATTR_ED25519_CTX = 0xD0000643, + TEE_ATTR_ED25519_PUBLIC_VALUE = 0xD0000743, + TEE_ATTR_ED25519_PRIVATE_VALUE = 0xC0000843, + TEE_ATTR_ED25519_PH = 0xF0000543, + TEE_ATTR_X25519_PUBLIC_VALUE = 0xD0000944, + TEE_ATTR_X25519_PRIVATE_VALUE = 0xC0000A44, +}; + +enum TEE_ObjectType { + TEE_TYPE_AES = 0xA0000010, + TEE_TYPE_DES = 0xA0000011, + TEE_TYPE_DES3 = 0xA0000013, + TEE_TYPE_HMAC_MD5 = 0xA0000001, + TEE_TYPE_HMAC_SHA1 = 0xA0000002, + TEE_TYPE_HMAC_SHA224 = 0xA0000003, + TEE_TYPE_HMAC_SHA256 = 0xA0000004, + TEE_TYPE_HMAC_SHA384 = 0xA0000005, + TEE_TYPE_HMAC_SHA512 = 0xA0000006, + TEE_TYPE_RSA_PUBLIC_KEY = 0xA0000030, + TEE_TYPE_RSA_KEYPAIR = 0xA1000030, + TEE_TYPE_DSA_PUBLIC_KEY = 0xA0000031, + TEE_TYPE_DSA_KEYPAIR = 0xA1000031, + TEE_TYPE_DH_KEYPAIR = 0xA1000032, + TEE_TYPE_GENERIC_SECRET = 0xA0000000, + TEE_TYPE_DATA = 0xA1000033, + TEE_TYPE_DATA_GP1_1 = 0xA00000BF, + TEE_TYPE_ECDSA_PUBLIC_KEY = 0xA0000041, + TEE_TYPE_ECDSA_KEYPAIR = 0xA1000041, + TEE_TYPE_ECDH_PUBLIC_KEY = 0xA0000042, + TEE_TYPE_ECDH_KEYPAIR = 0xA1000042, + TEE_TYPE_ED25519_PUBLIC_KEY = 0xA0000043, + TEE_TYPE_ED25519_KEYPAIR = 0xA1000043, + TEE_TYPE_X25519_PUBLIC_KEY = 0xA0000044, + TEE_TYPE_X25519_KEYPAIR = 0xA1000044, + TEE_TYPE_SM2_DSA_PUBLIC_KEY = 0xA0000045, + TEE_TYPE_SM2_DSA_KEYPAIR = 0xA1000045, + TEE_TYPE_SM2_KEP_PUBLIC_KEY = 0xA0000046, + TEE_TYPE_SM2_KEP_KEYPAIR = 0xA1000046, + TEE_TYPE_SM2_PKE_PUBLIC_KEY = 0xA0000047, + TEE_TYPE_SM2_PKE_KEYPAIR = 0xA1000047, + TEE_TYPE_HMAC_SM3 = 0xA0000007, + TEE_TYPE_SM4 = 0xA0000014, + + TEE_TYPE_CORRUPTED_OBJECT = 0xA00000BE, +}; + +#define OBJECT_NAME_LEN_MAX 255 + +struct __TEE_ObjectHandle { + void *dataPtr; + uint32_t dataLen; + uint8_t dataName[OBJECT_NAME_LEN_MAX]; + TEE_ObjectInfo *ObjectInfo; + TEE_Attribute *Attribute; + uint32_t attributesLen; + uint32_t CRTMode; + void *infoattrfd; + uint32_t generate_flag; + uint32_t storage_id; +}; +typedef struct __TEE_ObjectHandle *TEE_ObjectHandle; + +#define NODE_LEN 8 +typedef struct tee_uuid { + uint32_t timeLow; + uint16_t timeMid; + uint16_t timeHiAndVersion; + uint8_t clockSeqAndNode[NODE_LEN]; +} TEE_UUID; + +typedef struct spawn_uuid { + uint64_t uuid_valid; + TEE_UUID uuid; +} spawn_uuid_t; + +enum TEE_Result_Value { + TEE_SUCCESS = 0x0, /* success */ + TEE_ERROR_INVALID_CMD, /* command is invalid */ + TEE_ERROR_SERVICE_NOT_EXIST, /* service is not exist */ + TEE_ERROR_SESSION_NOT_EXIST, /* session is not exist */ + TEE_ERROR_SESSION_MAXIMUM, /* exceeds max session count */ + TEE_ERROR_REGISTER_EXIST_SERVICE, /* service already registered */ + TEE_ERROR_TARGET_DEAD_FATAL, /* internal error occurs */ + TEE_ERROR_READ_DATA, /* read data failed */ + TEE_ERROR_WRITE_DATA, /* write data failed */ + TEE_ERROR_TRUNCATE_OBJECT, /* truncate data failed */ + TEE_ERROR_SEEK_DATA, /* seek data failed */ + TEE_ERROR_SYNC_DATA, /* sync data failed */ + TEE_ERROR_RENAME_OBJECT, /* rename file failed */ + TEE_ERROR_TRUSTED_APP_LOAD_ERROR, /* error occurs when loading TA */ + TEE_ERROR_OTRP_LOAD_NOT_MATCHED = 0x80000100, /* TA type is inconsistent with the loading mode. */ + TEE_ERROR_OTRP_LOAD_EXCEED = 0x80000101, /* the not open session's otrp service num exceeds */ + TEE_ERROR_OTRP_ACCESS_DENIED = 0x80000102, /* uuid of load cmd is not inconsistent with the sec file */ + TEE_ERROR_OTRP_SERVICE_AGED = 0x80000103, /* otrp service is aged */ + TEE_ERROR_STORAGE_EIO = 0x80001001, /* I/O error occurs in storage operation */ + TEE_ERROR_STORAGE_EAGAIN = 0x80001002, /* storage section is unavailable */ + TEE_ERROR_STORAGE_ENOTDIR = 0x80001003, /* operation target is not directory */ + TEE_ERROR_STORAGE_EISDIR = 0x80001004, /* cannot do this operation on directory */ + TEE_ERROR_STORAGE_ENFILE = 0x80001005, /* opened files exceed max count in system */ + TEE_ERROR_STORAGE_EMFILE = 0x80001006, /* opened files exceed max count for this process */ + TEE_ERROR_STORAGE_EROFS = 0x80001007, /* stroage section is read only */ + TEE_ERROR_STORAGE_INSE_NOTSUPPORT = 0x80001008, /* SFS inse mode is not supported */ + TEE_ERROR_STORAGE_INSE_ERROR = 0x80001009, /* SFS inse encrypto/decrypto error occurs */ + TEE_ERROR_STORAGE_PATH_WRONG = 0x8000100A, /* File path error */ + TEE_ERROR_MSG_QUEUE_OVERFLOW = 0x8000100B, /* sevice msg queue overflow */ + TEE_ERROR_CORRUPT_OBJECT = 0xF0100001, /* file object has been damaged */ + TEE_ERROR_STORAGE_NOT_AVAILABLE = 0xF0100003, /* storage section is unavailable */ + TEE_ERROR_CIPHERTEXT_INVALID = 0xF0100006, /* cipher text is incorrect */ + TEE_ISOCKET_ERROR_PROTOCOL = 0xF1007001, /* protocol error in socket connection */ + TEE_ISOCKET_ERROR_REMOTE_CLOSED = 0xF1007002, /* socket is closed by remote */ + TEE_ISOCKET_ERROR_TIMEOUT = 0xF1007003, /* socket connection is timeout */ + TEE_ISOCKET_ERROR_OUT_OF_RESOURCES = 0xF1007004, /* no resource avaliable for socket connection */ + TEE_ISOCKET_ERROR_LARGE_BUFFER = 0xF1007005, /* buffer is too large in socket connection */ + TEE_ISOCKET_WARNING_PROTOCOL = 0xF1007006, /* warnning occurs in socket connection */ + TEE_ERROR_GENERIC = 0xFFFF0000, /* generic error */ + TEE_ERROR_ACCESS_DENIED = 0xFFFF0001, /* access is denied */ + TEE_ERROR_CANCEL = 0xFFFF0002, /* operation has been canceled */ + TEE_ERROR_ACCESS_CONFLICT = 0xFFFF0003, /* conflict access error occurs */ + TEE_ERROR_EXCESS_DATA = 0xFFFF0004, /* exceeds max data size */ + TEE_ERROR_BAD_FORMAT = 0xFFFF0005, /* incorrect data format */ + TEE_ERROR_BAD_PARAMETERS = 0xFFFF0006, /* incorrect parameters */ + TEE_ERROR_BAD_STATE = 0xFFFF0007, /* operation is not allowed in current state */ + TEE_ERROR_ITEM_NOT_FOUND = 0xFFFF0008, /* cannot find target item */ + TEE_ERROR_NOT_IMPLEMENTED = 0xFFFF0009, /* api is not implemented */ + TEE_ERROR_NOT_SUPPORTED = 0xFFFF000A, /* api is not supported */ + TEE_ERROR_NO_DATA = 0xFFFF000B, /* no data avaliable for this operation */ + TEE_ERROR_OUT_OF_MEMORY = 0xFFFF000C, /* not memory avaliable for this operation */ + TEE_ERROR_BUSY = 0xFFFF000D, /* system busy to handle this operation */ + TEE_ERROR_COMMUNICATION = 0xFFFF000E, /* communication error with target */ + TEE_ERROR_SECURITY = 0xFFFF000F, /* security error occurs */ + TEE_ERROR_SHORT_BUFFER = 0xFFFF0010, /* buffer is too short for this operation */ + TEE_ERROR_EXTERNAL_CANCEL = 0xFFFF0011, /* operation is canceled */ + TEE_PENDING = 0xFFFF2000, /* service is in pending state(in asynchronous state) */ + TEE_PENDING2 = 0xFFFF2001, /* service is in pending state() */ + TEE_PENDING3 = 0xFFFF2002, /* reserved error definition */ + TEE_ERROR_TIMEOUT = 0xFFFF3001, /* operation is timeout */ + TEE_ERROR_OVERFLOW = 0xFFFF300f, /* operation overflow */ + TEE_ERROR_TARGET_DEAD = 0xFFFF3024, /* TA is crashed */ + TEE_ERROR_STORAGE_NO_SPACE = 0xFFFF3041, /* no enough space to store data */ + TEE_ERROR_MAC_INVALID = 0xFFFF3071, /* MAC operation failed */ + TEE_ERROR_SIGNATURE_INVALID = 0xFFFF3072, /* signature check failed */ + TEE_CLIENT_INTR = 0xFFFF4000, /* Interrupted by CFC. Broken control flow is detected. */ + TEE_ERROR_TIME_NOT_SET = 0xFFFF5000, /* time is not set */ + TEE_ERROR_TIME_NEEDS_RESET = 0xFFFF5001, /* time need to be reset */ + TEE_FAIL = 0xFFFF5002, /* system error */ + TEE_ERROR_TIMER = 0xFFFF6000, /* base value of timer error codes */ + TEE_ERROR_TIMER_CREATE_FAILED, /* failed to create timer */ + TEE_ERROR_TIMER_DESTORY_FAILED, /* failed to destory timer */ + TEE_ERROR_TIMER_NOT_FOUND, /* timer not found */ + TEE_ERROR_RPMB_BASE = 0xFFFF7000, /* base value of RPMB error codes */ + TEE_ERROR_RPMB_GENERIC = 0xFFFF7001, /* generic error of RPMB operations */ + TEE_ERROR_RPMB_MAC_FAIL, /* verify MAC failed in RPMB operations */ + TEE_ERROR_RPMB_COUNTER_FAIL, /* invalid counter in RPMB operations */ + TEE_ERROR_RPMB_ADDR_FAIL, /* addresss check failed in RPMB operations */ + TEE_ERROR_RPMB_WRITE_FAIL, /* failed to write data to RPMB */ + TEE_ERROR_RPMB_READ_FAIL, /* failed to read data in RPMB */ + TEE_ERROR_RPMB_KEY_NOT_PROGRAM, /* key is not provisioned in RPMB */ + TEE_ERROR_RPMB_RESP_UNEXPECT_MSGTYPE = 0xFFFF7100, /* incorrect message type in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_BLKCNT, /* incorrect message data block count in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_BLKIDX, /* incorrect message data block index in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_WRCNT, /* incorrect message data counter in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_NONCE, /* incorrect message data nonce in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_MAC, /* incorrect message data MAC in RPMB response */ + TEE_ERROR_RPMB_FILE_NOT_FOUND, /* file not found in RPMB */ + TEE_ERROR_RPMB_NOSPC, /* not space left for RPMB operations */ + TEE_ERROR_RPMB_SPC_CONFLICT, /* exceeds max space of RPMB for this TA */ + TEE_ERROR_RPMB_NOT_AVAILABLE, /* RPMB service not ready */ + TEE_ERROR_RPMB_DAMAGED, /* RPMB partition is damaged */ + TEE_ERROR_TUI_IN_USE = 0xFFFF7110, + TEE_ERROR_TUI_SWITCH_CHANNAL, + TEE_ERROR_TUI_CFG_DRIVER, + TEE_ERROR_TUI_INVALID_EVENT, + TEE_ERROR_TUI_POLL_EVENT, + TEE_ERROR_TUI_CANCELED, + TEE_ERROR_TUI_EXIT, + TEE_ERROR_TUI_NOT_AVAILABLE, + TEE_ERROR_SEC_FLASH_NOT_AVAILABLE, + TEE_ERROR_SESRV_NOT_AVAILABLE, + TEE_ERROR_BIOSRV_NOT_AVAILABLE, + TEE_ERROR_ROTSRV_NOT_AVAILABLE, + TEE_ERROR_ARTSRV_NOT_AVAILABLE, + TEE_ERROR_HSMSRV_NOT_AVAILABLE, + TEE_ERROR_ANTIROOT_RSP_FAIL = 0xFFFF9110, + TEE_ERROR_ANTIROOT_INVOKE_ERROR = 0xFFFF9111, + TEE_ERROR_AUDIT_FAIL = 0xFFFF9112, + TEE_FAIL2 +}; + +/* + * Login type definitions + */ +enum TEE_LoginMethod { + TEE_LOGIN_PUBLIC = 0x0, + TEE_LOGIN_USER, + TEE_LOGIN_GROUP, + TEE_LOGIN_APPLICATION = 0x4, + TEE_LOGIN_USER_APPLICATION = 0x5, + TEE_LOGIN_GROUP_APPLICATION = 0x6, + TEE_LOGIN_IDENTIFY = 0x7, /* iTrustee defined Lognin type */ +}; + +typedef struct { + uint32_t login; + TEE_UUID uuid; +} TEE_Identity; + +typedef uint32_t TEE_Result; +typedef TEE_Result TEEC_Result; + +#define TEE_ORIGIN_TEE 0x00000003 +#define TEE_ORIGIN_TRUSTED_APP 0x00000004 + +#ifndef _TEE_TA_SESSION_HANDLE +#define _TEE_TA_SESSION_HANDLE +typedef uint32_t TEE_TASessionHandle; +#endif + +typedef struct __TEE_ObjectHandle *TEE_ObjectHandle; +typedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle; +typedef struct __TEE_OperationHandle *TEE_OperationHandle; + +#endif diff --git a/include/TA/tee_mem_mgmt_api.h b/include/TA/tee_mem_mgmt_api.h new file mode 100644 index 0000000..d4b0c48 --- /dev/null +++ b/include/TA/tee_mem_mgmt_api.h @@ -0,0 +1,165 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: yaodongdong + * Create: 2012-12-31 + * Description: Header file of memory management api + */ + +#ifndef TEE_MEM_MGMT_API_H +#define TEE_MEM_MGMT_API_H + +#include "tee_defines.h" + +/* + * below definitions are defined by Global Platform or Platform SDK released previously + * for compatibility: + * don't make any change to the content below + */ +#ifndef ZERO_SIZE_PTR +#define ZERO_SIZE_PTR ((void *)16) +#define zero_or_null_ptr(x) ((unsigned long)(x) <= (unsigned long)ZERO_SIZE_PTR) +#endif + +enum MALLOC_HINT { + ZERO = 0, + NOT_ZERO = 1, + ALIGN_004 = 0x80000002, /* buf align */ + ALIGN_008 = 0x80000003, + ALIGN_016 = 0x80000004, + ALIGN_032 = 0x80000005, + ALIGN_064 = 0x80000006, + ALIGN_128 = 0x80000007, + ALIGN_256 = 0x80000008, + ALIGN_004_ZERO = 0x80000012, /* buf align and set to zero */ + ALIGN_008_ZERO = 0x80000013, + ALIGN_016_ZERO = 0x80000014, + ALIGN_032_ZERO = 0x80000015, + ALIGN_064_ZERO = 0x80000016, + ALIGN_128_ZERO = 0x80000017, + ALIGN_256_ZERO = 0x80000018, +}; + +#define TEE_MALLOC_FILL_ZERO 0x00000000 +#define TEE_MALLOC_NO_FILL 0x00000001 +#define TEE_MALLOC_NO_SHARE 0x00000002 + +#define TEE_MEMORY_ACCESS_READ 0x00000001 +#define TEE_MEMORY_ACCESS_WRITE 0x00000002 +#define TEE_MEMORY_ACCESS_ANY_OWNER 0x00000004 + +/* + * fill the first size bytes of buffer with x. + * + * @param buffer [OUT] the pointer of buffer + * @param x [IN] fill value + * @param size [IN] number of bytes + * + * @return void + */ +#if (API_LEVEL >= API_LEVEL1_2) +void TEE_MemFill(void *buffer, uint8_t x, size_t size); +#else +void TEE_MemFill(void *buffer, uint32_t x, size_t size); +#endif + +/* + * copy size bytes from src to dest + * + * @param dest [OUT] dest buffer pointer + * @param src [IN] src buffer pointer + * @param size [IN] number of bytes + * + * @return void + */ +void TEE_MemMove(void *dest, const void *src, size_t size); + +/* + * alloc memory of size bytes with hint value + * The pointer returned will be compatible to any C basic data type + * + * @param size [IN] size of memory that will be allocated + * @param hint [IN] a flag, 0 mean that the memory returned will filled with '\0' + * + * @return a pointer to the new allocated memory + * @return NULL means failed when allocated + */ +void *TEE_Malloc(size_t size, uint32_t hint); + +/* + * release the memory which allocated by TEE_Malloc + * If buffer equals to NULL,TEE_Free will do nothing + * Caller should make sure that the buffer is created by TEE_Malloc or TEE_Realloc + * and should NOT free one memory twice, operation result is unpredictable + * + * @param buffer [IN] pointer to memory + * + * @return none + */ +void TEE_Free(void *buffer); + +/* + * If new size larger than old size, the contents of old memory will not changed, + * the remained memory are random bytes + * There will be a new allocate action when modify the size of memory + * If allocated failed, old memory will be returned and this function will return NULL + * If buffer equals to NULL, this function is same to TEE_Malloc + * + * @param buffer [IN] pointer to memory + * @param new_size [IN] new size + * + * @return pointer to new memory, should NOT be NULL + * @return NULL means failed + */ +void *TEE_Realloc(void *buffer, size_t new_size); + +/* + * compare of memory contents + * + * @param buffer1 [IN] first pointer + * @param buffer2 [IN] second pointer + * @param size [IN] bytes size to be compared + * + * @return -1 buffer1 < buffer2 + * @return 0 buffer1 == buffer2 + * @return 1 buffer1 > buffer2 + */ +int32_t TEE_MemCompare(const void *buffer1, const void *buffer2, size_t size); + +/* + * check the access rights of buffer + * + * @param accessFlags [IN] access rights to be checked + * @param buffer [IN] pointer to memory + * @param size [IN] size of memory to be checked + * + * @return TEE_SUCCESS have access rights + * @return TEE_ERROR_ACCESS_DENIED do NOT have access rights + */ +TEE_Result TEE_CheckMemoryAccessRights(uint32_t accessFlags, const void *buffer, size_t size); + +/* + * A global variable used to share in different Session of same Instance + * + * @param instanceData [IN] Address of the global variable + * + * @return void + */ +void TEE_SetInstanceData(void *instanceData); + +/* + * get the pointer which set by TEE_SetInstanceData + * + * @return a pointer to the variable which set by TEE_SetInstanceData, the pointer should NOT be NULL + * @return NULL no InstanceData is set + */ +void *TEE_GetInstanceData(void); + +#endif diff --git a/include/TA/tee_object_api.h b/include/TA/tee_object_api.h new file mode 100644 index 0000000..76cdc76 --- /dev/null +++ b/include/TA/tee_object_api.h @@ -0,0 +1,290 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: HuangJiankang + * Create: 2018-12-13 + * Description: Reference of TEE object api definitions + */ + +#ifndef __TEE_OBJECT_API_H +#define __TEE_OBJECT_API_H + +#include "tee_defines.h" + +/* + * Definition of HANDLE_NULL, invalid object handle + */ +#define TEE_HANDLE_NULL 0x00000000 + +/* + * The keyUsage of TEE_ObjectHandle determines the usage of the object key + */ +enum Usage_Constants { + TEE_USAGE_EXTRACTABLE = 0x00000001, /* The key of the object can be extracted */ + TEE_USAGE_ENCRYPT = 0x00000002, /* The key of the object can be used for encryption */ + TEE_USAGE_DECRYPT = 0x00000004, /* The key of the object can be used for decryption */ + TEE_USAGE_MAC = 0x00000008, /* The key of the object can be used for hash */ + TEE_USAGE_SIGN = 0x00000010, /* The key of the object can be used for signing */ + TEE_USAGE_VERIFY = 0x00000020, /* The key of the object can be used for verification */ + TEE_USAGE_DERIVE = 0x00000040, /* The key of the object can be used to derive */ + TEE_USAGE_DEFAULT = 0xFFFFFFFF, /* object initialization, all permissions are assigned by default */ +}; + +/* + * The handleFlags of TEE_ObjectHandle indicate some information of the object, + * whether it is a permanent object, whether it is initialized, etc. + */ +enum Handle_Flag_Constants { + TEE_HANDLE_FLAG_PERSISTENT = 0x00010000, /* Persistent object */ + TEE_HANDLE_FLAG_INITIALIZED = 0x00020000, /* Object has been initialized */ + TEE_HANDLE_FLAG_KEY_SET = 0x00040000, /* Unused */ + TEE_HANDLE_FLAG_EXPECT_TWO_KEYS = 0x00080000, /* Unused */ +}; + +/* + * List of attribute identifier flags + */ +#define TEE_ATTR_FLAG_VALUE 0x20000000 +#define TEE_ATTR_FLAG_PUBLIC 0x10000000 + +#define TEE_ATTR_IS_BUFFER(attribute_id) ((((attribute_id) << 2) >> 31) == 0) +#define TEE_ATTR_IS_VALUE(attribute_id) ((((attribute_id) << 2) >> 31) == 1) + +#define TEE_ATTR_IS_PROTECTED(attribute_id) ((((attribute_id) << 3) >> 31) == 0) +#define TEE_ATTR_IS_PUBLIC(attribute_id) ((((attribute_id) << 3) >> 31) == 1) + +/* + * Obtain the TEE_ObjectInfo of the object and copy it to the space pointed + * to by the parameter objectInfo, which is pre-allocated by the user + * + * @param object [IN] Source TEE_ObjectHandle + * @param objectInfo [OUT] Pointer to the structure used to store the TEE_ObjectInfo + * + * @return void + */ +void TEE_GetObjectInfo(TEE_ObjectHandle object, TEE_ObjectInfo *objectInfo); + +/* + * Limit the objectUsage bit of the object. This bit determines the usage of the key in the object. + * The value range is Usage_Constants. For the flag bit of the parameter objectUsage: + * If this bit is set to 1, the use flag of object will not be changed + * If this bit is set to 0, the corresponding object usage flag of the object is cleared + * + * @attention The newly created object will contain all Usage_Constants, + * and the usage flag can only be cleared, not set + * @param object [IN] Need to restrict TEE_ObjectHandle + * @param objectUsage [IN] ObjectUsage users want to change + * + * @return void + */ +void TEE_RestrictObjectUsage(TEE_ObjectHandle object, uint32_t objectUsage); + +/* + * Get the buffer content of the union in the TEE_Attribute structure of the object pointed + * to by TEE_ObjectHandle, and the union member must be ref + * + * @attention The union member in the TEE_Attribute structure must be ref. If the TEE_Attribute is private, + * the Usage_Constants of the object must include TEE_USAGE_EXTRACTABLE + * @param object [IN] The source TEE_ObjectHandle + * @param attributeID [IN] The Attribute ID you want to obtain, such as TEE_ObjectAttribute, can also be customized + * @param buffer [OUT] Pointer, the buffer pointed to is used to store the contents of the obtained buffer + * @param size [INOUT] Pointer, storing content byte length + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_ITEM_NOT_FOUND The TEE_Attribute you are looking for is not found in the object, + * or the object is not initialized + * @return TEE_ERROR_SHORT_BUFFER The provided buffer is too small to store the acquired content + */ +TEE_Result TEE_GetObjectBufferAttribute(TEE_ObjectHandle object, uint32_t attributeID, void *buffer, size_t *size); + +/* + * Get the value of the union in the TEE_Attribute in the object, and the union member must be the value + * + * @attention The member of the union in the TEE_Attribute structure must be value. If the TEE_Attribute is private, + * the Usage_Constants of the object must include TEE_USAGE_EXTRACTABLE + * @param object [IN] The source TEE_ObjectHandle + * @param attributeID [IN] The Attribute ID you want to obtain, such as TEE_ObjectAttribute, can also be customized + * @param a [OUT] Pointer, the space pointed to is used to store a + * @param b [OUT] Pointer, the space pointed to is used to store b + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_ITEM_NOT_FOUND The TEE_Attribute you are looking for is not found in the object, + * or the object is not initialized + * @return TEE_ERROR_ACCESS_DENIED Attempt to obtain a private TEE_Attribute but did not set TEE_USAGE_EXTRACTABLE + */ +TEE_Result TEE_GetObjectValueAttribute(TEE_ObjectHandle object, uint32_t attributeID, uint32_t *a, uint32_t *b); + +/* + * Close the opened TEE_ObjectHandle, the object can be a persistent object or a transient object + * + * @param object [IN] TEE_ObjectHandle to be closed + * + * @return void + */ +void TEE_CloseObject(TEE_ObjectHandle object); + +/* + * Allocate an uninitialized object to store the key, in which objectType and maxObjectSize + * must be specified to pre-allocate + * + * @param objectType [IN] The type of the object to be created, the value can be TEE_ObjectType + * @param maxObjectSize [IN] Maximum bytes of object + * @param object [OUT] Pointer to the handle of the newly created object + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_OUT_OF_MEMORY Not enough to allocate + * @return TEE_ERROR_NOT_SUPPORTED The bytes provided by the object is not supported + */ +TEE_Result TEE_AllocateTransientObject(uint32_t objectType, uint32_t maxObjectSize, TEE_ObjectHandle *object); + +/* + * Release a transient object that has allocated. After the function is called, the handle becomes invalid, + * and all allocated are released. Paired with TEE_AllocateTransientObject + * + * @param object [IN] TEE_ObjectHandle to be released + * + * @return void + */ +void TEE_FreeTransientObject(TEE_ObjectHandle object); + +/* + * Reset the transient object to initial state, that is, the state just after the allocate. + * The uninitialized object that has allocated but has not stored the key can be reused to store the key + * + * @param object [IN] TEE_ObjectHandle to be reset + * + * @return void + */ +void TEE_ResetTransientObject(TEE_ObjectHandle object); + +/* + * This function assigns the attributes in the parameter attrs to an uninitialized transient object, + * and the parameter attrs is provided by the trusted application (TA) + * + * @param object [IN/OUT] TEE_ObjectHandle created but not initialized + * @param attrs [IN] object attribute array, can be one or more TEE_Attribute + * @param attrCount [IN] Number of array members + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_BAD_PARAMETERS The attribute is incorrect or inconsistent. + * Ensure that the object is still uninitialized + */ +TEE_Result TEE_PopulateTransientObject(TEE_ObjectHandle object, TEE_Attribute *attrs, uint32_t attrCount); + +/* + * Initialize a buffer type TEE_Attribute, that is, the member of union in the TEE_Attribute structure must be ref + * + * @param attr [OUT] TEE_Attribute to be initialized + * @param attributeID [IN] ID assigned to TEE_Attribute + * @param buffer [IN] The buffer stores the content to be assigned + * @param length [IN] The byte length of the assignment content + * + * @return void + */ +void TEE_InitRefAttribute(TEE_Attribute *attr, uint32_t attributeID, void *buffer, size_t length); + +/* + * Initialize a value type TEE_Attribute + * + * @param attr [OUT] TEE_Attribute to be initialized + * @param attributeID [IN] ID assigned to TEE_Attribute + * @param a [IN] Assign the value to the member value a of the union in the TEE_Attribute + * @param b [IN] Assign the value to the member value b of the union in the TEE_Attribute + * + * @return void + */ +void TEE_InitValueAttribute(TEE_Attribute *attr, uint32_t attributeID, uint32_t a, uint32_t b); + +/* + * This function uses an initialized object to assign TEE_Attribute to an uninitialized object, + * which is equivalent to copying the TEE_Attribute of srcobject to destobject + * + * @attention The TEE_Attribute type and number of the two objects must match + * @param destObject [IN] The uninitialized TEE_ObjectHandle to be assigned + * @param srcObject [IN] The initialized TEE_ObjectHandle is used to assign a value to another object + * + * @return void + */ +void TEE_CopyObjectAttributes(TEE_ObjectHandle destObject, TEE_ObjectHandle srcObject); + +/* + * This function generates a random key or key-pair and assigns it to the transient object + * + * @param object [IN] Transient object, used to store the generated key + * @param keySize [IN] The bytes of the required key + * @param params [IN] Parameters required for key generation + * @param paramCount [IN] The number of parameters required to generate the key + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_BAD_PARAMETERS The generated key is inconsistent with the key type + * that the transient object can store + */ +TEE_Result TEE_GenerateKey(TEE_ObjectHandle object, uint32_t keySize, TEE_Attribute *params, uint32_t paramCount); + +/* + * Get the information of the object data part, the total length of the data part and the current + * position of the data stream + * + * @param object [IN] TEE_ObjectHandle to be obtained + * @param pos [out] Data stream position + * @param len [IN] Data stream length + * + * @return void + */ +TEE_Result TEE_InfoObjectData(TEE_ObjectHandle object, uint32_t *pos, uint32_t *len); + +#if (API_LEVEL >= 2) + +/* + * Obtain the TEE_ObjectInfo of the object and copy it to the space pointed + * to by the parameter objectInfo, which is pre-allocated by the user + * + * @param object [IN] Source TEE_ObjectHandle + * @param objectInfo [OUT] Pointer to the structure used to store the TEE_ObjectInfo + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_CORRUPT_OBJECT The file is damaged and the file handle will be closed + * @return TEE_ERROR_STORAGE_NOT_AVAILABLE Cannot access the storage area where the file is located + */ +TEE_Result TEE_GetObjectInfo1(TEE_ObjectHandle object, TEE_ObjectInfo *objectInfo); + +/* + * This function uses an initialized object to assign TEE_Attribute to an uninitialized object, + * which is equivalent to copying the TEE_Attribute of srcobject to destobject + * + * @attention The TEE_Attribute type and number of the two objects must match + * @param destObject [IN] The uninitialized TEE_ObjectHandle to be assigned + * @param srcObject [IN] The initialized TEE_ObjectHandle is used to assign a value to another object + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_CORRUPT_OBJECT The file is damaged and the file handle will be closed + * @return TEE_ERROR_STORAGE_NOT_AVAILABLE Cannot access the storage area where the file is located + */ +TEE_Result TEE_CopyObjectAttributes1(TEE_ObjectHandle destObject, TEE_ObjectHandle srcObject); + +/* + * Limit the objectUsage bit of the object. This bit determines the usage of the key in the object. + * The value range is Usage_Constants. For the flag bit of the parameter objectUsage: + * If this bit is set to 1, the use flag of object will not be changed + * If this bit is set to 0, the corresponding object usage flag of the object is cleared + * + * @attention The newly created object will contain all Usage_Constants, and the usage flag can + * only be cleared, not set + * @param object [IN] Need to restrict TEE_ObjectHandle + * @param objectUsage [IN] ObjectUsage users want to change + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_CORRUPT_OBJECT The file is damaged and the file handle will be closed + * @return TEE_ERROR_STORAGE_NOT_AVAILABLE Cannot access the storage area where the file is located + */ +TEE_Result TEE_RestrictObjectUsage1(TEE_ObjectHandle object, uint32_t objectUsage); + +#endif /* API_LEVEL */ +#endif diff --git a/include/TA/tee_property_api.h b/include/TA/tee_property_api.h new file mode 100644 index 0000000..523ac36 --- /dev/null +++ b/include/TA/tee_property_api.h @@ -0,0 +1,189 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: huangjiankang + * Create: 2012-01-20 + * Description: TEE property implementation header file + */ + +#ifndef TEE_PROPERTY_API_H +#define TEE_PROPERTY_API_H + +#include "tee_defines.h" + +/* + * below definitions are defined by Global Platform or Platform SDK released previously + * for compatibility: + * don't make any change to the content below + */ +typedef enum { + TEE_PROPSET_UNKNOW = 0, + TEE_PROPSET_TEE_IMPLEMENTATION = 0xFFFFFFFD, + TEE_PROPSET_CURRENT_CLIENT = 0xFFFFFFFE, + TEE_PROPSET_CURRENT_TA = 0xFFFFFFFF, +} Pseudo_PropSetHandle; + +typedef uint32_t TEE_PropSetHandle; + +/* + * performs a lookup in a property set to retrieve an individual + * property and convert its value into a printable string + * + * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator + * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve + * @param valueBuffer [OUT] Output buffer for the property value + * @param valueBufferLen [IN/OUT] Output buffer length + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property + * @return TEE_ERROR_SHORT_BUFFER the value buffer is not large enough to hold the whole property value + */ +TEE_Result TEE_GetPropertyAsString(TEE_PropSetHandle propsetOrEnumerator, const char *name, char *valueBuffer, + size_t *valueBufferLen); + +/* + * retrieves a single property in a property set and converts its value to a Boolean + * + * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator + * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve + * @param value [OUT] A pointer to the variable that will contain the value of the property + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property + */ +TEE_Result TEE_GetPropertyAsBool(TEE_PropSetHandle propsetOrEnumerator, const char *name, bool *value); + +/* + * retrieves a single property in a property set and converts its value to a 32-bit unsigned integer + * + * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator + * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve + * @param value [OUT] A pointer to the variable that will contain the value of the property + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property + */ +TEE_Result TEE_GetPropertyAsU32(TEE_PropSetHandle propsetOrEnumerator, const char *name, uint32_t *value); + +#if (API_LEVEL >= API_LEVEL1_2) +/* + * retrieves a single property in a property set and converts its value to a 64-bit unsigned integer + * + * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator + * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve + * @param value [IN/OUT] A pointer to the variable that will contain the value of the property + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property + */ +TEE_Result TEE_GetPropertyAsU64(TEE_PropSetHandle propsetOrEnumerator, const char *name, uint64_t *value); +#endif // API_LEVEL + +/* + * retrieves an individual property and converts its value into a binary block + * + * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator + * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve + * @param valueBuffer [OUT] Output buffer for the property value + * @param valueBufferLen [IN/OUT] Output buffer length + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property + * @return TEE_ERROR_SHORT_BUFFER the value buffer is not large enough to hold the whole property value + */ +TEE_Result TEE_GetPropertyAsBinaryBlock(TEE_PropSetHandle propsetOrEnumerator, const char *name, void *valueBuffer, + size_t *valueBufferLen); + +/* + * retrieves a single property in a property set and converts its value to TEE_UUID struct + * + * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator + * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve + * @param value [OUT] A pointer to the variable that will contain the value of the property + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property + */ +TEE_Result TEE_GetPropertyAsUUID(TEE_PropSetHandle propsetOrEnumerator, const char *name, TEE_UUID *value); + +/* + * retrieves a single property in a property set and converts its value to TEE_Identity struct + * + * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator + * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve + * @param value [OUT] A pointer to the variable that will contain the value of the property + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property + */ +TEE_Result TEE_GetPropertyAsIdentity(TEE_PropSetHandle propsetOrEnumerator, const char *name, TEE_Identity *value); + +/* + * allocates a property enumerator object + * + * @param enumerator [OUT] A pointer filled with an opaque handle on the property enumerator + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_OUT_OF_MEMORY not enough resources to allocate the property enumerator + */ +TEE_Result TEE_AllocatePropertyEnumerator(TEE_PropSetHandle *enumerator); + +/* + * deallocates a property enumerator object + * + * @param enumerator [IN] A handle on the enumerator to free + * + * @return void + */ +void TEE_FreePropertyEnumerator(TEE_PropSetHandle enumerator); + +/* + * starts to enumerate the properties in an enumerator + * + * @param enumerator [IN] A handle on the enumerator + * @param propSet [IN] A pseudo-handle on the property set to enumerate + * + * @return void + */ +void TEE_StartPropertyEnumerator(TEE_PropSetHandle enumerator, TEE_PropSetHandle propSet); + +/* + * resets a property enumerator to its state immediately after allocation + * + * @param enumerator A handle on the enumerator to reset + * + * @return void + */ +void TEE_ResetPropertyEnumerator(TEE_PropSetHandle enumerator); + +/* + * gets the name of the current property in an enumerator + * + * @param enumerator [IN] A handle on the enumerator + * @param nameBuffer [OUT] The buffer to be filled with the name + * @param nameBufferLen [IN/OUT] The length of buffer to be filled + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND no current property either because the enumerator has not started + * or because it has reached the end of the property set + * @return TEE_ERROR_SHORT_BUFFER If the name buffer is not large enough to contain the property name + */ +TEE_Result TEE_GetPropertyName(TEE_PropSetHandle enumerator, void *nameBuffer, size_t *nameBufferLen); + +/* + * advances the enumerator to the next property + * + * @param enumerator [IN] A handle on the enumerator + * + * @return TEE_SUCCESS operation success + * @return TEE_ERROR_ITEM_NOT_FOUND enumerator has reached the end of the property set or if it has not started + */ +TEE_Result TEE_GetNextProperty(TEE_PropSetHandle enumerator); +#endif diff --git a/include/TA/tee_time_api.h b/include/TA/tee_time_api.h new file mode 100644 index 0000000..aeb2056 --- /dev/null +++ b/include/TA/tee_time_api.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: Hanpeng + * Create: 2018-12-13 + * Description: Reference of TEE time api definitions + */ + +#ifndef __TEE_TIME_API_H +#define __TEE_TIME_API_H + +#include "tee_defines.h" + +#define TEE_TIMEOUT_INFINITE (0xFFFFFFFF) + +typedef struct { + uint32_t seconds; + uint32_t millis; +} TEE_Time; + +typedef struct { + int32_t seconds; + int32_t millis; + int32_t min; + int32_t hour; + int32_t day; + int32_t month; + int32_t year; +} TEE_Date_Time; + +typedef struct { + uint32_t type; + uint32_t timer_id; + uint32_t timer_class; + uint32_t reserved2; +} TEE_timer_property; + +typedef enum { + ANTI_ROOT_TIMER = 1, +} TEE_Anti_Root_Timer_Type; + +/* + * Get current TEE system rtc time + * + * @param time [OUT] current system rtc time + * @return void + */ +void get_sys_rtc_time(TEE_Time *time); + +/* + * Get current TEE system time + * + * @param time [OUT] current system time + * @return void + */ +void TEE_GetSystemTime(TEE_Time *time); + +/* + * Waits for the specified number of milliseconds + * + * @param timeout [IN] specified number of milliseconds + * + * @return TEE_SUCCESS success + * @return TEE_ERROR_CANCEL the wait has been cancelled + * @return TEE_ERROR_OUT_OF_MEMORY not enough memory is available to complete the operation + */ +TEE_Result TEE_Wait(uint32_t timeout); + +/* + * Retrieves the persistent time of the Trusted Application + * + * @param time [IN] the persistent time of the Trusted Application + * + * @return TEE_SUCCESS success + * @return TEE_ERROR_TIME_NOT_SET the persistent time has not been set + * @return TEE_ERROR_TIME_NEEDS_RESET the persistent time has been set but may have been + * corrupted and MUST no longer be trusted + * @return TEE_ERROR_OVERFLOW the number of seconds in the TA Persistent Time overflows the range of a uint32_t + * @return TEE_ERROR_OUT_OF_MEMORY not enough memory is available to complete the operation + */ +TEE_Result TEE_GetTAPersistentTime(TEE_Time *time); + +/* + * Set the persistent time of the current Trusted Application + * + * @param time [IN] the persistent time of the Trusted Application + * + * @return TEE_SUCCESS success + * @return TEE_ERROR_OUT_OF_MEMORY not enough memory is available to complete the operation + * @return TEE_ERROR_STORAGE_NO_SPACE insufficient storage space is available to complete the operation + */ +TEE_Result TEE_SetTAPersistentTime(TEE_Time *time); + +/* + * Get current REE system time + * + * @param time [OUT] current REE system time + * @return void + */ +void TEE_GetREETime(TEE_Time *time); + +/* + * Get string of current REE system time + * + * @param time_str [OUT] current REE system time string + * @param time_str_len [OUT] the length of time string + * @return void + */ +void TEE_GetREETimeStr(char *time_str, uint32_t time_str_len); + +/* + * Create rtc timer event + * + * @param time_seconds [IN] specified number of seconds + * @param timer_property [IN] specified property of timer + * + * @return TEE_SUCCESS success + * @return TEE_ERROR_GENERIC create timer fail + */ +TEE_Result TEE_EXT_CreateTimer(uint32_t time_seconds, TEE_timer_property *timer_property); + +/* + * Destory rtc timer event + * + * @param timer_property [IN] specified property of timer + * + * @return TEE_SUCCESS success + * @return TEE_ERROR_GENERIC destroy timer fail + */ +TEE_Result TEE_EXT_DestoryTimer(TEE_timer_property *timer_property); + +/* + * Get expire time of rtc timer event + * + * @param timer_property [IN] specified property of timer + * @param time_seconds [OUT] expire time of rtc timer event + * + * @return TEE_SUCCESS success + * @return TEE_ERROR_GENERIC get expire time fail + */ +TEE_Result TEE_EXT_GetTimerExpire(TEE_timer_property *timer_property, uint32_t *time_seconds); + +/* + * Get remain time of rtc timer event + * + * @param timer_property [IN] specified property of timer + * @param time_seconds [OUT] remain time of rtc timer event + * + * @return TEE_SUCCESS success + * @return TEE_ERROR_GENERIC get remain time fail + */ +TEE_Result TEE_EXT_GetTimerRemain(TEE_timer_property *timer_property, uint32_t *time_seconds); + +/* + * Get secure rtc time + * + * @return current rtc seconds + */ +unsigned int __get_secure_rtc_time(void); +#endif diff --git a/src/CA/cloud/libteec_adaptor.c b/src/CA/cloud/libteec_adaptor.c new file mode 100644 index 0000000..250cae4 --- /dev/null +++ b/src/CA/cloud/libteec_adaptor.c @@ -0,0 +1,271 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: lipeng + * Create: 2019.4.30 + * Description: this file is used for adapting interfaces in libteec.so + */ + +#include +#include + +#include "tee_client_api.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "libteec_adaptor" + +#define LIBTEEC_PATH "/usr/lib64/libteec.so" + +/* + * these Function pointers are consistent with those defined in "tee_client_api.h" + * if you want to call the new interface in "tee_client_api.h", + * you should add a new definition here + */ +typedef TEEC_Result (*initializeContext_f)(const char *name, TEEC_Context *context); +typedef void (*finalizeContext_f)(TEEC_Context *context); +typedef TEEC_Result (*openSession_f)(TEEC_Context *context, TEEC_Session *session, + const TEEC_UUID *destination, uint32_t connectionMethod, const void *connectionData, + TEEC_Operation *operation, uint32_t *returnOrigin); +typedef void (*closeSession_f)(TEEC_Session *session); +typedef TEEC_Result (*invokeCommand_f)(TEEC_Session *session, uint32_t commandID, + TEEC_Operation *operation, uint32_t *returnOrigin); +typedef TEEC_Result (*registerSharedMemory_f)(TEEC_Context *context, + TEEC_SharedMemory *sharedMem); +typedef TEEC_Result (*allocateSharedMemory_f)(TEEC_Context *context, + TEEC_SharedMemory *sharedMem); +typedef void (*releaseSharedMemory_f)(TEEC_SharedMemory *sharedMem); +typedef void (*requestCancellation_f)(TEEC_Operation *operation); + +typedef struct { + initializeContext_f initializeContextFn; + finalizeContext_f finalizeContextFn; + openSession_f openSessionFn; + closeSession_f closeSessionFn; + invokeCommand_f invokeCommandFn; + registerSharedMemory_f registerSharedMemoryFn; + allocateSharedMemory_f allocateSharedMemoryFn; + releaseSharedMemory_f releaseSharedMemoryFn; + requestCancellation_f requestCancellationFn; +} TeecApiTable; + +static TeecApiTable g_teecApiTable; +static void *g_libTeecHandle = NULL; +static pthread_mutex_t g_libTeecHandleLock = PTHREAD_MUTEX_INITIALIZER; + +static TEEC_Result GetBasicApiSymbol(TeecApiTable *teecApiTable) +{ + teecApiTable->initializeContextFn = + (initializeContext_f)(dlsym(g_libTeecHandle, "TEEC_InitializeContext")); + if (teecApiTable->initializeContextFn == NULL) { + TEEC_Error("get symbol TEEC_InitializeContext failed\n"); + return TEEC_ERROR_GENERIC; + } + + teecApiTable->finalizeContextFn = + (finalizeContext_f)(dlsym(g_libTeecHandle, "TEEC_FinalizeContext")); + if (teecApiTable->finalizeContextFn == NULL) { + TEEC_Error("get symbol TEEC_FinalizeContext failed\n"); + return TEEC_ERROR_GENERIC; + } + + teecApiTable->openSessionFn = + (openSession_f)(dlsym(g_libTeecHandle, "TEEC_OpenSession")); + if (teecApiTable->openSessionFn == NULL) { + TEEC_Error("get symbol TEEC_OpenSession failed\n"); + return TEEC_ERROR_GENERIC; + } + + teecApiTable->closeSessionFn = + (closeSession_f)(dlsym(g_libTeecHandle, "TEEC_CloseSession")); + if (teecApiTable->closeSessionFn == NULL) { + TEEC_Error("get symbol TEEC_CloseSession failed\n"); + return TEEC_ERROR_GENERIC; + } + + teecApiTable->invokeCommandFn = + (invokeCommand_f)(dlsym(g_libTeecHandle, "TEEC_InvokeCommand")); + if (teecApiTable->invokeCommandFn == NULL) { + TEEC_Error("get symbol TEEC_InvokeCommand failed\n"); + return TEEC_ERROR_GENERIC; + } + + return TEEC_SUCCESS; +} + +static TEEC_Result GetMemApiSymbol(TeecApiTable *teecApiTable) +{ + teecApiTable->registerSharedMemoryFn = + (registerSharedMemory_f)(dlsym(g_libTeecHandle, "TEEC_RegisterSharedMemory")); + if (teecApiTable->registerSharedMemoryFn == NULL) { + TEEC_Error("get symbol TEEC_RegisterSharedMemory failed\n"); + return TEEC_ERROR_GENERIC; + } + + teecApiTable->allocateSharedMemoryFn = + (allocateSharedMemory_f)(dlsym(g_libTeecHandle, "TEEC_AllocateSharedMemory")); + if (teecApiTable->allocateSharedMemoryFn == NULL) { + TEEC_Error("get symbol TEEC_AllocateSharedMemory failed\n"); + return TEEC_ERROR_GENERIC; + } + + teecApiTable->releaseSharedMemoryFn = + (releaseSharedMemory_f)(dlsym(g_libTeecHandle, "TEEC_ReleaseSharedMemory")); + if (teecApiTable->releaseSharedMemoryFn == NULL) { + TEEC_Error("get symbol TEEC_ReleaseSharedMemory failed\n"); + return TEEC_ERROR_GENERIC; + } + + teecApiTable->requestCancellationFn = + (requestCancellation_f)(dlsym(g_libTeecHandle, "TEEC_RequestCancellation")); + if (teecApiTable->requestCancellationFn == NULL) { + TEEC_Error("get symbol TEEC_RequestCancellation failed\n"); + return TEEC_ERROR_GENERIC; + } + + return TEEC_SUCCESS; +} + +static TEEC_Result GetTeecApiSymbol() +{ + TeecApiTable teecApiTable = {0}; + (void)pthread_mutex_lock(&g_libTeecHandleLock); + + if (g_libTeecHandle != NULL) { + (void)pthread_mutex_unlock(&g_libTeecHandleLock); + return TEEC_SUCCESS; + } + + g_libTeecHandle = dlopen(LIBTEEC_PATH, RTLD_LAZY); + if (g_libTeecHandle == NULL) { + TEEC_Error("dlopen libteec failed\n"); + (void)pthread_mutex_unlock(&g_libTeecHandleLock); + return TEEC_ERROR_GENERIC; + } + + if (GetBasicApiSymbol(&teecApiTable) != TEEC_SUCCESS || + GetMemApiSymbol(&teecApiTable) != TEEC_SUCCESS) { + TEEC_Error("get symbol failed\n"); + goto ERROR; + } + + g_teecApiTable = teecApiTable; + (void)pthread_mutex_unlock(&g_libTeecHandleLock); + return TEEC_SUCCESS; + +ERROR: + dlclose(g_libTeecHandle); + g_libTeecHandle = NULL; + (void)pthread_mutex_unlock(&g_libTeecHandleLock); + return TEEC_ERROR_GENERIC; +} + +/* + * The following are Interfaces for CA application, + * In these interfaces, you should make sure the function pointer in g_teecApiTable is not NULL + */ +TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context) +{ + TEEC_Result ret = GetTeecApiSymbol(); + if (ret != TEEC_SUCCESS) { + TEEC_Error("get teec api symbol failed!\n"); + return TEEC_ERROR_GENERIC; + } + + return g_teecApiTable.initializeContextFn(name, context); +} + +void TEEC_FinalizeContext(TEEC_Context *context) +{ + if (g_teecApiTable.finalizeContextFn == NULL) { + TEEC_Error("finalizeContextFn is null!\n"); + return; + } + + g_teecApiTable.finalizeContextFn(context); +} + +TEEC_Result TEEC_OpenSession(TEEC_Context *context, TEEC_Session *session, + const TEEC_UUID *destination, uint32_t connectionMethod, + const void *connectionData, TEEC_Operation *operation, + uint32_t *returnOrigin) +{ + if (g_teecApiTable.openSessionFn == NULL) { + TEEC_Error("openSessionFn is null!\n"); + return TEEC_ERROR_GENERIC; + } + + return g_teecApiTable.openSessionFn(context, session, destination, + connectionMethod, connectionData, operation, returnOrigin); +} + +void TEEC_CloseSession(TEEC_Session *session) +{ + if (g_teecApiTable.closeSessionFn == NULL) { + TEEC_Error("closeSessionFn is null!\n"); + return; + } + + g_teecApiTable.closeSessionFn(session); +} + +TEEC_Result TEEC_InvokeCommand(TEEC_Session *session, uint32_t commandID, + TEEC_Operation *operation, uint32_t *returnOrigin) +{ + if (g_teecApiTable.invokeCommandFn == NULL) { + TEEC_Error("invokeCommandFn is null!\n"); + return TEEC_ERROR_GENERIC; + } + + return g_teecApiTable.invokeCommandFn(session, commandID, operation, returnOrigin); +} + +TEEC_Result TEEC_RegisterSharedMemory(TEEC_Context *context, + TEEC_SharedMemory *sharedMem) +{ + if (g_teecApiTable.registerSharedMemoryFn == NULL) { + TEEC_Error("registerSharedMemoryFn is null!\n"); + return TEEC_ERROR_GENERIC; + } + + return g_teecApiTable.registerSharedMemoryFn(context, sharedMem); +} + +TEEC_Result TEEC_AllocateSharedMemory(TEEC_Context *context, + TEEC_SharedMemory *sharedMem) +{ + if (g_teecApiTable.allocateSharedMemoryFn == NULL) { + TEEC_Error("allocateSharedMemoryFn is null!\n"); + return TEEC_ERROR_GENERIC; + } + + return g_teecApiTable.allocateSharedMemoryFn(context, sharedMem); +} + +void TEEC_ReleaseSharedMemory(TEEC_SharedMemory *sharedMem) +{ + if (g_teecApiTable.releaseSharedMemoryFn == NULL) { + TEEC_Error("releaseSharedMemoryFn is null!\n"); + return; + } + + g_teecApiTable.releaseSharedMemoryFn(sharedMem); +} + +void TEEC_RequestCancellation(TEEC_Operation *operation) +{ + if (g_teecApiTable.requestCancellationFn == NULL) { + TEEC_Error("requestCancellationFn is null!\n"); + return; + } + + g_teecApiTable.requestCancellationFn(operation); +} diff --git a/test/CA/helloworld/ReadMe.txt b/test/CA/helloworld/ReadMe.txt new file mode 100755 index 0000000..e10f8b8 --- /dev/null +++ b/test/CA/helloworld/ReadMe.txt @@ -0,0 +1,2 @@ +Makefile is located in different folder for different product +please switch to target folder and execute "make" command to build TA binary for target product diff --git a/test/CA/helloworld/ca_demo.c b/test/CA/helloworld/ca_demo.c new file mode 100755 index 0000000..93e771c --- /dev/null +++ b/test/CA/helloworld/ca_demo.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Author: liushengwei + * Create: 2020-6-24 + * Description: C file template for CA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tee_client_api.h" + +#define VERSION_BUFFER_SIZE 256 +#define OPERATION_START_FLAG 1 +#define OUT_BUFF_INDEX 3 + +static const TEEC_UUID DEMO_TEMPLATE_UUID = +{ + 0xe3d37f4a, 0xf24c, 0x48d0, + { 0x88, 0x84, 0x3b, 0xdd, 0x6c, 0x44, 0xe9, 0x88 } +}; + +enum { + CMD_GET_TA_VERSION = 1, +}; + +int main(void) +{ + TEEC_Context context = {0}; + TEEC_Session session = {0}; + TEEC_Result result; + TEEC_Operation operation = {0}; + uint32_t origin = 0; + + char versionBuf[VERSION_BUFFER_SIZE] = {0}; + unsigned int bufLen = VERSION_BUFFER_SIZE; + + result = TEEC_InitializeContext(NULL, &context); + if (result != TEEC_SUCCESS) { + printf("teec initial failed"); + goto cleanup_1; + } + + /* MUST use TEEC_LOGIN_IDENTIFY method */ + operation.started = OPERATION_START_FLAG; + operation.paramTypes = TEEC_PARAM_TYPES( + TEEC_NONE, + TEEC_NONE, + TEEC_MEMREF_TEMP_INPUT, + TEEC_MEMREF_TEMP_INPUT); + + result = TEEC_OpenSession( + &context, &session, &DEMO_TEMPLATE_UUID, TEEC_LOGIN_IDENTIFY, NULL, &operation, &origin); + if (result != TEEC_SUCCESS) { + printf("teec open session failed"); + goto cleanup_2; + } else { + TEEC_Debug("teec open session successed"); + } + + operation.started = OPERATION_START_FLAG; + operation.paramTypes = TEEC_PARAM_TYPES( + TEEC_NONE, + TEEC_NONE, + TEEC_NONE, + TEEC_MEMREF_TEMP_OUTPUT); + operation.params[OUT_BUFF_INDEX].tmpref.buffer = versionBuf; + operation.params[OUT_BUFF_INDEX].tmpref.size = bufLen; + + result = TEEC_InvokeCommand(&session, CMD_GET_TA_VERSION, &operation, &origin); + if (result != TEEC_SUCCESS) { + printf("invoke failed, codes=0x%x, origin=0x%x", result, origin); + } else { + printf("Succeed to load TA, TA's version: %s.\n", versionBuf); + } + + TEEC_CloseSession(&session); +cleanup_2: + TEEC_FinalizeContext(&context); +cleanup_1: + return 0; +} diff --git a/test/CA/helloworld/cloud/Makefile b/test/CA/helloworld/cloud/Makefile new file mode 100755 index 0000000..190b131 --- /dev/null +++ b/test/CA/helloworld/cloud/Makefile @@ -0,0 +1,23 @@ +CUR_DIR=$(shell pwd) +iTrustee_SDK_PATH=${CUR_DIR}/../../../../ + +TARGET_APP := teec_hello + +APP_SOURCES := ../ca_demo.c + +APP_SOURCES += $(iTrustee_SDK_PATH)/src/CA/cloud/libteec_adaptor.c + +APP_CFLAGS += -fstack-protector-strong -fPIC + +APP_CFLAGS += -I$(iTrustee_SDK_PATH)/include/CA \ + +APP_LDFLAGS += -ldl -lpthread + +APP_LDFLAGS += -z text -z now -z relro -z noexecstack -pie + +APP_OBJECTS := $(APP_SOURCES:.c=.o) +$(TARGET_APP): $(APP_SOURCES) + @$(CC) $(APP_CFLAGS) -o $@ $(APP_SOURCES) $(APP_LDFLAGS) + +clean: + rm -f *.o $(TARGET_APP) diff --git a/test/TA/helloworld/ReadMe.txt b/test/TA/helloworld/ReadMe.txt new file mode 100755 index 0000000..e10f8b8 --- /dev/null +++ b/test/TA/helloworld/ReadMe.txt @@ -0,0 +1,2 @@ +Makefile is located in different folder for different product +please switch to target folder and execute "make" command to build TA binary for target product diff --git a/test/TA/helloworld/cloud/Makefile b/test/TA/helloworld/cloud/Makefile new file mode 100755 index 0000000..108fda6 --- /dev/null +++ b/test/TA/helloworld/cloud/Makefile @@ -0,0 +1,28 @@ +include ../config.mk +include ../../../../build/mk/cloud/common.mk + +SRC += $(wildcard ./*.c) +SRC += ../ta_demo.c + +# set header directory +INCLUDEDIR += -I./include + +# set target +COBJS := $(SRC:%.c=%.o) +TARGET = $(COBJS) + +sec_binary:combine + cp ../manifest.txt ./ + python3 -B ${SIGNTOOL_DIR}/signtool_v3.py ${CUR_DIR} ${CUR_DIR} --config ${SIGNTOOL_DIR}/cloud/config_cloud.ini + +combine: $(TARGET) + $(LD) $(LDFLAGS) $(TARGET) $(EXTRAO) -o libcombine.so + +src/%.o: ./src/%.c + $(CC) $(CFLAGS) $(INCLUDEDIR) -c $< -o $@ + +%.o: %.c + $(CC) $(CFLAGS) $(INCLUDEDIR) -c $< -o $@ + +clean: + rm -f $(COBJS) *.so diff --git a/test/TA/helloworld/config.mk b/test/TA/helloworld/config.mk new file mode 100644 index 0000000..ebdbd8c --- /dev/null +++ b/test/TA/helloworld/config.mk @@ -0,0 +1,10 @@ +# +# Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. +# +# API_LEVEL which indicates the GP API version of TA +# API_LEVEL=1 indicates GP 1.0 which is the current version of itrustee +# API_LEVEL=2 indicates GP 1.1.1 which is the current version of the partner +# API_LEVEL=3 indicates GP 1.2 which is the version we both going to support +# If no API_LEVEL is specified, API of GP 1.0 will be taked +CFLAGS += -DAPI_LEVEL=1 +TARGET_IS_ARM64 = y diff --git a/test/TA/helloworld/manifest.txt b/test/TA/helloworld/manifest.txt new file mode 100755 index 0000000..77059df --- /dev/null +++ b/test/TA/helloworld/manifest.txt @@ -0,0 +1,7 @@ +gpd.ta.appID: e3d37f4a-f24c-48d0-8884-3bdd6c44e988 +gpd.ta.service_name: demo-ta +gpd.ta.singleInstance: true +gpd.ta.multiSession: false +gpd.ta.instanceKeepAlive: False +gpd.ta.dataSize: 81920 +gpd.ta.stackSize: 8192 diff --git a/test/TA/helloworld/ta_demo.c b/test/TA/helloworld/ta_demo.c new file mode 100755 index 0000000..b5246f9 --- /dev/null +++ b/test/TA/helloworld/ta_demo.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR + * PURPOSE. + * See the Mulan PSL v2 for more details. + * Description: TA template code for reference + * Author: huangjiankang + * Create: 2020-02-20 + */ + +#include +#include +#include + +#define TA_TEMPLATE_VERSION "demo_20200601" +#define PARAM_COUNT 4 +#define OUT_BUFFER_INDEX 3 + +enum { + CMD_GET_TA_VERSION = 1, +}; + +static TEE_Result get_ta_version(char* buffer, size_t *buf_len) +{ + char *version = TA_TEMPLATE_VERSION; + + if (*buf_len < strlen(version) + 1) { + tloge("buffer is too short for storing result"); + *buf_len = strlen(version) + 1; + return TEE_ERROR_SHORT_BUFFER; + } + + errno_t err = strncpy_s(buffer, *buf_len, version, strlen(version) + 1); + if (err != EOK) + return TEE_ERROR_SECURITY; + + *buf_len = strlen(version) + 1; + + return TEE_SUCCESS; +} + +/** + * Function TA_CreateEntryPoint + * Description: + * The function TA_CreateEntryPoint is the Trusted Application's constructor, + * which the Framework calls when it creates a new instance of this Trusted Application. + */ +TEE_Result TA_CreateEntryPoint(void) +{ + TEE_Result ret = TEE_ERROR_GENERIC; + + tlogd("----- TA entry point ----- "); + tlogd("TA version: %s", TA_TEMPLATE_VERSION); + +#ifdef CONFIG_AUTH_CLOUD + ret = addcaller_ca_exec("/vendor/bin/teec_hello", "root"); +#endif + if (ret == TEE_SUCCESS) { + tlogd("TA entry point: add ca whitelist success"); + } else { + tloge("TA entry point: add ca whitelist failed"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +/** + * Function TA_OpenSessionEntryPoint + * Description: + * The Framework calls the function TA_OpenSessionEntryPoint + * when a client requests to open a session with the Trusted Application. + * The open session request may result in a new Trusted Application instance + * being created. + */ +TEE_Result TA_OpenSessionEntryPoint(uint32_t parm_type, + TEE_Param params[PARAM_COUNT], void** session_context) +{ + (void)parm_type; + (void)params; + (void)session_context; + tlogd("---- TA open session -------- "); + + return TEE_SUCCESS; +} + +/** + * Function TA_InvokeCommandEntryPoint: + * Description: + * The Framework calls this function when the client invokes a command + * within the given session. + */ +TEE_Result TA_InvokeCommandEntryPoint(void* session_context, uint32_t cmd, + uint32_t parm_type, TEE_Param params[PARAM_COUNT]) +{ + TEE_Result ret; + (void)session_context; + + tlogd("---- TA invoke command ----------- "); + switch (cmd) { + case CMD_GET_TA_VERSION: + if (!check_param_type(parm_type, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_NONE, + TEE_PARAM_TYPE_MEMREF_OUTPUT)) { + tloge("Bad expected parameter types"); + return TEE_ERROR_BAD_PARAMETERS; + } + if (params[OUT_BUFFER_INDEX].memref.buffer == NULL || + params[OUT_BUFFER_INDEX].memref.size == 0) { + tloge("InvokeCommand with bad, cmd is %u", cmd); + return TEE_ERROR_BAD_PARAMETERS; + } + ret = get_ta_version(params[OUT_BUFFER_INDEX].memref.buffer, ¶ms[OUT_BUFFER_INDEX].memref.size); + if (ret != TEE_SUCCESS) { + tloge("InvokeCommand Failed 0x%x. cmd is %u", ret, cmd); + return ret; + } + break; + default: + tloge("Unknown cmd is %u", cmd); + ret = TEE_ERROR_BAD_PARAMETERS; + } + + return ret; +} + +/** + * Function TA_CloseSessionEntryPoint: + * Description: + * The Framework calls this function to close a client session. + * During the call to this function the implementation can use + * any session functions. + */ +void TA_CloseSessionEntryPoint(void* session_context) +{ + (void)session_context; + tlogd("---- close session ----- "); +} + +/** + * Function TA_DestroyEntryPoint + * Description: + * The function TA_DestroyEntryPoint is the Trusted Application's destructor, + * which the Framework calls when the instance is being destroyed. + */ +void TA_DestroyEntryPoint(void) +{ + tlogd("---- destory TA ---- "); +} diff --git a/thirdparty/open_source/musl/libc/alloca.h b/thirdparty/open_source/musl/libc/alloca.h new file mode 100644 index 0000000..b8d183d --- /dev/null +++ b/thirdparty/open_source/musl/libc/alloca.h @@ -0,0 +1,19 @@ +#ifndef _ALLOCA_H +#define _ALLOCA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define __NEED_size_t +#include + +void *alloca(size_t); + +#define alloca __builtin_alloca + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/atomic_arch.h b/thirdparty/open_source/musl/libc/arch/aarch64/atomic_arch.h new file mode 100644 index 0000000..40fefc2 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/atomic_arch.h @@ -0,0 +1,82 @@ +#define a_ll a_ll +static inline int a_ll(volatile int *p) +{ + int v; + __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + return v; +} + +#define a_sc a_sc +static inline int a_sc(volatile int *p, int v) +{ + int r; + __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + return !r; +} + +#define a_barrier a_barrier +static inline void a_barrier() +{ + __asm__ __volatile__ ("dmb ish" : : : "memory"); +} + +#define a_cas a_cas +static inline int a_cas(volatile int *p, int t, int s) +{ + int old; + do { + old = a_ll(p); + if (old != t) { + a_barrier(); + break; + } + } while (!a_sc(p, s)); + return old; +} + +#define a_ll_p a_ll_p +static inline void *a_ll_p(volatile void *p) +{ + void *v; + __asm__ __volatile__ ("ldaxr %0, %1" : "=r"(v) : "Q"(*(void *volatile *)p)); + return v; +} + +#define a_sc_p a_sc_p +static inline int a_sc_p(volatile int *p, void *v) +{ + int r; + __asm__ __volatile__ ("stlxr %w0,%2,%1" : "=&r"(r), "=Q"(*(void *volatile *)p) : "r"(v) : "memory"); + return !r; +} + +#define a_cas_p a_cas_p +static inline void *a_cas_p(volatile void *p, void *t, void *s) +{ + void *old; + do { + old = a_ll_p(p); + if (old != t) { + a_barrier(); + break; + } + } while (!a_sc_p(p, s)); + return old; +} + +#define a_ctz_64 a_ctz_64 +static inline int a_ctz_64(uint64_t x) +{ + __asm__( + " rbit %0, %1\n" + " clz %0, %0\n" + : "=r"(x) : "r"(x)); + return x; +} + +#define a_clz_64 a_clz_64 +static inline int a_clz_64(uint64_t x) +{ + __asm__("clz %0, %1" : "=r"(x) : "r"(x)); + return x; +} diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h new file mode 100644 index 0000000..a0309c0 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h @@ -0,0 +1,466 @@ +#define _Addr long +#ifdef __LP64__ +#define _Int64 long +#else +#define _Int64 long long +#endif +#define _Reg long + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __USE_TIME_BITS64 1 + +#ifndef __BYTE_ORDER +#if __AARCH64EB__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif +#endif + +#define __LONG_MAX 0x7fffffffffffffffL + +#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) +typedef __builtin_va_list va_list; +#define __DEFINED_va_list +#endif + +#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list) +typedef __builtin_va_list __isoc_va_list; +#define __DEFINED___isoc_va_list +#endif + +#ifndef __cplusplus +#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t) +typedef unsigned wchar_t; +#define __DEFINED_wchar_t +#endif + +#endif +#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t) +typedef unsigned wint_t; +#define __DEFINED_wint_t +#endif + +#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t) +typedef int blksize_t; +#define __DEFINED_blksize_t +#endif + +#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t) +typedef unsigned int nlink_t; +#define __DEFINED_nlink_t +#endif + +#if defined(__NEED_float_t) && !defined(__DEFINED_float_t) +typedef float float_t; +#define __DEFINED_float_t +#endif + +#if defined(__NEED_double_t) && !defined(__DEFINED_double_t) +typedef double double_t; +#define __DEFINED_double_t +#endif + +#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t) +typedef struct { + long long __ll; + long double __ld; +} max_align_t; +#define __DEFINED_max_align_t +#endif + +#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) +typedef long time_t; +#define __DEFINED_time_t +#endif + +#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) +typedef long suseconds_t; +#define __DEFINED_suseconds_t +#endif + +#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) +typedef struct { + union { + int __i[14]; + volatile int __vi[14]; + unsigned long __s[7]; + } __u; +} pthread_attr_t; +#define __DEFINED_pthread_attr_t +#endif + +#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t) +typedef struct { + union { + int __i[10]; + volatile int __vi[10]; + volatile void *volatile __p[5]; + } __u; +} pthread_mutex_t; +#define __DEFINED_pthread_mutex_t +#endif + +#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t) +typedef struct { + union { + int __i[10]; + volatile int __vi[10]; + volatile void *volatile __p[5]; + } __u; +} mtx_t; +#define __DEFINED_mtx_t +#endif + +#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t) +typedef struct { + union { + int __i[12]; + volatile int __vi[12]; + void *__p[6]; + } __u; +} pthread_cond_t; +#define __DEFINED_pthread_cond_t +#endif + +#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t) +typedef struct { + union { + int __i[12]; + volatile int __vi[12]; + void *__p[6]; + } __u; +} cnd_t; +#define __DEFINED_cnd_t +#endif + +#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) +typedef struct { + union { + int __i[14]; + volatile int __vi[14]; + void *__p[7]; + } __u; +} pthread_rwlock_t; +#define __DEFINED_pthread_rwlock_t +#endif + +#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t) +typedef struct { + union { + int __i[8]; + volatile int __vi[8]; + void *__p[4]; + } __u; +} pthread_barrier_t; +#define __DEFINED_pthread_barrier_t +#endif + +#if defined(__NEED_size_t) && !defined(__DEFINED_size_t) +typedef unsigned _Addr size_t; +#define __DEFINED_size_t +#endif + +#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t) +typedef unsigned _Addr uintptr_t; +#define __DEFINED_uintptr_t +#endif + +#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t) +typedef _Addr ptrdiff_t; +#define __DEFINED_ptrdiff_t +#endif + +#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t) +typedef _Addr ssize_t; +#define __DEFINED_ssize_t +#endif + +#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t) +typedef _Addr intptr_t; +#define __DEFINED_intptr_t +#endif + +#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t) +typedef _Addr regoff_t; +#define __DEFINED_regoff_t +#endif + +#if defined(__NEED_register_t) && !defined(__DEFINED_register_t) +typedef _Reg register_t; +#define __DEFINED_register_t +#endif + +#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t) +typedef signed char int8_t; +#define __DEFINED_int8_t +#endif + +#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t) +typedef short int16_t; +#define __DEFINED_int16_t +#endif + +#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t) +typedef int int32_t; +#define __DEFINED_int32_t +#endif + +#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t) +typedef _Int64 int64_t; +#define __DEFINED_int64_t +#endif + +#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t) +typedef _Int64 intmax_t; +#define __DEFINED_intmax_t +#endif + +#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t) +typedef unsigned char uint8_t; +#define __DEFINED_uint8_t +#endif + +#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t) +typedef unsigned short uint16_t; +#define __DEFINED_uint16_t +#endif + +#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t) +typedef unsigned int uint32_t; +#define __DEFINED_uint32_t +#endif + +#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t) +typedef unsigned _Int64 uint64_t; +#define __DEFINED_uint64_t +#endif + +#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t) +typedef unsigned _Int64 u_int64_t; +#define __DEFINED_u_int64_t +#endif + +#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t) +typedef unsigned _Int64 uintmax_t; +#define __DEFINED_uintmax_t +#endif + +#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t) +typedef unsigned mode_t; +#define __DEFINED_mode_t +#endif + +#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t) +typedef unsigned _Reg nlink_t; +#define __DEFINED_nlink_t +#endif + +#if defined(__NEED_off_t) && !defined(__DEFINED_off_t) +typedef _Int64 off_t; +#define __DEFINED_off_t +#endif + +#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t) +typedef unsigned _Int64 ino_t; +#define __DEFINED_ino_t +#endif + +#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t) +typedef unsigned _Int64 dev_t; +#define __DEFINED_dev_t +#endif + +#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t) +typedef long blksize_t; +#define __DEFINED_blksize_t +#endif + +#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t) +typedef _Int64 blkcnt_t; +#define __DEFINED_blkcnt_t +#endif + +#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t) +typedef unsigned _Int64 fsblkcnt_t; +#define __DEFINED_fsblkcnt_t +#endif + +#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t) +typedef unsigned _Int64 fsfilcnt_t; +#define __DEFINED_fsfilcnt_t +#endif + +#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t) +typedef unsigned wint_t; +#define __DEFINED_wint_t +#endif + +#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t) +typedef unsigned long wctype_t; +#define __DEFINED_wctype_t +#endif + +#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t) +typedef void *timer_t; +#define __DEFINED_timer_t +#endif + +#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t) +typedef int clockid_t; +#define __DEFINED_clockid_t +#endif + +#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t) +typedef long clock_t; +#define __DEFINED_clock_t +#endif + +#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval) +struct timeval { + time_t tv_sec; + suseconds_t tv_usec; +}; +#define __DEFINED_struct_timeval +#endif + +#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#define __DEFINED_struct_timespec +#endif + +#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t) +typedef int pid_t; +#define __DEFINED_pid_t +#endif + +#if defined(__NEED_id_t) && !defined(__DEFINED_id_t) +typedef unsigned id_t; +#define __DEFINED_id_t +#endif + +#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t) +typedef unsigned uid_t; +#define __DEFINED_uid_t +#endif + +#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t) +typedef unsigned gid_t; +#define __DEFINED_gid_t +#endif + +#if defined(__NEED_key_t) && !defined(__DEFINED_key_t) +typedef int key_t; +#define __DEFINED_key_t +#endif + +#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t) +typedef unsigned useconds_t; +#define __DEFINED_useconds_t +#endif + +#ifdef __cplusplus +#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) +typedef unsigned long pthread_t; +#define __DEFINED_pthread_t +#endif + +#else +#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) +typedef struct __pthread *pthread_t; +#define __DEFINED_pthread_t +#endif + +#endif +#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t) +typedef int pthread_once_t; +#define __DEFINED_pthread_once_t +#endif + +#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t) +typedef unsigned pthread_key_t; +#define __DEFINED_pthread_key_t +#endif + +#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t) +typedef int pthread_spinlock_t; +#define __DEFINED_pthread_spinlock_t +#endif + +#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t) +typedef struct { + unsigned __attr; +} pthread_mutexattr_t; +#define __DEFINED_pthread_mutexattr_t +#endif + +#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t) +typedef struct { + unsigned __attr; +} pthread_condattr_t; +#define __DEFINED_pthread_condattr_t +#endif + +#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t) +typedef struct { + unsigned __attr; +} pthread_barrierattr_t; +#define __DEFINED_pthread_barrierattr_t +#endif + +#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t) +typedef struct { + unsigned __attr[2]; +} pthread_rwlockattr_t; +#define __DEFINED_pthread_rwlockattr_t +#endif + +#if defined(__NEED_FILE) && !defined(__DEFINED_FILE) +typedef struct _IO_FILE FILE; +#define __DEFINED_FILE +#endif + +#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t) +typedef struct __mbstate_t { + unsigned __opaque1, __opaque2; +} mbstate_t; +#define __DEFINED_mbstate_t +#endif + +#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t) +typedef struct __locale_struct *locale_t; +#define __DEFINED_locale_t +#endif + +#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t) +typedef struct __sigset_t { + unsigned long __bits[128 / sizeof(long)]; +} sigset_t; +#define __DEFINED_sigset_t +#endif + +#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec) +struct iovec { + void *iov_base; + size_t iov_len; +}; +#define __DEFINED_struct_iovec +#endif + +#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) +typedef unsigned socklen_t; +#define __DEFINED_socklen_t +#endif + +#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t) +typedef unsigned short sa_family_t; +#define __DEFINED_sa_family_t +#endif + +#undef _Addr +#undef _Int64 +#undef _Reg diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h.in b/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h.in new file mode 100644 index 0000000..c547ca0 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h.in @@ -0,0 +1,24 @@ +#define _Addr long +#define _Int64 long +#define _Reg long + +#if __AARCH64EB__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif + +#define __LONG_MAX 0x7fffffffffffffffL + +#ifndef __cplusplus +TYPEDEF unsigned wchar_t; +#endif +TYPEDEF unsigned wint_t; + +TYPEDEF int blksize_t; +TYPEDEF unsigned int nlink_t; + +TYPEDEF float float_t; +TYPEDEF double double_t; + +TYPEDEF struct { long long __ll; long double __ld; } max_align_t; diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/fcntl.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/fcntl.h new file mode 100644 index 0000000..9278797 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/fcntl.h @@ -0,0 +1,38 @@ +#define O_CREAT 0100 +#define O_EXCL 0200 +#define O_NOCTTY 0400 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_DSYNC 010000 +#define O_SYNC 04010000 +#define O_RSYNC 04010000 +#define O_DIRECTORY 040000 +#define O_NOFOLLOW 0100000 +#define O_CLOEXEC 02000000 + +#define O_ASYNC 020000 +#define O_DIRECT 0200000 +#define O_LARGEFILE 0400000 +#define O_NOATIME 01000000 +#define O_PATH 010000000 +#define O_TMPFILE 020040000 +#define O_NDELAY O_NONBLOCK + +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#define F_SETOWN 8 +#define F_GETOWN 9 +#define F_SETSIG 10 +#define F_GETSIG 11 + +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 + +#define F_GETOWNER_UIDS 17 diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/fenv.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/fenv.h new file mode 100644 index 0000000..2f3279a --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/fenv.h @@ -0,0 +1,19 @@ +#define FE_INVALID 1 +#define FE_DIVBYZERO 2 +#define FE_OVERFLOW 4 +#define FE_UNDERFLOW 8 +#define FE_INEXACT 16 +#define FE_ALL_EXCEPT 31 +#define FE_TONEAREST 0 +#define FE_DOWNWARD 0x800000 +#define FE_UPWARD 0x400000 +#define FE_TOWARDZERO 0xc00000 + +typedef unsigned int fexcept_t; + +typedef struct { + unsigned int __fpcr; + unsigned int __fpsr; +} fenv_t; + +#define FE_DFL_ENV ((const fenv_t *) -1) diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/float.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/float.h new file mode 100644 index 0000000..719c790 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/float.h @@ -0,0 +1,16 @@ +#define FLT_EVAL_METHOD 0 + +#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L +#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L +#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L +#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L + +#define LDBL_MANT_DIG 113 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MAX_EXP 16384 + +#define LDBL_DIG 33 +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_10_EXP 4932 + +#define DECIMAL_DIG 36 diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/hwcap.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/hwcap.h new file mode 100644 index 0000000..a748402 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/hwcap.h @@ -0,0 +1,40 @@ +#define HWCAP_FP (1 << 0) +#define HWCAP_ASIMD (1 << 1) +#define HWCAP_EVTSTRM (1 << 2) +#define HWCAP_AES (1 << 3) +#define HWCAP_PMULL (1 << 4) +#define HWCAP_SHA1 (1 << 5) +#define HWCAP_SHA2 (1 << 6) +#define HWCAP_CRC32 (1 << 7) +#define HWCAP_ATOMICS (1 << 8) +#define HWCAP_FPHP (1 << 9) +#define HWCAP_ASIMDHP (1 << 10) +#define HWCAP_CPUID (1 << 11) +#define HWCAP_ASIMDRDM (1 << 12) +#define HWCAP_JSCVT (1 << 13) +#define HWCAP_FCMA (1 << 14) +#define HWCAP_LRCPC (1 << 15) +#define HWCAP_DCPOP (1 << 16) +#define HWCAP_SHA3 (1 << 17) +#define HWCAP_SM3 (1 << 18) +#define HWCAP_SM4 (1 << 19) +#define HWCAP_ASIMDDP (1 << 20) +#define HWCAP_SHA512 (1 << 21) +#define HWCAP_SVE (1 << 22) +#define HWCAP_ASIMDFHM (1 << 23) +#define HWCAP_DIT (1 << 24) +#define HWCAP_USCAT (1 << 25) +#define HWCAP_ILRCPC (1 << 26) +#define HWCAP_FLAGM (1 << 27) +#define HWCAP_SSBS (1 << 28) +#define HWCAP_SB (1 << 29) +#define HWCAP_PACA (1 << 30) +#define HWCAP_PACG (1UL << 31) + +#define HWCAP2_DCPODP (1 << 0) +#define HWCAP2_SVE2 (1 << 1) +#define HWCAP2_SVEAES (1 << 2) +#define HWCAP2_SVEPMULL (1 << 3) +#define HWCAP2_SVEBITPERM (1 << 4) +#define HWCAP2_SVESHA3 (1 << 5) +#define HWCAP2_SVESM4 (1 << 6) diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/posix.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/posix.h new file mode 100644 index 0000000..c37b94c --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/posix.h @@ -0,0 +1,2 @@ +#define _POSIX_V6_LP64_OFF64 1 +#define _POSIX_V7_LP64_OFF64 1 diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/reg.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/reg.h new file mode 100644 index 0000000..2633f39 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/reg.h @@ -0,0 +1,2 @@ +#undef __WORDSIZE +#define __WORDSIZE 64 diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/setjmp.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/setjmp.h new file mode 100644 index 0000000..54bc261 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/setjmp.h @@ -0,0 +1 @@ +typedef unsigned long __jmp_buf[22]; diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/signal.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/signal.h new file mode 100644 index 0000000..b71261f --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/signal.h @@ -0,0 +1,153 @@ +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define MINSIGSTKSZ 6144 +#define SIGSTKSZ 12288 +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +typedef unsigned long greg_t; +typedef unsigned long gregset_t[34]; + +typedef struct { + long double vregs[32]; + unsigned int fpsr; + unsigned int fpcr; +} fpregset_t; +typedef struct sigcontext { + unsigned long fault_address; + unsigned long regs[31]; + unsigned long sp, pc, pstate; + long double __reserved[256]; +} mcontext_t; + +#define FPSIMD_MAGIC 0x46508001 +#define ESR_MAGIC 0x45535201 +#define EXTRA_MAGIC 0x45585401 +#define SVE_MAGIC 0x53564501 +struct _aarch64_ctx { + unsigned int magic; + unsigned int size; +}; +struct fpsimd_context { + struct _aarch64_ctx head; + unsigned int fpsr; + unsigned int fpcr; + long double vregs[32]; +}; +struct esr_context { + struct _aarch64_ctx head; + unsigned long esr; +}; +struct extra_context { + struct _aarch64_ctx head; + unsigned long datap; + unsigned int size; + unsigned int __reserved[3]; +}; +struct sve_context { + struct _aarch64_ctx head; + unsigned short vl; + unsigned short __reserved[3]; +}; +#define SVE_VQ_BYTES 16 +#define SVE_VQ_MIN 1 +#define SVE_VQ_MAX 512 +#define SVE_VL_MIN (SVE_VQ_MIN * SVE_VQ_BYTES) +#define SVE_VL_MAX (SVE_VQ_MAX * SVE_VQ_BYTES) +#define SVE_NUM_ZREGS 32 +#define SVE_NUM_PREGS 16 +#define sve_vl_valid(vl) \ + ((vl) % SVE_VQ_BYTES == 0 && (vl) >= SVE_VL_MIN && (vl) <= SVE_VL_MAX) +#define sve_vq_from_vl(vl) ((vl) / SVE_VQ_BYTES) +#define sve_vl_from_vq(vq) ((vq) * SVE_VQ_BYTES) +#define SVE_SIG_ZREG_SIZE(vq) ((unsigned)(vq) * SVE_VQ_BYTES) +#define SVE_SIG_PREG_SIZE(vq) ((unsigned)(vq) * (SVE_VQ_BYTES / 8)) +#define SVE_SIG_FFR_SIZE(vq) SVE_SIG_PREG_SIZE(vq) +#define SVE_SIG_REGS_OFFSET \ + ((sizeof(struct sve_context) + (SVE_VQ_BYTES - 1)) \ + / SVE_VQ_BYTES * SVE_VQ_BYTES) +#define SVE_SIG_ZREGS_OFFSET SVE_SIG_REGS_OFFSET +#define SVE_SIG_ZREG_OFFSET(vq, n) \ + (SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREG_SIZE(vq) * (n)) +#define SVE_SIG_ZREGS_SIZE(vq) \ + (SVE_SIG_ZREG_OFFSET(vq, SVE_NUM_ZREGS) - SVE_SIG_ZREGS_OFFSET) +#define SVE_SIG_PREGS_OFFSET(vq) \ + (SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREGS_SIZE(vq)) +#define SVE_SIG_PREG_OFFSET(vq, n) \ + (SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREG_SIZE(vq) * (n)) +#define SVE_SIG_PREGS_SIZE(vq) \ + (SVE_SIG_PREG_OFFSET(vq, SVE_NUM_PREGS) - SVE_SIG_PREGS_OFFSET(vq)) +#define SVE_SIG_FFR_OFFSET(vq) \ + (SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREGS_SIZE(vq)) +#define SVE_SIG_REGS_SIZE(vq) \ + (SVE_SIG_FFR_OFFSET(vq) + SVE_SIG_FFR_SIZE(vq) - SVE_SIG_REGS_OFFSET) +#define SVE_SIG_CONTEXT_SIZE(vq) (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq)) +#else +typedef struct { + long double __regs[18+256]; +} mcontext_t; +#endif + +struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +}; + +typedef struct __ucontext { + unsigned long uc_flags; + struct __ucontext *uc_link; + stack_t uc_stack; + sigset_t uc_sigmask; + mcontext_t uc_mcontext; +} ucontext_t; + +#define SA_NOCLDSTOP 1 +#define SA_NOCLDWAIT 2 +#define SA_SIGINFO 4 +#define SA_ONSTACK 0x08000000 +#define SA_RESTART 0x10000000 +#define SA_NODEFER 0x40000000 +#define SA_RESETHAND 0x80000000 +#define SA_RESTORER 0x04000000 + +#endif + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT SIGABRT +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL 29 +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED SIGSYS + +#define _NSIG 65 diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/stat.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/stat.h new file mode 100644 index 0000000..b7f4221 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/stat.h @@ -0,0 +1,18 @@ +struct stat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + unsigned long __pad; + off_t st_size; + blksize_t st_blksize; + int __pad2; + blkcnt_t st_blocks; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + unsigned __unused[2]; +}; diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/stdint.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/stdint.h new file mode 100644 index 0000000..1bb147f --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/stdint.h @@ -0,0 +1,20 @@ +typedef int32_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef uint32_t uint_fast16_t; +typedef uint32_t uint_fast32_t; + +#define INT_FAST16_MIN INT32_MIN +#define INT_FAST32_MIN INT32_MIN + +#define INT_FAST16_MAX INT32_MAX +#define INT_FAST32_MAX INT32_MAX + +#define UINT_FAST16_MAX UINT32_MAX +#define UINT_FAST32_MAX UINT32_MAX + +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX +#define PTRDIFF_MIN INT64_MIN +#define PTRDIFF_MAX INT64_MAX +#define SIZE_MAX UINT64_MAX diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h new file mode 100644 index 0000000..d57a091 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h @@ -0,0 +1,551 @@ +#define __NR_io_setup 0 +#define __NR_io_destroy 1 +#define __NR_io_submit 2 +#define __NR_io_cancel 3 +#define __NR_io_getevents 4 +#define __NR_setxattr 5 +#define __NR_lsetxattr 6 +#define __NR_fsetxattr 7 +#define __NR_getxattr 8 +#define __NR_lgetxattr 9 +#define __NR_fgetxattr 10 +#define __NR_listxattr 11 +#define __NR_llistxattr 12 +#define __NR_flistxattr 13 +#define __NR_removexattr 14 +#define __NR_lremovexattr 15 +#define __NR_fremovexattr 16 +#define __NR_getcwd 17 +#define __NR_lookup_dcookie 18 +#define __NR_eventfd2 19 +#define __NR_epoll_create1 20 +#define __NR_epoll_ctl 21 +#define __NR_epoll_pwait 22 +#define __NR_dup 23 +#define __NR_dup3 24 +#define __NR_fcntl 25 +#define __NR_inotify_init1 26 +#define __NR_inotify_add_watch 27 +#define __NR_inotify_rm_watch 28 +#define __NR_ioctl 29 +#define __NR_ioprio_set 30 +#define __NR_ioprio_get 31 +#define __NR_flock 32 +#define __NR_mknodat 33 +#define __NR_mkdirat 34 +#define __NR_unlinkat 35 +#define __NR_symlinkat 36 +#define __NR_linkat 37 +#define __NR_renameat 38 +#define __NR_umount2 39 +#define __NR_mount 40 +#define __NR_pivot_root 41 +#define __NR_nfsservctl 42 +#define __NR_statfs 43 +#define __NR_fstatfs 44 +#define __NR_truncate 45 +#define __NR_ftruncate 46 +#define __NR_fallocate 47 +#define __NR_faccessat 48 +#define __NR_chdir 49 +#define __NR_fchdir 50 +#define __NR_chroot 51 +#define __NR_fchmod 52 +#define __NR_fchmodat 53 +#define __NR_fchownat 54 +#define __NR_fchown 55 +#define __NR_openat 56 +#define __NR_close 57 +#define __NR_vhangup 58 +#define __NR_pipe2 59 +#define __NR_quotactl 60 +#define __NR_getdents64 61 +#define __NR_lseek 62 +#define __NR_read 63 +#define __NR_write 64 +#define __NR_readv 65 +#define __NR_writev 66 +#define __NR_pread64 67 +#define __NR_pwrite64 68 +#define __NR_preadv 69 +#define __NR_pwritev 70 +#define __NR_sendfile 71 +#define __NR_pselect6 72 +#define __NR_ppoll 73 +#define __NR_signalfd4 74 +#define __NR_vmsplice 75 +#define __NR_splice 76 +#define __NR_tee 77 +#define __NR_readlinkat 78 +#define __NR_newfstatat 79 +#define __NR_fstat 80 +#define __NR_sync 81 +#define __NR_fsync 82 +#define __NR_fdatasync 83 +#define __NR_sync_file_range 84 +#define __NR_timerfd_create 85 +#define __NR_timerfd_settime 86 +#define __NR_timerfd_gettime 87 +#define __NR_utimensat 88 +#define __NR_acct 89 +#define __NR_capget 90 +#define __NR_capset 91 +#define __NR_personality 92 +#define __NR_exit 93 +#define __NR_exit_group 94 +#define __NR_waitid 95 +#define __NR_set_tid_address 96 +#define __NR_unshare 97 +#define __NR_futex 98 +#define __NR_set_robust_list 99 +#define __NR_get_robust_list 100 +#define __NR_nanosleep 101 +#define __NR_getitimer 102 +#define __NR_setitimer 103 +#define __NR_kexec_load 104 +#define __NR_init_module 105 +#define __NR_delete_module 106 +#define __NR_timer_create 107 +#define __NR_timer_gettime 108 +#define __NR_timer_getoverrun 109 +#define __NR_timer_settime 110 +#define __NR_timer_delete 111 +#define __NR_clock_settime 112 +#define __NR_clock_gettime 113 +#define __NR_clock_getres 114 +#define __NR_clock_nanosleep 115 +#define __NR_syslog 116 +#define __NR_ptrace 117 +#define __NR_sched_setparam 118 +#define __NR_sched_setscheduler 119 +#define __NR_sched_getscheduler 120 +#define __NR_sched_getparam 121 +#define __NR_sched_setaffinity 122 +#define __NR_sched_getaffinity 123 +#define __NR_sched_yield 124 +#define __NR_sched_get_priority_max 125 +#define __NR_sched_get_priority_min 126 +#define __NR_sched_rr_get_interval 127 +#define __NR_restart_syscall 128 +#define __NR_kill 129 +#define __NR_tkill 130 +#define __NR_tgkill 131 +#define __NR_sigaltstack 132 +#define __NR_rt_sigsuspend 133 +#define __NR_rt_sigaction 134 +#define __NR_rt_sigprocmask 135 +#define __NR_rt_sigpending 136 +#define __NR_rt_sigtimedwait 137 +#define __NR_rt_sigqueueinfo 138 +#define __NR_rt_sigreturn 139 +#define __NR_setpriority 140 +#define __NR_getpriority 141 +#define __NR_reboot 142 +#define __NR_setregid 143 +#define __NR_setgid 144 +#define __NR_setreuid 145 +#define __NR_setuid 146 +#define __NR_setresuid 147 +#define __NR_getresuid 148 +#define __NR_setresgid 149 +#define __NR_getresgid 150 +#define __NR_setfsuid 151 +#define __NR_setfsgid 152 +#define __NR_times 153 +#define __NR_setpgid 154 +#define __NR_getpgid 155 +#define __NR_getsid 156 +#define __NR_setsid 157 +#define __NR_getgroups 158 +#define __NR_setgroups 159 +#define __NR_uname 160 +#define __NR_sethostname 161 +#define __NR_setdomainname 162 +#define __NR_getrlimit 163 +#define __NR_setrlimit 164 +#define __NR_getrusage 165 +#define __NR_umask 166 +#define __NR_prctl 167 +#define __NR_getcpu 168 +#define __NR_gettimeofday 169 +#define __NR_settimeofday 170 +#define __NR_adjtimex 171 +#define __NR_getpid 172 +#define __NR_getppid 173 +#define __NR_getuid 174 +#define __NR_geteuid 175 +#define __NR_getgid 176 +#define __NR_getegid 177 +#define __NR_gettid 178 +#define __NR_sysinfo 179 +#define __NR_mq_open 180 +#define __NR_mq_unlink 181 +#define __NR_mq_timedsend 182 +#define __NR_mq_timedreceive 183 +#define __NR_mq_notify 184 +#define __NR_mq_getsetattr 185 +#define __NR_msgget 186 +#define __NR_msgctl 187 +#define __NR_msgrcv 188 +#define __NR_msgsnd 189 +#define __NR_semget 190 +#define __NR_semctl 191 +#define __NR_semtimedop 192 +#define __NR_semop 193 +#define __NR_shmget 194 +#define __NR_shmctl 195 +#define __NR_shmat 196 +#define __NR_shmdt 197 +#define __NR_socket 198 +#define __NR_socketpair 199 +#define __NR_bind 200 +#define __NR_listen 201 +#define __NR_accept 202 +#define __NR_connect 203 +#define __NR_getsockname 204 +#define __NR_getpeername 205 +#define __NR_sendto 206 +#define __NR_recvfrom 207 +#define __NR_setsockopt 208 +#define __NR_getsockopt 209 +#define __NR_shutdown 210 +#define __NR_sendmsg 211 +#define __NR_recvmsg 212 +#define __NR_readahead 213 +#define __NR_brk 214 +#define __NR_munmap 215 +#define __NR_mremap 216 +#define __NR_add_key 217 +#define __NR_request_key 218 +#define __NR_keyctl 219 +#define __NR_clone 220 +#define __NR_execve 221 +#define __NR_mmap 222 +#define __NR_fadvise64 223 +#define __NR_swapon 224 +#define __NR_swapoff 225 +#define __NR_mprotect 226 +#define __NR_msync 227 +#define __NR_mlock 228 +#define __NR_munlock 229 +#define __NR_mlockall 230 +#define __NR_munlockall 231 +#define __NR_mincore 232 +#define __NR_madvise 233 +#define __NR_remap_file_pages 234 +#define __NR_mbind 235 +#define __NR_get_mempolicy 236 +#define __NR_set_mempolicy 237 +#define __NR_migrate_pages 238 +#define __NR_move_pages 239 +#define __NR_rt_tgsigqueueinfo 240 +#define __NR_perf_event_open 241 +#define __NR_accept4 242 +#define __NR_recvmmsg 243 +#define __NR_wait4 260 +#define __NR_prlimit64 261 +#define __NR_fanotify_init 262 +#define __NR_fanotify_mark 263 +#define __NR_name_to_handle_at 264 +#define __NR_open_by_handle_at 265 +#define __NR_clock_adjtime 266 +#define __NR_syncfs 267 +#define __NR_setns 268 +#define __NR_sendmmsg 269 +#define __NR_process_vm_readv 270 +#define __NR_process_vm_writev 271 +#define __NR_kcmp 272 +#define __NR_finit_module 273 +#define __NR_sched_setattr 274 +#define __NR_sched_getattr 275 +#define __NR_renameat2 276 +#define __NR_seccomp 277 +#define __NR_getrandom 278 +#define __NR_memfd_create 279 +#define __NR_bpf 280 +#define __NR_execveat 281 +#define __NR_userfaultfd 282 +#define __NR_membarrier 283 +#define __NR_mlock2 284 +#define __NR_copy_file_range 285 +#define __NR_preadv2 286 +#define __NR_pwritev2 287 +#define __NR_pkey_mprotect 288 +#define __NR_pkey_alloc 289 +#define __NR_pkey_free 290 + +#define SYS_io_setup 0 +#define SYS_io_destroy 1 +#define SYS_io_submit 2 +#define SYS_io_cancel 3 +#define SYS_io_getevents 4 +#define SYS_setxattr 5 +#define SYS_lsetxattr 6 +#define SYS_fsetxattr 7 +#define SYS_getxattr 8 +#define SYS_lgetxattr 9 +#define SYS_fgetxattr 10 +#define SYS_listxattr 11 +#define SYS_llistxattr 12 +#define SYS_flistxattr 13 +#define SYS_removexattr 14 +#define SYS_lremovexattr 15 +#define SYS_fremovexattr 16 +#define SYS_getcwd 17 +#define SYS_lookup_dcookie 18 +#define SYS_eventfd2 19 +#define SYS_epoll_create1 20 +#define SYS_epoll_ctl 21 +#define SYS_epoll_pwait 22 +#define SYS_dup 23 +#define SYS_dup3 24 +#define SYS_fcntl 25 +#define SYS_inotify_init1 26 +#define SYS_inotify_add_watch 27 +#define SYS_inotify_rm_watch 28 +#define SYS_ioctl 29 +#define SYS_ioprio_set 30 +#define SYS_ioprio_get 31 +#define SYS_flock 32 +#define SYS_mknodat 33 +#define SYS_mkdirat 34 +#define SYS_unlinkat 35 +#define SYS_symlinkat 36 +#define SYS_linkat 37 +#define SYS_renameat 38 +#define SYS_umount2 39 +#define SYS_mount 40 +#define SYS_pivot_root 41 +#define SYS_nfsservctl 42 +#define SYS_statfs 43 +#define SYS_fstatfs 44 +#define SYS_truncate 45 +#define SYS_ftruncate 46 +#define SYS_fallocate 47 +#define SYS_faccessat 48 +#define SYS_chdir 49 +#define SYS_fchdir 50 +#define SYS_chroot 51 +#define SYS_fchmod 52 +#define SYS_fchmodat 53 +#define SYS_fchownat 54 +#define SYS_fchown 55 +#define SYS_openat 56 +#define SYS_close 57 +#define SYS_vhangup 58 +#define SYS_pipe2 59 +#define SYS_quotactl 60 +#define SYS_getdents64 61 +#define SYS_lseek 62 +#define SYS_read 63 +#define SYS_write 64 +#define SYS_readv 65 +#define SYS_writev 66 +#define SYS_pread64 67 +#define SYS_pwrite64 68 +#define SYS_preadv 69 +#define SYS_pwritev 70 +#define SYS_sendfile 71 +#define SYS_pselect6 72 +#define SYS_ppoll 73 +#define SYS_signalfd4 74 +#define SYS_vmsplice 75 +#define SYS_splice 76 +#define SYS_tee 77 +#define SYS_readlinkat 78 +#define SYS_newfstatat 79 +#define SYS_fstat 80 +#define SYS_sync 81 +#define SYS_fsync 82 +#define SYS_fdatasync 83 +#define SYS_sync_file_range 84 +#define SYS_timerfd_create 85 +#define SYS_timerfd_settime 86 +#define SYS_timerfd_gettime 87 +#define SYS_utimensat 88 +#define SYS_acct 89 +#define SYS_capget 90 +#define SYS_capset 91 +#define SYS_personality 92 +#define SYS_exit 93 +#define SYS_exit_group 94 +#define SYS_waitid 95 +#define SYS_set_tid_address 96 +#define SYS_unshare 97 +#define SYS_futex 98 +#define SYS_set_robust_list 99 +#define SYS_get_robust_list 100 +#define SYS_nanosleep 101 +#define SYS_getitimer 102 +#define SYS_setitimer 103 +#define SYS_kexec_load 104 +#define SYS_init_module 105 +#define SYS_delete_module 106 +#define SYS_timer_create 107 +#define SYS_timer_gettime 108 +#define SYS_timer_getoverrun 109 +#define SYS_timer_settime 110 +#define SYS_timer_delete 111 +#define SYS_clock_settime 112 +#define SYS_clock_gettime 113 +#define SYS_clock_getres 114 +#define SYS_clock_nanosleep 115 +#define SYS_syslog 116 +#define SYS_ptrace 117 +#define SYS_sched_setparam 118 +#define SYS_sched_setscheduler 119 +#define SYS_sched_getscheduler 120 +#define SYS_sched_getparam 121 +#define SYS_sched_setaffinity 122 +#define SYS_sched_getaffinity 123 +#define SYS_sched_yield 124 +#define SYS_sched_get_priority_max 125 +#define SYS_sched_get_priority_min 126 +#define SYS_sched_rr_get_interval 127 +#define SYS_restart_syscall 128 +#define SYS_kill 129 +#define SYS_tkill 130 +#define SYS_tgkill 131 +#define SYS_sigaltstack 132 +#define SYS_rt_sigsuspend 133 +#define SYS_rt_sigaction 134 +#define SYS_rt_sigprocmask 135 +#define SYS_rt_sigpending 136 +#define SYS_rt_sigtimedwait 137 +#define SYS_rt_sigqueueinfo 138 +#define SYS_rt_sigreturn 139 +#define SYS_setpriority 140 +#define SYS_getpriority 141 +#define SYS_reboot 142 +#define SYS_setregid 143 +#define SYS_setgid 144 +#define SYS_setreuid 145 +#define SYS_setuid 146 +#define SYS_setresuid 147 +#define SYS_getresuid 148 +#define SYS_setresgid 149 +#define SYS_getresgid 150 +#define SYS_setfsuid 151 +#define SYS_setfsgid 152 +#define SYS_times 153 +#define SYS_setpgid 154 +#define SYS_getpgid 155 +#define SYS_getsid 156 +#define SYS_setsid 157 +#define SYS_getgroups 158 +#define SYS_setgroups 159 +#define SYS_uname 160 +#define SYS_sethostname 161 +#define SYS_setdomainname 162 +#define SYS_getrlimit 163 +#define SYS_setrlimit 164 +#define SYS_getrusage 165 +#define SYS_umask 166 +#define SYS_prctl 167 +#define SYS_getcpu 168 +#define SYS_gettimeofday 169 +#define SYS_settimeofday 170 +#define SYS_adjtimex 171 +#define SYS_getpid 172 +#define SYS_getppid 173 +#define SYS_getuid 174 +#define SYS_geteuid 175 +#define SYS_getgid 176 +#define SYS_getegid 177 +#define SYS_gettid 178 +#define SYS_sysinfo 179 +#define SYS_mq_open 180 +#define SYS_mq_unlink 181 +#define SYS_mq_timedsend 182 +#define SYS_mq_timedreceive 183 +#define SYS_mq_notify 184 +#define SYS_mq_getsetattr 185 +#define SYS_msgget 186 +#define SYS_msgctl 187 +#define SYS_msgrcv 188 +#define SYS_msgsnd 189 +#define SYS_semget 190 +#define SYS_semctl 191 +#define SYS_semtimedop 192 +#define SYS_semop 193 +#define SYS_shmget 194 +#define SYS_shmctl 195 +#define SYS_shmat 196 +#define SYS_shmdt 197 +#define SYS_socket 198 +#define SYS_socketpair 199 +#define SYS_bind 200 +#define SYS_listen 201 +#define SYS_accept 202 +#define SYS_connect 203 +#define SYS_getsockname 204 +#define SYS_getpeername 205 +#define SYS_sendto 206 +#define SYS_recvfrom 207 +#define SYS_setsockopt 208 +#define SYS_getsockopt 209 +#define SYS_shutdown 210 +#define SYS_sendmsg 211 +#define SYS_recvmsg 212 +#define SYS_readahead 213 +#define SYS_brk 214 +#define SYS_munmap 215 +#define SYS_mremap 216 +#define SYS_add_key 217 +#define SYS_request_key 218 +#define SYS_keyctl 219 +#define SYS_clone 220 +#define SYS_execve 221 +#define SYS_mmap 222 +#define SYS_fadvise64 223 +#define SYS_swapon 224 +#define SYS_swapoff 225 +#define SYS_mprotect 226 +#define SYS_msync 227 +#define SYS_mlock 228 +#define SYS_munlock 229 +#define SYS_mlockall 230 +#define SYS_munlockall 231 +#define SYS_mincore 232 +#define SYS_madvise 233 +#define SYS_remap_file_pages 234 +#define SYS_mbind 235 +#define SYS_get_mempolicy 236 +#define SYS_set_mempolicy 237 +#define SYS_migrate_pages 238 +#define SYS_move_pages 239 +#define SYS_rt_tgsigqueueinfo 240 +#define SYS_perf_event_open 241 +#define SYS_accept4 242 +#define SYS_recvmmsg 243 +#define SYS_wait4 260 +#define SYS_prlimit64 261 +#define SYS_fanotify_init 262 +#define SYS_fanotify_mark 263 +#define SYS_name_to_handle_at 264 +#define SYS_open_by_handle_at 265 +#define SYS_clock_adjtime 266 +#define SYS_syncfs 267 +#define SYS_setns 268 +#define SYS_sendmmsg 269 +#define SYS_process_vm_readv 270 +#define SYS_process_vm_writev 271 +#define SYS_kcmp 272 +#define SYS_finit_module 273 +#define SYS_sched_setattr 274 +#define SYS_sched_getattr 275 +#define SYS_renameat2 276 +#define SYS_seccomp 277 +#define SYS_getrandom 278 +#define SYS_memfd_create 279 +#define SYS_bpf 280 +#define SYS_execveat 281 +#define SYS_userfaultfd 282 +#define SYS_membarrier 283 +#define SYS_mlock2 284 +#define SYS_copy_file_range 285 +#define SYS_preadv2 286 +#define SYS_pwritev2 287 +#define SYS_pkey_mprotect 288 +#define SYS_pkey_alloc 289 +#define SYS_pkey_free 290 diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h.in b/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h.in new file mode 100644 index 0000000..93648af --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h.in @@ -0,0 +1,292 @@ +#define __NR_io_setup 0 +#define __NR_io_destroy 1 +#define __NR_io_submit 2 +#define __NR_io_cancel 3 +#define __NR_io_getevents 4 +#define __NR_setxattr 5 +#define __NR_lsetxattr 6 +#define __NR_fsetxattr 7 +#define __NR_getxattr 8 +#define __NR_lgetxattr 9 +#define __NR_fgetxattr 10 +#define __NR_listxattr 11 +#define __NR_llistxattr 12 +#define __NR_flistxattr 13 +#define __NR_removexattr 14 +#define __NR_lremovexattr 15 +#define __NR_fremovexattr 16 +#define __NR_getcwd 17 +#define __NR_lookup_dcookie 18 +#define __NR_eventfd2 19 +#define __NR_epoll_create1 20 +#define __NR_epoll_ctl 21 +#define __NR_epoll_pwait 22 +#define __NR_dup 23 +#define __NR_dup3 24 +#define __NR_fcntl 25 +#define __NR_inotify_init1 26 +#define __NR_inotify_add_watch 27 +#define __NR_inotify_rm_watch 28 +#define __NR_ioctl 29 +#define __NR_ioprio_set 30 +#define __NR_ioprio_get 31 +#define __NR_flock 32 +#define __NR_mknodat 33 +#define __NR_mkdirat 34 +#define __NR_unlinkat 35 +#define __NR_symlinkat 36 +#define __NR_linkat 37 +#define __NR_renameat 38 +#define __NR_umount2 39 +#define __NR_mount 40 +#define __NR_pivot_root 41 +#define __NR_nfsservctl 42 +#define __NR_statfs 43 +#define __NR_fstatfs 44 +#define __NR_truncate 45 +#define __NR_ftruncate 46 +#define __NR_fallocate 47 +#define __NR_faccessat 48 +#define __NR_chdir 49 +#define __NR_fchdir 50 +#define __NR_chroot 51 +#define __NR_fchmod 52 +#define __NR_fchmodat 53 +#define __NR_fchownat 54 +#define __NR_fchown 55 +#define __NR_openat 56 +#define __NR_close 57 +#define __NR_vhangup 58 +#define __NR_pipe2 59 +#define __NR_quotactl 60 +#define __NR_getdents64 61 +#define __NR_lseek 62 +#define __NR_read 63 +#define __NR_write 64 +#define __NR_readv 65 +#define __NR_writev 66 +#define __NR_pread64 67 +#define __NR_pwrite64 68 +#define __NR_preadv 69 +#define __NR_pwritev 70 +#define __NR_sendfile 71 +#define __NR_pselect6 72 +#define __NR_ppoll 73 +#define __NR_signalfd4 74 +#define __NR_vmsplice 75 +#define __NR_splice 76 +#define __NR_tee 77 +#define __NR_readlinkat 78 +#define __NR_newfstatat 79 +#define __NR_fstat 80 +#define __NR_sync 81 +#define __NR_fsync 82 +#define __NR_fdatasync 83 +#define __NR_sync_file_range 84 +#define __NR_timerfd_create 85 +#define __NR_timerfd_settime 86 +#define __NR_timerfd_gettime 87 +#define __NR_utimensat 88 +#define __NR_acct 89 +#define __NR_capget 90 +#define __NR_capset 91 +#define __NR_personality 92 +#define __NR_exit 93 +#define __NR_exit_group 94 +#define __NR_waitid 95 +#define __NR_set_tid_address 96 +#define __NR_unshare 97 +#define __NR_futex 98 +#define __NR_set_robust_list 99 +#define __NR_get_robust_list 100 +#define __NR_nanosleep 101 +#define __NR_getitimer 102 +#define __NR_setitimer 103 +#define __NR_kexec_load 104 +#define __NR_init_module 105 +#define __NR_delete_module 106 +#define __NR_timer_create 107 +#define __NR_timer_gettime 108 +#define __NR_timer_getoverrun 109 +#define __NR_timer_settime 110 +#define __NR_timer_delete 111 +#define __NR_clock_settime 112 +#define __NR_clock_gettime 113 +#define __NR_clock_getres 114 +#define __NR_clock_nanosleep 115 +#define __NR_syslog 116 +#define __NR_ptrace 117 +#define __NR_sched_setparam 118 +#define __NR_sched_setscheduler 119 +#define __NR_sched_getscheduler 120 +#define __NR_sched_getparam 121 +#define __NR_sched_setaffinity 122 +#define __NR_sched_getaffinity 123 +#define __NR_sched_yield 124 +#define __NR_sched_get_priority_max 125 +#define __NR_sched_get_priority_min 126 +#define __NR_sched_rr_get_interval 127 +#define __NR_restart_syscall 128 +#define __NR_kill 129 +#define __NR_tkill 130 +#define __NR_tgkill 131 +#define __NR_sigaltstack 132 +#define __NR_rt_sigsuspend 133 +#define __NR_rt_sigaction 134 +#define __NR_rt_sigprocmask 135 +#define __NR_rt_sigpending 136 +#define __NR_rt_sigtimedwait 137 +#define __NR_rt_sigqueueinfo 138 +#define __NR_rt_sigreturn 139 +#define __NR_setpriority 140 +#define __NR_getpriority 141 +#define __NR_reboot 142 +#define __NR_setregid 143 +#define __NR_setgid 144 +#define __NR_setreuid 145 +#define __NR_setuid 146 +#define __NR_setresuid 147 +#define __NR_getresuid 148 +#define __NR_setresgid 149 +#define __NR_getresgid 150 +#define __NR_setfsuid 151 +#define __NR_setfsgid 152 +#define __NR_times 153 +#define __NR_setpgid 154 +#define __NR_getpgid 155 +#define __NR_getsid 156 +#define __NR_setsid 157 +#define __NR_getgroups 158 +#define __NR_setgroups 159 +#define __NR_uname 160 +#define __NR_sethostname 161 +#define __NR_setdomainname 162 +#define __NR_getrlimit 163 +#define __NR_setrlimit 164 +#define __NR_getrusage 165 +#define __NR_umask 166 +#define __NR_prctl 167 +#define __NR_getcpu 168 +#define __NR_gettimeofday 169 +#define __NR_settimeofday 170 +#define __NR_adjtimex 171 +#define __NR_getpid 172 +#define __NR_getppid 173 +#define __NR_getuid 174 +#define __NR_geteuid 175 +#define __NR_getgid 176 +#define __NR_getegid 177 +#define __NR_gettid 178 +#define __NR_sysinfo 179 +#define __NR_mq_open 180 +#define __NR_mq_unlink 181 +#define __NR_mq_timedsend 182 +#define __NR_mq_timedreceive 183 +#define __NR_mq_notify 184 +#define __NR_mq_getsetattr 185 +#define __NR_msgget 186 +#define __NR_msgctl 187 +#define __NR_msgrcv 188 +#define __NR_msgsnd 189 +#define __NR_semget 190 +#define __NR_semctl 191 +#define __NR_semtimedop 192 +#define __NR_semop 193 +#define __NR_shmget 194 +#define __NR_shmctl 195 +#define __NR_shmat 196 +#define __NR_shmdt 197 +#define __NR_socket 198 +#define __NR_socketpair 199 +#define __NR_bind 200 +#define __NR_listen 201 +#define __NR_accept 202 +#define __NR_connect 203 +#define __NR_getsockname 204 +#define __NR_getpeername 205 +#define __NR_sendto 206 +#define __NR_recvfrom 207 +#define __NR_setsockopt 208 +#define __NR_getsockopt 209 +#define __NR_shutdown 210 +#define __NR_sendmsg 211 +#define __NR_recvmsg 212 +#define __NR_readahead 213 +#define __NR_brk 214 +#define __NR_munmap 215 +#define __NR_mremap 216 +#define __NR_add_key 217 +#define __NR_request_key 218 +#define __NR_keyctl 219 +#define __NR_clone 220 +#define __NR_execve 221 +#define __NR_mmap 222 +#define __NR_fadvise64 223 +#define __NR_swapon 224 +#define __NR_swapoff 225 +#define __NR_mprotect 226 +#define __NR_msync 227 +#define __NR_mlock 228 +#define __NR_munlock 229 +#define __NR_mlockall 230 +#define __NR_munlockall 231 +#define __NR_mincore 232 +#define __NR_madvise 233 +#define __NR_remap_file_pages 234 +#define __NR_mbind 235 +#define __NR_get_mempolicy 236 +#define __NR_set_mempolicy 237 +#define __NR_migrate_pages 238 +#define __NR_move_pages 239 +#define __NR_rt_tgsigqueueinfo 240 +#define __NR_perf_event_open 241 +#define __NR_accept4 242 +#define __NR_recvmmsg 243 +#define __NR_wait4 260 +#define __NR_prlimit64 261 +#define __NR_fanotify_init 262 +#define __NR_fanotify_mark 263 +#define __NR_name_to_handle_at 264 +#define __NR_open_by_handle_at 265 +#define __NR_clock_adjtime 266 +#define __NR_syncfs 267 +#define __NR_setns 268 +#define __NR_sendmmsg 269 +#define __NR_process_vm_readv 270 +#define __NR_process_vm_writev 271 +#define __NR_kcmp 272 +#define __NR_finit_module 273 +#define __NR_sched_setattr 274 +#define __NR_sched_getattr 275 +#define __NR_renameat2 276 +#define __NR_seccomp 277 +#define __NR_getrandom 278 +#define __NR_memfd_create 279 +#define __NR_bpf 280 +#define __NR_execveat 281 +#define __NR_userfaultfd 282 +#define __NR_membarrier 283 +#define __NR_mlock2 284 +#define __NR_copy_file_range 285 +#define __NR_preadv2 286 +#define __NR_pwritev2 287 +#define __NR_pkey_mprotect 288 +#define __NR_pkey_alloc 289 +#define __NR_pkey_free 290 +#define __NR_statx 291 +#define __NR_io_pgetevents 292 +#define __NR_rseq 293 +#define __NR_kexec_file_load 294 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 + diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/user.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/user.h new file mode 100644 index 0000000..d12cdf7 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/user.h @@ -0,0 +1,16 @@ +struct user_regs_struct { + unsigned long long regs[31]; + unsigned long long sp; + unsigned long long pc; + unsigned long long pstate; +}; + +struct user_fpsimd_struct { + long double vregs[32]; + unsigned int fpsr; + unsigned int fpcr; +}; + +#define ELF_NREG 34 +typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NREG]; +typedef struct user_fpsimd_struct elf_fpregset_t; diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/crt_arch.h b/thirdparty/open_source/musl/libc/arch/aarch64/crt_arch.h new file mode 100644 index 0000000..7643269 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/crt_arch.h @@ -0,0 +1,24 @@ +#ifndef AARCH64_CRT_ARCH_H +#define AARCH64_CRT_ARCH_H + +__asm__( +".text\n" +".global " START "\n" +".type " START ",%function\n" +START ":\n" +" mov x29, #0\n" +" mov x30, #0\n" +" ldr x18, [x0, #16]\n" /* paratbl */ +" str x1, [x18, #40]\n" /* PT_ZERO1 */ +" str x2, [x18, #48]\n" /* PT_ZERO2 */ +".weak _DYNAMIC\n" +".hidden _DYNAMIC\n" +" adrp x1, _DYNAMIC\n" +" add x1, x1, #:lo12:_DYNAMIC\n" +" mov x18, sp\n" +" and x18, x18, #-16\n" +" mov sp, x18\n" +" b " START "_c\n" +); + +#endif \ No newline at end of file diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/fp_arch.h b/thirdparty/open_source/musl/libc/arch/aarch64/fp_arch.h new file mode 100644 index 0000000..f3d445b --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/fp_arch.h @@ -0,0 +1,25 @@ +#define fp_barrierf fp_barrierf +static inline float fp_barrierf(float x) +{ + __asm__ __volatile__ ("" : "+w"(x)); + return x; +} + +#define fp_barrier fp_barrier +static inline double fp_barrier(double x) +{ + __asm__ __volatile__ ("" : "+w"(x)); + return x; +} + +#define fp_force_evalf fp_force_evalf +static inline void fp_force_evalf(float x) +{ + __asm__ __volatile__ ("" : "+w"(x)); +} + +#define fp_force_eval fp_force_eval +static inline void fp_force_eval(double x) +{ + __asm__ __volatile__ ("" : "+w"(x)); +} diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/kstat.h b/thirdparty/open_source/musl/libc/arch/aarch64/kstat.h new file mode 100644 index 0000000..92625f3 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + unsigned long __pad; + off_t st_size; + blksize_t st_blksize; + int __pad2; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned __unused[2]; +}; diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/pthread_arch.h b/thirdparty/open_source/musl/libc/arch/aarch64/pthread_arch.h new file mode 100644 index 0000000..e64b126 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/pthread_arch.h @@ -0,0 +1,12 @@ +static inline struct pthread *__pthread_self() +{ + char *self; + __asm__ ("mrs %0,tpidr_el0" : "=r"(self)); + return (void*)(self - sizeof(struct pthread)); +} + +#define TLS_ABOVE_TP +#define GAP_ABOVE_TP 16 +#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread)) + +#define MC_PC pc diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/reloc.h b/thirdparty/open_source/musl/libc/arch/aarch64/reloc.h new file mode 100644 index 0000000..b1b68c7 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/reloc.h @@ -0,0 +1,24 @@ +#if __BYTE_ORDER == __BIG_ENDIAN +#define ENDIAN_SUFFIX "_be" +#else +#define ENDIAN_SUFFIX "" +#endif + +#define LDSO_ARCH "aarch64" ENDIAN_SUFFIX + +#define NO_LEGACY_INITFINI + +#define TPOFF_K 0 + +#define REL_SYMBOLIC R_AARCH64_ABS64 +#define REL_GOT R_AARCH64_GLOB_DAT +#define REL_PLT R_AARCH64_JUMP_SLOT +#define REL_RELATIVE R_AARCH64_RELATIVE +#define REL_COPY R_AARCH64_COPY +#define REL_DTPMOD R_AARCH64_TLS_DTPMOD64 +#define REL_DTPOFF R_AARCH64_TLS_DTPREL64 +#define REL_TPOFF R_AARCH64_TLS_TPREL64 +#define REL_TLSDESC R_AARCH64_TLSDESC + +#define CRTJMP(pc,sp) __asm__ __volatile__( \ + "mov sp,%1 ; br %0" : : "r"(pc), "r"(sp) : "memory" ) diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/syscall_arch.h b/thirdparty/open_source/musl/libc/arch/aarch64/syscall_arch.h new file mode 100644 index 0000000..504983a --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/aarch64/syscall_arch.h @@ -0,0 +1,78 @@ +#define __SYSCALL_LL_E(x) (x) +#define __SYSCALL_LL_O(x) (x) + +#define __asm_syscall(...) do { \ + __asm__ __volatile__ ( "svc 0" \ + : "=r"(x0) : __VA_ARGS__ : "memory", "cc"); \ + return x0; \ + } while (0) + +static inline long __syscall0(long n) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0"); + __asm_syscall("r"(x8)); +} + +static inline long __syscall1(long n, long a) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + __asm_syscall("r"(x8), "0"(x0)); +} + +static inline long __syscall2(long n, long a, long b) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + register long x1 __asm__("x1") = b; + __asm_syscall("r"(x8), "0"(x0), "r"(x1)); +} + +static inline long __syscall3(long n, long a, long b, long c) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + register long x1 __asm__("x1") = b; + register long x2 __asm__("x2") = c; + __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2)); +} + +static inline long __syscall4(long n, long a, long b, long c, long d) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + register long x1 __asm__("x1") = b; + register long x2 __asm__("x2") = c; + register long x3 __asm__("x3") = d; + __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3)); +} + +static inline long __syscall5(long n, long a, long b, long c, long d, long e) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + register long x1 __asm__("x1") = b; + register long x2 __asm__("x2") = c; + register long x3 __asm__("x3") = d; + register long x4 __asm__("x4") = e; + __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4)); +} + +static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f) +{ + register long x8 __asm__("x8") = n; + register long x0 __asm__("x0") = a; + register long x1 __asm__("x1") = b; + register long x2 __asm__("x2") = c; + register long x3 __asm__("x3") = d; + register long x4 __asm__("x4") = e; + register long x5 __asm__("x5") = f; + __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5)); +} + +#define VDSO_USEFUL +#define VDSO_CGT_SYM "__kernel_clock_gettime" +#define VDSO_CGT_VER "LINUX_2.6.39" + +#define IPC_64 0 diff --git a/thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h b/thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h new file mode 100644 index 0000000..41b4204 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h @@ -0,0 +1,448 @@ +#define _Addr int +#define _Int64 long long +#define _Reg int + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __USE_TIME_BITS64 1 + +#ifndef __BYTE_ORDER +#if __AARCH64EB__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif +#endif + +#define __LONG_MAX 0x7fffffffL + +#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) +typedef __builtin_va_list va_list; +#define __DEFINED_va_list +#endif + +#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list) +typedef __builtin_va_list __isoc_va_list; +#define __DEFINED___isoc_va_list +#endif + +#ifndef __cplusplus +#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t) +typedef unsigned wchar_t; +#define __DEFINED_wchar_t +#endif + +#endif + +#if defined(__NEED_float_t) && !defined(__DEFINED_float_t) +typedef float float_t; +#define __DEFINED_float_t +#endif + +#if defined(__NEED_double_t) && !defined(__DEFINED_double_t) +typedef double double_t; +#define __DEFINED_double_t +#endif + +#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t) +typedef struct { + long long __ll; + long double __ld; +} max_align_t; +#define __DEFINED_max_align_t +#endif + +#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) +typedef long time_t; +#define __DEFINED_time_t +#endif + +#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) +typedef long suseconds_t; +#define __DEFINED_suseconds_t +#endif + +#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) +typedef struct { + union { + int __i[9]; + volatile int __vi[9]; + unsigned __s[9]; + } __u; +} pthread_attr_t; +#define __DEFINED_pthread_attr_t +#endif + +#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t) +typedef struct { + union { + int __i[6]; + volatile int __vi[6]; + volatile void *volatile __p[6]; + } __u; +} pthread_mutex_t; +#define __DEFINED_pthread_mutex_t +#endif + +#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t) +typedef struct { + union { + int __i[6]; + volatile int __vi[6]; + volatile void *volatile __p[6]; + } __u; +} mtx_t; +#define __DEFINED_mtx_t +#endif + +#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t) +typedef struct { + union { + int __i[12]; + volatile int __vi[12]; + void *__p[12]; + } __u; +} pthread_cond_t; +#define __DEFINED_pthread_cond_t +#endif + +#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t) +typedef struct { + union { + int __i[12]; + volatile int __vi[12]; + void *__p[12]; + } __u; +} cnd_t; +#define __DEFINED_cnd_t +#endif + +#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) +typedef struct { + union { + int __i[8]; + volatile int __vi[8]; + void *__p[8]; + } __u; +} pthread_rwlock_t; +#define __DEFINED_pthread_rwlock_t +#endif + +#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t) +typedef struct { + union { + int __i[5]; + volatile int __vi[5]; + void *__p[5]; + } __u; +} pthread_barrier_t; +#define __DEFINED_pthread_barrier_t +#endif + +#if defined(__NEED_size_t) && !defined(__DEFINED_size_t) +typedef unsigned _Addr size_t; +#define __DEFINED_size_t +#endif + +#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t) +typedef unsigned _Addr uintptr_t; +#define __DEFINED_uintptr_t +#endif + +#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t) +typedef _Addr ptrdiff_t; +#define __DEFINED_ptrdiff_t +#endif + +#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t) +typedef _Addr ssize_t; +#define __DEFINED_ssize_t +#endif + +#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t) +typedef _Addr intptr_t; +#define __DEFINED_intptr_t +#endif + +#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t) +typedef _Addr regoff_t; +#define __DEFINED_regoff_t +#endif + +#if defined(__NEED_register_t) && !defined(__DEFINED_register_t) +typedef _Reg register_t; +#define __DEFINED_register_t +#endif + +#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t) +typedef signed char int8_t; +#define __DEFINED_int8_t +#endif + +#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t) +typedef short int16_t; +#define __DEFINED_int16_t +#endif + +#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t) +typedef int int32_t; +#define __DEFINED_int32_t +#endif + +#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t) +typedef _Int64 int64_t; +#define __DEFINED_int64_t +#endif + +#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t) +typedef _Int64 intmax_t; +#define __DEFINED_intmax_t +#endif + +#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t) +typedef unsigned char uint8_t; +#define __DEFINED_uint8_t +#endif + +#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t) +typedef unsigned short uint16_t; +#define __DEFINED_uint16_t +#endif + +#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t) +typedef unsigned int uint32_t; +#define __DEFINED_uint32_t +#endif + +#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t) +typedef unsigned _Int64 uint64_t; +#define __DEFINED_uint64_t +#endif + +#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t) +typedef unsigned _Int64 u_int64_t; +#define __DEFINED_u_int64_t +#endif + +#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t) +typedef unsigned _Int64 uintmax_t; +#define __DEFINED_uintmax_t +#endif + +#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t) +typedef unsigned mode_t; +#define __DEFINED_mode_t +#endif + +#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t) +typedef unsigned _Reg nlink_t; +#define __DEFINED_nlink_t +#endif + +#if defined(__NEED_off_t) && !defined(__DEFINED_off_t) +typedef _Int64 off_t; +#define __DEFINED_off_t +#endif + +#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t) +typedef unsigned _Int64 ino_t; +#define __DEFINED_ino_t +#endif + +#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t) +typedef unsigned _Int64 dev_t; +#define __DEFINED_dev_t +#endif + +#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t) +typedef long blksize_t; +#define __DEFINED_blksize_t +#endif + +#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t) +typedef _Int64 blkcnt_t; +#define __DEFINED_blkcnt_t +#endif + +#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t) +typedef unsigned _Int64 fsblkcnt_t; +#define __DEFINED_fsblkcnt_t +#endif + +#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t) +typedef unsigned _Int64 fsfilcnt_t; +#define __DEFINED_fsfilcnt_t +#endif + +#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t) +typedef unsigned wint_t; +#define __DEFINED_wint_t +#endif + +#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t) +typedef unsigned long wctype_t; +#define __DEFINED_wctype_t +#endif + +#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t) +typedef void *timer_t; +#define __DEFINED_timer_t +#endif + +#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t) +typedef int clockid_t; +#define __DEFINED_clockid_t +#endif + +#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t) +typedef long clock_t; +#define __DEFINED_clock_t +#endif + +#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval) +struct timeval { + time_t tv_sec; + suseconds_t tv_usec; +}; +#define __DEFINED_struct_timeval +#endif + +#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#define __DEFINED_struct_timespec +#endif + +#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t) +typedef int pid_t; +#define __DEFINED_pid_t +#endif + +#if defined(__NEED_id_t) && !defined(__DEFINED_id_t) +typedef unsigned id_t; +#define __DEFINED_id_t +#endif + +#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t) +typedef unsigned uid_t; +#define __DEFINED_uid_t +#endif + +#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t) +typedef unsigned gid_t; +#define __DEFINED_gid_t +#endif + +#if defined(__NEED_key_t) && !defined(__DEFINED_key_t) +typedef int key_t; +#define __DEFINED_key_t +#endif + +#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t) +typedef unsigned useconds_t; +#define __DEFINED_useconds_t +#endif + +#ifdef __cplusplus +#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) +typedef unsigned long pthread_t; +#define __DEFINED_pthread_t +#endif + +#else +#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) +typedef struct __pthread *pthread_t; +#define __DEFINED_pthread_t +#endif + +#endif +#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t) +typedef int pthread_once_t; +#define __DEFINED_pthread_once_t +#endif + +#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t) +typedef unsigned pthread_key_t; +#define __DEFINED_pthread_key_t +#endif + +#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t) +typedef int pthread_spinlock_t; +#define __DEFINED_pthread_spinlock_t +#endif + +#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t) +typedef struct { + unsigned __attr; +} pthread_mutexattr_t; +#define __DEFINED_pthread_mutexattr_t +#endif + +#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t) +typedef struct { + unsigned __attr; +} pthread_condattr_t; +#define __DEFINED_pthread_condattr_t +#endif + +#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t) +typedef struct { + unsigned __attr; +} pthread_barrierattr_t; +#define __DEFINED_pthread_barrierattr_t +#endif + +#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t) +typedef struct { + unsigned __attr[2]; +} pthread_rwlockattr_t; +#define __DEFINED_pthread_rwlockattr_t +#endif + +#if defined(__NEED_FILE) && !defined(__DEFINED_FILE) +typedef struct _IO_FILE FILE; +#define __DEFINED_FILE +#endif + +#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t) +typedef struct __mbstate_t { + unsigned __opaque1, __opaque2; +} mbstate_t; +#define __DEFINED_mbstate_t +#endif + +#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t) +typedef struct __locale_struct *locale_t; +#define __DEFINED_locale_t +#endif + +#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t) +typedef struct __sigset_t { + unsigned long __bits[128 / sizeof(long)]; +} sigset_t; +#define __DEFINED_sigset_t +#endif + +#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec) +struct iovec { + void *iov_base; + size_t iov_len; +}; +#define __DEFINED_struct_iovec +#endif + +#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) +typedef unsigned socklen_t; +#define __DEFINED_socklen_t +#endif + +#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t) +typedef unsigned short sa_family_t; +#define __DEFINED_sa_family_t +#endif + +#undef _Addr +#undef _Int64 +#undef _Reg diff --git a/thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h b/thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h new file mode 100644 index 0000000..6b128e5 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h @@ -0,0 +1,715 @@ +#define __NR_restart_syscall 0 +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_lchown 16 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_ptrace 26 +#define __NR_pause 29 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_setpgid 57 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_symlink 83 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_vhangup 111 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +#define __NR_poll 168 +#define __NR_nfsservctl 169 +#define __NR_setresgid 170 +#define __NR_getresgid 171 +#define __NR_prctl 172 +#define __NR_rt_sigreturn 173 +#define __NR_rt_sigaction 174 +#define __NR_rt_sigprocmask 175 +#define __NR_rt_sigpending 176 +#define __NR_rt_sigtimedwait 177 +#define __NR_rt_sigqueueinfo 178 +#define __NR_rt_sigsuspend 179 +#define __NR_pread64 180 +#define __NR_pwrite64 181 +#define __NR_chown 182 +#define __NR_getcwd 183 +#define __NR_capget 184 +#define __NR_capset 185 +#define __NR_sigaltstack 186 +#define __NR_sendfile 187 +#define __NR_vfork 190 +#define __NR_ugetrlimit 191 +#define __NR_mmap2 192 +#define __NR_truncate64 193 +#define __NR_ftruncate64 194 +#define __NR_stat64 195 +#define __NR_lstat64 196 +#define __NR_fstat64 197 +#define __NR_lchown32 198 +#define __NR_getuid32 199 +#define __NR_getgid32 200 +#define __NR_geteuid32 201 +#define __NR_getegid32 202 +#define __NR_setreuid32 203 +#define __NR_setregid32 204 +#define __NR_getgroups32 205 +#define __NR_setgroups32 206 +#define __NR_fchown32 207 +#define __NR_setresuid32 208 +#define __NR_getresuid32 209 +#define __NR_setresgid32 210 +#define __NR_getresgid32 211 +#define __NR_chown32 212 +#define __NR_setuid32 213 +#define __NR_setgid32 214 +#define __NR_setfsuid32 215 +#define __NR_setfsgid32 216 +#define __NR_getdents64 217 +#define __NR_pivot_root 218 +#define __NR_mincore 219 +#define __NR_madvise 220 +#define __NR_fcntl64 221 +#define __NR_gettid 224 +#define __NR_readahead 225 +#define __NR_setxattr 226 +#define __NR_lsetxattr 227 +#define __NR_fsetxattr 228 +#define __NR_getxattr 229 +#define __NR_lgetxattr 230 +#define __NR_fgetxattr 231 +#define __NR_listxattr 232 +#define __NR_llistxattr 233 +#define __NR_flistxattr 234 +#define __NR_removexattr 235 +#define __NR_lremovexattr 236 +#define __NR_fremovexattr 237 +#define __NR_tkill 238 +#define __NR_sendfile64 239 +#define __NR_futex 240 +#define __NR_sched_setaffinity 241 +#define __NR_sched_getaffinity 242 +#define __NR_io_setup 243 +#define __NR_io_destroy 244 +#define __NR_io_getevents 245 +#define __NR_io_submit 246 +#define __NR_io_cancel 247 +#define __NR_exit_group 248 +#define __NR_lookup_dcookie 249 +#define __NR_epoll_create 250 +#define __NR_epoll_ctl 251 +#define __NR_epoll_wait 252 +#define __NR_remap_file_pages 253 +#define __NR_set_tid_address 256 +#define __NR_timer_create 257 +#define __NR_timer_settime 258 +#define __NR_timer_gettime 259 +#define __NR_timer_getoverrun 260 +#define __NR_timer_delete 261 +#define __NR_clock_settime 262 +#define __NR_clock_gettime 263 +#define __NR_clock_getres 264 +#define __NR_clock_nanosleep 265 +#define __NR_statfs64 266 +#define __NR_fstatfs64 267 +#define __NR_tgkill 268 +#define __NR_utimes 269 +#define __NR_fadvise64_64 270 +#define __NR_arm_fadvise64_64 270 +#define __NR_pciconfig_iobase 271 +#define __NR_pciconfig_read 272 +#define __NR_pciconfig_write 273 +#define __NR_mq_open 274 +#define __NR_mq_unlink 275 +#define __NR_mq_timedsend 276 +#define __NR_mq_timedreceive 277 +#define __NR_mq_notify 278 +#define __NR_mq_getsetattr 279 +#define __NR_waitid 280 +#define __NR_socket 281 +#define __NR_bind 282 +#define __NR_connect 283 +#define __NR_listen 284 +#define __NR_accept 285 +#define __NR_getsockname 286 +#define __NR_getpeername 287 +#define __NR_socketpair 288 +#define __NR_send 289 +#define __NR_sendto 290 +#define __NR_recv 291 +#define __NR_recvfrom 292 +#define __NR_shutdown 293 +#define __NR_setsockopt 294 +#define __NR_getsockopt 295 +#define __NR_sendmsg 296 +#define __NR_recvmsg 297 +#define __NR_semop 298 +#define __NR_semget 299 +#define __NR_semctl 300 +#define __NR_msgsnd 301 +#define __NR_msgrcv 302 +#define __NR_msgget 303 +#define __NR_msgctl 304 +#define __NR_shmat 305 +#define __NR_shmdt 306 +#define __NR_shmget 307 +#define __NR_shmctl 308 +#define __NR_add_key 309 +#define __NR_request_key 310 +#define __NR_keyctl 311 +#define __NR_semtimedop 312 +#define __NR_vserver 313 +#define __NR_ioprio_set 314 +#define __NR_ioprio_get 315 +#define __NR_inotify_init 316 +#define __NR_inotify_add_watch 317 +#define __NR_inotify_rm_watch 318 +#define __NR_mbind 319 +#define __NR_get_mempolicy 320 +#define __NR_set_mempolicy 321 +#define __NR_openat 322 +#define __NR_mkdirat 323 +#define __NR_mknodat 324 +#define __NR_fchownat 325 +#define __NR_futimesat 326 +#define __NR_fstatat64 327 +#define __NR_unlinkat 328 +#define __NR_renameat 329 +#define __NR_linkat 330 +#define __NR_symlinkat 331 +#define __NR_readlinkat 332 +#define __NR_fchmodat 333 +#define __NR_faccessat 334 +#define __NR_pselect6 335 +#define __NR_ppoll 336 +#define __NR_unshare 337 +#define __NR_set_robust_list 338 +#define __NR_get_robust_list 339 +#define __NR_splice 340 +#define __NR_sync_file_range2 341 +#define __NR_arm_sync_file_range 341 +#define __NR_tee 342 +#define __NR_vmsplice 343 +#define __NR_move_pages 344 +#define __NR_getcpu 345 +#define __NR_epoll_pwait 346 +#define __NR_kexec_load 347 +#define __NR_utimensat 348 +#define __NR_signalfd 349 +#define __NR_timerfd_create 350 +#define __NR_eventfd 351 +#define __NR_fallocate 352 +#define __NR_timerfd_settime 353 +#define __NR_timerfd_gettime 354 +#define __NR_signalfd4 355 +#define __NR_eventfd2 356 +#define __NR_epoll_create1 357 +#define __NR_dup3 358 +#define __NR_pipe2 359 +#define __NR_inotify_init1 360 +#define __NR_preadv 361 +#define __NR_pwritev 362 +#define __NR_rt_tgsigqueueinfo 363 +#define __NR_perf_event_open 364 +#define __NR_recvmmsg 365 +#define __NR_accept4 366 +#define __NR_fanotify_init 367 +#define __NR_fanotify_mark 368 +#define __NR_prlimit64 369 +#define __NR_name_to_handle_at 370 +#define __NR_open_by_handle_at 371 +#define __NR_clock_adjtime 372 +#define __NR_syncfs 373 +#define __NR_sendmmsg 374 +#define __NR_setns 375 +#define __NR_process_vm_readv 376 +#define __NR_process_vm_writev 377 +#define __NR_kcmp 378 +#define __NR_finit_module 379 +#define __NR_sched_setattr 380 +#define __NR_sched_getattr 381 +#define __NR_renameat2 382 +#define __NR_seccomp 383 +#define __NR_getrandom 384 +#define __NR_memfd_create 385 +#define __NR_bpf 386 +#define __NR_execveat 387 +#define __NR_userfaultfd 388 +#define __NR_membarrier 389 +#define __NR_mlock2 390 +#define __NR_copy_file_range 391 +#define __NR_preadv2 392 +#define __NR_pwritev2 393 +#define __NR_pkey_mprotect 394 +#define __NR_pkey_alloc 395 +#define __NR_pkey_free 396 + +#define __ARM_NR_breakpoint 0x0f0001 +#define __ARM_NR_cacheflush 0x0f0002 +#define __ARM_NR_usr26 0x0f0003 +#define __ARM_NR_usr32 0x0f0004 +#define __ARM_NR_set_tls 0x0f0005 + +#define SYS_restart_syscall 0 +#define SYS_exit 1 +#define SYS_fork 2 +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_creat 8 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_execve 11 +#define SYS_chdir 12 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_lchown 16 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_mount 21 +#define SYS_setuid 23 +#define SYS_getuid 24 +#define SYS_ptrace 26 +#define SYS_pause 29 +#define SYS_access 33 +#define SYS_nice 34 +#define SYS_sync 36 +#define SYS_kill 37 +#define SYS_rename 38 +#define SYS_mkdir 39 +#define SYS_rmdir 40 +#define SYS_dup 41 +#define SYS_pipe 42 +#define SYS_times 43 +#define SYS_brk 45 +#define SYS_setgid 46 +#define SYS_getgid 47 +#define SYS_geteuid 49 +#define SYS_getegid 50 +#define SYS_acct 51 +#define SYS_umount2 52 +#define SYS_ioctl 54 +#define SYS_fcntl 55 +#define SYS_setpgid 57 +#define SYS_umask 60 +#define SYS_chroot 61 +#define SYS_ustat 62 +#define SYS_dup2 63 +#define SYS_getppid 64 +#define SYS_getpgrp 65 +#define SYS_setsid 66 +#define SYS_sigaction 67 +#define SYS_setreuid 70 +#define SYS_setregid 71 +#define SYS_sigsuspend 72 +#define SYS_sigpending 73 +#define SYS_sethostname 74 +#define SYS_setrlimit 75 +#define SYS_getrusage 77 +#define SYS_gettimeofday 78 +#define SYS_settimeofday 79 +#define SYS_getgroups 80 +#define SYS_setgroups 81 +#define SYS_symlink 83 +#define SYS_readlink 85 +#define SYS_uselib 86 +#define SYS_swapon 87 +#define SYS_reboot 88 +#define SYS_munmap 91 +#define SYS_truncate 92 +#define SYS_ftruncate 93 +#define SYS_fchmod 94 +#define SYS_fchown 95 +#define SYS_getpriority 96 +#define SYS_setpriority 97 +#define SYS_statfs 99 +#define SYS_fstatfs 100 +#define SYS_syslog 103 +#define SYS_setitimer 104 +#define SYS_getitimer 105 +#define SYS_stat 106 +#define SYS_lstat 107 +#define SYS_fstat 108 +#define SYS_vhangup 111 +#define SYS_wait4 114 +#define SYS_swapoff 115 +#define SYS_sysinfo 116 +#define SYS_fsync 118 +#define SYS_sigreturn 119 +#define SYS_clone 120 +#define SYS_setdomainname 121 +#define SYS_uname 122 +#define SYS_adjtimex 124 +#define SYS_mprotect 125 +#define SYS_sigprocmask 126 +#define SYS_init_module 128 +#define SYS_delete_module 129 +#define SYS_quotactl 131 +#define SYS_getpgid 132 +#define SYS_fchdir 133 +#define SYS_bdflush 134 +#define SYS_sysfs 135 +#define SYS_personality 136 +#define SYS_setfsuid 138 +#define SYS_setfsgid 139 +#define SYS__llseek 140 +#define SYS_getdents 141 +#define SYS__newselect 142 +#define SYS_flock 143 +#define SYS_msync 144 +#define SYS_readv 145 +#define SYS_writev 146 +#define SYS_getsid 147 +#define SYS_fdatasync 148 +#define SYS__sysctl 149 +#define SYS_mlock 150 +#define SYS_munlock 151 +#define SYS_mlockall 152 +#define SYS_munlockall 153 +#define SYS_sched_setparam 154 +#define SYS_sched_getparam 155 +#define SYS_sched_setscheduler 156 +#define SYS_sched_getscheduler 157 +#define SYS_sched_yield 158 +#define SYS_sched_get_priority_max 159 +#define SYS_sched_get_priority_min 160 +#define SYS_sched_rr_get_interval 161 +#define SYS_nanosleep 162 +#define SYS_mremap 163 +#define SYS_setresuid 164 +#define SYS_getresuid 165 +#define SYS_poll 168 +#define SYS_nfsservctl 169 +#define SYS_setresgid 170 +#define SYS_getresgid 171 +#define SYS_prctl 172 +#define SYS_rt_sigreturn 173 +#define SYS_rt_sigaction 174 +#define SYS_rt_sigprocmask 175 +#define SYS_rt_sigpending 176 +#define SYS_rt_sigtimedwait 177 +#define SYS_rt_sigqueueinfo 178 +#define SYS_rt_sigsuspend 179 +#define SYS_pread64 180 +#define SYS_pwrite64 181 +#define SYS_chown 182 +#define SYS_getcwd 183 +#define SYS_capget 184 +#define SYS_capset 185 +#define SYS_sigaltstack 186 +#define SYS_sendfile 187 +#define SYS_vfork 190 +#define SYS_ugetrlimit 191 +#define SYS_mmap2 192 +#define SYS_truncate64 193 +#define SYS_ftruncate64 194 +#define SYS_stat64 195 +#define SYS_lstat64 196 +#define SYS_fstat64 197 +#define SYS_lchown32 198 +#define SYS_getuid32 199 +#define SYS_getgid32 200 +#define SYS_geteuid32 201 +#define SYS_getegid32 202 +#define SYS_setreuid32 203 +#define SYS_setregid32 204 +#define SYS_getgroups32 205 +#define SYS_setgroups32 206 +#define SYS_fchown32 207 +#define SYS_setresuid32 208 +#define SYS_getresuid32 209 +#define SYS_setresgid32 210 +#define SYS_getresgid32 211 +#define SYS_chown32 212 +#define SYS_setuid32 213 +#define SYS_setgid32 214 +#define SYS_setfsuid32 215 +#define SYS_setfsgid32 216 +#define SYS_getdents64 217 +#define SYS_pivot_root 218 +#define SYS_mincore 219 +#define SYS_madvise 220 +#define SYS_fcntl64 221 +#define SYS_gettid 224 +#define SYS_readahead 225 +#define SYS_setxattr 226 +#define SYS_lsetxattr 227 +#define SYS_fsetxattr 228 +#define SYS_getxattr 229 +#define SYS_lgetxattr 230 +#define SYS_fgetxattr 231 +#define SYS_listxattr 232 +#define SYS_llistxattr 233 +#define SYS_flistxattr 234 +#define SYS_removexattr 235 +#define SYS_lremovexattr 236 +#define SYS_fremovexattr 237 +#define SYS_tkill 238 +#define SYS_sendfile64 239 +#define SYS_futex 240 +#define SYS_sched_setaffinity 241 +#define SYS_sched_getaffinity 242 +#define SYS_io_setup 243 +#define SYS_io_destroy 244 +#define SYS_io_getevents 245 +#define SYS_io_submit 246 +#define SYS_io_cancel 247 +#define SYS_exit_group 248 +#define SYS_lookup_dcookie 249 +#define SYS_epoll_create 250 +#define SYS_epoll_ctl 251 +#define SYS_epoll_wait 252 +#define SYS_remap_file_pages 253 +#define SYS_set_tid_address 256 +#define SYS_timer_create 257 +#define SYS_timer_settime 258 +#define SYS_timer_gettime 259 +#define SYS_timer_getoverrun 260 +#define SYS_timer_delete 261 +#define SYS_clock_settime 262 +#define SYS_clock_gettime 263 +#define SYS_clock_getres 264 +#define SYS_clock_nanosleep 265 +#define SYS_statfs64 266 +#define SYS_fstatfs64 267 +#define SYS_tgkill 268 +#define SYS_utimes 269 +#define SYS_fadvise64_64 270 +#define SYS_arm_fadvise64_64 270 +#define SYS_pciconfig_iobase 271 +#define SYS_pciconfig_read 272 +#define SYS_pciconfig_write 273 +#define SYS_mq_open 274 +#define SYS_mq_unlink 275 +#define SYS_mq_timedsend 276 +#define SYS_mq_timedreceive 277 +#define SYS_mq_notify 278 +#define SYS_mq_getsetattr 279 +#define SYS_waitid 280 +#define SYS_socket 281 +#define SYS_bind 282 +#define SYS_connect 283 +#define SYS_listen 284 +#define SYS_accept 285 +#define SYS_getsockname 286 +#define SYS_getpeername 287 +#define SYS_socketpair 288 +#define SYS_send 289 +#define SYS_sendto 290 +#define SYS_recv 291 +#define SYS_recvfrom 292 +#define SYS_shutdown 293 +#define SYS_setsockopt 294 +#define SYS_getsockopt 295 +#define SYS_sendmsg 296 +#define SYS_recvmsg 297 +#define SYS_semop 298 +#define SYS_semget 299 +#define SYS_semctl 300 +#define SYS_msgsnd 301 +#define SYS_msgrcv 302 +#define SYS_msgget 303 +#define SYS_msgctl 304 +#define SYS_shmat 305 +#define SYS_shmdt 306 +#define SYS_shmget 307 +#define SYS_shmctl 308 +#define SYS_add_key 309 +#define SYS_request_key 310 +#define SYS_keyctl 311 +#define SYS_semtimedop 312 +#define SYS_vserver 313 +#define SYS_ioprio_set 314 +#define SYS_ioprio_get 315 +#define SYS_inotify_init 316 +#define SYS_inotify_add_watch 317 +#define SYS_inotify_rm_watch 318 +#define SYS_mbind 319 +#define SYS_get_mempolicy 320 +#define SYS_set_mempolicy 321 +#define SYS_openat 322 +#define SYS_mkdirat 323 +#define SYS_mknodat 324 +#define SYS_fchownat 325 +#define SYS_futimesat 326 +#define SYS_fstatat64 327 +#define SYS_unlinkat 328 +#define SYS_renameat 329 +#define SYS_linkat 330 +#define SYS_symlinkat 331 +#define SYS_readlinkat 332 +#define SYS_fchmodat 333 +#define SYS_faccessat 334 +#define SYS_pselect6 335 +#define SYS_ppoll 336 +#define SYS_unshare 337 +#define SYS_set_robust_list 338 +#define SYS_get_robust_list 339 +#define SYS_splice 340 +#define SYS_sync_file_range2 341 +#define SYS_arm_sync_file_range 341 +#define SYS_tee 342 +#define SYS_vmsplice 343 +#define SYS_move_pages 344 +#define SYS_getcpu 345 +#define SYS_epoll_pwait 346 +#define SYS_kexec_load 347 +#define SYS_utimensat 348 +#define SYS_signalfd 349 +#define SYS_timerfd_create 350 +#define SYS_eventfd 351 +#define SYS_fallocate 352 +#define SYS_timerfd_settime 353 +#define SYS_timerfd_gettime 354 +#define SYS_signalfd4 355 +#define SYS_eventfd2 356 +#define SYS_epoll_create1 357 +#define SYS_dup3 358 +#define SYS_pipe2 359 +#define SYS_inotify_init1 360 +#define SYS_preadv 361 +#define SYS_pwritev 362 +#define SYS_rt_tgsigqueueinfo 363 +#define SYS_perf_event_open 364 +#define SYS_recvmmsg 365 +#define SYS_accept4 366 +#define SYS_fanotify_init 367 +#define SYS_fanotify_mark 368 +#define SYS_prlimit64 369 +#define SYS_name_to_handle_at 370 +#define SYS_open_by_handle_at 371 +#define SYS_clock_adjtime 372 +#define SYS_syncfs 373 +#define SYS_sendmmsg 374 +#define SYS_setns 375 +#define SYS_process_vm_readv 376 +#define SYS_process_vm_writev 377 +#define SYS_kcmp 378 +#define SYS_finit_module 379 +#define SYS_sched_setattr 380 +#define SYS_sched_getattr 381 +#define SYS_renameat2 382 +#define SYS_seccomp 383 +#define SYS_getrandom 384 +#define SYS_memfd_create 385 +#define SYS_bpf 386 +#define SYS_execveat 387 +#define SYS_userfaultfd 388 +#define SYS_membarrier 389 +#define SYS_mlock2 390 +#define SYS_copy_file_range 391 +#define SYS_preadv2 392 +#define SYS_pwritev2 393 +#define SYS_pkey_mprotect 394 +#define SYS_pkey_alloc 395 +#define SYS_pkey_free 396 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/dirent.h b/thirdparty/open_source/musl/libc/arch/generic/bits/dirent.h new file mode 100644 index 0000000..c845fe8 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/dirent.h @@ -0,0 +1,11 @@ +#define _DIRENT_HAVE_D_RECLEN +#define _DIRENT_HAVE_D_OFF +#define _DIRENT_HAVE_D_TYPE + +struct dirent { + ino_t d_ino; + off_t d_off; + unsigned short d_reclen; + unsigned char d_type; + char d_name[256]; +}; diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/errno.h b/thirdparty/open_source/musl/libc/arch/generic/bits/errno.h new file mode 100644 index 0000000..d2e1eee --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/errno.h @@ -0,0 +1,134 @@ +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 +#define ELOOP 40 +#define EWOULDBLOCK EAGAIN +#define ENOMSG 42 +#define EIDRM 43 +#define ECHRNG 44 +#define EL2NSYNC 45 +#define EL3HLT 46 +#define EL3RST 47 +#define ELNRNG 48 +#define EUNATCH 49 +#define ENOCSI 50 +#define EL2HLT 51 +#define EBADE 52 +#define EBADR 53 +#define EXFULL 54 +#define ENOANO 55 +#define EBADRQC 56 +#define EBADSLT 57 +#define EDEADLOCK EDEADLK +#define EBFONT 59 +#define ENOSTR 60 +#define ENODATA 61 +#define ETIME 62 +#define ENOSR 63 +#define ENONET 64 +#define ENOPKG 65 +#define EREMOTE 66 +#define ENOLINK 67 +#define EADV 68 +#define ESRMNT 69 +#define ECOMM 70 +#define EPROTO 71 +#define EMULTIHOP 72 +#define EDOTDOT 73 +#define EBADMSG 74 +#define EOVERFLOW 75 +#define ENOTUNIQ 76 +#define EBADFD 77 +#define EREMCHG 78 +#define ELIBACC 79 +#define ELIBBAD 80 +#define ELIBSCN 81 +#define ELIBMAX 82 +#define ELIBEXEC 83 +#define EILSEQ 84 +#define ERESTART 85 +#define ESTRPIPE 86 +#define EUSERS 87 +#define ENOTSOCK 88 +#define EDESTADDRREQ 89 +#define EMSGSIZE 90 +#define EPROTOTYPE 91 +#define ENOPROTOOPT 92 +#define EPROTONOSUPPORT 93 +#define ESOCKTNOSUPPORT 94 +#define EOPNOTSUPP 95 +#define ENOTSUP EOPNOTSUPP +#define EPFNOSUPPORT 96 +#define EAFNOSUPPORT 97 +#define EADDRINUSE 98 +#define EADDRNOTAVAIL 99 +#define ENETDOWN 100 +#define ENETUNREACH 101 +#define ENETRESET 102 +#define ECONNABORTED 103 +#define ECONNRESET 104 +#define ENOBUFS 105 +#define EISCONN 106 +#define ENOTCONN 107 +#define ESHUTDOWN 108 +#define ETOOMANYREFS 109 +#define ETIMEDOUT 110 +#define ECONNREFUSED 111 +#define EHOSTDOWN 112 +#define EHOSTUNREACH 113 +#define EALREADY 114 +#define EINPROGRESS 115 +#define ESTALE 116 +#define EUCLEAN 117 +#define ENOTNAM 118 +#define ENAVAIL 119 +#define EISNAM 120 +#define EREMOTEIO 121 +#define EDQUOT 122 +#define ENOMEDIUM 123 +#define EMEDIUMTYPE 124 +#define ECANCELED 125 +#define ENOKEY 126 +#define EKEYEXPIRED 127 +#define EKEYREVOKED 128 +#define EKEYREJECTED 129 +#define EOWNERDEAD 130 +#define ENOTRECOVERABLE 131 +#define ERFKILL 132 +#define EHWPOISON 133 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/fcntl.h b/thirdparty/open_source/musl/libc/arch/generic/bits/fcntl.h new file mode 100644 index 0000000..ae233cc --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/fcntl.h @@ -0,0 +1,40 @@ +#define O_CREAT 0100 +#define O_EXCL 0200 +#define O_NOCTTY 0400 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_DSYNC 010000 +#define O_SYNC 04010000 +#define O_RSYNC 04010000 +#define O_DIRECTORY 0200000 +#define O_NOFOLLOW 0400000 +#define O_CLOEXEC 02000000 + +#define O_ASYNC 020000 +#define O_DIRECT 040000 +#define O_LARGEFILE 0100000 +#define O_NOATIME 01000000 +#define O_PATH 010000000 +#define O_TMPFILE 020200000 +#define O_NDELAY O_NONBLOCK + +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 + +#define F_SETOWN 8 +#define F_GETOWN 9 +#define F_SETSIG 10 +#define F_GETSIG 11 + +#define F_GETLK 12 +#define F_SETLK 13 +#define F_SETLKW 14 + +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 + +#define F_GETOWNER_UIDS 17 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/fenv.h b/thirdparty/open_source/musl/libc/arch/generic/bits/fenv.h new file mode 100644 index 0000000..edbdea2 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/fenv.h @@ -0,0 +1,10 @@ +#define FE_ALL_EXCEPT 0 +#define FE_TONEAREST 0 + +typedef unsigned long fexcept_t; + +typedef struct { + unsigned long __cw; +} fenv_t; + +#define FE_DFL_ENV ((const fenv_t *) -1) diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/hwcap.h b/thirdparty/open_source/musl/libc/arch/generic/bits/hwcap.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/io.h b/thirdparty/open_source/musl/libc/arch/generic/bits/io.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/ioctl.h b/thirdparty/open_source/musl/libc/arch/generic/bits/ioctl.h new file mode 100644 index 0000000..60ae8b8 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/ioctl.h @@ -0,0 +1,115 @@ +#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) ) +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0) +#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c)) +#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c)) +#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c)) + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 +#define TIOCSBRK 0x5427 +#define TIOCCBRK 0x5428 +#define TIOCGSID 0x5429 +#define TIOCGRS485 0x542E +#define TIOCSRS485 0x542F +#define TIOCGPTN 0x80045430 +#define TIOCSPTLCK 0x40045431 +#define TIOCGDEV 0x80045432 +#define TCGETX 0x5432 +#define TCSETX 0x5433 +#define TCSETXF 0x5434 +#define TCSETXW 0x5435 +#define TIOCSIG 0x40045436 +#define TIOCVHANGUP 0x5437 +#define TIOCGPKT 0x80045438 +#define TIOCGPTLCK 0x80045439 +#define TIOCGEXCL 0x80045440 +#define TIOCGPTPEER 0x5441 +#define TIOCGISO7816 0x80285442 +#define TIOCSISO7816 0xc0285443 + +#define FIONCLEX 0x5450 +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 +#define TIOCSERGETLSR 0x5459 +#define TIOCSERGETMULTI 0x545A +#define TIOCSERSETMULTI 0x545B + +#define TIOCMIWAIT 0x545C +#define TIOCGICOUNT 0x545D +#define FIOQSIZE 0x5460 + +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#if __LONG_MAX == 0x7fffffff +#define SIOCGSTAMP _IOR(0x89, 6, char[16]) +#define SIOCGSTAMPNS _IOR(0x89, 7, char[16]) +#else +#define SIOCGSTAMP 0x8906 +#define SIOCGSTAMPNS 0x8907 +#endif + +#include diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/ioctl_fix.h b/thirdparty/open_source/musl/libc/arch/generic/bits/ioctl_fix.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/ipc.h b/thirdparty/open_source/musl/libc/arch/generic/bits/ipc.h new file mode 100644 index 0000000..40d6f3a --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/ipc.h @@ -0,0 +1,11 @@ +struct ipc_perm { + key_t __ipc_perm_key; + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; + int __ipc_perm_seq; + long __pad1; + long __pad2; +}; diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/ipcstat.h b/thirdparty/open_source/musl/libc/arch/generic/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/kd.h b/thirdparty/open_source/musl/libc/arch/generic/bits/kd.h new file mode 100644 index 0000000..33b873f --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/kd.h @@ -0,0 +1 @@ +#include diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/limits.h b/thirdparty/open_source/musl/libc/arch/generic/bits/limits.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/link.h b/thirdparty/open_source/musl/libc/arch/generic/bits/link.h new file mode 100644 index 0000000..4a94d8f --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/link.h @@ -0,0 +1 @@ +typedef uint32_t Elf_Symndx; diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/mman.h b/thirdparty/open_source/musl/libc/arch/generic/bits/mman.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/msg.h b/thirdparty/open_source/musl/libc/arch/generic/bits/msg.h new file mode 100644 index 0000000..2e23ca2 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/msg.h @@ -0,0 +1,12 @@ +struct msqid_ds { + struct ipc_perm msg_perm; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; + unsigned long msg_cbytes; + msgqnum_t msg_qnum; + msglen_t msg_qbytes; + pid_t msg_lspid; + pid_t msg_lrpid; + unsigned long __unused[2]; +}; diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/poll.h b/thirdparty/open_source/musl/libc/arch/generic/bits/poll.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/ptrace.h b/thirdparty/open_source/musl/libc/arch/generic/bits/ptrace.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/resource.h b/thirdparty/open_source/musl/libc/arch/generic/bits/resource.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/sem.h b/thirdparty/open_source/musl/libc/arch/generic/bits/sem.h new file mode 100644 index 0000000..5184eb5 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/sem.h @@ -0,0 +1,14 @@ +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + time_t sem_ctime; +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned short sem_nsems; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; +#else + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; + unsigned short sem_nsems; +#endif + long __unused3; + long __unused4; +}; diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/shm.h b/thirdparty/open_source/musl/libc/arch/generic/bits/shm.h new file mode 100644 index 0000000..8d19378 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/shm.h @@ -0,0 +1,24 @@ +#define SHMLBA 4096 + +struct shmid_ds { + struct ipc_perm shm_perm; + size_t shm_segsz; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; + pid_t shm_cpid; + pid_t shm_lpid; + unsigned long shm_nattch; + unsigned long __pad1; + unsigned long __pad2; +}; + +struct shminfo { + unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4]; +}; + +struct shm_info { + int __used_ids; + unsigned long shm_tot, shm_rss, shm_swp; + unsigned long __swap_attempts, __swap_successes; +}; diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/socket.h b/thirdparty/open_source/musl/libc/arch/generic/bits/socket.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/soundcard.h b/thirdparty/open_source/musl/libc/arch/generic/bits/soundcard.h new file mode 100644 index 0000000..fade986 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/soundcard.h @@ -0,0 +1 @@ +#include diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/statfs.h b/thirdparty/open_source/musl/libc/arch/generic/bits/statfs.h new file mode 100644 index 0000000..f103f4e --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/statfs.h @@ -0,0 +1,7 @@ +struct statfs { + unsigned long f_type, f_bsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree; + fsid_t f_fsid; + unsigned long f_namelen, f_frsize, f_flags, f_spare[4]; +}; diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/termios.h b/thirdparty/open_source/musl/libc/arch/generic/bits/termios.h new file mode 100644 index 0000000..124f71d --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/termios.h @@ -0,0 +1,166 @@ +struct termios { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t c_line; + cc_t c_cc[NCCS]; + speed_t __c_ispeed; + speed_t __c_ospeed; +}; + +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 +#define IUTF8 0040000 + +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 +#endif + +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 + +#define B0 0000000 +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 + +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 + +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 + +#define ISIG 0000001 +#define ICANON 0000002 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define IEXTEN 0100000 + +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define EXTA 0000016 +#define EXTB 0000017 +#define CBAUD 0010017 +#define CBAUDEX 0010000 +#define CIBAUD 002003600000 +#define CMSPAR 010000000000 +#define CRTSCTS 020000000000 + +#define XCASE 0000004 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define EXTPROC 0200000 + +#define XTABS 0014000 +#endif diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/vt.h b/thirdparty/open_source/musl/libc/arch/generic/bits/vt.h new file mode 100644 index 0000000..834abfb --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/vt.h @@ -0,0 +1 @@ +#include diff --git a/thirdparty/open_source/musl/libc/arch/generic/fp_arch.h b/thirdparty/open_source/musl/libc/arch/generic/fp_arch.h new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/open_source/musl/libc/arpa/inet.h b/thirdparty/open_source/musl/libc/arpa/inet.h new file mode 100644 index 0000000..37f8c11 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arpa/inet.h @@ -0,0 +1,36 @@ +#ifndef _ARPA_INET_H +#define _ARPA_INET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +uint32_t htonl(uint32_t); +uint16_t htons(uint16_t); +uint32_t ntohl(uint32_t); +uint16_t ntohs(uint16_t); + +in_addr_t inet_addr (const char *); +in_addr_t inet_network (const char *); +char *inet_ntoa (struct in_addr); +int inet_pton (int, const char *__restrict, void *__restrict); +const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t); + +int inet_aton (const char *, struct in_addr *); +struct in_addr inet_makeaddr(in_addr_t, in_addr_t); +in_addr_t inet_lnaof(struct in_addr); +in_addr_t inet_netof(struct in_addr); + +#undef INET_ADDRSTRLEN +#undef INET6_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/assert.h b/thirdparty/open_source/musl/libc/assert.h new file mode 100644 index 0000000..d14ec94 --- /dev/null +++ b/thirdparty/open_source/musl/libc/assert.h @@ -0,0 +1,23 @@ +#include + +#undef assert + +#ifdef NDEBUG +#define assert(x) (void)0 +#else +#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) +#endif + +#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus) +#define static_assert _Static_assert +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_Noreturn void __assert_fail (const char *, const char *, int, const char *); + +#ifdef __cplusplus +} +#endif diff --git a/thirdparty/open_source/musl/libc/byteswap.h b/thirdparty/open_source/musl/libc/byteswap.h new file mode 100644 index 0000000..00b9df3 --- /dev/null +++ b/thirdparty/open_source/musl/libc/byteswap.h @@ -0,0 +1,26 @@ +#ifndef _BYTESWAP_H +#define _BYTESWAP_H + +#include +#include + +static __inline uint16_t __bswap_16(uint16_t __x) +{ + return __x<<8 | __x>>8; +} + +static __inline uint32_t __bswap_32(uint32_t __x) +{ + return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24; +} + +static __inline uint64_t __bswap_64(uint64_t __x) +{ + return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32); +} + +#define bswap_16(x) __bswap_16(x) +#define bswap_32(x) __bswap_32(x) +#define bswap_64(x) __bswap_64(x) + +#endif diff --git a/thirdparty/open_source/musl/libc/ctype.h b/thirdparty/open_source/musl/libc/ctype.h new file mode 100644 index 0000000..7936536 --- /dev/null +++ b/thirdparty/open_source/musl/libc/ctype.h @@ -0,0 +1,75 @@ +#ifndef _CTYPE_H +#define _CTYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +int isalnum(int); +int isalpha(int); +int isblank(int); +int iscntrl(int); +int isdigit(int); +int isgraph(int); +int islower(int); +int isprint(int); +int ispunct(int); +int isspace(int); +int isupper(int); +int isxdigit(int); +int tolower(int); +int toupper(int); + +#ifndef __cplusplus +static __inline int __isspace(int _c) +{ + return _c == ' ' || (unsigned)_c-'\t' < 5; +} + +#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26) +#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10) +#define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26) +#define isupper(a) (0 ? isupper(a) : ((unsigned)(a)-'A') < 26) +#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f) +#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e) +#define isspace(a) __isspace(a) +#endif + + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) + +#define __NEED_locale_t +#include + +int isalnum_l(int, locale_t); +int isalpha_l(int, locale_t); +int isblank_l(int, locale_t); +int iscntrl_l(int, locale_t); +int isdigit_l(int, locale_t); +int isgraph_l(int, locale_t); +int islower_l(int, locale_t); +int isprint_l(int, locale_t); +int ispunct_l(int, locale_t); +int isspace_l(int, locale_t); +int isupper_l(int, locale_t); +int isxdigit_l(int, locale_t); +int tolower_l(int, locale_t); +int toupper_l(int, locale_t); + +int isascii(int); +int toascii(int); +#define _tolower(a) ((a)|0x20) +#define _toupper(a) ((a)&0x5f) +#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128) + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/dlfcn.h b/thirdparty/open_source/musl/libc/dlfcn.h new file mode 100644 index 0000000..13ab71d --- /dev/null +++ b/thirdparty/open_source/musl/libc/dlfcn.h @@ -0,0 +1,46 @@ +#ifndef _DLFCN_H +#define _DLFCN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define RTLD_LAZY 1 +#define RTLD_NOW 2 +#define RTLD_NOLOAD 4 +#define RTLD_NODELETE 4096 +#define RTLD_GLOBAL 256 +#define RTLD_LOCAL 0 + +#define RTLD_NEXT ((void *)-1) +#define RTLD_DEFAULT ((void *)0) + +#define RTLD_DI_LINKMAP 2 + +int dlclose(void *); +char *dlerror(void); +void *dlopen(const char *, int); +void *dlsym(void *__restrict, const char *__restrict); + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +typedef struct { + const char *dli_fname; + void *dli_fbase; + const char *dli_sname; + void *dli_saddr; +} Dl_info; +int dladdr(const void *, Dl_info *); +int dlinfo(void *, int, void *); +#endif + +#if _REDIR_TIME64 +__REDIR(dlsym, __dlsym_time64); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/elf.h b/thirdparty/open_source/musl/libc/elf.h new file mode 100644 index 0000000..549f92c --- /dev/null +++ b/thirdparty/open_source/musl/libc/elf.h @@ -0,0 +1,3292 @@ +#ifndef _ELF_H +#define _ELF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + +#define EI_NIDENT (16) + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr; + +#define EI_MAG0 0 +#define ELFMAG0 0x7f + +#define EI_MAG1 1 +#define ELFMAG1 'E' + +#define EI_MAG2 2 +#define ELFMAG2 'L' + +#define EI_MAG3 3 +#define ELFMAG3 'F' + + +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 +#define ELFCLASSNONE 0 +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define EI_DATA 5 +#define ELFDATANONE 0 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 +#define ELFDATANUM 3 + +#define EI_VERSION 6 + + +#define EI_OSABI 7 +#define ELFOSABI_NONE 0 +#define ELFOSABI_SYSV 0 +#define ELFOSABI_HPUX 1 +#define ELFOSABI_NETBSD 2 +#define ELFOSABI_LINUX 3 +#define ELFOSABI_GNU 3 +#define ELFOSABI_SOLARIS 6 +#define ELFOSABI_AIX 7 +#define ELFOSABI_IRIX 8 +#define ELFOSABI_FREEBSD 9 +#define ELFOSABI_TRU64 10 +#define ELFOSABI_MODESTO 11 +#define ELFOSABI_OPENBSD 12 +#define ELFOSABI_ARM 97 +#define ELFOSABI_STANDALONE 255 + +#define EI_ABIVERSION 8 + +#define EI_PAD 9 + + + +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_NUM 5 +#define ET_LOOS 0xfe00 +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 +#define ET_HIPROC 0xffff + + + +#define EM_NONE 0 +#define EM_M32 1 +#define EM_SPARC 2 +#define EM_386 3 +#define EM_68K 4 +#define EM_88K 5 +#define EM_860 7 +#define EM_MIPS 8 +#define EM_S370 9 +#define EM_MIPS_RS3_LE 10 + +#define EM_PARISC 15 +#define EM_VPP500 17 +#define EM_SPARC32PLUS 18 +#define EM_960 19 +#define EM_PPC 20 +#define EM_PPC64 21 +#define EM_S390 22 + +#define EM_V800 36 +#define EM_FR20 37 +#define EM_RH32 38 +#define EM_RCE 39 +#define EM_ARM 40 +#define EM_FAKE_ALPHA 41 +#define EM_SH 42 +#define EM_SPARCV9 43 +#define EM_TRICORE 44 +#define EM_ARC 45 +#define EM_H8_300 46 +#define EM_H8_300H 47 +#define EM_H8S 48 +#define EM_H8_500 49 +#define EM_IA_64 50 +#define EM_MIPS_X 51 +#define EM_COLDFIRE 52 +#define EM_68HC12 53 +#define EM_MMA 54 +#define EM_PCP 55 +#define EM_NCPU 56 +#define EM_NDR1 57 +#define EM_STARCORE 58 +#define EM_ME16 59 +#define EM_ST100 60 +#define EM_TINYJ 61 +#define EM_X86_64 62 +#define EM_PDSP 63 + +#define EM_FX66 66 +#define EM_ST9PLUS 67 +#define EM_ST7 68 +#define EM_68HC16 69 +#define EM_68HC11 70 +#define EM_68HC08 71 +#define EM_68HC05 72 +#define EM_SVX 73 +#define EM_ST19 74 +#define EM_VAX 75 +#define EM_CRIS 76 +#define EM_JAVELIN 77 +#define EM_FIREPATH 78 +#define EM_ZSP 79 +#define EM_MMIX 80 +#define EM_HUANY 81 +#define EM_PRISM 82 +#define EM_AVR 83 +#define EM_FR30 84 +#define EM_D10V 85 +#define EM_D30V 86 +#define EM_V850 87 +#define EM_M32R 88 +#define EM_MN10300 89 +#define EM_MN10200 90 +#define EM_PJ 91 +#define EM_OR1K 92 +#define EM_OPENRISC 92 +#define EM_ARC_A5 93 +#define EM_ARC_COMPACT 93 +#define EM_XTENSA 94 +#define EM_VIDEOCORE 95 +#define EM_TMM_GPP 96 +#define EM_NS32K 97 +#define EM_TPC 98 +#define EM_SNP1K 99 +#define EM_ST200 100 +#define EM_IP2K 101 +#define EM_MAX 102 +#define EM_CR 103 +#define EM_F2MC16 104 +#define EM_MSP430 105 +#define EM_BLACKFIN 106 +#define EM_SE_C33 107 +#define EM_SEP 108 +#define EM_ARCA 109 +#define EM_UNICORE 110 +#define EM_EXCESS 111 +#define EM_DXP 112 +#define EM_ALTERA_NIOS2 113 +#define EM_CRX 114 +#define EM_XGATE 115 +#define EM_C166 116 +#define EM_M16C 117 +#define EM_DSPIC30F 118 +#define EM_CE 119 +#define EM_M32C 120 +#define EM_TSK3000 131 +#define EM_RS08 132 +#define EM_SHARC 133 +#define EM_ECOG2 134 +#define EM_SCORE7 135 +#define EM_DSP24 136 +#define EM_VIDEOCORE3 137 +#define EM_LATTICEMICO32 138 +#define EM_SE_C17 139 +#define EM_TI_C6000 140 +#define EM_TI_C2000 141 +#define EM_TI_C5500 142 +#define EM_TI_ARP32 143 +#define EM_TI_PRU 144 +#define EM_MMDSP_PLUS 160 +#define EM_CYPRESS_M8C 161 +#define EM_R32C 162 +#define EM_TRIMEDIA 163 +#define EM_QDSP6 164 +#define EM_8051 165 +#define EM_STXP7X 166 +#define EM_NDS32 167 +#define EM_ECOG1X 168 +#define EM_MAXQ30 169 +#define EM_XIMO16 170 +#define EM_MANIK 171 +#define EM_CRAYNV2 172 +#define EM_RX 173 +#define EM_METAG 174 +#define EM_MCST_ELBRUS 175 +#define EM_ECOG16 176 +#define EM_CR16 177 +#define EM_ETPU 178 +#define EM_SLE9X 179 +#define EM_L10M 180 +#define EM_K10M 181 +#define EM_AARCH64 183 +#define EM_AVR32 185 +#define EM_STM8 186 +#define EM_TILE64 187 +#define EM_TILEPRO 188 +#define EM_MICROBLAZE 189 +#define EM_CUDA 190 +#define EM_TILEGX 191 +#define EM_CLOUDSHIELD 192 +#define EM_COREA_1ST 193 +#define EM_COREA_2ND 194 +#define EM_ARC_COMPACT2 195 +#define EM_OPEN8 196 +#define EM_RL78 197 +#define EM_VIDEOCORE5 198 +#define EM_78KOR 199 +#define EM_56800EX 200 +#define EM_BA1 201 +#define EM_BA2 202 +#define EM_XCORE 203 +#define EM_MCHP_PIC 204 +#define EM_KM32 210 +#define EM_KMX32 211 +#define EM_EMX16 212 +#define EM_EMX8 213 +#define EM_KVARC 214 +#define EM_CDP 215 +#define EM_COGE 216 +#define EM_COOL 217 +#define EM_NORC 218 +#define EM_CSR_KALIMBA 219 +#define EM_Z80 220 +#define EM_VISIUM 221 +#define EM_FT32 222 +#define EM_MOXIE 223 +#define EM_AMDGPU 224 +#define EM_RISCV 243 +#define EM_BPF 247 +#define EM_CSKY 252 +#define EM_NUM 253 + +#define EM_ALPHA 0x9026 + +#define EV_NONE 0 +#define EV_CURRENT 1 +#define EV_NUM 2 + +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +typedef struct { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} Elf64_Shdr; + + + +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_BEFORE 0xff00 + +#define SHN_AFTER 0xff01 + +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 +#define SHN_HIOS 0xff3f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_XINDEX 0xffff +#define SHN_HIRESERVE 0xffff + + + +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_INIT_ARRAY 14 +#define SHT_FINI_ARRAY 15 +#define SHT_PREINIT_ARRAY 16 +#define SHT_GROUP 17 +#define SHT_SYMTAB_SHNDX 18 +#define SHT_NUM 19 +#define SHT_LOOS 0x60000000 +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 +#define SHT_GNU_HASH 0x6ffffff6 +#define SHT_GNU_LIBLIST 0x6ffffff7 +#define SHT_CHECKSUM 0x6ffffff8 +#define SHT_LOSUNW 0x6ffffffa +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd +#define SHT_GNU_verneed 0x6ffffffe +#define SHT_GNU_versym 0x6fffffff +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0x8fffffff + +#define SHF_WRITE (1 << 0) +#define SHF_ALLOC (1 << 1) +#define SHF_EXECINSTR (1 << 2) +#define SHF_MERGE (1 << 4) +#define SHF_STRINGS (1 << 5) +#define SHF_INFO_LINK (1 << 6) +#define SHF_LINK_ORDER (1 << 7) +#define SHF_OS_NONCONFORMING (1 << 8) + +#define SHF_GROUP (1 << 9) +#define SHF_TLS (1 << 10) +#define SHF_COMPRESSED (1 << 11) +#define SHF_MASKOS 0x0ff00000 +#define SHF_MASKPROC 0xf0000000 +#define SHF_ORDERED (1 << 30) +#define SHF_EXCLUDE (1U << 31) + +typedef struct { + Elf32_Word ch_type; + Elf32_Word ch_size; + Elf32_Word ch_addralign; +} Elf32_Chdr; + +typedef struct { + Elf64_Word ch_type; + Elf64_Word ch_reserved; + Elf64_Xword ch_size; + Elf64_Xword ch_addralign; +} Elf64_Chdr; + +#define ELFCOMPRESS_ZLIB 1 +#define ELFCOMPRESS_LOOS 0x60000000 +#define ELFCOMPRESS_HIOS 0x6fffffff +#define ELFCOMPRESS_LOPROC 0x70000000 +#define ELFCOMPRESS_HIPROC 0x7fffffff + + +#define GRP_COMDAT 0x1 + +typedef struct { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Section st_shndx; +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Section st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym; + +typedef struct { + Elf32_Half si_boundto; + Elf32_Half si_flags; +} Elf32_Syminfo; + +typedef struct { + Elf64_Half si_boundto; + Elf64_Half si_flags; +} Elf64_Syminfo; + +#define SYMINFO_BT_SELF 0xffff +#define SYMINFO_BT_PARENT 0xfffe +#define SYMINFO_BT_LOWRESERVE 0xff00 + +#define SYMINFO_FLG_DIRECT 0x0001 +#define SYMINFO_FLG_PASSTHRU 0x0002 +#define SYMINFO_FLG_COPY 0x0004 +#define SYMINFO_FLG_LAZYLOAD 0x0008 + +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_NUM 3 +#define STB_LOOS 10 +#define STB_GNU_UNIQUE 10 +#define STB_HIOS 12 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_COMMON 5 +#define STT_TLS 6 +#define STT_NUM 7 +#define STT_LOOS 10 +#define STT_GNU_IFUNC 10 +#define STT_HIOS 12 +#define STT_LOPROC 13 +#define STT_HIPROC 15 + +#define STN_UNDEF 0 + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +#define STV_DEFAULT 0 +#define STV_INTERNAL 1 +#define STV_HIDDEN 2 +#define STV_PROTECTED 3 + + + + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; +} Elf64_Rel; + + + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} Elf64_Rela; + + + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + + + +typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr; + + + +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_TLS 7 +#define PT_NUM 8 +#define PT_LOOS 0x60000000 +#define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_STACK 0x6474e551 +#define PT_GNU_RELRO 0x6474e552 +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa +#define PT_SUNWSTACK 0x6ffffffb +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff + + +#define PN_XNUM 0xffff + + +#define PF_X (1 << 0) +#define PF_W (1 << 1) +#define PF_R (1 << 2) +#define PF_MASKOS 0x0ff00000 +#define PF_MASKPROC 0xf0000000 + + + +#define NT_PRSTATUS 1 +#define NT_PRFPREG 2 +#define NT_FPREGSET 2 +#define NT_PRPSINFO 3 +#define NT_PRXREG 4 +#define NT_TASKSTRUCT 4 +#define NT_PLATFORM 5 +#define NT_AUXV 6 +#define NT_GWINDOWS 7 +#define NT_ASRS 8 +#define NT_PSTATUS 10 +#define NT_PSINFO 13 +#define NT_PRCRED 14 +#define NT_UTSNAME 15 +#define NT_LWPSTATUS 16 +#define NT_LWPSINFO 17 +#define NT_PRFPXREG 20 +#define NT_SIGINFO 0x53494749 +#define NT_FILE 0x46494c45 +#define NT_PRXFPREG 0x46e62b7f +#define NT_PPC_VMX 0x100 +#define NT_PPC_SPE 0x101 +#define NT_PPC_VSX 0x102 +#define NT_PPC_TAR 0x103 +#define NT_PPC_PPR 0x104 +#define NT_PPC_DSCR 0x105 +#define NT_PPC_EBB 0x106 +#define NT_PPC_PMU 0x107 +#define NT_PPC_TM_CGPR 0x108 +#define NT_PPC_TM_CFPR 0x109 +#define NT_PPC_TM_CVMX 0x10a +#define NT_PPC_TM_CVSX 0x10b +#define NT_PPC_TM_SPR 0x10c +#define NT_PPC_TM_CTAR 0x10d +#define NT_PPC_TM_CPPR 0x10e +#define NT_PPC_TM_CDSCR 0x10f +#define NT_386_TLS 0x200 +#define NT_386_IOPERM 0x201 +#define NT_X86_XSTATE 0x202 +#define NT_S390_HIGH_GPRS 0x300 +#define NT_S390_TIMER 0x301 +#define NT_S390_TODCMP 0x302 +#define NT_S390_TODPREG 0x303 +#define NT_S390_CTRS 0x304 +#define NT_S390_PREFIX 0x305 +#define NT_S390_LAST_BREAK 0x306 +#define NT_S390_SYSTEM_CALL 0x307 +#define NT_S390_TDB 0x308 +#define NT_S390_VXRS_LOW 0x309 +#define NT_S390_VXRS_HIGH 0x30a +#define NT_S390_GS_CB 0x30b +#define NT_S390_GS_BC 0x30c +#define NT_S390_RI_CB 0x30d +#define NT_ARM_VFP 0x400 +#define NT_ARM_TLS 0x401 +#define NT_ARM_HW_BREAK 0x402 +#define NT_ARM_HW_WATCH 0x403 +#define NT_ARM_SYSTEM_CALL 0x404 +#define NT_ARM_SVE 0x405 +#define NT_ARM_PAC_MASK 0x406 +#define NT_ARM_PACA_KEYS 0x407 +#define NT_ARM_PACG_KEYS 0x408 +#define NT_METAG_CBUF 0x500 +#define NT_METAG_RPIPE 0x501 +#define NT_METAG_TLS 0x502 +#define NT_ARC_V2 0x600 +#define NT_VMCOREDD 0x700 +#define NT_MIPS_DSP 0x800 +#define NT_MIPS_FP_MODE 0x801 +#define NT_MIPS_MSA 0x802 +#define NT_VERSION 1 + + + + +typedef struct { + Elf32_Sword d_tag; + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Sxword d_tag; + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; +} Elf64_Dyn; + + + +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_BIND_NOW 24 +#define DT_INIT_ARRAY 25 +#define DT_FINI_ARRAY 26 +#define DT_INIT_ARRAYSZ 27 +#define DT_FINI_ARRAYSZ 28 +#define DT_RUNPATH 29 +#define DT_FLAGS 30 +#define DT_ENCODING 32 +#define DT_PREINIT_ARRAY 32 +#define DT_PREINIT_ARRAYSZ 33 +#define DT_SYMTAB_SHNDX 34 +#define DT_NUM 35 +#define DT_LOOS 0x6000000d +#define DT_HIOS 0x6ffff000 +#define DT_LOPROC 0x70000000 +#define DT_HIPROC 0x7fffffff +#define DT_PROCNUM DT_MIPS_NUM + +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc +#define DT_POSFLAG_1 0x6ffffdfd + +#define DT_SYMINSZ 0x6ffffdfe +#define DT_SYMINENT 0x6ffffdff +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) +#define DT_VALNUM 12 + +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 +#define DT_TLSDESC_PLT 0x6ffffef6 +#define DT_TLSDESC_GOT 0x6ffffef7 +#define DT_GNU_CONFLICT 0x6ffffef8 +#define DT_GNU_LIBLIST 0x6ffffef9 +#define DT_CONFIG 0x6ffffefa +#define DT_DEPAUDIT 0x6ffffefb +#define DT_AUDIT 0x6ffffefc +#define DT_PLTPAD 0x6ffffefd +#define DT_MOVETAB 0x6ffffefe +#define DT_SYMINFO 0x6ffffeff +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) +#define DT_ADDRNUM 11 + + + +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + + +#define DT_FLAGS_1 0x6ffffffb +#define DT_VERDEF 0x6ffffffc + +#define DT_VERDEFNUM 0x6ffffffd +#define DT_VERNEED 0x6ffffffe + +#define DT_VERNEEDNUM 0x6fffffff +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) +#define DT_VERSIONTAGNUM 16 + + + +#define DT_AUXILIARY 0x7ffffffd +#define DT_FILTER 0x7fffffff +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + + +#define DF_ORIGIN 0x00000001 +#define DF_SYMBOLIC 0x00000002 +#define DF_TEXTREL 0x00000004 +#define DF_BIND_NOW 0x00000008 +#define DF_STATIC_TLS 0x00000010 + + + +#define DF_1_NOW 0x00000001 +#define DF_1_GLOBAL 0x00000002 +#define DF_1_GROUP 0x00000004 +#define DF_1_NODELETE 0x00000008 +#define DF_1_LOADFLTR 0x00000010 +#define DF_1_INITFIRST 0x00000020 +#define DF_1_NOOPEN 0x00000040 +#define DF_1_ORIGIN 0x00000080 +#define DF_1_DIRECT 0x00000100 +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 +#define DF_1_NODEFLIB 0x00000800 +#define DF_1_NODUMP 0x00001000 +#define DF_1_CONFALT 0x00002000 +#define DF_1_ENDFILTEE 0x00004000 +#define DF_1_DISPRELDNE 0x00008000 +#define DF_1_DISPRELPND 0x00010000 +#define DF_1_NODIRECT 0x00020000 +#define DF_1_IGNMULDEF 0x00040000 +#define DF_1_NOKSYMS 0x00080000 +#define DF_1_NOHDR 0x00100000 +#define DF_1_EDITED 0x00200000 +#define DF_1_NORELOC 0x00400000 +#define DF_1_SYMINTPOSE 0x00800000 +#define DF_1_GLOBAUDIT 0x01000000 +#define DF_1_SINGLETON 0x02000000 +#define DF_1_STUB 0x04000000 +#define DF_1_PIE 0x08000000 + +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + + +#define DF_P1_LAZYLOAD 0x00000001 +#define DF_P1_GROUPPERM 0x00000002 + + + + +typedef struct { + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} Elf32_Verdef; + +typedef struct { + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} Elf64_Verdef; + + + +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 +#define VER_DEF_NUM 2 + + +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + + +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_LORESERVE 0xff00 +#define VER_NDX_ELIMINATE 0xff01 + + + +typedef struct { + Elf32_Word vda_name; + Elf32_Word vda_next; +} Elf32_Verdaux; + +typedef struct { + Elf64_Word vda_name; + Elf64_Word vda_next; +} Elf64_Verdaux; + + + + +typedef struct { + Elf32_Half vn_version; + Elf32_Half vn_cnt; + Elf32_Word vn_file; + Elf32_Word vn_aux; + Elf32_Word vn_next; +} Elf32_Verneed; + +typedef struct { + Elf64_Half vn_version; + Elf64_Half vn_cnt; + Elf64_Word vn_file; + Elf64_Word vn_aux; + Elf64_Word vn_next; +} Elf64_Verneed; + + + +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 +#define VER_NEED_NUM 2 + + + +typedef struct { + Elf32_Word vna_hash; + Elf32_Half vna_flags; + Elf32_Half vna_other; + Elf32_Word vna_name; + Elf32_Word vna_next; +} Elf32_Vernaux; + +typedef struct { + Elf64_Word vna_hash; + Elf64_Half vna_flags; + Elf64_Half vna_other; + Elf64_Word vna_name; + Elf64_Word vna_next; +} Elf64_Vernaux; + + + +#define VER_FLG_WEAK 0x2 + + + +typedef struct { + uint32_t a_type; + union { + uint32_t a_val; + } a_un; +} Elf32_auxv_t; + +typedef struct { + uint64_t a_type; + union { + uint64_t a_val; + } a_un; +} Elf64_auxv_t; + + + +#define AT_NULL 0 +#define AT_IGNORE 1 +#define AT_EXECFD 2 +#define AT_PHDR 3 +#define AT_PHENT 4 +#define AT_PHNUM 5 +#define AT_PAGESZ 6 +#define AT_BASE 7 +#define AT_FLAGS 8 +#define AT_ENTRY 9 +#define AT_NOTELF 10 +#define AT_UID 11 +#define AT_EUID 12 +#define AT_GID 13 +#define AT_EGID 14 +#define AT_CLKTCK 17 + + +#define AT_PLATFORM 15 +#define AT_HWCAP 16 + + + + +#define AT_FPUCW 18 + + +#define AT_DCACHEBSIZE 19 +#define AT_ICACHEBSIZE 20 +#define AT_UCACHEBSIZE 21 + + + +#define AT_IGNOREPPC 22 + +#define AT_SECURE 23 + +#define AT_BASE_PLATFORM 24 + +#define AT_RANDOM 25 + +#define AT_HWCAP2 26 + +#define AT_EXECFN 31 + + + +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 + + + +#define AT_L1I_CACHESHAPE 34 +#define AT_L1D_CACHESHAPE 35 +#define AT_L2_CACHESHAPE 36 +#define AT_L3_CACHESHAPE 37 + +#define AT_L1I_CACHESIZE 40 +#define AT_L1I_CACHEGEOMETRY 41 +#define AT_L1D_CACHESIZE 42 +#define AT_L1D_CACHEGEOMETRY 43 +#define AT_L2_CACHESIZE 44 +#define AT_L2_CACHEGEOMETRY 45 +#define AT_L3_CACHESIZE 46 +#define AT_L3_CACHEGEOMETRY 47 + +#define AT_MINSIGSTKSZ 51 + + +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} Elf64_Nhdr; + + + + +#define ELF_NOTE_SOLARIS "SUNW Solaris" + + +#define ELF_NOTE_GNU "GNU" + + + + + +#define ELF_NOTE_PAGESIZE_HINT 1 + + +#define NT_GNU_ABI_TAG 1 +#define ELF_NOTE_ABI NT_GNU_ABI_TAG + + + +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 +#define ELF_NOTE_OS_FREEBSD 3 + +#define NT_GNU_BUILD_ID 3 +#define NT_GNU_GOLD_VERSION 4 + + + +typedef struct { + Elf32_Xword m_value; + Elf32_Word m_info; + Elf32_Word m_poffset; + Elf32_Half m_repeat; + Elf32_Half m_stride; +} Elf32_Move; + +typedef struct { + Elf64_Xword m_value; + Elf64_Xword m_info; + Elf64_Xword m_poffset; + Elf64_Half m_repeat; + Elf64_Half m_stride; +} Elf64_Move; + + +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + +#define EF_CPU32 0x00810000 + +#define R_68K_NONE 0 +#define R_68K_32 1 +#define R_68K_16 2 +#define R_68K_8 3 +#define R_68K_PC32 4 +#define R_68K_PC16 5 +#define R_68K_PC8 6 +#define R_68K_GOT32 7 +#define R_68K_GOT16 8 +#define R_68K_GOT8 9 +#define R_68K_GOT32O 10 +#define R_68K_GOT16O 11 +#define R_68K_GOT8O 12 +#define R_68K_PLT32 13 +#define R_68K_PLT16 14 +#define R_68K_PLT8 15 +#define R_68K_PLT32O 16 +#define R_68K_PLT16O 17 +#define R_68K_PLT8O 18 +#define R_68K_COPY 19 +#define R_68K_GLOB_DAT 20 +#define R_68K_JMP_SLOT 21 +#define R_68K_RELATIVE 22 +#define R_68K_TLS_GD32 25 +#define R_68K_TLS_GD16 26 +#define R_68K_TLS_GD8 27 +#define R_68K_TLS_LDM32 28 +#define R_68K_TLS_LDM16 29 +#define R_68K_TLS_LDM8 30 +#define R_68K_TLS_LDO32 31 +#define R_68K_TLS_LDO16 32 +#define R_68K_TLS_LDO8 33 +#define R_68K_TLS_IE32 34 +#define R_68K_TLS_IE16 35 +#define R_68K_TLS_IE8 36 +#define R_68K_TLS_LE32 37 +#define R_68K_TLS_LE16 38 +#define R_68K_TLS_LE8 39 +#define R_68K_TLS_DTPMOD32 40 +#define R_68K_TLS_DTPREL32 41 +#define R_68K_TLS_TPREL32 42 +#define R_68K_NUM 43 + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 +#define R_386_SIZE32 38 +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 +#define R_386_IRELATIVE 42 +#define R_386_GOT32X 43 +#define R_386_NUM 44 + + + + + +#define STT_SPARC_REGISTER 13 + + + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 +#define EF_SPARC_SUN_US1 0x000200 +#define EF_SPARC_HAL_R1 0x000400 +#define EF_SPARC_SUN_US3 0x000800 + + + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 + + + +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +#define R_SPARC_GOTDATA_HIX22 80 +#define R_SPARC_GOTDATA_LOX10 81 +#define R_SPARC_GOTDATA_OP_HIX22 82 +#define R_SPARC_GOTDATA_OP_LOX10 83 +#define R_SPARC_GOTDATA_OP 84 +#define R_SPARC_H34 85 +#define R_SPARC_SIZE32 86 +#define R_SPARC_SIZE64 87 +#define R_SPARC_GNU_VTINHERIT 250 +#define R_SPARC_GNU_VTENTRY 251 +#define R_SPARC_REV32 252 + +#define R_SPARC_NUM 253 + + + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + + +#define EF_MIPS_NOREORDER 1 +#define EF_MIPS_PIC 2 +#define EF_MIPS_CPIC 4 +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_FP64 512 +#define EF_MIPS_NAN2008 1024 +#define EF_MIPS_ARCH 0xf0000000 + + + +#define EF_MIPS_ARCH_1 0x00000000 +#define EF_MIPS_ARCH_2 0x10000000 +#define EF_MIPS_ARCH_3 0x20000000 +#define EF_MIPS_ARCH_4 0x30000000 +#define EF_MIPS_ARCH_5 0x40000000 +#define EF_MIPS_ARCH_32 0x50000000 +#define EF_MIPS_ARCH_64 0x60000000 +#define EF_MIPS_ARCH_32R2 0x70000000 +#define EF_MIPS_ARCH_64R2 0x80000000 + + +#define E_MIPS_ARCH_1 0x00000000 +#define E_MIPS_ARCH_2 0x10000000 +#define E_MIPS_ARCH_3 0x20000000 +#define E_MIPS_ARCH_4 0x30000000 +#define E_MIPS_ARCH_5 0x40000000 +#define E_MIPS_ARCH_32 0x50000000 +#define E_MIPS_ARCH_64 0x60000000 + + + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 +#define SHN_MIPS_SUNDEFINED 0xff04 + + + +#define SHT_MIPS_LIBLIST 0x70000000 +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 +#define SHT_MIPS_GPTAB 0x70000003 +#define SHT_MIPS_UCODE 0x70000004 +#define SHT_MIPS_DEBUG 0x70000005 +#define SHT_MIPS_REGINFO 0x70000006 +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + + + +#define SHF_MIPS_GPREL 0x10000000 +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + + + + +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_PLT 0x8 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + + +#define STB_MIPS_SPLIT_COMMON 13 + + + +typedef union { + struct { + Elf32_Word gt_current_g_value; + Elf32_Word gt_unused; + } gt_header; + struct { + Elf32_Word gt_g_value; + Elf32_Word gt_bytes; + } gt_entry; +} Elf32_gptab; + + + +typedef struct { + Elf32_Word ri_gprmask; + Elf32_Word ri_cprmask[4]; + Elf32_Sword ri_gp_value; +} Elf32_RegInfo; + + + +typedef struct { + unsigned char kind; + + unsigned char size; + Elf32_Section section; + + Elf32_Word info; +} Elf_Options; + + + +#define ODK_NULL 0 +#define ODK_REGINFO 1 +#define ODK_EXCEPTIONS 2 +#define ODK_PAD 3 +#define ODK_HWPATCH 4 +#define ODK_FILL 5 +#define ODK_TAGS 6 +#define ODK_HWAND 7 +#define ODK_HWOR 8 + + + +#define OEX_FPU_MIN 0x1f +#define OEX_FPU_MAX 0x1f00 +#define OEX_PAGE0 0x10000 +#define OEX_SMM 0x20000 +#define OEX_FPDBUG 0x40000 +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + + + +#define OHW_R4KEOP 0x1 +#define OHW_R8KPFETCH 0x2 +#define OHW_R5KEOP 0x4 +#define OHW_R5KCVTL 0x8 + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + + + +typedef struct { + Elf32_Word hwp_flags1; + Elf32_Word hwp_flags2; +} Elf_Options_Hw; + + + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + + + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 +#define R_MIPS_GPREL16 7 +#define R_MIPS_LITERAL 8 +#define R_MIPS_GOT16 9 +#define R_MIPS_PC16 10 +#define R_MIPS_CALL16 11 +#define R_MIPS_GPREL32 12 + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_DTPMOD32 38 +#define R_MIPS_TLS_DTPREL32 39 +#define R_MIPS_TLS_DTPMOD64 40 +#define R_MIPS_TLS_DTPREL64 41 +#define R_MIPS_TLS_GD 42 +#define R_MIPS_TLS_LDM 43 +#define R_MIPS_TLS_DTPREL_HI16 44 +#define R_MIPS_TLS_DTPREL_LO16 45 +#define R_MIPS_TLS_GOTTPREL 46 +#define R_MIPS_TLS_TPREL32 47 +#define R_MIPS_TLS_TPREL64 48 +#define R_MIPS_TLS_TPREL_HI16 49 +#define R_MIPS_TLS_TPREL_LO16 50 +#define R_MIPS_GLOB_DAT 51 +#define R_MIPS_COPY 126 +#define R_MIPS_JUMP_SLOT 127 + +#define R_MIPS_NUM 128 + + + +#define PT_MIPS_REGINFO 0x70000000 +#define PT_MIPS_RTPROC 0x70000001 +#define PT_MIPS_OPTIONS 0x70000002 +#define PT_MIPS_ABIFLAGS 0x70000003 + + + +#define PF_MIPS_LOCAL 0x10000000 + + + +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_LOCAL_GOTNO 0x7000000a +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 +#define DT_MIPS_DELTA_CLASS 0x70000017 +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 + +#define DT_MIPS_DELTA_INSTANCE 0x70000019 +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a + +#define DT_MIPS_DELTA_RELOC 0x7000001b +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c + +#define DT_MIPS_DELTA_SYM 0x7000001d + +#define DT_MIPS_DELTA_SYM_NO 0x7000001e + +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 + +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 + +#define DT_MIPS_CXX_FLAGS 0x70000022 +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 +#define DT_MIPS_INTERFACE 0x7000002a +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d + +#define DT_MIPS_PERF_SUFFIX 0x7000002e + +#define DT_MIPS_COMPACT_SIZE 0x7000002f +#define DT_MIPS_GP_VALUE 0x70000030 +#define DT_MIPS_AUX_DYNAMIC 0x70000031 + +#define DT_MIPS_PLTGOT 0x70000032 + +#define DT_MIPS_RWPLT 0x70000034 +#define DT_MIPS_RLD_MAP_REL 0x70000035 +#define DT_MIPS_NUM 0x36 + + + +#define RHF_NONE 0 +#define RHF_QUICKSTART (1 << 0) +#define RHF_NOTPOT (1 << 1) +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + + + +typedef struct { + Elf32_Word l_name; + Elf32_Word l_time_stamp; + Elf32_Word l_checksum; + Elf32_Word l_version; + Elf32_Word l_flags; +} Elf32_Lib; + +typedef struct { + Elf64_Word l_name; + Elf64_Word l_time_stamp; + Elf64_Word l_checksum; + Elf64_Word l_version; + Elf64_Word l_flags; +} Elf64_Lib; + + + + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) +#define LL_IGNORE_INT_VER (1 << 1) +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + + + +typedef Elf32_Addr Elf32_Conflict; + +typedef struct { + Elf32_Half version; + unsigned char isa_level; + unsigned char isa_rev; + unsigned char gpr_size; + unsigned char cpr1_size; + unsigned char cpr2_size; + unsigned char fp_abi; + Elf32_Word isa_ext; + Elf32_Word ases; + Elf32_Word flags1; + Elf32_Word flags2; +} Elf_MIPS_ABIFlags_v0; + +#define MIPS_AFL_REG_NONE 0x00 +#define MIPS_AFL_REG_32 0x01 +#define MIPS_AFL_REG_64 0x02 +#define MIPS_AFL_REG_128 0x03 + +#define MIPS_AFL_ASE_DSP 0x00000001 +#define MIPS_AFL_ASE_DSPR2 0x00000002 +#define MIPS_AFL_ASE_EVA 0x00000004 +#define MIPS_AFL_ASE_MCU 0x00000008 +#define MIPS_AFL_ASE_MDMX 0x00000010 +#define MIPS_AFL_ASE_MIPS3D 0x00000020 +#define MIPS_AFL_ASE_MT 0x00000040 +#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 +#define MIPS_AFL_ASE_VIRT 0x00000100 +#define MIPS_AFL_ASE_MSA 0x00000200 +#define MIPS_AFL_ASE_MIPS16 0x00000400 +#define MIPS_AFL_ASE_MICROMIPS 0x00000800 +#define MIPS_AFL_ASE_XPA 0x00001000 +#define MIPS_AFL_ASE_MASK 0x00001fff + +#define MIPS_AFL_EXT_XLR 1 +#define MIPS_AFL_EXT_OCTEON2 2 +#define MIPS_AFL_EXT_OCTEONP 3 +#define MIPS_AFL_EXT_LOONGSON_3A 4 +#define MIPS_AFL_EXT_OCTEON 5 +#define MIPS_AFL_EXT_5900 6 +#define MIPS_AFL_EXT_4650 7 +#define MIPS_AFL_EXT_4010 8 +#define MIPS_AFL_EXT_4100 9 +#define MIPS_AFL_EXT_3900 10 +#define MIPS_AFL_EXT_10000 11 +#define MIPS_AFL_EXT_SB1 12 +#define MIPS_AFL_EXT_4111 13 +#define MIPS_AFL_EXT_4120 14 +#define MIPS_AFL_EXT_5400 15 +#define MIPS_AFL_EXT_5500 16 +#define MIPS_AFL_EXT_LOONGSON_2E 17 +#define MIPS_AFL_EXT_LOONGSON_2F 18 + +#define MIPS_AFL_FLAGS1_ODDSPREG 1 + +enum +{ + Val_GNU_MIPS_ABI_FP_ANY = 0, + Val_GNU_MIPS_ABI_FP_DOUBLE = 1, + Val_GNU_MIPS_ABI_FP_SINGLE = 2, + Val_GNU_MIPS_ABI_FP_SOFT = 3, + Val_GNU_MIPS_ABI_FP_OLD_64 = 4, + Val_GNU_MIPS_ABI_FP_XX = 5, + Val_GNU_MIPS_ABI_FP_64 = 6, + Val_GNU_MIPS_ABI_FP_64A = 7, + Val_GNU_MIPS_ABI_FP_MAX = 7 +}; + + + + +#define EF_PARISC_TRAPNIL 0x00010000 +#define EF_PARISC_EXT 0x00020000 +#define EF_PARISC_LSB 0x00040000 +#define EF_PARISC_WIDE 0x00080000 +#define EF_PARISC_NO_KABP 0x00100000 + +#define EF_PARISC_LAZYSWAP 0x00400000 +#define EF_PARISC_ARCH 0x0000ffff + + + +#define EFA_PARISC_1_0 0x020b +#define EFA_PARISC_1_1 0x0210 +#define EFA_PARISC_2_0 0x0214 + + + +#define SHN_PARISC_ANSI_COMMON 0xff00 + +#define SHN_PARISC_HUGE_COMMON 0xff01 + + + +#define SHT_PARISC_EXT 0x70000000 +#define SHT_PARISC_UNWIND 0x70000001 +#define SHT_PARISC_DOC 0x70000002 + + + +#define SHF_PARISC_SHORT 0x20000000 +#define SHF_PARISC_HUGE 0x40000000 +#define SHF_PARISC_SBP 0x80000000 + + + +#define STT_PARISC_MILLICODE 13 + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + + + +#define R_PARISC_NONE 0 +#define R_PARISC_DIR32 1 +#define R_PARISC_DIR21L 2 +#define R_PARISC_DIR17R 3 +#define R_PARISC_DIR17F 4 +#define R_PARISC_DIR14R 6 +#define R_PARISC_PCREL32 9 +#define R_PARISC_PCREL21L 10 +#define R_PARISC_PCREL17R 11 +#define R_PARISC_PCREL17F 12 +#define R_PARISC_PCREL14R 14 +#define R_PARISC_DPREL21L 18 +#define R_PARISC_DPREL14R 22 +#define R_PARISC_GPREL21L 26 +#define R_PARISC_GPREL14R 30 +#define R_PARISC_LTOFF21L 34 +#define R_PARISC_LTOFF14R 38 +#define R_PARISC_SECREL32 41 +#define R_PARISC_SEGBASE 48 +#define R_PARISC_SEGREL32 49 +#define R_PARISC_PLTOFF21L 50 +#define R_PARISC_PLTOFF14R 54 +#define R_PARISC_LTOFF_FPTR32 57 +#define R_PARISC_LTOFF_FPTR21L 58 +#define R_PARISC_LTOFF_FPTR14R 62 +#define R_PARISC_FPTR64 64 +#define R_PARISC_PLABEL32 65 +#define R_PARISC_PLABEL21L 66 +#define R_PARISC_PLABEL14R 70 +#define R_PARISC_PCREL64 72 +#define R_PARISC_PCREL22F 74 +#define R_PARISC_PCREL14WR 75 +#define R_PARISC_PCREL14DR 76 +#define R_PARISC_PCREL16F 77 +#define R_PARISC_PCREL16WF 78 +#define R_PARISC_PCREL16DF 79 +#define R_PARISC_DIR64 80 +#define R_PARISC_DIR14WR 83 +#define R_PARISC_DIR14DR 84 +#define R_PARISC_DIR16F 85 +#define R_PARISC_DIR16WF 86 +#define R_PARISC_DIR16DF 87 +#define R_PARISC_GPREL64 88 +#define R_PARISC_GPREL14WR 91 +#define R_PARISC_GPREL14DR 92 +#define R_PARISC_GPREL16F 93 +#define R_PARISC_GPREL16WF 94 +#define R_PARISC_GPREL16DF 95 +#define R_PARISC_LTOFF64 96 +#define R_PARISC_LTOFF14WR 99 +#define R_PARISC_LTOFF14DR 100 +#define R_PARISC_LTOFF16F 101 +#define R_PARISC_LTOFF16WF 102 +#define R_PARISC_LTOFF16DF 103 +#define R_PARISC_SECREL64 104 +#define R_PARISC_SEGREL64 112 +#define R_PARISC_PLTOFF14WR 115 +#define R_PARISC_PLTOFF14DR 116 +#define R_PARISC_PLTOFF16F 117 +#define R_PARISC_PLTOFF16WF 118 +#define R_PARISC_PLTOFF16DF 119 +#define R_PARISC_LTOFF_FPTR64 120 +#define R_PARISC_LTOFF_FPTR14WR 123 +#define R_PARISC_LTOFF_FPTR14DR 124 +#define R_PARISC_LTOFF_FPTR16F 125 +#define R_PARISC_LTOFF_FPTR16WF 126 +#define R_PARISC_LTOFF_FPTR16DF 127 +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 +#define R_PARISC_IPLT 129 +#define R_PARISC_EPLT 130 +#define R_PARISC_TPREL32 153 +#define R_PARISC_TPREL21L 154 +#define R_PARISC_TPREL14R 158 +#define R_PARISC_LTOFF_TP21L 162 +#define R_PARISC_LTOFF_TP14R 166 +#define R_PARISC_LTOFF_TP14F 167 +#define R_PARISC_TPREL64 216 +#define R_PARISC_TPREL14WR 219 +#define R_PARISC_TPREL14DR 220 +#define R_PARISC_TPREL16F 221 +#define R_PARISC_TPREL16WF 222 +#define R_PARISC_TPREL16DF 223 +#define R_PARISC_LTOFF_TP64 224 +#define R_PARISC_LTOFF_TP14WR 227 +#define R_PARISC_LTOFF_TP14DR 228 +#define R_PARISC_LTOFF_TP16F 229 +#define R_PARISC_LTOFF_TP16WF 230 +#define R_PARISC_LTOFF_TP16DF 231 +#define R_PARISC_GNU_VTENTRY 232 +#define R_PARISC_GNU_VTINHERIT 233 +#define R_PARISC_TLS_GD21L 234 +#define R_PARISC_TLS_GD14R 235 +#define R_PARISC_TLS_GDCALL 236 +#define R_PARISC_TLS_LDM21L 237 +#define R_PARISC_TLS_LDM14R 238 +#define R_PARISC_TLS_LDMCALL 239 +#define R_PARISC_TLS_LDO21L 240 +#define R_PARISC_TLS_LDO14R 241 +#define R_PARISC_TLS_DTPMOD32 242 +#define R_PARISC_TLS_DTPMOD64 243 +#define R_PARISC_TLS_DTPOFF32 244 +#define R_PARISC_TLS_DTPOFF64 245 +#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L +#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R +#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L +#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R +#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32 +#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64 +#define R_PARISC_HIRESERVE 255 + + + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + + + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + + + + + +#define EF_ALPHA_32BIT 1 +#define EF_ALPHA_CANRELAX 2 + + + + +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + + + +#define SHF_ALPHA_GPREL 0x10000000 + + +#define STO_ALPHA_NOPV 0x80 +#define STO_ALPHA_STD_GPLOAD 0x88 + + + +#define R_ALPHA_NONE 0 +#define R_ALPHA_REFLONG 1 +#define R_ALPHA_REFQUAD 2 +#define R_ALPHA_GPREL32 3 +#define R_ALPHA_LITERAL 4 +#define R_ALPHA_LITUSE 5 +#define R_ALPHA_GPDISP 6 +#define R_ALPHA_BRADDR 7 +#define R_ALPHA_HINT 8 +#define R_ALPHA_SREL16 9 +#define R_ALPHA_SREL32 10 +#define R_ALPHA_SREL64 11 +#define R_ALPHA_GPRELHIGH 17 +#define R_ALPHA_GPRELLOW 18 +#define R_ALPHA_GPREL16 19 +#define R_ALPHA_COPY 24 +#define R_ALPHA_GLOB_DAT 25 +#define R_ALPHA_JMP_SLOT 26 +#define R_ALPHA_RELATIVE 27 +#define R_ALPHA_TLS_GD_HI 28 +#define R_ALPHA_TLSGD 29 +#define R_ALPHA_TLS_LDM 30 +#define R_ALPHA_DTPMOD64 31 +#define R_ALPHA_GOTDTPREL 32 +#define R_ALPHA_DTPREL64 33 +#define R_ALPHA_DTPRELHI 34 +#define R_ALPHA_DTPRELLO 35 +#define R_ALPHA_DTPREL16 36 +#define R_ALPHA_GOTTPREL 37 +#define R_ALPHA_TPREL64 38 +#define R_ALPHA_TPRELHI 39 +#define R_ALPHA_TPRELLO 40 +#define R_ALPHA_TPREL16 41 + +#define R_ALPHA_NUM 46 + + +#define LITUSE_ALPHA_ADDR 0 +#define LITUSE_ALPHA_BASE 1 +#define LITUSE_ALPHA_BYTOFF 2 +#define LITUSE_ALPHA_JSR 3 +#define LITUSE_ALPHA_TLS_GD 4 +#define LITUSE_ALPHA_TLS_LDM 5 + + +#define DT_ALPHA_PLTRO (DT_LOPROC + 0) +#define DT_ALPHA_NUM 1 + + + + +#define EF_PPC_EMB 0x80000000 + + +#define EF_PPC_RELOCATABLE 0x00010000 +#define EF_PPC_RELOCATABLE_LIB 0x00008000 + + + +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + + +#define R_PPC_TLS 67 +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 +#define R_PPC_GOT_DTPREL16 91 +#define R_PPC_GOT_DTPREL16_LO 92 +#define R_PPC_GOT_DTPREL16_HI 93 +#define R_PPC_GOT_DTPREL16_HA 94 +#define R_PPC_TLSGD 95 +#define R_PPC_TLSLD 96 + + +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + + +#define R_PPC_DIAB_SDA21_LO 180 +#define R_PPC_DIAB_SDA21_HI 181 +#define R_PPC_DIAB_SDA21_HA 182 +#define R_PPC_DIAB_RELSDA_LO 183 +#define R_PPC_DIAB_RELSDA_HI 184 +#define R_PPC_DIAB_RELSDA_HA 185 + + +#define R_PPC_IRELATIVE 248 + + +#define R_PPC_REL16 249 +#define R_PPC_REL16_LO 250 +#define R_PPC_REL16_HI 251 +#define R_PPC_REL16_HA 252 + + + +#define R_PPC_TOC16 255 + + +#define DT_PPC_GOT (DT_LOPROC + 0) +#define DT_PPC_OPT (DT_LOPROC + 1) +#define DT_PPC_NUM 2 + +#define PPC_OPT_TLS 1 + + +#define R_PPC64_NONE R_PPC_NONE +#define R_PPC64_ADDR32 R_PPC_ADDR32 +#define R_PPC64_ADDR24 R_PPC_ADDR24 +#define R_PPC64_ADDR16 R_PPC_ADDR16 +#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO +#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI +#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA +#define R_PPC64_ADDR14 R_PPC_ADDR14 +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN +#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN +#define R_PPC64_REL24 R_PPC_REL24 +#define R_PPC64_REL14 R_PPC_REL14 +#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN +#define R_PPC64_GOT16 R_PPC_GOT16 +#define R_PPC64_GOT16_LO R_PPC_GOT16_LO +#define R_PPC64_GOT16_HI R_PPC_GOT16_HI +#define R_PPC64_GOT16_HA R_PPC_GOT16_HA + +#define R_PPC64_COPY R_PPC_COPY +#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT +#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT +#define R_PPC64_RELATIVE R_PPC_RELATIVE + +#define R_PPC64_UADDR32 R_PPC_UADDR32 +#define R_PPC64_UADDR16 R_PPC_UADDR16 +#define R_PPC64_REL32 R_PPC_REL32 +#define R_PPC64_PLT32 R_PPC_PLT32 +#define R_PPC64_PLTREL32 R_PPC_PLTREL32 +#define R_PPC64_PLT16_LO R_PPC_PLT16_LO +#define R_PPC64_PLT16_HI R_PPC_PLT16_HI +#define R_PPC64_PLT16_HA R_PPC_PLT16_HA + +#define R_PPC64_SECTOFF R_PPC_SECTOFF +#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO +#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI +#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA +#define R_PPC64_ADDR30 37 +#define R_PPC64_ADDR64 38 +#define R_PPC64_ADDR16_HIGHER 39 +#define R_PPC64_ADDR16_HIGHERA 40 +#define R_PPC64_ADDR16_HIGHEST 41 +#define R_PPC64_ADDR16_HIGHESTA 42 +#define R_PPC64_UADDR64 43 +#define R_PPC64_REL64 44 +#define R_PPC64_PLT64 45 +#define R_PPC64_PLTREL64 46 +#define R_PPC64_TOC16 47 +#define R_PPC64_TOC16_LO 48 +#define R_PPC64_TOC16_HI 49 +#define R_PPC64_TOC16_HA 50 +#define R_PPC64_TOC 51 +#define R_PPC64_PLTGOT16 52 +#define R_PPC64_PLTGOT16_LO 53 +#define R_PPC64_PLTGOT16_HI 54 +#define R_PPC64_PLTGOT16_HA 55 + +#define R_PPC64_ADDR16_DS 56 +#define R_PPC64_ADDR16_LO_DS 57 +#define R_PPC64_GOT16_DS 58 +#define R_PPC64_GOT16_LO_DS 59 +#define R_PPC64_PLT16_LO_DS 60 +#define R_PPC64_SECTOFF_DS 61 +#define R_PPC64_SECTOFF_LO_DS 62 +#define R_PPC64_TOC16_DS 63 +#define R_PPC64_TOC16_LO_DS 64 +#define R_PPC64_PLTGOT16_DS 65 +#define R_PPC64_PLTGOT16_LO_DS 66 + + +#define R_PPC64_TLS 67 +#define R_PPC64_DTPMOD64 68 +#define R_PPC64_TPREL16 69 +#define R_PPC64_TPREL16_LO 70 +#define R_PPC64_TPREL16_HI 71 +#define R_PPC64_TPREL16_HA 72 +#define R_PPC64_TPREL64 73 +#define R_PPC64_DTPREL16 74 +#define R_PPC64_DTPREL16_LO 75 +#define R_PPC64_DTPREL16_HI 76 +#define R_PPC64_DTPREL16_HA 77 +#define R_PPC64_DTPREL64 78 +#define R_PPC64_GOT_TLSGD16 79 +#define R_PPC64_GOT_TLSGD16_LO 80 +#define R_PPC64_GOT_TLSGD16_HI 81 +#define R_PPC64_GOT_TLSGD16_HA 82 +#define R_PPC64_GOT_TLSLD16 83 +#define R_PPC64_GOT_TLSLD16_LO 84 +#define R_PPC64_GOT_TLSLD16_HI 85 +#define R_PPC64_GOT_TLSLD16_HA 86 +#define R_PPC64_GOT_TPREL16_DS 87 +#define R_PPC64_GOT_TPREL16_LO_DS 88 +#define R_PPC64_GOT_TPREL16_HI 89 +#define R_PPC64_GOT_TPREL16_HA 90 +#define R_PPC64_GOT_DTPREL16_DS 91 +#define R_PPC64_GOT_DTPREL16_LO_DS 92 +#define R_PPC64_GOT_DTPREL16_HI 93 +#define R_PPC64_GOT_DTPREL16_HA 94 +#define R_PPC64_TPREL16_DS 95 +#define R_PPC64_TPREL16_LO_DS 96 +#define R_PPC64_TPREL16_HIGHER 97 +#define R_PPC64_TPREL16_HIGHERA 98 +#define R_PPC64_TPREL16_HIGHEST 99 +#define R_PPC64_TPREL16_HIGHESTA 100 +#define R_PPC64_DTPREL16_DS 101 +#define R_PPC64_DTPREL16_LO_DS 102 +#define R_PPC64_DTPREL16_HIGHER 103 +#define R_PPC64_DTPREL16_HIGHERA 104 +#define R_PPC64_DTPREL16_HIGHEST 105 +#define R_PPC64_DTPREL16_HIGHESTA 106 +#define R_PPC64_TLSGD 107 +#define R_PPC64_TLSLD 108 +#define R_PPC64_TOCSAVE 109 +#define R_PPC64_ADDR16_HIGH 110 +#define R_PPC64_ADDR16_HIGHA 111 +#define R_PPC64_TPREL16_HIGH 112 +#define R_PPC64_TPREL16_HIGHA 113 +#define R_PPC64_DTPREL16_HIGH 114 +#define R_PPC64_DTPREL16_HIGHA 115 + + +#define R_PPC64_JMP_IREL 247 +#define R_PPC64_IRELATIVE 248 +#define R_PPC64_REL16 249 +#define R_PPC64_REL16_LO 250 +#define R_PPC64_REL16_HI 251 +#define R_PPC64_REL16_HA 252 + +#define EF_PPC64_ABI 3 + +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_OPD (DT_LOPROC + 1) +#define DT_PPC64_OPDSZ (DT_LOPROC + 2) +#define DT_PPC64_OPT (DT_LOPROC + 3) +#define DT_PPC64_NUM 4 + +#define PPC64_OPT_TLS 1 +#define PPC64_OPT_MULTI_TOC 2 +#define PPC64_OPT_LOCALENTRY 4 + +#define STO_PPC64_LOCAL_BIT 5 +#define STO_PPC64_LOCAL_MASK 0xe0 +#define PPC64_LOCAL_ENTRY_OFFSET(x) (1 << (((x)&0xe0)>>5) & 0xfc) + + +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 +#define EF_ARM_SOFT_FLOAT 0x200 +#define EF_ARM_VFP_FLOAT 0x400 +#define EF_ARM_MAVERICK_FLOAT 0x800 + +#define EF_ARM_ABI_FLOAT_SOFT 0x200 +#define EF_ARM_ABI_FLOAT_HARD 0x400 + + +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + + +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_LE8 0x00400000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + + +#define STT_ARM_TFUNC STT_LOPROC +#define STT_ARM_16BIT STT_HIPROC + + +#define SHF_ARM_ENTRYSECT 0x10000000 +#define SHF_ARM_COMDEF 0x80000000 + + + +#define PF_ARM_SB 0x10000000 + +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ABS 0x40000000 + + +#define PT_ARM_EXIDX (PT_LOPROC + 1) + + +#define SHT_ARM_EXIDX (SHT_LOPROC + 1) +#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) +#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) + +#define R_AARCH64_NONE 0 +#define R_AARCH64_P32_ABS32 1 +#define R_AARCH64_P32_COPY 180 +#define R_AARCH64_P32_GLOB_DAT 181 +#define R_AARCH64_P32_JUMP_SLOT 182 +#define R_AARCH64_P32_RELATIVE 183 +#define R_AARCH64_P32_TLS_DTPMOD 184 +#define R_AARCH64_P32_TLS_DTPREL 185 +#define R_AARCH64_P32_TLS_TPREL 186 +#define R_AARCH64_P32_TLSDESC 187 +#define R_AARCH64_P32_IRELATIVE 188 +#define R_AARCH64_ABS64 257 +#define R_AARCH64_ABS32 258 +#define R_AARCH64_ABS16 259 +#define R_AARCH64_PREL64 260 +#define R_AARCH64_PREL32 261 +#define R_AARCH64_PREL16 262 +#define R_AARCH64_MOVW_UABS_G0 263 +#define R_AARCH64_MOVW_UABS_G0_NC 264 +#define R_AARCH64_MOVW_UABS_G1 265 +#define R_AARCH64_MOVW_UABS_G1_NC 266 +#define R_AARCH64_MOVW_UABS_G2 267 +#define R_AARCH64_MOVW_UABS_G2_NC 268 +#define R_AARCH64_MOVW_UABS_G3 269 +#define R_AARCH64_MOVW_SABS_G0 270 +#define R_AARCH64_MOVW_SABS_G1 271 +#define R_AARCH64_MOVW_SABS_G2 272 +#define R_AARCH64_LD_PREL_LO19 273 +#define R_AARCH64_ADR_PREL_LO21 274 +#define R_AARCH64_ADR_PREL_PG_HI21 275 +#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 +#define R_AARCH64_ADD_ABS_LO12_NC 277 +#define R_AARCH64_LDST8_ABS_LO12_NC 278 +#define R_AARCH64_TSTBR14 279 +#define R_AARCH64_CONDBR19 280 +#define R_AARCH64_JUMP26 282 +#define R_AARCH64_CALL26 283 +#define R_AARCH64_LDST16_ABS_LO12_NC 284 +#define R_AARCH64_LDST32_ABS_LO12_NC 285 +#define R_AARCH64_LDST64_ABS_LO12_NC 286 +#define R_AARCH64_MOVW_PREL_G0 287 +#define R_AARCH64_MOVW_PREL_G0_NC 288 +#define R_AARCH64_MOVW_PREL_G1 289 +#define R_AARCH64_MOVW_PREL_G1_NC 290 +#define R_AARCH64_MOVW_PREL_G2 291 +#define R_AARCH64_MOVW_PREL_G2_NC 292 +#define R_AARCH64_MOVW_PREL_G3 293 +#define R_AARCH64_LDST128_ABS_LO12_NC 299 +#define R_AARCH64_MOVW_GOTOFF_G0 300 +#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 +#define R_AARCH64_MOVW_GOTOFF_G1 302 +#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 +#define R_AARCH64_MOVW_GOTOFF_G2 304 +#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 +#define R_AARCH64_MOVW_GOTOFF_G3 306 +#define R_AARCH64_GOTREL64 307 +#define R_AARCH64_GOTREL32 308 +#define R_AARCH64_GOT_LD_PREL19 309 +#define R_AARCH64_LD64_GOTOFF_LO15 310 +#define R_AARCH64_ADR_GOT_PAGE 311 +#define R_AARCH64_LD64_GOT_LO12_NC 312 +#define R_AARCH64_LD64_GOTPAGE_LO15 313 +#define R_AARCH64_TLSGD_ADR_PREL21 512 +#define R_AARCH64_TLSGD_ADR_PAGE21 513 +#define R_AARCH64_TLSGD_ADD_LO12_NC 514 +#define R_AARCH64_TLSGD_MOVW_G1 515 +#define R_AARCH64_TLSGD_MOVW_G0_NC 516 +#define R_AARCH64_TLSLD_ADR_PREL21 517 +#define R_AARCH64_TLSLD_ADR_PAGE21 518 +#define R_AARCH64_TLSLD_ADD_LO12_NC 519 +#define R_AARCH64_TLSLD_MOVW_G1 520 +#define R_AARCH64_TLSLD_MOVW_G0_NC 521 +#define R_AARCH64_TLSLD_LD_PREL19 522 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 +#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 +#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 +#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 +#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 +#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 +#define R_AARCH64_TLSDESC_LD_PREL19 560 +#define R_AARCH64_TLSDESC_ADR_PREL21 561 +#define R_AARCH64_TLSDESC_ADR_PAGE21 562 +#define R_AARCH64_TLSDESC_LD64_LO12 563 +#define R_AARCH64_TLSDESC_ADD_LO12 564 +#define R_AARCH64_TLSDESC_OFF_G1 565 +#define R_AARCH64_TLSDESC_OFF_G0_NC 566 +#define R_AARCH64_TLSDESC_LDR 567 +#define R_AARCH64_TLSDESC_ADD 568 +#define R_AARCH64_TLSDESC_CALL 569 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 +#define R_AARCH64_COPY 1024 +#define R_AARCH64_GLOB_DAT 1025 +#define R_AARCH64_JUMP_SLOT 1026 +#define R_AARCH64_RELATIVE 1027 +#define R_AARCH64_TLS_DTPMOD 1028 +#define R_AARCH64_TLS_DTPMOD64 1028 +#define R_AARCH64_TLS_DTPREL 1029 +#define R_AARCH64_TLS_DTPREL64 1029 +#define R_AARCH64_TLS_TPREL 1030 +#define R_AARCH64_TLS_TPREL64 1030 +#define R_AARCH64_TLSDESC 1031 + + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_TLS_DESC 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_TLS_DTPMOD32 17 +#define R_ARM_TLS_DTPOFF32 18 +#define R_ARM_TLS_TPOFF32 19 +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 +#define R_ARM_THM_JUMP19 51 +#define R_ARM_THM_JUMP6 52 +#define R_ARM_THM_ALU_PREL_11_0 53 +#define R_ARM_THM_PC12 54 +#define R_ARM_ABS32_NOI 55 +#define R_ARM_REL32_NOI 56 +#define R_ARM_ALU_PC_G0_NC 57 +#define R_ARM_ALU_PC_G0 58 +#define R_ARM_ALU_PC_G1_NC 59 +#define R_ARM_ALU_PC_G1 60 +#define R_ARM_ALU_PC_G2 61 +#define R_ARM_LDR_PC_G1 62 +#define R_ARM_LDR_PC_G2 63 +#define R_ARM_LDRS_PC_G0 64 +#define R_ARM_LDRS_PC_G1 65 +#define R_ARM_LDRS_PC_G2 66 +#define R_ARM_LDC_PC_G0 67 +#define R_ARM_LDC_PC_G1 68 +#define R_ARM_LDC_PC_G2 69 +#define R_ARM_ALU_SB_G0_NC 70 +#define R_ARM_ALU_SB_G0 71 +#define R_ARM_ALU_SB_G1_NC 72 +#define R_ARM_ALU_SB_G1 73 +#define R_ARM_ALU_SB_G2 74 +#define R_ARM_LDR_SB_G0 75 +#define R_ARM_LDR_SB_G1 76 +#define R_ARM_LDR_SB_G2 77 +#define R_ARM_LDRS_SB_G0 78 +#define R_ARM_LDRS_SB_G1 79 +#define R_ARM_LDRS_SB_G2 80 +#define R_ARM_LDC_SB_G0 81 +#define R_ARM_LDC_SB_G1 82 +#define R_ARM_LDC_SB_G2 83 +#define R_ARM_MOVW_BREL_NC 84 +#define R_ARM_MOVT_BREL 85 +#define R_ARM_MOVW_BREL 86 +#define R_ARM_THM_MOVW_BREL_NC 87 +#define R_ARM_THM_MOVT_BREL 88 +#define R_ARM_THM_MOVW_BREL 89 +#define R_ARM_TLS_GOTDESC 90 +#define R_ARM_TLS_CALL 91 +#define R_ARM_TLS_DESCSEQ 92 +#define R_ARM_THM_TLS_CALL 93 +#define R_ARM_PLT32_ABS 94 +#define R_ARM_GOT_ABS 95 +#define R_ARM_GOT_PREL 96 +#define R_ARM_GOT_BREL12 97 +#define R_ARM_GOTOFF12 98 +#define R_ARM_GOTRELAX 99 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 +#define R_ARM_THM_PC9 103 +#define R_ARM_TLS_GD32 104 + +#define R_ARM_TLS_LDM32 105 + +#define R_ARM_TLS_LDO32 106 + +#define R_ARM_TLS_IE32 107 + +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 +#define R_ARM_ME_TOO 128 +#define R_ARM_THM_TLS_DESCSEQ 129 +#define R_ARM_THM_TLS_DESCSEQ16 129 +#define R_ARM_THM_TLS_DESCSEQ32 130 +#define R_ARM_THM_GOT_BREL12 131 +#define R_ARM_IRELATIVE 160 +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS22 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_ARM_NUM 256 + + +#define R_CKCORE_NONE 0 +#define R_CKCORE_ADDR32 1 +#define R_CKCORE_PCRELIMM8BY4 2 +#define R_CKCORE_PCRELIMM11BY2 3 +#define R_CKCORE_PCREL32 5 +#define R_CKCORE_PCRELJSR_IMM11BY2 6 +#define R_CKCORE_RELATIVE 9 +#define R_CKCORE_COPY 10 +#define R_CKCORE_GLOB_DAT 11 +#define R_CKCORE_JUMP_SLOT 12 +#define R_CKCORE_GOTOFF 13 +#define R_CKCORE_GOTPC 14 +#define R_CKCORE_GOT32 15 +#define R_CKCORE_PLT32 16 +#define R_CKCORE_ADDRGOT 17 +#define R_CKCORE_ADDRPLT 18 +#define R_CKCORE_PCREL_IMM26BY2 19 +#define R_CKCORE_PCREL_IMM16BY2 20 +#define R_CKCORE_PCREL_IMM16BY4 21 +#define R_CKCORE_PCREL_IMM10BY2 22 +#define R_CKCORE_PCREL_IMM10BY4 23 +#define R_CKCORE_ADDR_HI16 24 +#define R_CKCORE_ADDR_LO16 25 +#define R_CKCORE_GOTPC_HI16 26 +#define R_CKCORE_GOTPC_LO16 27 +#define R_CKCORE_GOTOFF_HI16 28 +#define R_CKCORE_GOTOFF_LO16 29 +#define R_CKCORE_GOT12 30 +#define R_CKCORE_GOT_HI16 31 +#define R_CKCORE_GOT_LO16 32 +#define R_CKCORE_PLT12 33 +#define R_CKCORE_PLT_HI16 34 +#define R_CKCORE_PLT_LO16 35 +#define R_CKCORE_ADDRGOT_HI16 36 +#define R_CKCORE_ADDRGOT_LO16 37 +#define R_CKCORE_ADDRPLT_HI16 38 +#define R_CKCORE_ADDRPLT_LO16 39 +#define R_CKCORE_PCREL_JSR_IMM26BY2 40 +#define R_CKCORE_TOFFSET_LO16 41 +#define R_CKCORE_DOFFSET_LO16 42 +#define R_CKCORE_PCREL_IMM18BY2 43 +#define R_CKCORE_DOFFSET_IMM18 44 +#define R_CKCORE_DOFFSET_IMM18BY2 45 +#define R_CKCORE_DOFFSET_IMM18BY4 46 +#define R_CKCORE_GOT_IMM18BY4 48 +#define R_CKCORE_PLT_IMM18BY4 49 +#define R_CKCORE_PCREL_IMM7BY4 50 +#define R_CKCORE_TLS_LE32 51 +#define R_CKCORE_TLS_IE32 52 +#define R_CKCORE_TLS_GD32 53 +#define R_CKCORE_TLS_LDM32 54 +#define R_CKCORE_TLS_LDO32 55 +#define R_CKCORE_TLS_DTPMOD32 56 +#define R_CKCORE_TLS_DTPOFF32 57 +#define R_CKCORE_TLS_TPOFF32 58 + + +#define EF_IA_64_MASKOS 0x0000000f +#define EF_IA_64_ABI64 0x00000010 +#define EF_IA_64_ARCH 0xff000000 + + +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) +#define PT_IA_64_UNWIND (PT_LOPROC + 1) +#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) +#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) +#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) + + +#define PF_IA_64_NORECOV 0x80000000 + + +#define SHT_IA_64_EXT (SHT_LOPROC + 0) +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) + + +#define SHF_IA_64_SHORT 0x10000000 +#define SHF_IA_64_NORECOV 0x20000000 + + +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + + +#define R_IA64_NONE 0x00 +#define R_IA64_IMM14 0x21 +#define R_IA64_IMM22 0x22 +#define R_IA64_IMM64 0x23 +#define R_IA64_DIR32MSB 0x24 +#define R_IA64_DIR32LSB 0x25 +#define R_IA64_DIR64MSB 0x26 +#define R_IA64_DIR64LSB 0x27 +#define R_IA64_GPREL22 0x2a +#define R_IA64_GPREL64I 0x2b +#define R_IA64_GPREL32MSB 0x2c +#define R_IA64_GPREL32LSB 0x2d +#define R_IA64_GPREL64MSB 0x2e +#define R_IA64_GPREL64LSB 0x2f +#define R_IA64_LTOFF22 0x32 +#define R_IA64_LTOFF64I 0x33 +#define R_IA64_PLTOFF22 0x3a +#define R_IA64_PLTOFF64I 0x3b +#define R_IA64_PLTOFF64MSB 0x3e +#define R_IA64_PLTOFF64LSB 0x3f +#define R_IA64_FPTR64I 0x43 +#define R_IA64_FPTR32MSB 0x44 +#define R_IA64_FPTR32LSB 0x45 +#define R_IA64_FPTR64MSB 0x46 +#define R_IA64_FPTR64LSB 0x47 +#define R_IA64_PCREL60B 0x48 +#define R_IA64_PCREL21B 0x49 +#define R_IA64_PCREL21M 0x4a +#define R_IA64_PCREL21F 0x4b +#define R_IA64_PCREL32MSB 0x4c +#define R_IA64_PCREL32LSB 0x4d +#define R_IA64_PCREL64MSB 0x4e +#define R_IA64_PCREL64LSB 0x4f +#define R_IA64_LTOFF_FPTR22 0x52 +#define R_IA64_LTOFF_FPTR64I 0x53 +#define R_IA64_LTOFF_FPTR32MSB 0x54 +#define R_IA64_LTOFF_FPTR32LSB 0x55 +#define R_IA64_LTOFF_FPTR64MSB 0x56 +#define R_IA64_LTOFF_FPTR64LSB 0x57 +#define R_IA64_SEGREL32MSB 0x5c +#define R_IA64_SEGREL32LSB 0x5d +#define R_IA64_SEGREL64MSB 0x5e +#define R_IA64_SEGREL64LSB 0x5f +#define R_IA64_SECREL32MSB 0x64 +#define R_IA64_SECREL32LSB 0x65 +#define R_IA64_SECREL64MSB 0x66 +#define R_IA64_SECREL64LSB 0x67 +#define R_IA64_REL32MSB 0x6c +#define R_IA64_REL32LSB 0x6d +#define R_IA64_REL64MSB 0x6e +#define R_IA64_REL64LSB 0x6f +#define R_IA64_LTV32MSB 0x74 +#define R_IA64_LTV32LSB 0x75 +#define R_IA64_LTV64MSB 0x76 +#define R_IA64_LTV64LSB 0x77 +#define R_IA64_PCREL21BI 0x79 +#define R_IA64_PCREL22 0x7a +#define R_IA64_PCREL64I 0x7b +#define R_IA64_IPLTMSB 0x80 +#define R_IA64_IPLTLSB 0x81 +#define R_IA64_COPY 0x84 +#define R_IA64_SUB 0x85 +#define R_IA64_LTOFF22X 0x86 +#define R_IA64_LDXMOV 0x87 +#define R_IA64_TPREL14 0x91 +#define R_IA64_TPREL22 0x92 +#define R_IA64_TPREL64I 0x93 +#define R_IA64_TPREL64MSB 0x96 +#define R_IA64_TPREL64LSB 0x97 +#define R_IA64_LTOFF_TPREL22 0x9a +#define R_IA64_DTPMOD64MSB 0xa6 +#define R_IA64_DTPMOD64LSB 0xa7 +#define R_IA64_LTOFF_DTPMOD22 0xaa +#define R_IA64_DTPREL14 0xb1 +#define R_IA64_DTPREL22 0xb2 +#define R_IA64_DTPREL64I 0xb3 +#define R_IA64_DTPREL32MSB 0xb4 +#define R_IA64_DTPREL32LSB 0xb5 +#define R_IA64_DTPREL64MSB 0xb6 +#define R_IA64_DTPREL64LSB 0xb7 +#define R_IA64_LTOFF_DTPREL22 0xba + + +#define EF_SH_MACH_MASK 0x1f +#define EF_SH_UNKNOWN 0x0 +#define EF_SH1 0x1 +#define EF_SH2 0x2 +#define EF_SH3 0x3 +#define EF_SH_DSP 0x4 +#define EF_SH3_DSP 0x5 +#define EF_SH4AL_DSP 0x6 +#define EF_SH3E 0x8 +#define EF_SH4 0x9 +#define EF_SH2E 0xb +#define EF_SH4A 0xc +#define EF_SH2A 0xd +#define EF_SH4_NOFPU 0x10 +#define EF_SH4A_NOFPU 0x11 +#define EF_SH4_NOMMU_NOFPU 0x12 +#define EF_SH2A_NOFPU 0x13 +#define EF_SH3_NOMMU 0x14 +#define EF_SH2A_SH4_NOFPU 0x15 +#define EF_SH2A_SH3_NOFPU 0x16 +#define EF_SH2A_SH4 0x17 +#define EF_SH2A_SH3E 0x18 + +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_TLS_GD_32 144 +#define R_SH_TLS_LD_32 145 +#define R_SH_TLS_LDO_32 146 +#define R_SH_TLS_IE_32 147 +#define R_SH_TLS_LE_32 148 +#define R_SH_TLS_DTPMOD32 149 +#define R_SH_TLS_DTPOFF32 150 +#define R_SH_TLS_TPOFF32 151 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +#define R_SH_GOT20 201 +#define R_SH_GOTOFF20 202 +#define R_SH_GOTFUNCDESC 203 +#define R_SH_GOTFUNCDEST20 204 +#define R_SH_GOTOFFFUNCDESC 205 +#define R_SH_GOTOFFFUNCDEST20 206 +#define R_SH_FUNCDESC 207 +#define R_SH_FUNCDESC_VALUE 208 + +#define R_SH_NUM 256 + + + +#define R_390_NONE 0 +#define R_390_8 1 +#define R_390_12 2 +#define R_390_16 3 +#define R_390_32 4 +#define R_390_PC32 5 +#define R_390_GOT12 6 +#define R_390_GOT32 7 +#define R_390_PLT32 8 +#define R_390_COPY 9 +#define R_390_GLOB_DAT 10 +#define R_390_JMP_SLOT 11 +#define R_390_RELATIVE 12 +#define R_390_GOTOFF32 13 +#define R_390_GOTPC 14 +#define R_390_GOT16 15 +#define R_390_PC16 16 +#define R_390_PC16DBL 17 +#define R_390_PLT16DBL 18 +#define R_390_PC32DBL 19 +#define R_390_PLT32DBL 20 +#define R_390_GOTPCDBL 21 +#define R_390_64 22 +#define R_390_PC64 23 +#define R_390_GOT64 24 +#define R_390_PLT64 25 +#define R_390_GOTENT 26 +#define R_390_GOTOFF16 27 +#define R_390_GOTOFF64 28 +#define R_390_GOTPLT12 29 +#define R_390_GOTPLT16 30 +#define R_390_GOTPLT32 31 +#define R_390_GOTPLT64 32 +#define R_390_GOTPLTENT 33 +#define R_390_PLTOFF16 34 +#define R_390_PLTOFF32 35 +#define R_390_PLTOFF64 36 +#define R_390_TLS_LOAD 37 +#define R_390_TLS_GDCALL 38 + +#define R_390_TLS_LDCALL 39 + +#define R_390_TLS_GD32 40 + +#define R_390_TLS_GD64 41 + +#define R_390_TLS_GOTIE12 42 + +#define R_390_TLS_GOTIE32 43 + +#define R_390_TLS_GOTIE64 44 + +#define R_390_TLS_LDM32 45 + +#define R_390_TLS_LDM64 46 + +#define R_390_TLS_IE32 47 + +#define R_390_TLS_IE64 48 + +#define R_390_TLS_IEENT 49 + +#define R_390_TLS_LE32 50 + +#define R_390_TLS_LE64 51 + +#define R_390_TLS_LDO32 52 + +#define R_390_TLS_LDO64 53 + +#define R_390_TLS_DTPMOD 54 +#define R_390_TLS_DTPOFF 55 +#define R_390_TLS_TPOFF 56 + +#define R_390_20 57 +#define R_390_GOT20 58 +#define R_390_GOTPLT20 59 +#define R_390_TLS_GOTIE20 60 + + +#define R_390_NUM 61 + + + +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +#define R_CRIS_NUM 20 + + + +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 + +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 +#define R_X86_64_DTPMOD64 16 +#define R_X86_64_DTPOFF64 17 +#define R_X86_64_TPOFF64 18 +#define R_X86_64_TLSGD 19 + +#define R_X86_64_TLSLD 20 + +#define R_X86_64_DTPOFF32 21 +#define R_X86_64_GOTTPOFF 22 + +#define R_X86_64_TPOFF32 23 +#define R_X86_64_PC64 24 +#define R_X86_64_GOTOFF64 25 +#define R_X86_64_GOTPC32 26 +#define R_X86_64_GOT64 27 +#define R_X86_64_GOTPCREL64 28 +#define R_X86_64_GOTPC64 29 +#define R_X86_64_GOTPLT64 30 +#define R_X86_64_PLTOFF64 31 +#define R_X86_64_SIZE32 32 +#define R_X86_64_SIZE64 33 + +#define R_X86_64_GOTPC32_TLSDESC 34 +#define R_X86_64_TLSDESC_CALL 35 + +#define R_X86_64_TLSDESC 36 +#define R_X86_64_IRELATIVE 37 +#define R_X86_64_RELATIVE64 38 +#define R_X86_64_GOTPCRELX 41 +#define R_X86_64_REX_GOTPCRELX 42 +#define R_X86_64_NUM 43 + + + +#define R_MN10300_NONE 0 +#define R_MN10300_32 1 +#define R_MN10300_16 2 +#define R_MN10300_8 3 +#define R_MN10300_PCREL32 4 +#define R_MN10300_PCREL16 5 +#define R_MN10300_PCREL8 6 +#define R_MN10300_GNU_VTINHERIT 7 +#define R_MN10300_GNU_VTENTRY 8 +#define R_MN10300_24 9 +#define R_MN10300_GOTPC32 10 +#define R_MN10300_GOTPC16 11 +#define R_MN10300_GOTOFF32 12 +#define R_MN10300_GOTOFF24 13 +#define R_MN10300_GOTOFF16 14 +#define R_MN10300_PLT32 15 +#define R_MN10300_PLT16 16 +#define R_MN10300_GOT32 17 +#define R_MN10300_GOT24 18 +#define R_MN10300_GOT16 19 +#define R_MN10300_COPY 20 +#define R_MN10300_GLOB_DAT 21 +#define R_MN10300_JMP_SLOT 22 +#define R_MN10300_RELATIVE 23 + +#define R_MN10300_NUM 24 + + + +#define R_M32R_NONE 0 +#define R_M32R_16 1 +#define R_M32R_32 2 +#define R_M32R_24 3 +#define R_M32R_10_PCREL 4 +#define R_M32R_18_PCREL 5 +#define R_M32R_26_PCREL 6 +#define R_M32R_HI16_ULO 7 +#define R_M32R_HI16_SLO 8 +#define R_M32R_LO16 9 +#define R_M32R_SDA16 10 +#define R_M32R_GNU_VTINHERIT 11 +#define R_M32R_GNU_VTENTRY 12 + +#define R_M32R_16_RELA 33 +#define R_M32R_32_RELA 34 +#define R_M32R_24_RELA 35 +#define R_M32R_10_PCREL_RELA 36 +#define R_M32R_18_PCREL_RELA 37 +#define R_M32R_26_PCREL_RELA 38 +#define R_M32R_HI16_ULO_RELA 39 +#define R_M32R_HI16_SLO_RELA 40 +#define R_M32R_LO16_RELA 41 +#define R_M32R_SDA16_RELA 42 +#define R_M32R_RELA_GNU_VTINHERIT 43 +#define R_M32R_RELA_GNU_VTENTRY 44 +#define R_M32R_REL32 45 + +#define R_M32R_GOT24 48 +#define R_M32R_26_PLTREL 49 +#define R_M32R_COPY 50 +#define R_M32R_GLOB_DAT 51 +#define R_M32R_JMP_SLOT 52 +#define R_M32R_RELATIVE 53 +#define R_M32R_GOTOFF 54 +#define R_M32R_GOTPC24 55 +#define R_M32R_GOT16_HI_ULO 56 + +#define R_M32R_GOT16_HI_SLO 57 + +#define R_M32R_GOT16_LO 58 +#define R_M32R_GOTPC_HI_ULO 59 + +#define R_M32R_GOTPC_HI_SLO 60 + +#define R_M32R_GOTPC_LO 61 + +#define R_M32R_GOTOFF_HI_ULO 62 + +#define R_M32R_GOTOFF_HI_SLO 63 + +#define R_M32R_GOTOFF_LO 64 +#define R_M32R_NUM 256 + +#define R_MICROBLAZE_NONE 0 +#define R_MICROBLAZE_32 1 +#define R_MICROBLAZE_32_PCREL 2 +#define R_MICROBLAZE_64_PCREL 3 +#define R_MICROBLAZE_32_PCREL_LO 4 +#define R_MICROBLAZE_64 5 +#define R_MICROBLAZE_32_LO 6 +#define R_MICROBLAZE_SRO32 7 +#define R_MICROBLAZE_SRW32 8 +#define R_MICROBLAZE_64_NONE 9 +#define R_MICROBLAZE_32_SYM_OP_SYM 10 +#define R_MICROBLAZE_GNU_VTINHERIT 11 +#define R_MICROBLAZE_GNU_VTENTRY 12 +#define R_MICROBLAZE_GOTPC_64 13 +#define R_MICROBLAZE_GOT_64 14 +#define R_MICROBLAZE_PLT_64 15 +#define R_MICROBLAZE_REL 16 +#define R_MICROBLAZE_JUMP_SLOT 17 +#define R_MICROBLAZE_GLOB_DAT 18 +#define R_MICROBLAZE_GOTOFF_64 19 +#define R_MICROBLAZE_GOTOFF_32 20 +#define R_MICROBLAZE_COPY 21 +#define R_MICROBLAZE_TLS 22 +#define R_MICROBLAZE_TLSGD 23 +#define R_MICROBLAZE_TLSLD 24 +#define R_MICROBLAZE_TLSDTPMOD32 25 +#define R_MICROBLAZE_TLSDTPREL32 26 +#define R_MICROBLAZE_TLSDTPREL64 27 +#define R_MICROBLAZE_TLSGOTTPREL32 28 +#define R_MICROBLAZE_TLSTPREL32 29 + +#define DT_NIOS2_GP 0x70000002 + +#define R_NIOS2_NONE 0 +#define R_NIOS2_S16 1 +#define R_NIOS2_U16 2 +#define R_NIOS2_PCREL16 3 +#define R_NIOS2_CALL26 4 +#define R_NIOS2_IMM5 5 +#define R_NIOS2_CACHE_OPX 6 +#define R_NIOS2_IMM6 7 +#define R_NIOS2_IMM8 8 +#define R_NIOS2_HI16 9 +#define R_NIOS2_LO16 10 +#define R_NIOS2_HIADJ16 11 +#define R_NIOS2_BFD_RELOC_32 12 +#define R_NIOS2_BFD_RELOC_16 13 +#define R_NIOS2_BFD_RELOC_8 14 +#define R_NIOS2_GPREL 15 +#define R_NIOS2_GNU_VTINHERIT 16 +#define R_NIOS2_GNU_VTENTRY 17 +#define R_NIOS2_UJMP 18 +#define R_NIOS2_CJMP 19 +#define R_NIOS2_CALLR 20 +#define R_NIOS2_ALIGN 21 +#define R_NIOS2_GOT16 22 +#define R_NIOS2_CALL16 23 +#define R_NIOS2_GOTOFF_LO 24 +#define R_NIOS2_GOTOFF_HA 25 +#define R_NIOS2_PCREL_LO 26 +#define R_NIOS2_PCREL_HA 27 +#define R_NIOS2_TLS_GD16 28 +#define R_NIOS2_TLS_LDM16 29 +#define R_NIOS2_TLS_LDO16 30 +#define R_NIOS2_TLS_IE16 31 +#define R_NIOS2_TLS_LE16 32 +#define R_NIOS2_TLS_DTPMOD 33 +#define R_NIOS2_TLS_DTPREL 34 +#define R_NIOS2_TLS_TPREL 35 +#define R_NIOS2_COPY 36 +#define R_NIOS2_GLOB_DAT 37 +#define R_NIOS2_JUMP_SLOT 38 +#define R_NIOS2_RELATIVE 39 +#define R_NIOS2_GOTOFF 40 +#define R_NIOS2_CALL26_NOAT 41 +#define R_NIOS2_GOT_LO 42 +#define R_NIOS2_GOT_HA 43 +#define R_NIOS2_CALL_LO 44 +#define R_NIOS2_CALL_HA 45 + +#define R_OR1K_NONE 0 +#define R_OR1K_32 1 +#define R_OR1K_16 2 +#define R_OR1K_8 3 +#define R_OR1K_LO_16_IN_INSN 4 +#define R_OR1K_HI_16_IN_INSN 5 +#define R_OR1K_INSN_REL_26 6 +#define R_OR1K_GNU_VTENTRY 7 +#define R_OR1K_GNU_VTINHERIT 8 +#define R_OR1K_32_PCREL 9 +#define R_OR1K_16_PCREL 10 +#define R_OR1K_8_PCREL 11 +#define R_OR1K_GOTPC_HI16 12 +#define R_OR1K_GOTPC_LO16 13 +#define R_OR1K_GOT16 14 +#define R_OR1K_PLT26 15 +#define R_OR1K_GOTOFF_HI16 16 +#define R_OR1K_GOTOFF_LO16 17 +#define R_OR1K_COPY 18 +#define R_OR1K_GLOB_DAT 19 +#define R_OR1K_JMP_SLOT 20 +#define R_OR1K_RELATIVE 21 +#define R_OR1K_TLS_GD_HI16 22 +#define R_OR1K_TLS_GD_LO16 23 +#define R_OR1K_TLS_LDM_HI16 24 +#define R_OR1K_TLS_LDM_LO16 25 +#define R_OR1K_TLS_LDO_HI16 26 +#define R_OR1K_TLS_LDO_LO16 27 +#define R_OR1K_TLS_IE_HI16 28 +#define R_OR1K_TLS_IE_LO16 29 +#define R_OR1K_TLS_LE_HI16 30 +#define R_OR1K_TLS_LE_LO16 31 +#define R_OR1K_TLS_TPOFF 32 +#define R_OR1K_TLS_DTPOFF 33 +#define R_OR1K_TLS_DTPMOD 34 + +#define R_BPF_NONE 0 +#define R_BPF_MAP_FD 1 + +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JUMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 + +#define R_RISCV_BRANCH 16 +#define R_RISCV_JAL 17 +#define R_RISCV_CALL 18 +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 +#define R_RISCV_LO12_I 27 +#define R_RISCV_LO12_S 28 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 +#define R_RISCV_GNU_VTENTRY 42 +#define R_RISCV_ALIGN 43 +#define R_RISCV_RVC_BRANCH 44 +#define R_RISCV_RVC_JUMP 45 +#define R_RISCV_RVC_LUI 46 +#define R_RISCV_GPREL_I 47 +#define R_RISCV_GPREL_S 48 +#define R_RISCV_TPREL_I 49 +#define R_RISCV_TPREL_S 50 +#define R_RISCV_RELAX 51 +#define R_RISCV_SUB6 52 +#define R_RISCV_SET6 53 +#define R_RISCV_SET8 54 +#define R_RISCV_SET16 55 +#define R_RISCV_SET32 56 +#define R_RISCV_32_PCREL 57 + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/thirdparty/open_source/musl/libc/endian.h b/thirdparty/open_source/musl/libc/endian.h new file mode 100644 index 0000000..2a1081d --- /dev/null +++ b/thirdparty/open_source/musl/libc/endian.h @@ -0,0 +1,80 @@ +#ifndef _ENDIAN_H +#define _ENDIAN_H + +#include + +#define __NEED_uint16_t +#define __NEED_uint32_t +#define __NEED_uint64_t + +#include + +#define __PDP_ENDIAN 3412 + +#define BIG_ENDIAN __BIG_ENDIAN +#define LITTLE_ENDIAN __LITTLE_ENDIAN +#define PDP_ENDIAN __PDP_ENDIAN +#define BYTE_ORDER __BYTE_ORDER + +static __inline uint16_t __bswap16(uint16_t __x) +{ + return __x<<8 | __x>>8; +} + +static __inline uint32_t __bswap32(uint32_t __x) +{ + return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24; +} + +static __inline uint64_t __bswap64(uint64_t __x) +{ + return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32); +} + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define htobe16(x) __bswap16(x) +#define be16toh(x) __bswap16(x) +#define htobe32(x) __bswap32(x) +#define be32toh(x) __bswap32(x) +#define htobe64(x) __bswap64(x) +#define be64toh(x) __bswap64(x) +#define htole16(x) (uint16_t)(x) +#define le16toh(x) (uint16_t)(x) +#define htole32(x) (uint32_t)(x) +#define le32toh(x) (uint32_t)(x) +#define htole64(x) (uint64_t)(x) +#define le64toh(x) (uint64_t)(x) +#else +#define htobe16(x) (uint16_t)(x) +#define be16toh(x) (uint16_t)(x) +#define htobe32(x) (uint32_t)(x) +#define be32toh(x) (uint32_t)(x) +#define htobe64(x) (uint64_t)(x) +#define be64toh(x) (uint64_t)(x) +#define htole16(x) __bswap16(x) +#define le16toh(x) __bswap16(x) +#define htole32(x) __bswap32(x) +#define le32toh(x) __bswap32(x) +#define htole64(x) __bswap64(x) +#define le64toh(x) __bswap64(x) +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define betoh16(x) __bswap16(x) +#define betoh32(x) __bswap32(x) +#define betoh64(x) __bswap64(x) +#define letoh16(x) (uint16_t)(x) +#define letoh32(x) (uint32_t)(x) +#define letoh64(x) (uint64_t)(x) +#else +#define betoh16(x) (uint16_t)(x) +#define betoh32(x) (uint32_t)(x) +#define betoh64(x) (uint64_t)(x) +#define letoh16(x) __bswap16(x) +#define letoh32(x) __bswap32(x) +#define letoh64(x) __bswap64(x) +#endif +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/errno.h b/thirdparty/open_source/musl/libc/errno.h new file mode 100644 index 0000000..0361b33 --- /dev/null +++ b/thirdparty/open_source/musl/libc/errno.h @@ -0,0 +1,27 @@ +#ifndef _ERRNO_H +#define _ERRNO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +#ifdef __GNUC__ +__attribute__((const)) +#endif +int *__errno_location(void); +#define errno (*__errno_location()) + +#ifdef _GNU_SOURCE +extern char *program_invocation_short_name, *program_invocation_name; +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/thirdparty/open_source/musl/libc/fcntl.h b/thirdparty/open_source/musl/libc/fcntl.h new file mode 100644 index 0000000..b664cdc --- /dev/null +++ b/thirdparty/open_source/musl/libc/fcntl.h @@ -0,0 +1,216 @@ +#ifndef _FCNTL_H +#define _FCNTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_off_t +#define __NEED_pid_t +#define __NEED_mode_t + +#ifdef _GNU_SOURCE +#define __NEED_size_t +#define __NEED_ssize_t +#define __NEED_struct_iovec +#endif + +#include + +#include + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +int creat(const char *, mode_t); +int fcntl(int, int, ...); +int open(const char *, int, ...); +int openat(int, const char *, int, ...); +int posix_fadvise(int, off_t, off_t, int); +int posix_fallocate(int, off_t, off_t); + +#define O_SEARCH O_PATH +#define O_EXEC O_PATH +#define O_TTY_INIT 0 + +#define O_ACCMODE (03|O_SEARCH) +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 + +#define F_OFD_GETLK 36 +#define F_OFD_SETLK 37 +#define F_OFD_SETLKW 38 + +#define F_DUPFD_CLOEXEC 1030 + +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +#define FD_CLOEXEC 1 + +#define AT_FDCWD (-100) +#define AT_SYMLINK_NOFOLLOW 0x100 +#define AT_REMOVEDIR 0x200 +#define AT_SYMLINK_FOLLOW 0x400 +#define AT_EACCESS 0x200 + +#define POSIX_FADV_NORMAL 0 +#define POSIX_FADV_RANDOM 1 +#define POSIX_FADV_SEQUENTIAL 2 +#define POSIX_FADV_WILLNEED 3 +#ifndef POSIX_FADV_DONTNEED +#define POSIX_FADV_DONTNEED 4 +#define POSIX_FADV_NOREUSE 5 +#endif + +#undef SEEK_SET +#undef SEEK_CUR +#undef SEEK_END +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#ifndef S_IRUSR +#define S_ISUID 04000 +#define S_ISGID 02000 +#define S_ISVTX 01000 +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 +#define S_IRWXU 0700 +#define S_IRGRP 0040 +#define S_IWGRP 0020 +#define S_IXGRP 0010 +#define S_IRWXG 0070 +#define S_IROTH 0004 +#define S_IWOTH 0002 +#define S_IXOTH 0001 +#define S_IRWXO 0007 +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define AT_NO_AUTOMOUNT 0x800 +#define AT_EMPTY_PATH 0x1000 +#define AT_STATX_SYNC_TYPE 0x6000 +#define AT_STATX_SYNC_AS_STAT 0x0000 +#define AT_STATX_FORCE_SYNC 0x2000 +#define AT_STATX_DONT_SYNC 0x4000 +#define AT_RECURSIVE 0x8000 + +#define FAPPEND O_APPEND +#define FFSYNC O_SYNC +#define FASYNC O_ASYNC +#define FNONBLOCK O_NONBLOCK +#define FNDELAY O_NDELAY + +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_ULOCK 0 +#define F_LOCK 1 +#define F_TLOCK 2 +#define F_TEST 3 + +#define F_SETLEASE 1024 +#define F_GETLEASE 1025 +#define F_NOTIFY 1026 +#define F_CANCELLK 1029 +#define F_SETPIPE_SZ 1031 +#define F_GETPIPE_SZ 1032 +#define F_ADD_SEALS 1033 +#define F_GET_SEALS 1034 + +#define F_SEAL_SEAL 0x0001 +#define F_SEAL_SHRINK 0x0002 +#define F_SEAL_GROW 0x0004 +#define F_SEAL_WRITE 0x0008 +#define F_SEAL_FUTURE_WRITE 0x0010 + +#define F_GET_RW_HINT 1035 +#define F_SET_RW_HINT 1036 +#define F_GET_FILE_RW_HINT 1037 +#define F_SET_FILE_RW_HINT 1038 + +#define RWF_WRITE_LIFE_NOT_SET 0 +#define RWH_WRITE_LIFE_NONE 1 +#define RWH_WRITE_LIFE_SHORT 2 +#define RWH_WRITE_LIFE_MEDIUM 3 +#define RWH_WRITE_LIFE_LONG 4 +#define RWH_WRITE_LIFE_EXTREME 5 + +#define DN_ACCESS 0x00000001 +#define DN_MODIFY 0x00000002 +#define DN_CREATE 0x00000004 +#define DN_DELETE 0x00000008 +#define DN_RENAME 0x00000010 +#define DN_ATTRIB 0x00000020 +#define DN_MULTISHOT 0x80000000 + +int lockf(int, int, off_t); +#endif + +#if defined(_GNU_SOURCE) +#define F_OWNER_TID 0 +#define F_OWNER_PID 1 +#define F_OWNER_PGRP 2 +#define F_OWNER_GID 2 +struct file_handle { + unsigned handle_bytes; + int handle_type; + unsigned char f_handle[]; +}; +struct f_owner_ex { + int type; + pid_t pid; +}; +#define FALLOC_FL_KEEP_SIZE 1 +#define FALLOC_FL_PUNCH_HOLE 2 +#define MAX_HANDLE_SZ 128 +#define SYNC_FILE_RANGE_WAIT_BEFORE 1 +#define SYNC_FILE_RANGE_WRITE 2 +#define SYNC_FILE_RANGE_WAIT_AFTER 4 +#define SPLICE_F_MOVE 1 +#define SPLICE_F_NONBLOCK 2 +#define SPLICE_F_MORE 4 +#define SPLICE_F_GIFT 8 +int fallocate(int, int, off_t, off_t); +#define fallocate64 fallocate +int name_to_handle_at(int, const char *, struct file_handle *, int *, int); +int open_by_handle_at(int, struct file_handle *, int); +ssize_t readahead(int, off_t, size_t); +int sync_file_range(int, off_t, off_t, unsigned); +ssize_t vmsplice(int, const struct iovec *, size_t, unsigned); +ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned); +ssize_t tee(int, int, size_t, unsigned); +#define loff_t off_t +#endif + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define F_GETLK64 F_GETLK +#define F_SETLK64 F_SETLK +#define F_SETLKW64 F_SETLKW +#define flock64 flock +#define open64 open +#define openat64 openat +#define creat64 creat +#define lockf64 lockf +#define posix_fadvise64 posix_fadvise +#define posix_fallocate64 posix_fallocate +#define off64_t off_t +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/features.h b/thirdparty/open_source/musl/libc/features.h new file mode 100644 index 0000000..85cfb72 --- /dev/null +++ b/thirdparty/open_source/musl/libc/features.h @@ -0,0 +1,40 @@ +#ifndef _FEATURES_H +#define _FEATURES_H + +#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE 1 +#endif + +#if defined(_DEFAULT_SOURCE) && !defined(_BSD_SOURCE) +#define _BSD_SOURCE 1 +#endif + +#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \ + && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \ + && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__) +#define _BSD_SOURCE 1 +#define _XOPEN_SOURCE 700 +#endif + +#if __STDC_VERSION__ >= 199901L +#define __restrict restrict +#elif !defined(__GNUC__) +#define __restrict +#endif + +#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) +#define __inline inline +#elif !defined(__GNUC__) +#define __inline +#endif + +#if __STDC_VERSION__ >= 201112L +#elif defined(__GNUC__) +#define _Noreturn __attribute__((__noreturn__)) +#else +#define _Noreturn +#endif + +#define __REDIR(x,y) __typeof__(x) x __asm__(#y) + +#endif diff --git a/thirdparty/open_source/musl/libc/hm/hm_malloc.h b/thirdparty/open_source/musl/libc/hm/hm_malloc.h new file mode 100644 index 0000000..e2b829e --- /dev/null +++ b/thirdparty/open_source/musl/libc/hm/hm_malloc.h @@ -0,0 +1,17 @@ +#ifndef HM_MALLOC_H +#define HM_MALLOC_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*free_hook_fun)(void *, void *); +void set_free_heap_hook(free_hook_fun fn); +void use_bigheap_policy(void); +int shrink(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/hm/hm_stat.h b/thirdparty/open_source/musl/libc/hm/hm_stat.h new file mode 100644 index 0000000..ad39a13 --- /dev/null +++ b/thirdparty/open_source/musl/libc/hm/hm_stat.h @@ -0,0 +1,65 @@ +#ifndef __STAT_H_ +#define __STAT_H_ + +#ifndef HM_HOST_BUILD +#include +#ifndef S_IRWXU +#define S_IRWXU 00700 +#endif +#ifndef S_IRUSR +#define S_IRUSR 00400 +#endif +#ifndef S_IWUSR +#define S_IWUSR 00200 +#endif +#ifndef S_IXUSR +#define S_IXUSR 00100 +#endif +#ifndef S_IRWXG +#define S_IRWXG 00070 +#endif +#ifndef S_IRGRP +#define S_IRGRP 00040 +#endif +#ifndef S_IWGRP +#define S_IWGRP 00020 +#endif +#ifndef S_IXGRP +#define S_IXGRP 00010 +#endif +#ifndef S_IRWXO +#define S_IRWXO 00007 +#endif +#ifndef S_IROTH +#define S_IROTH 00004 +#endif +#ifndef S_IWOTH +#define S_IWOTH 00002 +#endif +#ifndef S_IXOTH +#define S_IXOTH 00001 +#endif +#ifndef S_ISUID +#define S_ISUID 04000 +#endif +#ifndef S_ISGID +#define S_ISGID 02000 +#endif +#ifndef S_ISVTX +#define S_ISVTX 01000 +#endif + +#define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +#define S_IALLUGO (S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO) +#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) +#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH) +#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) + +struct stat { + uid_t uid; + gid_t gid; + mode_t mode; + off_t size; +}; +#endif // ifndef HM_HOST_BUILD +#endif diff --git a/thirdparty/open_source/musl/libc/hm/hongmeng.h b/thirdparty/open_source/musl/libc/hm/hongmeng.h new file mode 100644 index 0000000..7699a1f --- /dev/null +++ b/thirdparty/open_source/musl/libc/hm/hongmeng.h @@ -0,0 +1,15 @@ +#ifndef _HONGMENG_H_ +#define _HONGMENG_H_ + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif + +#ifndef container_of +#define container_of(p, type, element) \ + ({ \ + type *q = (void *)p - offsetof(type, element); \ + q; \ + }) +#endif +#endif /* _HONGMENG_H_ */ diff --git a/thirdparty/open_source/musl/libc/hm/io.h b/thirdparty/open_source/musl/libc/hm/io.h new file mode 100644 index 0000000..61d9ef0 --- /dev/null +++ b/thirdparty/open_source/musl/libc/hm/io.h @@ -0,0 +1,38 @@ +/* + * @TAG(HUAWEI) // FIXME: this file needs rework + */ + +#ifndef __LIBC_HM_IO_H_ +#define __LIBC_HM_IO_H_ + +#include +#include + +#ifdef __arm__ +int __attribute__((noinline)) debug_call(uint64_t cap_ref, int64_t call_no, uint64_t arg1, uint64_t arg2); +#endif + +static inline void hm_debug_putchar(char c) +{ + debug_call(0, KCALL_DEBUG_CMD_PUT_CHAR, (uint64_t)(uint8_t)c, 0); +} + +static inline int hm_debug_getchar_noblock(void) +{ + return debug_call(0, KCALL_DEBUG_CMD_GET_CHAR, 0, 0); +} + +static inline int hm_debug_putbytes(char *str, size_t str_len) +{ + return debug_call(0, KCALL_DEBUG_CMD_PUT_BYTES, ptr_to_uint64(str), str_len); +} + +int putchar(int c); + +int getchar(void); + +int puts(const char *s); + +int printf(const char *format, ...); + +#endif /* __LIBC_HM_IO_H_ */ diff --git a/thirdparty/open_source/musl/libc/hm/thread.h b/thirdparty/open_source/musl/libc/hm/thread.h new file mode 100644 index 0000000..2928944 --- /dev/null +++ b/thirdparty/open_source/musl/libc/hm/thread.h @@ -0,0 +1,29 @@ +#ifndef __LIBC_HM_THREAD_H__ +#define __LIBC_HM_THREAD_H__ + +#include +#include +#include +#include +#include "hm/threadtypes.h" + +// errno.h is confilict with system errno.h. +// after rework the errno, this should be remove +#ifndef EBUSY +#define EBUSY 16 +#endif + +#ifndef EDEADLK +#define EDEADLK 35 +#endif + +#ifndef EPERM +#define EPERM 1 +#endif + +// Hongmeng thread +int set_thread_priority(cref_t thread, int priority); +unsigned long thread_tid(); +int __libc_pthread_reinit(void); + +#endif diff --git a/thirdparty/open_source/musl/libc/hm/threadtypes.h b/thirdparty/open_source/musl/libc/hm/threadtypes.h new file mode 100644 index 0000000..49a8f74 --- /dev/null +++ b/thirdparty/open_source/musl/libc/hm/threadtypes.h @@ -0,0 +1,11 @@ +#ifndef __THREAD_TYPES_H__ +#define __THREAD_TYPES_H__ + +#include + +typedef struct { + cref_t thread; + void *stack; +} hm_thread; + +#endif diff --git a/thirdparty/open_source/musl/libc/inttypes.h b/thirdparty/open_source/musl/libc/inttypes.h new file mode 100644 index 0000000..61dcb72 --- /dev/null +++ b/thirdparty/open_source/musl/libc/inttypes.h @@ -0,0 +1,229 @@ +#ifndef _INTTYPES_H +#define _INTTYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define __NEED_wchar_t +#include + +typedef struct { intmax_t quot, rem; } imaxdiv_t; + +intmax_t imaxabs(intmax_t); +imaxdiv_t imaxdiv(intmax_t, intmax_t); + +intmax_t strtoimax(const char *__restrict, char **__restrict, int); +uintmax_t strtoumax(const char *__restrict, char **__restrict, int); + +intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int); +uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); + +#if UINTPTR_MAX == UINT64_MAX +#define __PRI64 "l" +#define __PRIPTR "l" +#else +#define __PRI64 "ll" +#define __PRIPTR "" +#endif + +#define PRId8 "d" +#define PRId16 "d" +#define PRId32 "d" +#define PRId64 __PRI64 "d" + +#define PRIdLEAST8 "d" +#define PRIdLEAST16 "d" +#define PRIdLEAST32 "d" +#define PRIdLEAST64 __PRI64 "d" + +#define PRIdFAST8 "d" +#define PRIdFAST16 "d" +#define PRIdFAST32 "d" +#define PRIdFAST64 __PRI64 "d" + +#define PRIi8 "i" +#define PRIi16 "i" +#define PRIi32 "i" +#define PRIi64 __PRI64 "i" + +#define PRIiLEAST8 "i" +#define PRIiLEAST16 "i" +#define PRIiLEAST32 "i" +#define PRIiLEAST64 __PRI64 "i" + +#define PRIiFAST8 "i" +#define PRIiFAST16 "i" +#define PRIiFAST32 "i" +#define PRIiFAST64 __PRI64 "i" + +#define PRIo8 "o" +#define PRIo16 "o" +#define PRIo32 "o" +#define PRIo64 __PRI64 "o" + +#define PRIoLEAST8 "o" +#define PRIoLEAST16 "o" +#define PRIoLEAST32 "o" +#define PRIoLEAST64 __PRI64 "o" + +#define PRIoFAST8 "o" +#define PRIoFAST16 "o" +#define PRIoFAST32 "o" +#define PRIoFAST64 __PRI64 "o" + +#define PRIu8 "u" +#define PRIu16 "u" +#define PRIu32 "u" +#define PRIu64 __PRI64 "u" + +#define PRIuLEAST8 "u" +#define PRIuLEAST16 "u" +#define PRIuLEAST32 "u" +#define PRIuLEAST64 __PRI64 "u" + +#define PRIuFAST8 "u" +#define PRIuFAST16 "u" +#define PRIuFAST32 "u" +#define PRIuFAST64 __PRI64 "u" + +#define PRIx8 "x" +#define PRIx16 "x" +#define PRIx32 "x" +#define PRIx64 __PRI64 "x" + +#define PRIxLEAST8 "x" +#define PRIxLEAST16 "x" +#define PRIxLEAST32 "x" +#define PRIxLEAST64 __PRI64 "x" + +#define PRIxFAST8 "x" +#define PRIxFAST16 "x" +#define PRIxFAST32 "x" +#define PRIxFAST64 __PRI64 "x" + +#define PRIX8 "X" +#define PRIX16 "X" +#define PRIX32 "X" +#define PRIX64 __PRI64 "X" + +#define PRIXLEAST8 "X" +#define PRIXLEAST16 "X" +#define PRIXLEAST32 "X" +#define PRIXLEAST64 __PRI64 "X" + +#define PRIXFAST8 "X" +#define PRIXFAST16 "X" +#define PRIXFAST32 "X" +#define PRIXFAST64 __PRI64 "X" + +#define PRIdMAX __PRI64 "d" +#define PRIiMAX __PRI64 "i" +#define PRIoMAX __PRI64 "o" +#define PRIuMAX __PRI64 "u" +#define PRIxMAX __PRI64 "x" +#define PRIXMAX __PRI64 "X" + +#define PRIdPTR __PRIPTR "d" +#define PRIiPTR __PRIPTR "i" +#define PRIoPTR __PRIPTR "o" +#define PRIuPTR __PRIPTR "u" +#define PRIxPTR __PRIPTR "x" +#define PRIXPTR __PRIPTR "X" + +#define SCNd8 "hhd" +#define SCNd16 "hd" +#define SCNd32 "d" +#define SCNd64 __PRI64 "d" + +#define SCNdLEAST8 "hhd" +#define SCNdLEAST16 "hd" +#define SCNdLEAST32 "d" +#define SCNdLEAST64 __PRI64 "d" + +#define SCNdFAST8 "hhd" +#define SCNdFAST16 "d" +#define SCNdFAST32 "d" +#define SCNdFAST64 __PRI64 "d" + +#define SCNi8 "hhi" +#define SCNi16 "hi" +#define SCNi32 "i" +#define SCNi64 __PRI64 "i" + +#define SCNiLEAST8 "hhi" +#define SCNiLEAST16 "hi" +#define SCNiLEAST32 "i" +#define SCNiLEAST64 __PRI64 "i" + +#define SCNiFAST8 "hhi" +#define SCNiFAST16 "i" +#define SCNiFAST32 "i" +#define SCNiFAST64 __PRI64 "i" + +#define SCNu8 "hhu" +#define SCNu16 "hu" +#define SCNu32 "u" +#define SCNu64 __PRI64 "u" + +#define SCNuLEAST8 "hhu" +#define SCNuLEAST16 "hu" +#define SCNuLEAST32 "u" +#define SCNuLEAST64 __PRI64 "u" + +#define SCNuFAST8 "hhu" +#define SCNuFAST16 "u" +#define SCNuFAST32 "u" +#define SCNuFAST64 __PRI64 "u" + +#define SCNo8 "hho" +#define SCNo16 "ho" +#define SCNo32 "o" +#define SCNo64 __PRI64 "o" + +#define SCNoLEAST8 "hho" +#define SCNoLEAST16 "ho" +#define SCNoLEAST32 "o" +#define SCNoLEAST64 __PRI64 "o" + +#define SCNoFAST8 "hho" +#define SCNoFAST16 "o" +#define SCNoFAST32 "o" +#define SCNoFAST64 __PRI64 "o" + +#define SCNx8 "hhx" +#define SCNx16 "hx" +#define SCNx32 "x" +#define SCNx64 __PRI64 "x" + +#define SCNxLEAST8 "hhx" +#define SCNxLEAST16 "hx" +#define SCNxLEAST32 "x" +#define SCNxLEAST64 __PRI64 "x" + +#define SCNxFAST8 "hhx" +#define SCNxFAST16 "x" +#define SCNxFAST32 "x" +#define SCNxFAST64 __PRI64 "x" + +#define SCNdMAX __PRI64 "d" +#define SCNiMAX __PRI64 "i" +#define SCNoMAX __PRI64 "o" +#define SCNuMAX __PRI64 "u" +#define SCNxMAX __PRI64 "x" + +#define SCNdPTR __PRIPTR "d" +#define SCNiPTR __PRIPTR "i" +#define SCNoPTR __PRIPTR "o" +#define SCNuPTR __PRIPTR "u" +#define SCNxPTR __PRIPTR "x" + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/thirdparty/open_source/musl/libc/limits.h b/thirdparty/open_source/musl/libc/limits.h new file mode 100644 index 0000000..c9794bb --- /dev/null +++ b/thirdparty/open_source/musl/libc/limits.h @@ -0,0 +1,164 @@ +#ifndef _LIMITS_H +#define _LIMITS_H + +#include + +#include /* __LONG_MAX */ + +/* Support signed or unsigned plain-char */ + +#if '\xff' > 0 +#define CHAR_MIN 0 +#define CHAR_MAX 255 +#else +#define CHAR_MIN (-128) +#define CHAR_MAX 127 +#endif + +#define CHAR_BIT 8 +#define SCHAR_MIN (-128) +#define SCHAR_MAX 127 +#define UCHAR_MAX 255 +#define SHRT_MIN (-1-0x7fff) +#define SHRT_MAX 0x7fff +#define USHRT_MAX 0xffff +#define INT_MIN (-1-0x7fffffff) +#define INT_MAX 0x7fffffff +#define UINT_MAX 0xffffffffU +#define LONG_MIN (-LONG_MAX-1) +#define LONG_MAX __LONG_MAX +#define ULONG_MAX (2UL*LONG_MAX+1) +#define LLONG_MIN (-LLONG_MAX-1) +#define LLONG_MAX 0x7fffffffffffffffLL +#define ULLONG_MAX (2ULL*LLONG_MAX+1) + +#define MB_LEN_MAX 4 + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + +#define PIPE_BUF 4096 +#define FILESIZEBITS 64 +#ifndef NAME_MAX +#define NAME_MAX 255 +#endif +#define PATH_MAX 4096 +#define NGROUPS_MAX 32 +#define ARG_MAX 131072 +#define IOV_MAX 1024 +#define SYMLOOP_MAX 40 +#define WORD_BIT 32 +#define SSIZE_MAX LONG_MAX +#define TZNAME_MAX 6 +#define TTY_NAME_MAX 32 +#define HOST_NAME_MAX 255 + +#if LONG_MAX == 0x7fffffffL +#define LONG_BIT 32 +#else +#define LONG_BIT 64 +#endif + +/* Implementation choices... */ + +#define PTHREAD_KEYS_MAX 128 +#define PTHREAD_STACK_MIN 2048 +#define PTHREAD_DESTRUCTOR_ITERATIONS 4 +#define SEM_VALUE_MAX 0x7fffffff +#define SEM_NSEMS_MAX 256 +#define DELAYTIMER_MAX 0x7fffffff +#define MQ_PRIO_MAX 32768 +#define LOGIN_NAME_MAX 256 + +/* Arbitrary numbers... */ + +#define BC_BASE_MAX 99 +#define BC_DIM_MAX 2048 +#define BC_SCALE_MAX 99 +#define BC_STRING_MAX 1000 +#define CHARCLASS_NAME_MAX 14 +#define COLL_WEIGHTS_MAX 2 +#define EXPR_NEST_MAX 32 +#define LINE_MAX 4096 +#define RE_DUP_MAX 255 + +#define NL_ARGMAX 9 +#define NL_MSGMAX 32767 +#define NL_SETMAX 255 +#define NL_TEXTMAX 2048 + +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) + +#ifdef PAGESIZE +#define PAGE_SIZE PAGESIZE +#endif +#define NZERO 20 +#define NL_LANGMAX 32 + +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \ + || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) + +#define NL_NMAX 16 + +#endif + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +#define _POSIX_AIO_LISTIO_MAX 2 +#define _POSIX_AIO_MAX 1 +#define _POSIX_ARG_MAX 4096 +#define _POSIX_CHILD_MAX 25 +#define _POSIX_CLOCKRES_MIN 20000000 +#define _POSIX_DELAYTIMER_MAX 32 +#define _POSIX_HOST_NAME_MAX 255 +#define _POSIX_LINK_MAX 8 +#define _POSIX_LOGIN_NAME_MAX 9 +#define _POSIX_MAX_CANON 255 +#define _POSIX_MAX_INPUT 255 +#define _POSIX_MQ_OPEN_MAX 8 +#define _POSIX_MQ_PRIO_MAX 32 +#define _POSIX_NAME_MAX 14 +#define _POSIX_NGROUPS_MAX 8 +#define _POSIX_OPEN_MAX 20 +#define _POSIX_PATH_MAX 256 +#define _POSIX_PIPE_BUF 512 +#define _POSIX_RE_DUP_MAX 255 +#define _POSIX_RTSIG_MAX 8 +#define _POSIX_SEM_NSEMS_MAX 256 +#define _POSIX_SEM_VALUE_MAX 32767 +#define _POSIX_SIGQUEUE_MAX 32 +#define _POSIX_SSIZE_MAX 32767 +#define _POSIX_STREAM_MAX 8 +#define _POSIX_SS_REPL_MAX 4 +#define _POSIX_SYMLINK_MAX 255 +#define _POSIX_SYMLOOP_MAX 8 +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +#define _POSIX_THREAD_KEYS_MAX 128 +#define _POSIX_THREAD_THREADS_MAX 64 +#define _POSIX_TIMER_MAX 32 +#define _POSIX_TRACE_EVENT_NAME_MAX 30 +#define _POSIX_TRACE_NAME_MAX 8 +#define _POSIX_TRACE_SYS_MAX 8 +#define _POSIX_TRACE_USER_EVENT_MAX 32 +#define _POSIX_TTY_NAME_MAX 9 +#define _POSIX_TZNAME_MAX 6 +#define _POSIX2_BC_BASE_MAX 99 +#define _POSIX2_BC_DIM_MAX 2048 +#define _POSIX2_BC_SCALE_MAX 99 +#define _POSIX2_BC_STRING_MAX 1000 +#define _POSIX2_CHARCLASS_NAME_MAX 14 +#define _POSIX2_COLL_WEIGHTS_MAX 2 +#define _POSIX2_EXPR_NEST_MAX 32 +#define _POSIX2_LINE_MAX 2048 +#define _POSIX2_RE_DUP_MAX 255 + +#define _XOPEN_IOV_MAX 16 +#define _XOPEN_NAME_MAX 255 +#define _XOPEN_PATH_MAX 1024 + +#endif diff --git a/thirdparty/open_source/musl/libc/locale.h b/thirdparty/open_source/musl/libc/locale.h new file mode 100644 index 0000000..ce38438 --- /dev/null +++ b/thirdparty/open_source/musl/libc/locale.h @@ -0,0 +1,86 @@ +#ifndef _LOCALE_H +#define _LOCALE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif + +#define LC_CTYPE 0 +#define LC_NUMERIC 1 +#define LC_TIME 2 +#define LC_COLLATE 3 +#define LC_MONETARY 4 +#define LC_MESSAGES 5 +#define LC_ALL 6 + +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + char int_p_cs_precedes; + char int_p_sep_by_space; + char int_n_cs_precedes; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; +}; + + +char *setlocale (int, const char *); +struct lconv *localeconv(void); + + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + +#define __NEED_locale_t + +#include + +#define LC_GLOBAL_LOCALE ((locale_t)-1) + +#define LC_CTYPE_MASK (1< + +void *malloc (size_t); +void *calloc (size_t, size_t); +void *realloc (void *, size_t); +void free (void *); +void *valloc (size_t); +void *memalign(size_t, size_t); + +size_t malloc_usable_size(void *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/math.h b/thirdparty/open_source/musl/libc/math.h new file mode 100644 index 0000000..14f28ec --- /dev/null +++ b/thirdparty/open_source/musl/libc/math.h @@ -0,0 +1,442 @@ +#ifndef _MATH_H +#define _MATH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_float_t +#define __NEED_double_t +#include + +#if 100*__GNUC__+__GNUC_MINOR__ >= 303 +#define NAN __builtin_nanf("") +#define INFINITY __builtin_inff() +#else +#define NAN (0.0f/0.0f) +#define INFINITY 1e5000f +#endif + +#define HUGE_VALF INFINITY +#define HUGE_VAL ((double)INFINITY) +#define HUGE_VALL ((long double)INFINITY) + +#define MATH_ERRNO 1 +#define MATH_ERREXCEPT 2 +#define math_errhandling 2 + +#define FP_ILOGBNAN (-1-0x7fffffff) +#define FP_ILOGB0 FP_ILOGBNAN + +#define FP_NAN 0 +#define FP_INFINITE 1 +#define FP_ZERO 2 +#define FP_SUBNORMAL 3 +#define FP_NORMAL 4 + +#ifdef __FP_FAST_FMA +#define FP_FAST_FMA 1 +#endif + +#ifdef __FP_FAST_FMAF +#define FP_FAST_FMAF 1 +#endif + +#ifdef __FP_FAST_FMAL +#define FP_FAST_FMAL 1 +#endif + +int __fpclassify(double); +int __fpclassifyf(float); +int __fpclassifyl(long double); + +static __inline unsigned __FLOAT_BITS(float __f) +{ + union {float __f; unsigned __i;} __u; + __u.__f = __f; + return __u.__i; +} +static __inline unsigned long long __DOUBLE_BITS(double __f) +{ + union {double __f; unsigned long long __i;} __u; + __u.__f = __f; + return __u.__i; +} + +#define fpclassify(x) ( \ + sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \ + sizeof(x) == sizeof(double) ? __fpclassify(x) : \ + __fpclassifyl(x) ) + +#define isinf(x) ( \ + sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \ + sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \ + __fpclassifyl(x) == FP_INFINITE) + +#define isnan(x) ( \ + sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \ + sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \ + __fpclassifyl(x) == FP_NAN) + +#define isnormal(x) ( \ + sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \ + sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53 : \ + __fpclassifyl(x) == FP_NORMAL) + +#define isfinite(x) ( \ + sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 : \ + sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52 : \ + __fpclassifyl(x) > FP_INFINITE) + +int __signbit(double); +int __signbitf(float); +int __signbitl(long double); + +#define signbit(x) ( \ + sizeof(x) == sizeof(float) ? (int)(__FLOAT_BITS(x)>>31) : \ + sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x)>>63) : \ + __signbitl(x) ) + +#define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y))) + +#define __ISREL_DEF(rel, op, type) \ +static __inline int __is##rel(type __x, type __y) \ +{ return !isunordered(__x,__y) && __x op __y; } + +__ISREL_DEF(lessf, <, float_t) +__ISREL_DEF(less, <, double_t) +__ISREL_DEF(lessl, <, long double) +__ISREL_DEF(lessequalf, <=, float_t) +__ISREL_DEF(lessequal, <=, double_t) +__ISREL_DEF(lessequall, <=, long double) +__ISREL_DEF(lessgreaterf, !=, float_t) +__ISREL_DEF(lessgreater, !=, double_t) +__ISREL_DEF(lessgreaterl, !=, long double) +__ISREL_DEF(greaterf, >, float_t) +__ISREL_DEF(greater, >, double_t) +__ISREL_DEF(greaterl, >, long double) +__ISREL_DEF(greaterequalf, >=, float_t) +__ISREL_DEF(greaterequal, >=, double_t) +__ISREL_DEF(greaterequall, >=, long double) + +#define __tg_pred_2(x, y, p) ( \ + sizeof((x)+(y)) == sizeof(float) ? p##f(x, y) : \ + sizeof((x)+(y)) == sizeof(double) ? p(x, y) : \ + p##l(x, y) ) + +#define isless(x, y) __tg_pred_2(x, y, __isless) +#define islessequal(x, y) __tg_pred_2(x, y, __islessequal) +#define islessgreater(x, y) __tg_pred_2(x, y, __islessgreater) +#define isgreater(x, y) __tg_pred_2(x, y, __isgreater) +#define isgreaterequal(x, y) __tg_pred_2(x, y, __isgreaterequal) + +double acos(double); +float acosf(float); +long double acosl(long double); + +double acosh(double); +float acoshf(float); +long double acoshl(long double); + +double asin(double); +float asinf(float); +long double asinl(long double); + +double asinh(double); +float asinhf(float); +long double asinhl(long double); + +double atan(double); +float atanf(float); +long double atanl(long double); + +double atan2(double, double); +float atan2f(float, float); +long double atan2l(long double, long double); + +double atanh(double); +float atanhf(float); +long double atanhl(long double); + +double cbrt(double); +float cbrtf(float); +long double cbrtl(long double); + +double ceil(double); +float ceilf(float); +long double ceill(long double); + +double copysign(double, double); +float copysignf(float, float); +long double copysignl(long double, long double); + +double cos(double); +float cosf(float); +long double cosl(long double); + +double cosh(double); +float coshf(float); +long double coshl(long double); + +double erf(double); +float erff(float); +long double erfl(long double); + +double erfc(double); +float erfcf(float); +long double erfcl(long double); + +double exp(double); +float expf(float); +long double expl(long double); + +double exp2(double); +float exp2f(float); +long double exp2l(long double); + +double expm1(double); +float expm1f(float); +long double expm1l(long double); + +double fabs(double); +float fabsf(float); +long double fabsl(long double); + +double fdim(double, double); +float fdimf(float, float); +long double fdiml(long double, long double); + +double floor(double); +float floorf(float); +long double floorl(long double); + +double fma(double, double, double); +float fmaf(float, float, float); +long double fmal(long double, long double, long double); + +double fmax(double, double); +float fmaxf(float, float); +long double fmaxl(long double, long double); + +double fmin(double, double); +float fminf(float, float); +long double fminl(long double, long double); + +double fmod(double, double); +float fmodf(float, float); +long double fmodl(long double, long double); + +double frexp(double, int *); +float frexpf(float, int *); +long double frexpl(long double, int *); + +double hypot(double, double); +float hypotf(float, float); +long double hypotl(long double, long double); + +int ilogb(double); +int ilogbf(float); +int ilogbl(long double); + +double ldexp(double, int); +float ldexpf(float, int); +long double ldexpl(long double, int); + +double lgamma(double); +float lgammaf(float); +long double lgammal(long double); + +long long llrint(double); +long long llrintf(float); +long long llrintl(long double); + +long long llround(double); +long long llroundf(float); +long long llroundl(long double); + +double log(double); +float logf(float); +long double logl(long double); + +double log10(double); +float log10f(float); +long double log10l(long double); + +double log1p(double); +float log1pf(float); +long double log1pl(long double); + +double log2(double); +float log2f(float); +long double log2l(long double); + +double logb(double); +float logbf(float); +long double logbl(long double); + +long lrint(double); +long lrintf(float); +long lrintl(long double); + +long lround(double); +long lroundf(float); +long lroundl(long double); + +double modf(double, double *); +float modff(float, float *); +long double modfl(long double, long double *); + +double nan(const char *); +float nanf(const char *); +long double nanl(const char *); + +double nearbyint(double); +float nearbyintf(float); +long double nearbyintl(long double); + +double nextafter(double, double); +float nextafterf(float, float); +long double nextafterl(long double, long double); + +double nexttoward(double, long double); +float nexttowardf(float, long double); +long double nexttowardl(long double, long double); + +double pow(double, double); +float powf(float, float); +long double powl(long double, long double); + +double remainder(double, double); +float remainderf(float, float); +long double remainderl(long double, long double); + +double remquo(double, double, int *); +float remquof(float, float, int *); +long double remquol(long double, long double, int *); + +double rint(double); +float rintf(float); +long double rintl(long double); + +double round(double); +float roundf(float); +long double roundl(long double); + +double scalbln(double, long); +float scalblnf(float, long); +long double scalblnl(long double, long); + +double scalbn(double, int); +float scalbnf(float, int); +long double scalbnl(long double, int); + +double sin(double); +float sinf(float); +long double sinl(long double); + +double sinh(double); +float sinhf(float); +long double sinhl(long double); + +double sqrt(double); +float sqrtf(float); +long double sqrtl(long double); + +double tan(double); +float tanf(float); +long double tanl(long double); + +double tanh(double); +float tanhf(float); +long double tanhl(long double); + +double tgamma(double); +float tgammaf(float); +long double tgammal(long double); + +double trunc(double); +float truncf(float); +long double truncl(long double); + + +#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) +#undef MAXFLOAT +#define MAXFLOAT 3.40282346638528859812e+38F +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define M_E 2.7182818284590452354 /* e */ +#define M_LOG2E 1.4426950408889634074 /* log_2 e */ +#define M_LOG10E 0.43429448190325182765 /* log_10 e */ +#define M_LN2 0.69314718055994530942 /* log_e 2 */ +#define M_LN10 2.30258509299404568402 /* log_e 10 */ +#define M_PI 3.14159265358979323846 /* pi */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ + +extern int signgam; + +double j0(double); +double j1(double); +double jn(int, double); + +double y0(double); +double y1(double); +double yn(int, double); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define HUGE 3.40282346638528859812e+38F + +double drem(double, double); +float dremf(float, float); + +int finite(double); +int finitef(float); + +double scalb(double, double); +float scalbf(float, float); + +double significand(double); +float significandf(float); + +double lgamma_r(double, int*); +float lgammaf_r(float, int*); + +float j0f(float); +float j1f(float); +float jnf(int, float); + +float y0f(float); +float y1f(float); +float ynf(int, float); +#endif + +#ifdef _GNU_SOURCE +long double lgammal_r(long double, int*); + +void sincos(double, double*, double*); +void sincosf(float, float*, float*); +void sincosl(long double, long double*, long double*); + +double exp10(double); +float exp10f(float); +long double exp10l(long double); + +double pow10(double); +float pow10f(float); +long double pow10l(long double); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/netdb.h b/thirdparty/open_source/musl/libc/netdb.h new file mode 100644 index 0000000..d096c78 --- /dev/null +++ b/thirdparty/open_source/musl/libc/netdb.h @@ -0,0 +1,156 @@ +#ifndef _NETDB_H +#define _NETDB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_size_t +#include +#endif + +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; + +#define AI_PASSIVE 0x01 +#define AI_CANONNAME 0x02 +#define AI_NUMERICHOST 0x04 +#define AI_V4MAPPED 0x08 +#define AI_ALL 0x10 +#define AI_ADDRCONFIG 0x20 +#define AI_NUMERICSERV 0x400 + + +#define NI_NUMERICHOST 0x01 +#define NI_NUMERICSERV 0x02 +#define NI_NOFQDN 0x04 +#define NI_NAMEREQD 0x08 +#define NI_DGRAM 0x10 +#define NI_NUMERICSCOPE 0x100 + +#define EAI_BADFLAGS -1 +#define EAI_NONAME -2 +#define EAI_AGAIN -3 +#define EAI_FAIL -4 +#define EAI_FAMILY -6 +#define EAI_SOCKTYPE -7 +#define EAI_SERVICE -8 +#define EAI_MEMORY -10 +#define EAI_SYSTEM -11 +#define EAI_OVERFLOW -12 + +int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict); +void freeaddrinfo (struct addrinfo *); +int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int); +const char *gai_strerror(int); + + +/* Legacy functions follow (marked OBsolete in SUS) */ + +struct netent { + char *n_name; + char **n_aliases; + int n_addrtype; + uint32_t n_net; +}; + +struct hostent { + char *h_name; + char **h_aliases; + int h_addrtype; + int h_length; + char **h_addr_list; +}; +#define h_addr h_addr_list[0] + +struct servent { + char *s_name; + char **s_aliases; + int s_port; + char *s_proto; +}; + +struct protoent { + char *p_name; + char **p_aliases; + int p_proto; +}; + +void sethostent (int); +void endhostent (void); +struct hostent *gethostent (void); + +void setnetent (int); +void endnetent (void); +struct netent *getnetent (void); +struct netent *getnetbyaddr (uint32_t, int); +struct netent *getnetbyname (const char *); + +void setservent (int); +void endservent (void); +struct servent *getservent (void); +struct servent *getservbyname (const char *, const char *); +struct servent *getservbyport (int, const char *); + +void setprotoent (int); +void endprotoent (void); +struct protoent *getprotoent (void); +struct protoent *getprotobyname (const char *); +struct protoent *getprotobynumber (int); + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \ + || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \ + || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) +struct hostent *gethostbyname (const char *); +struct hostent *gethostbyaddr (const void *, socklen_t, int); +#ifdef __GNUC__ +__attribute__((const)) +#endif +int *__h_errno_location(void); +#define h_errno (*__h_errno_location()) +#define HOST_NOT_FOUND 1 +#define TRY_AGAIN 2 +#define NO_RECOVERY 3 +#define NO_DATA 4 +#define NO_ADDRESS NO_DATA +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +void herror(const char *); +const char *hstrerror(int); +int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *); +int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *); +struct hostent *gethostbyname2(const char *, int); +int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *); +int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **); +int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **); +#define EAI_NODATA -5 +#define EAI_ADDRFAMILY -9 +#define EAI_INPROGRESS -100 +#define EAI_CANCELED -101 +#define EAI_NOTCANCELED -102 +#define EAI_ALLDONE -103 +#define EAI_INTR -104 +#define EAI_IDN_ENCODE -105 +#define NI_MAXHOST 255 +#define NI_MAXSERV 32 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/netinet/in.h b/thirdparty/open_source/musl/libc/netinet/in.h new file mode 100644 index 0000000..5b8b21e --- /dev/null +++ b/thirdparty/open_source/musl/libc/netinet/in.h @@ -0,0 +1,415 @@ +#ifndef _NETINET_IN_H +#define _NETINET_IN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +typedef uint16_t in_port_t; +typedef uint32_t in_addr_t; +struct in_addr { in_addr_t s_addr; }; + +struct sockaddr_in { + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + uint8_t sin_zero[8]; +}; + +struct in6_addr { + union { + uint8_t __s6_addr[16]; + uint16_t __s6_addr16[8]; + uint32_t __s6_addr32[4]; + } __in6_union; +}; +#define s6_addr __in6_union.__s6_addr +#define s6_addr16 __in6_union.__s6_addr16 +#define s6_addr32 __in6_union.__s6_addr32 + +struct sockaddr_in6 { + sa_family_t sin6_family; + in_port_t sin6_port; + uint32_t sin6_flowinfo; + struct in6_addr sin6_addr; + uint32_t sin6_scope_id; +}; + +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; + unsigned ipv6mr_interface; +}; + +#define INADDR_ANY ((in_addr_t) 0x00000000) +#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) +#define INADDR_NONE ((in_addr_t) 0xffffffff) +#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) + +#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) +#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) +#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) +#define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a) +#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) + +#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } +#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } + +extern const struct in6_addr in6addr_any, in6addr_loopback; + +#undef INET_ADDRSTRLEN +#undef INET6_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 + +uint32_t htonl(uint32_t); +uint16_t htons(uint16_t); +uint32_t ntohl(uint32_t); +uint16_t ntohs(uint16_t); + +#define IPPORT_RESERVED 1024 + +#define IPPROTO_IP 0 +#define IPPROTO_HOPOPTS 0 +#define IPPROTO_ICMP 1 +#define IPPROTO_IGMP 2 +#define IPPROTO_IPIP 4 +#define IPPROTO_TCP 6 +#define IPPROTO_EGP 8 +#define IPPROTO_PUP 12 +#define IPPROTO_UDP 17 +#define IPPROTO_IDP 22 +#define IPPROTO_TP 29 +#define IPPROTO_DCCP 33 +#define IPPROTO_IPV6 41 +#define IPPROTO_ROUTING 43 +#define IPPROTO_FRAGMENT 44 +#define IPPROTO_RSVP 46 +#define IPPROTO_GRE 47 +#define IPPROTO_ESP 50 +#define IPPROTO_AH 51 +#define IPPROTO_ICMPV6 58 +#define IPPROTO_NONE 59 +#define IPPROTO_DSTOPTS 60 +#define IPPROTO_MTP 92 +#define IPPROTO_BEETPH 94 +#define IPPROTO_ENCAP 98 +#define IPPROTO_PIM 103 +#define IPPROTO_COMP 108 +#define IPPROTO_SCTP 132 +#define IPPROTO_MH 135 +#define IPPROTO_UDPLITE 136 +#define IPPROTO_MPLS 137 +#define IPPROTO_RAW 255 +#define IPPROTO_MAX 256 + +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ + ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == 0) + +#define IN6_IS_ADDR_LOOPBACK(a) \ + (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ + ((uint32_t *) (a))[2] == 0 && \ + ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && \ + ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 ) + +#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff) + +#define IN6_IS_ADDR_LINKLOCAL(a) \ + ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80) + +#define IN6_IS_ADDR_SITELOCAL(a) \ + ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0xc0) + +#define IN6_IS_ADDR_V4MAPPED(a) \ + (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ + ((uint8_t *) (a))[8] == 0 && ((uint8_t *) (a))[9] == 0 && \ + ((uint8_t *) (a))[10] == 0xff && ((uint8_t *) (a))[11] == 0xff) + +#define IN6_IS_ADDR_V4COMPAT(a) \ + (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ + ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[15] > 1) + +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x1)) + +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x2)) + +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x5)) + +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x8)) + +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0xe)) + +#define __ARE_4_EQUAL(a,b) \ + (!( (0[a]-0[b]) | (1[a]-1[b]) | (2[a]-2[b]) | (3[a]-3[b]) )) +#define IN6_ARE_ADDR_EQUAL(a,b) \ + __ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b)) + +#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) +#define IN_CLASSA_MAX 128 +#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) +#define IN_CLASSB_MAX 65536 +#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) +#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000) +#define IN_MULTICAST(a) IN_CLASSD(a) +#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) +#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000) + +#define IN_LOOPBACKNET 127 + + +#define IP_TOS 1 +#define IP_TTL 2 +#define IP_HDRINCL 3 +#define IP_OPTIONS 4 +#define IP_ROUTER_ALERT 5 +#define IP_RECVOPTS 6 +#define IP_RETOPTS 7 +#define IP_PKTINFO 8 +#define IP_PKTOPTIONS 9 +#define IP_PMTUDISC 10 +#define IP_MTU_DISCOVER 10 +#define IP_RECVERR 11 +#define IP_RECVTTL 12 +#define IP_RECVTOS 13 +#define IP_MTU 14 +#define IP_FREEBIND 15 +#define IP_IPSEC_POLICY 16 +#define IP_XFRM_POLICY 17 +#define IP_PASSSEC 18 +#define IP_TRANSPARENT 19 +#define IP_ORIGDSTADDR 20 +#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR +#define IP_MINTTL 21 +#define IP_NODEFRAG 22 +#define IP_CHECKSUM 23 +#define IP_BIND_ADDRESS_NO_PORT 24 +#define IP_RECVFRAGSIZE 25 +#define IP_MULTICAST_IF 32 +#define IP_MULTICAST_TTL 33 +#define IP_MULTICAST_LOOP 34 +#define IP_ADD_MEMBERSHIP 35 +#define IP_DROP_MEMBERSHIP 36 +#define IP_UNBLOCK_SOURCE 37 +#define IP_BLOCK_SOURCE 38 +#define IP_ADD_SOURCE_MEMBERSHIP 39 +#define IP_DROP_SOURCE_MEMBERSHIP 40 +#define IP_MSFILTER 41 +#define IP_MULTICAST_ALL 49 +#define IP_UNICAST_IF 50 + +#define IP_RECVRETOPTS IP_RETOPTS + +#define IP_PMTUDISC_DONT 0 +#define IP_PMTUDISC_WANT 1 +#define IP_PMTUDISC_DO 2 +#define IP_PMTUDISC_PROBE 3 +#define IP_PMTUDISC_INTERFACE 4 +#define IP_PMTUDISC_OMIT 5 + +#define IP_DEFAULT_MULTICAST_TTL 1 +#define IP_DEFAULT_MULTICAST_LOOP 1 +#define IP_MAX_MEMBERSHIPS 20 + +struct ip_opts { + struct in_addr ip_dst; + char ip_opts[40]; +}; + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + +#define MCAST_JOIN_GROUP 42 +#define MCAST_BLOCK_SOURCE 43 +#define MCAST_UNBLOCK_SOURCE 44 +#define MCAST_LEAVE_GROUP 45 +#define MCAST_JOIN_SOURCE_GROUP 46 +#define MCAST_LEAVE_SOURCE_GROUP 47 +#define MCAST_MSFILTER 48 + +#define MCAST_EXCLUDE 0 +#define MCAST_INCLUDE 1 + +struct ip_mreq { + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; + +struct ip_mreqn { + struct in_addr imr_multiaddr; + struct in_addr imr_address; + int imr_ifindex; +}; + +struct ip_mreq_source { + struct in_addr imr_multiaddr; + struct in_addr imr_interface; + struct in_addr imr_sourceaddr; +}; + +struct ip_msfilter { + struct in_addr imsf_multiaddr; + struct in_addr imsf_interface; + uint32_t imsf_fmode; + uint32_t imsf_numsrc; + struct in_addr imsf_slist[1]; +}; +#define IP_MSFILTER_SIZE(numsrc) \ + (sizeof(struct ip_msfilter) - sizeof(struct in_addr) \ + + (numsrc) * sizeof(struct in_addr)) + +struct group_req { + uint32_t gr_interface; + struct sockaddr_storage gr_group; +}; + +struct group_source_req { + uint32_t gsr_interface; + struct sockaddr_storage gsr_group; + struct sockaddr_storage gsr_source; +}; + +struct group_filter { + uint32_t gf_interface; + struct sockaddr_storage gf_group; + uint32_t gf_fmode; + uint32_t gf_numsrc; + struct sockaddr_storage gf_slist[1]; +}; +#define GROUP_FILTER_SIZE(numsrc) \ + (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \ + + (numsrc) * sizeof(struct sockaddr_storage)) + +struct in_pktinfo { + int ipi_ifindex; + struct in_addr ipi_spec_dst; + struct in_addr ipi_addr; +}; + +struct in6_pktinfo { + struct in6_addr ipi6_addr; + unsigned ipi6_ifindex; +}; + +struct ip6_mtuinfo { + struct sockaddr_in6 ip6m_addr; + uint32_t ip6m_mtu; +}; +#endif + +#define IPV6_ADDRFORM 1 +#define IPV6_2292PKTINFO 2 +#define IPV6_2292HOPOPTS 3 +#define IPV6_2292DSTOPTS 4 +#define IPV6_2292RTHDR 5 +#define IPV6_2292PKTOPTIONS 6 +#define IPV6_CHECKSUM 7 +#define IPV6_2292HOPLIMIT 8 +#define IPV6_NEXTHOP 9 +#define IPV6_AUTHHDR 10 +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_JOIN_GROUP 20 +#define IPV6_LEAVE_GROUP 21 +#define IPV6_ROUTER_ALERT 22 +#define IPV6_MTU_DISCOVER 23 +#define IPV6_MTU 24 +#define IPV6_RECVERR 25 +#define IPV6_V6ONLY 26 +#define IPV6_JOIN_ANYCAST 27 +#define IPV6_LEAVE_ANYCAST 28 +#define IPV6_MULTICAST_ALL 29 +#define IPV6_ROUTER_ALERT_ISOLATE 30 +#define IPV6_IPSEC_POLICY 34 +#define IPV6_XFRM_POLICY 35 +#define IPV6_HDRINCL 36 + +#define IPV6_RECVPKTINFO 49 +#define IPV6_PKTINFO 50 +#define IPV6_RECVHOPLIMIT 51 +#define IPV6_HOPLIMIT 52 +#define IPV6_RECVHOPOPTS 53 +#define IPV6_HOPOPTS 54 +#define IPV6_RTHDRDSTOPTS 55 +#define IPV6_RECVRTHDR 56 +#define IPV6_RTHDR 57 +#define IPV6_RECVDSTOPTS 58 +#define IPV6_DSTOPTS 59 +#define IPV6_RECVPATHMTU 60 +#define IPV6_PATHMTU 61 +#define IPV6_DONTFRAG 62 +#define IPV6_RECVTCLASS 66 +#define IPV6_TCLASS 67 +#define IPV6_AUTOFLOWLABEL 70 +#define IPV6_ADDR_PREFERENCES 72 +#define IPV6_MINHOPCOUNT 73 +#define IPV6_ORIGDSTADDR 74 +#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR +#define IPV6_TRANSPARENT 75 +#define IPV6_UNICAST_IF 76 +#define IPV6_RECVFRAGSIZE 77 +#define IPV6_FREEBIND 78 + +#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP +#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP +#define IPV6_RXHOPOPTS IPV6_HOPOPTS +#define IPV6_RXDSTOPTS IPV6_DSTOPTS + +#define IPV6_PMTUDISC_DONT 0 +#define IPV6_PMTUDISC_WANT 1 +#define IPV6_PMTUDISC_DO 2 +#define IPV6_PMTUDISC_PROBE 3 +#define IPV6_PMTUDISC_INTERFACE 4 +#define IPV6_PMTUDISC_OMIT 5 + +#define IPV6_PREFER_SRC_TMP 0x0001 +#define IPV6_PREFER_SRC_PUBLIC 0x0002 +#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100 +#define IPV6_PREFER_SRC_COA 0x0004 +#define IPV6_PREFER_SRC_HOME 0x0400 +#define IPV6_PREFER_SRC_CGA 0x0008 +#define IPV6_PREFER_SRC_NONCGA 0x0800 + +#define IPV6_RTHDR_LOOSE 0 +#define IPV6_RTHDR_STRICT 1 + +#define IPV6_RTHDR_TYPE_0 0 + +#define __UAPI_DEF_IN_ADDR 0 +#define __UAPI_DEF_IN_IPPROTO 0 +#define __UAPI_DEF_IN_PKTINFO 0 +#define __UAPI_DEF_IP_MREQ 0 +#define __UAPI_DEF_SOCKADDR_IN 0 +#define __UAPI_DEF_IN_CLASS 0 +#define __UAPI_DEF_IN6_ADDR 0 +#define __UAPI_DEF_IN6_ADDR_ALT 0 +#define __UAPI_DEF_SOCKADDR_IN6 0 +#define __UAPI_DEF_IPV6_MREQ 0 +#define __UAPI_DEF_IPPROTO_V6 0 +#define __UAPI_DEF_IPV6_OPTIONS 0 +#define __UAPI_DEF_IN6_PKTINFO 0 +#define __UAPI_DEF_IP6_MTUINFO 0 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/netinet/tcp.h b/thirdparty/open_source/musl/libc/netinet/tcp.h new file mode 100644 index 0000000..44a007a --- /dev/null +++ b/thirdparty/open_source/musl/libc/netinet/tcp.h @@ -0,0 +1,282 @@ +#ifndef _NETINET_TCP_H +#define _NETINET_TCP_H + +#include + +#define TCP_NODELAY 1 +#define TCP_MAXSEG 2 +#define TCP_CORK 3 +#define TCP_KEEPIDLE 4 +#define TCP_KEEPINTVL 5 +#define TCP_KEEPCNT 6 +#define TCP_SYNCNT 7 +#define TCP_LINGER2 8 +#define TCP_DEFER_ACCEPT 9 +#define TCP_WINDOW_CLAMP 10 +#define TCP_INFO 11 +#define TCP_QUICKACK 12 +#define TCP_CONGESTION 13 +#define TCP_MD5SIG 14 +#define TCP_THIN_LINEAR_TIMEOUTS 16 +#define TCP_THIN_DUPACK 17 +#define TCP_USER_TIMEOUT 18 +#define TCP_REPAIR 19 +#define TCP_REPAIR_QUEUE 20 +#define TCP_QUEUE_SEQ 21 +#define TCP_REPAIR_OPTIONS 22 +#define TCP_FASTOPEN 23 +#define TCP_TIMESTAMP 24 +#define TCP_NOTSENT_LOWAT 25 +#define TCP_CC_INFO 26 +#define TCP_SAVE_SYN 27 +#define TCP_SAVED_SYN 28 +#define TCP_REPAIR_WINDOW 29 +#define TCP_FASTOPEN_CONNECT 30 +#define TCP_ULP 31 +#define TCP_MD5SIG_EXT 32 +#define TCP_FASTOPEN_KEY 33 +#define TCP_FASTOPEN_NO_COOKIE 34 +#define TCP_ZEROCOPY_RECEIVE 35 +#define TCP_INQ 36 +#define TCP_TX_DELAY 37 + +#define TCP_CM_INQ TCP_INQ + +#define TCP_ESTABLISHED 1 +#define TCP_SYN_SENT 2 +#define TCP_SYN_RECV 3 +#define TCP_FIN_WAIT1 4 +#define TCP_FIN_WAIT2 5 +#define TCP_TIME_WAIT 6 +#define TCP_CLOSE 7 +#define TCP_CLOSE_WAIT 8 +#define TCP_LAST_ACK 9 +#define TCP_LISTEN 10 +#define TCP_CLOSING 11 + +enum { + TCP_NLA_PAD, + TCP_NLA_BUSY, + TCP_NLA_RWND_LIMITED, + TCP_NLA_SNDBUF_LIMITED, + TCP_NLA_DATA_SEGS_OUT, + TCP_NLA_TOTAL_RETRANS, + TCP_NLA_PACING_RATE, + TCP_NLA_DELIVERY_RATE, + TCP_NLA_SND_CWND, + TCP_NLA_REORDERING, + TCP_NLA_MIN_RTT, + TCP_NLA_RECUR_RETRANS, + TCP_NLA_DELIVERY_RATE_APP_LMT, + TCP_NLA_SNDQ_SIZE, + TCP_NLA_CA_STATE, + TCP_NLA_SND_SSTHRESH, + TCP_NLA_DELIVERED, + TCP_NLA_DELIVERED_CE, + TCP_NLA_BYTES_SENT, + TCP_NLA_BYTES_RETRANS, + TCP_NLA_DSACK_DUPS, + TCP_NLA_REORD_SEEN, + TCP_NLA_SRTT, +}; + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define TCPOPT_EOL 0 +#define TCPOPT_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOPT_WINDOW 3 +#define TCPOPT_SACK_PERMITTED 4 +#define TCPOPT_SACK 5 +#define TCPOPT_TIMESTAMP 8 +#define TCPOLEN_SACK_PERMITTED 2 +#define TCPOLEN_WINDOW 3 +#define TCPOLEN_MAXSEG 4 +#define TCPOLEN_TIMESTAMP 10 + +#define SOL_TCP 6 + +#include +#include +#include + +typedef uint32_t tcp_seq; + +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 + +struct tcphdr { +#ifdef _GNU_SOURCE +#ifdef __GNUC__ + __extension__ +#endif + union { struct { + + uint16_t source; + uint16_t dest; + uint32_t seq; + uint32_t ack_seq; +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint16_t res1:4; + uint16_t doff:4; + uint16_t fin:1; + uint16_t syn:1; + uint16_t rst:1; + uint16_t psh:1; + uint16_t ack:1; + uint16_t urg:1; + uint16_t res2:2; +#else + uint16_t doff:4; + uint16_t res1:4; + uint16_t res2:2; + uint16_t urg:1; + uint16_t ack:1; + uint16_t psh:1; + uint16_t rst:1; + uint16_t syn:1; + uint16_t fin:1; +#endif + uint16_t window; + uint16_t check; + uint16_t urg_ptr; + + }; struct { +#endif + + uint16_t th_sport; + uint16_t th_dport; + uint32_t th_seq; + uint32_t th_ack; +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint8_t th_x2:4; + uint8_t th_off:4; +#else + uint8_t th_off:4; + uint8_t th_x2:4; +#endif + uint8_t th_flags; + uint16_t th_win; + uint16_t th_sum; + uint16_t th_urp; + +#ifdef _GNU_SOURCE + }; }; +#endif +}; +#endif + +#ifdef _GNU_SOURCE +#define TCPI_OPT_TIMESTAMPS 1 +#define TCPI_OPT_SACK 2 +#define TCPI_OPT_WSCALE 4 +#define TCPI_OPT_ECN 8 + +#define TCP_CA_Open 0 +#define TCP_CA_Disorder 1 +#define TCP_CA_CWR 2 +#define TCP_CA_Recovery 3 +#define TCP_CA_Loss 4 + +struct tcp_info { + uint8_t tcpi_state; + uint8_t tcpi_ca_state; + uint8_t tcpi_retransmits; + uint8_t tcpi_probes; + uint8_t tcpi_backoff; + uint8_t tcpi_options; + uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; + uint8_t tcpi_delivery_rate_app_limited : 1; + uint32_t tcpi_rto; + uint32_t tcpi_ato; + uint32_t tcpi_snd_mss; + uint32_t tcpi_rcv_mss; + uint32_t tcpi_unacked; + uint32_t tcpi_sacked; + uint32_t tcpi_lost; + uint32_t tcpi_retrans; + uint32_t tcpi_fackets; + uint32_t tcpi_last_data_sent; + uint32_t tcpi_last_ack_sent; + uint32_t tcpi_last_data_recv; + uint32_t tcpi_last_ack_recv; + uint32_t tcpi_pmtu; + uint32_t tcpi_rcv_ssthresh; + uint32_t tcpi_rtt; + uint32_t tcpi_rttvar; + uint32_t tcpi_snd_ssthresh; + uint32_t tcpi_snd_cwnd; + uint32_t tcpi_advmss; + uint32_t tcpi_reordering; + uint32_t tcpi_rcv_rtt; + uint32_t tcpi_rcv_space; + uint32_t tcpi_total_retrans; + uint64_t tcpi_pacing_rate; + uint64_t tcpi_max_pacing_rate; + uint64_t tcpi_bytes_acked; + uint64_t tcpi_bytes_received; + uint32_t tcpi_segs_out; + uint32_t tcpi_segs_in; + uint32_t tcpi_notsent_bytes; + uint32_t tcpi_min_rtt; + uint32_t tcpi_data_segs_in; + uint32_t tcpi_data_segs_out; + uint64_t tcpi_delivery_rate; + uint64_t tcpi_busy_time; + uint64_t tcpi_rwnd_limited; + uint64_t tcpi_sndbuf_limited; + uint32_t tcpi_delivered; + uint32_t tcpi_delivered_ce; + uint64_t tcpi_bytes_sent; + uint64_t tcpi_bytes_retrans; + uint32_t tcpi_dsack_dups; + uint32_t tcpi_reord_seen; + uint32_t tcpi_rcv_ooopack; + uint32_t tcpi_snd_wnd; +}; + +#define TCP_MD5SIG_MAXKEYLEN 80 + +#define TCP_MD5SIG_FLAG_PREFIX 1 + +struct tcp_md5sig { + struct sockaddr_storage tcpm_addr; + uint8_t tcpm_flags; + uint8_t tcpm_prefixlen; + uint16_t tcpm_keylen; + uint32_t __tcpm_pad; + uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; +}; + +struct tcp_diag_md5sig { + uint8_t tcpm_family; + uint8_t tcpm_prefixlen; + uint16_t tcpm_keylen; + uint32_t tcpm_addr[4]; + uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; +}; + +#define TCP_REPAIR_ON 1 +#define TCP_REPAIR_OFF 0 +#define TCP_REPAIR_OFF_NO_WP -1 + +struct tcp_repair_window { + uint32_t snd_wl1; + uint32_t snd_wnd; + uint32_t max_window; + uint32_t rcv_wnd; + uint32_t rcv_wup; +}; + +struct tcp_zerocopy_receive { + uint64_t address; + uint32_t length; + uint32_t recv_skip_hint; +}; + +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/poll.h b/thirdparty/open_source/musl/libc/poll.h new file mode 100644 index 0000000..472e4b8 --- /dev/null +++ b/thirdparty/open_source/musl/libc/poll.h @@ -0,0 +1,57 @@ +#ifndef _POLL_H +#define _POLL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +#define POLLIN 0x001 +#define POLLPRI 0x002 +#define POLLOUT 0x004 +#define POLLERR 0x008 +#define POLLHUP 0x010 +#define POLLNVAL 0x020 +#define POLLRDNORM 0x040 +#define POLLRDBAND 0x080 +#ifndef POLLWRNORM +#define POLLWRNORM 0x100 +#define POLLWRBAND 0x200 +#endif +#ifndef POLLMSG +#define POLLMSG 0x400 +#define POLLRDHUP 0x2000 +#endif + +typedef unsigned long nfds_t; + +struct pollfd { + int fd; + short events; + short revents; +}; + +int poll (struct pollfd *, nfds_t, int); + +#ifdef _GNU_SOURCE +#define __NEED_time_t +#define __NEED_struct_timespec +#define __NEED_sigset_t +#include +int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *); +#endif + +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +__REDIR(ppoll, __ppoll_time64); +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/pthread.h b/thirdparty/open_source/musl/libc/pthread.h new file mode 100644 index 0000000..22120b0 --- /dev/null +++ b/thirdparty/open_source/musl/libc/pthread.h @@ -0,0 +1,243 @@ +#ifndef _PTHREAD_H +#define _PTHREAD_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_time_t +#define __NEED_clockid_t +#define __NEED_struct_timespec +#define __NEED_sigset_t +#define __NEED_pthread_t +#define __NEED_pthread_attr_t +#define __NEED_pthread_mutexattr_t +#define __NEED_pthread_condattr_t +#define __NEED_pthread_rwlockattr_t +#define __NEED_pthread_barrierattr_t +#define __NEED_pthread_mutex_t +#define __NEED_pthread_cond_t +#define __NEED_pthread_rwlock_t +#define __NEED_pthread_barrier_t +#define __NEED_pthread_spinlock_t +#define __NEED_pthread_key_t +#define __NEED_pthread_once_t +#define __NEED_size_t + +#include + +#include +#include + +#define PTHREAD_CREATE_JOINABLE 0 +#define PTHREAD_CREATE_DETACHED 1 + +#define PTHREAD_MUTEX_NORMAL 0 +#define PTHREAD_MUTEX_DEFAULT 0 +#define PTHREAD_MUTEX_RECURSIVE 1 +#define PTHREAD_MUTEX_ERRORCHECK 2 + +#define PTHREAD_MUTEX_STALLED 0 +#define PTHREAD_MUTEX_ROBUST 1 + +#define PTHREAD_PRIO_NONE 0 +#define PTHREAD_PRIO_INHERIT 1 +#define PTHREAD_PRIO_PROTECT 2 + +#define PTHREAD_INHERIT_SCHED 0 +#define PTHREAD_EXPLICIT_SCHED 1 + +#define PTHREAD_SCOPE_SYSTEM 0 +#define PTHREAD_SCOPE_PROCESS 1 + +#define PTHREAD_PROCESS_PRIVATE 0 +#define PTHREAD_PROCESS_SHARED 1 + + +#define PTHREAD_MUTEX_INITIALIZER {{{0}}} +#define PTHREAD_RWLOCK_INITIALIZER {{{0}}} +#define PTHREAD_COND_INITIALIZER {{{0}}} +#define PTHREAD_ONCE_INIT 0 +/* robust mutex init */ +#define PTHREAD_ROBUST_MUTEX_INITIALIZER { .__u.__i[0] = 132 } + + +#define PTHREAD_CANCEL_ENABLE 0 +#define PTHREAD_CANCEL_DISABLE 1 +#define PTHREAD_CANCEL_MASKED 2 + +#define PTHREAD_CANCEL_DEFERRED 0 +#define PTHREAD_CANCEL_ASYNCHRONOUS 1 + +#define PTHREAD_CANCELED ((void *)-1) + + +#define PTHREAD_BARRIER_SERIAL_THREAD (-1) + + +int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void *(*)(void *), void *__restrict); +int pthread_detach(pthread_t); +_Noreturn void pthread_exit(void *); +int pthread_join(pthread_t, void **); + +#ifdef __GNUC__ +__attribute__((const)) +#endif +pthread_t pthread_self(void); + +int pthread_equal(pthread_t, pthread_t); +#ifndef __cplusplus +#define pthread_equal(x,y) ((x)==(y)) +#endif + +int pthread_setcancelstate(int, int *); +int pthread_setcanceltype(int, int *); +void pthread_testcancel(void); +int pthread_cancel(pthread_t); + +int pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict); +int pthread_setschedparam(pthread_t, int, const struct sched_param *); +int pthread_setschedprio(pthread_t, int); + +int pthread_once(pthread_once_t *, void (*)(void)); + +int pthread_mutex_init(pthread_mutex_t *__restrict, const pthread_mutexattr_t *__restrict); +int pthread_mutex_lock(pthread_mutex_t *); +int pthread_mutex_unlock(pthread_mutex_t *); +int pthread_mutex_trylock(pthread_mutex_t *); +int pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict); +int pthread_mutex_destroy(pthread_mutex_t *); +int pthread_mutex_consistent(pthread_mutex_t *); + +int pthread_mutex_getprioceiling(const pthread_mutex_t *__restrict, int *__restrict); +int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict, int, int *__restrict); + +int pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__restrict); +int pthread_cond_destroy(pthread_cond_t *); +int pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict); +int pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict); +int pthread_cond_broadcast(pthread_cond_t *); +int pthread_cond_signal(pthread_cond_t *); + +int pthread_rwlock_init(pthread_rwlock_t *__restrict, const pthread_rwlockattr_t *__restrict); +int pthread_rwlock_destroy(pthread_rwlock_t *); +int pthread_rwlock_rdlock(pthread_rwlock_t *); +int pthread_rwlock_tryrdlock(pthread_rwlock_t *); +int pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); +int pthread_rwlock_wrlock(pthread_rwlock_t *); +int pthread_rwlock_trywrlock(pthread_rwlock_t *); +int pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); +int pthread_rwlock_unlock(pthread_rwlock_t *); + +int pthread_spin_init(pthread_spinlock_t *, int); +int pthread_spin_destroy(pthread_spinlock_t *); +int pthread_spin_lock(pthread_spinlock_t *); +int pthread_spin_trylock(pthread_spinlock_t *); +int pthread_spin_unlock(pthread_spinlock_t *); + +int pthread_barrier_init(pthread_barrier_t *__restrict, const pthread_barrierattr_t *__restrict, unsigned); +int pthread_barrier_destroy(pthread_barrier_t *); +int pthread_barrier_wait(pthread_barrier_t *); + +int pthread_key_create(pthread_key_t *, void (*)(void *)); +int pthread_key_delete(pthread_key_t); +void *pthread_getspecific(pthread_key_t); +int pthread_setspecific(pthread_key_t, const void *); + +int pthread_attr_init(pthread_attr_t *); +int pthread_attr_destroy(pthread_attr_t *); + +int pthread_attr_getguardsize(const pthread_attr_t *__restrict, size_t *__restrict); +int pthread_attr_setguardsize(pthread_attr_t *, size_t); +int pthread_attr_getstacksize(const pthread_attr_t *__restrict, size_t *__restrict); +int pthread_attr_setstacksize(pthread_attr_t *, size_t); +int pthread_attr_getdetachstate(const pthread_attr_t *, int *); +int pthread_attr_setdetachstate(pthread_attr_t *, int); +int pthread_attr_getstack(const pthread_attr_t *__restrict, void **__restrict, size_t *__restrict); +int pthread_attr_setstack(pthread_attr_t *, void *, size_t); +int pthread_attr_getscope(const pthread_attr_t *__restrict, int *__restrict); +int pthread_attr_setscope(pthread_attr_t *, int); +int pthread_attr_getschedpolicy(const pthread_attr_t *__restrict, int *__restrict); +int pthread_attr_setschedpolicy(pthread_attr_t *, int); +int pthread_attr_getschedparam(const pthread_attr_t *__restrict, struct sched_param *__restrict); +int pthread_attr_setschedparam(pthread_attr_t *__restrict, const struct sched_param *__restrict); +int pthread_attr_getinheritsched(const pthread_attr_t *__restrict, int *__restrict); +int pthread_attr_setinheritsched(pthread_attr_t *, int); +int pthread_attr_settee(pthread_attr_t *, int ca, int task_id, int shadow); + +int pthread_mutexattr_destroy(pthread_mutexattr_t *); +int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict, int *__restrict); +int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict, int *__restrict); +int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict, int *__restrict); +int pthread_mutexattr_getrobust(const pthread_mutexattr_t *__restrict, int *__restrict); +int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict, int *__restrict); +int pthread_mutexattr_init(pthread_mutexattr_t *); +int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int); +int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); +int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); +int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int); +int pthread_mutexattr_settype(pthread_mutexattr_t *, int); + +int pthread_condattr_init(pthread_condattr_t *); +int pthread_condattr_destroy(pthread_condattr_t *); +int pthread_condattr_setclock(pthread_condattr_t *, clockid_t); +int pthread_condattr_setpshared(pthread_condattr_t *, int); +int pthread_condattr_getclock(const pthread_condattr_t *__restrict, clockid_t *__restrict); +int pthread_condattr_getpshared(const pthread_condattr_t *__restrict, int *__restrict); + +int pthread_rwlockattr_init(pthread_rwlockattr_t *); +int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *__restrict, int *__restrict); + +int pthread_barrierattr_destroy(pthread_barrierattr_t *); +int pthread_barrierattr_getpshared(const pthread_barrierattr_t *__restrict, int *__restrict); +int pthread_barrierattr_init(pthread_barrierattr_t *); +int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); + +int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); + +int pthread_getconcurrency(void); +int pthread_setconcurrency(int); + +int pthread_getcpuclockid(pthread_t, clockid_t *); + +struct __ptcb { + void (*__f)(void *); + void *__x; + struct __ptcb *__next; +}; + +void _pthread_cleanup_push(struct __ptcb *, void (*)(void *), void *); +void _pthread_cleanup_pop(struct __ptcb *, int); + +#define pthread_cleanup_push(f, x) do { struct __ptcb __cb; _pthread_cleanup_push(&__cb, f, x); +#define pthread_cleanup_pop(r) _pthread_cleanup_pop(&__cb, (r)); } while(0) + +#ifdef _GNU_SOURCE +struct cpu_set_t; +int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *); +int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *); +int pthread_getattr_np(pthread_t, pthread_attr_t *); +int pthread_setname_np(pthread_t, const char *); +int pthread_getattr_default_np(pthread_attr_t *); +int pthread_setattr_default_np(const pthread_attr_t *); +int pthread_tryjoin_np(pthread_t, void **); +int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); +#endif + +#if _REDIR_TIME64 +__REDIR(pthread_mutex_timedlock, __pthread_mutex_timedlock_time64); +__REDIR(pthread_cond_timedwait, __pthread_cond_timedwait_time64); +__REDIR(pthread_rwlock_timedrdlock, __pthread_rwlock_timedrdlock_time64); +__REDIR(pthread_rwlock_timedwrlock, __pthread_rwlock_timedwrlock_time64); +#ifdef _GNU_SOURCE +__REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64); +#endif +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sched.h b/thirdparty/open_source/musl/libc/sched.h new file mode 100644 index 0000000..822f464 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sched.h @@ -0,0 +1,147 @@ +#ifndef _SCHED_H +#define _SCHED_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_struct_timespec +#define __NEED_pid_t +#define __NEED_time_t + +#ifdef _GNU_SOURCE +#define __NEED_size_t +#endif + +#include + +struct sched_param { + int sched_priority; + int __reserved1; +#if _REDIR_TIME64 + long __reserved2[4]; +#else + struct { + time_t __reserved1; + long __reserved2; + } __reserved2[2]; +#endif + int __reserved3; +}; + +int sched_get_priority_max(int); +int sched_get_priority_min(int); +int sched_getparam(pid_t, struct sched_param *); +int sched_getscheduler(pid_t); +int sched_rr_get_interval(pid_t, struct timespec *); +int sched_setparam(pid_t, const struct sched_param *); +int sched_setscheduler(pid_t, int, const struct sched_param *); +int sched_yield(void); + +#define SCHED_OTHER 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 +#define SCHED_BATCH 3 +#define SCHED_IDLE 5 +#define SCHED_DEADLINE 6 +#define SCHED_RESET_ON_FORK 0x40000000 + +#ifdef _GNU_SOURCE +#define CSIGNAL 0x000000ff +#define CLONE_VM 0x00000100 +#define CLONE_FS 0x00000200 +#define CLONE_FILES 0x00000400 +#define CLONE_SIGHAND 0x00000800 +#define CLONE_PIDFD 0x00001000 +#define CLONE_PTRACE 0x00002000 +#define CLONE_VFORK 0x00004000 +#define CLONE_PARENT 0x00008000 +#define CLONE_THREAD 0x00010000 +#define CLONE_NEWNS 0x00020000 +#define CLONE_SYSVSEM 0x00040000 +#define CLONE_SETTLS 0x00080000 +#define CLONE_PARENT_SETTID 0x00100000 +#define CLONE_CHILD_CLEARTID 0x00200000 +#define CLONE_DETACHED 0x00400000 +#define CLONE_UNTRACED 0x00800000 +#define CLONE_CHILD_SETTID 0x01000000 +#define CLONE_NEWCGROUP 0x02000000 +#define CLONE_NEWUTS 0x04000000 +#define CLONE_NEWIPC 0x08000000 +#define CLONE_NEWUSER 0x10000000 +#define CLONE_NEWPID 0x20000000 +#define CLONE_NEWNET 0x40000000 +#define CLONE_IO 0x80000000 +int clone (int (*)(void *), void *, int, void *, ...); +int unshare(int); +int setns(int, int); + +void *memcpy(void *__restrict, const void *__restrict, size_t); +int memcmp(const void *, const void *, size_t); +void *memset (void *, int, size_t); +void *calloc(size_t, size_t); +void free(void *); + +typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t; +int __sched_cpucount(size_t, const cpu_set_t *); +int sched_getcpu(void); +int sched_getaffinity(pid_t, size_t, cpu_set_t *); +int sched_setaffinity(pid_t, size_t, const cpu_set_t *); + +#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \ + (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) ) + +#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=) +#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~) +#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &) + +#define __CPU_op_func_S(func, op) \ +static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \ + const cpu_set_t *__src1, const cpu_set_t *__src2) \ +{ \ + size_t __i; \ + for (__i=0; __i<__size/sizeof(long); __i++) \ + ((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \ + op ((unsigned long *)__src2)[__i] ; \ +} + +__CPU_op_func_S(AND, &) +__CPU_op_func_S(OR, |) +__CPU_op_func_S(XOR, ^) + +#define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d) +#define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d) +#define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d) + +#define CPU_COUNT_S(size,set) __sched_cpucount(size,set) +#define CPU_ZERO_S(size,set) memset(set,0,size) +#define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size)) + +#define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \ + + ((n)%(8*sizeof(long)) + 8*sizeof(long)-1)/(8*sizeof(long)) ) ) +#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) +#define CPU_FREE(set) free(set) + +#define CPU_SETSIZE 128 + +#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set) +#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set) +#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set) +#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2) +#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2) +#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2) +#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set) +#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) +#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2) + +#endif + +#if _REDIR_TIME64 +__REDIR(sched_rr_get_interval, __sched_rr_get_interval_time64); +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/semaphore.h b/thirdparty/open_source/musl/libc/semaphore.h new file mode 100644 index 0000000..3690f49 --- /dev/null +++ b/thirdparty/open_source/musl/libc/semaphore.h @@ -0,0 +1,39 @@ +#ifndef _SEMAPHORE_H +#define _SEMAPHORE_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_time_t +#define __NEED_struct_timespec +#include + +#include + +#define SEM_FAILED ((sem_t *)0) + +typedef struct { + volatile int __val[4*sizeof(long)/sizeof(int)]; +} sem_t; + +int sem_close(sem_t *); +int sem_destroy(sem_t *); +int sem_getvalue(sem_t *__restrict, int *__restrict); +int sem_init(sem_t *, int, unsigned); +sem_t *sem_open(const char *, int, ...); +int sem_post(sem_t *); +int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict); +int sem_trywait(sem_t *); +int sem_unlink(const char *); +int sem_wait(sem_t *); + +#if _REDIR_TIME64 +__REDIR(sem_timedwait, __sem_timedwait_time64); +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/setjmp.h b/thirdparty/open_source/musl/libc/setjmp.h new file mode 100644 index 0000000..2d43abf --- /dev/null +++ b/thirdparty/open_source/musl/libc/setjmp.h @@ -0,0 +1,41 @@ +#ifndef _SETJMP_H +#define _SETJMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +typedef struct __jmp_buf_tag { + __jmp_buf __jb; + unsigned long __fl; + unsigned long __ss[128/sizeof(long)]; +} jmp_buf[1]; + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +typedef jmp_buf sigjmp_buf; +int sigsetjmp (sigjmp_buf, int); +_Noreturn void siglongjmp (sigjmp_buf, int); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +int _setjmp (jmp_buf); +_Noreturn void _longjmp (jmp_buf, int); +#endif + +int setjmp (jmp_buf); +_Noreturn void longjmp (jmp_buf, int); + +#define setjmp setjmp + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/signal.h b/thirdparty/open_source/musl/libc/signal.h new file mode 100644 index 0000000..fbdf667 --- /dev/null +++ b/thirdparty/open_source/musl/libc/signal.h @@ -0,0 +1,286 @@ +#ifndef _SIGNAL_H +#define _SIGNAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) + +#ifdef _GNU_SOURCE +#define __ucontext ucontext +#endif + +#define __NEED_size_t +#define __NEED_pid_t +#define __NEED_uid_t +#define __NEED_struct_timespec +#define __NEED_pthread_t +#define __NEED_pthread_attr_t +#define __NEED_time_t +#define __NEED_clock_t +#define __NEED_sigset_t + +#include + +#define SIG_BLOCK 0 +#define SIG_UNBLOCK 1 +#define SIG_SETMASK 2 + +#define SI_ASYNCNL (-60) +#define SI_TKILL (-6) +#define SI_SIGIO (-5) +#define SI_ASYNCIO (-4) +#define SI_MESGQ (-3) +#define SI_TIMER (-2) +#define SI_QUEUE (-1) +#define SI_USER 0 +#define SI_KERNEL 128 + +typedef struct sigaltstack stack_t; + +#endif + +#include + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) + +#define SIG_HOLD ((void (*)(int)) 2) + +#define FPE_INTDIV 1 +#define FPE_INTOVF 2 +#define FPE_FLTDIV 3 +#define FPE_FLTOVF 4 +#define FPE_FLTUND 5 +#define FPE_FLTRES 6 +#define FPE_FLTINV 7 +#define FPE_FLTSUB 8 + +#define ILL_ILLOPC 1 +#define ILL_ILLOPN 2 +#define ILL_ILLADR 3 +#define ILL_ILLTRP 4 +#define ILL_PRVOPC 5 +#define ILL_PRVREG 6 +#define ILL_COPROC 7 +#define ILL_BADSTK 8 + +#define SEGV_MAPERR 1 +#define SEGV_ACCERR 2 +#define SEGV_BNDERR 3 +#define SEGV_PKUERR 4 + +#define BUS_ADRALN 1 +#define BUS_ADRERR 2 +#define BUS_OBJERR 3 +#define BUS_MCEERR_AR 4 +#define BUS_MCEERR_AO 5 + +#define CLD_EXITED 1 +#define CLD_KILLED 2 +#define CLD_DUMPED 3 +#define CLD_TRAPPED 4 +#define CLD_STOPPED 5 +#define CLD_CONTINUED 6 + +union sigval { + int sival_int; + void *sival_ptr; +}; + +typedef struct { +#ifdef __SI_SWAP_ERRNO_CODE + int si_signo, si_code, si_errno; +#else + int si_signo, si_errno, si_code; +#endif + union { + char __pad[128 - 2*sizeof(int) - sizeof(long)]; + struct { + union { + struct { + pid_t si_pid; + uid_t si_uid; + } __piduid; + struct { + int si_timerid; + int si_overrun; + } __timer; + } __first; + union { + union sigval si_value; + struct { + int si_status; + clock_t si_utime, si_stime; + } __sigchld; + } __second; + } __si_common; + struct { + void *si_addr; + short si_addr_lsb; + union { + struct { + void *si_lower; + void *si_upper; + } __addr_bnd; + unsigned si_pkey; + } __first; + } __sigfault; + struct { + long si_band; + int si_fd; + } __sigpoll; + struct { + void *si_call_addr; + int si_syscall; + unsigned si_arch; + } __sigsys; + } __si_fields; +} siginfo_t; +#define si_pid __si_fields.__si_common.__first.__piduid.si_pid +#define si_uid __si_fields.__si_common.__first.__piduid.si_uid +#define si_status __si_fields.__si_common.__second.__sigchld.si_status +#define si_utime __si_fields.__si_common.__second.__sigchld.si_utime +#define si_stime __si_fields.__si_common.__second.__sigchld.si_stime +#define si_value __si_fields.__si_common.__second.si_value +#define si_addr __si_fields.__sigfault.si_addr +#define si_addr_lsb __si_fields.__sigfault.si_addr_lsb +#define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower +#define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper +#define si_pkey __si_fields.__sigfault.__first.si_pkey +#define si_band __si_fields.__sigpoll.si_band +#define si_fd __si_fields.__sigpoll.si_fd +#define si_timerid __si_fields.__si_common.__first.__timer.si_timerid +#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun +#define si_ptr si_value.sival_ptr +#define si_int si_value.sival_int +#define si_call_addr __si_fields.__sigsys.si_call_addr +#define si_syscall __si_fields.__sigsys.si_syscall +#define si_arch __si_fields.__sigsys.si_arch + +struct sigaction { + union { + void (*sa_handler)(int); + void (*sa_sigaction)(int, siginfo_t *, void *); + } __sa_handler; + sigset_t sa_mask; + int sa_flags; + void (*sa_restorer)(void); +}; +#define sa_handler __sa_handler.sa_handler +#define sa_sigaction __sa_handler.sa_sigaction + +struct sigevent { + union sigval sigev_value; + int sigev_signo; + int sigev_notify; + void (*sigev_notify_function)(union sigval); + pthread_attr_t *sigev_notify_attributes; + char __pad[56-3*sizeof(long)]; +}; + +#define SIGEV_SIGNAL 0 +#define SIGEV_NONE 1 +#define SIGEV_THREAD 2 + +int __libc_current_sigrtmin(void); +int __libc_current_sigrtmax(void); + +#define SIGRTMIN (__libc_current_sigrtmin()) +#define SIGRTMAX (__libc_current_sigrtmax()) + +int kill(pid_t, int); + +int sigemptyset(sigset_t *); +int sigfillset(sigset_t *); +int sigaddset(sigset_t *, int); +int sigdelset(sigset_t *, int); +int sigismember(const sigset_t *, int); + +int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict); +int sigsuspend(const sigset_t *); +int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict); +int sigpending(sigset_t *); +int sigwait(const sigset_t *__restrict, int *__restrict); +int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict); +int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict); +int sigqueue(pid_t, int, union sigval); + +int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict); +int pthread_kill(pthread_t, int); + +void psiginfo(const siginfo_t *, const char *); +void psignal(int, const char *); + +#endif + +#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +int killpg(pid_t, int); +int sigaltstack(const stack_t *__restrict, stack_t *__restrict); +int sighold(int); +int sigignore(int); +int siginterrupt(int, int); +int sigpause(int); +int sigrelse(int); +void (*sigset(int, void (*)(int)))(int); +#define TRAP_BRKPT 1 +#define TRAP_TRACE 2 +#define TRAP_BRANCH 3 +#define TRAP_HWBKPT 4 +#define TRAP_UNK 5 +#define POLL_IN 1 +#define POLL_OUT 2 +#define POLL_MSG 3 +#define POLL_ERR 4 +#define POLL_PRI 5 +#define POLL_HUP 6 +#define SS_ONSTACK 1 +#define SS_DISABLE 2 +#define SS_AUTODISARM (1U << 31) +#define SS_FLAG_BITS SS_AUTODISARM +#endif + +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +#define NSIG _NSIG +typedef void (*sig_t)(int); +#endif + +#ifdef _GNU_SOURCE +typedef void (*sighandler_t)(int); +void (*bsd_signal(int, void (*)(int)))(int); +int sigisemptyset(const sigset_t *); +int sigorset (sigset_t *, const sigset_t *, const sigset_t *); +int sigandset(sigset_t *, const sigset_t *, const sigset_t *); + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND +#endif + +#define SIG_ERR ((void (*)(int))-1) +#define SIG_DFL ((void (*)(int)) 0) +#define SIG_IGN ((void (*)(int)) 1) + +typedef int sig_atomic_t; + +void (*signal(int, void (*)(int)))(int); +int raise(int); + +#if _REDIR_TIME64 +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +__REDIR(sigtimedwait, __sigtimedwait_time64); +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/stdalign.h b/thirdparty/open_source/musl/libc/stdalign.h new file mode 100644 index 0000000..2cc94be --- /dev/null +++ b/thirdparty/open_source/musl/libc/stdalign.h @@ -0,0 +1,20 @@ +#ifndef _STDALIGN_H +#define _STDALIGN_H + +#ifndef __cplusplus + +/* this whole header only works in C11 or with compiler extensions */ +#if __STDC_VERSION__ < 201112L && defined( __GNUC__) +#define _Alignas(t) __attribute__((__aligned__(t))) +#define _Alignof(t) __alignof__(t) +#endif + +#define alignas _Alignas +#define alignof _Alignof + +#endif + +#define __alignas_is_defined 1 +#define __alignof_is_defined 1 + +#endif diff --git a/thirdparty/open_source/musl/libc/stdarg.h b/thirdparty/open_source/musl/libc/stdarg.h new file mode 100644 index 0000000..3256f80 --- /dev/null +++ b/thirdparty/open_source/musl/libc/stdarg.h @@ -0,0 +1,21 @@ +#ifndef _STDARG_H +#define _STDARG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define __NEED_va_list + +#include + +#define va_start(v,l) __builtin_va_start(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v,l) __builtin_va_arg(v,l) +#define va_copy(d,s) __builtin_va_copy(d,s) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/stdbool.h b/thirdparty/open_source/musl/libc/stdbool.h new file mode 100644 index 0000000..a9d7ab7 --- /dev/null +++ b/thirdparty/open_source/musl/libc/stdbool.h @@ -0,0 +1,14 @@ +#ifndef _STDBOOL_H +#define _STDBOOL_H + +#ifndef __cplusplus + +#define true 1 +#define false 0 +#define bool _Bool + +#endif + +#define __bool_true_false_are_defined 1 + +#endif diff --git a/thirdparty/open_source/musl/libc/stddef.h b/thirdparty/open_source/musl/libc/stddef.h new file mode 100644 index 0000000..4a914ee --- /dev/null +++ b/thirdparty/open_source/musl/libc/stddef.h @@ -0,0 +1,27 @@ +#ifndef _STDDEF_H +#define _STDDEF_H + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif +#endif + +#define __NEED_ptrdiff_t +#define __NEED_size_t +#define __NEED_wchar_t +#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L +#define __NEED_max_align_t +#endif + +#include + +#if __GNUC__ > 3 +#define offsetof(type, member) __builtin_offsetof(type, member) +#else +#define offsetof(type, member) ((size_t)( (char *)&(((type *)0)->member) - (char *)0 )) +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/stdint.h b/thirdparty/open_source/musl/libc/stdint.h new file mode 100644 index 0000000..a296819 --- /dev/null +++ b/thirdparty/open_source/musl/libc/stdint.h @@ -0,0 +1,117 @@ +#ifndef _STDINT_H +#define _STDINT_H + +#define __NEED_int8_t +#define __NEED_int16_t +#define __NEED_int32_t +#define __NEED_int64_t + +#define __NEED_uint8_t +#define __NEED_uint16_t +#define __NEED_uint32_t +#define __NEED_uint64_t + +#define __NEED_intptr_t +#define __NEED_uintptr_t + +#define __NEED_intmax_t +#define __NEED_uintmax_t + +#include + +typedef int8_t int_fast8_t; +typedef int64_t int_fast64_t; + +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; + +typedef uint8_t uint_fast8_t; +typedef uint64_t uint_fast64_t; + +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +#define INT8_MIN (-1-0x7f) +#define INT16_MIN (-1-0x7fff) +#define INT32_MIN (-1-0x7fffffff) +#define INT64_MIN (-1-0x7fffffffffffffff) + +#define INT8_MAX (0x7f) +#define INT16_MAX (0x7fff) +#define INT32_MAX (0x7fffffff) +#define INT64_MAX (0x7fffffffffffffff) + +#define UINT8_MAX (0xff) +#define UINT16_MAX (0xffff) +#define UINT32_MAX (0xffffffffu) +#define UINT64_MAX (0xffffffffffffffffu) + +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST64_MAX INT64_MAX + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST64_MAX UINT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +#define WINT_MIN 0U +#define WINT_MAX UINT32_MAX + +#if L'\0'-1 > 0 +#define WCHAR_MAX (0xffffffffu+L'\0') +#define WCHAR_MIN (0+L'\0') +#else +#define WCHAR_MAX (0x7fffffff+L'\0') +#define WCHAR_MIN (-1-0x7fffffff+L'\0') +#endif + +#define SIG_ATOMIC_MIN INT32_MIN +#define SIG_ATOMIC_MAX INT32_MAX + +#include + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U + +#if UINTPTR_MAX == UINT64_MAX +#define INT64_C(c) c ## L +#define UINT64_C(c) c ## UL +#define INTMAX_C(c) c ## L +#define UINTMAX_C(c) c ## UL +#else +#define INT64_C(c) c ## LL +#define UINT64_C(c) c ## ULL +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/stdio.h b/thirdparty/open_source/musl/libc/stdio.h new file mode 100644 index 0000000..3604198 --- /dev/null +++ b/thirdparty/open_source/musl/libc/stdio.h @@ -0,0 +1,222 @@ +#ifndef _STDIO_H +#define _STDIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_FILE +#define __NEED___isoc_va_list +#define __NEED_size_t + +#if __STDC_VERSION__ < 201112L +#define __NEED_struct__IO_FILE +#endif + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +#define __NEED_ssize_t +#define __NEED_off_t +#define __NEED_va_list +#endif + +#include + +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif + +#undef EOF +#define EOF (-1) + +#undef SEEK_SET +#undef SEEK_CUR +#undef SEEK_END +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#define _IOFBF 0 +#define _IOLBF 1 +#define _IONBF 2 + +#define BUFSIZ 1024 +#define FILENAME_MAX 4096 +#define FOPEN_MAX 1000 +#define TMP_MAX 10000 +#define L_tmpnam 20 + +typedef union _G_fpos64_t { + char __opaque[16]; + long long __lldata; + double __align; +} fpos_t; + +extern FILE *const stdin; +extern FILE *const stdout; +extern FILE *const stderr; + +#define stdin (stdin) +#define stdout (stdout) +#define stderr (stderr) + +FILE *fopen(const char *__restrict, const char *__restrict); +FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict); +int fclose(FILE *); + +int remove(const char *); +int rename(const char *, const char *); + +int feof(FILE *); +int ferror(FILE *); +int fflush(FILE *); +void clearerr(FILE *); + +int fseek(FILE *, long, int); +long ftell(FILE *); +void rewind(FILE *); + +int fgetpos(FILE *__restrict, fpos_t *__restrict); +int fsetpos(FILE *, const fpos_t *); + +size_t fread(void *__restrict, size_t, size_t, FILE *__restrict); +size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict); + +int fgetc(FILE *); +int getc(FILE *); +int getchar(void); +int ungetc(int, FILE *); + +int fputc(int, FILE *); +int putc(int, FILE *); +int putchar(int); + +char *fgets(char *__restrict, int, FILE *__restrict); +#if __STDC_VERSION__ < 201112L +char *gets(char *); +#endif + +int fputs(const char *__restrict, FILE *__restrict); +int puts(const char *); + +int printf(const char *__restrict, ...); +int fprintf(FILE *__restrict, const char *__restrict, ...); +int sprintf(char *__restrict, const char *__restrict, ...); +int snprintf(char *__restrict, size_t, const char *__restrict, ...); + +int vprintf(const char *__restrict, __isoc_va_list); +int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list); +int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list); +int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list); + +int scanf(const char *__restrict, ...); +int fscanf(FILE *__restrict, const char *__restrict, ...); +int sscanf(const char *__restrict, const char *__restrict, ...); +int vscanf(const char *__restrict, __isoc_va_list); +int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list); +int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list); + +void perror(const char *); + +int setvbuf(FILE *__restrict, char *__restrict, int, size_t); +void setbuf(FILE *__restrict, char *__restrict); + +char *tmpnam(char *); +FILE *tmpfile(void); + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +FILE *fmemopen(void *__restrict, size_t, const char *__restrict); +FILE *open_memstream(char **, size_t *); +FILE *fdopen(int, const char *); +FILE *popen(const char *, const char *); +int pclose(FILE *); +int fileno(FILE *); +int fseeko(FILE *, off_t, int); +off_t ftello(FILE *); +int dprintf(int, const char *__restrict, ...); +int vdprintf(int, const char *__restrict, __isoc_va_list); +void flockfile(FILE *); +int ftrylockfile(FILE *); +void funlockfile(FILE *); +int getc_unlocked(FILE *); +int getchar_unlocked(void); +int putc_unlocked(int, FILE *); +int putchar_unlocked(int); +ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict); +ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict); +int renameat(int, const char *, int, const char *); +char *ctermid(char *); +#define L_ctermid 20 +#endif + + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +#define P_tmpdir "/tmp" +char *tempnam(const char *, const char *); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define L_cuserid 20 +char *cuserid(char *); +void setlinebuf(FILE *); +void setbuffer(FILE *, char *, size_t); +int fgetc_unlocked(FILE *); +int fputc_unlocked(int, FILE *); +int fflush_unlocked(FILE *); +size_t fread_unlocked(void *, size_t, size_t, FILE *); +size_t fwrite_unlocked(const void *, size_t, size_t, FILE *); +void clearerr_unlocked(FILE *); +int feof_unlocked(FILE *); +int ferror_unlocked(FILE *); +int fileno_unlocked(FILE *); +int getw(FILE *); +int putw(int, FILE *); +char *fgetln(FILE *, size_t *); +int asprintf(char **, const char *, ...); +int vasprintf(char **, const char *, __isoc_va_list); +#endif + +#ifdef _GNU_SOURCE +char *fgets_unlocked(char *, int, FILE *); +int fputs_unlocked(const char *, FILE *); + +typedef ssize_t (cookie_read_function_t)(void *, char *, size_t); +typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t); +typedef int (cookie_seek_function_t)(void *, off_t *, int); +typedef int (cookie_close_function_t)(void *); + +typedef struct _IO_cookie_io_functions_t { + cookie_read_function_t *read; + cookie_write_function_t *write; + cookie_seek_function_t *seek; + cookie_close_function_t *close; +} cookie_io_functions_t; + +FILE *fopencookie(void *, const char *, cookie_io_functions_t); +#endif + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define tmpfile64 tmpfile +#define fopen64 fopen +#define freopen64 freopen +#define fseeko64 fseeko +#define ftello64 ftello +#define fgetpos64 fgetpos +#define fsetpos64 fsetpos +#define fpos64_t fpos_t +#define off64_t off_t +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/stdlib.h b/thirdparty/open_source/musl/libc/stdlib.h new file mode 100644 index 0000000..194c203 --- /dev/null +++ b/thirdparty/open_source/musl/libc/stdlib.h @@ -0,0 +1,175 @@ +#ifndef _STDLIB_H +#define _STDLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif + +#define __NEED_size_t +#define __NEED_wchar_t + +#include + +int atoi (const char *); +long atol (const char *); +long long atoll (const char *); +double atof (const char *); + +float strtof (const char *__restrict, char **__restrict); +double strtod (const char *__restrict, char **__restrict); +long double strtold (const char *__restrict, char **__restrict); + +long strtol (const char *__restrict, char **__restrict, int); +unsigned long strtoul (const char *__restrict, char **__restrict, int); +long long strtoll (const char *__restrict, char **__restrict, int); +unsigned long long strtoull (const char *__restrict, char **__restrict, int); + +int rand (void); +void srand (unsigned); + +void *malloc (size_t); +void *calloc (size_t, size_t); +void *realloc (void *, size_t); +void free (void *); +void *aligned_alloc(size_t, size_t); + +_Noreturn void abort (void); +int atexit (void (*) (void)); +_Noreturn void exit (int); +_Noreturn void _Exit (int); +int at_quick_exit (void (*) (void)); +_Noreturn void quick_exit (int); + +char *getenv (const char *); + +int system (const char *); + +void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); +void qsort (void *, size_t, size_t, int (*)(const void *, const void *)); + +int abs (int); +long labs (long); +long long llabs (long long); + +typedef struct { int quot, rem; } div_t; +typedef struct { long quot, rem; } ldiv_t; +typedef struct { long long quot, rem; } lldiv_t; + +div_t div (int, int); +ldiv_t ldiv (long, long); +lldiv_t lldiv (long long, long long); + +int mblen (const char *, size_t); +int mbtowc (wchar_t *__restrict, const char *__restrict, size_t); +int wctomb (char *, wchar_t); +size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t); +size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t); + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +size_t __ctype_get_mb_cur_max(void); +#define MB_CUR_MAX (__ctype_get_mb_cur_max()) + +#define RAND_MAX (0x7fffffff) + + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) + +#define WNOHANG 1 +#define WUNTRACED 2 + +#define WEXITSTATUS(s) (((s) & 0xff00) >> 8) +#define WTERMSIG(s) ((s) & 0x7f) +#define WSTOPSIG(s) WEXITSTATUS(s) +#define WIFEXITED(s) (!WTERMSIG(s)) +#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00) +#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) + +int posix_memalign (void **, size_t, size_t); +int setenv (const char *, const char *, int); +int unsetenv (const char *); +int mkstemp (char *); +int mkostemp (char *, int); +char *mkdtemp (char *); +int getsubopt (char **, char *const *, char **); +int rand_r (unsigned *); + +#endif + + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +char *realpath (const char *__restrict, char *__restrict); +long int random (void); +void srandom (unsigned int); +char *initstate (unsigned int, char *, size_t); +char *setstate (char *); +int putenv (char *); +int posix_openpt (int); +int grantpt (int); +int unlockpt (int); +char *ptsname (int); +char *l64a (long); +long a64l (const char *); +void setkey (const char *); +double drand48 (void); +double erand48 (unsigned short [3]); +long int lrand48 (void); +long int nrand48 (unsigned short [3]); +long mrand48 (void); +long jrand48 (unsigned short [3]); +void srand48 (long); +unsigned short *seed48 (unsigned short [3]); +void lcong48 (unsigned short [7]); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#include +char *mktemp (char *); +int mkstemps (char *, int); +int mkostemps (char *, int, int); +void *valloc (size_t); +void *memalign(size_t, size_t); +int getloadavg(double *, int); +int clearenv(void); +#define WCOREDUMP(s) ((s) & 0x80) +#define WIFCONTINUED(s) ((s) == 0xffff) +#endif + +#ifdef _GNU_SOURCE +int ptsname_r(int, char *, size_t); +char *ecvt(double, int, int *, int *); +char *fcvt(double, int, int *, int *); +char *gcvt(double, int, char *); +char *secure_getenv(const char *); +struct __locale_struct; +float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *); +double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *); +long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); +#endif + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define mkstemp64 mkstemp +#define mkostemp64 mkostemp +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define mkstemps64 mkstemps +#define mkostemps64 mkostemps +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/string.h b/thirdparty/open_source/musl/libc/string.h new file mode 100644 index 0000000..795a2ab --- /dev/null +++ b/thirdparty/open_source/musl/libc/string.h @@ -0,0 +1,105 @@ +#ifndef _STRING_H +#define _STRING_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif + +#define __NEED_size_t +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +#define __NEED_locale_t +#endif + +#include + +void *memcpy (void *__restrict, const void *__restrict, size_t); +void *memmove (void *, const void *, size_t); +void *memset (void *, int, size_t); +int memcmp (const void *, const void *, size_t); +void *memchr (const void *, int, size_t); + +char *strcpy (char *__restrict, const char *__restrict); +char *strncpy (char *__restrict, const char *__restrict, size_t); + +char *strcat (char *__restrict, const char *__restrict); +char *strncat (char *__restrict, const char *__restrict, size_t); + +int strcmp (const char *, const char *); +int strncmp (const char *, const char *, size_t); + +int strcoll (const char *, const char *); +size_t strxfrm (char *__restrict, const char *__restrict, size_t); + +char *strchr (const char *, int); +char *strrchr (const char *, int); + +size_t strcspn (const char *, const char *); +size_t strspn (const char *, const char *); +char *strpbrk (const char *, const char *); +char *strstr (const char *, const char *); +char *strtok (char *__restrict, const char *__restrict); + +size_t strlen (const char *); + +char *strerror (int); + +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +#include +#endif + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +char *strtok_r (char *__restrict, const char *__restrict, char **__restrict); +int strerror_r (int, char *, size_t); +char *stpcpy(char *__restrict, const char *__restrict); +char *stpncpy(char *__restrict, const char *__restrict, size_t); +size_t strnlen (const char *, size_t); +char *strdup (const char *); +char *strndup (const char *, size_t); +char *strsignal(int); +char *strerror_l (int, locale_t); +int strcoll_l (const char *, const char *, locale_t); +size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +void *memccpy (void *__restrict, const void *__restrict, int, size_t); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +char *strsep(char **, const char *); +size_t strlcat (char *, const char *, size_t); +size_t strlcpy (char *, const char *, size_t); +void explicit_bzero (void *, size_t); +#endif + +#ifdef _GNU_SOURCE +#define strdupa(x) strcpy(alloca(strlen(x)+1),x) +int strverscmp (const char *, const char *); +char *strchrnul(const char *, int); +char *strcasestr(const char *, const char *); +void *memmem(const void *, size_t, const void *, size_t); +void *memrchr(const void *, int, size_t); +void *mempcpy(void *, const void *, size_t); +#ifndef __cplusplus +char *basename(); +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/strings.h b/thirdparty/open_source/musl/libc/strings.h new file mode 100644 index 0000000..db0960b --- /dev/null +++ b/thirdparty/open_source/musl/libc/strings.h @@ -0,0 +1,39 @@ +#ifndef _STRINGS_H +#define _STRINGS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#define __NEED_size_t +#define __NEED_locale_t +#include + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \ + || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \ + || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) +int bcmp (const void *, const void *, size_t); +void bcopy (const void *, void *, size_t); +void bzero (void *, size_t); +char *index (const char *, int); +char *rindex (const char *, int); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int ffs (int); +int ffsl (long); +int ffsll (long long); +#endif + +int strcasecmp (const char *, const char *); +int strncasecmp (const char *, const char *, size_t); + +int strcasecmp_l (const char *, const char *, locale_t); +int strncasecmp_l (const char *, const char *, size_t, locale_t); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/auxv.h b/thirdparty/open_source/musl/libc/sys/auxv.h new file mode 100644 index 0000000..ddccf57 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/auxv.h @@ -0,0 +1,17 @@ +#ifndef _SYS_AUXV_H +#define _SYS_AUXV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +unsigned long getauxval(unsigned long); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/cdefs.h b/thirdparty/open_source/musl/libc/sys/cdefs.h new file mode 100644 index 0000000..bc8c246 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/cdefs.h @@ -0,0 +1,22 @@ +#ifndef __HM_TEEOS_LIBC_COMPATABLE_CDEFS_H_ +#define __HM_TEEOS_LIBC_COMPATABLE_CDEFS_H_ + +#define __flexarr [] +#define __always_inline __attribute__((always_inline)) + +#ifdef __cplusplus +// c++ end_decls +#define __END_DECLS } +// c++ throw +#define __THROW throw () +// c++ begin +#define __BEGIN_DECLS extern "C" { +#else +// for c language macros +#define __END_DECLS +#define __THROW +// in c language __BEGIN_DELS is empty. +#define __BEGIN_DECLS +#endif + +#endif /* __HM_TEEOS_LIBC_COMPATABLE_CDEFS_H_ */ \ No newline at end of file diff --git a/thirdparty/open_source/musl/libc/sys/ioctl.h b/thirdparty/open_source/musl/libc/sys/ioctl.h new file mode 100644 index 0000000..c2ce3b4 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/ioctl.h @@ -0,0 +1,125 @@ +#ifndef _SYS_IOCTL_H +#define _SYS_IOCTL_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 +#define N_6PACK 7 +#define N_MASC 8 +#define N_R3964 9 +#define N_PROFIBUS_FDL 10 +#define N_IRDA 11 +#define N_SMSBLOCK 12 +#define N_HDLC 13 +#define N_SYNC_PPP 14 +#define N_HCI 15 +#define N_GIGASET_M101 16 +#define N_SLCAN 17 +#define N_PPS 18 +#define N_V253 19 +#define N_CAIF 20 +#define N_GSM0710 21 +#define N_TI_WL 22 +#define N_TRACESINK 23 +#define N_TRACEROUTER 24 +#define N_NCI 25 +#define N_SPEAKUP 26 +#define N_NULL 27 + +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 +#define TIOCPKT_IOCTL 64 + +#define TIOCSER_TEMT 1 + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define SIOCADDRT 0x890B +#define SIOCDELRT 0x890C +#define SIOCRTMSG 0x890D + +#define SIOCGIFNAME 0x8910 +#define SIOCSIFLINK 0x8911 +#define SIOCGIFCONF 0x8912 +#define SIOCGIFFLAGS 0x8913 +#define SIOCSIFFLAGS 0x8914 +#define SIOCGIFADDR 0x8915 +#define SIOCSIFADDR 0x8916 +#define SIOCGIFDSTADDR 0x8917 +#define SIOCSIFDSTADDR 0x8918 +#define SIOCGIFBRDADDR 0x8919 +#define SIOCSIFBRDADDR 0x891a +#define SIOCGIFNETMASK 0x891b +#define SIOCSIFNETMASK 0x891c +#define SIOCGIFMETRIC 0x891d +#define SIOCSIFMETRIC 0x891e +#define SIOCGIFMEM 0x891f +#define SIOCSIFMEM 0x8920 +#define SIOCGIFMTU 0x8921 +#define SIOCSIFMTU 0x8922 +#define SIOCSIFNAME 0x8923 +#define SIOCSIFHWADDR 0x8924 +#define SIOCGIFENCAP 0x8925 +#define SIOCSIFENCAP 0x8926 +#define SIOCGIFHWADDR 0x8927 +#define SIOCGIFSLAVE 0x8929 +#define SIOCSIFSLAVE 0x8930 +#define SIOCADDMULTI 0x8931 +#define SIOCDELMULTI 0x8932 +#define SIOCGIFINDEX 0x8933 +#define SIOGIFINDEX SIOCGIFINDEX +#define SIOCSIFPFLAGS 0x8934 +#define SIOCGIFPFLAGS 0x8935 +#define SIOCDIFADDR 0x8936 +#define SIOCSIFHWBROADCAST 0x8937 +#define SIOCGIFCOUNT 0x8938 + +#define SIOCGIFBR 0x8940 +#define SIOCSIFBR 0x8941 + +#define SIOCGIFTXQLEN 0x8942 +#define SIOCSIFTXQLEN 0x8943 + +#define SIOCDARP 0x8953 +#define SIOCGARP 0x8954 +#define SIOCSARP 0x8955 + +#define SIOCDRARP 0x8960 +#define SIOCGRARP 0x8961 +#define SIOCSRARP 0x8962 + +#define SIOCGIFMAP 0x8970 +#define SIOCSIFMAP 0x8971 + +#define SIOCADDDLCI 0x8980 +#define SIOCDELDLCI 0x8981 + +#define SIOCDEVPRIVATE 0x89F0 +#define SIOCPROTOPRIVATE 0x89E0 + +int ioctl (int, int, ...); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sys/mman.h b/thirdparty/open_source/musl/libc/sys/mman.h new file mode 100644 index 0000000..105af9d --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/mman.h @@ -0,0 +1,151 @@ +#ifndef _SYS_MMAN_H +#define _SYS_MMAN_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_mode_t +#define __NEED_size_t +#define __NEED_off_t + +#if defined(_GNU_SOURCE) +#define __NEED_ssize_t +#endif + +#include + +#define MAP_FAILED ((void *) -1) + +#define MAP_SHARED 0x01 +#define MAP_PRIVATE 0x02 +#define MAP_RESERVE 0x04 +#define MAP_SHARED_VALIDATE 0x03 +#define MAP_TYPE 0x0f +#define MAP_FIXED 0x10 +#define MAP_ANON 0x20 +#define MAP_ANONYMOUS MAP_ANON +#define MAP_NORESERVE 0x4000 +#define MAP_GROWSDOWN 0x0100 +#define MAP_DENYWRITE 0x0800 +#define MAP_EXECUTABLE 0x1000 +#define MAP_LOCKED 0x2000 +#define MAP_POPULATE 0x8000 +#define MAP_NONBLOCK 0x10000 +#define MAP_STACK 0x20000 +#define MAP_HUGETLB 0x40000 +#define MAP_SYNC 0x80000 +#define MAP_FIXED_NOREPLACE 0x100000 +#define MAP_FILE 0 + +#define MAP_HUGE_SHIFT 26 +#define MAP_HUGE_MASK 0x3f +#define MAP_HUGE_64KB (16 << 26) +#define MAP_HUGE_512KB (19 << 26) +#define MAP_HUGE_1MB (20 << 26) +#define MAP_HUGE_2MB (21 << 26) +#define MAP_HUGE_8MB (23 << 26) +#define MAP_HUGE_16MB (24 << 26) +#define MAP_HUGE_32MB (25 << 26) +#define MAP_HUGE_256MB (28 << 26) +#define MAP_HUGE_512MB (29 << 26) +#define MAP_HUGE_1GB (30 << 26) +#define MAP_HUGE_2GB (31 << 26) +#define MAP_HUGE_16GB (34U << 26) + +#define PROT_NONE 0 +#define PROT_READ 1 +#define PROT_WRITE 2 +#define PROT_EXEC 4 +#define PROT_GROWSDOWN 0x01000000 +#define PROT_GROWSUP 0x02000000 + +#define MS_ASYNC 1 +#define MS_INVALIDATE 2 +#define MS_SYNC 4 + +#define MCL_CURRENT 1 +#define MCL_FUTURE 2 +#define MCL_ONFAULT 4 + +#define POSIX_MADV_NORMAL 0 +#define POSIX_MADV_RANDOM 1 +#define POSIX_MADV_SEQUENTIAL 2 +#define POSIX_MADV_WILLNEED 3 +#define POSIX_MADV_DONTNEED 4 + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define MADV_NORMAL 0 +#define MADV_RANDOM 1 +#define MADV_SEQUENTIAL 2 +#define MADV_WILLNEED 3 +#define MADV_DONTNEED 4 +#define MADV_FREE 8 +#define MADV_REMOVE 9 +#define MADV_DONTFORK 10 +#define MADV_DOFORK 11 +#define MADV_MERGEABLE 12 +#define MADV_UNMERGEABLE 13 +#define MADV_HUGEPAGE 14 +#define MADV_NOHUGEPAGE 15 +#define MADV_DONTDUMP 16 +#define MADV_DODUMP 17 +#define MADV_WIPEONFORK 18 +#define MADV_KEEPONFORK 19 +#define MADV_COLD 20 +#define MADV_PAGEOUT 21 +#define MADV_HWPOISON 100 +#define MADV_SOFT_OFFLINE 101 +#endif + +#ifdef _GNU_SOURCE +#define MREMAP_MAYMOVE 1 +#define MREMAP_FIXED 2 + +#define MLOCK_ONFAULT 0x01 + +#define MFD_CLOEXEC 0x0001U +#define MFD_ALLOW_SEALING 0x0002U +#define MFD_HUGETLB 0x0004U +#endif + +#include + +void *mmap (void *, size_t, int, int, int, off_t); +int munmap (const void *, size_t); + +int mprotect (void *, size_t, int); +int msync (void *, size_t, int); + +int posix_madvise (void *, size_t, int); + +int mlock (const void *, size_t); +int munlock (const void *, size_t); +int mlockall (int); +int munlockall (void); + +#ifdef _GNU_SOURCE +void *mremap (void *, size_t, size_t, int, ...); +int remap_file_pages (void *, size_t, int, size_t, int); +int memfd_create (const char *, unsigned); +int mlock2 (const void *, size_t, unsigned); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int madvise (void *, size_t, int); +int mincore (void *, size_t, unsigned char *); +#endif + +int shm_open (const char *, int, mode_t); +int shm_unlink (const char *); + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define mmap64 mmap +#define off64_t off_t +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sys/param.h b/thirdparty/open_source/musl/libc/sys/param.h new file mode 100644 index 0000000..ce6b801 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/param.h @@ -0,0 +1,35 @@ +#ifndef _SYS_PARAM_H +#define _SYS_PARAM_H + +#define MAXSYMLINKS 20 +#define MAXHOSTNAMELEN 64 +#define MAXNAMLEN 255 +#define MAXPATHLEN 4096 +#define NBBY 8 +#define NGROUPS 32 +#define CANBSIZ 255 +#define NOFILE 256 +#define NCARGS 131072 +#define DEV_BSIZE 512 +#define NOGROUP (-1) + +#undef MIN +#undef MAX +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +#define __bitop(x,i,o) ((x)[(i)/8] o (1<<(i)%8)) +#define setbit(x,i) __bitop(x,i,|=) +#define clrbit(x,i) __bitop(x,i,&=~) +#define isset(x,i) __bitop(x,i,&) +#define isclr(x,i) !isset(x,i) + +#define howmany(n,d) (((n)+((d)-1))/(d)) +#define roundup(n,d) (howmany(n,d)*(d)) +#define powerof2(n) !(((n)-1) & (n)) + +#include +#include +#include + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/procfs.h b/thirdparty/open_source/musl/libc/sys/procfs.h new file mode 100644 index 0000000..38e58c1 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/procfs.h @@ -0,0 +1,63 @@ +#ifndef _SYS_PROCFS_H +#define _SYS_PROCFS_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +struct elf_siginfo { + int si_signo; + int si_code; + int si_errno; +}; + +struct elf_prstatus { + struct elf_siginfo pr_info; + short int pr_cursig; + unsigned long int pr_sigpend; + unsigned long int pr_sighold; + pid_t pr_pid; + pid_t pr_ppid; + pid_t pr_pgrp; + pid_t pr_sid; + struct { + long tv_sec, tv_usec; + } pr_utime, pr_stime, pr_cutime, pr_cstime; + elf_gregset_t pr_reg; + int pr_fpvalid; +}; + +#define ELF_PRARGSZ 80 + +struct elf_prpsinfo { + char pr_state; + char pr_sname; + char pr_zomb; + char pr_nice; + unsigned long int pr_flag; +#if UINTPTR_MAX == 0xffffffff + unsigned short int pr_uid; + unsigned short int pr_gid; +#else + unsigned int pr_uid; + unsigned int pr_gid; +#endif + int pr_pid, pr_ppid, pr_pgrp, pr_sid; + char pr_fname[16]; + char pr_psargs[ELF_PRARGSZ]; +}; + +typedef void *psaddr_t; +typedef elf_gregset_t prgregset_t; +typedef elf_fpregset_t prfpregset_t; +typedef pid_t lwpid_t; +typedef struct elf_prstatus prstatus_t; +typedef struct elf_prpsinfo prpsinfo_t; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sys/resource.h b/thirdparty/open_source/musl/libc/sys/resource.h new file mode 100644 index 0000000..3068328 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/resource.h @@ -0,0 +1,116 @@ +#ifndef _SYS_RESOURCE_H +#define _SYS_RESOURCE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define __NEED_id_t + +#ifdef _GNU_SOURCE +#define __NEED_pid_t +#endif + +#include +#include + +typedef unsigned long long rlim_t; + +struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; +}; + +struct rusage { + struct timeval ru_utime; + struct timeval ru_stime; + /* linux extentions, but useful */ + long ru_maxrss; + long ru_ixrss; + long ru_idrss; + long ru_isrss; + long ru_minflt; + long ru_majflt; + long ru_nswap; + long ru_inblock; + long ru_oublock; + long ru_msgsnd; + long ru_msgrcv; + long ru_nsignals; + long ru_nvcsw; + long ru_nivcsw; + /* room for more... */ + long __reserved[16]; +}; + +int getrlimit (int, struct rlimit *); +int setrlimit (int, const struct rlimit *); +int getrusage (int, struct rusage *); + +int getpriority (int, id_t); +int setpriority (int, id_t, int); + +#ifdef _GNU_SOURCE +int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); +#define prlimit64 prlimit +#endif + +#define PRIO_MIN (-20) +#define PRIO_MAX 20 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) +#define RUSAGE_THREAD 1 + +#define RLIM_INFINITY (~0ULL) +#define RLIM_SAVED_CUR RLIM_INFINITY +#define RLIM_SAVED_MAX RLIM_INFINITY + +#define RLIMIT_CPU 0 +#define RLIMIT_FSIZE 1 +#define RLIMIT_DATA 2 +#define RLIMIT_STACK 3 +#define RLIMIT_CORE 4 +#ifndef RLIMIT_RSS +#define RLIMIT_RSS 5 +#define RLIMIT_NPROC 6 +#define RLIMIT_NOFILE 7 +#define RLIMIT_MEMLOCK 8 +#define RLIMIT_AS 9 +#endif +#define RLIMIT_LOCKS 10 +#define RLIMIT_SIGPENDING 11 +#define RLIMIT_MSGQUEUE 12 +#define RLIMIT_NICE 13 +#define RLIMIT_RTPRIO 14 +#define RLIMIT_RTTIME 15 +#define RLIMIT_NLIMITS 16 + +#define RLIM_NLIMITS RLIMIT_NLIMITS + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define RLIM64_INFINITY RLIM_INFINITY +#define RLIM64_SAVED_CUR RLIM_SAVED_CUR +#define RLIM64_SAVED_MAX RLIM_SAVED_MAX +#define getrlimit64 getrlimit +#define setrlimit64 setrlimit +#define rlimit64 rlimit +#define rlim64_t rlim_t +#endif + +#if _REDIR_TIME64 +__REDIR(getrusage, __getrusage_time64); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/select.h b/thirdparty/open_source/musl/libc/sys/select.h new file mode 100644 index 0000000..b3bab1d --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/select.h @@ -0,0 +1,46 @@ +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_size_t +#define __NEED_time_t +#define __NEED_suseconds_t +#define __NEED_struct_timeval +#define __NEED_struct_timespec +#define __NEED_sigset_t + +#include + +#define FD_SETSIZE 1024 + +typedef unsigned long fd_mask; + +typedef struct { + unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)]; +} fd_set; + +#define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0) +#define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long))))) +#define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long))))) +#define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long))))) + +int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict); +int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict); + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define NFDBITS (8*(int)sizeof(long)) +#endif + +#if _REDIR_TIME64 +__REDIR(select, __select_time64); +__REDIR(pselect, __pselect_time64); +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sys/socket.h b/thirdparty/open_source/musl/libc/sys/socket.h new file mode 100644 index 0000000..38f5bb1 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/socket.h @@ -0,0 +1,413 @@ +#ifndef _SYS_SOCKET_H +#define _SYS_SOCKET_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_socklen_t +#define __NEED_sa_family_t +#define __NEED_size_t +#define __NEED_ssize_t +#define __NEED_uid_t +#define __NEED_pid_t +#define __NEED_gid_t +#define __NEED_struct_iovec + +#include + +#include + +struct msghdr { + void *msg_name; + socklen_t msg_namelen; + struct iovec *msg_iov; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad1; +#endif + int msg_iovlen; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad1; +#endif + void *msg_control; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad2; +#endif + socklen_t msg_controllen; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad2; +#endif + int msg_flags; +}; + +struct cmsghdr { +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad1; +#endif + socklen_t cmsg_len; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad1; +#endif + int cmsg_level; + int cmsg_type; +}; + +#ifdef _GNU_SOURCE +struct ucred { + pid_t pid; + uid_t uid; + gid_t gid; +}; + +struct mmsghdr { + struct msghdr msg_hdr; + unsigned int msg_len; +}; + +struct timespec; + +int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int); +int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *); +#endif + +struct linger { + int l_onoff; + int l_linger; +}; + +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 + +#ifndef SOCK_STREAM +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +#endif + +#define SOCK_RAW 3 +#define SOCK_RDM 4 +#define SOCK_SEQPACKET 5 +#define SOCK_DCCP 6 +#define SOCK_PACKET 10 + +#ifndef SOCK_CLOEXEC +#define SOCK_CLOEXEC 02000000 +#define SOCK_NONBLOCK 04000 +#endif + +#define PF_UNSPEC 0 +#define PF_LOCAL 1 +#define PF_UNIX PF_LOCAL +#define PF_FILE PF_LOCAL +#define PF_INET 2 +#define PF_AX25 3 +#define PF_IPX 4 +#define PF_APPLETALK 5 +#define PF_NETROM 6 +#define PF_BRIDGE 7 +#define PF_ATMPVC 8 +#define PF_X25 9 +#define PF_INET6 10 +#define PF_ROSE 11 +#define PF_DECnet 12 +#define PF_NETBEUI 13 +#define PF_SECURITY 14 +#define PF_KEY 15 +#define PF_NETLINK 16 +#define PF_ROUTE PF_NETLINK +#define PF_PACKET 17 +#define PF_ASH 18 +#define PF_ECONET 19 +#define PF_ATMSVC 20 +#define PF_RDS 21 +#define PF_SNA 22 +#define PF_IRDA 23 +#define PF_PPPOX 24 +#define PF_WANPIPE 25 +#define PF_LLC 26 +#define PF_IB 27 +#define PF_MPLS 28 +#define PF_CAN 29 +#define PF_TIPC 30 +#define PF_BLUETOOTH 31 +#define PF_IUCV 32 +#define PF_RXRPC 33 +#define PF_ISDN 34 +#define PF_PHONET 35 +#define PF_IEEE802154 36 +#define PF_CAIF 37 +#define PF_ALG 38 +#define PF_NFC 39 +#define PF_VSOCK 40 +#define PF_KCM 41 +#define PF_QIPCRTR 42 +#define PF_SMC 43 +#define PF_XDP 44 +#define PF_MAX 45 + +#define AF_UNSPEC PF_UNSPEC +#define AF_LOCAL PF_LOCAL +#define AF_UNIX AF_LOCAL +#define AF_FILE AF_LOCAL +#define AF_INET PF_INET +#define AF_AX25 PF_AX25 +#define AF_IPX PF_IPX +#define AF_APPLETALK PF_APPLETALK +#define AF_NETROM PF_NETROM +#define AF_BRIDGE PF_BRIDGE +#define AF_ATMPVC PF_ATMPVC +#define AF_X25 PF_X25 +#define AF_INET6 PF_INET6 +#define AF_ROSE PF_ROSE +#define AF_DECnet PF_DECnet +#define AF_NETBEUI PF_NETBEUI +#define AF_SECURITY PF_SECURITY +#define AF_KEY PF_KEY +#define AF_NETLINK PF_NETLINK +#define AF_ROUTE PF_ROUTE +#define AF_PACKET PF_PACKET +#define AF_ASH PF_ASH +#define AF_ECONET PF_ECONET +#define AF_ATMSVC PF_ATMSVC +#define AF_RDS PF_RDS +#define AF_SNA PF_SNA +#define AF_IRDA PF_IRDA +#define AF_PPPOX PF_PPPOX +#define AF_WANPIPE PF_WANPIPE +#define AF_LLC PF_LLC +#define AF_IB PF_IB +#define AF_MPLS PF_MPLS +#define AF_CAN PF_CAN +#define AF_TIPC PF_TIPC +#define AF_BLUETOOTH PF_BLUETOOTH +#define AF_IUCV PF_IUCV +#define AF_RXRPC PF_RXRPC +#define AF_ISDN PF_ISDN +#define AF_PHONET PF_PHONET +#define AF_IEEE802154 PF_IEEE802154 +#define AF_CAIF PF_CAIF +#define AF_ALG PF_ALG +#define AF_NFC PF_NFC +#define AF_VSOCK PF_VSOCK +#define AF_KCM PF_KCM +#define AF_QIPCRTR PF_QIPCRTR +#define AF_SMC PF_SMC +#define AF_XDP PF_XDP +#define AF_MAX PF_MAX + +#ifndef SO_DEBUG +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 +#define SO_BSDCOMPAT 14 +#define SO_REUSEPORT 15 +#define SO_PASSCRED 16 +#define SO_PEERCRED 17 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_ACCEPTCONN 30 +#define SO_PEERSEC 31 +#define SO_SNDBUFFORCE 32 +#define SO_RCVBUFFORCE 33 +#define SO_PROTOCOL 38 +#define SO_DOMAIN 39 +#endif + +#ifndef SO_RCVTIMEO +#if __LONG_MAX == 0x7fffffff +#define SO_RCVTIMEO 66 +#define SO_SNDTIMEO 67 +#else +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#endif +#endif + +#ifndef SO_TIMESTAMP +#if __LONG_MAX == 0x7fffffff +#define SO_TIMESTAMP 63 +#define SO_TIMESTAMPNS 64 +#define SO_TIMESTAMPING 65 +#else +#define SO_TIMESTAMP 29 +#define SO_TIMESTAMPNS 35 +#define SO_TIMESTAMPING 37 +#endif +#endif + +#define SO_SECURITY_AUTHENTICATION 22 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define SO_SECURITY_ENCRYPTION_NETWORK 24 + +#define SO_BINDTODEVICE 25 + +#define SO_ATTACH_FILTER 26 +#define SO_DETACH_FILTER 27 +#define SO_GET_FILTER SO_ATTACH_FILTER + +#define SO_PEERNAME 28 +#define SCM_TIMESTAMP SO_TIMESTAMP +#define SO_PASSSEC 34 +#define SCM_TIMESTAMPNS SO_TIMESTAMPNS +#define SO_MARK 36 +#define SCM_TIMESTAMPING SO_TIMESTAMPING +#define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 +#define SO_NOFCS 43 +#define SO_LOCK_FILTER 44 +#define SO_SELECT_ERR_QUEUE 45 +#define SO_BUSY_POLL 46 +#define SO_MAX_PACING_RATE 47 +#define SO_BPF_EXTENSIONS 48 +#define SO_INCOMING_CPU 49 +#define SO_ATTACH_BPF 50 +#define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 +#define SO_CNX_ADVICE 53 +#define SCM_TIMESTAMPING_OPT_STATS 54 +#define SO_MEMINFO 55 +#define SO_INCOMING_NAPI_ID 56 +#define SO_COOKIE 57 +#define SCM_TIMESTAMPING_PKTINFO 58 +#define SO_PEERGROUPS 59 +#define SO_ZEROCOPY 60 +#define SO_TXTIME 61 +#define SCM_TXTIME SO_TXTIME +#define SO_BINDTOIFINDEX 62 +#define SO_DETACH_REUSEPORT_BPF 68 + +#ifndef SOL_SOCKET +#define SOL_SOCKET 1 +#endif + +#define SOL_IP 0 +#define SOL_IPV6 41 +#define SOL_ICMPV6 58 + +#define SOL_RAW 255 +#define SOL_DECNET 261 +#define SOL_X25 262 +#define SOL_PACKET 263 +#define SOL_ATM 264 +#define SOL_AAL 265 +#define SOL_IRDA 266 +#define SOL_NETBEUI 267 +#define SOL_LLC 268 +#define SOL_DCCP 269 +#define SOL_NETLINK 270 +#define SOL_TIPC 271 +#define SOL_RXRPC 272 +#define SOL_PPPOL2TP 273 +#define SOL_BLUETOOTH 274 +#define SOL_PNPIPE 275 +#define SOL_RDS 276 +#define SOL_IUCV 277 +#define SOL_CAIF 278 +#define SOL_ALG 279 +#define SOL_NFC 280 +#define SOL_KCM 281 +#define SOL_TLS 282 +#define SOL_XDP 283 + +#define SOMAXCONN 128 + +#define MSG_OOB 0x0001 +#define MSG_PEEK 0x0002 +#define MSG_DONTROUTE 0x0004 +#define MSG_CTRUNC 0x0008 +#define MSG_PROXY 0x0010 +#define MSG_TRUNC 0x0020 +#define MSG_DONTWAIT 0x0040 +#define MSG_EOR 0x0080 +#define MSG_WAITALL 0x0100 +#define MSG_FIN 0x0200 +#define MSG_SYN 0x0400 +#define MSG_CONFIRM 0x0800 +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 +#define MSG_NOSIGNAL 0x4000 +#define MSG_MORE 0x8000 +#define MSG_WAITFORONE 0x10000 +#define MSG_BATCH 0x40000 +#define MSG_ZEROCOPY 0x4000000 +#define MSG_FASTOPEN 0x20000000 +#define MSG_CMSG_CLOEXEC 0x40000000 + +#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)) +#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg)) +#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen) + +#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1)) +#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \ + __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ + ? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg)) +#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0) + +#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) +#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr))) +#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) + +#define SCM_RIGHTS 0x01 +#define SCM_CREDENTIALS 0x02 + +struct sockaddr { + sa_family_t sa_family; + char sa_data[14]; +}; + +struct sockaddr_storage { + sa_family_t ss_family; + char __ss_padding[128-sizeof(long)-sizeof(sa_family_t)]; + unsigned long __ss_align; +}; + +int socket (int, int, int); +int socketpair (int, int, int, int [2]); + +int shutdown (int, int); + +int bind (int, const struct sockaddr *, socklen_t); +int connect (int, const struct sockaddr *, socklen_t); +int listen (int, int); +int accept (int, struct sockaddr *__restrict, socklen_t *__restrict); +int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int); + +int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict); +int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict); + +ssize_t send (int, const void *, size_t, int); +ssize_t recv (int, void *, size_t, int); +ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t); +ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict); +ssize_t sendmsg (int, const struct msghdr *, int); +ssize_t recvmsg (int, struct msghdr *, int); + +int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict); +int setsockopt (int, int, int, const void *, socklen_t); + +int sockatmark (int); + +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +__REDIR(recvmmsg, __recvmmsg_time64); +#endif +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sys/stat.h b/thirdparty/open_source/musl/libc/sys/stat.h new file mode 100644 index 0000000..10d446c --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/stat.h @@ -0,0 +1,127 @@ +#ifndef _SYS_STAT_H +#define _SYS_STAT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_dev_t +#define __NEED_ino_t +#define __NEED_mode_t +#define __NEED_nlink_t +#define __NEED_uid_t +#define __NEED_gid_t +#define __NEED_off_t +#define __NEED_time_t +#define __NEED_blksize_t +#define __NEED_blkcnt_t +#define __NEED_struct_timespec + +#include + +#include + +#define st_atime st_atim.tv_sec +#define st_mtime st_mtim.tv_sec +#define st_ctime st_ctim.tv_sec + +#define S_IFMT 0170000 + +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFBLK 0060000 +#define S_IFREG 0100000 +#define S_IFIFO 0010000 +#define S_IFLNK 0120000 +#define S_IFSOCK 0140000 + +#define S_TYPEISMQ(buf) 0 +#define S_TYPEISSEM(buf) 0 +#define S_TYPEISSHM(buf) 0 +#define S_TYPEISTMO(buf) 0 + +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) +#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) +#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) +#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) +#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) + +#ifndef S_IRUSR +#define S_ISUID 04000 +#define S_ISGID 02000 +#define S_ISVTX 01000 +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 +#define S_IRWXU 0700 +#define S_IRGRP 0040 +#define S_IWGRP 0020 +#define S_IXGRP 0010 +#define S_IRWXG 0070 +#define S_IROTH 0004 +#define S_IWOTH 0002 +#define S_IXOTH 0001 +#define S_IRWXO 0007 +#endif + +#define UTIME_NOW 0x3fffffff +#define UTIME_OMIT 0x3ffffffe + +int stat(const char *__restrict, struct stat *__restrict); +int fstat(int, struct stat *); +int lstat(const char *__restrict, struct stat *__restrict); +int fstatat(int, const char *__restrict, struct stat *__restrict, int); +int chmod(const char *, mode_t); +int fchmod(int, mode_t); +int fchmodat(int, const char *, mode_t, int); +mode_t umask(mode_t); +int mkdir(const char *, mode_t); +int mkfifo(const char *, mode_t); +int mkdirat(int, const char *, mode_t); +int mkfifoat(int, const char *, mode_t); + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int mknod(const char *, mode_t, dev_t); +int mknodat(int, const char *, mode_t, dev_t); +#endif + +int futimens(int, const struct timespec [2]); +int utimensat(int, const char *, const struct timespec [2], int); + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int lchmod(const char *, mode_t); +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_IEXEC S_IXUSR +#endif + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define stat64 stat +#define fstat64 fstat +#define lstat64 lstat +#define fstatat64 fstatat +#define blkcnt64_t blkcnt_t +#define fsblkcnt64_t fsblkcnt_t +#define fsfilcnt64_t fsfilcnt_t +#define ino64_t ino_t +#define off64_t off_t +#endif + +#if _REDIR_TIME64 +__REDIR(stat, __stat_time64); +__REDIR(fstat, __fstat_time64); +__REDIR(lstat, __lstat_time64); +__REDIR(fstatat, __fstatat_time64); +__REDIR(futimens, __futimens_time64); +__REDIR(utimensat, __utimensat_time64); +#endif + +#ifdef __cplusplus +} +#endif +#endif + + diff --git a/thirdparty/open_source/musl/libc/sys/syscall.h b/thirdparty/open_source/musl/libc/sys/syscall.h new file mode 100644 index 0000000..24987dd --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/syscall.h @@ -0,0 +1,6 @@ +#ifndef _SYS_SYSCALL_H +#define _SYS_SYSCALL_H + +#include + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/sysmacros.h b/thirdparty/open_source/musl/libc/sys/sysmacros.h new file mode 100644 index 0000000..07a3ef1 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/sysmacros.h @@ -0,0 +1,15 @@ +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H + +#define major(x) \ + ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) )) +#define minor(x) \ + ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) )) + +#define makedev(x,y) ( \ + (((x)&0xfffff000ULL) << 32) | \ + (((x)&0x00000fffULL) << 8) | \ + (((y)&0xffffff00ULL) << 12) | \ + (((y)&0x000000ffULL)) ) + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/time.h b/thirdparty/open_source/musl/libc/sys/time.h new file mode 100644 index 0000000..cdc67ef --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/time.h @@ -0,0 +1,76 @@ +#ifndef _SYS_TIME_H +#define _SYS_TIME_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +int gettimeofday (struct timeval *__restrict, void *__restrict); + +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +struct itimerval { + struct timeval it_interval; + struct timeval it_value; +}; + +int getitimer (int, struct itimerval *); +int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict); +int utimes (const char *, const struct timeval [2]); + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +struct timezone { + int tz_minuteswest; + int tz_dsttime; +}; +int futimes(int, const struct timeval [2]); +int futimesat(int, const char *, const struct timeval [2]); +int lutimes(const char *, const struct timeval [2]); +int settimeofday(const struct timeval *, const struct timezone *); +int adjtime (const struct timeval *, struct timeval *); +#define timerisset(t) ((t)->tv_sec || (t)->tv_usec) +#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0) +#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \ + (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec) +#define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \ + ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \ + ((a)->tv_usec -= 1000000, (a)->tv_sec++) ) +#define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \ + ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \ + ((a)->tv_usec += 1000000, (a)->tv_sec--) ) +#endif + +#if defined(_GNU_SOURCE) +#define TIMEVAL_TO_TIMESPEC(tv, ts) ( \ + (ts)->tv_sec = (tv)->tv_sec, \ + (ts)->tv_nsec = (tv)->tv_usec * 1000, \ + (void)0 ) +#define TIMESPEC_TO_TIMEVAL(tv, ts) ( \ + (tv)->tv_sec = (ts)->tv_sec, \ + (tv)->tv_usec = (ts)->tv_nsec / 1000, \ + (void)0 ) +#endif + +#if _REDIR_TIME64 +__REDIR(gettimeofday, __gettimeofday_time64); +__REDIR(getitimer, __getitimer_time64); +__REDIR(setitimer, __setitimer_time64); +__REDIR(utimes, __utimes_time64); +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +__REDIR(futimes, __futimes_time64); +__REDIR(futimesat, __futimesat_time64); +__REDIR(lutimes, __lutimes_time64); +__REDIR(settimeofday, __settimeofday_time64); +__REDIR(adjtime, __adjtime64); +#endif +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sys/times.h b/thirdparty/open_source/musl/libc/sys/times.h new file mode 100644 index 0000000..80a5052 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/times.h @@ -0,0 +1,25 @@ +#ifndef _SYS_TIMES_H +#define _SYS_TIMES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define __NEED_clock_t +#include + +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + +clock_t times (struct tms *); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/thirdparty/open_source/musl/libc/sys/types.h b/thirdparty/open_source/musl/libc/sys/types.h new file mode 100644 index 0000000..0c35541 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/types.h @@ -0,0 +1,85 @@ +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_ino_t +#define __NEED_dev_t +#define __NEED_uid_t +#define __NEED_gid_t +#define __NEED_mode_t +#define __NEED_nlink_t +#define __NEED_off_t +#define __NEED_pid_t +#define __NEED_size_t +#define __NEED_ssize_t +#define __NEED_time_t +#define __NEED_timer_t +#define __NEED_clockid_t + +#define __NEED_blkcnt_t +#define __NEED_fsblkcnt_t +#define __NEED_fsfilcnt_t + +#define __NEED_id_t +#define __NEED_key_t +#define __NEED_clock_t +#define __NEED_suseconds_t +#define __NEED_blksize_t + +#define __NEED_pthread_t +#define __NEED_pthread_attr_t +#define __NEED_pthread_mutexattr_t +#define __NEED_pthread_condattr_t +#define __NEED_pthread_rwlockattr_t +#define __NEED_pthread_barrierattr_t +#define __NEED_pthread_mutex_t +#define __NEED_pthread_cond_t +#define __NEED_pthread_rwlock_t +#define __NEED_pthread_barrier_t +#define __NEED_pthread_spinlock_t +#define __NEED_pthread_key_t +#define __NEED_pthread_once_t +#define __NEED_useconds_t + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_int8_t +#define __NEED_int16_t +#define __NEED_int32_t +#define __NEED_int64_t +#define __NEED_u_int64_t +#define __NEED_register_t +#endif + +#include + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +typedef unsigned char u_int8_t; +typedef unsigned short u_int16_t; +typedef unsigned u_int32_t; +typedef char *caddr_t; +typedef unsigned char u_char; +typedef unsigned short u_short, ushort; +typedef unsigned u_int, uint; +typedef unsigned long u_long, ulong; +typedef long long quad_t; +typedef unsigned long long u_quad_t; +#include +#include +#endif + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define blkcnt64_t blkcnt_t +#define fsblkcnt64_t fsblkcnt_t +#define fsfilcnt64_t fsfilcnt_t +#define ino64_t ino_t +#define off64_t off_t +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/sys/uio.h b/thirdparty/open_source/musl/libc/sys/uio.h new file mode 100644 index 0000000..00f73a2 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/uio.h @@ -0,0 +1,48 @@ +#ifndef _SYS_UIO_H +#define _SYS_UIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_size_t +#define __NEED_ssize_t +#define __NEED_struct_iovec + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_off_t +#endif + +#ifdef _GNU_SOURCE +#define __NEED_pid_t +#endif + +#include + +#define UIO_MAXIOV 1024 + +ssize_t readv (int, const struct iovec *, int); +ssize_t writev (int, const struct iovec *, int); + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +ssize_t preadv (int, const struct iovec *, int, off_t); +ssize_t pwritev (int, const struct iovec *, int, off_t); +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define preadv64 preadv +#define pwritev64 pwritev +#define off64_t off_t +#endif +#endif + +#ifdef _GNU_SOURCE +ssize_t process_vm_writev(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long); +ssize_t process_vm_readv(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/un.h b/thirdparty/open_source/musl/libc/sys/un.h new file mode 100644 index 0000000..1a3193a --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/un.h @@ -0,0 +1,31 @@ +#ifndef _SYS_UN_H +#define _SYS_UN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_sa_family_t +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_size_t +#endif + +#include + +struct sockaddr_un { + sa_family_t sun_family; + char sun_path[108]; +}; + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +size_t strlen(const char *); +#define SUN_LEN(s) (2+strlen((s)->sun_path)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/sys/user.h b/thirdparty/open_source/musl/libc/sys/user.h new file mode 100644 index 0000000..96a0340 --- /dev/null +++ b/thirdparty/open_source/musl/libc/sys/user.h @@ -0,0 +1,16 @@ +#ifndef _SYS_USER_H +#define _SYS_USER_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#include + +#ifdef __cplusplus +} +#endif +#endif diff --git a/thirdparty/open_source/musl/libc/syscall.h b/thirdparty/open_source/musl/libc/syscall.h new file mode 100644 index 0000000..4c30578 --- /dev/null +++ b/thirdparty/open_source/musl/libc/syscall.h @@ -0,0 +1 @@ +#include diff --git a/thirdparty/open_source/musl/libc/time.h b/thirdparty/open_source/musl/libc/time.h new file mode 100644 index 0000000..1b18024 --- /dev/null +++ b/thirdparty/open_source/musl/libc/time.h @@ -0,0 +1,168 @@ +#ifndef _TIME_H +#define _TIME_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif +#endif + + +#define __NEED_size_t +#define __NEED_time_t +#define __NEED_clock_t +#define __NEED_struct_timespec + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +#define __NEED_clockid_t +#define __NEED_timer_t +#define __NEED_pid_t +#define __NEED_locale_t +#endif + +#include + +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +#define __tm_gmtoff tm_gmtoff +#define __tm_zone tm_zone +#endif + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + long __tm_gmtoff; + const char *__tm_zone; +}; + +clock_t clock (void); +time_t time (time_t *); +double difftime (time_t, time_t); +time_t mktime (struct tm *); +size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict); +struct tm *gmtime (const time_t *); +struct tm *localtime (const time_t *); +char *asctime (const struct tm *); +char *ctime (const time_t *); +int timespec_get(struct timespec *, int); + +#define CLOCKS_PER_SEC 1000000L + +#define TIME_UTC 1 + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) + +size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t); + +struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict); +struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict); +char *asctime_r (const struct tm *__restrict, char *__restrict); +char *ctime_r (const time_t *, char *); + +void tzset (void); + +struct itimerspec { + struct timespec it_interval; + struct timespec it_value; +}; + +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 +#define CLOCK_PROCESS_CPUTIME_ID 2 +#define CLOCK_THREAD_CPUTIME_ID 3 +#define CLOCK_MONOTONIC_RAW 4 +#define CLOCK_REALTIME_COARSE 5 +#define CLOCK_MONOTONIC_COARSE 6 +#define CLOCK_BOOTTIME 7 +#define CLOCK_REALTIME_ALARM 8 +#define CLOCK_BOOTTIME_ALARM 9 +#define CLOCK_SGI_CYCLE 10 +#define CLOCK_TAI 11 + +#define TIMER_ABSTIME 1 + +int nanosleep (const struct timespec *, struct timespec *); +int clock_getres (clockid_t, struct timespec *); +int clock_gettime (clockid_t, struct timespec *); +int clock_settime (clockid_t, const struct timespec *); +int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *); +int clock_getcpuclockid (pid_t, clockid_t *); + +struct sigevent; +int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict); +int timer_delete (timer_t); +int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); +int timer_gettime (timer_t, struct itimerspec *); +int timer_getoverrun (timer_t); + +extern char *tzname[2]; + +#endif + + +#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict); +extern int daylight; +extern long timezone; +extern int getdate_err; +struct tm *getdate (const char *); +#endif + + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int stime(const time_t *); +time_t timegm(struct tm *); +#endif + +#if _REDIR_TIME64 +__REDIR(time, __time64); +__REDIR(difftime, __difftime64); +__REDIR(mktime, __mktime64); +__REDIR(gmtime, __gmtime64); +__REDIR(localtime, __localtime64); +__REDIR(ctime, __ctime64); +__REDIR(timespec_get, __timespec_get_time64); +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +__REDIR(gmtime_r, __gmtime64_r); +__REDIR(localtime_r, __localtime64_r); +__REDIR(ctime_r, __ctime64_r); +__REDIR(nanosleep, __nanosleep_time64); +__REDIR(clock_getres, __clock_getres_time64); +__REDIR(clock_gettime, __clock_gettime64); +__REDIR(clock_settime, __clock_settime64); +__REDIR(clock_nanosleep, __clock_nanosleep_time64); +__REDIR(timer_settime, __timer_settime64); +__REDIR(timer_gettime, __timer_gettime64); +#endif +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +__REDIR(stime, __stime64); +__REDIR(timegm, __timegm_time64); +#endif +#endif + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/thirdparty/open_source/musl/libc/unistd.h b/thirdparty/open_source/musl/libc/unistd.h new file mode 100644 index 0000000..7bcbff9 --- /dev/null +++ b/thirdparty/open_source/musl/libc/unistd.h @@ -0,0 +1,469 @@ +#ifndef _UNISTD_H +#define _UNISTD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif + +#define __NEED_size_t +#define __NEED_ssize_t +#define __NEED_uid_t +#define __NEED_gid_t +#define __NEED_off_t +#define __NEED_pid_t +#define __NEED_intptr_t +#define __NEED_useconds_t + +#include + +int pipe(int [2]); +int pipe2(int [2], int); +int close(int); +int posix_close(int, int); +int dup(int); +int dup2(int, int); +int dup3(int, int, int); +off_t lseek(int, off_t, int); +int fsync(int); +int fdatasync(int); + +ssize_t read(int, void *, size_t); +ssize_t write(int, const void *, size_t); +ssize_t pread(int, void *, size_t, off_t); +ssize_t pwrite(int, const void *, size_t, off_t); + +int chown(const char *, uid_t, gid_t); +int fchown(int, uid_t, gid_t); +int lchown(const char *, uid_t, gid_t); +int fchownat(int, const char *, uid_t, gid_t, int); + +int link(const char *, const char *); +int linkat(int, const char *, int, const char *, int); +int symlink(const char *, const char *); +int symlinkat(const char *, int, const char *); +ssize_t readlink(const char *__restrict, char *__restrict, size_t); +ssize_t readlinkat(int, const char *__restrict, char *__restrict, size_t); +int unlink(const char *); +int unlinkat(int, const char *, int); +int rmdir(const char *); +int truncate(const char *, off_t); +int ftruncate(int, off_t); + +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 + +int access(const char *, int); +int faccessat(int, const char *, int, int); + +int chdir(const char *); +int fchdir(int); +char *getcwd(char *, size_t); + +unsigned alarm(unsigned); +unsigned sleep(unsigned); +int pause(void); + +pid_t fork(void); +int execve(const char *, char *const [], char *const []); +int execv(const char *, char *const []); +int execle(const char *, const char *, ...); +int execl(const char *, const char *, ...); +int execvp(const char *, char *const []); +int execlp(const char *, const char *, ...); +int fexecve(int, char *const [], char *const []); +_Noreturn void _exit(int); + +pid_t getpid(void); +pid_t getppid(void); +pid_t getpgrp(void); +pid_t getpgid(pid_t); +int setpgid(pid_t, pid_t); +pid_t setsid(void); +pid_t getsid(pid_t); +char *ttyname(int); +int ttyname_r(int, char *, size_t); +int isatty(int); +pid_t tcgetpgrp(int); +int tcsetpgrp(int, pid_t); + +uid_t getuid(void); +uid_t geteuid(void); +gid_t getgid(void); +gid_t getegid(void); +int getgroups(int, gid_t []); +int setuid(uid_t); +int seteuid(uid_t); +int setgid(gid_t); +int setegid(gid_t); + +char *getlogin(void); +int getlogin_r(char *, size_t); +int gethostname(char *, size_t); +char *ctermid(char *); + +int getopt(int, char * const [], const char *); +extern char *optarg; +extern int optind, opterr, optopt; + +long pathconf(const char *, int); +long fpathconf(int, int); +long sysconf(int); +size_t confstr(int, char *, size_t); + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define F_ULOCK 0 +#define F_LOCK 1 +#define F_TLOCK 2 +#define F_TEST 3 +int setreuid(uid_t, uid_t); +int setregid(gid_t, gid_t); +int lockf(int, int, off_t); +long gethostid(void); +int nice(int); +void sync(void); +pid_t setpgrp(void); +char *crypt(const char *, const char *); +void encrypt(char *, int); +void swab(const void *__restrict, void *__restrict, ssize_t); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \ + || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) +int usleep(unsigned); +unsigned ualarm(unsigned, unsigned); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define L_SET 0 +#define L_INCR 1 +#define L_XTND 2 +int brk(void *); +void *sbrk(intptr_t); +pid_t vfork(void); +int vhangup(void); +int chroot(const char *); +int getpagesize(void); +int getdtablesize(void); +int sethostname(const char *, size_t); +int getdomainname(char *, size_t); +int setdomainname(const char *, size_t); +int setgroups(size_t, const gid_t *); +char *getpass(const char *); +int daemon(int, int); +void setusershell(void); +void endusershell(void); +char *getusershell(void); +int acct(const char *); +long syscall(long, ...); +int execvpe(const char *, char *const [], char *const []); +int issetugid(void); +int getentropy(void *, size_t); +extern int optreset; +#endif + +#ifdef _GNU_SOURCE +extern char **environ; +int setresuid(uid_t, uid_t, uid_t); +int setresgid(gid_t, gid_t, gid_t); +int getresuid(uid_t *, uid_t *, uid_t *); +int getresgid(gid_t *, gid_t *, gid_t *); +char *get_current_dir_name(void); +int syncfs(int); +int euidaccess(const char *, int); +int eaccess(const char *, int); +ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); +#endif + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define lseek64 lseek +#define pread64 pread +#define pwrite64 pwrite +#define truncate64 truncate +#define ftruncate64 ftruncate +#define lockf64 lockf +#define off64_t off_t +#endif + +#define POSIX_CLOSE_RESTART 0 + +#define _XOPEN_VERSION 700 +#define _XOPEN_UNIX 1 +#define _XOPEN_ENH_I18N 1 + +#define _POSIX_VERSION 200809L +#define _POSIX2_VERSION _POSIX_VERSION + +#define _POSIX_ADVISORY_INFO _POSIX_VERSION +#define _POSIX_CHOWN_RESTRICTED 1 +#define _POSIX_IPV6 _POSIX_VERSION +#define _POSIX_JOB_CONTROL 1 +#define _POSIX_MAPPED_FILES _POSIX_VERSION +#define _POSIX_MEMLOCK _POSIX_VERSION +#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION +#define _POSIX_MEMORY_PROTECTION _POSIX_VERSION +#define _POSIX_MESSAGE_PASSING _POSIX_VERSION +#define _POSIX_FSYNC _POSIX_VERSION +#define _POSIX_NO_TRUNC 1 +#define _POSIX_RAW_SOCKETS _POSIX_VERSION +#define _POSIX_REALTIME_SIGNALS _POSIX_VERSION +#define _POSIX_REGEXP 1 +#define _POSIX_SAVED_IDS 1 +#define _POSIX_SHELL 1 +#define _POSIX_SPAWN _POSIX_VERSION +#define _POSIX_VDISABLE 0 + +#define _POSIX_THREADS _POSIX_VERSION +#define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION +#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION +#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION +#define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION +#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION +#define _POSIX_THREAD_CPUTIME _POSIX_VERSION +#define _POSIX_TIMERS _POSIX_VERSION +#define _POSIX_TIMEOUTS _POSIX_VERSION +#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION +#define _POSIX_CPUTIME _POSIX_VERSION +#define _POSIX_CLOCK_SELECTION _POSIX_VERSION +#define _POSIX_BARRIERS _POSIX_VERSION +#define _POSIX_SPIN_LOCKS _POSIX_VERSION +#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION +#define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION +#define _POSIX_SEMAPHORES _POSIX_VERSION +#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION + +#define _POSIX2_C_BIND _POSIX_VERSION + +#include + + + +#define _PC_LINK_MAX 0 +#define _PC_MAX_CANON 1 +#define _PC_MAX_INPUT 2 +#define _PC_NAME_MAX 3 +#define _PC_PATH_MAX 4 +#define _PC_PIPE_BUF 5 +#define _PC_CHOWN_RESTRICTED 6 +#define _PC_NO_TRUNC 7 +#define _PC_VDISABLE 8 +#define _PC_SYNC_IO 9 +#define _PC_ASYNC_IO 10 +#define _PC_PRIO_IO 11 +#define _PC_SOCK_MAXBUF 12 +#define _PC_FILESIZEBITS 13 +#define _PC_REC_INCR_XFER_SIZE 14 +#define _PC_REC_MAX_XFER_SIZE 15 +#define _PC_REC_MIN_XFER_SIZE 16 +#define _PC_REC_XFER_ALIGN 17 +#define _PC_ALLOC_SIZE_MIN 18 +#define _PC_SYMLINK_MAX 19 +#define _PC_2_SYMLINKS 20 + +#define _SC_ARG_MAX 0 +#define _SC_CHILD_MAX 1 +#define _SC_CLK_TCK 2 +#define _SC_NGROUPS_MAX 3 +#define _SC_OPEN_MAX 4 +#define _SC_STREAM_MAX 5 +#define _SC_TZNAME_MAX 6 +#define _SC_JOB_CONTROL 7 +#define _SC_SAVED_IDS 8 +#define _SC_REALTIME_SIGNALS 9 +#define _SC_PRIORITY_SCHEDULING 10 +#define _SC_TIMERS 11 +#define _SC_ASYNCHRONOUS_IO 12 +#define _SC_PRIORITIZED_IO 13 +#define _SC_SYNCHRONIZED_IO 14 +#define _SC_FSYNC 15 +#define _SC_MAPPED_FILES 16 +#define _SC_MEMLOCK 17 +#define _SC_MEMLOCK_RANGE 18 +#define _SC_MEMORY_PROTECTION 19 +#define _SC_MESSAGE_PASSING 20 +#define _SC_SEMAPHORES 21 +#define _SC_SHARED_MEMORY_OBJECTS 22 +#define _SC_AIO_LISTIO_MAX 23 +#define _SC_AIO_MAX 24 +#define _SC_AIO_PRIO_DELTA_MAX 25 +#define _SC_DELAYTIMER_MAX 26 +#define _SC_MQ_OPEN_MAX 27 +#define _SC_MQ_PRIO_MAX 28 +#define _SC_VERSION 29 +#define _SC_PAGE_SIZE 30 +#define _SC_PAGESIZE 30 /* !! */ +#define _SC_RTSIG_MAX 31 +#define _SC_SEM_NSEMS_MAX 32 +#define _SC_SEM_VALUE_MAX 33 +#define _SC_SIGQUEUE_MAX 34 +#define _SC_TIMER_MAX 35 +#define _SC_BC_BASE_MAX 36 +#define _SC_BC_DIM_MAX 37 +#define _SC_BC_SCALE_MAX 38 +#define _SC_BC_STRING_MAX 39 +#define _SC_COLL_WEIGHTS_MAX 40 +#define _SC_EXPR_NEST_MAX 42 +#define _SC_LINE_MAX 43 +#define _SC_RE_DUP_MAX 44 +#define _SC_2_VERSION 46 +#define _SC_2_C_BIND 47 +#define _SC_2_C_DEV 48 +#define _SC_2_FORT_DEV 49 +#define _SC_2_FORT_RUN 50 +#define _SC_2_SW_DEV 51 +#define _SC_2_LOCALEDEF 52 +#define _SC_UIO_MAXIOV 60 /* !! */ +#define _SC_IOV_MAX 60 +#define _SC_THREADS 67 +#define _SC_THREAD_SAFE_FUNCTIONS 68 +#define _SC_GETGR_R_SIZE_MAX 69 +#define _SC_GETPW_R_SIZE_MAX 70 +#define _SC_LOGIN_NAME_MAX 71 +#define _SC_TTY_NAME_MAX 72 +#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73 +#define _SC_THREAD_KEYS_MAX 74 +#define _SC_THREAD_STACK_MIN 75 +#define _SC_THREAD_THREADS_MAX 76 +#define _SC_THREAD_ATTR_STACKADDR 77 +#define _SC_THREAD_ATTR_STACKSIZE 78 +#define _SC_THREAD_PRIORITY_SCHEDULING 79 +#define _SC_THREAD_PRIO_INHERIT 80 +#define _SC_THREAD_PRIO_PROTECT 81 +#define _SC_THREAD_PROCESS_SHARED 82 +#define _SC_NPROCESSORS_CONF 83 +#define _SC_NPROCESSORS_ONLN 84 +#define _SC_PHYS_PAGES 85 +#define _SC_AVPHYS_PAGES 86 +#define _SC_ATEXIT_MAX 87 +#define _SC_PASS_MAX 88 +#define _SC_XOPEN_VERSION 89 +#define _SC_XOPEN_XCU_VERSION 90 +#define _SC_XOPEN_UNIX 91 +#define _SC_XOPEN_CRYPT 92 +#define _SC_XOPEN_ENH_I18N 93 +#define _SC_XOPEN_SHM 94 +#define _SC_2_CHAR_TERM 95 +#define _SC_2_UPE 97 +#define _SC_XOPEN_XPG2 98 +#define _SC_XOPEN_XPG3 99 +#define _SC_XOPEN_XPG4 100 +#define _SC_NZERO 109 +#define _SC_XBS5_ILP32_OFF32 125 +#define _SC_XBS5_ILP32_OFFBIG 126 +#define _SC_XBS5_LP64_OFF64 127 +#define _SC_XBS5_LPBIG_OFFBIG 128 +#define _SC_XOPEN_LEGACY 129 +#define _SC_XOPEN_REALTIME 130 +#define _SC_XOPEN_REALTIME_THREADS 131 +#define _SC_ADVISORY_INFO 132 +#define _SC_BARRIERS 133 +#define _SC_CLOCK_SELECTION 137 +#define _SC_CPUTIME 138 +#define _SC_THREAD_CPUTIME 139 +#define _SC_MONOTONIC_CLOCK 149 +#define _SC_READER_WRITER_LOCKS 153 +#define _SC_SPIN_LOCKS 154 +#define _SC_REGEXP 155 +#define _SC_SHELL 157 +#define _SC_SPAWN 159 +#define _SC_SPORADIC_SERVER 160 +#define _SC_THREAD_SPORADIC_SERVER 161 +#define _SC_TIMEOUTS 164 +#define _SC_TYPED_MEMORY_OBJECTS 165 +#define _SC_2_PBS 168 +#define _SC_2_PBS_ACCOUNTING 169 +#define _SC_2_PBS_LOCATE 170 +#define _SC_2_PBS_MESSAGE 171 +#define _SC_2_PBS_TRACK 172 +#define _SC_SYMLOOP_MAX 173 +#define _SC_STREAMS 174 +#define _SC_2_PBS_CHECKPOINT 175 +#define _SC_V6_ILP32_OFF32 176 +#define _SC_V6_ILP32_OFFBIG 177 +#define _SC_V6_LP64_OFF64 178 +#define _SC_V6_LPBIG_OFFBIG 179 +#define _SC_HOST_NAME_MAX 180 +#define _SC_TRACE 181 +#define _SC_TRACE_EVENT_FILTER 182 +#define _SC_TRACE_INHERIT 183 +#define _SC_TRACE_LOG 184 + +#define _SC_IPV6 235 +#define _SC_RAW_SOCKETS 236 +#define _SC_V7_ILP32_OFF32 237 +#define _SC_V7_ILP32_OFFBIG 238 +#define _SC_V7_LP64_OFF64 239 +#define _SC_V7_LPBIG_OFFBIG 240 +#define _SC_SS_REPL_MAX 241 +#define _SC_TRACE_EVENT_NAME_MAX 242 +#define _SC_TRACE_NAME_MAX 243 +#define _SC_TRACE_SYS_MAX 244 +#define _SC_TRACE_USER_EVENT_MAX 245 +#define _SC_XOPEN_STREAMS 246 +#define _SC_THREAD_ROBUST_PRIO_INHERIT 247 +#define _SC_THREAD_ROBUST_PRIO_PROTECT 248 + +#define _CS_PATH 0 +#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1 +#define _CS_GNU_LIBC_VERSION 2 +#define _CS_GNU_LIBPTHREAD_VERSION 3 +#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS 4 +#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5 + +#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116 +#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117 +#define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118 +#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119 +#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120 +#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121 +#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122 +#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123 +#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124 +#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125 +#define _CS_POSIX_V6_LP64_OFF64_LIBS 1126 +#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127 +#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130 +#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131 +#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132 +#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133 +#define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134 +#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135 +#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136 +#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137 +#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138 +#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139 +#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140 +#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141 +#define _CS_POSIX_V7_LP64_OFF64_LIBS 1142 +#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143 +#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144 +#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145 +#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146 +#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147 +#define _CS_V6_ENV 1148 +#define _CS_V7_ENV 1149 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/wchar.h b/thirdparty/open_source/musl/libc/wchar.h new file mode 100644 index 0000000..88eb55b --- /dev/null +++ b/thirdparty/open_source/musl/libc/wchar.h @@ -0,0 +1,205 @@ +#ifndef _WCHAR_H +#define _WCHAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_FILE +#define __NEED___isoc_va_list +#define __NEED_size_t +#define __NEED_wchar_t +#define __NEED_wint_t +#define __NEED_mbstate_t + +#if __STDC_VERSION__ < 201112L +#define __NEED_struct__IO_FILE +#endif + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_locale_t +#define __NEED_va_list +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_wctype_t +#endif + +#include + +#if L'\0'-1 > 0 +#define WCHAR_MAX (0xffffffffu+L'\0') +#define WCHAR_MIN (0+L'\0') +#else +#define WCHAR_MAX (0x7fffffff+L'\0') +#define WCHAR_MIN (-1-0x7fffffff+L'\0') +#endif + +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void*)0) +#endif + +#undef WEOF +#define WEOF 0xffffffffU + +wchar_t *wcscpy (wchar_t *__restrict, const wchar_t *__restrict); +wchar_t *wcsncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t); + +wchar_t *wcscat (wchar_t *__restrict, const wchar_t *__restrict); +wchar_t *wcsncat (wchar_t *__restrict, const wchar_t *__restrict, size_t); + +int wcscmp (const wchar_t *, const wchar_t *); +int wcsncmp (const wchar_t *, const wchar_t *, size_t); + +int wcscoll(const wchar_t *, const wchar_t *); +size_t wcsxfrm (wchar_t *__restrict, const wchar_t *__restrict, size_t); + +wchar_t *wcschr (const wchar_t *, wchar_t); +wchar_t *wcsrchr (const wchar_t *, wchar_t); + +size_t wcscspn (const wchar_t *, const wchar_t *); +size_t wcsspn (const wchar_t *, const wchar_t *); +wchar_t *wcspbrk (const wchar_t *, const wchar_t *); + +wchar_t *wcstok (wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict); + +size_t wcslen (const wchar_t *); + +wchar_t *wcsstr (const wchar_t *__restrict, const wchar_t *__restrict); +wchar_t *wcswcs (const wchar_t *, const wchar_t *); + +wchar_t *wmemchr (const wchar_t *, wchar_t, size_t); +int wmemcmp (const wchar_t *, const wchar_t *, size_t); +wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict, size_t); +wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t); +wchar_t *wmemset (wchar_t *, wchar_t, size_t); + +wint_t btowc (int); +int wctob (wint_t); + +int mbsinit (const mbstate_t *); +size_t mbrtowc (wchar_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict); +size_t wcrtomb (char *__restrict, wchar_t, mbstate_t *__restrict); + +size_t mbrlen (const char *__restrict, size_t, mbstate_t *__restrict); + +size_t mbsrtowcs (wchar_t *__restrict, const char **__restrict, size_t, mbstate_t *__restrict); +size_t wcsrtombs (char *__restrict, const wchar_t **__restrict, size_t, mbstate_t *__restrict); + +float wcstof (const wchar_t *__restrict, wchar_t **__restrict); +double wcstod (const wchar_t *__restrict, wchar_t **__restrict); +long double wcstold (const wchar_t *__restrict, wchar_t **__restrict); + +long wcstol (const wchar_t *__restrict, wchar_t **__restrict, int); +unsigned long wcstoul (const wchar_t *__restrict, wchar_t **__restrict, int); + +long long wcstoll (const wchar_t *__restrict, wchar_t **__restrict, int); +unsigned long long wcstoull (const wchar_t *__restrict, wchar_t **__restrict, int); + + + +int fwide (FILE *, int); + + +int wprintf (const wchar_t *__restrict, ...); +int fwprintf (FILE *__restrict, const wchar_t *__restrict, ...); +int swprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, ...); + +int vwprintf (const wchar_t *__restrict, __isoc_va_list); +int vfwprintf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list); +int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, __isoc_va_list); + +int wscanf (const wchar_t *__restrict, ...); +int fwscanf (FILE *__restrict, const wchar_t *__restrict, ...); +int swscanf (const wchar_t *__restrict, const wchar_t *__restrict, ...); + +int vwscanf (const wchar_t *__restrict, __isoc_va_list); +int vfwscanf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list); +int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, __isoc_va_list); + +wint_t fgetwc (FILE *); +wint_t getwc (FILE *); +wint_t getwchar (void); + +wint_t fputwc (wchar_t, FILE *); +wint_t putwc (wchar_t, FILE *); +wint_t putwchar (wchar_t); + +wchar_t *fgetws (wchar_t *__restrict, int, FILE *__restrict); +int fputws (const wchar_t *__restrict, FILE *__restrict); + +wint_t ungetwc (wint_t, FILE *); + +struct tm; +size_t wcsftime (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict); + +#undef iswdigit + +#if defined(_GNU_SOURCE) +wint_t fgetwc_unlocked (FILE *); +wint_t getwc_unlocked (FILE *); +wint_t getwchar_unlocked (void); +wint_t fputwc_unlocked (wchar_t, FILE *); +wint_t putwc_unlocked (wchar_t, FILE *); +wint_t putwchar_unlocked (wchar_t); +wchar_t *fgetws_unlocked (wchar_t *__restrict, int, FILE *__restrict); +int fputws_unlocked (const wchar_t *__restrict, FILE *__restrict); +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict, locale_t); +#endif + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +FILE *open_wmemstream(wchar_t **, size_t *); +size_t mbsnrtowcs(wchar_t *__restrict, const char **__restrict, size_t, size_t, mbstate_t *__restrict); +size_t wcsnrtombs(char *__restrict, const wchar_t **__restrict, size_t, size_t, mbstate_t *__restrict); +wchar_t *wcsdup(const wchar_t *); +size_t wcsnlen (const wchar_t *, size_t); +wchar_t *wcpcpy (wchar_t *__restrict, const wchar_t *__restrict); +wchar_t *wcpncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t); +int wcscasecmp(const wchar_t *, const wchar_t *); +int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t); +int wcsncasecmp(const wchar_t *, const wchar_t *, size_t); +int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t); +int wcscoll_l(const wchar_t *, const wchar_t *, locale_t); +size_t wcsxfrm_l(wchar_t *__restrict, const wchar_t *__restrict, size_t, locale_t); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int wcwidth (wchar_t); +int wcswidth (const wchar_t *, size_t); +int iswalnum(wint_t); +int iswalpha(wint_t); +int iswblank(wint_t); +int iswcntrl(wint_t); +int iswdigit(wint_t); +int iswgraph(wint_t); +int iswlower(wint_t); +int iswprint(wint_t); +int iswpunct(wint_t); +int iswspace(wint_t); +int iswupper(wint_t); +int iswxdigit(wint_t); +int iswctype(wint_t, wctype_t); +wint_t towlower(wint_t); +wint_t towupper(wint_t); +wctype_t wctype(const char *); + +#ifndef __cplusplus +#undef iswdigit +#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10) +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/wctype.h b/thirdparty/open_source/musl/libc/wctype.h new file mode 100644 index 0000000..bc2420d --- /dev/null +++ b/thirdparty/open_source/musl/libc/wctype.h @@ -0,0 +1,79 @@ +#ifndef _WCTYPE_H +#define _WCTYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_wint_t +#define __NEED_wctype_t + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define __NEED_locale_t +#endif + +#include + +typedef const int * wctrans_t; + +#undef WEOF +#define WEOF 0xffffffffU + +#undef iswdigit + +int iswalnum(wint_t); +int iswalpha(wint_t); +int iswblank(wint_t); +int iswcntrl(wint_t); +int iswdigit(wint_t); +int iswgraph(wint_t); +int iswlower(wint_t); +int iswprint(wint_t); +int iswpunct(wint_t); +int iswspace(wint_t); +int iswupper(wint_t); +int iswxdigit(wint_t); +int iswctype(wint_t, wctype_t); +wint_t towctrans(wint_t, wctrans_t); +wint_t towlower(wint_t); +wint_t towupper(wint_t); +wctrans_t wctrans(const char *); +wctype_t wctype(const char *); + +#ifndef __cplusplus +#undef iswdigit +#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10) +#endif + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + +int iswalnum_l(wint_t, locale_t); +int iswalpha_l(wint_t, locale_t); +int iswblank_l(wint_t, locale_t); +int iswcntrl_l(wint_t, locale_t); +int iswdigit_l(wint_t, locale_t); +int iswgraph_l(wint_t, locale_t); +int iswlower_l(wint_t, locale_t); +int iswprint_l(wint_t, locale_t); +int iswpunct_l(wint_t, locale_t); +int iswspace_l(wint_t, locale_t); +int iswupper_l(wint_t, locale_t); +int iswxdigit_l(wint_t, locale_t); +int iswctype_l(wint_t, wctype_t, locale_t); +wint_t towlower_l(wint_t, locale_t); +wint_t towupper_l(wint_t, locale_t); +wint_t towctrans_l(wint_t, wctrans_t, locale_t); +wctrans_t wctrans_l(const char *, locale_t); +wctype_t wctype_l(const char *, locale_t); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif -- Gitee