Implemented -A flag for Windows (#665)
TODO: Need to update some documentation that reflects `-A` is applicable to Windows. @bmah888 to do this.
Этот коммит содержится в:
родитель
480824e3c1
Коммит
5b27ea39a7
2
configure
поставляемый
2
configure
поставляемый
@ -13002,7 +13002,7 @@ fi
|
||||
# FreeBSD uses cpuset_setaffinity while Linux uses sched_setaffinity.
|
||||
# Define HAVE_CPU_AFFINITY to indicate the CPU affinity setting as a
|
||||
# generic concept is available.
|
||||
for ac_func in cpuset_setaffinity sched_setaffinity
|
||||
for ac_func in cpuset_setaffinity sched_setaffinity SetProcessAffinityMask
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||
|
@ -153,7 +153,7 @@ fi
|
||||
# FreeBSD uses cpuset_setaffinity while Linux uses sched_setaffinity.
|
||||
# Define HAVE_CPU_AFFINITY to indicate the CPU affinity setting as a
|
||||
# generic concept is available.
|
||||
AC_CHECK_FUNCS([cpuset_setaffinity sched_setaffinity],
|
||||
AC_CHECK_FUNCS([cpuset_setaffinity sched_setaffinity SetProcessAffinityMask],
|
||||
AC_DEFINE([HAVE_CPU_AFFINITY], [1],
|
||||
[Have CPU affinity support.]))
|
||||
|
||||
|
@ -62,6 +62,10 @@
|
||||
#include <sys/cpuset.h>
|
||||
#endif /* HAVE_CPUSET_SETAFFINITY */
|
||||
|
||||
#if defined(HAVE_SETPROCESSAFFINITYMASK)
|
||||
#include <Windows.h>
|
||||
#endif /* HAVE_SETPROCESSAFFINITYMASK */
|
||||
|
||||
#include "net.h"
|
||||
#include "iperf.h"
|
||||
#include "iperf_api.h"
|
||||
@ -3576,6 +3580,15 @@ iperf_setaffinity(struct iperf_test *test, int affinity)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#elif defined(HAVE_SETPROCESSAFFINITYMASK)
|
||||
HANDLE process = GetCurrentProcess();
|
||||
DWORD_PTR processAffinityMask = 1 << affinity;
|
||||
|
||||
if (SetProcessAffinityMask(process, processAffinityMask) == 0) {
|
||||
i_errno = IEAFFINITY;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#else /* neither HAVE_SCHED_SETAFFINITY nor HAVE_CPUSET_SETAFFINITY */
|
||||
i_errno = IEAFFINITY;
|
||||
return -1;
|
||||
@ -3604,6 +3617,17 @@ iperf_clearaffinity(struct iperf_test *test)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#elif defined(HAVE_SETPROCESSAFFINITYMASK)
|
||||
HANDLE process = GetCurrentProcess();
|
||||
DWORD_PTR processAffinityMask;
|
||||
DWORD_PTR lpSystemAffinityMask;
|
||||
|
||||
if (GetProcessAffinityMask(process, &processAffinityMask, &lpSystemAffinityMask) == 0
|
||||
|| SetProcessAffinityMask(process, lpSystemAffinityMask) == 0) {
|
||||
i_errno = IEAFFINITY;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#else /* neither HAVE_SCHED_SETAFFINITY nor HAVE_CPUSET_SETAFFINITY */
|
||||
i_errno = IEAFFINITY;
|
||||
return -1;
|
||||
|
@ -42,6 +42,9 @@
|
||||
/* Define to 1 if you have the `sendfile' function. */
|
||||
#undef HAVE_SENDFILE
|
||||
|
||||
/* Define to 1 if you have the `SetProcessAffinityMask' function. */
|
||||
#undef HAVE_SETPROCESSAFFINITYMASK
|
||||
|
||||
/* Have SO_MAX_PACING_RATE sockopt. */
|
||||
#undef HAVE_SO_MAX_PACING_RATE
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user