readlink and symlink prototypes [PATCH]

Jeff Johnston jjohnstn@redhat.com
Tue Nov 1 22:27:00 GMT 2005


Shaun Jackman wrote:
> Since readlink and symlink are standard functions (SUSv3 and others) I
> would like to see their prototypes provided by default.
> 
> As a general rule, could functions defined by SUSv3 be moved
> outside the common #if defined(__CYGWIN__) || defined(__rtems__)
> line? If so, I'll trickle in patches as I come across them.
>

Could you explain why you need/want to do this?  The reason these 
prototypes are not outside the #ifdefs is that these functions don't 
exist in generic newlib.  Generic newlib is not fully SUSv3-compliant 
nor POSIX-compliant nor is it intended to be.  X86 linux newlib, for 
example, which is far more robust, overrides the header files.

-- Jeff J.

> Cheers,
> Shaun
> 
> 2005-10-26  Shaun Jackman  <sjackman@gmail.com>
> 
> 	* libc/include/sys/unistd.h (readlink, symlink): Provide these
> 	prototypes by default.
> 	* libc/sys/linux/include/unistd.h (readlink): Remove this
> 	prototype.
> 	* libc/sys/linux/sys/unistd.h (readlink, symlink): New
> 	prototypes.
> 
> diff -u -r1.55 unistd.h
> --- libc/include/sys/unistd.h	23 Feb 2005 17:42:07 -0000	1.55
> +++ libc/include/sys/unistd.h	26 Oct 2005 22:06:34 -0000
> @@ -211,9 +211,9 @@
>  #else /* defined(__rtems__) */
>  int     _EXFUN(sync, (void));
>  #endif
> +#endif
>  int     _EXFUN(readlink, (const char *__path, char *__buf, int __buflen));
>  int     _EXFUN(symlink, (const char *__name1, const char *__name2));
> -#endif
> 
>  #define	F_OK	0
>  #define	R_OK	4
> diff -u -r1.1 unistd.h
> --- libc/sys/linux/include/unistd.h	9 Dec 2000 01:20:32 -0000	1.1
> +++ libc/sys/linux/include/unistd.h	26 Oct 2005 22:06:35 -0000
> @@ -15,6 +15,4 @@
>  extern int optind, opterr, optopt;
> 
> 
> -int readlink(const char *path, char *buf, size_t bufsiz);
> -
>  #endif
> diff -u -r1.5 unistd.h
> --- libc/sys/linux/sys/unistd.h	7 Dec 2004 18:54:28 -0000	1.5
> +++ libc/sys/linux/sys/unistd.h	26 Oct 2005 22:06:35 -0000
> @@ -72,6 +72,7 @@
>  ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t
> __offset));
>  ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes,
> off_t __offset));
>  _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
> +int     _EXFUN(readlink, (const char *path, char *buf, size_t bufsiz));
>  int     _EXFUN(rmdir, (const char *__path ));
>  void *  _EXFUN(sbrk,  (ptrdiff_t __incr));
>  int     _EXFUN(setegid, (gid_t __gid ));
> @@ -83,6 +84,7 @@
>  int     _EXFUN(setuid, (uid_t __uid ));
>  unsigned _EXFUN(sleep, (unsigned int __seconds ));
>  void    _EXFUN(swab, (const void *, void *, ssize_t));
> +int     _EXFUN(symlink, (const char *oldpath, const char *newpath));
>  long    _EXFUN(sysconf, (int __name ));
>  pid_t   _EXFUN(tcgetpgrp, (int __fildes ));
>  int     _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));



More information about the Newlib mailing list