mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-25 22:14:34 +00:00
feat(userspace/libc): support for linux target
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
8258d40115
commit
7e69b8f82a
24
Userspace/.vscode/c_cpp_properties.json
vendored
24
Userspace/.vscode/c_cpp_properties.json
vendored
@ -5,12 +5,16 @@
|
||||
"includePath": [
|
||||
"${workspaceFolder}/libc/include/**",
|
||||
"${workspaceFolder}/coreutils/include/**",
|
||||
"${workspaceFolder}/libs/include/**"
|
||||
"${workspaceFolder}/libs/include/**",
|
||||
"${workspaceFolder}/out/include/**"
|
||||
],
|
||||
"defines": [
|
||||
"__debug_vscode__",
|
||||
"DEBUG=\"1\""
|
||||
],
|
||||
"forcedInclude": [
|
||||
"${workspaceFolder}/.vscode/preinclude.h"
|
||||
],
|
||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/x86_64-fennix-gcc",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++20",
|
||||
@ -47,12 +51,16 @@
|
||||
"includePath": [
|
||||
"${workspaceFolder}/libc/include/**",
|
||||
"${workspaceFolder}/coreutils/include/**",
|
||||
"${workspaceFolder}/libs/include/**"
|
||||
"${workspaceFolder}/libs/include/**",
|
||||
"${workspaceFolder}/out/include/**"
|
||||
],
|
||||
"defines": [
|
||||
"__debug_vscode__",
|
||||
"DEBUG=\"1\""
|
||||
],
|
||||
"forcedInclude": [
|
||||
"${workspaceFolder}/.vscode/preinclude.h"
|
||||
],
|
||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/i386-fennix-gcc",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++20",
|
||||
@ -89,12 +97,16 @@
|
||||
"includePath": [
|
||||
"${workspaceFolder}/libc/include/**",
|
||||
"${workspaceFolder}/coreutils/include/**",
|
||||
"${workspaceFolder}/libs/include/**"
|
||||
"${workspaceFolder}/libs/include/**",
|
||||
"${workspaceFolder}/out/include/**"
|
||||
],
|
||||
"defines": [
|
||||
"__debug_vscode__",
|
||||
"DEBUG=\"1\""
|
||||
],
|
||||
"forcedInclude": [
|
||||
"${workspaceFolder}/.vscode/preinclude.h"
|
||||
],
|
||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/arm-fennix-gcc",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++20",
|
||||
@ -111,12 +123,16 @@
|
||||
"includePath": [
|
||||
"${workspaceFolder}/libc/include/**",
|
||||
"${workspaceFolder}/coreutils/include/**",
|
||||
"${workspaceFolder}/libs/include/**"
|
||||
"${workspaceFolder}/libs/include/**",
|
||||
"${workspaceFolder}/out/include/**"
|
||||
],
|
||||
"defines": [
|
||||
"__debug_vscode__",
|
||||
"DEBUG=\"1\""
|
||||
],
|
||||
"forcedInclude": [
|
||||
"${workspaceFolder}/.vscode/preinclude.h"
|
||||
],
|
||||
"compilerPath": "${workspaceFolder}/../tools/cross/bin/aarch64-fennix-gcc",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++20",
|
||||
|
1
Userspace/.vscode/preinclude.h
vendored
1
Userspace/.vscode/preinclude.h
vendored
@ -6,3 +6,4 @@
|
||||
#undef __APPLE__
|
||||
#undef __clang__
|
||||
#define __vscode__ 1
|
||||
#define FENNIX_DYNAMIC_LOADER 1
|
||||
|
@ -79,3 +79,4 @@ clean:
|
||||
touch cache/.gitkeep
|
||||
make -C libs clean
|
||||
make -C apps clean
|
||||
make -C docker clean
|
||||
|
2
Userspace/docker/.gitignore
vendored
Normal file
2
Userspace/docker/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
cache/*
|
||||
docker-root/*
|
3
Userspace/docker/Dockerfile
Normal file
3
Userspace/docker/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM scratch
|
||||
ADD docker-root /
|
||||
CMD ["/bin/sh"]
|
68
Userspace/docker/Makefile
Normal file
68
Userspace/docker/Makefile
Normal file
@ -0,0 +1,68 @@
|
||||
export DOCKER_ROOT = $(CURDIR)/docker-root
|
||||
DOCKER_IMAGE_NAME = fennix-userspace
|
||||
|
||||
export CMAKE_INSTALL_PREFIX := $(DOCKER_ROOT)
|
||||
export CMAKE_SYSROOT := $(DOCKER_ROOT)
|
||||
|
||||
export LDFLAGS := --sysroot=$(DOCKER_ROOT) \
|
||||
-ggdb3 -O0
|
||||
export CFLAGS := \
|
||||
--sysroot=$(DOCKER_ROOT) \
|
||||
-I$(DOCKER_ROOT)/include \
|
||||
-DDEBUG -ggdb3 -O0 -fdiagnostics-color=always
|
||||
|
||||
create_docker_out:
|
||||
rm -rf cache
|
||||
rm -rf $(DOCKER_ROOT)
|
||||
mkdir -p $(DOCKER_ROOT)
|
||||
mkdir -p $(DOCKER_ROOT)/bin
|
||||
mkdir -p $(DOCKER_ROOT)/etc
|
||||
mkdir -p $(DOCKER_ROOT)/lib
|
||||
mkdir -p $(DOCKER_ROOT)/lib64
|
||||
mkdir -p $(DOCKER_ROOT)/include/linux
|
||||
mkdir -p $(DOCKER_ROOT)/usr/bin
|
||||
mkdir -p $(DOCKER_ROOT)/usr/share/doc
|
||||
mkdir -p $(DOCKER_ROOT)/usr/share/info
|
||||
mkdir -p $(DOCKER_ROOT)/usr/include
|
||||
mkdir -p $(DOCKER_ROOT)/usr/lib
|
||||
|
||||
build_docker_coreutils:
|
||||
mkdir -p cache/coreutils
|
||||
cd cache/coreutils && \
|
||||
cmake $(CURDIR)/../coreutils \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=$(DOCKER_ROOT) \
|
||||
-DCMAKE_SYSROOT=$(DOCKER_ROOT) \
|
||||
-DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(DOCKER_ROOT)/include \
|
||||
-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=$(DOCKER_ROOT)/include \
|
||||
&& \
|
||||
make -j$(shell nproc) && \
|
||||
make install
|
||||
|
||||
build_docker_libc:
|
||||
mkdir -p cache/libc
|
||||
cd cache/libc && \
|
||||
cmake $(CURDIR)/../libc \
|
||||
-DCMAKE_INSTALL_PREFIX=$(DOCKER_ROOT) \
|
||||
-DCMAKE_SYSROOT=$(DOCKER_ROOT) \
|
||||
-DCMAKE_INSTALL_INCLUDEDIR=include \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
-DCMAKE_INSTALL_BINDIR=bin && \
|
||||
make -j$(shell nproc) && \
|
||||
make install
|
||||
|
||||
docker_image:
|
||||
docker build -t $(DOCKER_IMAGE_NAME) -f Dockerfile .
|
||||
|
||||
docker_run:
|
||||
@echo "Running container..."
|
||||
@docker run -it --name fennix-userspace-instance fennix-userspace:latest /bin/sh || true
|
||||
@echo "\nExit code: $$(docker inspect fennix-userspace-instance --format='{{.State.ExitCode}}')"
|
||||
@docker rm fennix-userspace-instance >/dev/null 2>&1
|
||||
|
||||
docker: create_docker_out
|
||||
$(MAKE) build_docker_libc
|
||||
$(MAKE) build_docker_coreutils
|
||||
|
||||
clean:
|
||||
rm -rf cache
|
||||
rm -rf $(DOCKER_ROOT)
|
@ -5,22 +5,39 @@ project(FennixCLibrary VERSION 1.0.0)
|
||||
if(NOT DEFINED ENV{WORKSPACE_DIR})
|
||||
set(STANDALONE_BUILD ON)
|
||||
message(STATUS "Compiling standalone")
|
||||
set(CMAKE_INSTALL_PREFIX "/usr")
|
||||
|
||||
if(NOT DEFINED ENV{CMAKE_INSTALL_PREFIX})
|
||||
set(CMAKE_INSTALL_PREFIX "/usr")
|
||||
message(STATUS "Using default install prefix: /usr")
|
||||
else()
|
||||
message(STATUS "Using custom install prefix: $ENV{CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
|
||||
else()
|
||||
set(STANDALONE_BUILD OFF)
|
||||
set(CMAKE_INSTALL_PREFIX "$ENV{WORKSPACE_DIR}/out")
|
||||
message(STATUS "Compiling within workspace")
|
||||
|
||||
if(NOT DEFINED ENV{CMAKE_INSTALL_PREFIX})
|
||||
set(CMAKE_INSTALL_PREFIX "$ENV{WORKSPACE_DIR}/out")
|
||||
message(STATUS "Using default install prefix: $ENV{WORKSPACE_DIR}/out")
|
||||
else()
|
||||
message(STATUS "Using custom install prefix: $ENV{CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
|
||||
try_compile(
|
||||
WORKSPACE_TEST
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/workspace_test.c
|
||||
CMAKE_FLAGS "-DCMAKE_C_COMPILER=$ENV{CC} -DCMAKE_CXX_COMPILER=$ENV{CXX} -DCMAKE_ASM_COMPILER=$ENV{AS} -DCMAKE_AR=$ENV{AR} -DCMAKE_LINKER=$ENV{LD}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
OUTPUT_VARIABLE OUTPUT
|
||||
)
|
||||
|
||||
if(NOT WORKSPACE_TEST)
|
||||
message(FATAL_ERROR "Workspace test failed: ${OUTPUT}")
|
||||
else()
|
||||
message(STATUS "Workspace test passed")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED TARGET_OS)
|
||||
@ -102,3 +119,26 @@ install(DIRECTORY ${ABIS_PATH}/
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/
|
||||
FILES_MATCHING
|
||||
PATTERN "*")
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
/lib/ld.so
|
||||
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib/ld-linux-x86-64.so.2\"
|
||||
)")
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
/lib/ld.so
|
||||
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib64/ld-linux-x86-64.so.2\"
|
||||
)")
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
/lib/libc.so
|
||||
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib/libc.so.6\"
|
||||
)")
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
/lib/libc.so
|
||||
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib64/libc.so.6\"
|
||||
)")
|
||||
endif()
|
||||
|
@ -15,8 +15,8 @@
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BITS_SIGNAL_H
|
||||
#define __BITS_SIGNAL_H
|
||||
#ifndef _BITS_SIGNAL_H
|
||||
#define _BITS_SIGNAL_H
|
||||
|
||||
#include <bits/syscalls.h>
|
||||
|
||||
@ -121,4 +121,4 @@
|
||||
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
#endif // __BITS_SIGNAL_H
|
||||
#endif // _BITS_SIGNAL_H
|
||||
|
@ -15,8 +15,8 @@
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BITS_SOCKET_H
|
||||
#define __BITS_SOCKET_H
|
||||
#ifndef _BITS_SOCKET_H
|
||||
#define _BITS_SOCKET_H
|
||||
|
||||
#define __socklen_t_defined
|
||||
typedef __UINT32_TYPE__ socklen_t;
|
||||
@ -31,4 +31,4 @@ struct sockaddr
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
#endif // __BITS_SOCKET_H
|
||||
#endif // _BITS_SOCKET_H
|
||||
|
159
Userspace/libc/abis/linux/x86_64/bits/errno.h
Normal file
159
Userspace/libc/abis/linux/x86_64/bits/errno.h
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _BITS_ERRNO_H
|
||||
#define _BITS_ERRNO_H
|
||||
|
||||
#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 41
|
||||
#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 58
|
||||
#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 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
|
||||
|
||||
#define ENOTSUP EOPNOTSUPP
|
||||
|
||||
#endif // _BITS_ERRNO_H
|
74
Userspace/libc/abis/linux/x86_64/bits/signal.h
Normal file
74
Userspace/libc/abis/linux/x86_64/bits/signal.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _BITS_SIGNAL_H
|
||||
#define _BITS_SIGNAL_H
|
||||
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
#define NSIG 32
|
||||
|
||||
#define SIGHUP 1
|
||||
#define SIGINT 2
|
||||
#define SIGQUIT 3
|
||||
#define SIGILL 4
|
||||
#define SIGTRAP 5
|
||||
#define SIGABRT 6
|
||||
#define SIGIOT 6
|
||||
#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 SIGIO
|
||||
|
||||
#define SIGLOST 29
|
||||
|
||||
#define SIGPWR 30
|
||||
#define SIGSYS 31
|
||||
#define SIGUNUSED 31
|
||||
|
||||
#define SIG_BLOCK 0
|
||||
#define SIG_UNBLOCK 1
|
||||
#define SIG_SETMASK 2
|
||||
|
||||
typedef void __signalfn_t(int);
|
||||
typedef __signalfn_t *__sighandler_t;
|
||||
|
||||
#define SIG_DFL ((__sighandler_t)0)
|
||||
#define SIG_IGN ((__sighandler_t)1)
|
||||
#define SIG_ERR ((__sighandler_t) - 1)
|
||||
|
||||
#endif // _BITS_SIGNAL_H
|
34
Userspace/libc/abis/linux/x86_64/bits/socket.h
Normal file
34
Userspace/libc/abis/linux/x86_64/bits/socket.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _BITS_SOCKET_H
|
||||
#define _BITS_SOCKET_H
|
||||
|
||||
#define __socklen_t_defined
|
||||
typedef __UINT32_TYPE__ socklen_t;
|
||||
|
||||
#define __sa_family_t_defined
|
||||
typedef unsigned int sa_family_t;
|
||||
|
||||
#define __sockaddr_defined
|
||||
struct sockaddr
|
||||
{
|
||||
sa_family_t sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
#endif // _BITS_SOCKET_H
|
474
Userspace/libc/abis/linux/x86_64/bits/syscalls.h
Normal file
474
Userspace/libc/abis/linux/x86_64/bits/syscalls.h
Normal file
@ -0,0 +1,474 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _BITS_SYSCALLS_H
|
||||
#define _BITS_SYSCALLS_H
|
||||
|
||||
#pragma region Syscall Wrappers
|
||||
|
||||
#define scarg __UINTPTR_TYPE__
|
||||
|
||||
static inline scarg syscall0(scarg syscall)
|
||||
{
|
||||
scarg ret;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(syscall)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline scarg syscall1(scarg syscall, scarg arg1)
|
||||
{
|
||||
scarg ret;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(syscall), "D"(arg1)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline scarg syscall2(scarg syscall, scarg arg1, scarg arg2)
|
||||
{
|
||||
scarg ret;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(syscall), "D"(arg1), "S"(arg2)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline scarg syscall3(scarg syscall, scarg arg1, scarg arg2, scarg arg3)
|
||||
{
|
||||
scarg ret;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline scarg syscall4(scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4)
|
||||
{
|
||||
scarg ret;
|
||||
register scarg r10 __asm__("r10") = arg4;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline scarg syscall5(scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4, scarg arg5)
|
||||
{
|
||||
scarg ret;
|
||||
register scarg r10 __asm__("r10") = arg4;
|
||||
register scarg r8 __asm__("r8") = arg5;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10), "r"(r8)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline scarg syscall6(scarg syscall, scarg arg1, scarg arg2, scarg arg3, scarg arg4, scarg arg5, scarg arg6)
|
||||
{
|
||||
scarg ret;
|
||||
register scarg r10 __asm__("r10") = arg4;
|
||||
register scarg r8 __asm__("r8") = arg5;
|
||||
register scarg r9 __asm__("r9") = arg6;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(syscall), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10), "r"(r8), "r"(r9)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#pragma endregion Syscall Wrappers
|
||||
|
||||
#define sys_read 0
|
||||
#define sys_write 1
|
||||
#define sys_open 2
|
||||
#define sys_close 3
|
||||
#define sys_stat 4
|
||||
#define sys_fstat 5
|
||||
#define sys_lstat 6
|
||||
#define sys_poll 7
|
||||
#define sys_lseek 8
|
||||
#define sys_mmap 9
|
||||
#define sys_mprotect 10
|
||||
#define sys_munmap 11
|
||||
#define sys_brk 12
|
||||
#define sys_rt_sigaction 13
|
||||
#define sys_rt_sigprocmask 14
|
||||
#define sys_rt_sigreturn 15
|
||||
#define sys_ioctl 16
|
||||
#define sys_pread64 17
|
||||
#define sys_pwrite64 18
|
||||
#define sys_readv 19
|
||||
#define sys_writev 20
|
||||
#define sys_access 21
|
||||
#define sys_pipe 22
|
||||
#define sys_select 23
|
||||
#define sys_sched_yield 24
|
||||
#define sys_mremap 25
|
||||
#define sys_msync 26
|
||||
#define sys_mincore 27
|
||||
#define sys_madvise 28
|
||||
#define sys_shmget 29
|
||||
#define sys_shmat 30
|
||||
#define sys_shmctl 31
|
||||
#define sys_dup 32
|
||||
#define sys_dup2 33
|
||||
#define sys_pause 34
|
||||
#define sys_nanosleep 35
|
||||
#define sys_getitimer 36
|
||||
#define sys_alarm 37
|
||||
#define sys_setitimer 38
|
||||
#define sys_getpid 39
|
||||
#define sys_sendfile 40
|
||||
#define sys_socket 41
|
||||
#define sys_connect 42
|
||||
#define sys_accept 43
|
||||
#define sys_sendto 44
|
||||
#define sys_recvfrom 45
|
||||
#define sys_sendmsg 46
|
||||
#define sys_recvmsg 47
|
||||
#define sys_shutdown 48
|
||||
#define sys_bind 49
|
||||
#define sys_listen 50
|
||||
#define sys_getsockname 51
|
||||
#define sys_getpeername 52
|
||||
#define sys_socketpair 53
|
||||
#define sys_setsockopt 54
|
||||
#define sys_getsockopt 55
|
||||
#define sys_clone 56
|
||||
#define sys_fork 57
|
||||
#define sys_vfork 58
|
||||
#define sys_execve 59
|
||||
#define sys_exit 60
|
||||
#define sys_wait4 61
|
||||
#define sys_kill 62
|
||||
#define sys_uname 63
|
||||
#define sys_semget 64
|
||||
#define sys_semop 65
|
||||
#define sys_semctl 66
|
||||
#define sys_shmdt 67
|
||||
#define sys_msgget 68
|
||||
#define sys_msgsnd 69
|
||||
#define sys_msgrcv 70
|
||||
#define sys_msgctl 71
|
||||
#define sys_fcntl 72
|
||||
#define sys_flock 73
|
||||
#define sys_fsync 74
|
||||
#define sys_fdatasync 75
|
||||
#define sys_truncate 76
|
||||
#define sys_ftruncate 77
|
||||
#define sys_getdents 78
|
||||
#define sys_getcwd 79
|
||||
#define sys_chdir 80
|
||||
#define sys_fchdir 81
|
||||
#define sys_rename 82
|
||||
#define sys_mkdir 83
|
||||
#define sys_rmdir 84
|
||||
#define sys_creat 85
|
||||
#define sys_link 86
|
||||
#define sys_unlink 87
|
||||
#define sys_symlink 88
|
||||
#define sys_readlink 89
|
||||
#define sys_chmod 90
|
||||
#define sys_fchmod 91
|
||||
#define sys_chown 92
|
||||
#define sys_fchown 93
|
||||
#define sys_lchown 94
|
||||
#define sys_umask 95
|
||||
#define sys_gettimeofday 96
|
||||
#define sys_getrlimit 97
|
||||
#define sys_getrusage 98
|
||||
#define sys_sysinfo 99
|
||||
#define sys_times 100
|
||||
#define sys_ptrace 101
|
||||
#define sys_getuid 102
|
||||
#define sys_syslog 103
|
||||
#define sys_getgid 104
|
||||
#define sys_setuid 105
|
||||
#define sys_setgid 106
|
||||
#define sys_geteuid 107
|
||||
#define sys_getegid 108
|
||||
#define sys_setpgid 109
|
||||
#define sys_getppid 110
|
||||
#define sys_getpgrp 111
|
||||
#define sys_setsid 112
|
||||
#define sys_setreuid 113
|
||||
#define sys_setregid 114
|
||||
#define sys_getgroups 115
|
||||
#define sys_setgroups 116
|
||||
#define sys_setresuid 117
|
||||
#define sys_getresuid 118
|
||||
#define sys_setresgid 119
|
||||
#define sys_getresgid 120
|
||||
#define sys_getpgid 121
|
||||
#define sys_setfsuid 122
|
||||
#define sys_setfsgid 123
|
||||
#define sys_getsid 124
|
||||
#define sys_capget 125
|
||||
#define sys_capset 126
|
||||
#define sys_rt_sigpending 127
|
||||
#define sys_rt_sigtimedwait 128
|
||||
#define sys_rt_sigqueueinfo 129
|
||||
#define sys_rt_sigsuspend 130
|
||||
#define sys_sigaltstack 131
|
||||
#define sys_utime 132
|
||||
#define sys_mknod 133
|
||||
#define sys_uselib 134
|
||||
#define sys_personality 135
|
||||
#define sys_ustat 136
|
||||
#define sys_statfs 137
|
||||
#define sys_fstatfs 138
|
||||
#define sys_sysfs 139
|
||||
#define sys_getpriority 140
|
||||
#define sys_setpriority 141
|
||||
#define sys_sched_setparam 142
|
||||
#define sys_sched_getparam 143
|
||||
#define sys_sched_setscheduler 144
|
||||
#define sys_sched_getscheduler 145
|
||||
#define sys_sched_get_priority_max 146
|
||||
#define sys_sched_get_priority_min 147
|
||||
#define sys_sched_rr_get_interval 148
|
||||
#define sys_mlock 149
|
||||
#define sys_munlock 150
|
||||
#define sys_mlockall 151
|
||||
#define sys_munlockall 152
|
||||
#define sys_vhangup 153
|
||||
#define sys_modify_ldt 154
|
||||
#define sys_pivot_root 155
|
||||
#define sys__sysctl 156
|
||||
#define sys_prctl 157
|
||||
#define sys_arch_prctl 158
|
||||
#define sys_adjtimex 159
|
||||
#define sys_setrlimit 160
|
||||
#define sys_chroot 161
|
||||
#define sys_sync 162
|
||||
#define sys_acct 163
|
||||
#define sys_settimeofday 164
|
||||
#define sys_mount 165
|
||||
#define sys_umount2 166
|
||||
#define sys_swapon 167
|
||||
#define sys_swapoff 168
|
||||
#define sys_reboot 169
|
||||
#define sys_sethostname 170
|
||||
#define sys_setdomainname 171
|
||||
#define sys_iopl 172
|
||||
#define sys_ioperm 173
|
||||
#define sys_create_module 174
|
||||
#define sys_init_module 175
|
||||
#define sys_delete_module 176
|
||||
#define sys_get_kernel_syms 177
|
||||
#define sys_query_module 178
|
||||
#define sys_quotactl 179
|
||||
#define sys_nfsservctl 180
|
||||
#define sys_getpmsg 181
|
||||
#define sys_putpmsg 182
|
||||
#define sys_afs_syscall 183
|
||||
#define sys_tuxcall 184
|
||||
#define sys_security 185
|
||||
#define sys_gettid 186
|
||||
#define sys_readahead 187
|
||||
#define sys_setxattr 188
|
||||
#define sys_lsetxattr 189
|
||||
#define sys_fsetxattr 190
|
||||
#define sys_getxattr 191
|
||||
#define sys_lgetxattr 192
|
||||
#define sys_fgetxattr 193
|
||||
#define sys_listxattr 194
|
||||
#define sys_llistxattr 195
|
||||
#define sys_flistxattr 196
|
||||
#define sys_removexattr 197
|
||||
#define sys_lremovexattr 198
|
||||
#define sys_fremovexattr 199
|
||||
#define sys_tkill 200
|
||||
#define sys_time 201
|
||||
#define sys_futex 202
|
||||
#define sys_sched_setaffinity 203
|
||||
#define sys_sched_getaffinity 204
|
||||
#define sys_set_thread_area 205
|
||||
#define sys_io_setup 206
|
||||
#define sys_io_destroy 207
|
||||
#define sys_io_getevents 208
|
||||
#define sys_io_submit 209
|
||||
#define sys_io_cancel 210
|
||||
#define sys_get_thread_area 211
|
||||
#define sys_lookup_dcookie 212
|
||||
#define sys_epoll_create 213
|
||||
#define sys_epoll_ctl_old 214
|
||||
#define sys_epoll_wait_old 215
|
||||
#define sys_remap_file_pages 216
|
||||
#define sys_getdents64 217
|
||||
#define sys_set_tid_address 218
|
||||
#define sys_restart_syscall 219
|
||||
#define sys_semtimedop 220
|
||||
#define sys_fadvise64 221
|
||||
#define sys_timer_create 222
|
||||
#define sys_timer_settime 223
|
||||
#define sys_timer_gettime 224
|
||||
#define sys_timer_getoverrun 225
|
||||
#define sys_timer_delete 226
|
||||
#define sys_clock_settime 227
|
||||
#define sys_clock_gettime 228
|
||||
#define sys_clock_getres 229
|
||||
#define sys_clock_nanosleep 230
|
||||
#define sys_exit_group 231
|
||||
#define sys_epoll_wait 232
|
||||
#define sys_epoll_ctl 233
|
||||
#define sys_tgkill 234
|
||||
#define sys_utimes 235
|
||||
#define sys_vserver 236
|
||||
#define sys_mbind 237
|
||||
#define sys_set_mempolicy 238
|
||||
#define sys_get_mempolicy 239
|
||||
#define sys_mq_open 240
|
||||
#define sys_mq_unlink 241
|
||||
#define sys_mq_timedsend 242
|
||||
#define sys_mq_timedreceive 243
|
||||
#define sys_mq_notify 244
|
||||
#define sys_mq_getsetattr 245
|
||||
#define sys_kexec_load 246
|
||||
#define sys_waitid 247
|
||||
#define sys_add_key 248
|
||||
#define sys_request_key 249
|
||||
#define sys_keyctl 250
|
||||
#define sys_ioprio_set 251
|
||||
#define sys_ioprio_get 252
|
||||
#define sys_inotify_init 253
|
||||
#define sys_inotify_add_watch 254
|
||||
#define sys_inotify_rm_watch 255
|
||||
#define sys_migrate_pages 256
|
||||
#define sys_openat 257
|
||||
#define sys_mkdirat 258
|
||||
#define sys_mknodat 259
|
||||
#define sys_fchownat 260
|
||||
#define sys_futimesat 261
|
||||
#define sys_newfstatat 262
|
||||
#define sys_unlinkat 263
|
||||
#define sys_renameat 264
|
||||
#define sys_linkat 265
|
||||
#define sys_symlinkat 266
|
||||
#define sys_readlinkat 267
|
||||
#define sys_fchmodat 268
|
||||
#define sys_faccessat 269
|
||||
#define sys_pselect6 270
|
||||
#define sys_ppoll 271
|
||||
#define sys_unshare 272
|
||||
#define sys_set_robust_list 273
|
||||
#define sys_get_robust_list 274
|
||||
#define sys_splice 275
|
||||
#define sys_tee 276
|
||||
#define sys_sync_file_range 277
|
||||
#define sys_vmsplice 278
|
||||
#define sys_move_pages 279
|
||||
#define sys_utimensat 280
|
||||
#define sys_epoll_pwait 281
|
||||
#define sys_signalfd 282
|
||||
#define sys_timerfd_create 283
|
||||
#define sys_eventfd 284
|
||||
#define sys_fallocate 285
|
||||
#define sys_timerfd_settime 286
|
||||
#define sys_timerfd_gettime 287
|
||||
#define sys_accept4 288
|
||||
#define sys_signalfd4 289
|
||||
#define sys_eventfd2 290
|
||||
#define sys_epoll_create1 291
|
||||
#define sys_dup3 292
|
||||
#define sys_pipe2 293
|
||||
#define sys_inotify_init1 294
|
||||
#define sys_preadv 295
|
||||
#define sys_pwritev 296
|
||||
#define sys_rt_tgsigqueueinfo 297
|
||||
#define sys_perf_event_open 298
|
||||
#define sys_recvmmsg 299
|
||||
#define sys_fanotify_init 300
|
||||
#define sys_fanotify_mark 301
|
||||
#define sys_prlimit64 302
|
||||
#define sys_name_to_handle_at 303
|
||||
#define sys_open_by_handle_at 304
|
||||
#define sys_clock_adjtime 305
|
||||
#define sys_syncfs 306
|
||||
#define sys_sendmmsg 307
|
||||
#define sys_setns 308
|
||||
#define sys_getcpu 309
|
||||
#define sys_process_vm_readv 310
|
||||
#define sys_process_vm_writev 311
|
||||
#define sys_kcmp 312
|
||||
#define sys_finit_module 313
|
||||
#define sys_sched_setattr 314
|
||||
#define sys_sched_getattr 315
|
||||
#define sys_renameat2 316
|
||||
#define sys_seccomp 317
|
||||
#define sys_getrandom 318
|
||||
#define sys_memfd_create 319
|
||||
#define sys_kexec_file_load 320
|
||||
#define sys_bpf 321
|
||||
#define sys_execveat 322
|
||||
#define sys_userfaultfd 323
|
||||
#define sys_membarrier 324
|
||||
#define sys_mlock2 325
|
||||
#define sys_copy_file_range 326
|
||||
#define sys_preadv2 327
|
||||
#define sys_pwritev2 328
|
||||
#define sys_pkey_mprotect 329
|
||||
#define sys_pkey_alloc 330
|
||||
#define sys_pkey_free 331
|
||||
#define sys_statx 332
|
||||
#define sys_io_pgetevents 333
|
||||
#define sys_rseq 334
|
||||
#define sys_pidfd_send_signal 424
|
||||
#define sys_io_uring_setup 425
|
||||
#define sys_io_uring_enter 426
|
||||
#define sys_io_uring_register 427
|
||||
#define sys_open_tree 428
|
||||
#define sys_move_mount 429
|
||||
#define sys_fsopen 430
|
||||
#define sys_fsconfig 431
|
||||
#define sys_fsmount 432
|
||||
#define sys_fspick 433
|
||||
#define sys_pidfd_open 434
|
||||
#define sys_clone3 435
|
||||
#define sys_close_range 436
|
||||
#define sys_openat2 437
|
||||
#define sys_pidfd_getfd 438
|
||||
#define sys_faccessat2 439
|
||||
#define sys_process_madvise 440
|
||||
#define sys_epoll_pwait2 441
|
||||
#define sys_mount_setattr 442
|
||||
#define sys_quotactl_fd 443
|
||||
#define sys_landlock_create_ruleset 444
|
||||
#define sys_landlock_add_rule 445
|
||||
#define sys_landlock_restrict_self 446
|
||||
#define sys_memfd_secret 447
|
||||
#define sys_process_mrelease 448
|
||||
|
||||
struct kutsname
|
||||
{
|
||||
char sysname[65];
|
||||
char nodename[65];
|
||||
char release[65];
|
||||
char version[65];
|
||||
char machine[65];
|
||||
char domainname[65];
|
||||
};
|
||||
|
||||
#endif // _BITS_SYSCALLS_H
|
@ -287,6 +287,10 @@ typedef long double double_t;
|
||||
double y1(double x);
|
||||
double yn(int n, double x);
|
||||
|
||||
void sincos(double x, double *s, double *c);
|
||||
void sincosf(float x, float *s, float *c);
|
||||
void sincosl(long double x, long double *s, long double *c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
@ -42,14 +42,14 @@ extern "C"
|
||||
blkcnt_t st_blocks; /* Number of blocks allocated for this object. */
|
||||
};
|
||||
|
||||
#define S_IFMT
|
||||
#define S_IFBLK
|
||||
#define S_IFCHR
|
||||
#define S_IFIFO
|
||||
#define S_IFREG
|
||||
#define S_IFDIR
|
||||
#define S_IFLNK
|
||||
#define S_IFSOCK
|
||||
#define S_IFMT 0170000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFIFO 0010000
|
||||
#define S_IFREG 0100000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFSOCK 0140000
|
||||
|
||||
#define S_IRWXU 0700
|
||||
#define S_IRUSR 0400
|
||||
@ -68,21 +68,21 @@ extern "C"
|
||||
#define S_ISGID 02000
|
||||
#define S_ISVTX 01000
|
||||
|
||||
#define S_ISBLK(m)
|
||||
#define S_ISCHR(m)
|
||||
#define S_ISDIR(m)
|
||||
#define S_ISFIFO(m)
|
||||
#define S_ISREG(m)
|
||||
#define S_ISLNK(m)
|
||||
#define S_ISSOCK(m)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
|
||||
#define S_TYPEISMQ(buf)
|
||||
#define S_TYPEISSEM(buf)
|
||||
#define S_TYPEISSHM(buf)
|
||||
#define S_TYPEISTMO(buf)
|
||||
#define S_TYPEISMQ(buf) 0
|
||||
#define S_TYPEISSEM(buf) 0
|
||||
#define S_TYPEISSHM(buf) 0
|
||||
#define S_TYPEISTMO(buf) 0
|
||||
|
||||
#define UTIME_NOW
|
||||
#define UTIME_OMIT
|
||||
#define UTIME_NOW 0x3fffffff
|
||||
#define UTIME_OMIT 0x3ffffffe
|
||||
|
||||
int chmod(const char *, mode_t);
|
||||
int fchmod(int, mode_t);
|
||||
|
@ -1,18 +1,18 @@
|
||||
/*
|
||||
This file is part of Fennix Userspace.
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix Userspace is free software: you can redistribute it and/or
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix Userspace is distributed in the hope that it will be useful,
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix Userspace. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
typedef void (*fct)(void);
|
||||
@ -39,7 +39,6 @@ void __crt_fini_array(void)
|
||||
|
||||
__attribute__((naked, used, no_stack_protector, section(".text"))) void _start()
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asm("xor %rbp, %rbp\n"
|
||||
"andq $-16, %rsp\n"
|
||||
"movq %rsp, %rbp\n"
|
||||
@ -67,15 +66,6 @@ __attribute__((naked, used, no_stack_protector, section(".text"))) void _start()
|
||||
|
||||
"movl %eax, %edi\n"
|
||||
"call _exit\n");
|
||||
#elif defined(__i386__)
|
||||
#warning "i386 _start not implemented"
|
||||
#elif defined(__arm__)
|
||||
#warning "arm _start not implemented"
|
||||
#elif defined(__aarch64__)
|
||||
#warning "aarch64 _start not implemented"
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
}
|
||||
|
||||
/* These are declared in GNU ld */
|
||||
|
1
Userspace/libc/runtime/linux/x86_64/Scrt1.c
Normal file
1
Userspace/libc/runtime/linux/x86_64/Scrt1.c
Normal file
@ -0,0 +1 @@
|
||||
#include "crt1.c"
|
101
Userspace/libc/runtime/linux/x86_64/crt1.c
Normal file
101
Userspace/libc/runtime/linux/x86_64/crt1.c
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
typedef void (*fct)(void);
|
||||
#define asm __asm__ __volatile__
|
||||
|
||||
extern void (*__preinit_array_start[])(void) __attribute__((weak));
|
||||
extern void (*__preinit_array_end[])(void) __attribute__((weak));
|
||||
extern void (*__init_array_start[])(void) __attribute__((weak));
|
||||
extern void (*__init_array_end[])(void) __attribute__((weak));
|
||||
extern void (*__fini_array_start[])(void) __attribute__((weak));
|
||||
extern void (*__fini_array_end[])(void) __attribute__((weak));
|
||||
|
||||
void __crt_init_array(void)
|
||||
{
|
||||
for (fct *func = __init_array_start; func != __init_array_end; func++)
|
||||
(*func)();
|
||||
}
|
||||
|
||||
void __crt_fini_array(void)
|
||||
{
|
||||
for (fct *func = __fini_array_start; func != __fini_array_end; func++)
|
||||
(*func)();
|
||||
}
|
||||
|
||||
__attribute__((naked, used, no_stack_protector, section(".text"))) void _start()
|
||||
{
|
||||
asm("xor %rbp, %rbp\n"
|
||||
"andq $-16, %rsp\n"
|
||||
"movq %rsp, %rbp\n"
|
||||
|
||||
"movq %rdx, %rax\n"
|
||||
"pushq %rcx\n"
|
||||
"pushq %rdx\n"
|
||||
"pushq %rsi\n"
|
||||
"pushq %rdi\n"
|
||||
"movq %rax, %rdi\n"
|
||||
|
||||
"call __libc_init\n"
|
||||
"call __crt_init_array\n"
|
||||
|
||||
"popq %rdi\n"
|
||||
"popq %rsi\n"
|
||||
"popq %rdx\n"
|
||||
"popq %rcx\n"
|
||||
|
||||
"call main\n"
|
||||
|
||||
"pushq %rax\n"
|
||||
"call __crt_fini_array\n"
|
||||
"popq %rax\n"
|
||||
|
||||
"movl %eax, %edi\n"
|
||||
"call _exit\n");
|
||||
}
|
||||
|
||||
/* These are declared in GNU ld */
|
||||
enum
|
||||
{
|
||||
NT_FNX_ABI_TAG = 1,
|
||||
NT_FNX_VERSION = 2,
|
||||
NT_FNX_BUILD_ID = 3,
|
||||
NT_FNX_ARCH = 4
|
||||
};
|
||||
|
||||
typedef struct Elf_Nhdr
|
||||
{
|
||||
__UINT32_TYPE__ n_namesz;
|
||||
__UINT32_TYPE__ n_descsz;
|
||||
__UINT32_TYPE__ n_type;
|
||||
char n_name[];
|
||||
} __attribute__((packed)) Elf_Nhdr;
|
||||
|
||||
const struct
|
||||
{
|
||||
Elf_Nhdr header;
|
||||
char name[4];
|
||||
__UINT32_TYPE__ desc[4];
|
||||
} __abi_tag __attribute__((aligned(4), section(".note.ABI-tag"))) = {
|
||||
.header = {
|
||||
.n_namesz = 4, /* "FNX" + '\0' */
|
||||
.n_descsz = sizeof(__UINT32_TYPE__) * 4, /* Description Size */
|
||||
.n_type = NT_FNX_ABI_TAG, /* Type */
|
||||
},
|
||||
.name = "FNX",
|
||||
.desc = {0, 0, 0, 0},
|
||||
};
|
@ -166,8 +166,10 @@ export char *strerror(int errnum)
|
||||
return (char *)"State not recoverable";
|
||||
case ENOTSOCK:
|
||||
return (char *)"Not a socket";
|
||||
#if ENOTSUP != EOPNOTSUPP
|
||||
case ENOTSUP:
|
||||
return (char *)"Not supported";
|
||||
#endif
|
||||
case ENOTTY:
|
||||
return (char *)"Inappropriate I/O control operation";
|
||||
case ENXIO:
|
||||
|
@ -1700,3 +1700,21 @@ export double yn(int n, double x)
|
||||
}
|
||||
return by;
|
||||
}
|
||||
|
||||
void sincos(double x, double *s, double *c)
|
||||
{
|
||||
*s = sin(x);
|
||||
*c = cos(x);
|
||||
}
|
||||
|
||||
void sincosf(float x, float *s, float *c)
|
||||
{
|
||||
*s = sinf(x);
|
||||
*c = cosf(x);
|
||||
}
|
||||
|
||||
void sincosl(long double x, long double *s, long double *c)
|
||||
{
|
||||
*s = sinl(x);
|
||||
*c = cosl(x);
|
||||
}
|
||||
|
@ -65,6 +65,14 @@ export int sigaction(int sig, const struct sigaction *restrict act, struct sigac
|
||||
|
||||
export int sigaddset(sigset_t *set, int signo)
|
||||
{
|
||||
#ifndef SIGNAL_MAX
|
||||
#ifdef NSIG
|
||||
#define SIGNAL_MAX NSIG
|
||||
#else
|
||||
#error "NSIG is not defined"
|
||||
#endif // NSIG
|
||||
#endif // SIGNAL_MAX
|
||||
|
||||
if (set == NULL || signo <= 0 || signo >= SIGNAL_MAX)
|
||||
{
|
||||
errno = EINVAL;
|
||||
|
@ -563,8 +563,10 @@ export char *strsignal(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
#ifdef SIGNULL
|
||||
case SIGNULL:
|
||||
return "NULL signal";
|
||||
#endif
|
||||
case SIGABRT:
|
||||
return "Aborted";
|
||||
case SIGALRM:
|
||||
|
48
Userspace/libc/sysdeps/linux/x86_64/dl_start.c
Normal file
48
Userspace/libc/sysdeps/linux/x86_64/dl_start.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef FENNIX_DYNAMIC_LOADER
|
||||
__attribute__((naked, used, no_stack_protector)) void _dl_start()
|
||||
{
|
||||
__asm__(
|
||||
"xorq %rbp, %rbp\n" /* Clear rbp */
|
||||
|
||||
"push %rdi\n"
|
||||
"push %rsi\n"
|
||||
"push %rdx\n"
|
||||
"push %rcx\n"
|
||||
"push %r8\n"
|
||||
"push %r9\n"
|
||||
|
||||
"call __init_print_buffer\n" /* Call __init_print_buffer */
|
||||
"call _dl_preload\n" /* Call _dl_preload */
|
||||
"movl %eax, %edi\n" /* Move return value to edi */
|
||||
"cmp $0, %edi\n" /* Check if return value is 0 */
|
||||
"jne _exit\n" /* If not, jump to _exit */
|
||||
|
||||
"pop %r9\n"
|
||||
"pop %r8\n"
|
||||
"pop %rcx\n"
|
||||
"pop %rdx\n"
|
||||
"pop %rsi\n"
|
||||
"pop %rdi\n"
|
||||
|
||||
"call main\n" /* Call _dl_main */
|
||||
"movl %eax, %edi\n" /* Move return value to edi */
|
||||
"call _exit\n"); /* Call _exit */
|
||||
}
|
||||
#endif
|
22
Userspace/libc/sysdeps/linux/x86_64/stack_chk.c
Normal file
22
Userspace/libc/sysdeps/linux/x86_64/stack_chk.c
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
__attribute__((noreturn)) __attribute__((no_stack_protector)) __attribute__((weak)) void __stack_chk_fail(void)
|
||||
{
|
||||
_exit(0xbeef);
|
||||
__builtin_unreachable();
|
||||
}
|
24
Userspace/libc/sysdeps/linux/x86_64/syscall_check.cpp
Normal file
24
Userspace/libc/sysdeps/linux/x86_64/syscall_check.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <bits/syscalls.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
// static_assert( == );
|
193
Userspace/libc/sysdeps/linux/x86_64/syscalls.c
Normal file
193
Userspace/libc/sysdeps/linux/x86_64/syscalls.c
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <bits/syscalls.h>
|
||||
#include <bits/libc.h>
|
||||
#include <string.h>
|
||||
|
||||
void sysdep(Exit)(int Status)
|
||||
{
|
||||
syscall1(sys_exit, Status);
|
||||
}
|
||||
|
||||
int sysdep(Accept)(int Socket, struct sockaddr *restrict Address, socklen_t *restrict AddressLength)
|
||||
{
|
||||
return syscall3(sys_accept, Socket, Address, AddressLength);
|
||||
}
|
||||
|
||||
int sysdep(Bind)(int Socket, const struct sockaddr *Address, socklen_t AddressLength)
|
||||
{
|
||||
return syscall3(sys_bind, Socket, Address, AddressLength);
|
||||
}
|
||||
|
||||
int sysdep(Connect)(int Socket, const struct sockaddr *Address, socklen_t AddressLength)
|
||||
{
|
||||
return syscall3(sys_connect, Socket, Address, AddressLength);
|
||||
}
|
||||
|
||||
int sysdep(Listen)(int Socket, int Backlog)
|
||||
{
|
||||
return syscall2(sys_listen, Socket, Backlog);
|
||||
}
|
||||
|
||||
int sysdep(Socket)(int Domain, int Type, int Protocol)
|
||||
{
|
||||
return syscall3(sys_socket, Domain, Type, Protocol);
|
||||
}
|
||||
|
||||
int sysdep(UnixName)(struct utsname *Name)
|
||||
{
|
||||
struct kutsname kname;
|
||||
int result = syscall1(sys_uname, &kname);
|
||||
if (result == 0)
|
||||
{
|
||||
strcpy(Name->sysname, kname.sysname);
|
||||
strcpy(Name->release, kname.release);
|
||||
strcpy(Name->version, kname.version);
|
||||
strcpy(Name->machine, kname.machine);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int sysdep(WaitProcessID)(pid_t ProcessID, int *Status, int Options)
|
||||
{
|
||||
return syscall3(sys_wait4, ProcessID, (scarg)Status, Options);
|
||||
}
|
||||
|
||||
int sysdep(IOControl)(int Descriptor, unsigned long Operation, void *Argument)
|
||||
{
|
||||
return syscall3(sys_ioctl, Descriptor, Operation, (scarg)Argument);
|
||||
}
|
||||
|
||||
void *sysdep(MemoryMap)(void *Address, size_t Length, int Protection, int Flags, int Descriptor, off_t Offset)
|
||||
{
|
||||
return syscall6(sys_mmap, (scarg)Address, Length, Protection, Flags, Descriptor, Offset);
|
||||
}
|
||||
|
||||
int sysdep(MemoryUnmap)(void *Address, size_t Length)
|
||||
{
|
||||
return syscall2(sys_munmap, (scarg)Address, Length);
|
||||
}
|
||||
|
||||
int sysdep(MemoryProtect)(void *Address, size_t Length, int Protection)
|
||||
{
|
||||
return syscall3(sys_mprotect, (scarg)Address, Length, Protection);
|
||||
}
|
||||
|
||||
int sysdep(Fork)(void)
|
||||
{
|
||||
return syscall0(sys_fork);
|
||||
}
|
||||
|
||||
int sysdep(Read)(int Descriptor, void *Buffer, size_t Size)
|
||||
{
|
||||
return syscall3(sys_read, Descriptor, (scarg)Buffer, Size);
|
||||
}
|
||||
|
||||
int sysdep(Write)(int Descriptor, const void *Buffer, size_t Size)
|
||||
{
|
||||
return syscall3(sys_write, Descriptor, (scarg)Buffer, Size);
|
||||
}
|
||||
|
||||
int sysdep(PRead)(int Descriptor, void *Buffer, size_t Size, off_t Offset)
|
||||
{
|
||||
return syscall4(sys_pread64, Descriptor, (scarg)Buffer, Size, Offset);
|
||||
}
|
||||
|
||||
int sysdep(PWrite)(int Descriptor, const void *Buffer, size_t Size, off_t Offset)
|
||||
{
|
||||
return syscall4(sys_pwrite64, Descriptor, (scarg)Buffer, Size, Offset);
|
||||
}
|
||||
|
||||
int sysdep(Open)(const char *Pathname, int Flags, mode_t Mode)
|
||||
{
|
||||
return syscall3(sys_open, (scarg)Pathname, Flags, Mode);
|
||||
}
|
||||
|
||||
int sysdep(Close)(int Descriptor)
|
||||
{
|
||||
return syscall1(sys_close, Descriptor);
|
||||
}
|
||||
|
||||
int sysdep(Access)(const char *Pathname, int Mode)
|
||||
{
|
||||
return syscall2(sys_access, (scarg)Pathname, Mode);
|
||||
}
|
||||
|
||||
int sysdep(Tell)(int Descriptor)
|
||||
{
|
||||
#undef SEEK_CUR
|
||||
#define SEEK_CUR 1
|
||||
return syscall3(sys_lseek, Descriptor, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
int sysdep(Seek)(int Descriptor, off_t Offset, int Whence)
|
||||
{
|
||||
return syscall3(sys_lseek, Descriptor, Offset, Whence);
|
||||
}
|
||||
|
||||
pid_t sysdep(GetProcessID)(void)
|
||||
{
|
||||
return syscall0(sys_getpid);
|
||||
}
|
||||
|
||||
pid_t sysdep(GetParentProcessID)(void)
|
||||
{
|
||||
return syscall0(sys_getppid);
|
||||
}
|
||||
|
||||
int sysdep(Execve)(const char *Pathname, char *const *Argv, char *const *Envp)
|
||||
{
|
||||
return syscall3(sys_execve, (scarg)Pathname, (scarg)Argv, (scarg)Envp);
|
||||
}
|
||||
|
||||
int sysdep(Kill)(pid_t ProcessID, int Signal)
|
||||
{
|
||||
return syscall2(sys_kill, ProcessID, Signal);
|
||||
}
|
||||
|
||||
int sysdep(Stat)(const char *Pathname, struct stat *Statbuf)
|
||||
{
|
||||
return syscall2(sys_stat, (scarg)Pathname, (scarg)Statbuf);
|
||||
}
|
||||
|
||||
int sysdep(FStat)(int Descriptor, struct stat *Statbuf)
|
||||
{
|
||||
return syscall2(sys_fstat, Descriptor, (scarg)Statbuf);
|
||||
}
|
||||
|
||||
int sysdep(LStat)(const char *Pathname, struct stat *Statbuf)
|
||||
{
|
||||
return syscall2(sys_lstat, (scarg)Pathname, (scarg)Statbuf);
|
||||
}
|
||||
|
||||
int sysdep(Truncate)(const char *Pathname, off_t Length)
|
||||
{
|
||||
return syscall2(sys_truncate, (scarg)Pathname, Length);
|
||||
}
|
||||
|
||||
int sysdep(MakeDirectory)(const char *Pathname, mode_t Mode)
|
||||
{
|
||||
return syscall2(sys_mkdir, (scarg)Pathname, Mode);
|
||||
}
|
||||
|
||||
int sysdep(ProcessControl)(unsigned long Option, unsigned long Arg1, unsigned long Arg2, unsigned long Arg3, unsigned long Arg4)
|
||||
{
|
||||
return syscall5(sys_prctl, Option, Arg1, Arg2, Arg3, Arg4);
|
||||
}
|
46
Userspace/libc/sysdeps/linux/x86_64/tls.c
Normal file
46
Userspace/libc/sysdeps/linux/x86_64/tls.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library 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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <bits/syscalls.h>
|
||||
#include <bits/libc.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <inttypes.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef FENNIX_DYNAMIC_LOADER
|
||||
export __attribute__((naked, used, no_stack_protector)) void *__tls_get_addr(void *__data)
|
||||
{
|
||||
#warning "__tls_get_addr not implemented"
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
__asm__("ud2");
|
||||
#endif
|
||||
}
|
||||
|
||||
int __init_pthread(void)
|
||||
{
|
||||
__pthread *ptr = (__pthread *)syscall6(sys_mmap, 0,
|
||||
0x1000,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE,
|
||||
-1, 0);
|
||||
syscall2(sys_prctl, 0x1002, ptr);
|
||||
ptr->Self = ptr;
|
||||
ptr->CurrentError = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user