K
Kevin
Hey, I was hoping someone out here might be able to clue me in on some
alignment issues I'm having. Hopefully I can explain this best
through code below. ACSign and MyACSign functions below get compiled
(gcc) into one library, where as the code that executes these
functions gets compiled into a seperate library. Calls to MyACSign
work fine, calls to the straight ACSign do not and I believe it is due
to alignment issues, but I can't pinpoint how. This <i>should</i> have
been very elementary. Any help is of course greatly appreciated,
- Kevin
Function Code:
********************************************************************
double ACSign ( double a) {
if (a > 0.0)
return(1.0);
else if (a < 0.0)
return(-1.0);
}
double * MyACSign (double * a) {
if (*a > 0.0)
*a = 1.0;
else if (*a < 0.0)
*a = -1.0;
return a;
}
Execution Code:
********************************************************************
double test = 0 ;
double test1 = 0;
test = 0.707107;
test1 = test * -1;
printf("Locations: %u, %u\r\n", &test, &test1);
printf("0Double: %f, %f", test, test1);
printf("1Double: %f, %f", ACSign(test), ACSign(test1));
printf("2Double: %i, %i", (char)ACSign(test), (char)ACSign(test1));
printf("3Double: %f, %f", 0.707107, -0.707107);
printf("4Double: %f, %f", ACSign(0.707107), ACSign(-0.707107));
printf("5Double: %i, %i", (char)ACSign(0.707107),
(char)ACSign(-0.707107));
printf("6Double: %f, %f", test, test1);
printf("7Double: %f, %f", *(double*)MyACSign(&test),
*(double*)MyACSign(&test1));
printf("8Double: %i, %i", (char)*(double*)MyACSign(&test),
(char)*(double*)MyACSign(&test1));
********************************************************************
The output I get is:
Locations: 4263558272, 4263558264
0Double: 0.707107, -0.707107
1Double: 0.707107, -0.707107
2Double: -98, -98
3Double: 0.707107, -0.707107
4Double: 0.707107, 0.000000
5Double: -98, -98
6Double: 0.707107, -0.707107
7Double: 1.000000, -1.000000
8Double: 1, -1
alignment issues I'm having. Hopefully I can explain this best
through code below. ACSign and MyACSign functions below get compiled
(gcc) into one library, where as the code that executes these
functions gets compiled into a seperate library. Calls to MyACSign
work fine, calls to the straight ACSign do not and I believe it is due
to alignment issues, but I can't pinpoint how. This <i>should</i> have
been very elementary. Any help is of course greatly appreciated,
- Kevin
Function Code:
********************************************************************
double ACSign ( double a) {
if (a > 0.0)
return(1.0);
else if (a < 0.0)
return(-1.0);
}
double * MyACSign (double * a) {
if (*a > 0.0)
*a = 1.0;
else if (*a < 0.0)
*a = -1.0;
return a;
}
Execution Code:
********************************************************************
double test = 0 ;
double test1 = 0;
test = 0.707107;
test1 = test * -1;
printf("Locations: %u, %u\r\n", &test, &test1);
printf("0Double: %f, %f", test, test1);
printf("1Double: %f, %f", ACSign(test), ACSign(test1));
printf("2Double: %i, %i", (char)ACSign(test), (char)ACSign(test1));
printf("3Double: %f, %f", 0.707107, -0.707107);
printf("4Double: %f, %f", ACSign(0.707107), ACSign(-0.707107));
printf("5Double: %i, %i", (char)ACSign(0.707107),
(char)ACSign(-0.707107));
printf("6Double: %f, %f", test, test1);
printf("7Double: %f, %f", *(double*)MyACSign(&test),
*(double*)MyACSign(&test1));
printf("8Double: %i, %i", (char)*(double*)MyACSign(&test),
(char)*(double*)MyACSign(&test1));
********************************************************************
The output I get is:
Locations: 4263558272, 4263558264
0Double: 0.707107, -0.707107
1Double: 0.707107, -0.707107
2Double: -98, -98
3Double: 0.707107, -0.707107
4Double: 0.707107, 0.000000
5Double: -98, -98
6Double: 0.707107, -0.707107
7Double: 1.000000, -1.000000
8Double: 1, -1