lkml.org 
[lkml]   [1999]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: Some general LINUX questions on compiling and header files
Date

> mike burrell wrote:
> > 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)
>
> 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.
jiffies is global kernel variable -accessed directly-
It's been updated somewhere in scheduler AFAIK.

Fabian

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.046 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site