Style compatibilization between two similar constructions addressed in two
separate recent patches. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@512 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
@@ -241,33 +241,28 @@ static void FreeThreadPoolJob(ThreadPool *tp, ThreadPoolJob *tpj)
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int SetPolicyType(PolicyType in)
|
static int SetPolicyType(PolicyType in)
|
||||||
{
|
{
|
||||||
|
int retVal = 0;
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
/* TODO not currently working... */
|
/* TODO not currently working... */
|
||||||
return 0;
|
retVal = 0;
|
||||||
#elif defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
|
#elif defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||||
setpriority(PRIO_PROCESS, 0, 0);
|
setpriority(PRIO_PROCESS, 0, 0);
|
||||||
return 0;
|
retVal = 0;
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
return sched_setscheduler(0, in);
|
retVal = sched_setscheduler(0, in);
|
||||||
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||||
struct sched_param current;
|
struct sched_param current;
|
||||||
int rc;
|
int sched_result;
|
||||||
|
|
||||||
memset(¤t, 0, sizeof(current)); /* purify? */
|
memset(¤t, 0, sizeof(current));
|
||||||
sched_getparam(0, ¤t);
|
sched_getparam(0, ¤t);
|
||||||
current.sched_priority = DEFAULT_SCHED_PARAM;
|
current.sched_priority = DEFAULT_SCHED_PARAM;
|
||||||
|
sched_result = sched_setscheduler(0, in, ¤t);
|
||||||
/* Solaris returns -1 if failure ..., but can return
|
retVal = (sched_result != -1 || errno == EPERM) ? 0 : errno;
|
||||||
* non-zero values for 0, ..., 5 [former scheduling values.] */
|
|
||||||
rc = sched_setscheduler(0, in, ¤t);
|
|
||||||
if (rc == -1) {
|
|
||||||
return rc;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return 0;
|
retVal = 0;
|
||||||
#endif
|
#endif
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -286,6 +281,7 @@ static int SetPolicyType(PolicyType in)
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int SetPriority(ThreadPriority priority)
|
static int SetPriority(ThreadPriority priority)
|
||||||
{
|
{
|
||||||
|
int retVal = 0;
|
||||||
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||||
int currentPolicy;
|
int currentPolicy;
|
||||||
int minPriority = 0;
|
int minPriority = 0;
|
||||||
@@ -310,16 +306,19 @@ static int SetPriority(ThreadPriority priority)
|
|||||||
actPriority = maxPriority;
|
actPriority = maxPriority;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return EINVAL;
|
retVal = EINVAL;
|
||||||
|
goto exit_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
newPriority.sched_priority = actPriority;
|
newPriority.sched_priority = actPriority;
|
||||||
|
|
||||||
sched_result = pthread_setschedparam(ithread_self(), currentPolicy, &newPriority);
|
sched_result = pthread_setschedparam(ithread_self(), currentPolicy, &newPriority);
|
||||||
return (0 == sched_result || EPERM == errno) ? 0 : -1;
|
retVal = (sched_result == 0 || errno == EPERM) ? 0 : sched_result;
|
||||||
#else
|
#else
|
||||||
return 0;
|
retVal = 0;
|
||||||
#endif
|
#endif
|
||||||
|
exit_function:
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user