[PATCH] Move MAXPATHLEN definition
Corinna Vinschen
vinschen@redhat.com
Wed Oct 16 13:02:00 GMT 2013
On Oct 16 14:43, Sebastian Huber wrote:
> Glibc and FreeBSD define MAXPATHLEN in <sys/param.h>. An include of
> <unistd.h> only lets MAXPATHLEN undefined on both systems. The change
> brings Newlib in line with these systems. This change may break
> applications which rely on the previous Newlib approach. The #ifndef
> __CYGWIN__ was changed into a #ifndef MAXPATHLEN. Will this work for
> Cygwin?
Cygwin comes with its own sys/param.h, so it's not affected by this
change. Just drop the #ifndef and define MAXPATHLEN unconditionally.
Thanks,
Corinna
>
> newlib/ChangeLog
> 2013-10-16 Sebastian Huber <sebastian.huber@embedded-brains.de>
>
> * libc/include/sys/unistd.h (MAXPATHLEN): Delete.
> * libc/include/sys/param.h (MAXPATHLEN): Define.
> * libc/sys/rtems/sys/param.h (MAXPATHLEN): Likewise.
> * libc/unix/getcwd.c: Include <sys/param.h> for MAXPATHLEN.
> ---
> newlib/libc/include/sys/param.h | 4 ++++
> newlib/libc/include/sys/unistd.h | 4 ----
> newlib/libc/sys/rtems/sys/param.h | 2 --
> newlib/libc/unix/getcwd.c | 1 +
> 4 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/newlib/libc/include/sys/param.h b/newlib/libc/include/sys/param.h
> index 7e8762a..e30fbd3 100644
> --- a/newlib/libc/include/sys/param.h
> +++ b/newlib/libc/include/sys/param.h
> @@ -6,6 +6,7 @@
> # define _SYS_PARAM_H
>
> #include <sys/config.h>
> +#include <sys/syslimits.h>
> #include <machine/endian.h>
> #include <machine/param.h>
>
> @@ -18,6 +19,9 @@
> #ifndef PATHSIZE
> # define PATHSIZE (1024)
> #endif
> +#ifndef MAXPATHLEN
> +# define MAXPATHLEN PATH_MAX
> +#endif
>
> #define MAX(a,b) ((a) > (b) ? (a) : (b))
> #define MIN(a,b) ((a) < (b) ? (a) : (b))
> diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
> index a5f66c0..f1aacfa 100644
> --- a/newlib/libc/include/sys/unistd.h
> +++ b/newlib/libc/include/sys/unistd.h
> @@ -500,10 +500,6 @@ int _EXFUN(unlinkat, (int, const char *, int));
> #define _CS_V6_ENV _CS_V7_ENV
> #endif
>
> -#ifndef __CYGWIN__
> -# define MAXPATHLEN 1024
> -#endif
> -
> #ifdef __cplusplus
> }
> #endif
> diff --git a/newlib/libc/sys/rtems/sys/param.h b/newlib/libc/sys/rtems/sys/param.h
> index eac24e9..808745f 100644
> --- a/newlib/libc/sys/rtems/sys/param.h
> +++ b/newlib/libc/sys/rtems/sys/param.h
> @@ -156,9 +156,7 @@
> * It should be set high enough to allow all legitimate uses, but halt
> * infinite loops reasonably quickly.
> */
> -#if !defined(__rtems__)
> #define MAXPATHLEN PATH_MAX
> -#endif
> #define MAXSYMLINKS 32
>
> /* Bit map related macros. */
> diff --git a/newlib/libc/unix/getcwd.c b/newlib/libc/unix/getcwd.c
> index b49a4b6..92f1b20 100644
> --- a/newlib/libc/unix/getcwd.c
> +++ b/newlib/libc/unix/getcwd.c
> @@ -32,6 +32,7 @@
> static char sccsid[] = "@(#)getcwd.c 5.11 (Berkeley) 2/24/91";
> #endif /* LIBC_SCCS and not lint */
>
> +#include <sys/param.h>
> #include <sys/stat.h>
> #include <errno.h>
> #include <dirent.h>
> --
> 1.7.7
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20131016/95cb2639/attachment.sig>
More information about the Newlib
mailing list