From 78d00c3371324cd17b2227bfd839c41f6005162e Mon Sep 17 00:00:00 2001 From: BoloniniD Date: Tue, 23 Aug 2022 21:26:19 +0300 Subject: [PATCH] Add glibc symbols to glibc_compatibility --- .../musl/copy_file_range.c | 8 +++++ base/glibc-compatibility/musl/fstatat.c | 29 +++++++++++++++++++ base/glibc-compatibility/musl/posix_spawnp.c | 14 +++++++++ base/glibc-compatibility/musl/spawn.h | 19 ++++++++++++ base/glibc-compatibility/musl/splice.c | 8 +++++ contrib/BLAKE3/build_rust_lib.cmake | 2 +- 6 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 base/glibc-compatibility/musl/copy_file_range.c create mode 100644 base/glibc-compatibility/musl/fstatat.c create mode 100644 base/glibc-compatibility/musl/posix_spawnp.c create mode 100644 base/glibc-compatibility/musl/spawn.h create mode 100644 base/glibc-compatibility/musl/splice.c diff --git a/base/glibc-compatibility/musl/copy_file_range.c b/base/glibc-compatibility/musl/copy_file_range.c new file mode 100644 index 00000000000..dd4b1333362 --- /dev/null +++ b/base/glibc-compatibility/musl/copy_file_range.c @@ -0,0 +1,8 @@ +#define _GNU_SOURCE +#include +#include "syscall.h" + +ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags) +{ + return syscall(SYS_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags); +} diff --git a/base/glibc-compatibility/musl/fstatat.c b/base/glibc-compatibility/musl/fstatat.c new file mode 100644 index 00000000000..39221bd1575 --- /dev/null +++ b/base/glibc-compatibility/musl/fstatat.c @@ -0,0 +1,29 @@ +#define _BSD_SOURCE +#include +#include +#include "syscall.h" + +struct statx { + uint32_t stx_mask; + uint32_t stx_blksize; + uint64_t stx_attributes; + uint32_t stx_nlink; + uint32_t stx_uid; + uint32_t stx_gid; + uint16_t stx_mode; + uint16_t pad1; + uint64_t stx_ino; + uint64_t stx_size; + uint64_t stx_blocks; + uint64_t stx_attributes_mask; + struct { + int64_t tv_sec; + uint32_t tv_nsec; + int32_t pad; + } stx_atime, stx_btime, stx_ctime, stx_mtime; + uint32_t stx_rdev_major; + uint32_t stx_rdev_minor; + uint32_t stx_dev_major; + uint32_t stx_dev_minor; + uint64_t spare[14]; +}; diff --git a/base/glibc-compatibility/musl/posix_spawnp.c b/base/glibc-compatibility/musl/posix_spawnp.c new file mode 100644 index 00000000000..15762b95979 --- /dev/null +++ b/base/glibc-compatibility/musl/posix_spawnp.c @@ -0,0 +1,14 @@ +#include "spawn.h" +#include +#include + +int posix_spawnp(pid_t *restrict res, const char *restrict file, + const posix_spawn_file_actions_t *fa, + const posix_spawnattr_t *restrict attr, + char *const argv[restrict], char *const envp[restrict]) +{ + posix_spawnattr_t spawnp_attr = { 0 }; + if (attr) spawnp_attr = *attr; + spawnp_attr.__fn = (void *)execvpe; + return posix_spawn(res, file, fa, &spawnp_attr, argv, envp); +} diff --git a/base/glibc-compatibility/musl/spawn.h b/base/glibc-compatibility/musl/spawn.h new file mode 100644 index 00000000000..d7ed44acb8b --- /dev/null +++ b/base/glibc-compatibility/musl/spawn.h @@ -0,0 +1,19 @@ +#include +#include +#include + + +typedef struct { + int __flags; + pid_t __pgrp; + sigset_t __def, __mask; + int __prio, __pol; + void *__fn; + char __pad[64-sizeof(void *)]; +} posix_spawnattr_t; + +typedef struct { + int __pad0[2]; + void *__actions; + int __pad[16]; +} posix_spawn_file_actions_t; diff --git a/base/glibc-compatibility/musl/splice.c b/base/glibc-compatibility/musl/splice.c new file mode 100644 index 00000000000..4b3f06ec2f5 --- /dev/null +++ b/base/glibc-compatibility/musl/splice.c @@ -0,0 +1,8 @@ +#define _GNU_SOURCE +#include +#include "syscall.h" + +long splice(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags) +{ + return syscall(SYS_splice, fd_in, off_in, fd_out, off_out, len, flags); +} diff --git a/contrib/BLAKE3/build_rust_lib.cmake b/contrib/BLAKE3/build_rust_lib.cmake index 5d00ba52928..66feba85d45 100755 --- a/contrib/BLAKE3/build_rust_lib.cmake +++ b/contrib/BLAKE3/build_rust_lib.cmake @@ -74,7 +74,7 @@ function(build_cargo target_name project_dir) COMMENT ${compile_message} COMMAND export BUILD_FOR_OSX=${OSX_RUST_ROOT} COMMAND env CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} cargo rustc -v ${CARGO_RELEASE_FLAG} ${TARGET_SPEC_FLAG} - COMMAND if [ ${TARGET_CP} = 0 ]\; then cp ${output_library} ${CMAKE_CURRENT_BINARY_DIR}\; else cp ./libblake_test/* ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_SPEC}/${TARGET_DIR}\; fi + #COMMAND if [ ${TARGET_CP} = 0 ]\; then cp ${output_library} ${CMAKE_CURRENT_BINARY_DIR}\; else cp ./libblake_test/* ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_SPEC}/${TARGET_DIR}\; fi OUTPUT ${output_library} WORKING_DIRECTORY ${project_dir})