Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 83210 invoked by uid 500); 1 Mar 2002 18:34:18 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 83168 invoked from network); 1 Mar 2002 18:34:18 -0000 Date: Fri, 1 Mar 2002 13:34:01 -0500 (EST) From: Cliff Woolley X-X-Sender: root@deepthought.cs.virginia.edu To: Aaron Bannert cc: dev@httpd.apache.org, Subject: Re: [PATCH] fix alignment on shared memory In-Reply-To: <20020301102927.Z15055@clove.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 #include 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 cliffwoolley@yahoo.com Charlottesville, VA