diff options
-rw-r--r-- | configs/mingw32_defconfig | 4 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 4 | ||||
-rw-r--r-- | coreutils/nproc.c | 30 |
3 files changed, 34 insertions, 4 deletions
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index 772f7fdb9..7108c2dda 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.34.0.git | 3 | # Busybox version: 1.34.0.git |
4 | # Sat Feb 13 10:29:16 2021 | 4 | # Wed Feb 17 13:34:38 2021 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -295,7 +295,7 @@ CONFIG_MV=y | |||
295 | # CONFIG_NICE is not set | 295 | # CONFIG_NICE is not set |
296 | CONFIG_NL=y | 296 | CONFIG_NL=y |
297 | # CONFIG_NOHUP is not set | 297 | # CONFIG_NOHUP is not set |
298 | # CONFIG_NPROC is not set | 298 | CONFIG_NPROC=y |
299 | CONFIG_OD=y | 299 | CONFIG_OD=y |
300 | CONFIG_PASTE=y | 300 | CONFIG_PASTE=y |
301 | CONFIG_PRINTENV=y | 301 | CONFIG_PRINTENV=y |
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index f73f23fa3..0cb4f4a3e 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.34.0.git | 3 | # Busybox version: 1.34.0.git |
4 | # Sat Feb 13 10:37:01 2021 | 4 | # Wed Feb 17 13:34:38 2021 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -295,7 +295,7 @@ CONFIG_MV=y | |||
295 | # CONFIG_NICE is not set | 295 | # CONFIG_NICE is not set |
296 | CONFIG_NL=y | 296 | CONFIG_NL=y |
297 | # CONFIG_NOHUP is not set | 297 | # CONFIG_NOHUP is not set |
298 | # CONFIG_NPROC is not set | 298 | CONFIG_NPROC=y |
299 | CONFIG_OD=y | 299 | CONFIG_OD=y |
300 | CONFIG_PASTE=y | 300 | CONFIG_PASTE=y |
301 | CONFIG_PRINTENV=y | 301 | CONFIG_PRINTENV=y |
diff --git a/coreutils/nproc.c b/coreutils/nproc.c index 31e452bc4..7025765c5 100644 --- a/coreutils/nproc.c +++ b/coreutils/nproc.c | |||
@@ -29,6 +29,7 @@ | |||
29 | int nproc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 29 | int nproc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
30 | int nproc_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 30 | int nproc_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
31 | { | 31 | { |
32 | #if !ENABLE_PLATFORM_MINGW32 | ||
32 | unsigned long mask[1024]; | 33 | unsigned long mask[1024]; |
33 | int count = 0; | 34 | int count = 0; |
34 | #if ENABLE_LONG_OPTS | 35 | #if ENABLE_LONG_OPTS |
@@ -63,6 +64,35 @@ int nproc_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
63 | } | 64 | } |
64 | } | 65 | } |
65 | } | 66 | } |
67 | #else /* ENABLE_PLATFORM_MINGW32 */ | ||
68 | int count = 0; | ||
69 | DWORD_PTR process_affinity, system_affinity; | ||
70 | #if ENABLE_LONG_OPTS | ||
71 | int ignore = 0; | ||
72 | int opts = getopt32long(argv, "\xfe:+", | ||
73 | "ignore\0" Required_argument "\xfe" | ||
74 | "all\0" No_argument "\xff" | ||
75 | , &ignore | ||
76 | ); | ||
77 | #endif | ||
78 | if (!GetProcessAffinityMask(GetCurrentProcess(), &process_affinity, | ||
79 | &system_affinity)) { | ||
80 | process_affinity = system_affinity = 0; | ||
81 | } | ||
82 | |||
83 | #if ENABLE_LONG_OPTS | ||
84 | if (opts & (1 << 1)) { | ||
85 | for (count = 0; system_affinity; system_affinity >>= 1) { | ||
86 | count += system_affinity & 1; | ||
87 | } | ||
88 | } else | ||
89 | #endif | ||
90 | { | ||
91 | for (count = 0; process_affinity; process_affinity >>= 1) { | ||
92 | count += process_affinity & 1; | ||
93 | } | ||
94 | } | ||
95 | #endif /* ENABLE_PLATFORM_MINGW32 */ | ||
66 | 96 | ||
67 | IF_LONG_OPTS(count -= ignore;) | 97 | IF_LONG_OPTS(count -= ignore;) |
68 | if (count <= 0) | 98 | if (count <= 0) |