Removed all the old Magenta-specific stuff
This commit is contained in:
@@ -76,22 +76,22 @@ file(GLOB platform_headers
|
||||
set(photon_libc_sources ${photon_libc_sources} ${malloc_sources} ${platform_sources})
|
||||
set(photon_libc_headers ${photon_libc_headers} ${platform_headers})
|
||||
|
||||
add_framework(Photon STATIC
|
||||
add_framework(photon STATIC
|
||||
BUNDLE_ID net.doorstuck.photon
|
||||
SOURCES ${photon_libc_sources} ${photon_libc_headers}
|
||||
HEADERS ${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include/*)
|
||||
|
||||
bundle_compile_options(Photon PRIVATE -ffreestanding -nostdlib -fPIC -fPIE)
|
||||
bundle_link_libraries(Photon ${photon_platform_libs})
|
||||
bundle_link_frameworks(Photon ${photon_platform_frameworks})
|
||||
bundle_compile_options(photon PRIVATE -ffreestanding -nostdlib -fPIC -fPIE)
|
||||
bundle_link_libraries(photon ${photon_platform_libs})
|
||||
bundle_link_frameworks(photon ${photon_platform_frameworks})
|
||||
|
||||
bundle_include_directories(Photon PRIVATE
|
||||
bundle_include_directories(photon PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include)
|
||||
|
||||
foreach (platform_include_dir ${photon_platform_extra_include_dirs})
|
||||
bundle_include_directories(Photon
|
||||
bundle_include_directories(photon
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/${platform_include_dir})
|
||||
endforeach (platform_include_dir)
|
||||
|
||||
@@ -102,20 +102,20 @@ add_custom_target(local-root
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${platform} ${machine})
|
||||
|
||||
bundle_add_dependencies(Photon local-root crt)
|
||||
bundle_add_dependencies(photon local-root crt)
|
||||
|
||||
add_custom_command(TARGET Photon POST_BUILD
|
||||
add_custom_command(TARGET photon POST_BUILD
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/add-framework-crt.sh
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Photon.framework
|
||||
${CMAKE_CURRENT_BINARY_DIR}/photon.framework
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
bundle_link_libraries(Photon gcc)
|
||||
bundle_link_libraries(photon gcc)
|
||||
endif ()
|
||||
|
||||
if (TARGET early-sysroot)
|
||||
# We are being built as part of asbestOS, make sure the sysroot is there.
|
||||
bundle_add_dependencies(Photon early-sysroot)
|
||||
bundle_add_dependencies(photon early-sysroot)
|
||||
endif ()
|
||||
|
||||
if (PHOTON_TESTS EQUAL 1)
|
||||
|
||||
@@ -29,11 +29,7 @@ extern FILE *stderr;
|
||||
|
||||
extern FILE *fopen(const char *path, const char *mode);
|
||||
extern FILE *freopen(const char *path, const char *mode, FILE *fp);
|
||||
#ifdef __magenta__
|
||||
extern FILE *fdopen(mx_handle_t fd, const char *mode);
|
||||
#else
|
||||
extern FILE *fdopen(int fd, const char *mode);
|
||||
#endif
|
||||
extern int fclose(FILE *fp);
|
||||
extern int fflush(FILE *fp);
|
||||
extern size_t fread(void *ptr, size_t size, size_t count, FILE *fp);
|
||||
|
||||
@@ -3,11 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <__fio.h>
|
||||
|
||||
#ifdef __magenta__
|
||||
FILE *fdopen(mx_handle_t fd, const char *mode)
|
||||
#else
|
||||
FILE *fdopen(int fd, const char *mode)
|
||||
#endif
|
||||
{
|
||||
struct __io_file *fp = malloc(sizeof(*fp));
|
||||
memset(fp, 0x0, sizeof(*fp));
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef SYS_MAGENTA___FIO_H_
|
||||
#define SYS_MAGENTA___FIO_H_
|
||||
|
||||
#include <magenta.h>
|
||||
|
||||
#define __FIO_BUFSZ 512
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -12,13 +10,13 @@ extern "C" {
|
||||
struct __io_file {
|
||||
char buf[__FIO_BUFSZ];
|
||||
unsigned long buf_idx;
|
||||
mx_handle_t handle;
|
||||
int fd;
|
||||
char err;
|
||||
char unget;
|
||||
};
|
||||
|
||||
extern int __fileno(struct __io_file *f);
|
||||
extern void __fio_init(mx_handle_t in, mx_handle_t out, mx_handle_t err);
|
||||
extern void __fio_init(int in, int out, int err);
|
||||
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);
|
||||
@@ -27,7 +25,7 @@ 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(mx_handle_t fd, const char *mode, struct __io_file *out);
|
||||
extern int __fio_fdopen(int fd, const char *mode, struct __io_file *out);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
#include "__init.h"
|
||||
|
||||
extern int __heap_init(struct __proc_start_info *info);
|
||||
extern int __heap_init();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,4 @@
|
||||
#ifndef SYS_MAGENTA_INIT_H_
|
||||
#define SYS_MAGENTA_INIT_H_
|
||||
|
||||
#include <magenta.h>
|
||||
|
||||
struct __proc_start_info {
|
||||
mx_handle_t in;
|
||||
mx_handle_t out;
|
||||
mx_handle_t err;
|
||||
int argc;
|
||||
const char **argv;
|
||||
mx_handle_t heap;
|
||||
void *heap_map_base;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(photon_platform_frameworks Magenta)
|
||||
set(photon_platform_frameworks magenta)
|
||||
|
||||
@@ -9,43 +9,16 @@ struct __io_file *stdin = &__stdin;
|
||||
struct __io_file *stdout = &__stdout;
|
||||
struct __io_file *stderr = &__stderr;
|
||||
|
||||
static mx_flags_t flags_from_mode(const char *r)
|
||||
static int flags_from_mode(const char *r)
|
||||
{
|
||||
mx_flags_t out = 0;
|
||||
|
||||
while (*r) {
|
||||
switch (*r) {
|
||||
case 'r':
|
||||
out |= MX_FILE_READ;
|
||||
break;
|
||||
case 'w':
|
||||
out |= MX_FILE_WRITE;
|
||||
break;
|
||||
case '+':
|
||||
out |= (MX_FILE_READ | MX_FILE_WRITE);
|
||||
break;
|
||||
case 'a':
|
||||
out |= MX_FILE_APPEND;
|
||||
break;
|
||||
case 'b':
|
||||
/* TODO */
|
||||
break;
|
||||
default:
|
||||
out = 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
r++;
|
||||
}
|
||||
|
||||
return out;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __fio_init(mx_handle_t in, mx_handle_t out, mx_handle_t err)
|
||||
void __fio_init(int in, int out, int err)
|
||||
{
|
||||
__stdin.handle = in;
|
||||
__stdout.handle = out;
|
||||
__stderr.handle = err;
|
||||
__stdin.fd = in;
|
||||
__stdout.fd = out;
|
||||
__stderr.fd = err;
|
||||
}
|
||||
|
||||
int __fio_fopen(const char *path, const char *mode, struct __io_file *fp)
|
||||
@@ -58,14 +31,14 @@ int __fio_fclose(struct __io_file *fp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int __fio_fdopen(mx_handle_t fd, const char *mode, struct __io_file *fp)
|
||||
int __fio_fdopen(int fd, const char *mode, struct __io_file *fp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int __fileno(struct __io_file *f)
|
||||
{
|
||||
return (int)f->handle;
|
||||
return (int)f->fd;
|
||||
}
|
||||
|
||||
unsigned int __fio_read(struct __io_file *f, char *buf, unsigned int sz)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <magenta.h>
|
||||
#include <magenta/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "__init.h"
|
||||
@@ -9,9 +9,9 @@
|
||||
static uintptr_t heap_start = 0;
|
||||
static uintptr_t heap_end = 0;
|
||||
static size_t heap_sz = 0;
|
||||
static mx_handle_t heap_segment = MX_NULL_HANDLE;
|
||||
static mx_handle_t heap_vmo = MX_NULL_HANDLE;
|
||||
|
||||
int __heap_init(struct __proc_start_info *info)
|
||||
int __heap_init()
|
||||
{
|
||||
#if 0
|
||||
heap_start = (uintptr_t)info->heap_map_base;
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
|
||||
extern int main(int, const char **);
|
||||
|
||||
int __crt_init(struct __proc_start_info *info)
|
||||
/* TODO magenta/procargs.h protocol */
|
||||
int __crt_init(void *arg)
|
||||
{
|
||||
__fio_init(info->in, info->out, info->err);
|
||||
__heap_init(info);
|
||||
return main(info->argc, info->argv);
|
||||
return main(0, 0);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#ifndef SYS_LINUX_SYS__FCONST_H_
|
||||
#define SYS_LINUX_SYS__FCONST_H_
|
||||
|
||||
#include <magenta.h>
|
||||
|
||||
#define __FILENAME_MAX 1024
|
||||
|
||||
#define __SEEK_SET MX_SEEK_START
|
||||
#define __SEEK_CUR MX_SEEK_CURRENT
|
||||
#define __SEEK_END MX_SEEK_END
|
||||
#define __SEEK_SET 0
|
||||
#define __SEEK_CUR 1
|
||||
#define __SEEK_END 2
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user