Portability fixes for gcc 4.6.3

This commit is contained in:
Wilson Snyder 2012-05-10 22:04:53 -04:00
parent 247e855dbf
commit b429319bc0
2 changed files with 19 additions and 5 deletions

View File

@ -92,7 +92,14 @@ int dpic_save(int value) {
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");
return 0;
}
@ -106,8 +113,14 @@ int dpic_restore() {
return 0;
}
if (void* userp = svGetUserData(scope, &Dpic_Unique)) {
return (int)(long long)(userp);
if (void* userp = svGetUserData(scope, (void*)&Dpic_Unique)) {
// Use union to avoid cast to different size pointer warnings
union valpack {
void* ptr;
int i;
} vp;
vp.ptr = userp;
return vp.i;
} else {
printf("%%Warning: svGetUserData failed\n");
return 0;

View File

@ -15,13 +15,14 @@ module t;
count = 1234;
`ifdef TEST_VERBOSE
$display("-count == %d, infile %d, outfile %d", count, infile, outfile);
$display("-count == %0d, infile %d, outfile %d", count, infile, outfile);
`endif
count = $fscanf(infile, "%d\n", a);
`ifdef TEST_VERBOSE
// 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
if (count == 0) $stop;
$fwrite(outfile, "# a\n");
$fwrite(outfile, "%d\n", a);
$fclose(infile);