Portability fixes for gcc 4.6.3
This commit is contained in:
parent
247e855dbf
commit
b429319bc0
|
|
@ -92,7 +92,14 @@ int dpic_save(int value) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (svPutUserData(scope, &Dpic_Unique, (void*)(value))) {
|
// Use union to avoid cast to different size pointer warnings
|
||||||
|
union valpack {
|
||||||
|
void* ptr;
|
||||||
|
int i;
|
||||||
|
} vp;
|
||||||
|
|
||||||
|
vp.i = value;
|
||||||
|
if (svPutUserData(scope, &Dpic_Unique, vp.ptr)) {
|
||||||
printf("%%Warning: svPutUserData failed\n");
|
printf("%%Warning: svPutUserData failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -106,8 +113,14 @@ int dpic_restore() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (void* userp = svGetUserData(scope, &Dpic_Unique)) {
|
if (void* userp = svGetUserData(scope, (void*)&Dpic_Unique)) {
|
||||||
return (int)(long long)(userp);
|
// Use union to avoid cast to different size pointer warnings
|
||||||
|
union valpack {
|
||||||
|
void* ptr;
|
||||||
|
int i;
|
||||||
|
} vp;
|
||||||
|
vp.ptr = userp;
|
||||||
|
return vp.i;
|
||||||
} else {
|
} else {
|
||||||
printf("%%Warning: svGetUserData failed\n");
|
printf("%%Warning: svGetUserData failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,14 @@ module t;
|
||||||
|
|
||||||
count = 1234;
|
count = 1234;
|
||||||
`ifdef TEST_VERBOSE
|
`ifdef TEST_VERBOSE
|
||||||
$display("-count == %d, infile %d, outfile %d", count, infile, outfile);
|
$display("-count == %0d, infile %d, outfile %d", count, infile, outfile);
|
||||||
`endif
|
`endif
|
||||||
count = $fscanf(infile, "%d\n", a);
|
count = $fscanf(infile, "%d\n", a);
|
||||||
`ifdef TEST_VERBOSE
|
`ifdef TEST_VERBOSE
|
||||||
// Ifdefing this out gave bug248
|
// Ifdefing this out gave bug248
|
||||||
$display("-count == %d, infile %d, outfile %d", count, infile, outfile);
|
$display("-count == %0d, infile %d, outfile %d", count, infile, outfile);
|
||||||
`endif
|
`endif
|
||||||
|
if (count == 0) $stop;
|
||||||
$fwrite(outfile, "# a\n");
|
$fwrite(outfile, "# a\n");
|
||||||
$fwrite(outfile, "%d\n", a);
|
$fwrite(outfile, "%d\n", a);
|
||||||
$fclose(infile);
|
$fclose(infile);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue