On Fri, 1 Mar 2002, Aaron Bannert wrote:
> Yes, I completely agree that each structure needs to be 64-bit aligned.
> I don't see how the shared memory code itself is incorrect. It must be
> mapping the segment at a properly aligned boundary, so as long as the
> contents of that segment are accessed in an aligned manner than we're
> safe, right?
That's what I'm thinking, too. I don't see the problem there. It looks
to me like you (Aaron) were right on when you suggested that it's
ap_calc_scoreboard_size() and ap_init_scoreboard()'s fault. Try this, for
example:
#include <stddef.h>
#include <stdio.h>
int main(void)
{
void *foo;
struct s1 {
char a;
char b;
} *s1;
struct s2 {
char a;
int b;
} *s2;
struct s3 {
char a;
long long b;
} *s3;
struct s4 {
char a;
double b;
} *s4;
printf("%d %d %d %d\n",
offsetof(struct s1,b),
offsetof(struct s2,b),
offsetof(struct s3,b),
offsetof(struct s4,b));
printf(" sizes: %d %d %d %d\n",
sizeof(struct s1),
sizeof(struct s2),
sizeof(struct s3),
sizeof(struct s4));
foo = malloc(100);
s1 = (struct s1 *)foo;
s2 = (struct s2 *)(((char *)s1)+sizeof(s1)*4);
s3 = (struct s3 *)(((char *)s2)+sizeof(s2));
printf("%p\n%p\n%p\n",s3,&s3->a,&s3->b);
s3->a = 'A';
s3->b = 10241024LL;
return 0;
}
jcw5q@cobra:/uf2/jcw5q$ ./test
1 4 8 8
sizes: 2 8 16 16
20c44
20c44
20c4c
Bus Error
Except for the times 4, this is very similar to what ap_init_scoreboard()
is giving us. Each of the sizeof()'s needs to be padded out because they
can interfere with one another when you place the structs back-to-back in
memory.
--Cliff
--------------------------------------------------------------
Cliff Woolley
[EMAIL PROTECTED]
Charlottesville, VA