From 45c8de9387cd73a7369c21fcec70ca77e6832076 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 12 Nov 2015 17:20:51 +0100 Subject: [PATCH] If threads is set to 0, try to autodetect number of threads. --- configure.ac | 1 + include/textbox.h | 16 ++++++++-------- source/helper.c | 7 +++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 36dafb94..b9ca532d 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,7 @@ AS_IF([test "x$enable_i3support" != xno && test "x$enable_windowmode" != "xno"], ## AC_CHECK_FUNC([getdelim],, AC_MSG_ERROR("Could not find getdelim in c library")) +AC_CHECK_FUNC([sysconf],, AC_MSG_ERROR("Could not find sysconf")) ## # Check dependencies ## diff --git a/include/textbox.h b/include/textbox.h index fb03234e..9b0c4090 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -33,14 +33,14 @@ typedef struct typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, - TB_MARKUP = 1 << 20, - TB_WRAP = 1 << 21, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, + TB_MARKUP = 1 << 20, + TB_WRAP = 1 << 21, } TextboxFlags; typedef enum diff --git a/source/helper.c b/source/helper.c index 0d0070cc..1653bd25 100644 --- a/source/helper.c +++ b/source/helper.c @@ -513,6 +513,13 @@ void remove_pid_file ( int fd ) */ void config_sanity_check ( Display *display ) { + if ( config.threads == 0 ) { + config.threads = 1; + long procs = sysconf ( _SC_NPROCESSORS_CONF ); + if ( procs > 0 ) { + config.threads = MIN(procs,UINT_MAX); + } + } // If alternative row is not set, copy the normal background color. // Do this at the beginning as we might use it in the error dialog. if ( config.menu_bg_alt == NULL ) {