diff options
Diffstat (limited to 'libc/sysdeps/linux/common/getdirname.c')
| -rw-r--r-- | libc/sysdeps/linux/common/getdirname.c | 30 | 
1 files changed, 20 insertions, 10 deletions
| diff --git a/libc/sysdeps/linux/common/getdirname.c b/libc/sysdeps/linux/common/getdirname.c index a4285322b..e196d1bd9 100644 --- a/libc/sysdeps/linux/common/getdirname.c +++ b/libc/sysdeps/linux/common/getdirname.c @@ -17,14 +17,23 @@     Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA     02111-1307 USA.  */ -#define getcwd __getcwd -  #include <features.h> + +#ifdef __USE_GNU  #include <unistd.h>  #include <sys/stat.h>  #include <stdlib.h>  #include <string.h> +libc_hidden_proto(strdup) +libc_hidden_proto(getcwd) +libc_hidden_proto(getenv) +#ifdef __UCLIBC_HAS_LFS__ +libc_hidden_proto(stat64) +#else +libc_hidden_proto(stat) +#endif +  /* Return a malloc'd string containing the current directory name.     If the environment variable `PWD' is set, and its value is correct,     that value is used.  */ @@ -33,25 +42,26 @@ char *  get_current_dir_name (void)  {  	char *pwd; -#if defined __UCLIBC_HAS_LFS__ +#ifdef __UCLIBC_HAS_LFS__  	struct stat64 dotstat, pwdstat;  #else  	struct stat dotstat, pwdstat;  #endif -	pwd = __getenv ("PWD"); +	pwd = getenv ("PWD");  	if (pwd != NULL -#if defined __UCLIBC_HAS_LFS__ -		&& __stat64 (".", &dotstat) == 0 -		&& __stat64 (pwd, &pwdstat) == 0 +#ifdef __UCLIBC_HAS_LFS__ +		&& stat64 (".", &dotstat) == 0 +		&& stat64 (pwd, &pwdstat) == 0  #else -		&& __stat (".", &dotstat) == 0 -		&& __stat (pwd, &pwdstat) == 0 +		&& stat (".", &dotstat) == 0 +		&& stat (pwd, &pwdstat) == 0  #endif  		&& pwdstat.st_dev == dotstat.st_dev  		&& pwdstat.st_ino == dotstat.st_ino)  		/* The PWD value is correct.  Use it.  */ -		return __strdup (pwd); +		return strdup (pwd);  	return getcwd ((char *) NULL, 0);  } +#endif | 
