omegaonline / oobase

Omega Online Base library
2 stars 1 forks source link

BUG: OSX build fails to configure libtdl #12

Open jamal-fuma opened 8 years ago

jamal-fuma commented 8 years ago

Attached archive of osx configure run

Archive.zip

jamal-fuma commented 8 years ago

Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive Making all in libltdl GEN libltdl/ltargz.h /Applications/Xcode.app/Contents/Developer/usr/bin/make all-am CC loaders/dlopen.lo CCLD dlopen.la CC loaders/libltdlc_la-preopen.lo CC libltdlc_la-ltalloc.lo CC libltdlc_la-lt_dlloader.lo CC libltdlc_la-lt_error.lo CC libltdlc_la-ltdl.lo CC libltdlc_la-slist.lo CC lt__argz.lo CCLD libltdlc.la Making all in . CXX src/liboobase_la-ArenaAllocator.lo In file included from ../src/ArenaAllocator.cpp:50: In file included from ../src/../include/OOBase/ArenaAllocator.h:25: ../src/../include/OOBase/Memory.h:27:10: fatal error: 'malloc.h' file not found

include

     ^

1 error generated. make[2]: * [src/liboobase_la-ArenaAllocator.lo] Error 1 make[1]: * [all-recursive] Error 1 make: *\ [all] Error 2

jamal-fuma commented 8 years ago

Commenting out malloc.h, results in compile errors due to lack of OSX native Timeout.h implementation.

I have an existing solution for this using the NextStep API so it works on OSX and IOS.

This was just some timing code I wrote while profiling my trie-based routing engine, it's currently unpublished but am happy to donate it for reshaping, it's currently c++11 only but very minimally so, I think its only defaulted destructors, I use.

[Edit] it was on defaulted destrctors so have removed them, so it should be C98 compatible.

#include <mach/clock.h>
#include <mach/mach.h>
#include <mach/mach_time.h>

struct TimeBase
{
    TimeBase()
    {
        m_timebase.numer = 0;
        m_timebase.denom = 0;
        mach_timebase_info(&m_timebase);
    }
    ~TimeBase(){}

    uint64_t to_nanoseconds(uint64_t ticks) const
    {
        return ticks * (uint64_t)m_timebase.numer / (uint64_t)m_timebase.denom;
    }

    mach_timebase_info_data_t m_timebase;
};

struct TimeSpec
{
    TimeSpec(uint64_t ns_diff)
    {
        reset(ns_diff);
    }

    void reset(uint64_t ns_diff)
    {
        m_tv_sec  = ns_diff / 1000000000UL;
        m_tv_nsec = ns_diff % 1000000000UL;

    }
    ~TimeSpec(){}

    uint64_t m_tv_sec;
    uint64_t m_tv_nsec;
};

struct HiResTimer
{
    HiResTimer()
        : m_ns_first_tick(mach_absolute_time())
        , m_timebase()
    {
    }
    ~HiResTimer(){}

    uint64_t sample() const
    {
        // sample monatonic clock
        uint64_t ns_start = mach_absolute_time() - m_ns_first_tick;

        // convert to adjusted nanoseconds
        return m_timebase.to_nanoseconds(ns_start);
    }

    uint64_t m_ns_first_tick;
    TimeBase m_timebase;
};
ricktaylor commented 8 years ago

No posix time support on osx. Weird!

That mach stuff should port okay

Rick

Sent from my HTC

----- Reply message ----- From: "Jamal Natour" notifications@github.com To: "omegaonline/oobase" oobase@noreply.github.com Cc: "Rick Taylor" rick@tropicalstormsoftware.com Subject: [omegaonline/oobase] BUG: OSX build fails to configure libtdl (#12) Date: Sun, Apr 17, 2016 09:31

Commenting out malloc.h, results in compile errors due to lack of OSX native Timeout.h implementation.

I have an existing solution for this using the NextStep API so it works on OSX and IOS.

This was just some timing code I wrote while profiling my trie-based routing engine, it's currently unpublished but am happy to donate it for reshaping, it's currently c++11 only but very minimally so, I think its only defaulted destructors, I use.

include

include

include

struct TimeBase { TimeBase() { m_timebase.numer = 0; m_timebase.denom = 0; mach_timebase_info(&m_timebase); } ~TimeBase() = default;

uint64_t to_nanoseconds(uint64_t ticks) const { return ticks * (uint64_t)m_timebase.numer / (uint64_t)m_timebase.denom; }

mach_timebase_info_data_t m_timebase;

};

struct TimeSpec { TimeSpec(uint64_t ns_diff) { reset(ns_diff); }

void reset(uint64_t ns_diff) { m_tv_sec = ns_diff / 1000000000UL; m_tv_nsec = ns_diff % 1000000000UL;

} ~TimeSpec() = default;

uint64_t m_tv_sec; uint64_t m_tv_nsec;

};

struct HiResTimer { HiResTimer() : m_ns_first_tick(mach_absolute_time()) , m_timebase() { } ~HiResTimer() = default;

uint64_t sample() const { // sample monatonic clock uint64_t ns_start = mach_absolute_time() - m_ns_first_tick;

// convert to adjusted nanoseconds
return m_timebase.to_nanoseconds(ns_start);

}

uint64_t m_ns_first_tick; TimeBase m_timebase;

}; /

— You are receiving this because you were assigned. Reply to this email directly or view it on GitHubhttps://github.com/omegaonline/oobase/issues/12#issuecomment-211011802

jamal-fuma commented 8 years ago

Digging into this a little more, I'm not convinced the timespec stuff shouldn't work on OSX.

I think its a configure issue as Timeout.h has

if defined(_WIN32)

    LONGLONG   m_end;

elif defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)

    ::timespec m_end;

else

error Implement platform native time

endif

But OSX has timespec defined with inclusion of <time.h> and <sys/time.h>

jamal-fuma commented 8 years ago

Digging into this a bit further. _POSIX_TIMERS is from ANSI/IEEE standards POSIX 1003.1b-1993 and POSIX 1003.1i-1995. and as far as I can verify is Linux only (might be other bsd's but not OSX)

So looking around this, it's clock_getime that you rely on, which is indeed not on OSX

Options, seem to be? 1) write an osx specific implemention as per windows.

2) wrap calls to get_clocktime as Omega::get_clocktime() which keeps the posix layer more or less unchanged.

3) use link replacement to replace get_clocktime via the autotools transparent mechinism, e.g. provide get_clocktime.c as a platform fallback?