Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for Linux and MOD Devices #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
15 changes: 8 additions & 7 deletions exported-code/gen_dsp/genlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <cstdio>
#include <cstring>

#ifndef MSP_ON_CLANG
# include <cmath>
#endif

#ifdef __APPLE__
# include <malloc/malloc.h>
#elif !defined(GEN_WINDOWS) // WIN32?
Expand All @@ -42,8 +38,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
# include "json.c"
# include "json_builder.c"
#endif
#include "json.h"
#include "json_builder.h"
#if GENLIB_USE_JSON
# include "json.h"
# include "json_builder.h"
#endif

// DATA_MAXIMUM_ELEMENTS * 8 bytes = 256 mb limit
#define DATA_MAXIMUM_ELEMENTS (33554432)
Expand Down Expand Up @@ -148,11 +146,13 @@ unsigned long systime_ticks(void)
return 0; // Gen code can deal with this
}

#ifdef GEN_WINDOWS
// NEED THIS FOR WINDOWS:
void *operator new(size_t size) { return sysmem_newptr(size); }
void *operator new[](size_t size) { return sysmem_newptr(size); }
void operator delete(void *p) throw() { sysmem_freeptr(p); }
void operator delete[](void *p) throw() { sysmem_freeptr(p); }
#endif

void *genlib_obtain_reference_from_string(const char *name)
{
Expand Down Expand Up @@ -385,6 +385,7 @@ void genlib_reset_complete(void *data)
{
}

#if GENLIB_USE_JSON
void genlib_build_json(CommonState *cself, json_value **jsonvalue, getparameter_method getmethod)
{
int i;
Expand Down Expand Up @@ -474,4 +475,4 @@ short genlib_setstate(CommonState *cself, const char *state, setparameter_method

return 0;
}

#endif // GENLIB_USE_JSON
20 changes: 17 additions & 3 deletions exported-code/gen_dsp/genlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

#include "genlib_common.h"

#ifndef MSP_ON_CLANG
# include <math.h>
#endif

//////////// genlib.h ////////////
// genlib.h -- max (gen~) version

Expand All @@ -50,9 +54,14 @@ typedef unsigned __INT64_TYPE__ uint64_t;
# endif
#endif

#ifdef GENLIB_USE_FLOAT32
#define inf (__FLT_MAX__)
#else
#define inf (__DBL_MAX__)
#endif

#define GEN_UINT_MAX (4294967295)
#define TWO_TO_32 (4294967296.0)
#define TWO_TO_32 (t_sample(4294967296.0))

#define C74_CONST const

Expand All @@ -62,6 +71,11 @@ typedef unsigned long long t_ptr_uint;
typedef long long t_ptr_int;
typedef double t_atom_float;
typedef t_ptr_uint t_getbytes_size;
#elif defined(__GNUC__) && !defined(MSP_ON_CLANG)
typedef uintptr_t t_ptr_uint;
typedef intptr_t t_ptr_int;
typedef float t_atom_float;
typedef t_ptr_uint t_getbytes_size;
#else
typedef unsigned long t_ptr_uint;
typedef long t_ptr_int;
Expand Down Expand Up @@ -139,8 +153,8 @@ extern "C" {
# define atan2(x,y) fasteratan2(x,y)
# define tanh(x) fastertanh(x)
# if !defined(GENLIB_USE_ARMMATH)
# define sin(x) fastersinfull(x);
# define cos(x) fastercosfull(x);
# define sin(x) fastersinfull(x)
# define cos(x) fastercosfull(x)
# endif
#endif // GENLIB_USE_FASTMATH

Expand Down
5 changes: 5 additions & 0 deletions exported-code/gen_dsp/genlib_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

#define DSP_GEN_MAX_SIGNALS 16

// json is enabled by default, but can be disabled if not needed
#ifndef GENLIB_USE_JSON
#define GENLIB_USE_JSON 1
#endif

#ifdef GENLIB_USE_FLOAT32
typedef float t_sample;
typedef float t_param;
Expand Down
7 changes: 2 additions & 5 deletions exported-code/gen_dsp/genlib_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include "genlib_common.h"
#include "genlib.h"

#ifndef MSP_ON_CLANG
# include <cmath>
#endif

//////////// genlib_ops.h ////////////

// system constants
Expand Down Expand Up @@ -64,6 +60,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
# else
# ifdef WIN32
# define __FLT_MIN__ (FLT_MIN)
# define __FLT_MAX__ (FLT_MAX)
# endif
# define GENLIB_IS_DENORM_FLOAT(v) ((v)!=0.&&fabs(v)<__FLT_MIN__)
# define GENLIB_FIX_DENORM_FLOAT(v) ((v)=GENLIB_IS_DENORM_FLOAT(v)?0.f:(v))
Expand Down Expand Up @@ -146,7 +143,7 @@ inline t_sample safepow(t_sample base, t_sample exponent) {
inline t_sample absdiff(t_sample a, t_sample b) { return fabs(a-b); }

#ifndef WIN32
inline t_sample exp2(t_sample v) { return pow(2., v); }
inline t_sample exp2(t_sample v) { return pow(t_sample(2.), v); }

inline t_sample trunc(t_sample v) {
t_sample epsilon = (v<0.0) * -2 * 1E-9 + 1E-9;
Expand Down
1 change: 0 additions & 1 deletion exported-code/gen_dsp/genlib_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include "genlib_common_win.h"

#if defined(ARM_MATH_CM4) || defined(ARM_MATH_CM7) // embedded ARM cortex support
#define GENLIB_NO_STDLIB
#define GENLIB_USE_ARMMATH
#define GENLIB_USE_FASTMATH
#endif // defined(ARM_MATH_CM4) || defined(ARM_MATH_CM7)
Expand Down