Compare commits
3 Commits
feaf9ed19b
...
5aa667c776
Author | SHA1 | Date | |
---|---|---|---|
5aa667c776 | |||
3ac3d54788 | |||
c82ed5df01 |
@ -1,5 +1,6 @@
|
|||||||
function(luna_app SOURCE_FILE APP_NAME)
|
function(luna_app SOURCE_FILE APP_NAME)
|
||||||
add_executable(${APP_NAME} ${SOURCE_FILE})
|
add_executable(${APP_NAME} ${SOURCE_FILE})
|
||||||
|
target_compile_options(${APP_NAME} PRIVATE -Os -Wall -Wextra -pedantic -Werror)
|
||||||
add_dependencies(${APP_NAME} libc)
|
add_dependencies(${APP_NAME} libc)
|
||||||
target_include_directories(${APP_NAME} PRIVATE ${LUNA_BASE}/usr/include)
|
target_include_directories(${APP_NAME} PRIVATE ${LUNA_BASE}/usr/include)
|
||||||
install(TARGETS ${APP_NAME} DESTINATION ${LUNA_ROOT}/initrd/bin)
|
install(TARGETS ${APP_NAME} DESTINATION ${LUNA_ROOT}/initrd/bin)
|
||||||
|
@ -31,7 +31,8 @@ target_link_libraries(bare_libc PUBLIC luna)
|
|||||||
|
|
||||||
target_include_directories(bare_libc PUBLIC include/)
|
target_include_directories(bare_libc PUBLIC include/)
|
||||||
|
|
||||||
target_compile_options(bare_libc PRIVATE -Wall -Wextra -Werror -pedantic -nostdlib -fno-exceptions -fno-rtti)
|
target_compile_options(bare_libc PRIVATE -Os -Wall -Wextra -Werror -pedantic -nostdlib)
|
||||||
|
target_compile_options(bare_libc PRIVATE -fno-exceptions -fno-rtti)
|
||||||
|
|
||||||
target_link_options(bare_libc PRIVATE -nostdlib)
|
target_link_options(bare_libc PRIVATE -nostdlib)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ set(SOURCES
|
|||||||
|
|
||||||
add_library(luna-freestanding ${FREESTANDING_SOURCES})
|
add_library(luna-freestanding ${FREESTANDING_SOURCES})
|
||||||
target_compile_definitions(luna-freestanding PRIVATE USE_FREESTANDING)
|
target_compile_definitions(luna-freestanding PRIVATE USE_FREESTANDING)
|
||||||
target_compile_options(luna-freestanding PRIVATE -Wall -Wextra -Werror -Wvla)
|
target_compile_options(luna-freestanding PRIVATE -Os -Wall -Wextra -Werror -Wvla)
|
||||||
target_compile_options(luna-freestanding PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self -Wsign-conversion)
|
target_compile_options(luna-freestanding PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self -Wsign-conversion)
|
||||||
target_compile_options(luna-freestanding PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
target_compile_options(luna-freestanding PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
||||||
target_compile_options(luna-freestanding PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
target_compile_options(luna-freestanding PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
||||||
@ -37,7 +37,7 @@ target_include_directories(luna-freestanding PUBLIC include/)
|
|||||||
set_target_properties(luna-freestanding PROPERTIES CXX_STANDARD 20)
|
set_target_properties(luna-freestanding PROPERTIES CXX_STANDARD 20)
|
||||||
|
|
||||||
add_library(luna ${SOURCES})
|
add_library(luna ${SOURCES})
|
||||||
target_compile_options(luna PRIVATE -Wall -Wextra -Werror -Wvla)
|
target_compile_options(luna PRIVATE -Os -Wall -Wextra -Werror -Wvla)
|
||||||
target_compile_options(luna PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
|
target_compile_options(luna PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
|
||||||
target_compile_options(luna PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
target_compile_options(luna PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
|
||||||
target_compile_options(luna PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
target_compile_options(luna PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#include <luna/Attributes.h>
|
#include <luna/Attributes.h>
|
||||||
|
|
||||||
_weak [[noreturn]] bool __check_failed(const char*, const char*, const char*, const char*)
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
_weak [[noreturn]] bool __check_failed(const char* file, const char* line, const char* func, const char* expr)
|
||||||
{
|
{
|
||||||
__builtin_trap();
|
// FIXME: Output to standard error instead of standard output.
|
||||||
|
printf("Check failed at %s:%s in %s: %s\n", file, line, func, expr);
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,7 @@ OwnedStringView::~OwnedStringView()
|
|||||||
|
|
||||||
Result<OwnedStringView> OwnedStringView::clone() const
|
Result<OwnedStringView> OwnedStringView::clone() const
|
||||||
{
|
{
|
||||||
char* const c_str = strdup(m_string);
|
return from_string_literal(m_string);
|
||||||
|
|
||||||
if (!c_str) return err(ENOMEM);
|
|
||||||
|
|
||||||
return OwnedStringView { c_str };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char& OwnedStringView::operator[](usize index) const
|
const char& OwnedStringView::operator[](usize index) const
|
||||||
@ -43,7 +39,7 @@ const char& OwnedStringView::operator[](usize index) const
|
|||||||
|
|
||||||
Result<OwnedStringView> OwnedStringView::from_string_literal(const char* str)
|
Result<OwnedStringView> OwnedStringView::from_string_literal(const char* str)
|
||||||
{
|
{
|
||||||
char* dup = strdup(str);
|
char* const dup = strdup(str);
|
||||||
if (!dup) return err(ENOMEM);
|
if (!dup) return err(ENOMEM);
|
||||||
return OwnedStringView { dup };
|
return OwnedStringView { dup };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user