Bug 19485

Summary: Syscall module example fails to compile
Product: Base System Reporter: mhenry <mhenry>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-STABLE   
Hardware: Any   
OS: Any   

Description mhenry 2000-06-24 13:20:00 UTC
I'm getting errors when trying to compile the example system
call in /usr/share/examples/kld/syscall/module/syscall.c.
The version of the file is 1.2.

The errors are as follows:

*** In file included from syscall.c:35:
*** /usr/include/sys/systm.h:327: syntax error before `int'
*** /usr/include/sys/systm.h:328: syntax error before `int'
*** /usr/include/sys/systm.h:329: syntax error before `('

The corresponding lines from the header are:

*** int major(dev_t x);
*** int minor(dev_t x);
*** dev_t makedev(int x, int y);

There is a comment above these lines: "Common `dev_t'
stuff are declared here to avoid #include poisoning".
But these lines are getting mangled by the following
macros defined in <sys/types.h>:

*** #define major(x)        ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
*** #define minor(x)        ((int)((x)&0xffff00ff))         /* minor number */
*** #define makedev(x,y)    ((dev_t)(((x) << 8) | (y)))     /* create dev_t */

which, after pre-processing, results in the following:

*** int ((int)(((u_int)( dev_t x ) >> 8)&0xff)) ;
*** int ((int)(( dev_t x )&0xffff00ff)) ;
*** dev_t ((dev_t)((( int x ) << 8) | (  int y ))) ;

Clearly this is nonsense.

Fix: 

Remove offending lines from <sys/systm.h>
How-To-Repeat: cd /usr/share/examples/kld/syscall/module/
gcc -c syscall.c
Comment 1 Ruslan Ermilov 2000-06-24 15:26:31 UTC
On Sat, Jun 24, 2000 at 05:13:39AM -0700, mhenry@speednet.com.au wrote:
> 
> I'm getting errors when trying to compile the example system
> call in /usr/share/examples/kld/syscall/module/syscall.c.
> The version of the file is 1.2.
> 
> The errors are as follows:
> 
> *** In file included from syscall.c:35:
> *** /usr/include/sys/systm.h:327: syntax error before `int'
> *** /usr/include/sys/systm.h:328: syntax error before `int'
> *** /usr/include/sys/systm.h:329: syntax error before `('
> 
> The corresponding lines from the header are:
> 
> *** int major(dev_t x);
> *** int minor(dev_t x);
> *** dev_t makedev(int x, int y);
> 
> There is a comment above these lines: "Common `dev_t'
> stuff are declared here to avoid #include poisoning".
> But these lines are getting mangled by the following
> macros defined in <sys/types.h>:
> 
> *** #define major(x)        ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
> *** #define minor(x)        ((int)((x)&0xffff00ff))         /* minor number */
> *** #define makedev(x,y)    ((dev_t)(((x) << 8) | (y)))     /* create dev_t */
> 
> which, after pre-processing, results in the following:
> 
> *** int ((int)(((u_int)( dev_t x ) >> 8)&0xff)) ;
> *** int ((int)(( dev_t x )&0xffff00ff)) ;
> *** dev_t ((dev_t)((( int x ) << 8) | (  int y ))) ;
> 
> Clearly this is nonsense.
> 
> 
> >How-To-Repeat:
> cd /usr/share/examples/kld/syscall/module/
> gcc -c syscall.c
> 
Try `gcc -D_KERNEL -c syscall.c' or better yet just `make' :-)

> >Fix:
> Remove offending lines from <sys/systm.h>
> 
Add -D_KERNEL to CFLAGS.


-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 2 ru freebsd_committer freebsd_triage 2000-06-24 15:27:09 UTC
State Changed
From-To: open->closed

syscall module example compiles just fine on 4.0-STABLE.