Skip to content

Commit 1ba4a60

Browse files
committed
Configure options reorganization
1 parent 3c0f246 commit 1ba4a60

File tree

4 files changed

+72
-51
lines changed

4 files changed

+72
-51
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ install:
88
- if [ -n "$EXTRAPACKAGES" ]; then sudo apt-get update && sudo apt-get install --no-install-recommends --no-upgrade $EXTRAPACKAGES; fi
99
env:
1010
global:
11-
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no BUILD=check EXTRAFLAGS= HOST= EXTRAPACKAGES=
11+
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no ASM=no BUILD=check EXTRAFLAGS= HOST= EXTRAPACKAGES=
1212
matrix:
1313
- SCALAR=32bit
1414
- SCALAR=64bit
1515
- FIELD=gmp
1616
- FIELD=gmp ENDOMORPHISM=yes
17-
- FIELD=64bit_asm
18-
- FIELD=64bit_asm ENDOMORPHISM=yes
1917
- FIELD=64bit
2018
- FIELD=64bit ENDOMORPHISM=yes
19+
- FIELD=64bit ASM=x86_64
20+
- FIELD=64bit ENDOMORPHISM=yes ASM=x86_64
2121
- FIELD=32bit
2222
- FIELD=32bit ENDOMORPHISM=yes
23-
- BIGNUM=none
24-
- BIGNUM=none ENDOMORPHISM=yes
23+
- BIGNUM=no
24+
- BIGNUM=no ENDOMORPHISM=yes
2525
- BUILD=distcheck
2626
- EXTRAFLAGS=CFLAGS=-DDETERMINISTIC
2727
- HOST=i686-linux-gnu EXTRAPACKAGES="gcc-multilib"

build-aux/m4/bitcoin_secp.m4

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
dnl libsecp25k1 helper checks
22
AC_DEFUN([SECP_INT128_CHECK],[
33
has_int128=$ac_cv_type___int128
4-
if test x"$has_int128" != x"yes" && test x"$set_field" = x"64bit"; then
5-
AC_MSG_ERROR([$set_field field support explicitly requested but is not compatible with this host])
6-
fi
7-
if test x"$has_int128" != x"yes" && test x"$set_scalar" = x"64bit"; then
8-
AC_MSG_ERROR([$set_scalar scalar support explicitly requested but is not compatible with this host])
9-
fi
104
])
115

126
dnl
@@ -18,11 +12,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1812
__asm__ __volatile__("movq $0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
1913
]])],[has_64bit_asm=yes],[has_64bit_asm=no])
2014
AC_MSG_RESULT([$has_64bit_asm])
21-
if test x"$set_field" = x"64bit_asm"; then
22-
if test x"$has_64bit_asm" = x"no"; then
23-
AC_MSG_ERROR([$set_field field support explicitly requested but no x86_64 assembly available])
24-
fi
25-
fi
2615
])
2716

2817
dnl
@@ -69,11 +58,4 @@ if test x"$has_gmp" != x"yes"; then
6958
CPPFLAGS="$CPPFLAGS_TEMP"
7059
LIBS="$LIBS_TEMP"
7160
fi
72-
if test x"$set_field" = x"gmp" && test x"$has_gmp" != x"yes"; then
73-
AC_MSG_ERROR([$set_field field support explicitly requested but libgmp was not found])
74-
fi
75-
if test x"$set_bignum" = x"gmp" && test x"$has_gmp" != x"yes"; then
76-
AC_MSG_ERROR([$set_bignum field support explicitly requested but libgmp was not found])
77-
fi
7861
])
79-

configure.ac

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,18 @@ AC_ARG_ENABLE(endomorphism,
9696
[use_endomorphism=$enableval],
9797
[use_endomorphism=no])
9898

99-
AC_ARG_WITH([field], [AS_HELP_STRING([--with-field=gmp|64bit|64bit_asm|32bit|auto],
99+
AC_ARG_WITH([field], [AS_HELP_STRING([--with-field=gmp|64bit|32bit|auto],
100100
[Specify Field Implementation. Default is auto])],[req_field=$withval], [req_field=auto])
101101

102-
AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|none|auto],
102+
AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|no|auto],
103103
[Specify Bignum Implementation. Default is auto])],[req_bignum=$withval], [req_bignum=auto])
104104

105105
AC_ARG_WITH([scalar], [AS_HELP_STRING([--with-scalar=64bit|32bit|auto],
106106
[Specify scalar implementation. Default is auto])],[req_scalar=$withval], [req_scalar=auto])
107107

108+
AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|no|auto]
109+
[Specify assembly optimizations to use. Default is auto])],[req_asm=$withval], [req_asm=auto])
110+
108111
AC_CHECK_TYPES([__int128])
109112

110113
AC_MSG_CHECKING([for __builtin_expect])
@@ -113,40 +116,66 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])],
113116
[ AC_MSG_RESULT([no])
114117
])
115118

116-
if test x"$req_field" = x"auto"; then
119+
if test x"$req_asm" = x"auto"; then
117120
SECP_64BIT_ASM_CHECK
118121
if test x"$has_64bit_asm" = x"yes"; then
119-
set_field=64bit_asm
122+
set_asm=x86_64
123+
fi
124+
if test x"$set_asm" = x; then
125+
set_asm=no
120126
fi
127+
else
128+
set_asm=$req_asm
129+
case $set_asm in
130+
x86_64)
131+
SECP_64BIT_ASM_CHECK
132+
if test x"$has_64bit_asm" != x"yes"; then
133+
AC_MSG_ERROR([x86_64 assembly optimization requested but not available])
134+
fi
135+
;;
136+
no)
137+
;;
138+
*)
139+
AC_MSG_ERROR([invalid assembly optimization selection])
140+
;;
141+
esac
142+
fi
121143

144+
if test x"$req_field" = x"auto"; then
145+
if test x"set_asm" = x"x86_64"; then
146+
set_field=64bit
147+
fi
122148
if test x"$set_field" = x; then
123149
SECP_INT128_CHECK
124150
if test x"$has_int128" = x"yes"; then
125151
set_field=64bit
126152
fi
127153
fi
128-
129154
if test x"$set_field" = x; then
130155
SECP_GMP_CHECK
131156
if test x"$has_gmp" = x"yes"; then
132157
set_field=gmp
133158
fi
134159
fi
135-
136160
if test x"$set_field" = x; then
137161
set_field=32bit
138162
fi
139163
else
140164
set_field=$req_field
141165
case $set_field in
142-
64bit_asm)
143-
SECP_64BIT_ASM_CHECK
144-
;;
145166
64bit)
146-
SECP_INT128_CHECK
167+
if test x"$set_asm" != x"x86_64"; then
168+
SECP_INT128_CHECK
169+
if test x"$has_int128" != x"yes"; then
170+
AC_MSG_ERROR([64bit field explicitly requested but neither __int128 support or x86_64 assembly available])
171+
fi
172+
fi
147173
;;
148174
gmp)
149175
SECP_GMP_CHECK
176+
if test x"$has_gmp" != x"yes"; then
177+
AC_MSG_ERROR([gmp field explicitly requested but libgmp not available])
178+
fi
150179
;;
151180
32bit)
152181
;;
@@ -157,11 +186,9 @@ else
157186
fi
158187

159188
if test x"$req_scalar" = x"auto"; then
160-
if test x"$set_scalar" = x; then
161-
SECP_INT128_CHECK
162-
if test x"$has_int128" = x"yes"; then
163-
set_scalar=64bit
164-
fi
189+
SECP_INT128_CHECK
190+
if test x"$has_int128" = x"yes"; then
191+
set_scalar=64bit
165192
fi
166193
if test x"$set_scalar" = x; then
167194
set_scalar=32bit
@@ -171,6 +198,9 @@ else
171198
case $set_scalar in
172199
64bit)
173200
SECP_INT128_CHECK
201+
if test x"$has_int128" != x"yes"; then
202+
AC_MSG_ERROR([64bit scalar explicitly requested but __int128 support not available])
203+
fi
174204
;;
175205
32bit)
176206
;;
@@ -187,30 +217,40 @@ if test x"$req_bignum" = x"auto"; then
187217
fi
188218

189219
if test x"$set_bignum" = x; then
190-
set_bignum=none
220+
set_bignum=no
191221
fi
192222
else
193223
set_bignum=$req_bignum
194224
case $set_bignum in
195225
gmp)
196226
SECP_GMP_CHECK
227+
if test x"$has_gmp" != x"yes"; then
228+
AC_MSG_ERROR([gmp bignum explicitly requested but libgmp not available])
229+
fi
197230
;;
198-
none)
231+
no)
199232
;;
200233
*)
201234
AC_MSG_ERROR([invalid bignum implementation selection])
202235
;;
203236
esac
204237
fi
205238

239+
# select assembly optimization
240+
case $set_asm in
241+
x86_64)
242+
AC_DEFINE(USE_ASM_X86_64, 1, [Define this symbol to enable x86_64 assembly optimizations])
243+
;;
244+
no)
245+
;;
246+
*)
247+
AC_MSG_ERROR([invalid assembly optimizations])
248+
;;
249+
esac
250+
206251
# select field implementation
207252
case $set_field in
208-
64bit_asm)
209-
AC_DEFINE(USE_FIELD_5X52_ASM, 1, [Define this symbol to use the assembly version for the 5x52 field implementation])
210-
AC_DEFINE(USE_FIELD_5X52, 1, [Define this symbol to use the FIELD_5X52 implementation])
211-
;;
212253
64bit)
213-
AC_DEFINE(USE_FIELD_5X52_INT128, 1, [Define this symbol to use the __int128 version for the 5x52 field implementation])
214254
AC_DEFINE(USE_FIELD_5X52, 1, [Define this symbol to use the FIELD_5X52 implementation])
215255
;;
216256
gmp)
@@ -233,7 +273,7 @@ gmp)
233273
AC_DEFINE(USE_FIELD_INV_NUM, 1, [Define this symbol to use the num-based field inverse implementation])
234274
AC_DEFINE(USE_SCALAR_INV_NUM, 1, [Define this symbol to use the num-based scalar inverse implementation])
235275
;;
236-
none)
276+
no)
237277
AC_DEFINE(USE_NUM_NONE, 1, [Define this symbol to use no num implementation])
238278
AC_DEFINE(USE_FIELD_INV_BUILTIN, 1, [Define this symbol to use the native field inverse implementation])
239279
AC_DEFINE(USE_SCALAR_INV_BUILTIN, 1, [Define this symbol to use the native scalar inverse implementation])
@@ -281,17 +321,18 @@ if test x"$use_endomorphism" = x"yes"; then
281321
AC_DEFINE(USE_ENDOMORPHISM, 1, [Define this symbol to use endomorphism optimization])
282322
fi
283323

324+
AC_MSG_NOTICE([Using assembly optimizations: $set_asm])
284325
AC_MSG_NOTICE([Using field implementation: $set_field])
285326
AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
286327
AC_MSG_NOTICE([Using scalar implementation: $set_scalar])
328+
AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism])
287329

288330
AC_CONFIG_HEADERS([src/libsecp256k1-config.h])
289331
AC_CONFIG_FILES([Makefile libsecp256k1.pc])
290332
AC_SUBST(SECP_INCLUDES)
291333
AC_SUBST(SECP_LIBS)
292334
AC_SUBST(SECP_TEST_LIBS)
293335
AC_SUBST(SECP_TEST_INCLUDES)
294-
AM_CONDITIONAL([USE_ASM], [test x"$set_field" = x"64bit_asm"])
295336
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
296337
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
297338

src/field_5x52_impl.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
#include "num.h"
1717
#include "field.h"
1818

19-
#if defined(USE_FIELD_5X52_ASM)
19+
#if defined(USE_ASM_X86_64)
2020
#include "field_5x52_asm_impl.h"
21-
#elif defined(USE_FIELD_5X52_INT128)
22-
#include "field_5x52_int128_impl.h"
2321
#else
24-
#error "Please select field_5x52 implementation"
22+
#include "field_5x52_int128_impl.h"
2523
#endif
2624

2725
/** Implements arithmetic modulo FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F,

0 commit comments

Comments
 (0)