This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Implement pragma redefine_extname


> On Sat, Nov 10, 2001 at 10:18:13PM +0100, Martin v. Loewis wrote:
> > This patch fixes the problem reported in c/4850, for C and C++.
> > #pragma redefine_extname is a SunPRO extension to rename library entry
> > points depending on the API version selected. If it is not supported,
> > the headers fall back to #defines, which may result in strange
> > renamings, e.g. of methods.
> 
> Why doesn't this use the existing machinery for __attribute__ ((alias)),
> which is effectively the same feature?

I'm not sure I understand the question. This implements a feature
availabe in SunPRO (since 4.2), and used in Sun Solaris header files
(starting with Solaris 8). 

It is somewhat different from __attribute__((alias)) in that the
original name goes away in the pragma, but stays in the alias; so it
is more like asm("labelname"). It "doesn't use" that because the
header files have been written by Sun, and Sun decided to use their
own extension over the GCC one.

To give an example from <fcntl.h> (see PR 4850 for another example),
they define

#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname        open    open64
#pragma redefine_extname        creat   creat64
#else
#define open                    open64
#define creat                   creat64
#endif
#endif  /* !_LP64 && _FILE_OFFSET_BITS == 64 */

As a result, compiling for large file support with GCC on that system,
you will get many object-like macros, which may well interfere with
other headers. For example, this will silently rename the open method
of std::fstream. If the pragma is supported, the Solaris header files
will stop putting these macros into user namespace.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]