NetBSD-Users archive

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

Re: NetBSD macros

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.
> Regards,

There are some things you can't perform during run time. For example, if you 
want to use atomic_ops functions, their availability and prototypes depend on 
the type of the operating system and the release version. 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
        use pthread_mutex_lock

Home | Main Index | Thread Index | Old Index