Fixed linux compatibility
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
# project(photon C ASM-ATT)
|
||||
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(photon C ASM-ATT)
|
||||
endif ()
|
||||
|
||||
macro(subdirlist result curdir)
|
||||
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
||||
@@ -12,6 +14,7 @@ macro(subdirlist result curdir)
|
||||
set(${result} ${dirlist})
|
||||
endmacro()
|
||||
|
||||
include(Bundles)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/platform.cmake)
|
||||
platform_config(${PHOTON_TARGET})
|
||||
|
||||
@@ -42,7 +45,7 @@ file(GLOB photon_libc_crt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/machine/${machine}/crt*.s)
|
||||
|
||||
add_library(crt OBJECT ${photon_libc_crt})
|
||||
target_compile_options(crt PRIVATE -c -ffreestanding -nostdlib)
|
||||
# target_compile_options(crt PRIVATE -c -ffreestanding -nostdlib)
|
||||
|
||||
file(GLOB platform_sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/*.c
|
||||
|
||||
@@ -15,9 +15,16 @@ struct __io_file {
|
||||
};
|
||||
|
||||
extern int __fileno(struct __io_file *f);
|
||||
extern void __fio_init();
|
||||
extern unsigned int __fio_read(struct __io_file *f, char *buf, unsigned int sz);
|
||||
extern unsigned int __fio_write(struct __io_file *f, const char *buf, unsigned int sz);
|
||||
extern unsigned int __fio_flush(struct __io_file *f);
|
||||
extern int __fio_error(struct __io_file *f);
|
||||
extern int __fio_ungetc(struct __io_file *f, char c);
|
||||
|
||||
extern int __fio_fopen(const char *path, const char *mode, struct __io_file *out);
|
||||
extern int __fio_fclose(struct __io_file *in);
|
||||
extern int __fio_fdopen(int fd, const char *mode, struct __io_file *out);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -2,21 +2,14 @@
|
||||
#include "__syscall.h"
|
||||
#include "unistd.h"
|
||||
|
||||
struct __io_file __stdin = {};
|
||||
struct __io_file __stdout = {};
|
||||
struct __io_file __stderr = {};
|
||||
struct __io_file __stdin = { .fd = 0 };
|
||||
struct __io_file __stdout = { .fd = 1 };
|
||||
struct __io_file __stderr = { .fd = 2 };
|
||||
|
||||
struct __io_file *stdin = &__stdin;
|
||||
struct __io_file *stdout = &__stdout;
|
||||
struct __io_file *stderr = &__stderr;
|
||||
|
||||
void __fio_init()
|
||||
{
|
||||
__stdin.fd = 0;
|
||||
__stdout.fd = 1;
|
||||
__stderr.fd = 2;
|
||||
}
|
||||
|
||||
int __fileno(struct __io_file *f)
|
||||
{
|
||||
return f->fd;
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
.type main, @function
|
||||
|
||||
_start:
|
||||
pop %rbp
|
||||
pop %rdi
|
||||
mov %rsp, %rsi
|
||||
andq $-16, %rsp
|
||||
call __fio_init
|
||||
xor %ebp, %ebp
|
||||
mov (%rsp), %edi
|
||||
lea 8(%rsp), %rsi
|
||||
lea 16(%rsp, %rdi, 8), %rdx
|
||||
xor %eax, %eax
|
||||
|
||||
call main
|
||||
movq %rax, %rdi
|
||||
movq $60, %rax
|
||||
|
||||
39
photon/libc/sys/linux/sys/_errno.h
Normal file
39
photon/libc/sys/linux/sys/_errno.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef SYS_MAGENTA_SYS__ERRNO_H_
|
||||
#define SYS_MAGENTA_SYS__ERRNO_H_
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Argument list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user