Skip to content

Commit

Permalink
build: rename HAVE_PTHREAD to FLINT_USES_PTHREAD
Browse files Browse the repository at this point in the history
A library such as flint should always try to namespace its own
defines somehow, lest flint's defines could interfere or override a
macro of the same name in a project that happens to use HAVE_* macros
of its own.

HAVE_PTHREAD's value influences the ABI of e.g. fmpz_block_header_s,
so the macro does not just describe a system property at the time of
building, but also the state of a built-and-installed libflint, so to
that end, I renamed HAVE_PTHREAD to FLINT_USES_PTHREAD.
  • Loading branch information
jengelh committed Sep 23, 2020
1 parent 95ed3f0 commit e0aa3bf
Show file tree
Hide file tree
Showing 55 changed files with 306 additions and 306 deletions.
2 changes: 1 addition & 1 deletion config.h.in
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion configure
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions fft/fft_mfa_truncate_sqrt2.c
Expand Up @@ -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
}
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand All @@ -385,7 +385,7 @@ void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n,

while ((UWORD(1)<<depth) < n2) depth++;

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_init(&mutex, NULL);
#endif

Expand Down Expand Up @@ -413,7 +413,7 @@ void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n,
args[i].t1 = t1 + i;
args[i].t2 = t2 + i;
args[i].temp = temp[i];
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
args[i].mutex = &mutex;
#endif
}
Expand Down Expand Up @@ -454,7 +454,7 @@ void fft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n,

flint_free(args);

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_destroy(&mutex);
#endif
}
18 changes: 9 additions & 9 deletions fft/fft_mfa_truncate_sqrt2_inner.c
Expand Up @@ -29,7 +29,7 @@ typedef struct
mp_limb_t ** t1;
mp_limb_t ** t2;
mp_limb_t * tt;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_t * mutex;
#endif
}
Expand All @@ -55,12 +55,12 @@ _fft_inner1_worker(void * arg_ptr)

while (1)
{
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_lock(arg.mutex);
#endif
s = *arg.i;
end = *arg.i = FLINT_MIN(s + 16, trunc);
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_unlock(arg.mutex);
#endif

Expand Down Expand Up @@ -104,12 +104,12 @@ _fft_inner2_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, n2);
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_unlock(arg.mutex);
#endif

Expand Down Expand Up @@ -143,7 +143,7 @@ void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, 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;
Expand All @@ -152,7 +152,7 @@ void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, mp_size_t n,

while ((UWORD(1)<<depth) < n2) depth++;

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_init(&mutex, NULL);
#endif

Expand Down Expand Up @@ -182,7 +182,7 @@ void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, mp_size_t n,
args[i].t1 = t1 + i;
args[i].t2 = t2 + i;
args[i].tt = tt[i];
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
args[i].mutex = &mutex;
#endif
}
Expand Down Expand Up @@ -222,7 +222,7 @@ void fft_mfa_truncate_sqrt2_inner(mp_limb_t ** ii, mp_limb_t ** jj, mp_size_t n,

flint_free(args);

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_destroy(&mutex);
#endif
}
Expand Down
18 changes: 9 additions & 9 deletions fft/ifft_mfa_truncate_sqrt2.c
Expand Up @@ -261,7 +261,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
}
Expand All @@ -282,12 +282,12 @@ _ifft_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

Expand Down Expand Up @@ -332,12 +332,12 @@ _ifft_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

Expand Down Expand Up @@ -424,7 +424,7 @@ void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t
flint_bitcnt_t depth = 0;
flint_bitcnt_t depth2 = 0;
flint_bitcnt_t limbs = (w*n)/FLINT_BITS;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_t mutex;
#endif
slong num_threads;
Expand All @@ -434,7 +434,7 @@ void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t
while ((UWORD(1)<<depth) < n2) depth++;
while ((UWORD(1)<<depth2) < n1) depth2++;

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_init(&mutex, NULL);
#endif

Expand Down Expand Up @@ -464,7 +464,7 @@ void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t
args[i].t1 = t1 + i;
args[i].t2 = t2 + i;
args[i].temp = temp[i];
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
args[i].mutex = &mutex;
#endif
}
Expand Down Expand Up @@ -503,7 +503,7 @@ void ifft_mfa_truncate_sqrt2_outer(mp_limb_t ** ii, mp_size_t n, flint_bitcnt_t

flint_free(args);

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_destroy(&mutex);
#endif
}
28 changes: 14 additions & 14 deletions fft/split_bits.c
Expand Up @@ -22,7 +22,7 @@ typedef struct
mp_size_t output_limbs;
mp_srcptr limbs;
mp_limb_t ** poly;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_t * mutex;
#endif
}
Expand All @@ -42,12 +42,12 @@ _split_limbs_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, num);
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_unlock(arg.mutex);
#endif

Expand All @@ -69,14 +69,14 @@ mp_size_t fft_split_limbs(mp_limb_t ** poly, mp_srcptr limbs,
{
mp_size_t i, shared_i = 0, skip, length = (total_limbs - 1)/coeff_limbs + 1;
mp_size_t num = total_limbs/coeff_limbs;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_t mutex;
#endif
slong num_threads;
thread_pool_handle * threads;
split_limbs_arg_t * args;

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_init(&mutex, NULL);
#endif

Expand All @@ -94,7 +94,7 @@ mp_size_t fft_split_limbs(mp_limb_t ** poly, mp_srcptr limbs,
args[i].output_limbs = output_limbs;
args[i].limbs = limbs;
args[i].poly = poly;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
args[i].mutex = &mutex;
#endif
}
Expand All @@ -112,7 +112,7 @@ mp_size_t fft_split_limbs(mp_limb_t ** poly, mp_srcptr limbs,

flint_free(args);

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_destroy(&mutex);
#endif

Expand All @@ -138,7 +138,7 @@ typedef struct
flint_bitcnt_t top_bits;
mp_limb_t mask;
mp_limb_t ** poly;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_t * mutex;
#endif
}
Expand All @@ -161,12 +161,12 @@ _split_bits_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, length - 1);
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_unlock(arg.mutex);
#endif

Expand Down Expand Up @@ -214,7 +214,7 @@ mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs,
flint_bitcnt_t shift_bits, top_bits = ((FLINT_BITS - 1) & bits);
mp_srcptr limb_ptr;
mp_limb_t mask;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_t mutex;
#endif
slong num_threads;
Expand All @@ -229,7 +229,7 @@ mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs,
shift_bits = WORD(0);
limb_ptr = limbs;

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_init(&mutex, NULL);
#endif

Expand All @@ -249,7 +249,7 @@ mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs,
args[i].top_bits = top_bits;
args[i].mask = mask;
args[i].poly = poly;
#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
args[i].mutex = &mutex;
#endif
}
Expand All @@ -267,7 +267,7 @@ mp_size_t fft_split_bits(mp_limb_t ** poly, mp_srcptr limbs,

flint_free(args);

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
pthread_mutex_destroy(&mutex);
#endif

Expand Down
4 changes: 2 additions & 2 deletions fmpz.h
Expand Up @@ -31,7 +31,7 @@
#include "nmod_vec.h"
#include "fmpz-conversions.h"

#if HAVE_PTHREAD
#if FLINT_USES_PTHREAD
#include <pthread.h>
#endif

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e0aa3bf

Please sign in to comment.