]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
core: Follow up to r1897240: Opt-out for AP_HAS_THREAD_LOCAL and/or pcre's usage.
authorYann Ylavic <ylavic@apache.org>
Wed, 2 Feb 2022 10:02:26 +0000 (10:02 +0000)
committerYann Ylavic <ylavic@apache.org>
Wed, 2 Feb 2022 10:02:26 +0000 (10:02 +0000)
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

include/httpd.h
server/util.c
server/util_pcre.c

index 96618c282af019f56d20259a387e803be0de67da..86456d4afd927bfc2ec0f3ad93fb5a1d43253c84 100644 (file)
@@ -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
index 7b7cbdd60b134253bcfed14d6328283d2761ac01..7c2fa87cfd83fcfbb662d96f61e18a1ef6283cef 100644 (file)
@@ -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)
 {
index ff64e3ff17a5fc708e78d5e8306cc0d0d51b3f57..2be99842c16c10219823bd3f5c76c829c16a09d9 100644 (file)
@@ -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,