diff options
| -rw-r--r-- | meson.build | 24 | ||||
| -rw-r--r-- | src/lisiblestd/assert.h | 8 | ||||
| -rw-r--r-- | src/lisiblestd/log.h | 14 | ||||
| -rw-r--r-- | src/lisiblestd/memory.c | 2 | ||||
| -rw-r--r-- | src/lisiblestd/string.c | 2 |
5 files changed, 42 insertions, 8 deletions
diff --git a/meson.build b/meson.build index 0202d9e..4c34b8b 100644 --- a/meson.build +++ b/meson.build @@ -8,8 +8,28 @@ if is_playdate_build playdate_sdk_path = get_option('playdate_sdk_path') playdate_sdk_incdir = playdate_sdk_path / 'C_API' playdate_sdk_dep = declare_dependency(include_directories: playdate_sdk_incdir) -lisiblestd_c_args += '-DLSTD_PLATFORM_PLAYDATE' -lisiblestd_c_args += '-DTARGET_EXTENSION' +lisiblestd_c_args += '-DLSTD_PLATFORM_PLAYDATE=1' +lisiblestd_c_args += [ + '-DTARGET_PLAYDATE=1', + '-DTARGET_EXTENSION=1', + '-mthumb', + '-mcpu=cortex-m7', + '-mfloat-abi=hard', + '-mfpu=fpv5-sp-d16', + '-D__FPU_USED=1', + '-falign-functions=16', + '-fomit-frame-pointer', + '-gdwarf-2', + '-fverbose-asm', + '-ffunction-sections', + '-fdata-sections', + '-mword-relocations', + '-fno-common', + '-fno-exceptions', + '-Wno-unknown-pragmas', + '-Wdouble-promotion', + '-O2', +] lisiblestd_deps += playdate_sdk_dep endif diff --git a/src/lisiblestd/assert.h b/src/lisiblestd/assert.h index 15026f9..2babb6d 100644 --- a/src/lisiblestd/assert.h +++ b/src/lisiblestd/assert.h @@ -5,21 +5,19 @@ extern void exit(int); - - #ifdef LSTD_PLATFORM_PLAYDATE #include <pd_api.h> -extern PlaydateAPI* pd; +extern PlaydateAPI *pd; #define LSTD_ASSERT(expr) \ do { \ if (!(expr)) { \ - pd->system->error("Assertion failed:\n\t%s", #expr); \ + pd->system->error("Assertion failed: %s", #expr); \ } \ } while (0) #define LSTD_UNIMPLEMENTED() \ do { \ - pd->system->error("Unimpemented code reached"); \ + pd->system->error("Unimpemented code reached"); \ } while (0) #else #define LSTD_ASSERT(expr) \ diff --git a/src/lisiblestd/log.h b/src/lisiblestd/log.h index f4b4d6f..1cc4dc5 100644 --- a/src/lisiblestd/log.h +++ b/src/lisiblestd/log.h @@ -15,6 +15,19 @@ typedef enum { extern LogLevel lstd_log_level; +#ifdef LSTD_PLATFORM_PLAYDATE +#include <pd_api.h> +extern PlaydateAPI *pd; +#define LOG(log_level, ...) \ + do { \ + if (lstd_log_level <= log_level) { \ + pd->system->logToConsole(LSTD_LOG_PREFIX, log_level_to_str(log_level), \ + __FILE__, __LINE__); \ + pd->system->logToConsole(__VA_ARGS__); \ + pd->system->logToConsole("\n"); \ + } \ + } while (0) +#else #define LOG(log_level, ...) \ do { \ if (lstd_log_level <= log_level) { \ @@ -24,6 +37,7 @@ extern LogLevel lstd_log_level; fprintf(stderr, "\n"); \ } \ } while (0) +#endif #define LOG_TRACE(...) LOG(LogLevel_Trace, __VA_ARGS__) #define LOG_DEBUG(...) LOG(LogLevel_Debug, __VA_ARGS__) #define LOG_WARN(...) LOG(LogLevel_Warn, __VA_ARGS__) diff --git a/src/lisiblestd/memory.c b/src/lisiblestd/memory.c index 1f6b3c9..c8498f8 100644 --- a/src/lisiblestd/memory.c +++ b/src/lisiblestd/memory.c @@ -68,6 +68,7 @@ void *arena_allocator_allocate_aligned(usize alignment, usize size, void *ctx) { (void)alignment; (void)size; LSTD_UNIMPLEMENTED(); + return NULL; } void *arena_allocator_allocate_array(usize count, usize item_size, void *ctx) { LSTD_ASSERT(ctx != NULL); @@ -80,6 +81,7 @@ void *arena_allocator_reallocate(void *ptr, usize old_size, usize new_size, (void)new_size; (void)ctx; LSTD_UNIMPLEMENTED(); + return NULL; } void arena_allocator_free(void *ptr, void *ctx) { diff --git a/src/lisiblestd/string.c b/src/lisiblestd/string.c index 2b191b2..e7ef28c 100644 --- a/src/lisiblestd/string.c +++ b/src/lisiblestd/string.c @@ -12,7 +12,7 @@ String String_new(Allocator *allocator, const char *str) { char *value = Allocator_allocate(allocator, length + 1); LSTD_ASSERT(value != NULL); - strncpy(value, str, length); + strncpy(value, str, length + 1); value[length] = '\0'; return (String){.value = value, .length = length}; |
