Changeset 4896:0cd0dc3bc104 in roaraudio for libroar


Ignore:
Timestamp:
04/29/11 15:28:16 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

removed useage of usleep() in flavor to nanosleep() if supported.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/libroar.c

    r4790 r4896  
    9797} 
    9898 
     99void roar_usleep(uint_least32_t t) { 
     100#ifdef ROAR_TARGET_WIN32 
     101 Sleep(t/(uint_least32_t)1000); 
     102#elif defined(ROAR_HAVE_NANOSLEEP) 
     103 struct timespec tv; 
     104 struct timespec left; 
     105 
     106 if ( t > (uint_least32_t)1000000 ) { 
     107  tv.tv_sec  = t/(uint_least32_t)1000000; 
     108  t         -= tv.tv_sec*(uint_least32_t)1000000; 
     109 } else { 
     110  tv.tv_sec  = 0; 
     111 } 
     112 
     113 tv.tv_nsec = t*(uint_least32_t)1000; 
     114 
     115 while (nanosleep(&tv, &left) == -1) 
     116  memcpy(&tv, &left, sizeof(tv)); 
     117#elif defined(ROAR_HAVE_USLEEP) 
     118 usleep(t); 
     119#else 
     120 ROAR_ERR("roar_usleep(t=%llu): can not sleep: not implemented", (long long unsigned int)t); 
     121 roar_strap(ROAR_TRAP_GROUP_LIBROAR, "usleep.not-implemented"); 
     122 roar_err_set(ROAR_ERROR_NOSYS); 
     123#endif 
     124} 
     125 
    99126//ll 
Note: See TracChangeset for help on using the changeset viewer.