3

We are porting a linux app to macOS / iOS

The app uses a timer wheel and timer_t type. This type is not defined in time.h class of macOS as described in:

why is "timer_t" defined in "time.h" on Linux but not OS X

Also the methods timer_create(), timer_settime() and timer_delete() are not defined.

This is the class that I'm porting: https://github.com/OpenOverlayRouter/oor/blob/testing/oor/lib/timers.c

We found that maybe we can do this with NSTimer and Objective-C but I would like to do in C.

Can we do it in C? Which kernel libraries should we use?

Thanks

6
  • 2
    What system calls use this timer_t type, and what does the code use them for? Commented Jun 27, 2017 at 17:00
  • We use it in a timer wheel algorithm stackoverflow.com/questions/867621/efficient-timer-algorithm Commented Jun 27, 2017 at 17:24
  • I thought you said you were porting an application to macOS, but you're asking about how to port a library to allow you to not port the application. Am I right? Commented Jun 27, 2017 at 17:27
  • You're going to have to implement timer_settime on macOS, or rewrite that library to instead use some other timer callback scheme; maybe see how libevent or such implements timers on *BSD systems? Commented Jun 28, 2017 at 14:09
  • Yes, I have to implement timer_settime, timer_create, timer_delete and timer_t type, or search another way to provide the same function... @thrig Commented Jun 28, 2017 at 14:41

1 Answer 1

3

After talking with Apple Support:

The most obvious candidate here is dispatch timer sources.

Now I'm working in other section of that project, after implementing the timers section I'll post more information about that if I found something interesting.

2
  • 1
    Any news? I understand that timer_create() and family are timer functions from the POSIX realtime library; I'm not sure libdispatch would be the most obvious candidate for anything realtime? Commented Oct 3, 2018 at 11:15
  • @RJVB crosspost: stackoverflow.com/questions/44807302/create-c-timer-in-macos/… Commented Dec 24, 2018 at 2:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.