From 23b538b7c87e3fbc82051bb0f17498057243ea94 Mon Sep 17 00:00:00 2001 From: Christophe Mutricy Date: Sun, 6 Jan 2008 01:00:35 +0000 Subject: [PATCH] Fix compilation of galaktos: - there's still plenty of compile warning - I may have been a bit heavy handed on the de-'static inlin'ing --- modules/visualization/galaktos/Modules.am | 1 - .../visualization/galaktos/builtin_funcs.c | 206 --------------- .../visualization/galaktos/builtin_funcs.h | 239 +++++++++++++++--- modules/visualization/galaktos/custom_shape.c | 4 +- modules/visualization/galaktos/custom_shape.h | 4 +- modules/visualization/galaktos/custom_wave.c | 17 +- modules/visualization/galaktos/custom_wave.h | 13 +- modules/visualization/galaktos/eval.c | 2 +- modules/visualization/galaktos/eval.h | 2 +- modules/visualization/galaktos/init_cond.h | 1 + modules/visualization/galaktos/main.c | 8 +- .../visualization/galaktos/per_pixel_eqn.c | 10 +- .../visualization/galaktos/per_pixel_eqn.h | 3 +- modules/visualization/galaktos/splaytree.c | 62 ++--- modules/visualization/galaktos/splaytree.h | 26 +- 15 files changed, 282 insertions(+), 316 deletions(-) delete mode 100644 modules/visualization/galaktos/builtin_funcs.c diff --git a/modules/visualization/galaktos/Modules.am b/modules/visualization/galaktos/Modules.am index 75ee49e1b0..35d774681e 100644 --- a/modules/visualization/galaktos/Modules.am +++ b/modules/visualization/galaktos/Modules.am @@ -7,7 +7,6 @@ SOURCES_galaktos = plugin.c plugin.h \ param.c param.h param_types.h \ engine_vars.c engine_vars.h \ parser.c parser.h \ - builtin_funcs.c \ eval.c eval.h \ init_cond.c init_cond.h init_cond_types.h \ PCM.c PCM.h \ diff --git a/modules/visualization/galaktos/builtin_funcs.c b/modules/visualization/galaktos/builtin_funcs.c deleted file mode 100644 index 8c6cb5767d..0000000000 --- a/modules/visualization/galaktos/builtin_funcs.c +++ /dev/null @@ -1,206 +0,0 @@ -/***************************************************************************** - * builtin_funcs.c: - ***************************************************************************** - * Copyright (C) 2004 the VideoLAN team - * $Id$ - * - * Authors: Cyril Deguet - * code from projectM http://xmms-projectm.sourceforge.net - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - - -#include -#include -#include -/* Values to optimize the sigmoid function */ -#define R 32767 -#define RR 65534 - -static inline double int_wrapper(double * arg_list) { - - return floor(arg_list[0]); - -} - - -static inline double sqr_wrapper(double * arg_list) { - - return pow(2, arg_list[0]); -} - - -static inline double sign_wrapper(double * arg_list) { - - return -arg_list[0]; -} - -static inline double min_wrapper(double * arg_list) { - - if (arg_list[0] > arg_list[1]) - return arg_list[1]; - - return arg_list[0]; -} - -static inline double max_wrapper(double * arg_list) { - - if (arg_list[0] > arg_list[1]) - return arg_list[0]; - - return arg_list[1]; -} - -/* consult your AI book */ -static inline double sigmoid_wrapper(double * arg_list) { - return (RR / (1 + exp( -(((double)(arg_list[0])) * arg_list[1]) / R) - R)); -} - - -static inline double bor_wrapper(double * arg_list) { - - return (double)((int)arg_list[0] || (int)arg_list[1]); -} - -static inline double band_wrapper(double * arg_list) { - return (double)((int)arg_list[0] && (int)arg_list[1]); -} - -static inline double bnot_wrapper(double * arg_list) { - return (double)(!(int)arg_list[0]); -} - -static inline double if_wrapper(double * arg_list) { - - if ((int)arg_list[0] == 0) - return arg_list[2]; - return arg_list[1]; -} - - -static inline double rand_wrapper(double * arg_list) { - double l; - - // printf("RAND ARG:(%d)\n", (int)arg_list[0]); - l = (double)((rand()) % ((int)arg_list[0])); - //printf("VAL: %f\n", l); - return l; -} - -static inline double equal_wrapper(double * arg_list) { - - return (arg_list[0] == arg_list[1]); -} - - -static inline double above_wrapper(double * arg_list) { - - return (arg_list[0] > arg_list[1]); -} - - -static inline double below_wrapper(double * arg_list) { - - return (arg_list[0] < arg_list[1]); -} - -static inline double sin_wrapper(double * arg_list) { - return (sin (arg_list[0])); -} - - -static inline double cos_wrapper(double * arg_list) { - return (cos (arg_list[0])); -} - -static inline double tan_wrapper(double * arg_list) { - return (tan(arg_list[0])); -} - -static inline double asin_wrapper(double * arg_list) { - return (asin (arg_list[0])); -} - -static inline double acos_wrapper(double * arg_list) { - return (acos (arg_list[0])); -} - -static inline double atan_wrapper(double * arg_list) { - return (atan (arg_list[0])); -} - -static inline double atan2_wrapper(double * arg_list) { - return (atan2 (arg_list[0], arg_list[1])); -} - -static inline double pow_wrapper(double * arg_list) { - return (pow (arg_list[0], arg_list[1])); -} - -static inline double exp_wrapper(double * arg_list) { - return (exp(arg_list[0])); -} - -static inline double abs_wrapper(double * arg_list) { - return (fabs(arg_list[0])); -} - -static inline double log_wrapper(double *arg_list) { - return (log (arg_list[0])); -} - -static inline double log10_wrapper(double * arg_list) { - return (log10 (arg_list[0])); -} - -static inline double sqrt_wrapper(double * arg_list) { - return (sqrt (arg_list[0])); -} - - -static inline double nchoosek_wrapper(double * arg_list) { - unsigned long cnm = 1UL; - int i, f; - int n, m; - - n = (int)arg_list[0]; - m = (int)arg_list[1]; - - if (m*2 >n) m = n-m; - for (i=1 ; i <= m; n--, i++) - { - if ((f=n) % i == 0) - f /= i; - else cnm /= i; - cnm *= f; - } - return (double)cnm; -} - - -static inline double fact_wrapper(double * arg_list) { - - - int result = 1; - - int n = (int)arg_list[0]; - - while (n > 1) { - result = result * n; - n--; - } - return (double)result; -} diff --git a/modules/visualization/galaktos/builtin_funcs.h b/modules/visualization/galaktos/builtin_funcs.h index a1816845e2..8c6cb5767d 100644 --- a/modules/visualization/galaktos/builtin_funcs.h +++ b/modules/visualization/galaktos/builtin_funcs.h @@ -1,35 +1,206 @@ -/* Wrappers for all the builtin functions - The arg_list pointer is a list of doubles. Its - size is equal to the number of arguments the parameter - takes */ +/***************************************************************************** + * builtin_funcs.c: + ***************************************************************************** + * Copyright (C) 2004 the VideoLAN team + * $Id$ + * + * Authors: Cyril Deguet + * code from projectM http://xmms-projectm.sourceforge.net + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + + +#include +#include +#include +/* Values to optimize the sigmoid function */ +#define R 32767 +#define RR 65534 -inline double below_wrapper(double * arg_list); -inline double above_wrapper(double * arg_list); -inline double equal_wrapper(double * arg_list); -inline double if_wrapper(double * arg_list); -inline double bnot_wrapper(double * arg_list); -inline double rand_wrapper(double * arg_list); -inline double bor_wrapper(double * arg_list); -inline double band_wrapper(double * arg_list); -inline double sigmoid_wrapper(double * arg_list); -inline double max_wrapper(double * arg_list); -inline double min_wrapper(double * arg_list); -inline double sign_wrapper(double * arg_list); -inline double sqr_wrapper(double * arg_list); -inline double int_wrapper(double * arg_list); -inline double nchoosek_wrapper(double * arg_list); -inline double sin_wrapper(double * arg_list); -inline double cos_wrapper(double * arg_list); -inline double tan_wrapper(double * arg_list); -inline double fact_wrapper(double * arg_list); -inline double asin_wrapper(double * arg_list); -inline double acos_wrapper(double * arg_list); -inline double atan_wrapper(double * arg_list); -inline double atan2_wrapper(double * arg_list); - -inline double pow_wrapper(double * arg_list); -inline double exp_wrapper(double * arg_list); -inline double abs_wrapper(double * arg_list); -inline double log_wrapper(double *arg_list); -inline double log10_wrapper(double * arg_list); -inline double sqrt_wrapper(double * arg_list); +static inline double int_wrapper(double * arg_list) { + + return floor(arg_list[0]); + +} + + +static inline double sqr_wrapper(double * arg_list) { + + return pow(2, arg_list[0]); +} + + +static inline double sign_wrapper(double * arg_list) { + + return -arg_list[0]; +} + +static inline double min_wrapper(double * arg_list) { + + if (arg_list[0] > arg_list[1]) + return arg_list[1]; + + return arg_list[0]; +} + +static inline double max_wrapper(double * arg_list) { + + if (arg_list[0] > arg_list[1]) + return arg_list[0]; + + return arg_list[1]; +} + +/* consult your AI book */ +static inline double sigmoid_wrapper(double * arg_list) { + return (RR / (1 + exp( -(((double)(arg_list[0])) * arg_list[1]) / R) - R)); +} + + +static inline double bor_wrapper(double * arg_list) { + + return (double)((int)arg_list[0] || (int)arg_list[1]); +} + +static inline double band_wrapper(double * arg_list) { + return (double)((int)arg_list[0] && (int)arg_list[1]); +} + +static inline double bnot_wrapper(double * arg_list) { + return (double)(!(int)arg_list[0]); +} + +static inline double if_wrapper(double * arg_list) { + + if ((int)arg_list[0] == 0) + return arg_list[2]; + return arg_list[1]; +} + + +static inline double rand_wrapper(double * arg_list) { + double l; + + // printf("RAND ARG:(%d)\n", (int)arg_list[0]); + l = (double)((rand()) % ((int)arg_list[0])); + //printf("VAL: %f\n", l); + return l; +} + +static inline double equal_wrapper(double * arg_list) { + + return (arg_list[0] == arg_list[1]); +} + + +static inline double above_wrapper(double * arg_list) { + + return (arg_list[0] > arg_list[1]); +} + + +static inline double below_wrapper(double * arg_list) { + + return (arg_list[0] < arg_list[1]); +} + +static inline double sin_wrapper(double * arg_list) { + return (sin (arg_list[0])); +} + + +static inline double cos_wrapper(double * arg_list) { + return (cos (arg_list[0])); +} + +static inline double tan_wrapper(double * arg_list) { + return (tan(arg_list[0])); +} + +static inline double asin_wrapper(double * arg_list) { + return (asin (arg_list[0])); +} + +static inline double acos_wrapper(double * arg_list) { + return (acos (arg_list[0])); +} + +static inline double atan_wrapper(double * arg_list) { + return (atan (arg_list[0])); +} + +static inline double atan2_wrapper(double * arg_list) { + return (atan2 (arg_list[0], arg_list[1])); +} + +static inline double pow_wrapper(double * arg_list) { + return (pow (arg_list[0], arg_list[1])); +} + +static inline double exp_wrapper(double * arg_list) { + return (exp(arg_list[0])); +} + +static inline double abs_wrapper(double * arg_list) { + return (fabs(arg_list[0])); +} + +static inline double log_wrapper(double *arg_list) { + return (log (arg_list[0])); +} + +static inline double log10_wrapper(double * arg_list) { + return (log10 (arg_list[0])); +} + +static inline double sqrt_wrapper(double * arg_list) { + return (sqrt (arg_list[0])); +} + + +static inline double nchoosek_wrapper(double * arg_list) { + unsigned long cnm = 1UL; + int i, f; + int n, m; + + n = (int)arg_list[0]; + m = (int)arg_list[1]; + + if (m*2 >n) m = n-m; + for (i=1 ; i <= m; n--, i++) + { + if ((f=n) % i == 0) + f /= i; + else cnm /= i; + cnm *= f; + } + return (double)cnm; +} + + +static inline double fact_wrapper(double * arg_list) { + + + int result = 1; + + int n = (int)arg_list[0]; + + while (n > 1) { + result = result * n; + n--; + } + return (double)result; +} diff --git a/modules/visualization/galaktos/custom_shape.c b/modules/visualization/galaktos/custom_shape.c index 802202e488..c2f16fca48 100644 --- a/modules/visualization/galaktos/custom_shape.c +++ b/modules/visualization/galaktos/custom_shape.c @@ -519,7 +519,7 @@ custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag) { return custom_shape; } -static inline void evalCustomShapeInitConditions() { +void evalCustomShapeInitConditions() { splay_traverse(eval_custom_shape_init_conds, active_preset->custom_shape_tree); } @@ -588,7 +588,7 @@ void load_unspec_init_cond_shape(param_t * param) { /* Interface function. Makes another custom shape the current concern for per frame / point equations */ -static inline custom_shape_t * nextCustomShape() { +custom_shape_t * nextCustomShape() { if ((interface_shape = splay_find(&cwave_interface_id, active_preset->custom_shape_tree)) == NULL) { cwave_interface_id = 0; diff --git a/modules/visualization/galaktos/custom_shape.h b/modules/visualization/galaktos/custom_shape.h index 4e4d8a8bd8..f07a5b4502 100644 --- a/modules/visualization/galaktos/custom_shape.h +++ b/modules/visualization/galaktos/custom_shape.h @@ -9,6 +9,6 @@ void free_custom_shape(custom_shape_t * custom_shape); custom_shape_t * new_custom_shape(int id); custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag); void load_unspecified_init_conds_shape(custom_shape_t * custom_shape); -inline void evalCustomShapeInitConditions(); -inline custom_shape_t * nextCustomShape(); +void evalCustomShapeInitConditions(); +custom_shape_t * nextCustomShape(); #endif diff --git a/modules/visualization/galaktos/custom_wave.c b/modules/visualization/galaktos/custom_wave.c index d9a25bc79a..8ccb9573cf 100644 --- a/modules/visualization/galaktos/custom_wave.c +++ b/modules/visualization/galaktos/custom_wave.c @@ -604,18 +604,9 @@ custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag) { return custom_wave; } -static inline void evalCustomWaveInitConditions() { - splay_traverse(eval_custom_wave_init_conds, active_preset->custom_wave_tree); -} - -static inline void eval_custom_wave_init_conds(custom_wave_t * custom_wave) { - splay_traverse(eval_init_cond, custom_wave->init_cond_tree); - splay_traverse(eval_init_cond, custom_wave->per_frame_init_eqn_tree); -} - /* Interface function. Makes another custom wave the current concern for per frame / point equations */ -static inline custom_wave_t * nextCustomWave() { +custom_wave_t * nextCustomWave() { if ((interface_wave = splay_find(&interface_id, active_preset->custom_wave_tree)) == NULL) { interface_id = 0; @@ -630,7 +621,7 @@ static inline custom_wave_t * nextCustomWave() { } -static inline void evalPerPointEqns() { +void evalPerPointEqns() { int x; @@ -740,3 +731,7 @@ void load_unspec_init_cond(param_t * param) { } } + +void evalCustomWaveInitConditions() { + splay_traverse(eval_custom_wave_init_conds, active_preset->custom_wave_tree); +} diff --git a/modules/visualization/galaktos/custom_wave.h b/modules/visualization/galaktos/custom_wave.h index af330bf5ef..113f749102 100644 --- a/modules/visualization/galaktos/custom_wave.h +++ b/modules/visualization/galaktos/custom_wave.h @@ -4,6 +4,9 @@ #include "expr_types.h" #include "custom_wave_types.h" #include "preset_types.h" +#include "splaytree.h" +#include "init_cond.h" + void free_custom_wave(custom_wave_t * custom_wave); custom_wave_t * new_custom_wave(int id); @@ -14,9 +17,13 @@ void reset_per_point_eqn_array(custom_wave_t * custom_wave); custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag); int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom_wave); -inline void evalCustomWaveInitConditions(); -inline void evalPerPointEqns(); -inline custom_wave_t * nextCustomWave(); +void evalCustomWaveInitConditions(); +void evalPerPointEqns(); +custom_wave_t * nextCustomWave(); void load_unspecified_init_conds(custom_wave_t * custom_wave); +static inline void eval_custom_wave_init_conds(custom_wave_t * custom_wave) { + splay_traverse(eval_init_cond, custom_wave->init_cond_tree); + splay_traverse(eval_init_cond, custom_wave->per_frame_init_eqn_tree); +} #endif diff --git a/modules/visualization/galaktos/eval.c b/modules/visualization/galaktos/eval.c index 5ad2c0dc02..601df08466 100644 --- a/modules/visualization/galaktos/eval.c +++ b/modules/visualization/galaktos/eval.c @@ -48,7 +48,7 @@ static inline double eval_prefun_expr(prefun_expr_t * prefun_expr); static inline double eval_val_expr(val_expr_t * val_expr); -static inline double eval_gen_expr(gen_expr_t * gen_expr) { +double eval_gen_expr(gen_expr_t * gen_expr) { double l; if (gen_expr == NULL) diff --git a/modules/visualization/galaktos/eval.h b/modules/visualization/galaktos/eval.h index 60ae143d63..a48ccccbe6 100644 --- a/modules/visualization/galaktos/eval.h +++ b/modules/visualization/galaktos/eval.h @@ -24,7 +24,7 @@ //#define EVAL_DEBUG -inline double eval_gen_expr(gen_expr_t * gen_expr); +double eval_gen_expr(gen_expr_t * gen_expr); inline gen_expr_t * opt_gen_expr(gen_expr_t * gen_expr, int ** param_list); gen_expr_t * const_to_expr(double val); diff --git a/modules/visualization/galaktos/init_cond.h b/modules/visualization/galaktos/init_cond.h index 34cbd3025c..40bf8e4951 100644 --- a/modules/visualization/galaktos/init_cond.h +++ b/modules/visualization/galaktos/init_cond.h @@ -2,6 +2,7 @@ #define INIT_COND_H #define INIT_COND_DEBUG 0 #include "param_types.h" +#include "init_cond_types.h" #include "splaytree_types.h" void eval_init_cond(init_cond_t * init_cond); diff --git a/modules/visualization/galaktos/main.c b/modules/visualization/galaktos/main.c index deea6f8d99..50be639e59 100644 --- a/modules/visualization/galaktos/main.c +++ b/modules/visualization/galaktos/main.c @@ -43,6 +43,7 @@ #include "custom_wave.h" #include "custom_shape_types.h" #include "custom_shape.h" +#include "splaytree.h" //#include // Forward declarations @@ -116,6 +117,12 @@ double **origy; char *buffer; //XXX + +static inline int isPerPixelEqn(int op) { + + return active_preset->per_pixel_flag[op]; + +} int galaktos_init( galaktos_thread_t *p_thread ) { init_per_pixel_matrices(); @@ -1576,4 +1583,3 @@ void render_texture_to_studio() glPopMatrix(); } - diff --git a/modules/visualization/galaktos/per_pixel_eqn.c b/modules/visualization/galaktos/per_pixel_eqn.c index bc9656f828..3cd0c016aa 100644 --- a/modules/visualization/galaktos/per_pixel_eqn.c +++ b/modules/visualization/galaktos/per_pixel_eqn.c @@ -52,7 +52,7 @@ extern int mesh_j; /* Evaluates a per pixel equation */ -static inline void evalPerPixelEqn(per_pixel_eqn_t * per_pixel_eqn) { +void evalPerPixelEqn(per_pixel_eqn_t * per_pixel_eqn) { double ** param_matrix = NULL; gen_expr_t * eqn_ptr = NULL; @@ -94,7 +94,7 @@ static inline void evalPerPixelEqn(per_pixel_eqn_t * per_pixel_eqn) { per_pixel_eqn->param->matrix_flag = 1; } -static inline void evalPerPixelEqns() { +void evalPerPixelEqns() { /* Evaluate all per pixel equations using splay traversal */ splay_traverse(evalPerPixelEqn, active_preset->per_pixel_eqn_tree); @@ -211,12 +211,6 @@ void free_per_pixel_eqn(per_pixel_eqn_t * per_pixel_eqn) { return; } -static inline int isPerPixelEqn(int op) { - - return active_preset->per_pixel_flag[op]; - -} - static inline int resetPerPixelEqnFlags(preset_t * preset) { int i; diff --git a/modules/visualization/galaktos/per_pixel_eqn.h b/modules/visualization/galaktos/per_pixel_eqn.h index 332ef156aa..6861735814 100644 --- a/modules/visualization/galaktos/per_pixel_eqn.h +++ b/modules/visualization/galaktos/per_pixel_eqn.h @@ -5,8 +5,7 @@ #include "preset_types.h" #define PER_PIXEL_EQN_DEBUG 0 -inline void evalPerPixelEqns(); -inline int isPerPixelEqn(int index); +void evalPerPixelEqns(); int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, struct PRESET_T * preset); void free_per_pixel_eqn(per_pixel_eqn_t * per_pixel_eqn); per_pixel_eqn_t * new_per_pixel_eqn(int index, param_t * param, gen_expr_t * gen_expr); diff --git a/modules/visualization/galaktos/splaytree.c b/modules/visualization/galaktos/splaytree.c index aaeffe3282..0417fda288 100644 --- a/modules/visualization/galaktos/splaytree.c +++ b/modules/visualization/galaktos/splaytree.c @@ -83,19 +83,19 @@ -static inline splaynode_t * splay (void * key, splaynode_t * t, int * match_type, int (*compare)()); -static inline int free_splaynode(splaynode_t * splaynode, void (*free_key)()); -static inline void splay_traverse_helper (void (*func_ptr)(), splaynode_t * splaynode); -static inline splaynode_t * splay_delete_helper(void * key, splaynode_t * t, int (*compare)(), void (*free_key)()); -static inline void splay_find_above_min_helper(void * max_key, void ** closest_key, splaynode_t * root, int (*compare)()); -static inline void splay_find_below_max_helper(void * max_key, void ** closest_key, splaynode_t * root, int (*compare)()); -static inline splaynode_t * new_splaynode(int type, void * key, void * data); -static inline int splay_insert_node(splaynode_t * splaynode, splaytree_t * splaytree); -static inline int splay_rec_size(splaynode_t * splaynode); +splaynode_t * splay (void * key, splaynode_t * t, int * match_type, int (*compare)()); +int free_splaynode(splaynode_t * splaynode, void (*free_key)()); +void splay_traverse_helper (void (*func_ptr)(), splaynode_t * splaynode); +splaynode_t * splay_delete_helper(void * key, splaynode_t * t, int (*compare)(), void (*free_key)()); +void splay_find_above_min_helper(void * max_key, void ** closest_key, splaynode_t * root, int (*compare)()); +void splay_find_below_max_helper(void * max_key, void ** closest_key, splaynode_t * root, int (*compare)()); +splaynode_t * new_splaynode(int type, void * key, void * data); +int splay_insert_node(splaynode_t * splaynode, splaytree_t * splaytree); +int splay_rec_size(splaynode_t * splaynode); /* Creates a splay tree given a compare key function, copy key function, and free key function. Ah yes, the wonders of procedural programming */ -static inline splaytree_t * create_splaytree(int (*compare)(), void * (*copy_key)(), void (*free_key)()) { +splaytree_t * create_splaytree(int (*compare)(), void * (*copy_key)(), void (*free_key)()) { splaytree_t * splaytree; @@ -114,7 +114,7 @@ static inline splaytree_t * create_splaytree(int (*compare)(), void * (*copy_key } /* Destroys a splay tree */ -static inline int destroy_splaytree(splaytree_t * splaytree) { +int destroy_splaytree(splaytree_t * splaytree) { /* Null argument check */ if (splaytree == NULL) @@ -132,7 +132,7 @@ static inline int destroy_splaytree(splaytree_t * splaytree) { } /* Recursively free all the splaynodes */ -static inline int free_splaynode(splaynode_t * splaynode, void (*free_key)()) { +int free_splaynode(splaynode_t * splaynode, void (*free_key)()) { /* Ok if this happens, a recursive base case */ if (splaynode == NULL) @@ -159,7 +159,7 @@ static inline int free_splaynode(splaynode_t * splaynode, void (*free_key)()) { } /* Traverses the entire splay tree with the given function func_ptr */ -static inline void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree) { +void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree) { /* Null argument check */ @@ -175,7 +175,7 @@ static inline void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree) { } /* Helper function to traverse the entire splaytree */ -static inline void splay_traverse_helper (void (*func_ptr)(), splaynode_t * splaynode) { +void splay_traverse_helper (void (*func_ptr)(), splaynode_t * splaynode) { /* Normal if this happens, its a base case of recursion */ if (splaynode == NULL) @@ -205,7 +205,7 @@ static inline void splay_traverse_helper (void (*func_ptr)(), splaynode_t * spla } /* Find the node corresponding to the given key in splaytree, return its data pointer */ -static inline void * splay_find(void * key, splaytree_t * splaytree) { +void * splay_find(void * key, splaytree_t * splaytree) { splaynode_t * splaynode; int match_type; @@ -245,7 +245,7 @@ static inline void * splay_find(void * key, splaytree_t * splaytree) { } /* Gets the splaynode that the given key points to */ -static inline splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree) { +splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree) { splaynode_t * splaynode; int match_type; @@ -272,7 +272,7 @@ static inline splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree } /* Finds the desired node, and changes the tree such that it is the root */ -static inline splaynode_t * splay (void * key, splaynode_t * t, int * match_type, int (*compare)()) { +splaynode_t * splay (void * key, splaynode_t * t, int * match_type, int (*compare)()) { /* Simple top down splay, not requiring key to be in the tree t. What it does is described above. */ @@ -326,7 +326,7 @@ static inline splaynode_t * splay (void * key, splaynode_t * t, int * match_type /* Deletes a splay node from a splay tree. If the node doesn't exist then nothing happens */ -static inline int splay_delete(void * key, splaytree_t * splaytree) { +int splay_delete(void * key, splaytree_t * splaytree) { splaynode_t * splaynode; @@ -342,7 +342,7 @@ static inline int splay_delete(void * key, splaytree_t * splaytree) { } /* Deletes a splay node */ -static inline splaynode_t * splay_delete_helper(void * key, splaynode_t * splaynode, int (*compare)(), void (*free_key)()) { +splaynode_t * splay_delete_helper(void * key, splaynode_t * splaynode, int (*compare)(), void (*free_key)()) { splaynode_t * new_root; int match_type; @@ -381,7 +381,7 @@ static inline splaynode_t * splay_delete_helper(void * key, splaynode_t * splayn } /* Create a new splay node type */ -static inline splaynode_t * new_splaynode(int type, void * key, void * data) { +splaynode_t * new_splaynode(int type, void * key, void * data) { splaynode_t * splaynode; /* Argument checks */ if (data == NULL) @@ -403,7 +403,7 @@ static inline splaynode_t * new_splaynode(int type, void * key, void * data) { } /* Inserts a link into the splay tree */ -static inline int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * splaytree) { +int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * splaytree) { splaynode_t * splaynode, * data_node; void * key_clone; @@ -440,7 +440,7 @@ static inline int splay_insert_link(void * alias_key, void * orig_key, splaytree } /* Inserts 'data' into the 'splaytree' paired with the passed 'key' */ -static inline int splay_insert(void * data, void * key, splaytree_t * splaytree) { +int splay_insert(void * data, void * key, splaytree_t * splaytree) { splaynode_t * splaynode; void * key_clone; @@ -475,7 +475,7 @@ static inline int splay_insert(void * data, void * key, splaytree_t * splaytree) } /* Helper function to insert splaynodes into the splaytree */ -static inline int splay_insert_node(splaynode_t * splaynode, splaytree_t * splaytree) { +int splay_insert_node(splaynode_t * splaynode, splaytree_t * splaytree) { int match_type; int cmpval; void * key; @@ -528,7 +528,7 @@ static inline int splay_insert_node(splaynode_t * splaynode, splaytree_t * splay } /* Returns the 'maximum' key that is less than the given key in the splaytree */ -static inline void * splay_find_below_max(void * key, splaytree_t * splaytree) { +void * splay_find_below_max(void * key, splaytree_t * splaytree) { void * closest_key; @@ -549,7 +549,7 @@ static inline void * splay_find_below_max(void * key, splaytree_t * splaytree) { /* Returns the 'minimum' key that is greater than the given key in the splaytree */ -static inline void * splay_find_above_min(void * key, splaytree_t * splaytree) { +void * splay_find_above_min(void * key, splaytree_t * splaytree) { void * closest_key; @@ -571,7 +571,7 @@ static inline void * splay_find_above_min(void * key, splaytree_t * splaytree) { } /* Helper function */ -static inline void splay_find_below_max_helper(void * min_key, void ** closest_key, splaynode_t * root, int (*compare)()) { +void splay_find_below_max_helper(void * min_key, void ** closest_key, splaynode_t * root, int (*compare)()) { /* Empty root, return*/ if (root == NULL) @@ -608,7 +608,7 @@ static inline void splay_find_below_max_helper(void * min_key, void ** closest_k } /* Helper function */ -static inline void splay_find_above_min_helper(void * max_key, void ** closest_key, splaynode_t * root, int (*compare)()) { +void splay_find_above_min_helper(void * max_key, void ** closest_key, splaynode_t * root, int (*compare)()) { /* Empty root, stop */ if (root == NULL) @@ -644,7 +644,7 @@ static inline void splay_find_above_min_helper(void * max_key, void ** closest_k } /* Find the minimum entry of the splay tree */ -static inline void * splay_find_min(splaytree_t * t) { +void * splay_find_min(splaytree_t * t) { splaynode_t * splaynode; @@ -663,7 +663,7 @@ static inline void * splay_find_min(splaytree_t * t) { /* Find the maximum entry of the splay tree */ -static inline void * splay_find_max(splaytree_t * t) { +void * splay_find_max(splaytree_t * t) { splaynode_t * splaynode; @@ -681,7 +681,7 @@ static inline void * splay_find_max(splaytree_t * t) { return splaynode->data; } -static inline int splay_size(splaytree_t * t) { +int splay_size(splaytree_t * t) { if (t == NULL) return 0; @@ -692,7 +692,7 @@ static inline int splay_size(splaytree_t * t) { } -static inline int splay_rec_size(splaynode_t * splaynode) { +int splay_rec_size(splaynode_t * splaynode) { if (!splaynode) return 0; diff --git a/modules/visualization/galaktos/splaytree.h b/modules/visualization/galaktos/splaytree.h index 856ea2cd8a..4af6ac3418 100644 --- a/modules/visualization/galaktos/splaytree.h +++ b/modules/visualization/galaktos/splaytree.h @@ -8,17 +8,17 @@ -inline void * splay_find(void * key, splaytree_t * t); -inline int splay_insert(void * data, void * key, splaytree_t * t); -inline int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * splaytree); -inline int splay_delete(void * key, splaytree_t * splaytree); -inline int splay_size(splaytree_t * t); -inline splaytree_t * create_splaytree(int (*compare)(), void * (*copy_key)(), void (*free_key)()); -inline int destroy_splaytree(splaytree_t * splaytree); -inline void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree); -inline splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree); -inline void * splay_find_above_min(void * key, splaytree_t * root); -inline void * splay_find_below_max(void * key, splaytree_t * root); -inline void * splay_find_min(splaytree_t * t); -inline void * splay_find_max(splaytree_t * t); +void * splay_find(void * key, splaytree_t * t); +int splay_insert(void * data, void * key, splaytree_t * t); +int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * splaytree); +int splay_delete(void * key, splaytree_t * splaytree); +int splay_size(splaytree_t * t); +splaytree_t * create_splaytree(int (*compare)(), void * (*copy_key)(), void (*free_key)()); +int destroy_splaytree(splaytree_t * splaytree); +void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree); +splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree); +void * splay_find_above_min(void * key, splaytree_t * root); +void * splay_find_below_max(void * key, splaytree_t * root); +void * splay_find_min(splaytree_t * t); +void * splay_find_max(splaytree_t * t); #endif -- 2.39.2