NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NetBSD macros

Sad Clouds wrote:
> On Friday 11 December 2009 18:51:42 Chuck Swiger wrote:
> > In other words, Matthias' suggestion to query uname(3) (and
> > getrlimit(2),
> >  sysctl(3), etc) when the program runs is much better than compiling
> >  in data from a system header and assuming the binary will always run
> >  in that same context.
> Under NetBSD, Linux 
> and Solaris you would have to to use different functions.
> There is not much else you can do apart from writing code like:
> #if NetBSD && NetBSD_Version >= 5.0
>       use NetBSD atomic_ops
> #elif Solaris
>       use Solaris atomic_ops
> #elif Linux
>       use Linux atomic_ops
> #else
>       use pthread_mutex_lock
> #endif

And that in fact is why autoconf was invented.  I'm not a huge autoconf
fan except, like old age, for the alternative.  The above tests are
indirect and force you to chase flavors and versions as feature sets
evolve.  Autoconf -- Chuck's wise observation notwithstanding -- provides
direct feature tests, letting you ask not what the OS is, but whether the
function you want is provided (and works).  Which is what you really want.


Home | Main Index | Thread Index | Old Index