Update of example Extern_C

master
Gwenaël Delaval 9 years ago
parent 3b81368074
commit 0a65ffc8e2

@ -7,5 +7,5 @@ This example show how to import an external function written in C in an Heptagon
To make it work:
heptc mathext.epi
heptc imports.ept
gcc -std=c99 -I . mathext.c imports_c/*.c -o imports
heptc -target c imports.ept
gcc -c -I /usr/local/lib/heptagon/c -I . mathext.c imports_c/*.c

@ -1,21 +1,22 @@
#include <math.h>
#include "mathext.h"
void mycos_step(float a, mycos_out *out)
void Mathext__mycos_step(float a, Mathext__mycos_out *out)
{
out->o = cos(a);
out->o = cosf(a);
}
void st_cos_reset(st_cos_mem *self)
void Mathext__st_cos_reset(Mathext__st_cos_mem *self)
{
int j;
self->i = 0;
for(int j = 0; j < 100; ++j)
for(j = 0; j < 100; ++j)
self->mem[j] = 0.0;
}
void st_cos_step(float a, st_cos_out *out, st_cos_mem *self)
void Mathext__st_cos_step(float a, Mathext__st_cos_out *out, Mathext__st_cos_mem *self)
{
out->o = self->mem[self->i];
self->i = (self->i+1) % 100;
self->mem[self->i] = cos(a);
self->mem[self->i] = cosf(a);
}

@ -2,24 +2,24 @@
#define MATHEXT_H
/* Example of a combinatorial function */
typedef struct mycos_out {
typedef struct Mathext__mycos_out {
float o;
} mycos_out;
} Mathext__mycos_out;
void mycos_step(float a, mycos_out *o);
void Mathext__mycos_step(float a, Mathext__mycos_out *o);
/* Example of a statefull function. */
typedef struct st_cos_out {
typedef struct Mathext__st_cos_out {
float o;
} st_cos_out;
} Mathext__st_cos_out;
typedef struct st_cos_mem {
typedef struct Mathext__st_cos_mem {
int i;
float mem[100];
} st_cos_mem;
} Mathext__st_cos_mem;
void st_cos_reset(st_cos_mem *self);
void st_cos_step(float a, st_cos_out *out, st_cos_mem *self);
void Mathext__st_cos_reset(Mathext__st_cos_mem *self);
void Mathext__st_cos_step(float a, Mathext__st_cos_out *out, Mathext__st_cos_mem *self);
#endif

Loading…
Cancel
Save