__func__ -> __FUNCTION__
PATCH 1/1 __func__ -> __FUNCTION__
It is a requirement of the SPARC port that Linux be compilable by egcs-1.1.2, aka gcc-2.91.66.
That compiler does not support __func__.
include/linux/kernel.h +2 -0
@@ -13,6 +13,8 @@#include <linux/types.h> #include <linux/compiler.h> +#define __func__ __FUNCTION__/* For old gcc's */ +/* Optimization barrier */ /* The "volatile" is due to gcc bugs */ #define barrier () __asm__ __volatile__("": : :"memory")
Followup to: <[email protected]> By author: Andrew Morton <[email protected]> In newsgroup: linux.dev.kernel
include/linux/kernel.h line 20
Quoted 11 lines
include/linux/kernel.h +2
-0@@ -13,6 +13,8 @@#include <linux/types.h> #include <linux/compiler.h> +#define __func__ __FUNCTION__/* For old gcc's */ +/* Optimization barrier */ /* The "volatile" is due to gcc bugs */ #define barrier () __asm__ __volatile__("": : :"memory")
Shouldn't this be conditional on the version?
Signature · 3 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." http://www.zytor.com/~hpa/puzzle.txt <[email protected]>
Quoted 11 lines · H. Peter Anvin
Followup to: <[email protected]> By author: Andrew Morton <[email protected]> In newsgroup: linux.dev.kernelQuoted 6 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 renamed from include/linux/kernel.h Wed Jul 24 14:31:31 2002 +0
-0@@ -13,6 +13,8 @@ #include <linux/types.h> #include <linux/compiler.h>
Quoted 7 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 line 20
Quoted 5 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 renamed from include/linux/kernel.h Wed Jul 24 14:31:31 2002 +2
-0+#define __func__ __FUNCTION__ /* For old gcc's */ + /* Optimization barrier */ /* The "volatile" is due to gcc bugs */ #define barrier() __asm__ __volatile__("": : :"memory")Shouldn't this be conditional on the version?
Could be. But I don't know what version to use.
Quoted 20 lines · Andrew Morton
Quoted 11 lines · H. Peter Anvin
Followup to: <[email protected]> By author: Andrew Morton <[email protected]> In newsgroup: linux.dev.kernelQuoted 6 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 renamed from include/linux/kernel.h Wed Jul 24 14:31:31 2002 +0
-0@@ -13,6 +13,8 @@ #include <linux/types.h> #include <linux/compiler.h>Quoted 7 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 line 20
Quoted 5 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 renamed from include/linux/kernel.h Wed Jul 24 14:31:31 2002 +2
-0+#define __func__ __FUNCTION__ /* For old gcc's */ + /* Optimization barrier */ /* The "volatile" is due to gcc bugs */ #define barrier() __asm__ __volatile__("": : :"memory")Shouldn't this be conditional on the version?
Quoted 1 line
Could be. But I don't know what version to use.
How about:
/* early gcc compilers lose on __func__ */
#ifndef __func__
#define __func__ __FUNCTION__
#endif /* !defined __func__ */
Signature · 4 lines
"Hmm.. Cache shrink failed - time to kill something? Mhwahahhaha! This is the part I really like. Giggle." -- linux/mm/vmscan.c http://vipe.technion.ac.il/~mulix/ http://syscalltrack.sf.net
Quoted 5 lines · Muli Ben-Yehuda
How about:
/* early gcc compilers lose on
__func__*/ #ifndef__func__#define__func____FUNCTION__#endif /* !defined__func__*/
__func__ isn't a macro; it's a compiler token.
-hpa
Quoted 10 lines · H. Peter Anvin
Quoted 7 lines · Muli Ben-Yehuda
How about:
/* early gcc compilers lose on
__func__*/
#ifndef__func__
#define__func____FUNCTION__
#endif /* !defined__func__*/
__func__isn't a macro; it's a compiler token.
Works for me(TM).
mulix@alhambra:~/tmp$ cat foo.c #include <stdio.h>
#if DEF_FUNC
#ifndef __func__
#define __func__ __FUNCTION__
#endif /* !defined __func__ */
#endif /* DEF_FUNC */
int main()
{
printf("%s\n", __func__);
return 0;
}
mulix@alhambra:~/tmp$ /usr/bin/gcc -v
Reading specs from
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
mulix@alhambra:~/tmp$ /usr/bin/gcc foo.c -DDEF_FUNC=0 -o foo
foo.c: In function `main':
foo.c:11: `__func__' undeclared (first use in this function)
foo.c:11: (Each undeclared identifier is reported only once
foo.c:11: for each function it appears in.)
mulix@alhambra:~/tmp$ /usr/bin/gcc foo.c -DDEF_FUNC=1 -o foo
mulix@alhambra:~/tmp$ ./fooObCompleteyUnrelatedQuestions: where can I find klibc?
Signature · 4 lines
"Hmm.. Cache shrink failed - time to kill something? Mhwahahhaha! This is the part I really like. Giggle." -- linux/mm/vmscan.c http://vipe.technion.ac.il/~mulix/ http://syscalltrack.sf.net
Quoted 6 lines · Muli Ben-Yehuda
Quoted 4 lines · H. Peter Anvin
Quoted 2 lines · Muli Ben-Yehuda
How about:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
/* early gcc compilers lose on
__func__*/ #ifndef__func__#define__func____FUNCTION__#endif /* !defined__func__*/
__func__isn't a macro; it's a compiler token.Works for me(TM).
But it won't work on a compiler that actually *supports* __func__...
I think that is gcc 3.1 or higher, but I'm not the authority...
Quoted 1 line
ObCompleteyUnrelatedQuestions: where can I find klibc?
ftp://ftp.kernel.org/pub/linux/libs/klibc/
-hpa
Quoted 4 lines · H. Peter Anvin
But it won't work on a compiler that actually *supports*
__func__...I think that is gcc 3.1 or higher, but I'm not the authority...
Again, works for me.
http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.html (search for __func__) would seem to imply that you are correct, though. Perhaphs someone more knowledgable about gcc could shed some light?
mulix@tea:~/tmp$ cat foo.c #include <stdio.h>
#if DEF_FUNC
#ifndef __func__
#define __func__ __FUNCTION__
#endif /* !defined __func__ */
#endif /* DEF_FUNC */
int main()
{
printf("%s\n", __func__);
return 0;
}
mulix@tea:~/tmp$ gcc3 -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc-3.1/configure --enable-threads
--enable-languages=c,c++
Thread model: posix
gcc version 3.1
mulix@tea:~/tmp$ gcc3 foo.c -DDEF_FUNC=1 -o foo
mulix@tea:~/tmp$ ./foo
main
mulix@tea:~/tmp$ gcc3 foo.c -DDEF_FUNC=0 -o foo
mulix@tea:~/tmp$ ./foo
main
mulix@tea:~/tmp$ Quoted 3 lines
Quoted 1 line
ObCompleteyUnrelatedQuestions: where can I find klibc?
ftp://ftp.kernel.org/pub/linux/libs/klibc/
Much obliged.
Signature · 4 lines
"Hmm.. Cache shrink failed - time to kill something? Mhwahahhaha! This is the part I really like. Giggle." -- linux/mm/vmscan.c http://vipe.technion.ac.il/~mulix/ http://syscalltrack.sf.net
Quoted 20 lines · Andrew Morton
Quoted 11 lines · H. Peter Anvin
Followup to: <[email protected]> By author: Andrew Morton <[email protected]> In newsgroup: linux.dev.kernelQuoted 6 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 renamed from include/linux/kernel.h Wed Jul 24 14:31:31 2002 +0
-0@@ -13,6 +13,8 @@ #include <linux/types.h> #include <linux/compiler.h>Quoted 7 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 line 20
Quoted 5 lines
include/linux/kernel.h Mon Aug 12 23:09:31 2002 renamed from include/linux/kernel.h Wed Jul 24 14:31:31 2002 +2
-0+#define __func__ __FUNCTION__ /* For old gcc's */ + /* Optimization barrier */ /* The "volatile" is due to gcc bugs */ #define barrier() __asm__ __volatile__("": : :"memory")Shouldn't this be conditional on the version?
Quoted 1 line
Could be. But I don't know what version to use.
#if __GNUC__ <= 2 && __GNUC_MINOR__ < 95
#define __func__ __FUNCTION__
#endif
Max
Quoted 5 lines · Andrew Morton
It is a requirement of the SPARC port that Linux be compilable by egcs-1.1.2, aka gcc-2.91.66.
That compiler does not support
__func__.
Is there any reason to not use __FUNCTION__? According to the gcc folks that there is no plan to retire it, and as long as all known-good kernel compilers support it a gccism is a lot better than a standard feature that is not supported by most of the kernel compilers.
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Andrew Morton
It is a requirement of the SPARC port that Linux be compilable by egcs-1.1.2, aka gcc-2.91.66.
Quoted 6 lines
Quoted 1 line
That compiler does not support
__func__.Is there any reason to not use
__FUNCTION__? According to the gcc folks that there is no plan to retire it, and as long as all known-good kernel compilers support it a gccism is a lot better than a standard feature that is not supported by most of the kernel compilers.
Sounds fine to me.
include/linux/kernel.h +2 -0
@@ -13,6 +13,8 @@#include <linux/types.h> #include <linux/compiler.h> +#define __func__ use.__FUNCTION__.not.__func__ +/* Optimization barrier */ /* The "volatile" is due to gcc bugs */ #define barrier () __asm__ __volatile__("": : :"memory")
It affects
drivers/char/drm/mga_dma.cdrivers/char/drm/mga_drv.hdrivers/char/drm/mga_state.cdrivers/char/drm/r128_cce.cdrivers/char/drm/r128_drv.hdrivers/char/drm/r128_state.cdrivers/char/drm/radeon_cp.cdrivers/char/drm/radeon_drv.hdrivers/char/drm/radeon_state.cinclude/net/bluetooth/bluetooth.h