[prev in list] [next in list] [prev in thread] [next in thread]
List: pcc-list
Subject: Re: Correct way to redirect functions at asm level?
From: Gregory McGarry <greg () bitlynx ! com>
Date: 2009-08-24 21:25:29
Message-ID: 2B2839F7-3891-433E-B0B3-DD452A3671DD () bitlynx ! com
[Download RAW message or body]
On 25/08/2009, at 1:07 AM, Detlef Riekenberg wrote:
> glibc does a redirection for several c functions at the asm level.
> (lstat, pread, pwrite as examples).
>
> I added "defined __PCC__" to the Macro definition <sys/cdefs.h>
>
> Is this the correct way to do that?
>
> -------- part of sys/cdefs.h --
> /* __asm__ ("xyz") is used throughout the headers to rename functions
> at the assembly language level. This is wrapped by the __REDIRECT
> macro, in order to support compilers that can do this some other
> way. When compilers don't support asm-names at all, we have to do
> preprocessor tricks instead (which don't have exactly the right
> semantics, but it's the best we can do).
>
> Example:
> int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
>
> #if defined __PCC__ || (defined __GNUC__ && __GNUC__ >= 2)
>
> # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME
> (#alias))
> # ifdef __cplusplus
> # define __REDIRECT_NTH(name, proto, alias) \
> name proto __THROW __asm__ (__ASMNAME (#alias))
> # else
> # define __REDIRECT_NTH(name, proto, alias) \
> name proto __asm__ (__ASMNAME (#alias)) __THROW
> # endif
> # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
> # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
>
> /*
> #elif __SOME_OTHER_COMPILER__
>
> # define __REDIRECT(name, proto, alias) name proto; \
> _Pragma("let " #name " = " #alias)
> */
> #endif
> ------------------------------
I believe that should work. The OSX headers and mingw sources do the
same thing.
#if __DARWIN_UNIX03 && !defined(__LP64__)
#define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) "$UNIX2003")
#else
#define __DARWIN_ALIAS(sym)
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic