Verified Commit c09470a5 authored by Karel Koci's avatar Karel Koci 🤘

uri: make threads conditional

We do not need error variables to be thread_local but it would be good
to set them so. The problem is that some libc implementations with C11
support do not provide this header. We can check for that and for now
just ignore given option. This means that we provide it in case of
existing threads.h and ignore it in other case.
parent ce8d8ba0
Pipeline #47333 passed with stage
in 4 minutes and 43 seconds
......@@ -30,9 +30,9 @@
#define TMP_TEMPLATE_SIGNATURE_FILE "/tmp/updater-sig-XXXXXX"
thread_local enum uri_error uri_errno = 0;
thread_local enum uri_error uri_sub_errno = 0;
thread_local struct uri *uri_sub_err_uri = NULL;
THREAD_LOCAL enum uri_error uri_errno = 0;
THREAD_LOCAL enum uri_error uri_sub_errno = 0;
THREAD_LOCAL struct uri *uri_sub_err_uri = NULL;
static const char *error_messages[] = {
[URI_E_INVALID_URI] = "URI has invalid format",
......@@ -21,8 +21,14 @@
#include <stdint.h>
#include <stdbool.h>
#include <threads.h>
#include "download.h"
#ifndef __STDC_NO_THREADS__
#include <threads.h>
#define THREAD_LOCAL thread_local
#warning Your LIBC does not provide threads.h. Updater should work but you should update nonetheless
struct uri;
......@@ -40,12 +46,12 @@ enum uri_error {
// URI error number
extern thread_local enum uri_error uri_errno;
extern THREAD_LOCAL enum uri_error uri_errno;
// Error that is set when uri_errno is set to URI_E_SIG_FAIL
extern thread_local enum uri_error uri_sub_errno;
extern THREAD_LOCAL enum uri_error uri_sub_errno;
// URI object that caused uri_sub_errno error.
// This is valid only until original URI object is freed or new error happens
extern thread_local struct uri *uri_sub_err_uri;
extern THREAD_LOCAL struct uri *uri_sub_err_uri;
#define URI_E_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment