WIP: accelerate build with precompiled headers
Also got rid of rwops_pipe; we don't use it and PCHs make passing the required feature macro for the posix implementation too complicated.
This commit is contained in:
parent
f7ca79e834
commit
14f0a170c8
11 changed files with 26 additions and 129 deletions
|
@ -8,10 +8,12 @@
|
|||
|
||||
#include "taisei.h"
|
||||
|
||||
#define HT_IMPL
|
||||
#include "hashtable.h"
|
||||
#include "util.h"
|
||||
|
||||
#define HT_IMPL
|
||||
#include "hashtable_predefs.inc.h"
|
||||
|
||||
uint32_t (*htutil_hashfunc_string)(uint32_t crc, const char *str);
|
||||
|
||||
void htutil_init(void) {
|
||||
|
|
|
@ -212,8 +212,7 @@
|
|||
* If HT_DECL is defined, this header will generate declarations of the API types
|
||||
* and functions. This should be used in headers.
|
||||
*
|
||||
* If HT_IMPL is defined, then HT_DECL is implied, and definitions of the API
|
||||
* functions are also generated.
|
||||
* If HT_IMPL is defined, this header will generate definitions of the API functions.
|
||||
*
|
||||
* * Example:
|
||||
*
|
||||
|
@ -222,8 +221,6 @@
|
|||
*/
|
||||
#if !defined(HT_DECL) && !defined(HT_IMPL)
|
||||
#error neither HT_DECL nor HT_IMPL defined
|
||||
#elif defined(HT_IMPL) && !defined(HT_DECL)
|
||||
#define HT_DECL
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
20
src/list.c
20
src/list.c
|
@ -11,11 +11,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define LIST_NO_MACROS
|
||||
|
||||
#include "list.h"
|
||||
#include "global.h"
|
||||
|
||||
#undef list_insert
|
||||
List* list_insert(List **dest, List *elem) {
|
||||
elem->prev = *dest;
|
||||
|
||||
|
@ -35,6 +34,7 @@ List* list_insert(List **dest, List *elem) {
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef alist_insert
|
||||
List* alist_insert(ListAnchor *list, List *ref, List *elem) {
|
||||
elem->prev = ref;
|
||||
|
||||
|
@ -64,6 +64,7 @@ List* alist_insert(ListAnchor *list, List *ref, List *elem) {
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef list_push
|
||||
List* list_push(List **dest, List *elem) {
|
||||
if(*dest) {
|
||||
(*dest)->prev = elem;
|
||||
|
@ -76,6 +77,7 @@ List* list_push(List **dest, List *elem) {
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef alist_push
|
||||
List* alist_push(ListAnchor *list, List *elem) {
|
||||
elem->next = list->first;
|
||||
elem->prev = NULL;
|
||||
|
@ -92,6 +94,7 @@ List* alist_push(ListAnchor *list, List *elem) {
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef list_append
|
||||
List* list_append(List **dest, List *elem) {
|
||||
if(*dest == NULL) {
|
||||
return list_insert(dest, elem);
|
||||
|
@ -105,6 +108,7 @@ List* list_append(List **dest, List *elem) {
|
|||
return list_insert(&end, elem);
|
||||
}
|
||||
|
||||
#undef alist_append
|
||||
List* alist_append(ListAnchor *list, List *elem) {
|
||||
elem->next = NULL;
|
||||
elem->prev = list->last;
|
||||
|
@ -169,10 +173,12 @@ static List* list_insert_at_priority(List **list_head, List *elem, int prio, Lis
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef list_insert_at_priority_head
|
||||
List* list_insert_at_priority_head(List **dest, List *elem, int prio, ListPriorityFunc prio_func) {
|
||||
return list_insert_at_priority(dest, elem, prio, prio_func, true);
|
||||
}
|
||||
|
||||
#undef alist_insert_at_priority_head
|
||||
List* alist_insert_at_priority_head(ListAnchor *list, List *elem, int prio, ListPriorityFunc prio_func) {
|
||||
if(list->first == NULL) {
|
||||
assert(list->last == NULL);
|
||||
|
@ -217,10 +223,12 @@ List* alist_insert_at_priority_head(ListAnchor *list, List *elem, int prio, List
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef list_insert_at_priority_tail
|
||||
List* list_insert_at_priority_tail(List **dest, List *elem, int prio, ListPriorityFunc prio_func) {
|
||||
return list_insert_at_priority(dest, elem, prio, prio_func, false);
|
||||
}
|
||||
|
||||
#undef alist_insert_at_priority_tail
|
||||
List* alist_insert_at_priority_tail(ListAnchor *list, List *elem, int prio, ListPriorityFunc prio_func) {
|
||||
if(list->last == NULL) {
|
||||
assert(list->first == NULL);
|
||||
|
@ -268,6 +276,7 @@ List* alist_insert_at_priority_tail(ListAnchor *list, List *elem, int prio, List
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef list_unlink
|
||||
List* list_unlink(List **dest, List *elem) {
|
||||
if(elem->prev != NULL) {
|
||||
elem->prev->next = elem->next;
|
||||
|
@ -284,6 +293,7 @@ List* list_unlink(List **dest, List *elem) {
|
|||
return elem;
|
||||
}
|
||||
|
||||
#undef alist_unlink
|
||||
List* alist_unlink(ListAnchor *list, List *elem) {
|
||||
if(list->last == elem) {
|
||||
list->last = list->last->prev;
|
||||
|
@ -292,6 +302,7 @@ List* alist_unlink(ListAnchor *list, List *elem) {
|
|||
return list_unlink(&list->first, elem);
|
||||
}
|
||||
|
||||
#undef list_pop
|
||||
List* list_pop(List **dest) {
|
||||
if(*dest == NULL) {
|
||||
return NULL;
|
||||
|
@ -300,6 +311,7 @@ List* list_pop(List **dest) {
|
|||
return list_unlink(dest, *dest);
|
||||
}
|
||||
|
||||
#undef alist_pop
|
||||
List* alist_pop(ListAnchor *list) {
|
||||
if(list->first == NULL) {
|
||||
return NULL;
|
||||
|
@ -308,6 +320,7 @@ List* alist_pop(ListAnchor *list) {
|
|||
return alist_unlink(list, list->first);
|
||||
}
|
||||
|
||||
#undef list_foreach
|
||||
void* list_foreach(List **dest, ListForeachCallback callback, void *arg) {
|
||||
void *ret = NULL;
|
||||
|
||||
|
@ -322,6 +335,7 @@ void* list_foreach(List **dest, ListForeachCallback callback, void *arg) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
#undef alist_foreach
|
||||
void* alist_foreach(ListAnchor *list, ListAnchorForeachCallback callback, void *arg) {
|
||||
void *ret = NULL;
|
||||
|
||||
|
@ -348,10 +362,12 @@ void* alist_callback_free_element(ListAnchor *list, List *elem, void *arg) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#undef list_free_all
|
||||
void list_free_all(List **dest) {
|
||||
list_foreach(dest, list_callback_free_element, NULL);
|
||||
}
|
||||
|
||||
#undef alist_free_all
|
||||
void alist_free_all(ListAnchor *list) {
|
||||
alist_foreach(list, alist_callback_free_element, NULL);
|
||||
}
|
||||
|
|
|
@ -96,8 +96,6 @@ ListContainer* list_wrap_container(void *data) attr_nodiscard;
|
|||
|
||||
// type-generic macros
|
||||
|
||||
#ifndef LIST_NO_MACROS
|
||||
|
||||
#ifdef USE_GNU_EXTENSIONS
|
||||
// thorough safeguard
|
||||
|
||||
|
@ -189,6 +187,4 @@ ListContainer* list_wrap_container(void *data) attr_nodiscard;
|
|||
#define alist_free_all(dest) \
|
||||
alist_free_all(LIST_ANCHOR_CAST(dest))
|
||||
|
||||
#endif // LIST_NO_MACROS
|
||||
|
||||
#endif // IGUARD_list_h
|
||||
|
|
|
@ -165,6 +165,7 @@ endif
|
|||
taisei_exe = executable(taisei_exe_name, taisei_src, version_deps,
|
||||
dependencies : taisei_deps,
|
||||
c_args : taisei_c_args,
|
||||
c_pch : 'pch/taisei_pch.h',
|
||||
gui_app : not get_option('win_console'),
|
||||
install : true,
|
||||
install_dir : bindir,
|
||||
|
|
3
src/pch/taisei_pch.h
Normal file
3
src/pch/taisei_pch.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
#include "taisei.h"
|
||||
#include "global.h"
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include "rwops_autobuf.h"
|
||||
#include "rwops_crc32.h"
|
||||
#include "rwops_pipe.h"
|
||||
#include "rwops_segment.h"
|
||||
#include "rwops_zlib.h"
|
||||
|
||||
|
|
|
@ -12,10 +12,3 @@ if taisei_deps.contains(dep_zip)
|
|||
'rwops_zipfile.c',
|
||||
)
|
||||
endif
|
||||
|
||||
if have_posix
|
||||
rwops_src += files('rwops_pipe_posix.c')
|
||||
else
|
||||
rwops_src += files('rwops_pipe_null.c')
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@alienslab.net>.
|
||||
*/
|
||||
|
||||
#ifndef IGUARD_rwops_rwops_pipe_h
|
||||
#define IGUARD_rwops_rwops_pipe_h
|
||||
|
||||
#include "taisei.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
SDL_RWops* SDL_RWpopen(const char *command, const char *mode);
|
||||
int SDL_RWConvertToPipe(SDL_RWops *stdio_rw);
|
||||
|
||||
#endif // IGUARD_rwops_rwops_pipe_h
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@alienslab.net>.
|
||||
*/
|
||||
|
||||
#include "taisei.h"
|
||||
|
||||
#include "rwops_pipe.h"
|
||||
|
||||
SDL_RWops* SDL_RWpopen(const char *command, const char *mode) {
|
||||
SDL_SetError("Not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int SDL_RWConvertToPipe(SDL_RWops *rw) {
|
||||
SDL_SetError("Not implemented");
|
||||
return -1;
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@alienslab.net>.
|
||||
*/
|
||||
|
||||
// BEGIN before-taisei-h
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
// END before-taisei-h
|
||||
|
||||
#include "taisei.h"
|
||||
|
||||
#include "rwops_pipe.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int pipe_close(SDL_RWops *rw) {
|
||||
int status = 0;
|
||||
|
||||
if(rw->hidden.stdio.autoclose) {
|
||||
if((status = pclose(rw->hidden.stdio.fp)) != 0) {
|
||||
SDL_SetError("Process exited abnormally: code %i", status);
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_FreeRW(rw);
|
||||
return status;
|
||||
}
|
||||
|
||||
SDL_RWops* SDL_RWpopen(const char *command, const char *mode) {
|
||||
assert(command != NULL);
|
||||
assert(mode != NULL);
|
||||
|
||||
FILE *fp = popen(command, mode);
|
||||
|
||||
if(!fp) {
|
||||
SDL_SetError("popen(\"%s\", \"%s\") failed: errno %i", command, mode, errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_RWops *rw = SDL_RWFromFP(fp, true);
|
||||
|
||||
if(!rw) {
|
||||
pclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(SDL_RWConvertToPipe(rw)) {
|
||||
SDL_RWclose(rw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return rw;
|
||||
}
|
||||
|
||||
int SDL_RWConvertToPipe(SDL_RWops *rw) {
|
||||
if(rw->type != SDL_RWOPS_STDFILE) {
|
||||
SDL_SetError("Not an stdio stream");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rw->close = pipe_close;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue