classpath
[Top][All Lists]
Advanced

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

Re: darwin / OS X support - revisited


From: Tom Tromey
Subject: Re: darwin / OS X support - revisited
Date: 27 Jan 2004 10:42:03 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>>>>> "David" == David Bélanger <address@hidden> writes:

David> Note: The diff between Darwin and Linux are quite small,
David> basically 2 lines but I still added a arch.

Darwin is really close enough to other Unices that, IMO, we don't need
a separate architecture for it.

David> +#if (defined( __BIG_ENDIAN__) && defined( __APPLE__ ))
David> +#define __IEEE_BIG_ENDIAN
David> +#endif 

libgcj also uses fdlibm.  We've already got a lot of portability hacks
in it.  I think it would be cool if somebody merged the two.  For this
case we have:

    #if defined (__PPC__) || defined (__ppc__)
    #if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX) \
        || defined (__APPLE__)
    #define __IEEE_BIG_ENDIAN
    #else
    #if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && 
__sun__) || (defined(__WIN32__) && __WIN32__)
    #define __IEEE_LITTLE_ENDIAN
    #endif
    #endif
    #endif

David> It may be tempting to add
David> a __APPLE__ beside the __AIX__, but __PPC__ is not defined by gcc and
David> we still need the CPPFLAGS anyway.

I wonder if this changed at some point.  The above probably wouldn't
work unless gcc defined __PPC__.

David> Here the problem is that O_FSYNC is be defined in fcntl.h.
David> However, fcntl.h is not included for the constant in the generic file.
David> On Linux works fine,
David> OS X don't like it.  So either the Linux fcntl.h gets included
David> by some other include etc.  Would need investigation.

This is the sort of situation where you can just add a configure
check for fcntl.h and #include it.

For libgcj we do this:

    // Some POSIX systems don't have O_SYNC and O_DYSNC so we define them here.
    // Needed in java/io/natFileDescriptorPosix.cc.
    #if !defined (O_SYNC) && defined (O_FSYNC)
    #define O_SYNC O_FSYNC
    #endif
    #if !defined (O_DSYNC) && defined (O_FSYNC)
    #define O_DSYNC O_FSYNC
    #endif
    // If O_DSYNC is still not defined, use O_SYNC (needed for newlib)
    #if !defined (O_DSYNC) 
    #define O_DSYNC O_SYNC
    #endif

David> +#ifdef __MACH__
David> +typedef int    socklen_t;       
David> +#endif
David> I simply added it (without the #ifdef) to the network target specific
David> file.

It's more robust to find the required header and #include it, perhaps
conditionally.

The only really Darwin-specific change we needed in libgcj was
handling the shared library suffix:

    // Prefix and suffix for shared libraries.
    #define _Jv_platform_solib_prefix "lib"
    #if defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
    #define _Jv_platform_solib_suffix ".dylib"
    #else
    #define _Jv_platform_solib_suffix ".so"
    #endif

Everything else is handled using the ordinary configure mechanisms.  I
think this is really the best approach for classpath.  Lots of history
shows that using feature tests is much more robust.  There are only a
few situations where they aren't practical (e.g., the shared library
suffix).

Tom




reply via email to

[Prev in Thread] Current Thread [Next in Thread]