NetBSD-Users archive

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

Re: NetBSD macros

Masao Uebayashi wrote:
> > 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
> How many kind of interfaces do you need?  If you're not going to write a
> software which can run on top of either GNOME or KDE or whatever, you
> won't need autoconf

The number of #if tests isn't governed by the number of interfaces.  The
above code expands with the number of operating systems.  Where are the
other BSDs, the 2.4 linux kernel, Irix, AIX, etc?  And how do you know
where to put them?  

By letting autoconf test for functionality, which matters, rather than OS,
which doesn't, the code becomes more robust, more portable, and more

        use NetBSD atomic_ops
        use Solaris atomic_ops
        use Linux atomic_ops
        use pthread_mutex_lock
#error "need some kinda atomic ops"

(Of course, the _HAVE_ label could be more descriptive.) 


Home | Main Index | Thread Index | Old Index