Skip to content

Conversation

chitkosarvesh
Copy link

@chitkosarvesh chitkosarvesh commented Oct 2, 2025

Summary of Changes Made

  1. Added platform-specific headers: Conditionally include the appropriate headers for Linux (sys/timerfd.h, endian.h) and macOS (libkern/OSByteOrder.h)
  2. Added macOS endian conversion macros: Defined htole32() and related functions using macOS's OSSwap* functions
  3. Made timer code platform-specific: Used #ifdef blocks to provide different timer implementations:
    ◦ Linux: Original timerfd_create() and timerfd_settime()
    ◦ macOS: nanosleep() for timing intervals
  4. Updated the main loop: Added platform-specific timing logic while keeping the rest of the functionality the same

The code now compiles successfully on macOS while maintaining compatibility with Linux systems.
Screenshot 2025-10-02 at 10 53 38 AM

Sarvesh Chitko, OH2DTC

@cyanide-burnout
Copy link
Member

LOL! Thanks ;)
Why not kqueue timer?

@chitkosarvesh
Copy link
Author

Well, no other reason than the implementation complexity.

@cyanide-burnout
Copy link
Member

Well, no other reason than the implementation complexity.

Timing accuracy?

@chitkosarvesh
Copy link
Author

Now that I look at it, I don't think nanosleep is a good implementation. Let me rework it a bit, I am considering kqueue_timer or grand central dispatch (dispatch_source_set_timer()). Will update the PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants