[K42-discussion] Getting rid of inline linux function problems in C++
Patrick G. Bridges
bridges at cs.unm.edu
Fri Sep 14 00:55:11 EST 2007
On Sep 12, 2007, at 3:25 PM, Amos Waterland wrote:
> On Wed, Sep 12, 2007 at 02:42:52PM -0600, Patrick G. Bridges wrote:
>> Anyone have any tricks on how to deal with included (from Linux
>> headers) inline C code that's not legal C++ without changing the base
>> linux source? In particular, asm/thread_info.h on the x86_64 assigns
>> a void * to a typed pointer, which gcc 4 barfs on as illegal C++...
>
> Our general technique, discovered by Michal Ostrowski if I remember
> correctly, is illustrated in the following:
>
> #define private __C__private
> #include <linux/cpu.h>
> #undef private
>
> I hope you can find a pattern in the offending C code that you can
> modify in this manner.
Yes, this will work for C keywords that conflict with C++ keywords.
The problem is that this code is the following:
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
ti = (void *)(read_pda(kernelstack) + PDA_STACKOFFSET -
THREAD_SIZE);
return ti;
}
The C++ problem here seems to be the implicit cast from (void *) to
(struct thread_info *), which the C++ compiler will not allow by C
compilers will. I don't see an easy macro substitution for this one. :(
-Patrick
More information about the K42-discussion
mailing list