brunodebus / tinq-core

Tinq Project
Other
12 stars 8 forks source link

Fixes to support building on OS X #8

Open wjwwood opened 9 years ago

wjwwood commented 9 years ago

I was building on my macbook and ran into a few issues in addition to needing to install a few packages from Homebrew. So I made a pull request with my changes in case you guys want to incorperate them. I have not tested these changes on Linux.

Also I had to install these things from Homebrew before building:

mouse256 commented 9 years ago

wouldn't it be better to use gettimeofday() instead fo clock_get_time()? I believe this is portable for both osx as linux. It is already used in qeo-c/qeo-c-core/src/core.c.

wjwwood commented 9 years ago

Certainly you could use gettimeofday() which should be portable, but it has a lower resolution timestruct (us vs ns) so I wanted to emulate the existing code as closely as possible.

mouse256 commented 9 years ago

I see, good point. However the precision of that part is not really critical. It's used to poll for upnp changes every once and a while, so some drag doesn't harm.

wjwwood commented 9 years ago

I guess the other big difference between the two is that with clock_get_time() can be made to be monotonic, where as gettimeofday() can time travel backwards or forwards if the system time is changed during run time. I don't know if that makes a difference.

brunodebus commented 9 years ago

The monotonicity is indeed important in this piece of code. So I would go with the clock_get_time implementation. However, could we also put it in ./tinq-core/dds/src/co/sys.c:800? This is the code dds uses to simulate clock_gettime on OSX. It would also benefit from a monotonic clock with better resolution....

@wjwwood: would you be willing to cput your code there as well and update your pull request? @mouse256: maybe we should simply use the dds implementation, or we could try to use DDS_Timer iso the timers that the forwarder is currently using?

wjwwood commented 9 years ago

@brunodebus Sure, I'll look at doing that today.

wjwwood commented 9 years ago

Ok, so I moved the code, but it is a bit messy and I don't know how you want it organized. I'll comment on the changes inline in a few places.