For example, recently I wanted to call `gettid()` in a signal handler. Which I guessed was just a simple wrapper around the syscall.
However, it seems this can cache the thread ID in thread local storage (can't remember exact details).
I switched to making a syscall instead.
https://man7.org/linux/man-pages/man7/signal-safety.7.html
If it's on this list I generally trust it is safe.
I guess my point is, that if it's not, even a simple function may appear safe, but could do surprising things.
For example, recently I wanted to call `gettid()` in a signal handler. Which I guessed was just a simple wrapper around the syscall.
However, it seems this can cache the thread ID in thread local storage (can't remember exact details).
I switched to making a syscall instead.