llvmpipe: silence cast warnings in test programs

This commit is contained in:
Brian Paul
2010-05-13 13:21:19 -06:00
parent 45d6289fab
commit 966d28cb2e
4 changed files with 63 additions and 6 deletions

View File

@@ -52,6 +52,19 @@ enum vector_mode
typedef void (*blend_test_ptr_t)(const void *src, const void *dst, const void *con, void *res);
/** cast wrapper */
static blend_test_ptr_t
voidptr_to_blend_test_ptr_t(void *p)
{
union {
void *v;
blend_test_ptr_t f;
} u;
u.v = p;
return u.f;
}
void
write_tsv_header(FILE *fp)
@@ -482,6 +495,7 @@ test_one(unsigned verbose,
int64_t cycles[LP_TEST_NUM_SAMPLES];
double cycles_avg = 0.0;
unsigned i, j;
void *code;
if(verbose >= 1)
dump_blend_type(stdout, blend, mode, type);
@@ -523,10 +537,11 @@ test_one(unsigned verbose,
if(verbose >= 2)
LLVMDumpModule(module);
blend_test_ptr = (blend_test_ptr_t)LLVMGetPointerToGlobal(engine, func);
code = LLVMGetPointerToGlobal(engine, func);
blend_test_ptr = voidptr_to_blend_test_ptr_t(code);
if(verbose >= 2)
lp_disassemble(blend_test_ptr);
lp_disassemble(code);
success = TRUE;
for(i = 0; i < n && success; ++i) {

View File

@@ -43,6 +43,17 @@
typedef void (*conv_test_ptr_t)(const void *src, const void *dst);
/** cast wrapper */
static conv_test_ptr_t
voidptr_to_conv_test_ptr_t(void *p)
{
union {
void *v;
conv_test_ptr_t f;
} u;
u.v = p;
return u.f;
}
void
write_tsv_header(FILE *fp)
@@ -164,6 +175,7 @@ test_one(unsigned verbose,
unsigned num_dsts;
double eps;
unsigned i, j;
void *code;
if(verbose >= 1)
dump_conv_types(stdout, src_type, dst_type);
@@ -221,10 +233,11 @@ test_one(unsigned verbose,
if(verbose >= 2)
LLVMDumpModule(module);
conv_test_ptr = (conv_test_ptr_t)LLVMGetPointerToGlobal(engine, func);
code = LLVMGetPointerToGlobal(engine, func);
conv_test_ptr = voidptr_to_conv_test_ptr_t(code);
if(verbose >= 2)
lp_disassemble(conv_test_ptr);
lp_disassemble(code);
success = TRUE;
for(i = 0; i < n && success; ++i) {

View File

@@ -73,6 +73,19 @@ typedef void
(*fetch_ptr_t)(float *, const void *packed,
unsigned i, unsigned j);
/** cast wrapper to avoid warnings */
static fetch_ptr_t
void_to_fetch_ptr_t(void *p)
{
union {
void *v;
fetch_ptr_t f;
} u;
u.v = p;
return u.f;
}
static LLVMValueRef
add_fetch_rgba_test(LLVMModuleRef lp_build_module,
@@ -149,7 +162,7 @@ test_format(unsigned verbose, FILE *fp,
(void)pass;
#endif
fetch_ptr = (fetch_ptr_t) LLVMGetPointerToGlobal(lp_build_engine, fetch);
fetch_ptr = void_to_fetch_ptr_t(LLVMGetPointerToGlobal(lp_build_engine, fetch));
for (i = 0; i < desc->block.height; ++i) {
for (j = 0; j < desc->block.width; ++j) {

View File

@@ -41,6 +41,7 @@
struct printf_test_case {
int foo;
};
void
@@ -57,6 +58,19 @@ write_tsv_header(FILE *fp)
typedef void (*test_printf_t)(int i);
/** cast wrapper */
static test_printf_t
voidptr_to_test_printf_t(void *p)
{
union {
void *v;
test_printf_t f;
} u;
u.v = p;
return u.f;
}
static LLVMValueRef
add_printf_test(LLVMModuleRef module)
{
@@ -91,6 +105,7 @@ test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase)
float unpacked[4];
unsigned packed;
boolean success = TRUE;
void *code;
module = LLVMModuleCreateWithName("test");
@@ -124,7 +139,8 @@ test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase)
(void)pass;
#endif
test_printf = (test_printf_t)LLVMGetPointerToGlobal(engine, test);
code = LLVMGetPointerToGlobal(engine, test);
test_printf = voidptr_to_test_printf_t(code);
memset(unpacked, 0, sizeof unpacked);
packed = 0;