;; the number of processors, see get_native_system_info in w32.c.
;; The result needs to be exported to Lisp.
(max 1 (/ (cond ((eq 'windows-nt system-type)
- (string-to-number (getenv
- "NUMBER_OF_PROCESSORS")))
+ (w32-get-nproc))
((executable-find "nproc")
(string-to-number
(shell-command-to-string "nproc")))
return prev_idx;
}
-static void
-sample_system_load (ULONGLONG *idle, ULONGLONG *kernel, ULONGLONG *user)
+unsigned
+w32_get_nproc (void)
{
SYSTEM_INFO sysinfo;
- FILETIME ft_idle, ft_user, ft_kernel;
/* Initialize the number of processors on this machine. */
if (num_of_processors <= 0)
if (num_of_processors <= 0)
num_of_processors = 1;
}
+ return num_of_processors;
+}
+
+static void
+sample_system_load (ULONGLONG *idle, ULONGLONG *kernel, ULONGLONG *user)
+{
+ FILETIME ft_idle, ft_user, ft_kernel;
+
+ (void) w32_get_nproc ();
/* TODO: Take into account threads that are ready to run, by
sampling the "\System\Processor Queue Length" performance
/* Compare 2 UTF-8 strings in locale-dependent fashion. */
extern int w32_compare_strings (const char *, const char *, char *, int);
+/* Return the number of processor execution units on this system. */
+extern unsigned w32_get_nproc (void);
+
/* Return a cryptographically secure seed for PRNG. */
extern int w32_init_random (void *, ptrdiff_t);
return val - 2;
}
+DEFUN ("w32-get-nproc", Fw32_get_nproc,
+ Sw32_get_nproc, 0, 0, 0,
+ doc: /* Return the number of system's processor execution units. */)
+ (void)
+{
+ return make_fixnum (w32_get_nproc ());
+}
+
\f
void
syms_of_ntproc (void)
defsubr (&Sw32_get_keyboard_layout);
defsubr (&Sw32_set_keyboard_layout);
+ defsubr (&Sw32_get_nproc);
+
DEFVAR_LISP ("w32-quote-process-args", Vw32_quote_process_args,
doc: /* Non-nil enables quoting of process arguments to ensure correct parsing.
Because Windows does not directly pass argv arrays to child processes,