diff --git a/config.h.in b/config.h.in index 1cd9d2d890..7a6c587981 100644 --- a/config.h.in +++ b/config.h.in @@ -294,7 +294,7 @@ (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine WORDS_BIGENDIAN -#cmakedefine HAVE_PTHREAD 1 +#cmakedefine FLINT_USES_PTHREAD 1 /* Define as `__inline' if that's what the C compiler calls it, or to nothing if it is not supported. */ diff --git a/configure b/configure index 5cee1c09da..2d8209f45e 100755 --- a/configure +++ b/configure @@ -680,7 +680,7 @@ rm -f build/test-fenv.h #pthread configuration -CONFIG_PTHREAD="#define HAVE_PTHREAD ${PTHREAD}" +CONFIG_PTHREAD="#define FLINT_USES_PTHREAD ${PTHREAD}" #cpu_set_t configuration diff --git a/fft/fft_mfa_truncate_sqrt2.c b/fft/fft_mfa_truncate_sqrt2.c index d2d58b15f0..efaf32e2c9 100644 --- a/fft/fft_mfa_truncate_sqrt2.c +++ b/fft/fft_mfa_truncate_sqrt2.c @@ -232,7 +232,7 @@ typedef struct mp_limb_t ** t1; mp_limb_t ** t2; mp_limb_t * temp; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif } @@ -257,12 +257,12 @@ _fft_outer1_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif i = *arg.i; end = *arg.i = FLINT_MIN(i + 16, n1); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -338,12 +338,12 @@ _fft_outer2_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif i = *arg.i; end = *arg.i = FLINT_MIN(i + 16, n1); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -376,7 +376,7 @@ void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, mp_size_t trunc2 = (trunc - 2*n)/n1; mp_size_t limbs = (n*w)/FLINT_BITS; flint_bitcnt_t depth = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif slong num_threads; @@ -385,7 +385,7 @@ void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, while ((UWORD(1)< #endif @@ -59,7 +59,7 @@ typedef fmpz_preinvn_struct fmpz_preinvn_t[1]; typedef struct { int count; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_t thread; #endif void * address; diff --git a/fmpz/link/fmpz_gc.c b/fmpz/link/fmpz_gc.c index 432de6519c..a3f36241dc 100644 --- a/fmpz/link/fmpz_gc.c +++ b/fmpz/link/fmpz_gc.c @@ -14,7 +14,7 @@ #include "flint.h" #include "fmpz.h" -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD #include static pthread_once_t fmpz_initialised = PTHREAD_ONCE_INIT; @@ -35,7 +35,7 @@ ulong mpz_alloc = 0; ulong mpz_free_num = 0; ulong mpz_free_alloc = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD void fmpz_lock_init() { pthread_mutex_init(&fmpz_lock, NULL); @@ -46,7 +46,7 @@ __mpz_struct * _fmpz_new_mpz(void) { __mpz_struct * z = NULL; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_once(&fmpz_initialised, fmpz_lock_init); pthread_mutex_lock(&fmpz_lock); #endif @@ -67,7 +67,7 @@ __mpz_struct * _fmpz_new_mpz(void) mpz_init(z); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&fmpz_lock); #endif @@ -81,7 +81,7 @@ void _fmpz_clear_mpz(fmpz f) if (ptr->_mp_alloc > FLINT_MPZ_MAX_CACHE_LIMBS) mpz_realloc2(ptr, 1); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&fmpz_lock); #endif @@ -93,7 +93,7 @@ void _fmpz_clear_mpz(fmpz f) mpz_free_arr[mpz_free_num++] = ptr; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&fmpz_lock); #endif } @@ -114,7 +114,7 @@ void _fmpz_cleanup_mpz_content(void) void _fmpz_cleanup(void) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&fmpz_lock); #endif @@ -122,7 +122,7 @@ void _fmpz_cleanup(void) flint_free(mpz_free_arr); mpz_free_arr = NULL; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&fmpz_lock); #endif } diff --git a/fmpz/link/fmpz_single.c b/fmpz/link/fmpz_single.c index 47c78350c2..4c4a79a18c 100644 --- a/fmpz/link/fmpz_single.c +++ b/fmpz/link/fmpz_single.c @@ -17,7 +17,7 @@ #include /* GetSytemInfo */ #endif -#if defined(_MSC_VER) && HAVE_PTHREAD +#if defined(_MSC_VER) && FLINT_USES_PTHREAD #include #endif @@ -83,7 +83,7 @@ __mpz_struct * _fmpz_new_mpz(void) /* set free count to zero and determine if this is the main thread */ ((fmpz_block_header_s *) ptr)->count = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD ((fmpz_block_header_s *) ptr)->thread = pthread_self(); #endif /* how many __mpz_structs worth are dedicated to header, per page */ @@ -133,7 +133,7 @@ void _fmpz_clear_mpz(fmpz f) header_ptr = (fmpz_block_header_s *) header_ptr->address; /* clean up if this is left over from another thread */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD if (header_ptr->count != 0 || !pthread_equal(header_ptr->thread, pthread_self())) #else if (header_ptr->count != 0) @@ -143,9 +143,9 @@ void _fmpz_clear_mpz(fmpz f) mpz_clear(ptr); -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && HAVE_PTHREAD +#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && FLINT_USES_PTHREAD new_count = __atomic_add_fetch(&(header_ptr->count), 1, __ATOMIC_SEQ_CST); -#elif defined(_MSC_VER) && HAVE_PTHREAD +#elif defined(_MSC_VER) && FLINT_USES_PTHREAD new_count = atomic_add_fetch(&(header_ptr->count), 1); #else new_count = ++header_ptr->count; @@ -184,9 +184,9 @@ void _fmpz_cleanup_mpz_content(void) ptr = (fmpz_block_header_s *) ptr->address; -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && HAVE_PTHREAD +#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && FLINT_USES_PTHREAD new_count = __atomic_add_fetch(&(ptr->count), 1, __ATOMIC_SEQ_CST); -#elif defined(_MSC_VER) && HAVE_PTHREAD +#elif defined(_MSC_VER) && FLINT_USES_PTHREAD new_count = atomic_add_fetch(&(ptr->count), 1); #else /* may be a very small leak with pthreads */ new_count = ++ptr->count; diff --git a/fmpz_mod_mat/mul_classical_threaded.c b/fmpz_mod_mat/mul_classical_threaded.c index 7ad69571e4..e242d983e2 100755 --- a/fmpz_mod_mat/mul_classical_threaded.c +++ b/fmpz_mod_mat/mul_classical_threaded.c @@ -65,7 +65,7 @@ typedef struct fmpz ** D; fmpz * tmp; fmpz * p; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif int op; @@ -92,7 +92,7 @@ _fmpz_mod_mat_addmul_transpose_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif i = *arg.i; @@ -104,7 +104,7 @@ _fmpz_mod_mat_addmul_transpose_worker(void * arg_ptr) j = 0; } *arg.j = j + block; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -145,7 +145,7 @@ _fmpz_mod_mat_addmul_transpose_threaded_pool_op(fmpz ** D, fmpz ** const C, slong i, j, block, nlimbs; slong shared_i = 0, shared_j = 0; fmpz_mod_mat_transpose_arg_t * args; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -179,13 +179,13 @@ _fmpz_mod_mat_addmul_transpose_threaded_pool_op(fmpz ** D, fmpz ** const C, args[i].D = D; args[i].tmp = tmp; args[i].p = p; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD args[i].mutex = &mutex; #endif args[i].op = op; } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&mutex, NULL); #endif @@ -202,7 +202,7 @@ _fmpz_mod_mat_addmul_transpose_threaded_pool_op(fmpz ** D, fmpz ** const C, thread_pool_wait(global_thread_pool, threads[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&mutex); #endif diff --git a/fmpz_mod_mat/test/t-mul_classical_threaded.c b/fmpz_mod_mat/test/t-mul_classical_threaded.c index 29d9db1328..0627d8d26d 100755 --- a/fmpz_mod_mat/test/t-mul_classical_threaded.c +++ b/fmpz_mod_mat/test/t-mul_classical_threaded.c @@ -22,7 +22,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) slong i, max_threads = 5; #endif FLINT_TEST_INIT(state); @@ -30,7 +30,7 @@ main(void) flint_printf("mul_classical_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) for (i = 0; i < 1000 * flint_test_multiplier(); i++) { fmpz_mod_mat_t A, B, C, D; diff --git a/fmpz_mod_poly/compose_mod_brent_kung_vec_preinv_threaded.c b/fmpz_mod_poly/compose_mod_brent_kung_vec_preinv_threaded.c index 70c0ecc9ab..d0765ef7d7 100644 --- a/fmpz_mod_poly/compose_mod_brent_kung_vec_preinv_threaded.c +++ b/fmpz_mod_poly/compose_mod_brent_kung_vec_preinv_threaded.c @@ -35,7 +35,7 @@ typedef struct slong len; slong leninv; slong len2; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif } @@ -57,12 +57,12 @@ _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif j = *arg.j; *arg.j = j + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -109,7 +109,7 @@ _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_str slong i, j, n, m, k, len2 = l, len1, shared_j = 0; fmpz * h; compose_vec_arg_t * args; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -173,12 +173,12 @@ _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_str args[i].leninv = leninv; args[i].p = p; args[i].len2 = len2; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD args[i].mutex = &mutex; #endif } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&mutex, NULL); #endif @@ -195,7 +195,7 @@ _fmpz_mod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(fmpz_mod_poly_str thread_pool_wait(global_thread_pool, threads[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&mutex); #endif diff --git a/fmpz_mod_poly/powers_mod_bsgs_threaded.c b/fmpz_mod_poly/powers_mod_bsgs_threaded.c index a7608823f6..40ff30534a 100755 --- a/fmpz_mod_poly/powers_mod_bsgs_threaded.c +++ b/fmpz_mod_poly/powers_mod_bsgs_threaded.c @@ -27,7 +27,7 @@ typedef struct const fmpz * ginv; fmpz ** res; const fmpz * p; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif } fmpz_powers_preinv_arg_t; @@ -44,12 +44,12 @@ _fmpz_mod_poly_powers_mod_preinv_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif j = *arg.j + k; *arg.j = j; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -87,7 +87,7 @@ _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, { slong i, k, shared_j = 0; fmpz_powers_preinv_arg_t * args; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -147,12 +147,12 @@ _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, args[i].ginv = ginv; args[i].res = res; args[i].p = p; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD args[i].mutex = &mutex; #endif } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&mutex, NULL); #endif @@ -165,7 +165,7 @@ _fmpz_mod_poly_powers_mod_preinv_threaded_pool(fmpz ** res, const fmpz * f, for (i = 0; i < num_threads; i++) thread_pool_wait(global_thread_pool, threads[i]); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&mutex); #endif diff --git a/fmpz_mod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c b/fmpz_mod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c index a2951c015f..a9e3d6f55c 100644 --- a/fmpz_mod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c +++ b/fmpz_mod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c @@ -33,7 +33,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int i; fmpz_mod_ctx_t ctx; #endif @@ -42,7 +42,7 @@ main(void) flint_printf("compose_mod_brent_kung_precomp_preinv_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) fmpz_mod_ctx_init_ui(ctx, 2); diff --git a/fmpz_mod_poly/test/t-powers_mod_bsgs.c b/fmpz_mod_poly/test/t-powers_mod_bsgs.c index df1492de0d..9ecb8dfc0b 100755 --- a/fmpz_mod_poly/test/t-powers_mod_bsgs.c +++ b/fmpz_mod_poly/test/t-powers_mod_bsgs.c @@ -20,7 +20,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int i, result, max_threads = 5; fmpz_mod_ctx_t ctx; #endif @@ -29,7 +29,7 @@ main(void) flint_printf("powers_mod_bsgs...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) fmpz_mod_ctx_init_ui(ctx, 2); diff --git a/fmpz_mod_poly_factor/test/t-factor_distinct_deg_threaded.c b/fmpz_mod_poly_factor/test/t-factor_distinct_deg_threaded.c index 91b8c8c6aa..a2779fe135 100644 --- a/fmpz_mod_poly_factor/test/t-factor_distinct_deg_threaded.c +++ b/fmpz_mod_poly_factor/test/t-factor_distinct_deg_threaded.c @@ -24,7 +24,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int iter; fmpz_mod_ctx_t ctx; #endif @@ -33,7 +33,7 @@ int main(void) flint_printf("factor_distinct_deg_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) fmpz_mod_ctx_init_ui(ctx, 2); diff --git a/fmpz_mod_poly_factor/test/t-interval_threaded.c b/fmpz_mod_poly_factor/test/t-interval_threaded.c index 0188013a50..8fc08c0bab 100644 --- a/fmpz_mod_poly_factor/test/t-interval_threaded.c +++ b/fmpz_mod_poly_factor/test/t-interval_threaded.c @@ -31,7 +31,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int i; fmpz_mod_ctx_t ctx; #endif @@ -40,7 +40,7 @@ main(void) flint_printf("interval_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) fmpz_mod_ctx_init_ui(ctx, 2); diff --git a/fmpz_mpoly/divides_heap_threaded.c b/fmpz_mpoly/divides_heap_threaded.c index 84f41b6133..3f5061bea0 100644 --- a/fmpz_mpoly/divides_heap_threaded.c +++ b/fmpz_mpoly/divides_heap_threaded.c @@ -212,7 +212,7 @@ typedef divides_heap_chunk_struct divides_heap_chunk_t[1]; */ typedef struct { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif divides_heap_chunk_struct * head; @@ -1958,28 +1958,28 @@ static void worker_loop(void * varg) } while (L != NULL) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif if (L->lock != -1) { L->lock = -1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif trychunk(W, L); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif L->lock = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif break; } else { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif } @@ -2178,7 +2178,7 @@ int _fmpz_mpoly_divides_heap_threaded_pool( /* start the workers */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&H->mutex, NULL); #endif @@ -2200,7 +2200,7 @@ int _fmpz_mpoly_divides_heap_threaded_pool( flint_free(worker_args); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&H->mutex); #endif diff --git a/fmpz_mpoly/gcd_berlekamp_massey_threaded.c b/fmpz_mpoly/gcd_berlekamp_massey_threaded.c index 0546e87c02..3bad887a7e 100644 --- a/fmpz_mpoly/gcd_berlekamp_massey_threaded.c +++ b/fmpz_mpoly/gcd_berlekamp_massey_threaded.c @@ -51,7 +51,7 @@ typedef struct volatile int zip_find_coeffs_no_match, zip_find_coeffs_non_invertible; volatile int Gchanged, Abarchanged, Bbarchanged, Hchanged, failed; int which_check; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -351,12 +351,12 @@ static void _worker_skel_sp(void * varg_) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -396,12 +396,12 @@ static void _worker_skel_mp(void * varg_) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -701,12 +701,12 @@ static void _worker_check_eval_sp(void * varg) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -757,12 +757,12 @@ static void _worker_check_eval_mp(void * varg) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -817,12 +817,12 @@ static void _worker_reduce_sp(void * varg) next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -871,12 +871,12 @@ static void _worker_reduce_mp(void * varg) next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -940,12 +940,12 @@ static void _worker_get_mpoly_sp(void * varg) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -1000,12 +1000,12 @@ static void _worker_get_mpoly_mp(void * varg) next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -1043,12 +1043,12 @@ static void _worker_find_zip_coeffs(void * varg) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -1094,12 +1094,12 @@ static void _worker_crt_zip_coeffs(void * varg) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&w->mutex); #endif i = w->index; w->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&w->mutex); #endif @@ -1893,7 +1893,7 @@ int fmpz_mpolyuu_gcd_berlekamp_massey_threaded_pool( mpoly_bma_interpolate_ctx_init(w->Ictx, ctx->minfo->nvars); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&w->mutex, NULL); #endif @@ -2398,7 +2398,7 @@ int fmpz_mpolyuu_gcd_berlekamp_massey_threaded_pool( flint_free(w->Adegs); flint_free(w->Bdegs); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&w->mutex); #endif diff --git a/fmpz_mpoly/gcd_brown_threaded.c b/fmpz_mpoly/gcd_brown_threaded.c index bf8c76bcac..f96516fd76 100644 --- a/fmpz_mpoly/gcd_brown_threaded.c +++ b/fmpz_mpoly/gcd_brown_threaded.c @@ -18,7 +18,7 @@ typedef struct { volatile int gcd_is_one; volatile mp_limb_t p; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif fmpz_t gamma; @@ -116,20 +116,20 @@ static void _splitworker(void * varg) while (arg->image_count < arg->required_images) { /* get prime */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif p = base->p; if (p >= UWORD_MAX_PRIME) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif break; } p = n_nextprime(base->p, 1); base->p = p; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif @@ -505,7 +505,7 @@ static slong _fmpz_mpoly_crt( typedef struct { volatile int idx; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif const fmpz_mpoly_ctx_struct * ctx; @@ -546,12 +546,12 @@ static void _joinworker(void * varg) while (1) { /* get exponent of either G, Abar, or Bbar to start working on */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif i = base->idx; base->idx = i + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif @@ -809,7 +809,7 @@ int fmpz_mpolyl_gcd_brown_threaded_pool( splitbase->p = UWORD(1) << (FLINT_BITS - 2); splitbase->I = I; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&splitbase->mutex, NULL); #endif @@ -970,7 +970,7 @@ int fmpz_mpolyl_gcd_brown_threaded_pool( joinbase->Abar = Abar; joinbase->Bbar = Bbar; joinbase->ctx = ctx; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&joinbase->mutex, NULL); #endif @@ -1095,7 +1095,7 @@ int fmpz_mpolyl_gcd_brown_threaded_pool( FLINT_ASSERT(fmpz_mpoly_is_canonical(Abar, ctx)); FLINT_ASSERT(fmpz_mpoly_is_canonical(Bbar, ctx)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&joinbase->mutex); #endif @@ -1152,7 +1152,7 @@ int fmpz_mpolyl_gcd_brown_threaded_pool( cleanup_split: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&splitbase->mutex); #endif fmpz_clear(splitbase->gamma); diff --git a/fmpz_mpoly/mpolyu.c b/fmpz_mpoly/mpolyu.c index 6f0deff376..98e996ace2 100644 --- a/fmpz_mpoly/mpolyu.c +++ b/fmpz_mpoly/mpolyu.c @@ -462,7 +462,7 @@ void fmpz_mpoly_to_mpoly_perm_deflate_threaded_pool( typedef struct { volatile slong index; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif slong length; @@ -481,12 +481,12 @@ static void _worker_sort(void * varg) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&arg->mutex); #endif i = arg->index; arg->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&arg->mutex); #endif @@ -765,7 +765,7 @@ void fmpz_mpoly_to_mpolyu_perm_deflate_threaded_pool( { _sort_arg_t arg; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&arg->mutex, NULL); #endif arg->index = 0; @@ -783,7 +783,7 @@ void fmpz_mpoly_to_mpolyu_perm_deflate_threaded_pool( thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&arg->mutex); #endif } @@ -1247,7 +1247,7 @@ void fmpz_mpoly_to_mpolyuu_perm_deflate_threaded_pool( { _sort_arg_t arg; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&arg->mutex, NULL); #endif arg->index = 0; @@ -1265,7 +1265,7 @@ void fmpz_mpoly_to_mpolyuu_perm_deflate_threaded_pool( thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&arg->mutex); #endif } diff --git a/fmpz_mpoly/mpolyu_divides_threaded.c b/fmpz_mpoly/mpolyu_divides_threaded.c index a53f1f0984..05f5c730be 100644 --- a/fmpz_mpoly/mpolyu_divides_threaded.c +++ b/fmpz_mpoly/mpolyu_divides_threaded.c @@ -276,7 +276,7 @@ typedef divides_heap_chunk_struct divides_heap_chunk_t[1]; typedef struct { volatile int failed; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif divides_heap_chunk_struct * head; @@ -1269,28 +1269,28 @@ static void worker_loop(void * varg) } while (L != NULL) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif if (L->lock != -1) { L->lock = -1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif trychunk(W, L); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif L->lock = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif break; } else { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif } @@ -1478,7 +1478,7 @@ int fmpz_mpolyuu_divides_threaded_pool( /* start the workers */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&H->mutex, NULL); #endif @@ -1499,7 +1499,7 @@ int fmpz_mpolyuu_divides_threaded_pool( flint_free(worker_args); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&H->mutex); #endif diff --git a/fmpz_mpoly/mul_array_threaded.c b/fmpz_mpoly/mul_array_threaded.c index 3a95f7f0c6..5160400fda 100644 --- a/fmpz_mpoly/mul_array_threaded.c +++ b/fmpz_mpoly/mul_array_threaded.c @@ -35,7 +35,7 @@ _chunk_struct; typedef struct { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif volatile int idx; @@ -86,12 +86,12 @@ void _fmpz_mpoly_mul_array_threaded_worker_LEX(void * varg) for (j = 0; j < 3*base->array_size; j++) coeff_array[j] = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif @@ -202,12 +202,12 @@ void _fmpz_mpoly_mul_array_threaded_worker_LEX(void * varg) base->array_size, base->Pl - base->perm[Pi] - 1); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -329,7 +329,7 @@ void _fmpz_mpoly_mul_array_chunked_threaded_LEX( args = (_worker_arg_struct *) TMP_ALLOC(base->nthreads *sizeof(_worker_arg_struct)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&base->mutex, NULL); #endif for (i = 0; i < num_handles; i++) @@ -347,7 +347,7 @@ void _fmpz_mpoly_mul_array_chunked_threaded_LEX( { thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&base->mutex); #endif @@ -509,12 +509,12 @@ void _fmpz_mpoly_mul_array_threaded_worker_DEG(void * varg) for (j = 0; j < 3*base->array_size; j++) coeff_array[j] = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif @@ -621,12 +621,12 @@ void _fmpz_mpoly_mul_array_threaded_worker_DEG(void * varg) base->nvars, base->degb); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -751,7 +751,7 @@ void _fmpz_mpoly_mul_array_chunked_threaded_DEG( args = (_worker_arg_struct *) TMP_ALLOC(base->nthreads *sizeof(_worker_arg_struct)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&base->mutex, NULL); #endif for (i = 0; i < num_handles; i++) @@ -770,7 +770,7 @@ void _fmpz_mpoly_mul_array_chunked_threaded_DEG( { thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&base->mutex); #endif diff --git a/fmpz_mpoly/mul_heap_threaded.c b/fmpz_mpoly/mul_heap_threaded.c index e8e454c333..d510db0392 100644 --- a/fmpz_mpoly/mul_heap_threaded.c +++ b/fmpz_mpoly/mul_heap_threaded.c @@ -388,7 +388,7 @@ slong _fmpz_mpoly_mul_heap_part(fmpz ** A_coeff, ulong ** A_exp, slong * A_alloc typedef struct { volatile int idx; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif slong nthreads; @@ -430,7 +430,7 @@ typedef struct slong time; _base_struct * base; _div_struct * divs; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; pthread_cond_t cond; #endif @@ -496,12 +496,12 @@ static void _fmpz_mpoly_mul_heap_threaded_worker(void * varg) /* get index to start working on */ if (arg->idx + 1 < base->nthreads) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif i = base->idx - 1; base->idx = i; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -586,12 +586,12 @@ static void _fmpz_mpoly_mul_heap_threaded_worker(void * varg) } /* get next index to work on */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif i = base->idx - 1; base->idx = i; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -719,7 +719,7 @@ void _fmpz_mpoly_mul_heap_threaded( } /* compute each chunk in parallel */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&base->mutex, NULL); #endif for (i = 0; i < num_handles; i++) @@ -771,7 +771,7 @@ void _fmpz_mpoly_mul_heap_threaded( thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&base->mutex); #endif diff --git a/fmpz_poly/test/t-taylor_shift_multi_mod_threaded.c b/fmpz_poly/test/t-taylor_shift_multi_mod_threaded.c index e8ac37f79e..b551a82113 100644 --- a/fmpz_poly/test/t-taylor_shift_multi_mod_threaded.c +++ b/fmpz_poly/test/t-taylor_shift_multi_mod_threaded.c @@ -20,7 +20,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int i; #endif FLINT_TEST_INIT(state); @@ -28,7 +28,7 @@ main(void) flint_printf("taylor_shift_multi_mod...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) /* Check aliasing */ for (i = 0; i < 100 * flint_test_multiplier(); i++) diff --git a/nmod_mat/mul_classical_threaded.c b/nmod_mat/mul_classical_threaded.c index 5d5f3488a0..a03e164eba 100644 --- a/nmod_mat/mul_classical_threaded.c +++ b/nmod_mat/mul_classical_threaded.c @@ -62,7 +62,7 @@ typedef struct mp_ptr * D; mp_ptr tmp; nmod_t mod; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif int op; @@ -88,7 +88,7 @@ _nmod_mat_addmul_transpose_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif i = *arg.i; @@ -100,7 +100,7 @@ _nmod_mat_addmul_transpose_worker(void * arg_ptr) j = 0; } *arg.j = j + block; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -138,7 +138,7 @@ _nmod_mat_addmul_transpose_threaded_pool_op(mp_ptr * D, const mp_ptr * C, slong i, j, block; slong shared_i = 0, shared_j = 0; nmod_mat_transpose_arg_t * args; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -171,13 +171,13 @@ _nmod_mat_addmul_transpose_threaded_pool_op(mp_ptr * D, const mp_ptr * C, args[i].D = D; args[i].tmp = tmp; args[i].mod = mod; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD args[i].mutex = &mutex; #endif args[i].op = op; } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&mutex, NULL); #endif @@ -194,7 +194,7 @@ _nmod_mat_addmul_transpose_threaded_pool_op(mp_ptr * D, const mp_ptr * C, thread_pool_wait(global_thread_pool, threads[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&mutex); #endif @@ -218,7 +218,7 @@ typedef struct mp_ptr tmp; nmod_t mod; mp_limb_t mask; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif int pack; @@ -250,7 +250,7 @@ _nmod_mat_addmul_packed_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif i = *arg.i; @@ -262,7 +262,7 @@ _nmod_mat_addmul_packed_worker(void * arg_ptr) j = 0; } *arg.j = j + block; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -327,7 +327,7 @@ _nmod_mat_addmul_packed_threaded_pool_op(mp_ptr * D, mp_ptr tmp; slong shared_i = 0, shared_j = 0; nmod_mat_packed_arg_t * args; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -381,7 +381,7 @@ _nmod_mat_addmul_packed_threaded_pool_op(mp_ptr * D, args[i].tmp = tmp; args[i].mod = mod; args[i].mask = mask; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD args[i].mutex = &mutex; #endif args[i].pack = pack; @@ -389,7 +389,7 @@ _nmod_mat_addmul_packed_threaded_pool_op(mp_ptr * D, args[i].op = op; } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&mutex, NULL); #endif @@ -406,7 +406,7 @@ _nmod_mat_addmul_packed_threaded_pool_op(mp_ptr * D, thread_pool_wait(global_thread_pool, threads[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&mutex); #endif diff --git a/nmod_mat/test/t-mul_classical_threaded.c b/nmod_mat/test/t-mul_classical_threaded.c index 36e9e13b23..d4a3976b00 100644 --- a/nmod_mat/test/t-mul_classical_threaded.c +++ b/nmod_mat/test/t-mul_classical_threaded.c @@ -49,7 +49,7 @@ nmod_mat_mul_check(nmod_mat_t C, const nmod_mat_t A, const nmod_mat_t B) int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) slong i, max_threads = 5; #endif FLINT_TEST_INIT(state); @@ -57,7 +57,7 @@ main(void) flint_printf("mul_classical_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) for (i = 0; i < 1000 * flint_test_multiplier(); i++) { nmod_mat_t A, B, C, D; diff --git a/nmod_mpoly/divides_heap_threaded.c b/nmod_mpoly/divides_heap_threaded.c index f487516eea..ed5136ff3f 100644 --- a/nmod_mpoly/divides_heap_threaded.c +++ b/nmod_mpoly/divides_heap_threaded.c @@ -252,7 +252,7 @@ typedef divides_heap_chunk_struct divides_heap_chunk_t[1]; */ typedef struct { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif divides_heap_chunk_struct * head; @@ -1671,28 +1671,28 @@ static void worker_loop(void * varg) } while (L != NULL) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif if (L->lock != -1) { L->lock = -1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif trychunk(W, L); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif L->lock = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif break; } else { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif } @@ -1881,7 +1881,7 @@ int _nmod_mpoly_divides_heap_threaded_pool( /* start the workers */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&H->mutex, NULL); #endif @@ -1925,7 +1925,7 @@ int _nmod_mpoly_divides_heap_threaded_pool( flint_free(worker_args); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&H->mutex); #endif diff --git a/nmod_mpoly/gcd_brown_threaded.c b/nmod_mpoly/gcd_brown_threaded.c index 959c786739..faa74d46cf 100644 --- a/nmod_mpoly/gcd_brown_threaded.c +++ b/nmod_mpoly/gcd_brown_threaded.c @@ -653,7 +653,7 @@ static slong _nmod_mpolyn_crt( typedef struct { volatile int idx; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif const nmod_mpoly_ctx_struct * ctx; @@ -696,12 +696,12 @@ static void _joinworker(void * varg) while (1) { /* get exponent of either G, Abar, or Bbar to start working on */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif i = base->idx; base->idx = i + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif @@ -1034,7 +1034,7 @@ int nmod_mpolyn_gcd_brown_smprime_threaded_pool( joinbase->Abar = Abar; joinbase->Bbar = Bbar; joinbase->ctx = ctx; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&joinbase->mutex, NULL); #endif @@ -1147,7 +1147,7 @@ int nmod_mpolyn_gcd_brown_smprime_threaded_pool( FLINT_ASSERT(nmod_mpolyn_is_canonical(Abar, ctx)); FLINT_ASSERT(nmod_mpolyn_is_canonical(Bbar, ctx)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&joinbase->mutex); #endif diff --git a/nmod_mpoly/mpolyn_divides_threaded.c b/nmod_mpoly/mpolyn_divides_threaded.c index b82254a9be..6d5cb15b8a 100644 --- a/nmod_mpoly/mpolyn_divides_threaded.c +++ b/nmod_mpoly/mpolyn_divides_threaded.c @@ -287,7 +287,7 @@ typedef divides_heap_chunk_struct divides_heap_chunk_t[1]; */ typedef struct { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif divides_heap_chunk_struct * head; @@ -1697,28 +1697,28 @@ static void worker_loop(void * varg) } while (L != NULL) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif if (L->lock != -1) { L->lock = -1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif trychunk(W, L); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&H->mutex); #endif L->lock = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif break; } else { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&H->mutex); #endif } @@ -1874,7 +1874,7 @@ int nmod_mpolyn_divides_threaded_pool( /* start the workers */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&H->mutex, NULL); #endif @@ -1896,7 +1896,7 @@ int nmod_mpolyn_divides_threaded_pool( flint_free(worker_args); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&H->mutex); #endif diff --git a/nmod_mpoly/mpolyu.c b/nmod_mpoly/mpolyu.c index a0dd711f0c..8af82a5a97 100644 --- a/nmod_mpoly/mpolyu.c +++ b/nmod_mpoly/mpolyu.c @@ -146,7 +146,7 @@ nmod_mpoly_struct * _nmod_mpolyu_get_coeff(nmod_mpolyu_t A, typedef struct { volatile slong index; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif slong length; @@ -165,12 +165,12 @@ static void _worker_sort(void * varg) get_next_index: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&arg->mutex); #endif i = arg->index; arg->index++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&arg->mutex); #endif @@ -257,7 +257,7 @@ void nmod_mpoly_to_mpolyu_perm_deflate_threaded_pool( { _sort_arg_t arg; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&arg->mutex, NULL); #endif arg->index = 0; @@ -275,7 +275,7 @@ void nmod_mpoly_to_mpolyu_perm_deflate_threaded_pool( thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&arg->mutex); #endif } diff --git a/nmod_mpoly/mul_array_threaded.c b/nmod_mpoly/mul_array_threaded.c index b92bc958d4..ee2e9817e0 100644 --- a/nmod_mpoly/mul_array_threaded.c +++ b/nmod_mpoly/mul_array_threaded.c @@ -31,7 +31,7 @@ _chunk_struct; typedef struct { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif volatile int idx; @@ -87,12 +87,12 @@ static void _nmod_mpoly_mul_array_threaded_worker_LEX(void * varg) for (j = 0; j < 3*base->array_size; j++) coeff_array[j] = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif @@ -193,12 +193,12 @@ static void _nmod_mpoly_mul_array_threaded_worker_LEX(void * varg) base->array_size, Pl - Pi - 1, base->ctx); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -299,7 +299,7 @@ void _nmod_mpoly_mul_array_chunked_threaded_LEX( args = (_worker_arg_struct *) TMP_ALLOC(base->nthreads *sizeof(_worker_arg_struct)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&base->mutex, NULL); #endif for (i = 0; i < num_handles; i++) @@ -317,7 +317,7 @@ void _nmod_mpoly_mul_array_chunked_threaded_LEX( { thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&base->mutex); #endif @@ -480,12 +480,12 @@ static void _nmod_mpoly_mul_array_threaded_worker_DEG(void * varg) for (j = 0; j < 3*base->array_size; j++) coeff_array[j] = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif @@ -576,12 +576,12 @@ static void _nmod_mpoly_mul_array_threaded_worker_DEG(void * varg) coeff_array, Pl - Pi - 1, base->nvars, base->degb, base->ctx); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif Pi = base->idx; base->idx = Pi + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -686,7 +686,7 @@ void _nmod_mpoly_mul_array_chunked_threaded_DEG( args = (_worker_arg_struct *) TMP_ALLOC(base->nthreads *sizeof(_worker_arg_struct)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&base->mutex, NULL); #endif for (i = 0; i < num_handles; i++) @@ -705,7 +705,7 @@ void _nmod_mpoly_mul_array_chunked_threaded_DEG( { thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&base->mutex); #endif diff --git a/nmod_mpoly/mul_heap_threaded.c b/nmod_mpoly/mul_heap_threaded.c index aadacb25c8..c3d58a0580 100644 --- a/nmod_mpoly/mul_heap_threaded.c +++ b/nmod_mpoly/mul_heap_threaded.c @@ -340,7 +340,7 @@ slong _nmod_mpoly_mul_heap_part(mp_limb_t ** A_coeff, ulong ** A_exp, slong * A_ typedef struct { volatile int idx; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif slong nthreads; @@ -382,7 +382,7 @@ typedef struct slong time; _base_struct * base; _div_struct * divs; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; pthread_cond_t cond; #endif @@ -449,12 +449,12 @@ static void _nmod_mpoly_mul_heap_threaded_worker(void * arg_ptr) /* get index to start working on */ if (arg->idx + 1 < base->nthreads) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif i = base->idx - 1; base->idx = i; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -540,12 +540,12 @@ static void _nmod_mpoly_mul_heap_threaded_worker(void * arg_ptr) } /* get next index to work on */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&base->mutex); #endif i = base->idx - 1; base->idx = i; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&base->mutex); #endif } @@ -670,7 +670,7 @@ void _nmod_mpoly_mul_heap_threaded( } /* compute each chunk in parallel */ -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&base->mutex, NULL); #endif for (i = 0; i < num_handles; i++) @@ -723,7 +723,7 @@ void _nmod_mpoly_mul_heap_threaded( thread_pool_wait(global_thread_pool, handles[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&base->mutex); #endif diff --git a/nmod_poly/compose_mod_brent_kung_vec_preinv_threaded.c b/nmod_poly/compose_mod_brent_kung_vec_preinv_threaded.c index a69cf0c2a5..fce279e4b6 100644 --- a/nmod_poly/compose_mod_brent_kung_vec_preinv_threaded.c +++ b/nmod_poly/compose_mod_brent_kung_vec_preinv_threaded.c @@ -12,7 +12,7 @@ */ #include -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD #include #endif #include "flint.h" @@ -37,7 +37,7 @@ typedef struct slong len; slong leninv; slong len2; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif } compose_vec_arg_t; @@ -58,12 +58,12 @@ _nmod_poly_compose_mod_brent_kung_vec_preinv_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif j = *arg.j; *arg.j = j + 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -108,7 +108,7 @@ _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * re slong i, j, n, m, k, len2 = l, len1, shared_j = 0; mp_ptr h; compose_vec_arg_t * args; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -173,12 +173,12 @@ _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * re args[i].leninv = leninv; args[i].p = mod; args[i].len2 = len2; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD args[i].mutex = &mutex; #endif } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&mutex, NULL); #endif @@ -195,7 +195,7 @@ _nmod_poly_compose_mod_brent_kung_vec_preinv_threaded_pool(nmod_poly_struct * re thread_pool_wait(global_thread_pool, threads[i]); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&mutex); #endif diff --git a/nmod_poly/powers_mod_bsgs_threaded.c b/nmod_poly/powers_mod_bsgs_threaded.c index 0cf79cdf5c..a7d48e5428 100644 --- a/nmod_poly/powers_mod_bsgs_threaded.c +++ b/nmod_poly/powers_mod_bsgs_threaded.c @@ -27,7 +27,7 @@ typedef struct mp_srcptr ginv; mp_ptr * res; nmod_t mod; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t * mutex; #endif } powers_preinv_arg_t; @@ -44,12 +44,12 @@ _nmod_poly_powers_mod_preinv_worker(void * arg_ptr) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(arg.mutex); #endif j = *arg.j + k; *arg.j = j; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(arg.mutex); #endif @@ -85,7 +85,7 @@ _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, { slong i, k, shared_j = 0; powers_preinv_arg_t * args; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif @@ -139,12 +139,12 @@ _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, args[i].ginv = ginv; args[i].res = res; args[i].mod = mod; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD args[i].mutex = &mutex; #endif } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&mutex, NULL); #endif @@ -157,7 +157,7 @@ _nmod_poly_powers_mod_preinv_threaded_pool(mp_ptr * res, mp_srcptr f, for (i = 0; i < num_threads; i++) thread_pool_wait(global_thread_pool, threads[i]); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&mutex); #endif diff --git a/nmod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c b/nmod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c index 66e0843d3f..71dd112cb3 100644 --- a/nmod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c +++ b/nmod_poly/test/t-compose_mod_brent_kung_precomp_preinv_threaded.c @@ -32,7 +32,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int i; #endif FLINT_TEST_INIT(state); @@ -40,7 +40,7 @@ main(void) flint_printf("compose_mod_brent_kung_precomp_preinv_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) /* check precomputation */ for (i = 0; i < 100 * flint_test_multiplier(); i++) { diff --git a/nmod_poly/test/t-compose_mod_brent_kung_vec_preinv_threaded.c b/nmod_poly/test/t-compose_mod_brent_kung_vec_preinv_threaded.c index 3fda4f4586..01d6163790 100644 --- a/nmod_poly/test/t-compose_mod_brent_kung_vec_preinv_threaded.c +++ b/nmod_poly/test/t-compose_mod_brent_kung_vec_preinv_threaded.c @@ -31,7 +31,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int i; slong max_threads = 5; #endif @@ -40,7 +40,7 @@ main(void) flint_printf("compose_mod_brent_kung_vec_preinv_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) for (i = 0; i < 20 * flint_test_multiplier(); i++) { diff --git a/nmod_poly/test/t-powers_mod_bsgs.c b/nmod_poly/test/t-powers_mod_bsgs.c index 6c2c576035..904c79e7a2 100644 --- a/nmod_poly/test/t-powers_mod_bsgs.c +++ b/nmod_poly/test/t-powers_mod_bsgs.c @@ -20,7 +20,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int i, result, max_threads = 5; #endif FLINT_TEST_INIT(state); @@ -28,7 +28,7 @@ main(void) flint_printf("powers_mod_bsgs...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) /* Compare with powmod */ for (i = 0; i < 100 * flint_test_multiplier(); i++) { diff --git a/nmod_poly_factor/test/t-factor_distinct_deg_threaded.c b/nmod_poly_factor/test/t-factor_distinct_deg_threaded.c index 0107aef887..bd30f7137a 100644 --- a/nmod_poly_factor/test/t-factor_distinct_deg_threaded.c +++ b/nmod_poly_factor/test/t-factor_distinct_deg_threaded.c @@ -24,7 +24,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int iter; #endif FLINT_TEST_INIT(state); @@ -32,7 +32,7 @@ main(void) flint_printf("factor_distinct_deg_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) for (iter = 0; iter < 20 * flint_test_multiplier(); iter++) { nmod_poly_t poly1, poly, q, r, product; diff --git a/nmod_poly_factor/test/t-interval_threaded.c b/nmod_poly_factor/test/t-interval_threaded.c index e21b5dece9..14606e17f3 100644 --- a/nmod_poly_factor/test/t-interval_threaded.c +++ b/nmod_poly_factor/test/t-interval_threaded.c @@ -30,7 +30,7 @@ int main(void) { -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) int iter; #endif FLINT_TEST_INIT(state); @@ -38,7 +38,7 @@ main(void) flint_printf("interval_threaded...."); fflush(stdout); -#if HAVE_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) +#if FLINT_USES_PTHREAD && (HAVE_TLS || FLINT_REENTRANT) for (iter = 0; iter < 20*flint_test_multiplier(); iter++) { nmod_poly_t a, b, c, cinv, d; diff --git a/qsieve.h b/qsieve.h index 654602f8cd..33c19c5288 100644 --- a/qsieve.h +++ b/qsieve.h @@ -91,7 +91,7 @@ typedef qs_poly_s qs_poly_t[1]; typedef struct qs_s { volatile slong index_j; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif thread_pool_handle * handles; diff --git a/qsieve/collect_relations.c b/qsieve/collect_relations.c index 4b4dc245cf..800809fbd5 100644 --- a/qsieve/collect_relations.c +++ b/qsieve/collect_relations.c @@ -369,14 +369,14 @@ slong qsieve_evaluate_candidate(qs_t qs_inf, ulong i, unsigned char * sieve, qs_ poly->num_factors = num_factors; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&qs_inf->mutex); #endif qsieve_write_to_file(qs_inf, 1, Y, poly); qs_inf->full_relation++; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&qs_inf->mutex); #endif relations++; @@ -413,7 +413,7 @@ slong qsieve_evaluate_candidate(qs_t qs_inf, ulong i, unsigned char * sieve, qs_ poly->num_factors = num_factors; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&qs_inf->mutex); #endif /* store this partial in file */ @@ -424,7 +424,7 @@ slong qsieve_evaluate_candidate(qs_t qs_inf, ulong i, unsigned char * sieve, qs_ qsieve_add_to_hashtable(qs_inf, prime); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&qs_inf->mutex); #endif @@ -509,7 +509,7 @@ static void qsieve_collect_relations_worker(void * varg) while (1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&qs_inf->mutex); #endif j = qs_inf->index_j; @@ -521,7 +521,7 @@ static void qsieve_collect_relations_worker(void * varg) qsieve_init_poly_next(qs_inf, j); qsieve_poly_copy(thread_poly, qs_inf); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&qs_inf->mutex); #endif diff --git a/qsieve/factor.c b/qsieve/factor.c index b2011ac5f8..d73a6f3d7f 100644 --- a/qsieve/factor.c +++ b/qsieve/factor.c @@ -198,7 +198,7 @@ void qsieve_factor(fmpz_factor_t factors, const fmpz_t n) sieve = flint_malloc((qs_inf->sieve_size + sizeof(ulong) + (qs_inf->num_handles > 0 ? 64 : 0))*(qs_inf->num_handles + 1)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&qs_inf->mutex, NULL); #endif @@ -438,7 +438,7 @@ void qsieve_factor(fmpz_factor_t factors, const fmpz_t n) flint_printf("\nCleanup\n"); #endif -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_destroy(&qs_inf->mutex); #endif diff --git a/thread_pool.h b/thread_pool.h index 18a06ec5aa..fb07337f63 100644 --- a/thread_pool.h +++ b/thread_pool.h @@ -22,7 +22,7 @@ #include "flint.h" -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD #include #endif @@ -32,7 +32,7 @@ typedef struct { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_t pth; pthread_mutex_t mutex; pthread_cond_t sleep1; @@ -51,10 +51,10 @@ typedef thread_pool_entry_struct thread_pool_entry_t[1]; typedef struct { -#if HAVE_CPU_SET_T && HAVE_PTHREAD +#if HAVE_CPU_SET_T && FLINT_USES_PTHREAD cpu_set_t original_affinity; #endif -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_t mutex; #endif thread_pool_entry_struct * tdata; diff --git a/thread_pool/clear.c b/thread_pool/clear.c index 87cf6c2086..875080f17f 100644 --- a/thread_pool/clear.c +++ b/thread_pool/clear.c @@ -17,7 +17,7 @@ void thread_pool_clear(thread_pool_t T) slong i, size; thread_pool_entry_struct * D; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&T->mutex); #endif D = T->tdata; @@ -25,13 +25,13 @@ void thread_pool_clear(thread_pool_t T) for (i = 0; i < size; i++) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&D[i].mutex); #endif /* all threads should be given back */ FLINT_ASSERT(D[i].available == 1); D[i].exit = 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_cond_signal(&D[i].sleep1); pthread_mutex_unlock(&D[i].mutex); pthread_join(D[i].pth, NULL); @@ -44,7 +44,7 @@ void thread_pool_clear(thread_pool_t T) { flint_free(D); } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&T->mutex); pthread_mutex_destroy(&T->mutex); #endif diff --git a/thread_pool/get_size.c b/thread_pool/get_size.c index c7944661af..1d2c16256d 100644 --- a/thread_pool/get_size.c +++ b/thread_pool/get_size.c @@ -15,11 +15,11 @@ slong thread_pool_get_size(thread_pool_t T) { slong ret; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&T->mutex); #endif ret = T->length; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&T->mutex); #endif return ret; diff --git a/thread_pool/give_back.c b/thread_pool/give_back.c index ef7bd4e431..cdf8bd12a1 100644 --- a/thread_pool/give_back.c +++ b/thread_pool/give_back.c @@ -16,12 +16,12 @@ void thread_pool_give_back(thread_pool_t T, thread_pool_handle i) { thread_pool_entry_struct * D; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&T->mutex); #endif D = T->tdata; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&D[i].mutex); #endif @@ -31,7 +31,7 @@ void thread_pool_give_back(thread_pool_t T, thread_pool_handle i) D[i].available = 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&D[i].mutex); pthread_mutex_unlock(&T->mutex); diff --git a/thread_pool/init.c b/thread_pool/init.c index 5fb2f226eb..3282eb8911 100644 --- a/thread_pool/init.c +++ b/thread_pool/init.c @@ -28,7 +28,7 @@ void * thread_pool_idle_loop(void * varg) thread_pool_Lock: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&arg->mutex); #endif arg->working = 0; @@ -38,7 +38,7 @@ void * thread_pool_idle_loop(void * varg) if (arg->exit != 0) goto thread_pool_Unlock; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_cond_signal(&arg->sleep2); pthread_cond_wait(&arg->sleep1, &arg->mutex); #endif @@ -48,7 +48,7 @@ void * thread_pool_idle_loop(void * varg) thread_pool_Unlock: -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&arg->mutex); #endif @@ -67,12 +67,12 @@ void thread_pool_init(thread_pool_t T, slong size) thread_pool_entry_struct * D; size = FLINT_MAX(size, WORD(0)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&T->mutex, NULL); #endif T->length = size; -#if HAVE_CPU_SET_T && HAVE_PTHREAD +#if HAVE_CPU_SET_T && FLINT_USES_PTHREAD if (0 != pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &T->original_affinity)) { @@ -92,7 +92,7 @@ void thread_pool_init(thread_pool_t T, slong size) for (i = 0; i < size; i++) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&D[i].mutex, NULL); pthread_cond_init(&D[i].sleep1, NULL); pthread_cond_init(&D[i].sleep2, NULL); @@ -104,7 +104,7 @@ void thread_pool_init(thread_pool_t T, slong size) D[i].working = -1; D[i].max_workers = 0; D[i].exit = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&D[i].mutex); pthread_create(&D[i].pth, NULL, thread_pool_idle_loop, &D[i]); while (D[i].working != 0) diff --git a/thread_pool/request.c b/thread_pool/request.c index 8ac16d7f61..9f127cea88 100644 --- a/thread_pool/request.c +++ b/thread_pool/request.c @@ -21,7 +21,7 @@ slong thread_pool_request(thread_pool_t T, thread_pool_handle * out, if (requested <= 0) return 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&T->mutex); #endif @@ -41,7 +41,7 @@ slong thread_pool_request(thread_pool_t T, thread_pool_handle * out, } } -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&T->mutex); #endif diff --git a/thread_pool/restore_affinity.c b/thread_pool/restore_affinity.c index c56f822bf0..9cdeca515e 100644 --- a/thread_pool/restore_affinity.c +++ b/thread_pool/restore_affinity.c @@ -13,7 +13,7 @@ int thread_pool_restore_affinity(thread_pool_t T) { -#if HAVE_CPU_SET_T && HAVE_PTHREAD +#if HAVE_CPU_SET_T && FLINT_USES_PTHREAD slong i; int errorno; thread_pool_entry_struct * D; diff --git a/thread_pool/set_affinity.c b/thread_pool/set_affinity.c index 0e0ad9039b..3bd87c1570 100644 --- a/thread_pool/set_affinity.c +++ b/thread_pool/set_affinity.c @@ -17,7 +17,7 @@ */ int thread_pool_set_affinity(thread_pool_t T, int * cpus, slong length) { -#if HAVE_CPU_SET_T && HAVE_PTHREAD +#if HAVE_CPU_SET_T && FLINT_USES_PTHREAD slong i; int errorno; cpu_set_t mask; diff --git a/thread_pool/set_size.c b/thread_pool/set_size.c index 35e7f88e41..27d60f0770 100644 --- a/thread_pool/set_size.c +++ b/thread_pool/set_size.c @@ -19,7 +19,7 @@ int thread_pool_set_size(thread_pool_t T, slong new_size) new_size = FLINT_MAX(new_size, WORD(0)); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&T->mutex); #endif D = T->tdata; @@ -30,7 +30,7 @@ int thread_pool_set_size(thread_pool_t T, slong new_size) { if (D[i].available != 1) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&T->mutex); #endif return 0; @@ -40,11 +40,11 @@ int thread_pool_set_size(thread_pool_t T, slong new_size) /* destroy all old data */ for (i = 0; i < old_size; i++) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&D[i].mutex); #endif D[i].exit = 1; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_cond_signal(&D[i].sleep1); pthread_mutex_unlock(&D[i].mutex); pthread_join(D[i].pth, NULL); @@ -68,7 +68,7 @@ int thread_pool_set_size(thread_pool_t T, slong new_size) for (i = 0; i < new_size; i++) { -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_init(&D[i].mutex, NULL); pthread_cond_init(&D[i].sleep1, NULL); pthread_cond_init(&D[i].sleep2, NULL); @@ -79,7 +79,7 @@ int thread_pool_set_size(thread_pool_t T, slong new_size) D[i].fxnarg = NULL; D[i].working = -1; D[i].exit = 0; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&D[i].mutex); pthread_create(&D[i].pth, NULL, thread_pool_idle_loop, &D[i]); while (D[i].working != 0) @@ -91,7 +91,7 @@ int thread_pool_set_size(thread_pool_t T, slong new_size) T->length = new_size; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_unlock(&T->mutex); #endif return 1; diff --git a/thread_pool/wait.c b/thread_pool/wait.c index 15bbf8bfcc..38a26a4bba 100644 --- a/thread_pool/wait.c +++ b/thread_pool/wait.c @@ -18,14 +18,14 @@ void thread_pool_wait(thread_pool_t T, thread_pool_handle i) D = T->tdata; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&D[i].mutex); #endif /* should not be trying to wait on a available thread */ FLINT_ASSERT(D[i].available == 0); -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD while (D[i].working != 0) pthread_cond_wait(&D[i].sleep2, &D[i].mutex); diff --git a/thread_pool/wake.c b/thread_pool/wake.c index 70bef003b0..2818834341 100644 --- a/thread_pool/wake.c +++ b/thread_pool/wake.c @@ -17,7 +17,7 @@ void thread_pool_wake(thread_pool_t T, thread_pool_handle i, { thread_pool_entry_struct * D; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&T->mutex); #endif @@ -25,7 +25,7 @@ void thread_pool_wake(thread_pool_t T, thread_pool_handle i, D = T->tdata; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_mutex_lock(&D[i].mutex); #endif @@ -36,7 +36,7 @@ void thread_pool_wake(thread_pool_t T, thread_pool_handle i, D[i].working = 1; D[i].fxn = f; D[i].fxnarg = a; -#if HAVE_PTHREAD +#if FLINT_USES_PTHREAD pthread_cond_signal(&D[i].sleep1); pthread_mutex_unlock(&D[i].mutex); diff --git a/thread_support.c b/thread_support.c index 176a3e11ef..70b9468a5e 100644 --- a/thread_support.c +++ b/thread_support.c @@ -24,7 +24,7 @@ int flint_get_num_threads() void flint_set_num_threads(int num_threads) { -#if !HAVE_PTHREAD +#if !FLINT_USES_PTHREAD num_threads = 1; #endif _flint_num_workers = num_threads - 1; @@ -52,7 +52,7 @@ int flint_set_num_workers(int num_workers) { int old_num_workers; -#if !HAVE_PTHREAD +#if !FLINT_USES_PTHREAD num_workers = 0; #endif