Skip to content

Commit

Permalink
remove some old stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
apache-hb committed Mar 28, 2024
1 parent 61af5b0 commit a9da704
Show file tree
Hide file tree
Showing 60 changed files with 170 additions and 908 deletions.
13 changes: 1 addition & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ endif

opt_paranoid = get_option('paranoid').disable_auto_if(is_release)
opt_analyze = get_option('analyze').disable_auto_if(meson.is_subproject())
win32_trickery = get_option('win32_trickery')
trace_time = get_option('trace_time').disable_auto_if(meson.is_subproject())

# disable stb_sprintf by default if we're a subproject, people may not
Expand All @@ -53,7 +52,6 @@ driver_tests = get_option('driver_tests').disable_auto_if(meson.is_subproject())
warning_level = get_option('warning_level').to_int()

trace_memory = get_option('trace_memory').disable_auto_if(is_release or meson.is_subproject())
events = get_option('events').disable_auto_if(is_release or meson.is_subproject())

# these are tools for internal use, so disable them in release mode
tool_notify = get_option('tool_notify').disable_auto_if(is_release or meson.is_subproject())
Expand All @@ -70,10 +68,7 @@ frontend_example = get_option('frontend_example').disable_auto_if(meson.is_subpr
lang_ctu = get_option('lang_ctu').disable_auto_if(meson.is_subproject())
lang_pl0 = get_option('lang_pl0').disable_auto_if(meson.is_subproject())
lang_oberon = get_option('lang_oberon').disable_auto_if(meson.is_subproject())
lang_jvm = get_option('lang_jvm').disable_auto_if(meson.is_subproject())
lang_example = get_option('lang_example').disable_auto_if(meson.is_subproject())
lang_c = get_option('lang_c').disable_auto_if(meson.is_subproject())
lang_cpp = get_option('lang_cpp').disable_auto_if(meson.is_subproject())

# all the codegen targets
target_cfamily = get_option('target_cfamily').disable_auto_if(meson.is_subproject())
Expand Down Expand Up @@ -114,7 +109,6 @@ config_cdata.set('CTU_PATCH', parts[2].to_int())
config_cdata.set10('CTU_DEBUG', is_debug)
config_cdata.set10('CTU_PARANOID', opt_paranoid.allowed())
config_cdata.set10('CTU_BUILD_SHARED', default_library == 'shared')
config_cdata.set10('CTU_WIN32_TRICKERY', win32_trickery.allowed())

# we use `__attribute__((const|pure))` heavily, but during unit tests we
# violate function preconditions to test assertions.
Expand All @@ -127,7 +121,6 @@ config_cdata.set10('CTU_HAS_PRETTY_FUNCTION', warning_level < 3)

config_cdata.set10('CTU_TRACE_MEMORY', trace_memory.allowed())
config_cdata.set10('CTU_STB_SPRINTF', opt_stb_sprintf.allowed())
config_cdata.set10('CTU_EVENTS', events.allowed())

# args for all code
all_args = cc.get_supported_arguments(
Expand Down Expand Up @@ -371,13 +364,12 @@ build_summary = {
'Paranoid asserts': opt_paranoid.allowed(),
'Flex': flex,
'Bison': bison,
'Win32 trickery': win32_trickery.allowed(),
'Compile time tracing': trace_time.enabled(),
'Module loader': default_library,
'Unit tests': unit_tests,
'Driver tests': driver_tests,
'Doxygen': doxygen,
'STB sprintf': opt_stb_sprintf
'STB sprintf': opt_stb_sprintf,
},
'Targets': {
'C Family': target_cfamily.allowed(),
Expand All @@ -391,12 +383,9 @@ build_summary = {
'Example': frontend_example.allowed()
},
'Languages': {
'C': lang_c.allowed(),
'C preprocessor': lang_cpp.allowed(),
'Cthulhu': lang_ctu.allowed(),
'PL/0': lang_pl0.allowed(),
'Oberon-2': lang_oberon.allowed(),
'JVM bytecode': lang_jvm.allowed(),
'Example': lang_example.allowed()
},
'Tools': {
Expand Down
25 changes: 0 additions & 25 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,11 @@ option('lang_oberon', type : 'feature',
value : 'auto'
)

option('lang_jvm', type : 'feature',
description : 'build the jvm language driver',
value : 'disabled'
)

option('lang_example', type : 'feature',
description : 'build the example language driver',
value : 'auto'
)

option('lang_c', type : 'feature',
description : 'build the c language driver, implies lang_cpp',
value : 'auto'
)

option('lang_cpp', type : 'feature',
description : 'build the c preprocessor',
value : 'auto'
)

# interfaces

option('frontend_cli', type : 'feature',
Expand Down Expand Up @@ -89,11 +74,6 @@ option('trace_memory', type : 'feature',
value : 'auto'
)

option('events', type : 'feature',
description : 'enable event callbacks',
value : 'auto'
)

option('paranoid', type : 'feature',
description : 'enable paranoid assertions',
value : 'auto'
Expand Down Expand Up @@ -130,11 +110,6 @@ option('analyze', type : 'feature',
value : 'disabled'
)

option('win32_trickery', type : 'feature',
description : 'enable some slightly hacky win32 handling to speed up builds',
value : 'disabled'
)

option('stb_sprintf', type : 'feature',
description : 'use stb_sprintf instead of the libc printf',
value : 'auto'
Expand Down
5 changes: 1 addition & 4 deletions src/common/arena/include/arena/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include <ctu_arena_api.h>
#include <ctu_config.h>

#include "core/analyze.h"
#include "core/compiler.h"
Expand All @@ -21,10 +22,6 @@ CT_BEGIN_API
/// @ingroup common
/// @{

#ifdef WITH_DOXYGEN
# define CTU_TRACE_MEMORY 1
#endif

/// @def CTU_TRACE_MEMORY
/// @brief a compile time flag to enable memory tracing
/// @note this is enabled by default in debug builds, see [The build guide](@ref building) for more information
Expand Down
7 changes: 0 additions & 7 deletions src/common/backtrace/src/dbghelp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

#include "core/macros.h"
#include "core/win32.h" // IWYU pragma: keep

#if CTU_WIN32_TRICKERY
# include <windef.h>
# include <winbase.h>
# include <verrsrc.h>
#endif

#include <dbghelp.h>

#define MAX_NAME_SIZE 512
Expand Down
6 changes: 1 addition & 5 deletions src/common/base/include/base/panic.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include <ctu_base_api.h>
#include <ctu_config.h>

#include "core/source_info.h"

Expand All @@ -14,11 +15,6 @@ CT_BEGIN_API
/// @ingroup base
/// @{

#ifdef WITH_DOXYGEN
# define CTU_DEBUG 1
# define CTU_PARANOID 1
#endif

/// @def CTU_DEBUG
/// @brief enable panic handling
/// @note this is only enabled in debug builds, see [The build guide](@ref building) for more
Expand Down
26 changes: 1 addition & 25 deletions src/common/core/include/core/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,6 @@
#undef STRICT
#undef VC_EXTRALEAN

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#define STRICT
#define VC_EXTRALEAN

#if CTU_WIN32_TRICKERY
// prevents other headers from detecting if windows.h has already been included
// and then undoing our work here. its on the user to include this header first
// and any transitive includes that their code may have
# define _INC_WINDOWS
// detect amd64, x86, or arm and define them ourselves
# if defined(_M_IX86)
# define _X86_
# elif defined(_M_AMD64)
# define _AMD64_
# elif defined(_M_ARM)
# define _ARM_
# elif defined(_M_ARM64)
# define _ARM64_
# else
# error "Unknown architecture, disable win32 trickery or add your arch here"
# endif
#else
# include <windows.h> // IWYU pragma: export
#endif
#include <windows.h> // IWYU pragma: export

/// @}
4 changes: 0 additions & 4 deletions src/common/endian/include/endian/endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

#if CT_OS_WINDOWS
# include "core/win32.h" // IWYU pragma: keep
# if CTU_WIN32_TRICKERY
# include <windef.h>
# include <winnt.h>
# endif
# define CT_BIG_ENDIAN REG_DWORD_BIG_ENDIAN
# define CT_LITTLE_ENDIAN REG_DWORD_LITTLE_ENDIAN
# define CT_BYTE_ORDER REG_DWORD
Expand Down
12 changes: 12 additions & 0 deletions src/common/fs/include/fs/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ typedef void (*fs_dirent_callback_t)(const char *path, const char *name, os_dire

CT_FS_API void fs_iter_dirents(fs_t *fs, const char *path, void *data, fs_dirent_callback_t callback);

CT_FS_API os_error_t fs_iter_begin(
IN_NOTNULL fs_t *fs,
IN_STRING const char *path,
OUT_NOTNULL fs_iter_t **iter);

CT_FS_API os_error_t fs_iter_end(
IN_NOTNULL fs_iter_t *iter);

CT_FS_API os_error_t fs_iter_next(
IN_NOTNULL fs_iter_t *iter,
OUT_NOTNULL fs_inode_t **inode);

/// @}

CT_END_API
9 changes: 4 additions & 5 deletions src/common/fs/src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,21 @@ bool inode_is(fs_inode_t *inode, os_dirent_t type)

// helpers

os_error_t mkdir_recursive(const char *path, bool *create, arena_t *arena)
os_error_t mkdir_recursive(const char *path, arena_t *arena)
{
CTASSERT(path != NULL);
CTASSERT(create != NULL);

size_t index = str_rfind(path, CT_NATIVE_PATH_SEPARATOR);
if (index != SIZE_MAX)
{
// create parent directory
char *parent = arena_strndup(path, index, arena);
os_error_t result = mkdir_recursive(parent, create, arena);
if (result != 0) { return result; }
os_error_t result = mkdir_recursive(parent, arena);
if (result != 0 && result != eOsExists) { return result; }
}

// create this directory
return os_dir_create(path, create);
return os_dir_create(path);
}

// fs api
Expand Down
2 changes: 1 addition & 1 deletion src/common/fs/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ CT_LOCAL void *inode_data(fs_inode_t *inode);
CT_LOCAL bool inode_is(fs_inode_t *inode, os_dirent_t type);

// helpers
CT_LOCAL os_error_t mkdir_recursive(const char *path, bool *success, arena_t *arena);
CT_LOCAL os_error_t mkdir_recursive(const char *path, arena_t *arena);

// fs api

Expand Down
27 changes: 27 additions & 0 deletions src/common/fs/src/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,30 @@ void fs_iter_dirents(fs_t *fs, const char *path, void *data, fs_dirent_callback_

iter_dirents(fs, query_inode(fs, fs->root, path), ".", path, data, callback);
}

USE_DECL
os_error_t fs_iter_begin(fs_t *fs, const char *path, fs_iter_t **iter)
{
CTASSERT(fs != NULL);
CTASSERT(path != NULL);
CTASSERT(iter != NULL);

return eOsSuccess;
}

USE_DECL
os_error_t fs_iter_end(fs_iter_t *iter)
{
CTASSERT(iter != NULL);

return eOsSuccess;
}

USE_DECL
os_error_t fs_iter_next(fs_iter_t *iter, fs_inode_t **inode)
{
CTASSERT(iter != NULL);
CTASSERT(inode != NULL);

return eOsSuccess;
}
13 changes: 4 additions & 9 deletions src/common/fs/src/physical.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ static inode_result_t pfs_file_create(fs_t *fs, fs_inode_t *self, const char *na
static inode_result_t pfs_dir_create(fs_t *fs, fs_inode_t *self, const char *name)
{
const char *absolute = get_absolute(fs, self, name);
bool create = false;
os_error_t err = mkdir_recursive(absolute, &create, fs->arena);
if (err != eOsSuccess)
os_error_t err = mkdir_recursive(absolute, fs->arena);
if (err != eOsSuccess && err != eOsExists)
{
inode_result_t result = { .error = err };
return result;
Expand Down Expand Up @@ -203,13 +202,9 @@ fs_t *fs_physical(const char *root, arena_t *arena)
bool exist = os_dir_exists(root);
if (exist)
{
bool create = false;
os_error_t err = mkdir_recursive(root, &create, arena);

// TODO: make this work recursively
CTASSERTF(err == 0, "error creating root directory: %s. %s", root, os_error_string(err, arena));
os_error_t err = mkdir_recursive(root, arena);

if (!create)
if (err != eOsSuccess && err != eOsExists)
{
return NULL;
}
Expand Down
26 changes: 3 additions & 23 deletions src/common/os/include/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ CT_OS_API os_error_t os_file_delete(IN_STRING const char *path);
/// @brief check if a directory exists
///
/// @param path the path to the directory to check
/// @param create true if the directory was created, false if it already existed
///
/// @return an error if the directory could not be checked
/// @retval eOsSuccess if the directory was created
/// @retval eOsExists if the directory already exists
RET_INSPECT
CT_OS_API os_error_t os_dir_create(IN_STRING const char *path, OUT_NOTNULL bool *create);
CT_OS_API os_error_t os_dir_create(IN_STRING const char *path);

/// @brief delete a directory
///
Expand Down Expand Up @@ -330,27 +331,6 @@ CT_OS_API bool os_mapping_active(INOUT_NOTNULL const os_mapping_t *mapping);
CT_NODISCARD
CT_OS_API const char *os_file_name(INOUT_NOTNULL const os_file_t *file);

#if CTU_EVENTS

typedef struct os_events_t
{
void (*on_file_open)(const os_file_t *file);
void (*on_file_close)(const os_file_t *file);
void (*on_file_read)(const os_file_t *file, size_t size);
void (*on_file_write)(const os_file_t *file, size_t size);

void (*on_library_open)(const os_library_t *library);
void (*on_library_close)(const os_library_t *library);
void (*on_library_symbol)(const os_library_t *library, const char *name, const os_symbol_t *symbol);

void (*on_mapping_open)(const os_file_t *file, const os_mapping_t *mapping);
void (*on_mapping_close)(const os_mapping_t *mapping);
} os_events_t;

CT_OS_API extern os_events_t gOsEvents;

#endif

/// @}

CT_END_API
Loading

0 comments on commit a9da704

Please sign in to comment.