Re: Some general LINUX questions on compiling and header files

mike burrell (mikpos@mikpos.dyndns.org)
Thu, 9 Sep 1999 10:48:33 -0600


Bret Indrelee (breti@bit3.com) said:
> I've been looking around and haven't been able to find a few things on Linux
> that I was expecting to find.
>
> 1. Is there a standard preprocessor token you can check for to know that the
> compilation is on Linux? I'm looking for something like the __sun token that
> is predefined by the compiler, so I can put conditional code in a module I
> share amoungst multiple operating systems.

take a look at your /usr/lib/gcc-lib/*/*/specs file. the important line is:
specs:-D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -Asystem(posix)

so, yes, '#ifdef linux' will work (assuming everyone's specs file is like
mine, hee hee)

> 2. Where is the <stddef.h> header file required by ANSI C? I looked in
> /usr/include and didn't see it.

perhaps you should look in /usr/include/linux

> 3. In kernel code, are you supposed to directly read jiffies or should you
> use a routine to access it? If so, what is the name of the routine? On other
> operating systems, they use a routine to access the information. From what
> I've seen, it looks like it is just directly accessed in Linux.

that's what it looks like to me too. i'm not exactly the best person to
ask, though :)

> 4. When compiling a kernel module, what special flags are required? I would
> expect to have to put in '-r -nostdlib' at the very least.

take a look at the makefiles, they're not too scary.
from /usr/src/linux/arch/*/Makefile:
LDFLAGS=-e stext

also, /usr/src/linux/arch/*/vmlinux.lds has tonnes of cool linker stuff

finally, .*.flags (e.g. in /usr/src/linux/arch/*) might be of some help.

-- 

/"\ m i k e b u r r e l l \ / ASCII RIBBON CAMPAIGN mikpos@home.com X AGAINST HTML MAIL http://mikpos.dyndns.org / \

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