summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-02-02 10:02:26 +0000
committerYann Ylavic <ylavic@apache.org>2022-02-02 10:02:26 +0000
commit7833dc9148c549040eee27ddc90dda8cf28dcf4d (patch)
treefa58a0e1c8a88d7639ba94c972eda4cbb792b288
parenta31b463532e83d557a4898cfb6411e144bc39266 (diff)
downloadhttpd-7833dc9148c549040eee27ddc90dda8cf28dcf4d.tar.gz
core: Follow up to r1897240: Opt-out for AP_HAS_THREAD_LOCAL and/or pcre's usage.
If the compiler's thread_local is not efficient enough on some platforms, or not desired, have a way to disable its usage in httpd (at compile time). Handle -DAP_NO_THREAD_LOCAL and/or -DAPREG_NO_THREAD_LOCAL as build opt-out for thread_local usage in httpd gobally and/or in ap_regex only (respectively). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897689 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--include/httpd.h12
-rw-r--r--server/util.c6
-rw-r--r--server/util_pcre.c6
3 files changed, 13 insertions, 11 deletions
diff --git a/include/httpd.h b/include/httpd.h
index 96618c282a..86456d4afd 100644
--- a/include/httpd.h
+++ b/include/httpd.h
@@ -2566,7 +2566,7 @@ AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
#if APR_HAS_THREADS
-#if APR_VERSION_AT_LEAST(1,8,0)
+#if APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL)
/**
* APR 1.8+ implement those already.
@@ -2581,8 +2581,9 @@ AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
#define ap_thread_current apr_thread_current
#define ap_thread_current_after_fork apr_thread_current_after_fork
-#else /* !APR_VERSION_AT_LEAST(1,8,0) */
+#else /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
+#ifndef AP_NO_THREAD_LOCAL
/**
* AP_THREAD_LOCAL keyword mapping the compiler's.
*/
@@ -2595,6 +2596,7 @@ AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
#elif defined(WIN32) && defined(_MSC_VER)
#define AP_THREAD_LOCAL __declspec(thread)
#endif
+#endif /* ndef AP_NO_THREAD_LOCAL */
#ifndef AP_THREAD_LOCAL
#define AP_HAS_THREAD_LOCAL 0
@@ -2610,16 +2612,16 @@ AP_DECLARE(apr_status_t) ap_thread_create(apr_thread_t **thread,
AP_DECLARE(void) ap_thread_current_after_fork(void);
AP_DECLARE(apr_thread_t *) ap_thread_current(void);
-#endif /* !APR_VERSION_AT_LEAST(1,8,0) */
+#endif /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
AP_DECLARE(apr_status_t) ap_thread_main_create(apr_thread_t **thread,
apr_pool_t *pool);
-#else /* !APR_HAS_THREADS */
+#else /* APR_HAS_THREADS */
#define AP_HAS_THREAD_LOCAL 0
-#endif /* !APR_HAS_THREADS */
+#endif /* APR_HAS_THREADS */
/**
* Get server load params
diff --git a/server/util.c b/server/util.c
index 7b7cbdd60b..7c2fa87cfd 100644
--- a/server/util.c
+++ b/server/util.c
@@ -3263,11 +3263,11 @@ AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
#if APR_HAS_THREADS
-#if APR_VERSION_AT_LEAST(1,8,0)
+#if APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL)
#define ap_thread_current_create apr_thread_current_create
-#else /* !APR_VERSION_AT_LEAST(1,8,0) */
+#else /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
#if AP_HAS_THREAD_LOCAL
@@ -3357,7 +3357,7 @@ AP_DECLARE(apr_thread_t *) ap_thread_current(void)
#endif
}
-#endif /* !APR_VERSION_AT_LEAST(1,8,0) */
+#endif /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
static apr_status_t main_thread_cleanup(void *arg)
{
diff --git a/server/util_pcre.c b/server/util_pcre.c
index ff64e3ff17..2be99842c1 100644
--- a/server/util_pcre.c
+++ b/server/util_pcre.c
@@ -313,7 +313,7 @@ void free_match_data(match_data_pt data, apr_size_t size)
#endif
}
-#if AP_HAS_THREAD_LOCAL
+#if AP_HAS_THREAD_LOCAL && !defined(APREG_NO_THREAD_LOCAL)
struct apreg_tls {
match_data_pt data;
@@ -380,7 +380,7 @@ static match_data_pt get_match_data(apr_size_t size,
return tls->data;
}
-#else /* !AP_HAS_THREAD_LOCAL */
+#else /* AP_HAS_THREAD_LOCAL && !defined(APREG_NO_THREAD_LOCAL) */
static APR_INLINE match_data_pt get_match_data(apr_size_t size,
match_vector_pt small_vector,
@@ -390,7 +390,7 @@ static APR_INLINE match_data_pt get_match_data(apr_size_t size,
return alloc_match_data(size, small_vector);
}
-#endif /* !AP_HAS_THREAD_LOCAL */
+#endif /* AP_HAS_THREAD_LOCAL && !defined(APREG_NO_THREAD_LOCAL) */
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
apr_size_t nmatch, ap_regmatch_t *pmatch,