Improve value conversion warnings.
[sljit.git] / test_src / sljitMain.c
blob06e0ed1da52d483031704f3d63704da29dea930b
1 /*
2 * Stack-less Just-In-Time compiler
4 * Copyright 2009-2010 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
6 * Redistribution and use in source and binary forms, with or without modification, are
7 * permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice, this list of
10 * conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 * of conditions and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include "sljitLir.h"
29 #include <stdio.h>
30 #include <stdlib.h>
32 int sljit_test(int argc, char* argv[]);
34 void error(const char* str)
36 printf("An error occured: %s\n", str);
37 exit(-1);
40 union executable_code {
41 void* code;
42 sljit_sw (SLJIT_FUNC *func)(sljit_sw* a);
44 typedef union executable_code executable_code;
46 void devel(void)
48 executable_code code;
50 struct sljit_compiler *compiler = sljit_create_compiler(NULL, NULL);
51 sljit_sw buf[4];
53 if (!compiler)
54 error("Not enough of memory");
55 buf[0] = 5;
56 buf[1] = 12;
57 buf[2] = 0;
58 buf[3] = 0;
60 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
61 sljit_compiler_verbose(compiler, stdout);
62 #endif
63 sljit_emit_enter(compiler, 0, SLJIT_ARGS1(W, P), 4, 5, 4, 0, 2 * sizeof(sljit_sw));
65 sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
67 code.code = sljit_generate_code(compiler);
68 sljit_free_compiler(compiler);
70 printf("Code at: %p\n", (void*)SLJIT_FUNC_ADDR(code.code));
72 printf("Function returned with %ld\n", (long)code.func((sljit_sw*)buf));
73 printf("buf[0] = %ld\n", (long)buf[0]);
74 printf("buf[1] = %ld\n", (long)buf[1]);
75 printf("buf[2] = %ld\n", (long)buf[2]);
76 printf("buf[3] = %ld\n", (long)buf[3]);
77 sljit_free_code(code.code, NULL);
80 int main(int argc, char* argv[])
82 /* devel(); */
83 return sljit_test(argc, argv);