They aren't, and the gcc people have been trying to get rid of the
defines without underscores for YEARS. Don't make their job harder.
You want #ifdef __linux__.
"gcc -E -dM - </dev/null" is an easier way to find out what's predefined.
> > 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
Nope. /usr/lib/gcc-lib/i486-linux/2.7.2.3/include. "i486-linux" and
"2.7.2.3" may be different depending on your compiler. You don't need
any special command line switches to make the compiler find it.
This is a good place to point out that except in very specific unusual
contexts, user space code should never include linux/whatever.h or
asm/whatever.h. There will be a sys/whatever.h or net/whatever.h (the
name might be slightly different) that has what you want.
> > 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 :)
I get the same impression. There are special routines (macros
actually) for *comparing* jiffies values: you'll see things like
if (time_before(timeout, jiffies)) { ... }
where timeout has been set previously.
> > 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.
You don't actually _link_ a kernel module. The appropriate switches
are something like -c -D__KERNEL__ -DMODULE and possibly -DMODVERSIONS.
For this, I would look at the sources for pcmcia-cs-3.0.x, it compiles
a bunch of modules outside the kernel tree. Doing so is not trivial.
zw
-
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/