Skip to content

Commit c75ca82

Browse files
authored
Merge pull request #1630 from albinahlback/pthread
Don't include pthread.h if not using it
2 parents fddfc40 + 2a1ffee commit c75ca82

File tree

7 files changed

+24
-35
lines changed

7 files changed

+24
-35
lines changed

src/fmpz.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
#include "fmpz_types.h"
2222

23-
#if FLINT_USES_PTHREAD
24-
#include <pthread.h>
25-
#endif
26-
2723
#ifdef __cplusplus
2824
extern "C" {
2925
#endif

src/fmpz/link/fmpz_single.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "fmpz.h"
2323

2424
#if FLINT_USES_PTHREAD
25+
# include <pthread.h>
2526
# include <stdatomic.h>
2627
#endif
2728

src/generic_files/exception.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <stdarg.h>
1515
#include "flint.h"
1616

17-
#if FLINT_REENTRANT && !FLINT_USES_TLS
17+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
1818
#include <pthread.h>
1919

2020
static pthread_once_t abort_func_init = PTHREAD_ONCE_INIT;
@@ -30,14 +30,14 @@ FLINT_NORETURN void (*abort_func)(void) = abort;
3030

3131
void flint_set_abort(FLINT_NORETURN void (*func)(void))
3232
{
33-
#if FLINT_REENTRANT && !FLINT_USES_TLS
33+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
3434
pthread_once(&abort_func_init, __flint_set_abort_init);
3535
pthread_mutex_lock(&abort_func_lock);
3636
#endif
3737

3838
abort_func = func;
3939

40-
#if FLINT_REENTRANT && !FLINT_USES_TLS
40+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
4141
pthread_mutex_unlock(&abort_func_lock);
4242
#endif
4343
}

src/generic_files/memory_manager.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414

1515
#include <stdlib.h>
16-
#include "flint.h"
1716
#include "mpfr.h"
1817
#include "thread_pool.h"
1918

@@ -31,7 +30,7 @@ static void *(*__flint_callocate_func) (size_t, size_t) = _flint_calloc;
3130
static void *(*__flint_reallocate_func) (void *, size_t) = _flint_realloc;
3231
static void (*__flint_free_func) (void *) = _flint_free;
3332

34-
#if FLINT_REENTRANT && !FLINT_USES_TLS
33+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
3534
#include <pthread.h>
3635

3736
static pthread_once_t register_initialised = PTHREAD_ONCE_INIT;
@@ -56,7 +55,7 @@ void __flint_get_memory_functions(void *(**alloc_func) (size_t),
5655
void *(**realloc_func) (void *, size_t),
5756
void (**free_func) (void *))
5857
{
59-
#if FLINT_REENTRANT && !FLINT_USES_TLS
58+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
6059
pthread_once(&alloc_func_init, __flint_set_memory_functions_init);
6160
pthread_mutex_lock(&alloc_func_lock);
6261
#endif
@@ -66,7 +65,7 @@ void __flint_get_memory_functions(void *(**alloc_func) (size_t),
6665
*realloc_func = __flint_reallocate_func;
6766
*free_func = __flint_free_func;
6867

69-
#if FLINT_REENTRANT && !FLINT_USES_TLS
68+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
7069
pthread_mutex_unlock(&alloc_func_lock);
7170
#endif
7271
}
@@ -76,7 +75,7 @@ void __flint_set_memory_functions(void *(*alloc_func) (size_t),
7675
void *(*realloc_func) (void *, size_t),
7776
void (*free_func) (void *))
7877
{
79-
#if FLINT_REENTRANT && !FLINT_USES_TLS
78+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
8079
pthread_once(&alloc_func_init, __flint_set_memory_functions_init);
8180
pthread_mutex_lock(&alloc_func_lock);
8281
#endif
@@ -86,7 +85,7 @@ void __flint_set_memory_functions(void *(*alloc_func) (size_t),
8685
__flint_reallocate_func = realloc_func;
8786
__flint_free_func = free_func;
8887

89-
#if FLINT_REENTRANT && !FLINT_USES_TLS
88+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
9089
pthread_mutex_unlock(&alloc_func_lock);
9190
#endif
9291
}
@@ -185,7 +184,7 @@ FLINT_TLS_PREFIX size_t flint_num_cleanup_functions = 0;
185184

186185
FLINT_TLS_PREFIX flint_cleanup_function_t * flint_cleanup_functions = NULL;
187186

188-
#if FLINT_REENTRANT && !FLINT_USES_TLS
187+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
189188
void register_init(void)
190189
{
191190
pthread_mutex_init(&register_lock, NULL);
@@ -194,7 +193,7 @@ void register_init(void)
194193

195194
void flint_register_cleanup_function(flint_cleanup_function_t cleanup_function)
196195
{
197-
#if FLINT_REENTRANT && !FLINT_USES_TLS
196+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
198197
pthread_once(&register_initialised, register_init);
199198
pthread_mutex_lock(&register_lock);
200199
#endif
@@ -206,7 +205,7 @@ void flint_register_cleanup_function(flint_cleanup_function_t cleanup_function)
206205

207206
flint_num_cleanup_functions++;
208207

209-
#if FLINT_REENTRANT && !FLINT_USES_TLS
208+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
210209
pthread_mutex_unlock(&register_lock);
211210
#endif
212211
}
@@ -217,7 +216,7 @@ void _flint_cleanup(void)
217216
{
218217
size_t i;
219218

220-
#if FLINT_REENTRANT && !FLINT_USES_TLS
219+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
221220
pthread_mutex_lock(&register_lock);
222221
#endif
223222

@@ -231,7 +230,7 @@ void _flint_cleanup(void)
231230
mpfr_free_cache();
232231
_fmpz_cleanup();
233232

234-
#if FLINT_REENTRANT && !FLINT_USES_TLS
233+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
235234
pthread_mutex_unlock(&register_lock);
236235
#endif
237236

src/mpn_extras/factor_trial_tree.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
(at your option) any later version. See <https://www.gnu.org/licenses/>.
1010
*/
1111

12-
#include "flint.h"
13-
#include "fmpz.h"
14-
#include "fmpz_poly.h"
1512
#include "mpn_extras.h"
1613
#include "ulong_extras.h"
14+
#include "fmpz.h"
15+
#include "fmpz_poly.h"
1716

18-
#if FLINT_REENTRANT && !FLINT_USES_TLS
17+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
1918
#include <pthread.h>
2019

2120
static pthread_once_t _factor_trial_initialised = PTHREAD_ONCE_INIT;
@@ -25,7 +24,7 @@ pthread_mutex_t _factor_trial_lock;
2524
FLINT_TLS_PREFIX mp_ptr _factor_trial_tree[16 - (FLINT_BITS/32)];
2625
FLINT_TLS_PREFIX int _factor_trial_tree_initialised = 0;
2726

28-
#if FLINT_REENTRANT && !FLINT_USES_TLS
27+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
2928
void _tree_mutex_init(void)
3029
{
3130
pthread_mutex_init(&_factor_trial_lock, NULL);
@@ -48,7 +47,7 @@ _factor_trial_tree_init(void)
4847
slong i, j, k, m, n;
4948
const mp_limb_t * primes;
5049

51-
#if FLINT_REENTRANT && !FLINT_USES_TLS
50+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
5251
pthread_once(&_factor_trial_initialised, _tree_mutex_init);
5352
pthread_mutex_lock(&_factor_trial_lock);
5453
#endif
@@ -108,7 +107,7 @@ _factor_trial_tree_init(void)
108107
_factor_trial_tree_initialised = 1;
109108
}
110109

111-
#if FLINT_REENTRANT && !FLINT_USES_TLS
110+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
112111
pthread_mutex_unlock(&_factor_trial_lock);
113112
#endif
114113
}

src/nmod_poly/compose_mod_brent_kung_vec_preinv_threaded.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
(at your option) any later version. See <https://www.gnu.org/licenses/>.
1212
*/
1313

14-
#if FLINT_USES_PTHREAD
15-
#include <pthread.h>
16-
#endif
1714
#include "thread_support.h"
1815
#include "ulong_extras.h"
1916
#include "nmod_vec.h"

src/ulong_extras/compute_primes.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@
1111
(at your option) any later version. See <https://www.gnu.org/licenses/>.
1212
*/
1313

14-
#include <string.h>
15-
16-
#include "flint.h"
1714
#include "ulong_extras.h"
1815

19-
#if FLINT_REENTRANT && !FLINT_USES_TLS
16+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
2017
#include <pthread.h>
2118

2219
static pthread_once_t primes_initialised = PTHREAD_ONCE_INIT;
@@ -43,7 +40,7 @@ FLINT_TLS_PREFIX mp_limb_t * _flint_primes[FLINT_BITS];
4340
FLINT_TLS_PREFIX double * _flint_prime_inverses[FLINT_BITS];
4441
FLINT_TLS_PREFIX int _flint_primes_used = 0;
4542

46-
#if FLINT_REENTRANT && !FLINT_USES_TLS
43+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
4744
void n_compute_primes_init()
4845
{
4946
pthread_mutex_init(&primes_lock, NULL);
@@ -56,7 +53,7 @@ n_compute_primes(ulong num_primes)
5653
int i, m;
5754
ulong num_computed;
5855

59-
#if FLINT_REENTRANT && !FLINT_USES_TLS
56+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
6057
pthread_once(&primes_initialised, n_compute_primes_init);
6158
pthread_mutex_lock(&primes_lock);
6259
#endif
@@ -91,7 +88,7 @@ n_compute_primes(ulong num_primes)
9188
_flint_primes_used = m + 1;
9289
}
9390

94-
#if FLINT_REENTRANT && !FLINT_USES_TLS
91+
#if FLINT_REENTRANT && !FLINT_USES_TLS && FLINT_USES_PTHREAD
9592
pthread_mutex_unlock(&primes_lock);
9693
#endif
9794
}

0 commit comments

Comments
 (0)