diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-29 18:13:26 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-29 18:13:26 +0000 |
| commit | c531795b8372eb0e69aa874476f3e96cd7c09dfc (patch) | |
| tree | 56c2cc2ff9476038d81e34c4c186e7d6562103c8 /config.c | |
| parent | Merge branch 'use-freetype-to-render-glyphs' (diff) | |
wip: initial multithreaded renderer
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -107,26 +107,28 @@ get_config_path(void) } static bool -str_to_color(const char *s, uint32_t *color, const char *path, int lineno) +str_to_ulong(const char *s, int base, unsigned long *res) { if (s == NULL) return false; errno = 0; char *end = NULL; - unsigned long res = strtoul(s, &end, 16); - if (errno != 0) { - LOG_ERRNO("%s:%d: invalid color: %s", path, lineno, s); - return false; - } + *res = strtoul(s, &end, base); + return errno == 0 && *end == '\0'; +} - if (*end != '\0') { - LOG_ERR("%s:%d: invalid color: %s", path, lineno, s); +static bool +str_to_color(const char *s, uint32_t *color, const char *path, int lineno) +{ + unsigned long value; + if (!str_to_ulong(s, 16, &value)) { + LOG_ERRNO("%s:%d: invalid color: %s", path, lineno, s); return false; } - *color = res & 0xffffff; + *color = value & 0xffffff; return true; } @@ -149,6 +151,15 @@ parse_section_main(const char *key, const char *value, struct config *conf, conf->font = strdup(value); } + else if (strcmp(key, "workers") == 0) { + unsigned long count; + if (!str_to_ulong(value, 10, &count)) { + LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); + return false; + } + conf->render_worker_count = count; + } + else { LOG_WARN("%s:%u: invalid key: %s", path, lineno, key); return false; @@ -427,6 +438,8 @@ config_load(struct config *conf) .cursor = 0, }, }, + + .render_worker_count = sysconf(_SC_NPROCESSORS_ONLN), }; char *path = get_config_path(); |
