2003-05-13 23:47:44

by Stephen Torri

[permalink] [raw]
Subject: Compile error including asm/uaccess.h

GLIBC VERSION: 2.3.1

HOST MACHINE and OPERATING SYSTEM: i686 Gentoo Linux 1.4.2.9

KERNEL VERSION: 2.4.18

TARGET MACHINE and OPERATING SYSTEM, if different from HOST: Same

COMPILER NAME AND VERSION (AND PATCHLEVEL): g++ 3.2.2

DOES THE PROBLEM AFFECT:
COMPILATION? Yes.
LINKING? No
EXECUTION? No
OTHER (please specify)? No

SYNOPSIS:

Receiving a compiler error when attempting to include asm/uacccess.h

DESCRIPTION:

I am compiling a program that is written in C++ so the g++ compiler is
being used to compile the source. On of the headers of a dependent
library is including asm/uaccess.h. When I attempt to compile this
program I get parse errors.

====== Errors (C++) ==========

In file included from /usr/include/linux/sched.h:14,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/linux/timex.h:173: field `time' has incomplete type
In file included from /usr/include/linux/sched.h:17,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/asm/system.h:238: parse error before `new'
/usr/include/asm/system.h: In function `long unsigned int
__cmpxchg(...)':
/usr/include/asm/system.h:241: `size' undeclared (first use this
function)
/usr/include/asm/system.h:241: (Each undeclared identifier is reported
only
once for each function it appears in.)
/usr/include/asm/system.h:245: parse error before `)' token
/usr/include/asm/system.h:251: parse error before `)' token
/usr/include/asm/system.h:257: parse error before `)' token
/usr/include/asm/system.h:261: `old' undeclared (first use this
function)
In file included from /usr/include/asm/smp.h:15,
from /usr/include/linux/smp.h:14,
from /usr/include/linux/sched.h:23,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/asm/fixmap.h: At global scope:
/usr/include/asm/fixmap.h:77: type specifier omitted for parameter
`pgprot_t'
/usr/include/asm/fixmap.h:77: parse error before `)' token
In file included from /usr/include/asm/smp.h:21,
from /usr/include/linux/smp.h:14,
from /usr/include/linux/sched.h:23,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/asm/apic.h:85: `pm_dev_t' was not declared in this scope
/usr/include/asm/apic.h:85: parse error before `long'
In file included from /usr/include/linux/sched.h:23,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/linux/smp.h:29: parse error before `)' token
In file included from /usr/include/asm/processor.h:11,
from /usr/include/linux/sched.h:87,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/asm/math_emu.h: In function `void FASTCALL(...)':
/usr/include/asm/math_emu.h:6: non-local function `int
restore_i387_soft(void*,
FASTCALL(...)::_fpstate*)' uses local type `FASTCALL(...)::_fpstate'
/usr/include/asm/math_emu.h:7: non-local function `int
save_i387_soft(void*,
FASTCALL(...)::_fpstate*)' uses local type `FASTCALL(...)::_fpstate'
In file included from /usr/include/linux/sched.h:87,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/asm/processor.h:73: non-local variable
`FASTCALL(...)::cpuinfo_x86
boot_cpu_data' uses local type `FASTCALL(...)::cpuinfo_x86'
/usr/include/asm/processor.h:77: non-local variable
`FASTCALL(...)::cpuinfo_x86
cpu_data[]' uses local type `FASTCALL(...)::cpuinfo_x86'
/usr/include/asm/processor.h:97: non-local function `void
identify_cpu(FASTCALL(...)::cpuinfo_x86*)' uses local type `
FASTCALL(...)::cpuinfo_x86'
/usr/include/asm/processor.h:98: non-local function `void
print_cpu_info(FASTCALL(...)::cpuinfo_x86*)' uses local type `
FASTCALL(...)::cpuinfo_x86'
/usr/include/asm/processor.h:126: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `void cpuid(int, int*, int*,
int*,
int*)':
/usr/include/asm/processor.h:139: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `unsigned int
cpuid_eax(unsigned
int)':
/usr/include/asm/processor.h:149: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `unsigned int
cpuid_ebx(unsigned
int)':
/usr/include/asm/processor.h:159: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `unsigned int
cpuid_ecx(unsigned
int)':
/usr/include/asm/processor.h:169: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `unsigned int
cpuid_edx(unsigned
int)':
/usr/include/asm/processor.h:206: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `void set_in_cr4(long unsigned
int)':
/usr/include/asm/processor.h:216: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `void clear_in_cr4(long
unsigned
int)':
/usr/include/asm/processor.h:432: non-local function `void
release_thread(clear_in_cr4(long unsigned int)::task_struct*)' uses
local
type `clear_in_cr4(long unsigned int)::task_struct'
/usr/include/asm/processor.h:439: non-local function `void
copy_segments(clear_in_cr4(long unsigned int)::task_struct*,
clear_in_cr4(long unsigned int)::mm_struct*)' uses local type `
clear_in_cr4(long unsigned int)::task_struct'
/usr/include/asm/processor.h:440: non-local function `void
release_segments(clear_in_cr4(long unsigned int)::mm_struct*)' uses
local
type `clear_in_cr4(long unsigned int)::mm_struct'
/usr/include/asm/processor.h:446: cannot declare static function inside
another
function
/usr/include/asm/processor.h: In function `long unsigned int
thread_saved_pc(clear_in_cr4(long unsigned int)::thread_struct*)':
/usr/include/asm/processor.h:450: non-local function `long unsigned int
get_wchan(clear_in_cr4(long unsigned int)::task_struct*)' uses local
type `
clear_in_cr4(long unsigned int)::task_struct'
/usr/include/asm/processor.h:479: cannot declare static function inside
another
function
In file included from /usr/include/asm/uaccess.h:9,
from test.cpp:1:
/usr/include/linux/prefetch.h: In function `void prefetch(const void*)':
/usr/include/linux/prefetch.h:48: cannot declare static function inside
another
function
In file included from test.cpp:1:
/usr/include/asm/uaccess.h: In function `void prefetchw(const void*)':
/usr/include/asm/uaccess.h:63: cannot declare static function inside
another
function
/usr/include/asm/uaccess.h: In function `int verify_area(int, const
void*, long
unsigned int)':
/usr/include/asm/uaccess.h:64: `current' undeclared (first use this
function)
/usr/include/asm/uaccess.h:64: `EFAULT' undeclared (first use this
function)
/usr/include/asm/uaccess.h:310: cannot declare static function inside
another
function
/usr/include/asm/uaccess.h: In function `long unsigned int
__generic_copy_from_user_nocheck(void*, const void*, long unsigned
int)':
/usr/include/asm/uaccess.h:317: cannot declare static function inside
another
function
/usr/include/asm/uaccess.h: In function `long unsigned int
__generic_copy_to_user_nocheck(void*, const void*, long unsigned
int)':
/usr/include/asm/uaccess.h:548: cannot declare static function inside
another
function
/usr/include/asm/uaccess.h: In function `long unsigned int
__constant_copy_to_user(void*, const void*, long unsigned int)':
/usr/include/asm/uaccess.h:557: cannot declare static function inside
another
function
/usr/include/asm/uaccess.h: In function `long unsigned int
__constant_copy_from_user(void*, const void*, long unsigned int)':
/usr/include/asm/uaccess.h:561: `memset' undeclared (first use this
function)
/usr/include/asm/uaccess.h:567: cannot declare static function inside
another
function
/usr/include/asm/uaccess.h: In function `long unsigned int
__constant_copy_to_user_nocheck(void*, const void*, long unsigned
int)':
/usr/include/asm/uaccess.h:574: cannot declare static function inside
another
function


REPEAT BY:

Here a test programs that I did:

#include <asm/uaccess.h>

int main (){
return 0;
}



SAMPLE FIX/WORKAROUND:

None.

Stephen


--
Stephen Torri <[email protected]>


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2003-05-14 13:22:18

by ismail donmez

[permalink] [raw]
Subject: Re: Compile error including asm/uaccess.h

<snip>
====== Errors (C++) ==========

In file included from /usr/include/linux/sched.h:14,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/linux/timex.h:173: field `time' has incomplete type
In file included from /usr/include/linux/sched.h:17,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/asm/system.h:238: parse error before `new'
/usr/include/asm/system.h: In function `long unsigned int
__cmpxchg(...)':
/usr/include/asm/system.h:241: `size' undeclared (first use this
function)
/usr/include/asm/system.h:241: (Each undeclared identifier is reported
only

</snip>

Well rule of thumb says "Do not include kernel headers in userspace" second rule of thumb says "if you have to do so take care of variables that is need to be defined..."

2003-05-14 13:24:28

by ismail donmez

[permalink] [raw]
Subject: Re: Compile error including asm/uaccess.h

<snip>
In file included from /usr/include/linux/sched.h:14,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/linux/timex.h:173: field `time' has incomplete type
In file included from /usr/include/linux/sched.h:17,
from /usr/include/asm/uaccess.h:8,
from test.cpp:1:
/usr/include/asm/system.h:238: parse error before `new'
/usr/include/asm/system.h: In function `long unsigned int
__cmpxchg(...)':
/usr/include/asm/system.h:241: `size' undeclared (first use this
function)
/usr/include/asm/system.h:241: (Each undeclared identifier is reported
only
once for each function it appears in.)
/usr/include/asm/system.h:245: parse error before `)' token
/usr/include/asm/system.h:251: parse error before `)' token
/usr/include/asm/system.h:257: parse error before `)' token
/usr/include/asm/system.h:261: `old' undeclared (first use this
function)
</snip>

Dont include kernel headers in userspace OR define the needed variables to make your userspace application compile.

Nice report btw

/ismail

2003-05-14 13:58:08

by Stephen Torri

[permalink] [raw]
Subject: Re: Compile error including asm/uaccess.h

> Dont include kernel headers in userspace OR define the needed variables to make your userspace application compile.
>
> Nice report btw
>
> /ismail

How then do you wrote an application to utilize kernel features? I am
working on a real-time operating system (KURT - http://www.ittc.ku.edu/kurt)
and need to include a header that exists in the kernel. The header is
installed in the /usr/src/linux/include/linux/ but not in
/usr/include/linux.

Thanks about the report. I got the idea from a library I help work on
called ACE+TAO (http://www.cs.wustl.edu/~schmidt/ACE.html).

Stephen
--
Stephen Torri <[email protected]>


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2003-05-14 14:25:25

by Ahmed Masud

[permalink] [raw]
Subject: Re: Compile error including asm/uaccess.h

>
> #include <asm/uaccess.h>
>
> int main (){
> return 0;
> }


Hi stephen:

<asm/uaccess.h> or for that matter any other kernel related header do
not contain references to other headers they may need, and this is done on
purpose for various reasons least of which is creating faster dependencies
information.

In any event, if your purpose is to use any information usefully from
these, then you should look into an other file in the kernel code that
includes this file and see the headers that are include before it.

Also have a look at the defines that go with compiling this file.

If you are simply verifying the existence of this file in an autoconf
configure type script (which may be the case looking at your example
code). Then you should write your own test of somesort rather than
resorting to AC_CONFIG_HEADER.

Cheers,

Ahmed.

For more info have a look at http://www.kernelnewbies.org

2003-05-15 06:08:52

by ismail donmez

[permalink] [raw]
Subject: Re: Compile error including asm/uaccess.h

On Wednesday 14 May 2003 17:19, Stephen Torri wrote:
> How then do you wrote an application to utilize kernel features? I am
> working on a real-time operating system (KURT - http://www.ittc.ku.edu/kurt)
> and need to include a header that exists in the kernel. The header is
> installed in the /usr/src/linux/include/linux/ but not in
> /usr/include/linux.
>

See what definitions missing and typedef them in your own source code. That
way you wont need other kernel headers.


--
Brain fried -- Core dumped