macOS support (using compatibility libraries)#144
macOS support (using compatibility libraries)#144electricalgrade wants to merge 6 commits intoOCEAN-xyz:masterfrom
Conversation
Add support for MACOS Apple Silicon
|
Gents, please forgive me for spamming this with LLM code and text. Below is Grok comparing the Pr144 with what I have (again, I apologize for this)...The pull request (PR) #144 for the Datum Gateway repository (https://github.com/OCEAN-xyz/datum_gateway/pull/144/files) introduces a fix for macOS compatibility by addressing the Analysis of PR #144The PR modifies #ifdef __APPLE__
rc = pthread_mutex_lock(&datum_protocol_coinbaser_fetch_mutex);
#else
rc = pthread_mutex_timedlock(&datum_protocol_coinbaser_fetch_mutex, &ts);
#endif
Impact on Your Current SetupYour current setup, with the manually patched
Recommended ActionsSince your current build works, you don’t need to delete it immediately. However, to test PR #144 and contribute to the project, you can update your local repository and rebuild. Here’s how to proceed:
Should You Delete the Recompiled Version?
Additional Considerations
SummaryPR #144 provides an official fix for the |
UPdating CMakelist.txt main problem was argp and in some cases even epoll. mac does not have epoll like Linux. So Have to install epoll_shim
removed hard-coded and also takes timespec
|
I have added CMakeList also. You will not need env variables. Only thing you will need is set PKG_CONFIG_PATH to homebrew pls try this patch. Also what grok gave you is hacky version of pthread_mutex_timedlock Please try this and let me know if you face issues. |
|
Thank you soooo much.
Will test it today and provide feedback.
Regads,
Anton
… On 19 Aug 2025, at 04:37, EG ***@***.***> wrote:
electricalgrade
left a comment
(OCEAN-xyz/datum_gateway#144)
<#144 (comment)>
I have added CMakeList also. You will not need env variables. Only thing you will need is set PKG_CONFIG_PATH to homebrew
usually PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig
pls try this patch.
epoll is not supported on MAC so you need epoll-shim
Also what grok gave you is hacky version of pthread_mutex_timedlock
In my new commit I have made it exactly look like pthread_mutex_timedlock. I use same args. Infact on apple i can name my function as pthread_mutex_timedlock. I have just named it portable_mutex_timedlock to avoid any confusion. But it sprinkles ifdef in the code which I personally dont like.
Please try this and let me know if you face issues.
—
Reply to this email directly, view it on GitHub <#144 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/BWFP5MS3MCZZ5H6GVF76SGD3OKEU7AVCNFSM6AAAAACEDDQHRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJZGAYTINRSGE>.
You are receiving this because you commented.
|
src/datum_protocol.c
Outdated
|
|
||
| // Sleep for 5ms to avoid busy waiting | ||
| struct timespec sleep_ts = {0, 5 * 1000000}; | ||
| nanosleep(&sleep_ts, NULL); |
There was a problem hiding this comment.
This is kind of ugly :(
How about using pthread_cond_timedwait?
There was a problem hiding this comment.
Ah yes. I will try that
There was a problem hiding this comment.
If we use pthread_cond_timed_wait then it will not be drop in replacement. I will have to wrap this.
I need to create a seperate protable_mutex.c and .h and i need sprinkle these ifdef.
#ifdef __APPLE__
portable_mutex_lock(&datum_protocol_coinbaser_fetch_mutex);
#else
pthread_mutex_lock(&datum_protocol_coinbaser_fetch_mutex);
#endif
#ifdef __APPLE__
portable_mutex_unlock(&datum_protocol_coinbaser_fetch_mutex);
#else
pthread_mutex_unlock(&datum_protocol_coinbaser_fetch_mutex);
#endif
}
If this is must have then i can work on creating a solution with pthread_cond_timed_wait
There was a problem hiding this comment.
I pushed changes removing the nanosleep(&sleep_ts, NULL);
i now created a seperate file to cleanly handle apple specific cases.
To avoid race condition i had to use the customized lock/unlock for this mutex. datum_protocol_coinbaser_fetch_mutex
i did a standlone test of my logic to check race condition.
Hence this is not a drop in replacement. I have removed the my drop-in replacement code.
Add support for MACOS Apple Silicon