place all options in options.c / options.h

added assert.h, log.h, math.h and string.h to core.h to reduce includes
This commit is contained in:
Anthony Pesch 2017-10-03 17:52:50 -04:00
parent 0b4ed0c3ab
commit b2f780dbe7
64 changed files with 103 additions and 104 deletions

View File

@ -245,7 +245,8 @@ set(RELIB_SOURCES
src/jit/jit.c
src/jit/pass_stats.c
src/render/gl_backend.c
src/imgui.cc)
src/imgui.cc
src/options.c)
if(PLATFORM_ANDROID)
list(APPEND RELIB_DEFS PLATFORM_ANDROID=1)

View File

@ -3,7 +3,10 @@
#include <stddef.h>
#include <stdint.h>
#include "core/assert.h"
#include "core/log.h"
#include "core/math.h"
#include "core/string.h"
#define ARRAY_SIZE(arr) (int)(sizeof(arr) / sizeof((arr)[0]))

View File

@ -1,5 +1,5 @@
#include "core/exception_handler.h"
#include "core/assert.h"
#include "core/core.h"
#include "core/list.h"
#define MAX_EXCEPTION_HANDLERS 32

View File

@ -1,6 +1,6 @@
#include <signal.h>
#include <stdlib.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/exception_handler.h"
static struct sigaction old_sigsegv;

View File

@ -1,7 +1,7 @@
#include <mach/mach.h>
#include <pthread.h>
#include "core/core.h"
#include "core/exception_handler.h"
#include "core/log.h"
/* POSIX signal handlers, for whatever reason, don't seem to be invoked for
segmentation faults on OSX when running the application under lldb / gdb.

View File

@ -1,7 +1,6 @@
#include <errno.h>
#include "core/filesystem.h"
#include "core/log.h"
#include "core/string.h"
#include "core/core.h"
static char appdir[PATH_MAX];

View File

@ -1,6 +1,6 @@
#include <stddef.h>
#include "core/interval_tree.h"
#include "core/math.h"
#include "core/core.h"
static int interval_tree_cmp(const struct rb_node *lhs,
const struct rb_node *rhs);

View File

@ -3,7 +3,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "core/option.h"
enum log_level {
LOG_LEVEL_INFO,

View File

@ -1,10 +1,9 @@
#include <stdlib.h>
#include "core/memory.h"
#include "core/assert.h"
#include "core/core.h"
#include "core/exception_handler.h"
#include "core/interval_tree.h"
#include "core/list.h"
#include "core/math.h"
#define MAX_WATCHES 8192

View File

@ -2,11 +2,10 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/filesystem.h"
#include "core/list.h"
#include "core/memory.h"
#include "core/string.h"
#if PLATFORM_ANDROID
#include <linux/ashmem.h>

View File

@ -1,9 +1,7 @@
#include <ini.h>
#include <stdlib.h>
#include "core/option.h"
#include "core/log.h"
#include "core/math.h"
#include "core/string.h"
#include "core/core.h"
static struct list s_options;

View File

@ -1,5 +1,5 @@
#ifndef OPTIONS_H
#define OPTIONS_H
#ifndef REDREAM_OPTION_H
#define REDREAM_OPTION_H
#include <string.h>
#include "core/constructor.h"

View File

@ -1,5 +1,5 @@
#include "core/profiler.h"
#include "core/assert.h"
#include "core/core.h"
#include "core/time.h"
#define PROFILER_MAX_COUNTERS 32

View File

@ -1,5 +1,5 @@
#include "core/rb_tree.h"
#include "core/assert.h"
#include "core/core.h"
#define VERIFY_TREE 0

View File

@ -1,10 +1,9 @@
/* would be nice to convert this file to C once MSVC supports stdatomic.h */
#include <atomic>
extern "C" {
#include "core/assert.h"
#include "core/core.h"
#include "core/memory.h"
#include "core/ringbuf.h"
#include "core/string.h"
}
/* single producer, single consumer ring buffer implementation */

View File

@ -2,7 +2,7 @@
#include <pthread.h>
#include <stdlib.h>
#include <time.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/thread.h"
static void thread_destroy(pthread_t *pthread) {

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <windows.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/thread.h"
struct thread_wrapper {

View File

@ -1,6 +1,6 @@
#include <mach/mach.h>
#include <mach/mach_time.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/time.h"
int64_t time_nanoseconds() {

View File

@ -1,5 +1,5 @@
#include <Windows.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/time.h"
int64_t time_nanoseconds() {

View File

@ -12,7 +12,6 @@
*/
#include "emulator.h"
#include "core/option.h"
#include "core/profiler.h"
#include "core/thread.h"
#include "core/time.h"
@ -32,13 +31,11 @@
#include "guest/sh4/sh4.h"
#include "host/host.h"
#include "imgui.h"
#include "options.h"
#include "render/render_backend.h"
DEFINE_AGGREGATE_COUNTER(frames);
DEFINE_PERSISTENT_OPTION_INT(debug, 1, "Show debug menu");
DEFINE_PERSISTENT_OPTION_STRING(aspect, "stretch", "Video aspect ratio");
enum {
ASPECT_RATIO_STRETCH,
ASPECT_RATIO_16BY9,

View File

@ -1,8 +1,7 @@
#include <limits.h>
#include "file/trace.h"
#include "core/assert.h"
#include "core/core.h"
#include "core/filesystem.h"
#include "core/math.h"
#include "guest/pvr/tr.h"
void trace_writer_close(struct trace_writer *writer) {

View File

@ -1,8 +1,6 @@
#include "guest/aica/aica.h"
#include "core/core.h"
#include "core/filesystem.h"
#include "core/log.h"
#include "core/math.h"
#include "core/option.h"
#include "core/profiler.h"
#include "guest/aica/aica_types.h"
#include "guest/arm7/arm7.h"

View File

@ -1,5 +1,5 @@
#include "guest/arm7/arm7.h"
#include "core/log.h"
#include "core/core.h"
#include "guest/aica/aica.h"
#include "guest/dreamcast.h"
#include "guest/scheduler.h"

View File

@ -1,6 +1,5 @@
#include "guest/bios/bios.h"
#include "core/math.h"
#include "core/option.h"
#include "core/core.h"
#include "core/time.h"
#include "guest/aica/aica.h"
#include "guest/bios/bios.h"
@ -11,10 +10,7 @@
#include "guest/rom/flash.h"
#include "guest/sh4/sh4.h"
#include "imgui.h"
DEFINE_PERSISTENT_OPTION_STRING(region, "usa", "System region");
DEFINE_PERSISTENT_OPTION_STRING(language, "english", "System language");
DEFINE_PERSISTENT_OPTION_STRING(broadcast, "ntsc", "System broadcast mode");
#include "options.h"
/* system settings */
static const char *regions[] = {

View File

@ -3,7 +3,7 @@
*/
#include "guest/bios/flash.h"
#include "core/math.h"
#include "core/core.h"
#include "guest/rom/flash.h"
#define FLASH_BLOCK_SIZE 0x40

View File

@ -4,7 +4,7 @@
#include "gdb/gdb_server.h"
#endif
#include "core/log.h"
#include "core/core.h"
#include "guest/debugger.h"
#include "guest/dreamcast.h"

View File

@ -1,6 +1,5 @@
#include "guest/dreamcast.h"
#include "core/option.h"
#include "core/string.h"
#include "core/core.h"
#include "guest/aica/aica.h"
#include "guest/arm7/arm7.h"
#include "guest/bios/bios.h"

View File

@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdint.h>
#include "core/constructor.h"
#include "core/list.h"
#include "guest/memory.h"
#include "host/keycode.h"

View File

@ -1,4 +1,4 @@
#include "core/assert.h"
#include "core/core.h"
#include "guest/gdrom/disc.h"
#include "guest/gdrom/gdrom_types.h"

View File

@ -1,5 +1,5 @@
#include <chd.h>
#include "core/assert.h"
#include "core/core.h"
#include "guest/gdrom/disc.h"
#include "guest/gdrom/gdrom_types.h"

View File

@ -1,6 +1,5 @@
#include "guest/gdrom/disc.h"
#include "core/assert.h"
#include "core/string.h"
#include "core/core.h"
#include "guest/gdrom/cdi.h"
#include "guest/gdrom/chd.h"
#include "guest/gdrom/gdi.h"

View File

@ -1,5 +1,5 @@
#include "guest/gdrom/gdi.h"
#include "core/assert.h"
#include "core/core.h"
#include "guest/gdrom/disc.h"
struct gdi {

View File

@ -1,6 +1,5 @@
#include "guest/gdrom/gdrom.h"
#include "core/math.h"
#include "core/string.h"
#include "core/core.h"
#include "guest/dreamcast.h"
#include "guest/gdrom/gdrom_replies.inc"
#include "guest/gdrom/gdrom_types.h"

View File

@ -1,5 +1,4 @@
#include "core/option.h"
#include "core/string.h"
#include "core/core.h"
#include "guest/dreamcast.h"
#include "guest/maple/maple.h"

View File

@ -1,6 +1,5 @@
#include "core/assert.h"
#include "core/core.h"
#include "core/filesystem.h"
#include "core/string.h"
#include "guest/maple/maple.h"
#include "guest/maple/vmu_default.inc"

View File

@ -1,7 +1,6 @@
#include "guest/memory.h"
#include "core/core.h"
#include "core/exception_handler.h"
#include "core/math.h"
#include "core/string.h"
#include "guest/dreamcast.h"
/*

View File

@ -1,8 +1,7 @@
#ifndef MEMORY_H
#define MEMORY_H
#include "core/assert.h"
#include "core/math.h"
#include <stdint.h>
#include "core/memory.h"
struct address_map;

View File

@ -19,10 +19,10 @@
*/
#include "guest/pvr/ta.h"
#include "core/core.h"
#include "core/exception_handler.h"
#include "core/filesystem.h"
#include "core/list.h"
#include "core/string.h"
#include "guest/holly/holly.h"
#include "guest/pvr/pvr.h"
#include "guest/pvr/tr.h"

View File

@ -1,5 +1,5 @@
#include "guest/pvr/tex.h"
#include "core/assert.h"
#include "core/core.h"
#include "render/render_backend.h"
/*

View File

@ -6,9 +6,7 @@
*/
#include "guest/pvr/tr.h"
#include "core/assert.h"
#include "core/core.h"
#include "core/math.h"
#include "core/profiler.h"
#include "core/sort.h"
#include "guest/pvr/ta.h"

View File

@ -1,7 +1,6 @@
#include "guest/rom/boot.h"
#include "core/filesystem.h"
#include "core/md5.h"
#include "core/option.h"
#include "guest/dreamcast.h"
struct boot {

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include "guest/scheduler.h"
#include "core/assert.h"
#include "core/core.h"
#include "core/list.h"
#include "guest/dreamcast.h"

View File

@ -1,6 +1,5 @@
#include "guest/sh4/sh4.h"
#include "core/math.h"
#include "core/string.h"
#include "core/core.h"
#include "core/time.h"
#include "guest/aica/aica.h"
#include "guest/bios/bios.h"

View File

@ -1,5 +1,5 @@
#include "keycode.h"
#include "core/string.h"
#include "core/core.h"
struct key {
enum keycode code;

View File

@ -2,7 +2,7 @@
#include <libretro.h>
#include <stdio.h>
#include <stdlib.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/filesystem.h"
#include "core/profiler.h"
#include "emulator.h"

View File

@ -1,22 +1,18 @@
#include <glad/glad.h>
#include <SDL.h>
#include <SDL_opengl.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/filesystem.h"
#include "core/option.h"
#include "core/profiler.h"
#include "core/ringbuf.h"
#include "core/time.h"
#include "emulator.h"
#include "host/host.h"
#include "imgui.h"
#include "options.h"
#include "render/render_backend.h"
#include "tracer.h"
DEFINE_OPTION_INT(audio, 1, "Enable audio");
DEFINE_OPTION_INT(latency, 50, "Preferred audio latency in ms");
DEFINE_PERSISTENT_OPTION_INT(fullscreen, 0, "Start window fullscreen");
/*
* sdl host implementation
*/

View File

@ -7,7 +7,7 @@
#endif
extern "C" {
#include "core/assert.h"
#include "core/core.h"
#include "core/time.h"
#include "host/keycode.h"
#include "imgui.h"

View File

@ -1,7 +1,7 @@
#include "jit/backend/x64/x64_local.h"
extern "C" {
#include "core/assert.h"
#include "core/core.h"
#include "jit/jit.h"
#include "jit/jit_guest.h"
}

View File

@ -1,7 +1,6 @@
#include "jit/frontend/armv3/armv3_disasm.h"
#include "core/assert.h"
#include "core/constructor.h"
#include "core/string.h"
#include "core/core.h"
#include "jit/frontend/armv3/armv3_fallback.h"
int armv3_optable[ARMV3_LOOKUP_SIZE];

View File

@ -1,7 +1,5 @@
#include "jit/frontend/armv3/armv3_fallback.h"
#include "core/assert.h"
#include "core/log.h"
#include "core/math.h"
#include "core/core.h"
#include "jit/frontend/armv3/armv3_context.h"
#include "jit/frontend/armv3/armv3_disasm.h"
#include "jit/frontend/armv3/armv3_guest.h"

View File

@ -1,7 +1,6 @@
#include "jit/frontend/sh4/sh4_disasm.h"
#include "core/assert.h"
#include "core/constructor.h"
#include "core/string.h"
#include "core/core.h"
#include "jit/frontend/sh4/sh4_fallback.h"
int sh4_optable[UINT16_MAX + 1];

View File

@ -1,7 +1,5 @@
#include "jit/frontend/sh4/sh4_fallback.h"
#include "core/assert.h"
#include "core/log.h"
#include "core/math.h"
#include "core/core.h"
#include "jit/frontend/sh4/sh4_frontend.h"
#include "jit/frontend/sh4/sh4_guest.h"
#include "jit/jit.h"

View File

@ -1,6 +1,5 @@
#include "jit/frontend/sh4/sh4_translate.h"
#include "core/assert.h"
#include "core/log.h"
#include "core/core.h"
#include "jit/frontend/sh4/sh4_frontend.h"
#include "jit/frontend/sh4/sh4_guest.h"
#include "jit/ir/ir.h"

View File

@ -1,7 +1,7 @@
#include <stdarg.h>
#include <stdio.h>
#include "jit/ir/ir.h"
#include "core/math.h"
#include "core/core.h"
const struct ir_opdef ir_opdefs[IR_NUM_OPS] = {
#define IR_OP(name, flags) {#name, flags},

View File

@ -2,7 +2,6 @@
#define IR_BUILDER_H
#include <stdio.h>
#include "core/assert.h"
#include "core/hash.h"
#include "core/list.h"

View File

@ -1,4 +1,4 @@
#include "core/string.h"
#include "core/core.h"
#include "jit/ir/ir.h"
enum ir_token {

View File

@ -1,5 +1,5 @@
#include <inttypes.h>
#include "core/string.h"
#include "core/core.h"
#include "jit/ir/ir.h"
struct ir_writer {

View File

@ -3,7 +3,6 @@
#include "core/core.h"
#include "core/exception_handler.h"
#include "core/filesystem.h"
#include "core/option.h"
#include "core/profiler.h"
#include "jit/ir/ir.h"
#include "jit/jit_backend.h"
@ -14,13 +13,12 @@
#include "jit/passes/expression_simplification_pass.h"
#include "jit/passes/load_store_elimination_pass.h"
#include "jit/passes/register_allocation_pass.h"
#include "options.h"
#if PLATFORM_DARWIN || PLATFORM_LINUX
#include <unistd.h>
#endif
DEFINE_OPTION_INT(perf, 0, "Create maps for compiled code for use with perf");
static int block_map_cmp(const struct rb_node *rb_lhs,
const struct rb_node *rb_rhs) {
const struct jit_block *lhs =

View File

@ -1,7 +1,5 @@
#include "jit/pass_stats.h"
#include "core/assert.h"
#include "core/math.h"
#include "core/string.h"
#include "core/core.h"
static struct list stats;

View File

@ -1,7 +1,7 @@
#include <limits.h>
#include "jit/passes/register_allocation_pass.h"
#include "core/core.h"
#include "core/list.h"
#include "core/math.h"
#include "jit/ir/ir.h"
#include "jit/jit_backend.h"
#include "jit/pass_stats.h"

18
src/options.c Normal file
View File

@ -0,0 +1,18 @@
#include "options.h"
/* host */
DEFINE_OPTION_INT(audio, 1, "Enable audio");
DEFINE_OPTION_INT(latency, 50, "Preferred audio latency in ms");
DEFINE_PERSISTENT_OPTION_INT(fullscreen, 0, "Start window fullscreen");
/* emulator */
DEFINE_PERSISTENT_OPTION_INT(debug, 1, "Show debug menu");
DEFINE_PERSISTENT_OPTION_STRING(aspect, "stretch", "Video aspect ratio");
/* bios */
DEFINE_PERSISTENT_OPTION_STRING(region, "usa", "System region");
DEFINE_PERSISTENT_OPTION_STRING(language, "english", "System language");
DEFINE_PERSISTENT_OPTION_STRING(broadcast, "ntsc", "System broadcast mode");
/* jit */
DEFINE_OPTION_INT(perf, 0, "Create maps for compiled code for use with perf");

22
src/options.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef OPTIONS_H
#include "core/option.h"
/* host */
DECLARE_OPTION_INT(audio);
DECLARE_OPTION_INT(latency);
DECLARE_OPTION_INT(fullscreen);
/* emulator */
DECLARE_OPTION_INT(debug);
DECLARE_OPTION_STRING(aspect);
/* bios */
DECLARE_OPTION_STRING(region);
DECLARE_OPTION_STRING(language);
DECLARE_OPTION_STRING(broadcast);
/* jit */
DECLARE_OPTION_INT(perf);
#endif

View File

@ -1,7 +1,6 @@
#include <glad/glad.h>
#include "core/assert.h"
#include "core/core.h"
#include "core/profiler.h"
#include "core/string.h"
#include "host/host.h"
#include "render/render_backend.h"

View File

@ -1,5 +1,5 @@
#include "tracer.h"
#include "core/math.h"
#include "core/core.h"
#include "core/rb_tree.h"
#include "file/trace.h"
#include "guest/pvr/ta.h"