Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timer_t missing on Mac OSX #334

Open
jeffhammond opened this issue Jul 29, 2015 · 7 comments
Open

timer_t missing on Mac OSX #334

jeffhammond opened this issue Jul 29, 2015 · 7 comments

Comments

@jeffhammond
Copy link

Even though timer_t is part of POSIX, it's missing from Mac OSX and references thereto are causing build errors of the form error: unknown type name 'timer_t'; did you mean 'time_t'?.

I have not found a trivial solution.

@jeffhammond
Copy link
Author

Related to #9 and #333.

@Talbot3
Copy link

Talbot3 commented Jul 18, 2019

hi, macosx support it

// Path Here '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/_types/_time_t.h'
#ifndef _TIME_T
#define _TIME_T
#include <machine/types.h> /* __darwin_time_t */
typedef __darwin_time_t         time_t;
#endif  /* _TIME_T */

macosx version: 11.14.5

@hiroyuki-sato
Copy link
Contributor

Hello, @OrangeBook
Thank you for your information.
I'm porting OpenUCX to macOS. It helps for me.
hiroyuki-sato#4

But, macOS doesn't support timer_create function which use timer_t data type.

@Talbot3
Copy link

Talbot3 commented Jul 19, 2019

@hiroyuki-sato
your provide code have no time_t.
so you use it to check system have time_t right?
if you want to check which header file have time_t , then
run here bash code

cat  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/_types/_time_t.h | grep time_t

@Talbot3
Copy link

Talbot3 commented Jul 19, 2019

suggest you add here code

#ifdef __APPLE__
#include "sys/_types/_time_t.h"
#endif

and add

gcc ... -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/

or you can try gnulib

here ... is ellipsis

@hiroyuki-sato
Copy link
Contributor

Hello, @OrangeBook. Thank you for your comment.

My point was

  • timer_create function use timer_t data type.
  • macOS doesn't support timer_create
  • So timer_t data type will solve, but I have to use an alternative function
  • gnulib may solve the missing function, but I don't want to use external libraries as much as possible.

ucx/src/ucs/async/signal.c

Lines 104 to 119 in cb508a0

static ucs_status_t
ucs_async_signal_sys_timer_create(int uid, pid_t tid, timer_t *sys_timer_id)
{
struct sigevent ev;
timer_t timer;
int ret;
ucs_trace_func("tid=%d", tid);
/* Create timer signal */
memset(&ev, 0, sizeof(ev));
ev.sigev_notify = SIGEV_THREAD_ID;
ev.sigev_signo = ucs_global_opts.async_signo;
ev.sigev_value.sival_int = uid; /* user parameter to timer */
ev._sigev_un._tid = tid; /* target thread */
ret = timer_create(CLOCK_REALTIME, &ev, &timer);

SYNOPSIS
       #include <signal.h>
       #include <time.h>

       int timer_create(clockid_t clockid, struct sigevent *sevp,
                        timer_t *timerid);
% grep -rl timer_create /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
% 

@Talbot3
Copy link

Talbot3 commented Jul 19, 2019

yea, I found mixed timer_t and time_t.
sorry for it .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants