lots of mac build progress

master
Allen Webster 2017-11-04 01:07:14 -04:00
parent d25aa1bf62
commit f3ea38abec
11 changed files with 123 additions and 28 deletions

View File

@ -52,6 +52,10 @@ typedef double f64;
#define AllowLocal(c) (void)(c)
#define Member(T, m) (((T*)0)->m)
#define STR__(s) #s
#define STR_(s) STR__(s)
#define LINE_STR STR_(__LINE__)
#if defined(Assert)
# undef Assert
#endif
@ -109,9 +113,6 @@ inline u32 round_up_pot_u32(u32 x){
return(x);
}
#define STR__(s) #s
#define STR_(s) STR__(s)
#define DrCase(PC) case PC: goto resumespot_##PC
#define DrYield(PC, n) { *S_ptr = S; S_ptr->__pc__ = PC; return(n); resumespot_##PC:; }
#define DrReturn(n) { *S_ptr = S; S_ptr->__pc__ = -1; return(n); }

View File

@ -321,7 +321,7 @@ build(u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, c
#define GCC_LIBS \
"-framework Cocoa -framework QuartzCore " \
"-framework OpenGL -framework IOKit"
"-framework OpenGL -framework IOKit -lfreetype"
#else
# error gcc options not set for this platform

View File

@ -15,10 +15,17 @@
#define CORE_COUNT 8
#define THREAD_TYPE_SIZE 32
#define MUTEX_TYPE_SIZE 40
#define MUTEX_TYPE_SIZE 64
#define CONDITION_VARIABLE_TYPE_SIZE 48
#define SEMAPHORE_TYPE_SIZE 32
/*
fprintf(stdout, "%d VS %d\n", (i32)sizeof(Thread), THREAD_TYPE_SIZE); \
fprintf(stdout, "%d VS %d\n", (i32)sizeof(Mutex), MUTEX_TYPE_SIZE); \
fprintf(stdout, "%d VS %d\n", (i32)sizeof(Condition_Variable), CONDITION_VARIABLE_TYPE_SIZE); \
fprintf(stdout, "%d VS %d\n", (i32)sizeof(Semaphore), SEMAPHORE_TYPE_SIZE); \
*/
#define AssertThreadSizes() \
Assert( sizeof(Thread) == THREAD_TYPE_SIZE ); \
Assert( sizeof(Mutex) == MUTEX_TYPE_SIZE ); \

View File

@ -24,18 +24,23 @@ system_get_binary_path_string(String *out){
internal void
init_shared_vars(){
DBG_POINT();
umem scratch_size = KB(128);
void *scratch_memory = system_memory_allocate(scratch_size);
shared_vars.scratch = make_part(scratch_memory, (i32)scratch_size);
DBG_POINT();
shared_vars.track_table_size = KB(16);
shared_vars.track_table = system_memory_allocate(shared_vars.track_table_size);
DBG_POINT();
shared_vars.track_node_size = KB(16);
void *track_nodes = system_memory_allocate(shared_vars.track_node_size);
DBG_POINT();
i32 track_result = init_track_system(&shared_vars.track, &shared_vars.scratch, shared_vars.track_table, shared_vars.track_table_size, track_nodes, shared_vars.track_node_size);
DBG_POINT();
if (track_result != FileTrack_Good){
exit(1);
}

View File

@ -370,23 +370,29 @@ INTERNAL_Sys_Get_Thread_States_Sig(system_internal_get_thread_states){
internal void
work_system_init(){
DBG_POINT();
AssertThreadSizes();
DBG_POINT();
u32 core_count = CORE_COUNT;
i32 thread_system_memory_size = core_count*(sizeof(Thread_Context) + sizeof(Thread_Memory));
void *thread_system_memory = system_memory_allocate(thread_system_memory_size);
Partition thread_part = make_part(thread_system_memory, thread_system_memory_size);
DBG_POINT();
for (i32 i = 0; i < LOCK_COUNT; ++i){
system_init_lock(&threadvars.locks[i]);
}
DBG_POINT();
for (i32 i = 0; i < CV_COUNT; ++i){
system_init_cv(&threadvars.conds[i]);
}
DBG_POINT();
threadvars.thread_memory = push_array(&thread_part, Thread_Memory, core_count);
DBG_POINT();
for (u32 group_i = 0; group_i < THREAD_GROUP_COUNT; ++group_i){
Thread_Context *threads = push_array(&thread_part, Thread_Context, core_count);
threadvars.groups[group_i].threads = threads;
@ -394,8 +400,10 @@ work_system_init(){
threadvars.groups[group_i].cancel_lock0 = CANCEL_LOCK0;
threadvars.groups[group_i].cancel_cv0 = CANCEL_CV0;
DBG_POINT();
system_init_semaphore(&threadvars.queues[group_i].semaphore, core_count);
DBG_POINT();
for (u32 i = 0; i < core_count; ++i){
Thread_Context *thread = threads + i;
thread->id = i + 1;
@ -409,6 +417,7 @@ work_system_init(){
system_init_and_launch_thread(&thread->thread, job_thread_proc, thread);
}
DBG_POINT();
initialize_unbounded_queue(&threadvars.groups[group_i].queue);
}
}

View File

@ -217,6 +217,21 @@ handle_sem(sem_t *sem){
////////////////////////////////
internal
Sys_Get_4ed_Path_Sig(system_get_4ed_path){
ssize_t size = readlink("/proc/self/exe", out, capacity - 1);
if (size != -1 && size < capacity - 1){
String str = make_string(out, size);
remove_last_folder(&str);
terminate_with_null(&str);
size = str.size;
}
else{
size = 0;
}
return(size);
}
#include "unix_4ed_functions.cpp"
#include "4ed_shared_file_handling.cpp"

View File

@ -11,6 +11,9 @@
#define IS_PLAT_LAYER
#include <stdio.h>
#define DBG_POINT() fprintf(stdout, "%s\n", __FILE__ ":" LINE_STR ":")
#include "4ed_defines.h"
#include "4coder_API/version.h"
@ -48,6 +51,8 @@
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <mach-o/dyld.h>
#include <stdlib.h>
////////////////////////////////
@ -91,6 +96,20 @@ global Coroutine_System_Auto_Alloc coroutines;
////////////////////////////////
internal
Sys_Get_4ed_Path_Sig(system_get_4ed_path){
u32 buf_size = capacity;
i32 status = _NSGetExecutablePath(out, &buf_size);
i32 size = 0;
if (status == 0){
String str = make_string_slowly(out);
remove_last_folder(&str);
terminate_with_null(&str);
size = str.size;
}
return(size);
}
#include "unix_4ed_functions.cpp"
#include "4ed_shared_file_handling.cpp"
@ -197,12 +216,14 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
external void*
osx_allocate(umem size){
DBG_POINT();
void *result = system_memory_allocate(size);
return(result);
}
external void
osx_resize(int width, int height){
DBG_POINT();
osx.width = width;
osx.height = height;
// TODO
@ -210,21 +231,25 @@ osx_resize(int width, int height){
external void
osx_character_input(u32 code, OSX_Keyboard_Modifiers modifier_flags){
DBG_POINT();
// TODO
}
external void
osx_mouse(i32 mx, i32 my, u32 type){
DBG_POINT();
// TODO
}
external void
osx_mouse_wheel(float dx, float dy){
DBG_POINT();
// TODO
}
external void
osx_step(){
DBG_POINT();
// TODO
}
@ -234,12 +259,14 @@ osx_init(){
// System Linkage
//
DBG_POINT();
link_system_code();
//
// Memory init
//
DBG_POINT();
memset(&target, 0, sizeof(target));
memset(&memory_vars, 0, sizeof(memory_vars));
memset(&plat_settings, 0, sizeof(plat_settings));
@ -255,12 +282,14 @@ osx_init(){
// Previously zipped stuff is here, it should be zipped in the new pattern now.
//
DBG_POINT();
init_shared_vars();
//
// Dynamic Linkage
//
DBG_POINT();
load_app_code();
link_rendering();
#if defined(FRED_SUPER)
@ -273,32 +302,38 @@ osx_init(){
// Read command line
//
DBG_POINT();
read_command_line(osx.argc, osx.argv);
//
// Threads
//
DBG_POINT();
work_system_init();
//
// Coroutines
//
DBG_POINT();
coroutines_init();
//
// Font System Init
//
DBG_POINT();
system_font_init(&sysfunc.font, 0, 0, plat_settings.font_size, plat_settings.use_hinting);
//
// App Init
//
DBG_POINT();
char cwd[4096];
u32 size = sysfunc.get_current_path(cwd, sizeof(cwd));
fprintf(stdout, "cwd = \"%.*s\"\n", size, cwd);
if (size == 0 || size >= sizeof(cwd)){
system_error_box("Could not get current directory at launch.");
}
@ -306,13 +341,20 @@ osx_init(){
terminate_with_null(&curdir);
replace_char(&curdir, '\\', '/');
DBG_POINT();
String clipboard_string = {0};
if (osx.has_clipboard_item){
clipboard_string = make_string(osx.clipboard_data, osx.clipboard_size);
}
DBG_POINT();
fprintf(stdout, "%p\n", app.init);
LOG("Initializing application variables\n");
app.init(&sysfunc, &target, &memory_vars, clipboard_string, curdir, custom_api);
DBG_POINT();
}
#include "4ed_shared_fonts.cpp"

View File

@ -284,6 +284,23 @@ DISPLINK_SIG(osx_display_link){
}
@end
void
osx_add_file_listener(char *file_name){
NotImplemented;
}
void
osx_remove_file_listener(char *file_name){
NotImplemented;
}
i32
osx_get_file_change_event(char *buffer, i32 max, i32 *size){
i32 result = 0;
NotImplemented;
return(result);
}
int
main(int argc, char **argv){
memset(&osx, 0, sizeof(osx));

View File

@ -9,53 +9,58 @@
// TOP
File_Track_Result
init_track_system(File_Track_System *system, Partition *scratch, void *table_memory, i32 table_memory_size, void *listener_memory, i32 listener_memory_size){
File_Track_Result result = FileTrack_Good;
NotImplemented;
// NOTE(allen): Do nothing???
return(result);
}
File_Track_Result
add_listener(File_Track_System *system, Partition *scratch, u8 *filename){
File_Track_Result result = FileTrack_Good;
NotImplemented;
osx_add_file_listener((char*)filename);
return(result);
}
File_Track_Result
remove_listener(File_Track_System *system, Partition *scratch, u8 *filename){
File_Track_Result result = FileTrack_Good;
NotImplemented;
osx_remove_file_listener((char*)filename);
return(result);
}
File_Track_Result
move_track_system(File_Track_System *system, Partition *scratch, void *mem, i32 size){
File_Track_Result result = FileTrack_Good;
NotImplemented;
// NOTE(allen): Do nothing???
return(result);
}
File_Track_Result
expand_track_system_listeners(File_Track_System *system, Partition *scratch, void *mem, i32 size){
File_Track_Result result = FileTrack_Good;
NotImplemented;
// NOTE(allen): Do nothing???
return(result);
}
File_Track_Result
get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, i32 max, i32 *size){
File_Track_Result result = FileTrack_Good;
NotImplemented;
i32 status = osx_get_file_change_event((char*)buffer, max, size);
if (status == 0){
result = FileTrack_NoMoreEvents;
}
if (status == -1){
result = FileTrack_MemoryTooSmall;
}
return(result);
}
File_Track_Result
shut_down_track_system(File_Track_System *system, Partition *scratch){
File_Track_Result result = FileTrack_Good;
NotImplemented;
// NOTE(allen): Do nothing???
return(result);
}

View File

@ -78,6 +78,15 @@ osx_post_to_clipboard(char *str);
external void
osx_error_dialogue(char *str);
external void
osx_add_file_listener(char *file_name);
external void
osx_remove_file_listener(char *file_name);
external i32
osx_get_file_change_event(char *buffer, i32 max, i32 *size);
#endif
// BOTTOM

View File

@ -28,21 +28,6 @@ Sys_Get_Current_Path_Sig(system_get_current_path){
return(result);
}
internal
Sys_Get_4ed_Path_Sig(system_get_4ed_path){
ssize_t size = readlink("/proc/self/exe", out, capacity - 1);
if (size != -1 && size < capacity - 1){
String str = make_string(out, size);
remove_last_folder(&str);
terminate_with_null(&str);
size = str.size;
}
else{
size = 0;
}
return(size);
}
//
// Logging
//