aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.c')
-rw-r--r--src/compiler.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/compiler.c b/src/compiler.c
index bdcb1c8..2b59a93 100644
--- a/src/compiler.c
+++ b/src/compiler.c
@@ -12,15 +12,6 @@
#include <limits.h>
#include <assert.h>
-static CHECK_RESULT int get_thread_count_env_var(int *thread_count) {
- char *threads;
- threads = getenv("THREADS");
- if(!threads)
- return -1;
- *thread_count = atoi(threads);
- return 0;
-}
-
static usize strnlen(const char *str, usize max_length) {
usize len;
len = 0;
@@ -70,23 +61,20 @@ static CHECK_RESULT int init_default_types(amal_compiler *compiler) {
void amal_compiler_options_init(amal_compiler_options *self) {
self->error_callback = NULL;
self->error_callback_userdata = NULL;
+ self->num_threads = 0;
}
int amal_compiler_init(amal_compiler *self, const amal_compiler_options *options) {
int i;
- int result;
- result = get_thread_count_env_var(&self->usable_thread_count);
- if(result != 0) {
+ self->usable_thread_count = options->num_threads;
+ if(self->usable_thread_count == 0) {
self->usable_thread_count = amal_get_usable_thread_count();
if(self->usable_thread_count == 0) {
amal_log_warning("Unable to get the number of threads available on the system, using 1 thread.");
- amal_log_warning("You can override the number of threads using by setting the environment variable THREADS");
+ amal_log_warning("You can override the number of threads using by setting compiler option for number of thread to use.");
self->usable_thread_count = 1;
}
- } else if(self->usable_thread_count <= 0) {
- amal_log_error("Environment variable THREADS contains invalid number for threads. THREADS has to be at least 1.");
- return AMAL_COMPILER_ERR;
}
am_memset(&self->allocator, 0, sizeof(self->allocator));