3804345481
This code was assuming it could copy double's in/out of char *'s with just casts and normal copies. This blows up on anything which enforces alignments. Change the generic case for the ATOM to just have a special double field. For the serialization routines memcpy the double in and provide a union to memcpy it out to that also contains a single double value. This ensures alignment is correct and it won't SIGBUS anymore. Bump pkg to nb1
41 lines
1.1 KiB
Text
41 lines
1.1 KiB
Text
$NetBSD: patch-ae,v 1.1 2002/03/15 00:22:43 jmc Exp $
|
|
|
|
--- src/lcore.c.orig Fri Mar 15 00:16:32 2002
|
|
+++ src/lcore.c Fri Mar 15 00:16:44 2002
|
|
@@ -113,7 +113,7 @@
|
|
case 1: sprintf(TeXt,"[^H]");return TeXt;
|
|
case 2: sprintf(TeXt,"[^F]");return TeXt;
|
|
case 3: sprintf(TeXt,"[^T]");return TeXt;
|
|
- case 4: sprintf(TeXt,"%g",*(double*)(a->a)); return TeXt;
|
|
+ case 4: sprintf(TeXt,"%g",a->d); return TeXt;
|
|
case 6: sprintf(TeXt,"%d",*(int*)(a->a)); return TeXt;
|
|
case 5: sprintf(TeXt,"[^II]");return TeXt;
|
|
case 8: sprintf(TeXt,"[^IF]");return TeXt;
|
|
@@ -180,6 +180,7 @@
|
|
tmp->a=(char *)malloc(sizeof(double));
|
|
dd=(double *)(tmp->a);
|
|
(*dd)=d;
|
|
+ tmp->d = d;
|
|
tmp->g=1;tmp->f=4<<1;tmp->b=NULL;
|
|
return tmp;
|
|
}
|
|
@@ -197,9 +198,7 @@
|
|
/*--X FNAME: "GetDouble" DESC: "Takes a double from atom a" */
|
|
double GetDbleOld(ATOM a)
|
|
{
|
|
- double *dd;
|
|
- dd=(double*)(a->a);
|
|
- return *dd;
|
|
+ return a->d;
|
|
}
|
|
|
|
/*--X VNAME: "Pos" DESC: "Temporary variable for a string to list conversion" */
|
|
@@ -249,7 +248,7 @@
|
|
{
|
|
double *d;
|
|
t=mkatm(sizeof(double));t->f=4<<1;
|
|
- d=(double*)(t->a);
|
|
+ d=&t->d;
|
|
sscanf(c,"%lf",d);
|
|
}
|
|
return t;
|