Delaying for microseconds (without nanosleep)?

When writing a driver in Swift that uses the Raspberry Pi GPIO I have the need to delay for 1 microsecond, but delaying for longer is just a waste. I'm currently using Glibc nanosleep (indirectly through usleep), which works since there's not really an upper bound for the delays (fortunately, since it runs in user space), but I have the impression that it's very unlikely that it would have the potential to ever reach a delay of a few microseconds on a platform like the Pi due to the overhead inherent in that syscall.

Is there some existing Swift library function that can help me to e.g. busy wait for one or a few microseconds?

Terms of Service

Privacy Policy

Cookie Policy