Compare commits

..

3 Commits

Author SHA1 Message Date
5aa667c776
luna: Make OwnedStringView::clone() just call from_string_literal()
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-10 19:03:00 +01:00
3ac3d54788
luna: Make check() and expect() output errors in userspace 2023-01-10 19:02:16 +01:00
c82ed5df01
Enable -Os on all targets 2023-01-10 18:13:21 +01:00
5 changed files with 14 additions and 11 deletions

View File

@ -1,5 +1,6 @@
function(luna_app SOURCE_FILE APP_NAME)
add_executable(${APP_NAME} ${SOURCE_FILE})
target_compile_options(${APP_NAME} PRIVATE -Os -Wall -Wextra -pedantic -Werror)
add_dependencies(${APP_NAME} libc)
target_include_directories(${APP_NAME} PRIVATE ${LUNA_BASE}/usr/include)
install(TARGETS ${APP_NAME} DESTINATION ${LUNA_ROOT}/initrd/bin)

View File

@ -31,7 +31,8 @@ target_link_libraries(bare_libc PUBLIC luna)
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)

View File

@ -25,7 +25,7 @@ set(SOURCES
add_library(luna-freestanding ${FREESTANDING_SOURCES})
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 -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
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)
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 -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
target_compile_options(luna PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)

View File

@ -1,6 +1,11 @@
#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();
}

View File

@ -28,11 +28,7 @@ OwnedStringView::~OwnedStringView()
Result<OwnedStringView> OwnedStringView::clone() const
{
char* const c_str = strdup(m_string);
if (!c_str) return err(ENOMEM);
return OwnedStringView { c_str };
return from_string_literal(m_string);
}
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)
{
char* dup = strdup(str);
char* const dup = strdup(str);
if (!dup) return err(ENOMEM);
return OwnedStringView { dup };
}