Open hawkinchina opened 1 month ago
Good to know that macOS is not POSIX. Thanks for reporting. What to do about it?
I just simply include the files in the project of https://github.com/ChisholmKyle/PosixMachTiming timing_mach.c timing_mach.h.
and modify qf_port.c in the directory of posix-qv
// sleep without drifting till next_tick (absolute), see NOTE03
// if (clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &next_tick, NULL) == 0) // success?
if (clock_nanosleep_abstime(&next_tick) == 0) // success? modified by jack_he.
{
QF_onClockTick();
}
and then it is ok.
log info: ➜ /Users/jack/Downloads/qp/qpc/examples/posix-win32/blinky/build >./blinky LED OFF LED ON LED OFF LED ON LED OFF LED ON LED OFF LED ON LED OFF LED ON LED OFF LED ON LED OFF
The qpc and qpcpp POSIX ports have been adapted for APPLE. The changes have been checked into the qpc and qpcpp repos. With these changes, the examples should build and run on macOS. This includes the Spy build configurations. For example, here is the updated file qpc/ports/posix-qv/qf_port.c --MMS
➜ /Users/jack/Downloads/qp/qpc/examples/posix-win32/blinky >make gcc -MM -MT build/qf_port.o -c -g -O -fno-pie -std=c11 -pedantic -Wall -Wextra -W -I. -I../../../include -I../../../ports/posix-qv -DQP_API_VERSION=9999 ../../../ports/posix-qv/qf_port.c > build/qf_port.d gcc -c -g -O -fno-pie -std=c11 -pedantic -Wall -Wextra -W -I. -I../../../include -I../../../ports/posix-qv -DQP_API_VERSION=9999 ../../../ports/posix-qv/qf_port.c -o build/qf_port.o ../../../ports/posix-qv/qf_port.c:91:13: warning: implicit declaration of function 'clock_nanosleep' is invalid in C99 [-Wimplicit-function-declaration] if (clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &next_tick, NULL) == 0) // success? ^ ../../../ports/posix-qv/qf_port.c:91:46: error: use of undeclared identifier 'TIMER_ABSTIME' if (clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &next_tick, NULL) == 0) // success? ^ 1 warning and 1 error generated. make: *** [build/qf_port.o] Error 1