clean up macro function naming

parent 0985614d
Version 1.5 04/09/2019
Updated formatting of function macros to binary_c coding standards.
Version 1.3 Monday 01/04/2019
No April fool! I've rewritten the code to be more
......
......@@ -12,7 +12,7 @@ C_SRC := $(wildcard *.c)
OBJECTS := $(C_SRC:.c=.o)
#OBJECTS := rinterpolate.o rinterpolate-debug.o
LIBRINTERPOLATE_ARCHFLAGS ?= -march=native -mtune=native
CFLAGS := -fPIC -O2 -g $(LIBRINTERPOLATE_ARCHFLAGS) -Wall -Wstrict-prototypes -ffast-math -D__RINTERPOLATE__ -D__RINTERPOLATE_BUILD_BUILD_FLAGS__ $(COPTFLAGS)
CFLAGS := -fPIC -O2 -g $(LIBRINTERPOLATE_ARCHFLAGS) -Wall -Wstrict-prototypes -ffast-math -D__RINTERPOLATE__ -D__RINTERPOLATE_BUILD_BUILD_FLAGS__ $(COPTFLAGS)
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
......
......@@ -21,9 +21,9 @@
* rinterpolate's macros
*************************************************************/
#define RINTERPOLATE_VERSION "1.4"
#define RINTERPOLATE_VERSION "1.5"
#define RINTERPOLATE_MAJOR_VERSION 1
#define RINTERPOLATE_MINOR_VERSION 4
#define RINTERPOLATE_MINOR_VERSION 5
/* types */
typedef unsigned int rinterpolate_counter_t;
......@@ -61,9 +61,9 @@ typedef unsigned int rinterpolate_Boolean_t;
/*
* Use standard *alloc
*/
#define RINTERPOLATE_MALLOC(A) malloc(A)
#define RINTERPOLATE_CALLOC(A,B) calloc((A),(B))
#define RINTERPOLATE_REALLOC(A,B) realloc((A),(B))
#define Rinterpolate_malloc(A) malloc(A)
#define Rinterpolate_calloc(A,B) calloc((A),(B))
#define Rinterpolate_realloc(A,B) realloc((A),(B))
/*
* In some places I have different algorithms based on either
......@@ -87,7 +87,7 @@ typedef unsigned int rinterpolate_Boolean_t;
#define RINTERPOLATE_CACHE_LINE (table->n+table->d)
/* pointer to cache result A */
#define RINTERPOLATE_CACHE_PARAM(A) (table->cache+RINTERPOLATE_CACHE_LINE*(A))
#define Rinterpolate_cache_param(A) (table->cache+RINTERPOLATE_CACHE_LINE*(A))
/* pointer to the location of cache result A */
#define RINTERPOLATE_CACHE_RESULT(A) (table->cache+RINTERPOLATE_CACHE_LINE*(A)+table->n)
......
......@@ -20,11 +20,11 @@ rinterpolate_counter_t rinterpolate_add_new_table(
rinterpolate_data->number_of_interpolation_tables++;
rinterpolate_data->tables =
RINTERPOLATE_REALLOC(rinterpolate_data->tables,
Rinterpolate_realloc(rinterpolate_data->tables,
sizeof(struct rinterpolate_table_t *) * rinterpolate_data->number_of_interpolation_tables);
struct rinterpolate_table_t * table =
RINTERPOLATE_MALLOC(sizeof(struct rinterpolate_table_t));
Rinterpolate_malloc(sizeof(struct rinterpolate_table_t));
rinterpolate_data->tables[table_number] = table;
/*
......
......@@ -16,7 +16,7 @@ void rinterpolate_alloc_cacheline(struct rinterpolate_table_t * RESTRICT const t
* Allocate cache space for this interpolation table
*/
table->cache =
RINTERPOLATE_CALLOC(table->line_length*table->cache_length,
Rinterpolate_calloc(table->line_length*table->cache_length,
sizeof(rinterpolate_float_t));
#ifdef RINTERPOLATE_ALLOC_CHECKS
......
......@@ -22,7 +22,7 @@ rinterpolate_counter_t rinterpolate_alloc_dataspace(struct rinterpolate_data_t *
/*
* Allocate space
*/
*r = RINTERPOLATE_CALLOC(1,sizeof(struct rinterpolate_data_t));
*r = Rinterpolate_calloc(1,sizeof(struct rinterpolate_data_t));
return 0;
}
}
......
......@@ -7,15 +7,15 @@
void rinterpolate_alloc_hypertable(struct rinterpolate_table_t * RESTRICT const table)
{
/* make space for hypertable */
table->hypertable = RINTERPOLATE_MALLOC(sizeof(struct rinterpolate_hypertable_t));
table->hypertable = Rinterpolate_malloc(sizeof(struct rinterpolate_hypertable_t));
#ifdef RINTERPOLATE_DEBUG
Rinterpolate_print("Interpolate: memory allocation\n");FLUSH;
#endif
table->hypertable->table = table;
table->hypertable->data = RINTERPOLATE_MALLOC(table->hypertable_length*table->line_length_sizeof);
table->hypertable->f = RINTERPOLATE_MALLOC(table->n_float_sizeof);
table->hypertable->sum = RINTERPOLATE_CALLOC(1,table->sum_sizeof);
table->hypertable->data = Rinterpolate_malloc(table->hypertable_length*table->line_length_sizeof);
table->hypertable->f = Rinterpolate_malloc(table->n_float_sizeof);
table->hypertable->sum = Rinterpolate_calloc(1,table->sum_sizeof);
#ifdef RINTERPOLATE_DEBUG
Rinterpolate_print("MALLOC data at %p size %ld, f at %p size %ld, sum at %p size %ld\n",
......
......@@ -3,7 +3,7 @@
void rinterpolate_alloc_varcount(struct rinterpolate_table_t * RESTRICT const table)
{
table->varcount = RINTERPOLATE_CALLOC(table->n,sizeof(rinterpolate_counter_t));
table->varcount = Rinterpolate_calloc(table->n,sizeof(rinterpolate_counter_t));
#ifdef RINTERPOLATE_ALLOC_CHECKS
if(unlikely(table->varcount==NULL))
{
......
......@@ -47,20 +47,20 @@ rinterpolate_Boolean_t rinterpolate_check_cache(
{
Rinterpolate_print("%g%s",*(x+m),m==(table->n-1) ? " }\n":",");
}
rinterpolate_float_t * cl = RINTERPOLATE_CACHE_PARAM(iline);
rinterpolate_float_t * cl = Rinterpolate_cache_param(iline);
Rinterpolate_print(" c={ ");
for(m=0;m<table->n;m++)
{
Rinterpolate_print("%g%s",*(cl+m),m==(table->n-1) ? " }\n":",");
}
Rinterpolate_print("memcmp = %d\n",
memcmp(RINTERPOLATE_CACHE_PARAM(iline),x,table->n_float_sizeof));
memcmp(Rinterpolate_cache_param(iline),x,table->n_float_sizeof));
}
#endif//RINTERPOLATE_DEBUG
match = (memcmp(RINTERPOLATE_CACHE_PARAM(iline),x,table->n_float_sizeof)==0) ? TRUE : FALSE;
match = (memcmp(Rinterpolate_cache_param(iline),x,table->n_float_sizeof)==0) ? TRUE : FALSE;
#else // RINTERPOLATE_CACHE_USE_MEMCMP
rinterpolate_counter_t m;
rinterpolate_float_t * cacheline = RINTERPOLATE_CACHE_PARAM(iline);
rinterpolate_float_t * cacheline = Rinterpolate_cache_param(iline);
match = TRUE;
Rinterpolate_print("start of for loop\n");
for(m=0; m<table->n; m++)
......
......@@ -5,7 +5,6 @@
/*
* macros which depend on the compiler, for librinterpolate
*/
#ifndef Autotype
#if defined __GNUC__ && __GNUC__ > 4 && __GNUC_MINOR__ > 9
#define Autotype(X) __auto_type
......
......@@ -10,7 +10,7 @@ void rinterpolate_make_presearch(struct rinterpolate_table_t * RESTRICT const ta
/* make table for presearch data for n columns */
table->presearch =
RINTERPOLATE_MALLOC(table->n*sizeof(rinterpolate_float_t *));
Rinterpolate_malloc(table->n*sizeof(rinterpolate_float_t *));
table->presearch_n = table->n;
#ifdef RINTERPOLATE_ALLOC_CHECKS
......@@ -27,7 +27,7 @@ void rinterpolate_make_presearch(struct rinterpolate_table_t * RESTRICT const ta
for(j=0;j<table->n;j++)
{
table->presearch[j] =
RINTERPOLATE_MALLOC(table->varcount[j]*
Rinterpolate_malloc(table->varcount[j]*
sizeof(rinterpolate_float_t));
rinterpolate_float_t * pline = table->presearch[j];
......
......@@ -6,7 +6,7 @@ void rinterpolate_make_steps(struct rinterpolate_table_t * RESTRICT const table)
/*
* First time with this table: Find the variable steps
*/
table->steps = RINTERPOLATE_CALLOC(table->n,sizeof(rinterpolate_counter_t));
table->steps = Rinterpolate_calloc(table->n,sizeof(rinterpolate_counter_t));
#ifdef RINTERPOLATE_ALLOC_CHECKS
if(unlikely(table->steps==NULL))
......
......@@ -10,8 +10,8 @@ struct rinterpolate_data_t * rinterpolate(
const rinterpolate_counter_t n, // the number of parameters (i.e. dimensions)
const rinterpolate_counter_t d, // the number of data items
const rinterpolate_counter_t l, // the number of lines of data
const rinterpolate_float_t * RESTRICT x, // the values of the parameters
rinterpolate_float_t * RESTRICT r, // the result of the interpolation
const rinterpolate_float_t * RESTRICT const x, // the values of the parameters
rinterpolate_float_t * RESTRICT const r, // the result of the interpolation
const rinterpolate_counter_t cache_length // tells us to use the cache, or not
);
......
......@@ -15,7 +15,7 @@ void rinterpolate_store_cache(struct rinterpolate_table_t * RESTRICT const table
table->cache_spin_line % table->cache_length;
/* insert data : NB memcpy is definitely faster than a loop */
memcpy(RINTERPOLATE_CACHE_PARAM(table->cache_spin_line),x,table->n_float_sizeof);
memcpy(Rinterpolate_cache_param(table->cache_spin_line),x,table->n_float_sizeof);
memcpy(RINTERPOLATE_CACHE_RESULT(table->cache_spin_line),r,table->d_float_sizeof);
}
#endif // RINTERPOLATE_CACHE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment