From: Paul Eggert Date: Tue, 21 Feb 2006 06:42:29 +0000 (+0000) Subject: (AT_FDCWD): Work around a bug in Solaris 9 and 10, where X-Git-Tag: v6.0~696 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6870eeeaff70a3a2721126a54ea2c25b956cc198;p=thirdparty%2Fcoreutils.git (AT_FDCWD): Work around a bug in Solaris 9 and 10, where AT_FDCWD exceeds INT_MAX. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index a216120606..3756ac55cf 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2006-02-20 Paul Eggert + + * getcwd.c (AT_FDCWD): Work around a bug in Solaris 9 and 10, where + AT_FDCWD exceeds INT_MAX. + * openat.h (AT_FDCWD): Likewise. + 2006-02-17 Jim Meyering * openat.c: Include lstat.h, so that uses of lstat are converted diff --git a/lib/getcwd.c b/lib/getcwd.c index ec1771b83d..5bb9e4be14 100644 --- a/lib/getcwd.c +++ b/lib/getcwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2004,2005 Free Software +/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2004,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -74,6 +74,14 @@ #include +/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its + value exceeds INT_MAX, so its use as an int doesn't conform to the + C standard, and GCC and Sun C complain in some cases. */ +#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 +# undef AT_FDCWD +# define AT_FDCWD (-3041965) +#endif + #ifdef ENAMETOOLONG # define is_ENAMETOOLONG(x) ((x) == ENAMETOOLONG) #else diff --git a/lib/openat.h b/lib/openat.h index aa900c72eb..017cf5cb05 100644 --- a/lib/openat.h +++ b/lib/openat.h @@ -35,10 +35,24 @@ # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) #endif +/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its + value exceeds INT_MAX, so its use as an int doesn't conform to the + C standard, and GCC and Sun C complain in some cases. If the bug + is present, undef AT_FDCWD here, so it can be redefined below. */ +#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 +# undef AT_FDCWD +#endif + +/* Use the same bit pattern as Solaris 9, but with the proper + signedness. The bit pattern is important, in case this actually is + Solaris with the above workaround. */ #ifndef AT_FDCWD +# define AT_FDCWD (-3041965) +#endif + /* Use the same values as Solaris 9. This shouldn't matter, but there's no real reason to differ. */ -# define AT_FDCWD (-3041965) +#ifndef AT_SYMLINK_NOFOLLOW # define AT_SYMLINK_NOFOLLOW 4096 # define AT_REMOVEDIR 1 #endif