lkml.org 
[lkml]   [2009]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Confusion in usr/include/asm-generic/fcntl.h
David Miller wrote:
> From: Jaswinder Singh Rajput <jaswinder@kernel.org>
> Date: Wed, 21 Jan 2009 05:34:17 +0530
>
>> usr/include/asm-generic/fcntl.h is giving 2 'make headers_check' warnings:
>> usr/include/asm-generic/fcntl.h:127: leaks CONFIG_64BIT to userspace where it is not valid
>> usr/include/asm-generic/fcntl.h:149: leaks CONFIG_64BIT to userspace where it is not valid
>>
>> usr/include/asm-generic/fcntl.h:
> ...
>> #ifndef CONFIG_64BIT will always be true for userspace. So what is the use of #ifndef CONFIG_64BIT ?
>
> Good catch.
>
> This file needs to test for 64-bit'ness using some non-CONFIG_*
> test. And the standard built-in CPP macros which can be used
> to check for that are different on every platform.
>

There are a few ways to check for 64-bitness that are
platform-independent, unfortunately each of them have drawbacks.

a) the gcc-specific way:

#if __SIZEOF_POINTER__ == 8

or

#ifdef __LP64__

or any other number of variants.

It has the obvious disadvantage of being gcc-specific, although
it seems rather likely that other Linux-supporting compilers might
also define these macros.

b) the standard C way:

#include <limits.h>

#if LONG_MAX > 2147483647L

it has the obvious disadvantage of needing to include <limits.h>...

We can, of course, also do our own thing as DaveM suggested; this is
probably the best option. FWIW, glibc has _WORDSIZE which is equivalent
to what we call BITS_PER_LONG. We might as well export it under that
name (presumably under #ifndef).

-hpa


\
 
 \ /
  Last update: 2009-01-21 01:51    [W:0.101 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site