Library was not compiling on FreeBSD 7. Code now no longer uses
ftime(), using gettimeofday() instead. Thanks to Josh Carroll. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@270 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
8faf828b50
commit
9bfac585af
@ -2,6 +2,10 @@
|
||||
Version 1.6.3
|
||||
*******************************************************************************
|
||||
|
||||
2007-12-16 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Library was not compiling on FreeBSD 7. Code now no longer uses
|
||||
ftime(), using gettimeofday() instead. Thanks to Josh Carroll.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.6.2
|
||||
|
1
THANKS
1
THANKS
@ -23,6 +23,7 @@ exempt of errors.
|
||||
- Jiri Zouhar
|
||||
- John Dennis
|
||||
- Jonathan (no_dice)
|
||||
- Josh Carroll
|
||||
- Keith Brindley
|
||||
- Leuk_He
|
||||
- Loigu
|
||||
|
@ -98,13 +98,16 @@ AC_INIT([libupnp], [1.6.3], [mroberto@users.sourceforge.net])
|
||||
# Release 1.6.3:
|
||||
# "current:revision:age"
|
||||
#
|
||||
# - Code has changed in threadutil
|
||||
# revision: 0 -> 1
|
||||
#
|
||||
#AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [4:1:2])
|
||||
#AC_SUBST([LT_VERSION_UPNP], [3:2:0])
|
||||
#
|
||||
###############################################################################
|
||||
AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||
AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
|
||||
AC_SUBST([LT_VERSION_THREADUTIL], [4:1:2])
|
||||
AC_SUBST([LT_VERSION_UPNP], [3:2:0])
|
||||
###############################################################################
|
||||
# Repeating the algorithm so that it is closer to the modificatin place:
|
||||
|
@ -83,12 +83,11 @@ typedef enum priority {LOW_PRIORITY,
|
||||
#endif
|
||||
|
||||
#include "LinkedList.h"
|
||||
#include <sys/timeb.h>
|
||||
#include <sys/time.h> /* for gettimeofday() */
|
||||
#include "FreeList.h"
|
||||
|
||||
#include "ithread.h"
|
||||
#include <errno.h>
|
||||
#include <sys/timeb.h>
|
||||
#define EXPORT
|
||||
typedef int PolicyType;
|
||||
#define DEFAULT_POLICY SCHED_OTHER
|
||||
@ -144,7 +143,7 @@ typedef struct THREADPOOLJOB
|
||||
start_routine func;
|
||||
void *arg;
|
||||
free_routine free_func;
|
||||
struct timeb requestTime;
|
||||
struct timeval requestTime;
|
||||
int priority;
|
||||
int jobId;
|
||||
} ThreadPoolJob;
|
||||
|
@ -168,26 +168,36 @@ SetPriority( ThreadPriority priority )
|
||||
*
|
||||
* Description:
|
||||
* Returns the difference in milliseconds between two
|
||||
* timeb structures.
|
||||
* timeval structures.
|
||||
* Internal Only.
|
||||
* Parameters:
|
||||
* struct timeb *time1,
|
||||
* struct timeb *time2,
|
||||
* struct timeval *time1,
|
||||
* struct timeval *time2,
|
||||
* Returns:
|
||||
* the difference in milliseconds, time1-time2.
|
||||
*****************************************************************************/
|
||||
static double
|
||||
DiffMillis( struct timeb *time1,
|
||||
struct timeb *time2 )
|
||||
static unsigned long
|
||||
DiffMillis( struct timeval *time1,
|
||||
struct timeval *time2 )
|
||||
{
|
||||
double temp = 0;
|
||||
|
||||
assert( time1 != NULL );
|
||||
assert( time2 != NULL );
|
||||
|
||||
struct timeval {
|
||||
time_t tv_sec; /* seconds */
|
||||
suseconds_t tv_usec; /* and microseconds */
|
||||
};
|
||||
|
||||
temp = time1->tv_sec - time2->tv_sec;
|
||||
/* convert to milliseconds */
|
||||
temp *= 1000;
|
||||
|
||||
/* convert microseconds to milliseconds and add to temp */
|
||||
/* implicit flooring of unsigned long data type */
|
||||
temp += ( (time1->tv_usec - time2->tv_usec) / 1000 );
|
||||
|
||||
temp = ( ( double )( time1->time ) - time2->time );
|
||||
temp = temp * 1000;
|
||||
temp += ( time1->millitm - time2->millitm );
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -207,13 +217,13 @@ static void
|
||||
BumpPriority( ThreadPool * tp )
|
||||
{
|
||||
int done = 0;
|
||||
struct timeb now;
|
||||
double diffTime = 0;
|
||||
struct timeval now;
|
||||
unsigned long diffTime = 0;
|
||||
ThreadPoolJob *tempJob = NULL;
|
||||
|
||||
assert( tp != NULL );
|
||||
|
||||
ftime( &now );
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
while( !done ) {
|
||||
if( tp->medJobQ.size ) {
|
||||
@ -272,16 +282,16 @@ static void
|
||||
SetRelTimeout( struct timespec *time,
|
||||
int relMillis )
|
||||
{
|
||||
struct timeb now;
|
||||
struct timeval now;
|
||||
int sec = relMillis / 1000;
|
||||
int milliSeconds = relMillis % 1000;
|
||||
|
||||
assert( time != NULL );
|
||||
|
||||
ftime( &now );
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
time->tv_sec = now.time + sec;
|
||||
time->tv_nsec = ( now.millitm + milliSeconds ) * 1000000;
|
||||
time->tv_sec = now.tv_sec + sec;
|
||||
time->tv_nsec = ( (now.tv_usec/1000) + milliSeconds ) * 1000000;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -334,11 +344,11 @@ static void StatsInit( ThreadPoolStats * stats )
|
||||
static void CalcWaitTime( ThreadPool * tp,
|
||||
ThreadPriority p,
|
||||
ThreadPoolJob * job ) {
|
||||
struct timeb now;
|
||||
double diff;
|
||||
struct timeval now;
|
||||
unsigned long diff;
|
||||
assert( tp != NULL );
|
||||
assert( job != NULL );
|
||||
ftime( &now );
|
||||
gettimeofday(&now, NULL);
|
||||
diff = DiffMillis( &now, &job->requestTime ); switch ( p ) {
|
||||
case HIGH_PRIORITY:
|
||||
tp->stats.totalJobsHQ++; tp->stats.totalTimeHQ += diff; break; case MED_PRIORITY:
|
||||
@ -360,15 +370,15 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
*
|
||||
*****************************************************************************/
|
||||
static void SetSeed() {
|
||||
struct timeb t;
|
||||
|
||||
ftime( &t );
|
||||
struct timeval t;
|
||||
|
||||
gettimeofday(&t, NULL);
|
||||
#if defined(WIN32)
|
||||
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id().p );
|
||||
#elif defined(__FreeBSD__) || defined(__OSX__)
|
||||
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id() );
|
||||
srand( ( unsigned int )t.tv_usec + (unsigned int)ithread_get_current_thread_id().p );
|
||||
#elif defined(__FreeBSD__)
|
||||
srand( ( unsigned int )t.tv_usec + (unsigned int)ithread_get_current_thread_id() );
|
||||
#elif defined(__linux__)
|
||||
srand( ( unsigned int )t.millitm + ithread_get_current_thread_id() );
|
||||
srand( ( unsigned int )t.tv_usec + ithread_get_current_thread_id() );
|
||||
#else
|
||||
{
|
||||
volatile union { volatile pthread_t tid; volatile unsigned i; } idu;
|
||||
@ -607,7 +617,7 @@ static void SetSeed() {
|
||||
if( newJob ) {
|
||||
( *newJob ) = ( *job );
|
||||
newJob->jobId = id;
|
||||
ftime( &newJob->requestTime );
|
||||
gettimeofday( &newJob->requestTime, NULL );
|
||||
}
|
||||
return newJob;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user