Changeset 4913:5640b4c00ace in roaraudio for libroar/libroar.c


Ignore:
Timestamp:
05/07/11 20:10:37 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_sleep() function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/libroar.c

    r4896 r4913  
    9797} 
    9898 
    99 void roar_usleep(uint_least32_t t) { 
     99int roar_usleep(uint_least32_t t) { 
    100100#ifdef ROAR_TARGET_WIN32 
    101101 Sleep(t/(uint_least32_t)1000); 
     102 return 0; 
    102103#elif defined(ROAR_HAVE_NANOSLEEP) 
    103104 struct timespec tv; 
     
    115116 while (nanosleep(&tv, &left) == -1) 
    116117  memcpy(&tv, &left, sizeof(tv)); 
     118 return 0; 
    117119#elif defined(ROAR_HAVE_USLEEP) 
    118120 usleep(t); 
     121 return 0; 
    119122#else 
    120123 ROAR_ERR("roar_usleep(t=%llu): can not sleep: not implemented", (long long unsigned int)t); 
    121124 roar_strap(ROAR_TRAP_GROUP_LIBROAR, "usleep.not-implemented"); 
    122125 roar_err_set(ROAR_ERROR_NOSYS); 
     126 return -1; 
    123127#endif 
    124128} 
    125129 
     130int roar_sleep(int t) { 
     131 if ( t < 0 ) { 
     132  roar_err_set(ROAR_ERROR_CAUSALITY); 
     133  return -1; 
     134 } 
     135 
     136 while (t) 
     137  t = sleep(t); 
     138 
     139 return 0; 
     140} 
     141 
    126142//ll 
Note: See TracChangeset for help on using the changeset viewer.