* \brief microsecond sleep * \param usec is microseconds to sleep * This does not have the same 1000000 limit as POSIX usleep */
| 166 | * This does not have the same 1000000 limit as POSIX usleep |
| 167 | */ |
| 168 | int usleep(rig_useconds_t usec) |
| 169 | { |
| 170 | int retval; |
| 171 | unsigned long sec = usec / 1000000ul; |
| 172 | unsigned long nsec = usec * 1000ul - (sec * 1000000000ul); |
| 173 | struct timespec t; |
| 174 | t.tv_sec = sec; |
| 175 | t.tv_nsec = nsec; |
| 176 | retval = nanosleep(&t, NULL); |
| 177 | |
| 178 | // EINTR is the only error return usleep should need |
| 179 | // since EINVAL should not be a problem |
| 180 | if (retval == -1) { return EINTR; } |
| 181 | |
| 182 | return 0; |
| 183 | } |
| 184 | #endif |
| 185 | |
| 186 | #endif // HAVE_NANOSLEEP |
no outgoing calls
no test coverage detected