Another patch I dug out of my archive.
The attached patch is a complete rewrite of the timer subsystem, making use of the more modern timer_create, timer_settime etc. With the use of POSIX timer API, the alarming signal can pass data to the signal handler. With this patch, one timer per timer table entry is created and the signal handler does not have to loop - it is told straight away which timer fired by reading its underlying data structure, and that timer is marked as expired. Timers are still asynchronous, but there is no continuous stream of signals being delivered to ptpd - signals are fired only when timers expire.
There are no changes to the timer interface and other ptpd code, only to the function bodies and initialisation / shutdown of the timers.
This would need to be checked for compatibility issues on FreeBSD and other non-Linux OSes.