lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 30 Oct 2006 00:08:42 -0500
From:	Kyle Moffett <mrmacman_g4@....com>
To:	Adrian Bunk <bunk@...sta.de>
Cc:	"Robert P. J. Day" <rpjday@...dspring.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Oleg Verych <olecom@...wer.upol.cz>
Subject: Re: why test for "__GNUC__"?

On Oct 29, 2006, at 22:38:34, Adrian Bunk wrote:
>> for better or worse, i generally assume that whatever i'm looking  
>> at is there for a *reason* and i might spend some time puzzling  
>> over a bit of code until it finally dawns on me that it's just  
>> historical cruft that has no value.  it's not a bug, it just  
>> doesn't *do* anything anymore.
>>
>> in my case, it's sometimes easier to spot things like this since  
>> i'm following along in some book, like r. love's "linux kernel  
>> development."  so when he writes that the linux kernel is wedded  
>> to gcc, and yet i see tests for "__GNUC__" throughout the code, my  
>> little antenna stalks perk up a bit.
>
> Looking at it, it seems I might look through them - some of them  
> seem to be really pointless.

One other thing of note is that certain linux kernel headers _are_  
used by userspace (albeit in a number of cases legacy userspace), and  
as a result we need to ensure that they continue to build on the  
variety of compilers currently used in userspace.  Naturally this  
doesn't apply to everything, but see the recent threads involving  
(IIRC) some part of KDE and indirectly <linux/types.h>.  From what  
Linus has stated in the past it sounds like his goal is to make the  
user<=>libc interface completely 100% separated from the  
libc<=>kernel interface such that neither includes the other, but a  
lot of older userspace violates those assumptions.  As a result, if  
we want older versions of libc's to continue to work in various  
compilers with newer kernel headers we need to maintain some of that  
"compatibility cruft".

That said, if __GNUC__ is mentioned inside __KERNEL__ in anything  
other than a version test then it should probably be removed.  To  
that end these little macros in <linux/compiler.h> might make it a  
bit more obvious what's being tested and make it easier to grep for:

#ifdef __KERNEL__
# define GCC_VERSION ((__GNUC__ << 24) | \
	(__GNUC_MINOR__ << 16) | \
	(__GNUC_PATCHLEVEL__))
# define GCC_AT_LEAST(x,y,z) (GCC_VERSION >= (((x)<<24)|((y)<<16)|(z)))
# define GCC_OLDER_THAN(x,y,z) (!GCC_AT_LEAST(x,y,z))
#endif

> There's also the kernelnewbies list.
>
> But your emails are not as bad as you think - the email starting  
> this thread as well as your earlier emails regarding menu structure  
> etc. have some value (and they are better than many other questions  
> that hit this list...).

I personally tend to agree; seems like some of this cruft is just  
accepted status-quo because it would be so tedious and git-queue- 
blocking to go through and clean it all up.

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists