diff options
author | David Schleef <ds@ginger.bigkitten.com> | 2008-05-15 18:36:32 -0700 |
---|---|---|
committer | David Schleef <ds@ginger.bigkitten.com> | 2008-05-15 18:36:32 -0700 |
commit | ee71e629d30f76205c21ac7323b93e9181de11d8 (patch) | |
tree | d959b88e4ad197af874659b7a99b70becef5300b /examples | |
parent | c003f17b82ed66f7879a83519d19ac81207c07ce (diff) | |
download | liboil-ee71e629d30f76205c21ac7323b93e9181de11d8.tar.gz |
[orc] fix valgrind problems
Diffstat (limited to 'examples')
-rw-r--r-- | examples/orc/Makefile.am | 4 | ||||
-rw-r--r-- | examples/orc/jit.c | 9 | ||||
-rw-r--r-- | examples/orc/simple.c | 74 |
3 files changed, 82 insertions, 5 deletions
diff --git a/examples/orc/Makefile.am b/examples/orc/Makefile.am index 7d3bfc0..9023579 100644 --- a/examples/orc/Makefile.am +++ b/examples/orc/Makefile.am @@ -1,8 +1,10 @@ -noinst_PROGRAMS = jit +noinst_PROGRAMS = jit simple AM_LDFLAGS = $(ORC_LIBS) $(GLIB_LIBS) AM_CFLAGS = $(ORC_CFLAGS) $(GLIB_CFLAGS) jit_SOURCES = jit.c +simple_SOURCES = simple.c + diff --git a/examples/orc/jit.c b/examples/orc/jit.c index 4e9b1fc..35df92c 100644 --- a/examples/orc/jit.c +++ b/examples/orc/jit.c @@ -24,7 +24,7 @@ main (int argc, char *argv[]) int s1, s2, d1, offset, shift; int t1; - orc_opcode_init (); + orc_init (); p = orc_program_new (); @@ -50,15 +50,13 @@ main (int argc, char *argv[]) if (0) { int i; - void (*func) (OrcExecutor *); for(i=0;i<N;i++){ src1[i] = rand()&0xf; src2[i] = rand()&0xf; } - func = p->code_exec; - func (ex); + orc_executor_run (ex); //orc_executor_emulate (ex); for(i=0;i<N;i++){ @@ -67,6 +65,9 @@ main (int argc, char *argv[]) } } + orc_executor_free (ex); + orc_program_free (p); + return 0; } diff --git a/examples/orc/simple.c b/examples/orc/simple.c new file mode 100644 index 0000000..d505c41 --- /dev/null +++ b/examples/orc/simple.c @@ -0,0 +1,74 @@ + +#include "config.h" + +#include <glib.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <orc/orcprogram.h> + +#define N 10 + +int16_t src1[N]; +int16_t src2[N]; +int16_t dest[N]; + +void test1(void); + +int +main (int argc, char *argv[]) +{ + orc_init (); + + test1(); + exit(0); +} + + +void +test1(void) +{ + OrcProgram *p; + OrcExecutor *ex; + int s1, s2, d1; + + + p = orc_program_new (); + + d1 = orc_program_add_destination (p, "s16", "d1"); + s1 = orc_program_add_source (p, "s16", "s1"); + s2 = orc_program_add_source (p, "s16", "s2"); + + orc_program_append (p, "add_s16", d1, s1, s2); + + orc_program_compile_x86 (p); + + ex = orc_executor_new (p); + orc_executor_set_n (ex, N); + orc_executor_set_array (ex, s1, src1); + orc_executor_set_array (ex, s2, src2); + orc_executor_set_array (ex, d1, dest); + + if (1) { + int i; + + for(i=0;i<N;i++){ + src1[i] = rand()&0xf; + src2[i] = rand()&0xf; + } + + orc_executor_run (ex); + //orc_executor_emulate (ex); + + for(i=0;i<N;i++){ + printf("# %4d %4d %4d %4d\n", src1[i], src2[i], dest[i], + (src1[i] + src2[i] + 1)>>1); + } + } + + orc_executor_free (ex); + orc_program_free (p); +} + + |