Commit 23b538b7 authored by Christophe Mutricy's avatar Christophe Mutricy

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 
parent 32c1dee5
......@@ -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 \
......
/*****************************************************************************
* builtin_funcs.c:
*****************************************************************************
* Copyright (C) 2004 the VideoLAN team
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
* 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 <math.h>
#include <stdlib.h>
#include <stdio.h>
/* 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;
}
/* 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 <asmax@videolan.org>
* 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 <math.h>
#include <stdlib.h>
#include <stdio.h>
/* 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;
}
......@@ -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;
......
......@@ -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
......@@ -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);
}
......@@ -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
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
......@@ -43,6 +43,7 @@
#include "custom_wave.h"
#include "custom_shape_types.h"
#include "custom_shape.h"
#include "splaytree.h"
//#include <dmalloc.h>
// 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();
}
......@@ -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;
......
......@@ -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);
......
......@@ -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) {
}