summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2015-11-12 17:20:51 +0100
committerDave Davenport <qball@gmpclient.org>2015-11-12 17:20:51 +0100
commit45c8de9387cd73a7369c21fcec70ca77e6832076 (patch)
tree7910e484fd010b14e18f464be9eb168654448a29
parente6ca8acba98c414a93866583f17f1f6c7216f555 (diff)
If threads is set to 0, try to autodetect number of threads.
-rw-r--r--configure.ac1
-rw-r--r--include/textbox.h16
-rw-r--r--source/helper.c7
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 ) {