bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AT_FDCWD glitch on Solaris 10 with Sun C 5.7


From: Paul Eggert
Subject: AT_FDCWD glitch on Solaris 10 with Sun C 5.7
Date: Mon, 20 Feb 2006 22:46:35 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I noticed the following compile-time glitch with getcwd.c when
building tar 1.15.90 on Solaris 10 with Sun C 5.7 (64-bit):

cc -xarch=v9 -DHAVE_CONFIG_H -DLIBDIR=\"/usr/local/lib\" -I. -I. -I.. -g -c 
getcwd.c
"getcwd.c", line 134: warning: initializer does not fit or is out of range: 
0xffd19553

The problem is that Sun's definition of AT_FDCWD is not a valid int.
This is a bug, but it's easy for us to work around it, so I installed
the following into gnulib.  It will be picked up by the next tar
bootstrap.  I installed a similar patch into coreutils (whose openat.h
has temporarily diverged from gnulib's).

2006-02-20  Paul Eggert  <address@hidden>

        * lib/getcwd.c (AT_FDCWD): Work around a bug in Solaris 9 and 10, where
        AT_FDCWD exceeds INT_MAX.
        * lib/openat.h (AT_FDCWD): Likewise.

--- lib/getcwd.c        30 Oct 2005 01:32:04 -0000      1.10
+++ lib/getcwd.c        21 Feb 2006 06:40:34 -0000      1.11
@@ -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 <limits.h>
 
+/* 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
--- lib/openat.h        9 Jan 2006 23:13:56 -0000       1.8
+++ lib/openat.h        21 Feb 2006 06:40:34 -0000      1.9
@@ -1,5 +1,5 @@
 /* provide a replacement openat function
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]