From 0a65ffc8e2d3f17d18de46566a52f09668be25dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwena=C3=ABl=20Delaval?= Date: Thu, 17 Sep 2015 17:20:31 +0200 Subject: [PATCH] Update of example Extern_C --- examples/extern_C/README | 4 ++-- examples/extern_C/mathext.c | 13 +++++++------ examples/extern_C/mathext.h | 18 +++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/examples/extern_C/README b/examples/extern_C/README index 4bc0873..af9c2cd 100644 --- a/examples/extern_C/README +++ b/examples/extern_C/README @@ -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 diff --git a/examples/extern_C/mathext.c b/examples/extern_C/mathext.c index 91495b1..1f1d9a3 100644 --- a/examples/extern_C/mathext.c +++ b/examples/extern_C/mathext.c @@ -1,21 +1,22 @@ #include #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); } diff --git a/examples/extern_C/mathext.h b/examples/extern_C/mathext.h index f20f922..0c26319 100644 --- a/examples/extern_C/mathext.h +++ b/examples/extern_C/mathext.h @@ -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