aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-04-19 14:48:57 +0200
committerLoïc Hoguin <[email protected]>2017-04-19 14:48:57 +0200
commit1947c4d7f32272ec0c5b9295808cde4c9138995c (patch)
tree18afdcdfc3ea21167d84f7d57f09eb8542dc0fb9
parent3d3a8dcdc9a2f45888059e69587dd07c45aa856a (diff)
downloadesdl2-1947c4d7f32272ec0c5b9295808cde4c9138995c.tar.gz
esdl2-1947c4d7f32272ec0c5b9295808cde4c9138995c.tar.bz2
esdl2-1947c4d7f32272ec0c5b9295808cde4c9138995c.zip
Fix warnings in preparation for splitting nif_helpers out
-rw-r--r--Makefile4
-rw-r--r--c_src/esdl2.c6
-rw-r--r--c_src/esdl2.h8
-rw-r--r--c_src/nif_helpers.c12
-rw-r--r--c_src/nif_helpers.h4
-rw-r--r--c_src/sdl.c4
-rw-r--r--c_src/sdl_events.c8
-rw-r--r--c_src/sdl_hints.c2
-rw-r--r--c_src/sdl_power.c2
-rw-r--r--c_src/sdl_renderer.c8
-rw-r--r--c_src/sdl_texture.c3
-rw-r--r--c_src/sdl_window.c10
-rw-r--r--erlang.mk4
13 files changed, 38 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 6cfe5df..f8d717b 100644
--- a/Makefile
+++ b/Makefile
@@ -20,12 +20,12 @@ PROJECT_VERSION = 0.1.0
SDL2_LIBS_FILTER_OUT = -Wl,--no-undefined
SDL2_LIBS = $(filter-out $(SDL2_LIBS_FILTER_OUT),$(shell sdl2-config --static-libs))
+include erlang.mk
+
CFLAGS += $(shell sdl2-config --cflags)
# @todo -undefined dynamic_lookup on OSX?
LDLIBS += $(SDL2_LIBS) -lSDL2_image
-include erlang.mk
-
ifeq ($(PLATFORM),msys2)
CFLAGS += -I"$(C_SRC_DIR)/compat/"
endif
diff --git a/c_src/esdl2.c b/c_src/esdl2.c
index 430847f..1790dd7 100644
--- a/c_src/esdl2.c
+++ b/c_src/esdl2.c
@@ -20,7 +20,7 @@ NIF_RESOURCES(NIF_RES_DECL)
static int loads = 0;
-int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
+static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
{
NIF_ATOMS(NIF_ATOM_INIT)
NIF_RESOURCES(NIF_RES_INIT)
@@ -32,7 +32,7 @@ int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
return 0;
}
-int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info)
+static int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info)
{
*priv_data = *old_priv_data;
@@ -41,7 +41,7 @@ int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM
return 0;
}
-void unload(ErlNifEnv* env, void* priv_data)
+static void unload(ErlNifEnv* env, void* priv_data)
{
if (loads == 1)
nif_destroy_main_thread(priv_data);
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index df16664..10508ff 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -257,9 +257,15 @@ NIF_ATOMS(NIF_ATOM_H_DECL)
NIF_RESOURCES(NIF_RES_H_DECL)
NIF_FUNCTIONS(NIF_FUNCTION_H_DECL)
+// Utility functions used across different files.
+
+NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_bool, SDL_bool)
+NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_blend_mode, SDL_BlendMode)
+NIF_ENUM_TO_ATOM_FUNCTION_DECL(blend_mode_to_atom, SDL_BlendMode)
+
// --
-ErlNifPid* get_callback_process();
+ErlNifPid* get_callback_process(void);
#define sdl_error_tuple(env) \
enif_make_tuple2(env, \
diff --git a/c_src/nif_helpers.c b/c_src/nif_helpers.c
index f1465da..0f98cd6 100644
--- a/c_src/nif_helpers.c
+++ b/c_src/nif_helpers.c
@@ -38,7 +38,7 @@ typedef struct {
// Message.
-nif_thread_message* nif_thread_message_alloc(void* f, nif_thread_arg* args, ErlNifPid* pid)
+static nif_thread_message* nif_thread_message_alloc(void* f, nif_thread_arg* args, ErlNifPid* pid)
{
nif_thread_message* msg = (nif_thread_message*)enif_alloc(sizeof(nif_thread_message));
@@ -49,7 +49,7 @@ nif_thread_message* nif_thread_message_alloc(void* f, nif_thread_arg* args, ErlN
return msg;
}
-void nif_thread_message_free(nif_thread_message* msg)
+static void nif_thread_message_free(nif_thread_message* msg)
{
enif_free(msg->from_pid);
enif_free(msg->args);
@@ -58,7 +58,7 @@ void nif_thread_message_free(nif_thread_message* msg)
// Calls and casts.
-ERL_NIF_TERM nif_thread_send(nif_thread_state* st, nif_thread_message* msg)
+static ERL_NIF_TERM nif_thread_send(nif_thread_state* st, nif_thread_message* msg)
{
enif_mutex_lock(st->lock);
@@ -107,7 +107,7 @@ ERL_NIF_TERM nif_thread_call(ErlNifEnv* env, ERL_NIF_TERM (*f)(ErlNifEnv*, nif_t
// Main thread loop.
-int nif_thread_receive(nif_thread_state* st, nif_thread_message** msg)
+static int nif_thread_receive(nif_thread_state* st, nif_thread_message** msg)
{
enif_mutex_lock(st->lock);
@@ -125,7 +125,7 @@ int nif_thread_receive(nif_thread_state* st, nif_thread_message** msg)
return 1;
}
-void nif_thread_handle(ErlNifEnv* env, nif_thread_state* st, nif_thread_message* msg)
+static void nif_thread_handle(ErlNifEnv* env, nif_thread_state* st, nif_thread_message* msg)
{
if (msg->from_pid == NULL) {
void (*cast)(nif_thread_arg*) = msg->function;
@@ -143,7 +143,7 @@ void nif_thread_handle(ErlNifEnv* env, nif_thread_state* st, nif_thread_message*
nif_thread_message_free(msg);
}
-void* nif_main_thread(void* obj)
+static void* nif_main_thread(void* obj)
{
ErlNifEnv* env = enif_alloc_env();
nif_thread_state* st = (nif_thread_state*)obj;
diff --git a/c_src/nif_helpers.h b/c_src/nif_helpers.h
index 8c1cfa4..111ea84 100644
--- a/c_src/nif_helpers.h
+++ b/c_src/nif_helpers.h
@@ -125,7 +125,7 @@ void nif_destroy_main_thread(void*);
ERL_NIF_TERM nif_thread_cast(ErlNifEnv*, void (*f)(nif_thread_arg*), int a, ...);
ERL_NIF_TERM nif_thread_call(ErlNifEnv*, ERL_NIF_TERM (*f)(ErlNifEnv*, nif_thread_arg*), int a, ...);
-#define NIF_CAST_HANDLER(f) void f(nif_thread_arg* args)
-#define NIF_CALL_HANDLER(f) ERL_NIF_TERM f(ErlNifEnv* env, nif_thread_arg* args)
+#define NIF_CAST_HANDLER(f) static void f(nif_thread_arg* args)
+#define NIF_CALL_HANDLER(f) static ERL_NIF_TERM f(ErlNifEnv* env, nif_thread_arg* args)
#endif
diff --git a/c_src/sdl.c b/c_src/sdl.c
index 26a1d0e..94302bd 100644
--- a/c_src/sdl.c
+++ b/c_src/sdl.c
@@ -27,8 +27,8 @@
BASE_INIT_FLAGS(F) \
F(everything, SDL_INIT_EVERYTHING)
-NIF_LIST_TO_FLAGS_FUNCTION(list_to_init_flags, Uint32, INIT_FLAGS)
-NIF_FLAGS_TO_LIST_FUNCTION(init_flags_to_list, Uint32, BASE_INIT_FLAGS)
+static NIF_LIST_TO_FLAGS_FUNCTION(list_to_init_flags, Uint32, INIT_FLAGS)
+static NIF_FLAGS_TO_LIST_FUNCTION(init_flags_to_list, Uint32, BASE_INIT_FLAGS)
// init
diff --git a/c_src/sdl_events.c b/c_src/sdl_events.c
index 1da0165..017802a 100644
--- a/c_src/sdl_events.c
+++ b/c_src/sdl_events.c
@@ -24,7 +24,7 @@
E(mouse_wheel, SDL_MOUSEWHEEL) \
E(quit, SDL_QUIT)
-NIF_ENUM_TO_ATOM_FUNCTION(event_type_to_atom, Uint32, EVENT_TYPE_ENUM)
+static NIF_ENUM_TO_ATOM_FUNCTION(event_type_to_atom, Uint32, EVENT_TYPE_ENUM)
#define WINDOW_EVENT_ENUM(E) \
E(shown, SDL_WINDOWEVENT_SHOWN) \
@@ -42,7 +42,7 @@ NIF_ENUM_TO_ATOM_FUNCTION(event_type_to_atom, Uint32, EVENT_TYPE_ENUM)
E(focus_lost, SDL_WINDOWEVENT_FOCUS_LOST) \
E(close, SDL_WINDOWEVENT_CLOSE)
-NIF_ENUM_TO_ATOM_FUNCTION(window_event_to_atom, Uint8, WINDOW_EVENT_ENUM)
+static NIF_ENUM_TO_ATOM_FUNCTION(window_event_to_atom, Uint8, WINDOW_EVENT_ENUM)
#define KEYMOD_FLAGS(F) \
F(left_shift, KMOD_LSHIFT) \
@@ -57,7 +57,7 @@ NIF_ENUM_TO_ATOM_FUNCTION(window_event_to_atom, Uint8, WINDOW_EVENT_ENUM)
F(caps, KMOD_CAPS) \
F(mode, KMOD_MODE)
-NIF_FLAGS_TO_LIST_FUNCTION(keymod_flags_to_list, Uint16, KEYMOD_FLAGS)
+static NIF_FLAGS_TO_LIST_FUNCTION(keymod_flags_to_list, Uint16, KEYMOD_FLAGS)
#define BUTTON_ENUM(E) \
E(left, SDL_BUTTON_LEFT) \
@@ -66,7 +66,7 @@ NIF_FLAGS_TO_LIST_FUNCTION(keymod_flags_to_list, Uint16, KEYMOD_FLAGS)
E(x1, SDL_BUTTON_X1) \
E(x2, SDL_BUTTON_X2)
-NIF_ENUM_TO_ATOM_FUNCTION(button_to_atom, Uint8, BUTTON_ENUM)
+static NIF_ENUM_TO_ATOM_FUNCTION(button_to_atom, Uint8, BUTTON_ENUM)
// poll_event
diff --git a/c_src/sdl_hints.c b/c_src/sdl_hints.c
index fe4eceb..0342777 100644
--- a/c_src/sdl_hints.c
+++ b/c_src/sdl_hints.c
@@ -21,7 +21,7 @@ typedef struct esdl2_callback {
char* function;
} esdl2_callback;
-void esdl2_hint_callback(void* userdata, const char* name, const char* oldValue, const char* newValue)
+static void esdl2_hint_callback(void* userdata, const char* name, const char* oldValue, const char* newValue)
{
ErlNifEnv* env = enif_alloc_env();
esdl2_callback* callback = (esdl2_callback*)userdata;
diff --git a/c_src/sdl_power.c b/c_src/sdl_power.c
index c97e2f2..eb4cf4f 100644
--- a/c_src/sdl_power.c
+++ b/c_src/sdl_power.c
@@ -21,7 +21,7 @@
E(charging, SDL_POWERSTATE_CHARGING) \
E(charged, SDL_POWERSTATE_CHARGED)
-NIF_ENUM_TO_ATOM_FUNCTION(power_state_to_atom, SDL_PowerState, POWER_STATE_ENUM)
+static NIF_ENUM_TO_ATOM_FUNCTION(power_state_to_atom, SDL_PowerState, POWER_STATE_ENUM)
// get_power_info
diff --git a/c_src/sdl_renderer.c b/c_src/sdl_renderer.c
index f5b6889..5344199 100644
--- a/c_src/sdl_renderer.c
+++ b/c_src/sdl_renderer.c
@@ -26,7 +26,7 @@ void dtor_Renderer(ErlNifEnv* env, void* obj)
F(present_vsync, SDL_RENDERER_PRESENTVSYNC) \
F(target_texture, SDL_RENDERER_TARGETTEXTURE)
-NIF_LIST_TO_FLAGS_FUNCTION(list_to_renderer_flags, Uint32, RENDERER_FLAGS)
+static NIF_LIST_TO_FLAGS_FUNCTION(list_to_renderer_flags, Uint32, RENDERER_FLAGS)
#define BLEND_MODE_ENUM(E) \
E(none, SDL_BLENDMODE_NONE) \
@@ -42,9 +42,9 @@ NIF_ENUM_TO_ATOM_FUNCTION(blend_mode_to_atom, SDL_BlendMode, BLEND_MODE_ENUM)
F(horizontal, SDL_FLIP_HORIZONTAL) \
F(vertical, SDL_FLIP_VERTICAL)
-NIF_LIST_TO_FLAGS_FUNCTION(list_to_flip_flags, SDL_RendererFlip, FLIP_FLAGS)
+static NIF_LIST_TO_FLAGS_FUNCTION(list_to_flip_flags, SDL_RendererFlip, FLIP_FLAGS)
-int map_to_point(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Point* point)
+static int map_to_point(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Point* point)
{
ERL_NIF_TERM x, y;
@@ -61,7 +61,7 @@ int map_to_point(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Point* point)
return 1;
}
-int map_to_rect(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Rect* rect)
+static int map_to_rect(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Rect* rect)
{
ERL_NIF_TERM x, y, w, h;
diff --git a/c_src/sdl_texture.c b/c_src/sdl_texture.c
index 8606f37..425e0ec 100644
--- a/c_src/sdl_texture.c
+++ b/c_src/sdl_texture.c
@@ -14,9 +14,6 @@
#include "esdl2.h"
-NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_blend_mode, SDL_BlendMode)
-NIF_ENUM_TO_ATOM_FUNCTION_DECL(blend_mode_to_atom, SDL_BlendMode)
-
void dtor_Texture(ErlNifEnv* env, void* obj)
{
SDL_DestroyTexture(NIF_RES_GET(Texture, obj));
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c
index 96b3b3e..ef3647b 100644
--- a/c_src/sdl_window.c
+++ b/c_src/sdl_window.c
@@ -14,8 +14,6 @@
#include "esdl2.h"
-NIF_ATOM_TO_ENUM_FUNCTION_DECL(atom_to_bool, SDL_bool)
-
void dtor_Window(ErlNifEnv* env, void* obj)
{
SDL_DestroyWindow(NIF_RES_GET(Window, obj));
@@ -37,21 +35,21 @@ void dtor_Window(ErlNifEnv* env, void* obj)
F(foreign, SDL_WINDOW_FOREIGN) \
F(allow_high_dpi, SDL_WINDOW_ALLOW_HIGHDPI)
-NIF_LIST_TO_FLAGS_FUNCTION(list_to_window_flags, Uint32, WINDOW_FLAGS)
-NIF_FLAGS_TO_LIST_FUNCTION(window_flags_to_list, Uint32, WINDOW_FLAGS)
+static NIF_LIST_TO_FLAGS_FUNCTION(list_to_window_flags, Uint32, WINDOW_FLAGS)
+static NIF_FLAGS_TO_LIST_FUNCTION(window_flags_to_list, Uint32, WINDOW_FLAGS)
#define WINDOW_POS_ENUM(E) \
E(centered, SDL_WINDOWPOS_CENTERED) \
E(undefined, SDL_WINDOWPOS_UNDEFINED)
-NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_pos, int, WINDOW_POS_ENUM)
+static NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_pos, int, WINDOW_POS_ENUM)
#define WINDOW_FULLSCREEN_ENUM(E) \
E(fullscreen, SDL_WINDOW_FULLSCREEN) \
E(fullscreen_desktop, SDL_WINDOW_FULLSCREEN_DESKTOP) \
E(windowed, 0)
-NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_fullscreen, Uint32, WINDOW_FULLSCREEN_ENUM)
+static NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_fullscreen, Uint32, WINDOW_FULLSCREEN_ENUM)
// create_window
diff --git a/erlang.mk b/erlang.mk
index a4e1dbd..724e7d4 100644
--- a/erlang.mk
+++ b/erlang.mk
@@ -16,7 +16,7 @@
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
-ERLANG_MK_VERSION = 2016.01.12-1-ge0ebd0a
+ERLANG_MK_VERSION = 2016.01.12-2-g7a200f5
# Make 3.81 and 3.82 are deprecated.
@@ -5039,7 +5039,7 @@ $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES):
ebin/$(PROJECT).app:: $(ERLANG_MK_TMP)/last-makefile-change
endif
--include $(PROJECT).d
+include $(wildcard $(PROJECT).d)
ebin/$(PROJECT).app:: ebin/