Re: Linux getdents.c is not aliasing safe

2002-11-04 Thread Roland McGrath
> I'm not sure that it's valid C99 - my impression is that it isn't, and > the only valid way would be to have a function return the DIRENT_TYPE > by value - but it's valid GNU C and it fixes the bug I was chasing. I'm not sure either. I don't have a copy of C99 to consult, and my weasel-wording

Re: Linux getdents.c is not aliasing safe

2002-11-04 Thread Roland McGrath
> I'm not sure that it's valid C99 - my impression is that it isn't, and > the only valid way would be to have a function return the DIRENT_TYPE > by value - but it's valid GNU C and it fixes the bug I was chasing. I'm not sure either. I don't have a copy of C99 to consult, and my weasel-wording

Re: Linux getdents.c is not aliasing safe

2002-11-04 Thread Daniel Jacobowitz
On Sun, Nov 03, 2002 at 12:12:25PM -0500, Daniel Jacobowitz wrote: > On Sat, Nov 02, 2002 at 07:48:24PM -0800, Roland McGrath wrote: > > I've put in a fix similar to yours but with cosmetic differences. > > I believe it is valid C99. > > Thanks, that's much cleaner than my solution. It looks safe

Re: Linux getdents.c is not aliasing safe

2002-11-04 Thread Daniel Jacobowitz
On Sun, Nov 03, 2002 at 12:12:25PM -0500, Daniel Jacobowitz wrote: > On Sat, Nov 02, 2002 at 07:48:24PM -0800, Roland McGrath wrote: > > I've put in a fix similar to yours but with cosmetic differences. > > I believe it is valid C99. > > Thanks, that's much cleaner than my solution. It looks safe

Re: Linux getdents.c is not aliasing safe

2002-11-03 Thread Daniel Jacobowitz
On Sat, Nov 02, 2002 at 07:48:24PM -0800, Roland McGrath wrote: > I've put in a fix similar to yours but with cosmetic differences. > I believe it is valid C99. Thanks, that's much cleaner than my solution. It looks safe to me; I'll give it a try. -- Daniel Jacobowitz MontaVista Software

Re: Linux getdents.c is not aliasing safe

2002-11-03 Thread Daniel Jacobowitz
On Sat, Nov 02, 2002 at 07:48:24PM -0800, Roland McGrath wrote: > I've put in a fix similar to yours but with cosmetic differences. > I believe it is valid C99. Thanks, that's much cleaner than my solution. It looks safe to me; I'll give it a try. -- Daniel Jacobowitz MontaVista Software

Re: Linux getdents.c is not aliasing safe

2002-11-02 Thread Roland McGrath
I've put in a fix similar to yours but with cosmetic differences. I believe it is valid C99.

Re: Linux getdents.c is not aliasing safe

2002-11-02 Thread Roland McGrath
I've put in a fix similar to yours but with cosmetic differences. I believe it is valid C99. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Re: Linux getdents.c is not aliasing safe

2002-11-02 Thread Daniel Jacobowitz
On Wed, Oct 30, 2002 at 12:03:12PM +0100, Jakub Jelinek wrote: > On Wed, Oct 30, 2002 at 10:52:30AM +0100, Wolfram Gloger wrote: > > > > [That is: two pointers to a buffer, of different types; walk through > > > > the buffer, reading one object of the first type and writing out an > > > > object of

Re: Linux getdents.c is not aliasing safe

2002-11-02 Thread Daniel Jacobowitz
On Wed, Oct 30, 2002 at 12:03:12PM +0100, Jakub Jelinek wrote: > On Wed, Oct 30, 2002 at 10:52:30AM +0100, Wolfram Gloger wrote: > > > > [That is: two pointers to a buffer, of different types; walk through > > > > the buffer, reading one object of the first type and writing out an > > > > object of

Re: Linux getdents.c is not aliasing safe

2002-10-30 Thread Wolfram Gloger
Hi, > But that intermediate buffer is in registers (on sane arches), while using > memcpy would mean at least with current compilers memory. True, I just consider that not so bad in this particular case. > glibc requires gcc (even 3.2+) to compile anyway, so IMHO just using the > union as drow p

Re: Linux getdents.c is not aliasing safe

2002-10-30 Thread Jakub Jelinek
On Wed, Oct 30, 2002 at 10:52:30AM +0100, Wolfram Gloger wrote: > > > [That is: two pointers to a buffer, of different types; walk through > > > the buffer, reading one object of the first type and writing out an > > > object of the second lesser-or-equal sized type.] > > > > No, there's no standa

Re: Linux getdents.c is not aliasing safe

2002-10-30 Thread Wolfram Gloger
> > [That is: two pointers to a buffer, of different types; walk through > > the buffer, reading one object of the first type and writing out an > > object of the second lesser-or-equal sized type.] > > No, there's no standard C way to do that. An object can only have one > type at a time. You h

Re: Linux getdents.c is not aliasing safe

2002-10-30 Thread Wolfram Gloger
Hi, > But that intermediate buffer is in registers (on sane arches), while using > memcpy would mean at least with current compilers memory. True, I just consider that not so bad in this particular case. > glibc requires gcc (even 3.2+) to compile anyway, so IMHO just using the > union as drow p

Re: Linux getdents.c is not aliasing safe

2002-10-30 Thread Jakub Jelinek
On Wed, Oct 30, 2002 at 10:52:30AM +0100, Wolfram Gloger wrote: > > > [That is: two pointers to a buffer, of different types; walk through > > > the buffer, reading one object of the first type and writing out an > > > object of the second lesser-or-equal sized type.] > > > > No, there's no standa

Re: Linux getdents.c is not aliasing safe

2002-10-30 Thread Wolfram Gloger
> > [That is: two pointers to a buffer, of different types; walk through > > the buffer, reading one object of the first type and writing out an > > object of the second lesser-or-equal sized type.] > > No, there's no standard C way to do that. An object can only have one > type at a time. You h

Re: Linux getdents.c is not aliasing safe

2002-10-29 Thread Geoff Keating
Daniel Jacobowitz <[EMAIL PROTECTED]> writes: > On Tue, Oct 29, 2002 at 11:33:49PM +0100, Andreas Schwab wrote: > That works, patch attached. With this I can use -O2 on i386 again - > it's not a pretty patch but it does work at least :) My understanding > is that this uses a GCC extension which s

Re: Linux getdents.c is not aliasing safe

2002-10-29 Thread Daniel Jacobowitz
On Tue, Oct 29, 2002 at 11:33:49PM +0100, Andreas Schwab wrote: > Daniel Jacobowitz <[EMAIL PROTECTED]> writes: > > |> Highlights: > |> char *kbuf = buf; > |> size_t kbytes = nbytes; > |> if (offsetof (DIRENT_TYPE, d_name) > |> < offsetof (struct kernel_dirent64, d_name

Re: Linux getdents.c is not aliasing safe

2002-10-29 Thread Geoff Keating
Daniel Jacobowitz <[EMAIL PROTECTED]> writes: > On Tue, Oct 29, 2002 at 11:33:49PM +0100, Andreas Schwab wrote: > That works, patch attached. With this I can use -O2 on i386 again - > it's not a pretty patch but it does work at least :) My understanding > is that this uses a GCC extension which s

Re: Linux getdents.c is not aliasing safe

2002-10-29 Thread Daniel Jacobowitz
On Tue, Oct 29, 2002 at 11:33:49PM +0100, Andreas Schwab wrote: > Daniel Jacobowitz <[EMAIL PROTECTED]> writes: > > |> Highlights: > |> char *kbuf = buf; > |> size_t kbytes = nbytes; > |> if (offsetof (DIRENT_TYPE, d_name) > |> < offsetof (struct kernel_dirent64, d_name

Re: Linux getdents.c is not aliasing safe

2002-10-29 Thread Andreas Schwab
Daniel Jacobowitz <[EMAIL PROTECTED]> writes: |> Highlights: |> char *kbuf = buf; |> size_t kbytes = nbytes; |> if (offsetof (DIRENT_TYPE, d_name) |> < offsetof (struct kernel_dirent64, d_name) |> && nbytes <= sizeof (DIRENT_TYPE)) |> { |> kb

Linux getdents.c is not aliasing safe

2002-10-29 Thread Daniel Jacobowitz
Highlights: char *kbuf = buf; size_t kbytes = nbytes; if (offsetof (DIRENT_TYPE, d_name) < offsetof (struct kernel_dirent64, d_name) && nbytes <= sizeof (DIRENT_TYPE)) { kbytes = nbytes + offsetof (struct kernel_dirent64, d_name)

Re: Linux getdents.c is not aliasing safe

2002-10-29 Thread Andreas Schwab
Daniel Jacobowitz <[EMAIL PROTECTED]> writes: |> Highlights: |> char *kbuf = buf; |> size_t kbytes = nbytes; |> if (offsetof (DIRENT_TYPE, d_name) |> < offsetof (struct kernel_dirent64, d_name) |> && nbytes <= sizeof (DIRENT_TYPE)) |> { |> kb

Linux getdents.c is not aliasing safe

2002-10-29 Thread Daniel Jacobowitz
Highlights: char *kbuf = buf; size_t kbytes = nbytes; if (offsetof (DIRENT_TYPE, d_name) < offsetof (struct kernel_dirent64, d_name) && nbytes <= sizeof (DIRENT_TYPE)) { kbytes = nbytes + offsetof (struct kernel_dirent64, d_name)