diff --git a/.ikc3_history b/.ikc3_history
index 36e6754..3e43f5c 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,4 +1,3 @@
-points = [{(F128) 0, (F128) 1}, {(F128) 0.5, (F128) 0.6}]
points[0]
points[1]
points[2]
@@ -97,4 +96,4 @@ Gtk4.init()
w = Gtk4.Window.new()
Gtk4.Window.present(w)
Gtk4.main()
-
+ncpu
diff --git a/lib/kc3/0.1/httpd.kc3 b/lib/kc3/0.1/httpd.kc3
index dabd09d..2eff99b 100644
--- a/lib/kc3/0.1/httpd.kc3
+++ b/lib/kc3/0.1/httpd.kc3
@@ -119,7 +119,7 @@ defmodule HTTPd do
end
}
- def thread_count = 8
+ def thread_count = ncpu
def server = fn (host, port) {
def socket = Socket.listen(host, port)
diff --git a/libkc3/env.c b/libkc3/env.c
index c6005f6..db694a1 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -11,6 +11,11 @@
* THIS SOFTWARE.
*/
#include <string.h>
+
+#ifndef __APPLE__
+#include <sys/sysinfo.h>
+#endif
+
#include <unistd.h>
#include "alloc.h"
#include "array.h"
@@ -2740,6 +2745,7 @@ s_env * env_init_globals (s_env *env)
{
s_tag *file_dir;
s_tag *file_path;
+ s_tag *ncpu;
if (! (env->read_time_frame = frame_new(NULL, NULL)))
return NULL;
if (! (file_dir = frame_binding_new(env->read_time_frame,
@@ -2755,6 +2761,14 @@ s_env * env_init_globals (s_env *env)
return NULL;
if (! (env->global_frame = frame_new(env->read_time_frame, NULL)))
return NULL;
+ if (! (ncpu = frame_binding_new(env->read_time_frame,
+ &g_sym_ncpu)))
+ return NULL;
+#if HAVE_PTHREAD
+ tag_init_u8(ncpu, get_nprocs());
+#else
+ tag_init_u8(ncpu, 1);
+#endif
return env;
}
diff --git a/libkc3/sym.c b/libkc3/sym.c
index 9ee548b..7543346 100644
--- a/libkc3/sym.c
+++ b/libkc3/sym.c
@@ -97,6 +97,7 @@ const s_sym g_sym_is_loading = {{{NULL}, 10, {"is_loading"}}};
const s_sym g_sym_load_time = {{{NULL}, 9, {"load_time"}}};
const s_sym g_sym_macro = {{{NULL}, 5, {"macro"}}};
const s_sym g_sym_module = {{{NULL}, 6, {"module"}}};
+const s_sym g_sym_ncpu = {{{NULL}, 4, {"ncpu"}}};
const s_sym g_sym_operator = {{{NULL}, 8, {"operator"}}};
const s_sym g_sym_operator_associativity =
{{{NULL}, 22, {"operator_associativity"}}};
@@ -414,6 +415,7 @@ void sym_init_g_sym (void)
sym_register(&g_sym_load_time, NULL);
sym_register(&g_sym_macro, NULL);
sym_register(&g_sym_module, NULL);
+ sym_register(&g_sym_ncpu, NULL);
sym_register(&g_sym_operator, NULL);
sym_register(&g_sym_operator_associativity, NULL);
sym_register(&g_sym_operator_equal, NULL);
diff --git a/libkc3/sym.h b/libkc3/sym.h
index 2bc8153..2ebfefe 100644
--- a/libkc3/sym.h
+++ b/libkc3/sym.h
@@ -101,6 +101,7 @@ extern const s_sym g_sym_is_loading;
extern const s_sym g_sym_load_time;
extern const s_sym g_sym_macro;
extern const s_sym g_sym_module;
+extern const s_sym g_sym_ncpu;
extern const s_sym g_sym_operator;
extern const s_sym g_sym_operator_associativity;
extern const s_sym g_sym_operator_equal;