1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-22 14:10:34 +00:00

(trunk libT) #3381 "replace calls to usleep() with calls to nanosleep()" -- done.

This commit is contained in:
Charles Kerr 2010-07-01 03:59:06 +00:00
parent b40c3ee234
commit 4a9e36e842
2 changed files with 9 additions and 5 deletions

View file

@ -28,12 +28,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* strerror(), memset(), memmem() */
#include <time.h> /* nanosleep() */
#include <libgen.h> /* basename() */
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h> /* usleep(), stat(), getcwd(), getpagesize() */
#include <unistd.h> /* stat(), getcwd(), getpagesize() */
#include "event.h"
@ -789,12 +790,15 @@ tr_date( void )
}
void
tr_wait_msec( uint64_t delay_milliseconds )
tr_wait_msec( long int msec )
{
#ifdef WIN32
Sleep( (DWORD)delay_milliseconds );
Sleep( (DWORD)msec );
#else
usleep( 1000 * delay_milliseconds );
struct timespec ts;
ts.tv_sec = msec / 1000;
ts.tv_sec = ( msec % 1000 ) * 1000000;
nanosleep( &ts, NULL );
#endif
}

View file

@ -268,7 +268,7 @@ void tr_timerAddMsec( struct event * timer, int milliseconds ) TR_GNUC_NONNULL(1
uint64_t tr_date( void );
/** @brief sleep the specified number of milliseconds */
void tr_wait_msec( uint64_t delay_milliseconds );
void tr_wait_msec( long int delay_milliseconds );
/**
* @brief make a copy of 'str' whose non-utf8 content has been corrected or stripped