This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: patch: parentheses and remaining prototypes


Werner Almesberger wrote:
> 
> J. Johnston wrote:
> > Patch has been checked in.
> 
> Thanks ! Here's another one that just ran into.
> 
> Possibly controversial issue: HAVE_NO_D_NAMLEN - I set it in my
> sys/dirent.h because Linux doesn't have such a field.
> 

I don't have a problem with using a define, except I would rather do it
the opposite way round.  POSIX doesn't specify the field and defines d_name
as being nul-terminated so I think it is better to do what glibc does and have the define:
_DIRENT_HAVE_D_NAMLEN instead.  This would require changing the few libc/sys/xxxx/sys/dirent.h files
that define d_namlen to define the macro as well (though many supply their own scandir).

In the POSIX.1 spec I have, there is reference to telldir not being included,
however, it is prototyped as returning long.  The same is true when you look in the glibc
/usr/include/dirent.h and the Solaris definition.  The man page on my linux box shows the
BSD 4.3 definition which uses off_t.  My preference would be to leave it as returning "long" and 
have Cygwin change the prototype unless there proves to be some good reason to change it that
I am unaware of.

-- Jeff Johnston (Red Hat Inc.)

> 
> ---------------------------------- ChangeLog ----------------------------------
> 
> 2000-08-25  Werner Almesberger  <Werner.Almesberger@epfl.ch>
>         * libc/posix/scandir.c (DIRSIZ, scandir): don't use
>         struct dirent.d_namlen if HAVE_NO_D_NAMLEN is defined
>         * libc/posix/scandir.c (alphasort): aligned prototype with
>         libc/sys/cygwin/sys/dirent.h and simplified function body
>         * libc/posix/telldir.c (telldir): aligned prototype with
>         libc/sys/cygwin/sys/dirent.h
> 
> ------------------------------------ patch ------------------------------------
> 
> --- orig/newlib/libc/posix/scandir.c    Thu Feb 17 20:39:47 2000
> +++ src/newlib/libc/posix/scandir.c     Fri Aug 25 01:16:40 2000
> @@ -57,8 +57,13 @@
>   * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
>   */
>  #undef DIRSIZ
> +#ifndef HAVE_NO_D_NAMLEN
>  #define DIRSIZ(dp) \
>      ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
> +#else
> +#define DIRSIZ(dp) \
> +    ((sizeof (struct dirent) - (MAXNAMLEN+1)) + ((strlen((dp)->d_name)+1 + 3) &~ 3))
> +#endif
> 
>  #ifndef __P
>  #define __P(args) ()
> @@ -103,8 +108,12 @@
>                         return(-1);
>                 p->d_ino = d->d_ino;
>                 p->d_reclen = d->d_reclen;
> +#ifndef HAVE_NO_D_NAMLEN
>                 p->d_namlen = d->d_namlen;
>                 bcopy(d->d_name, p->d_name, p->d_namlen + 1);
> +#else
> +               strcpy(p->d_name, d->d_name);
> +#endif
>                 /*
>                  * Check to make sure the array has space left and
>                  * realloc the maximum size.
> @@ -132,11 +141,10 @@
>   */
>  int
>  alphasort(d1, d2)
> -       const void *d1;
> -       const void *d2;
> +       const struct dirent **d1;
> +       const struct dirent **d2;
>  {
> -       return(strcmp((*(struct dirent **)d1)->d_name,
> -           (*(struct dirent **)d2)->d_name));
> +       return(strcmp((*d1)->d_name, (*d2)->d_name));
>  }
> 
>  #endif /* ! HAVE_OPENDIR */
> --- orig/newlib/libc/posix/telldir.c    Thu Feb 17 20:39:47 2000
> +++ src/newlib/libc/posix/telldir.c     Fri Aug 25 01:10:05 2000
> @@ -71,9 +71,9 @@
>  /*
>   * return a pointer into a directory
>   */
> -long
> +off_t
>  telldir(dirp)
> -       const DIR *dirp;
> +       DIR *dirp;
>  {
>         register int index;
>         register struct ddloc *lp;
> 
> --
>   _________________________________________________________________________
>  / Werner Almesberger, ICA, EPFL, CH       werner.almesberger@ica.epfl.ch /
> /_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]