gmp-6.1.0/000775 001756 001756 00000000000 12615427033 013450 5ustar00bodratobodrato000000 000000 gmp-6.1.0/config.guess000775 001756 001756 00000104351 12615426624 016001 0ustar00bodratobodrato000000 000000 #! /bin/sh # # GMP config.guess wrapper. # Copyright 2000-2006, 2008, 2011-2015 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # # The GNU MP Library is free software; you can redistribute it and/or modify # it under the terms of either: # # * the GNU Lesser General Public License as published by the Free # Software Foundation; either version 3 of the License, or (at your # option) any later version. # # or # # * the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any # later version. # # or both in parallel, as here. # # The GNU MP Library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received copies of the GNU General Public License and the # GNU Lesser General Public License along with the GNU MP Library. If not, # see https://www.gnu.org/licenses/. # Usage: config.guess # # Print the host system CPU-VENDOR-OS. # # configfsf.guess is run and its guess then sharpened up to take advantage # of the finer grained CPU types that GMP knows. # Expect to find configfsf.guess in the same directory as this config.guess configfsf_guess="`echo \"$0\" | sed 's/config.guess$/configfsf.guess/'`" if test "$configfsf_guess" = "$0"; then echo "Cannot derive configfsf.guess from $0" 1>&2 exit 1 fi if test -f "$configfsf_guess"; then : else echo "$configfsf_guess not found" 1>&2 exit 1 fi # Setup a $SHELL with which to run configfsf.guess, using the same # $CONFIG_SHELL or /bin/sh as autoconf does when running config.guess SHELL=${CONFIG_SHELL-/bin/sh} # Identify ourselves on --version, --help or errors if test $# != 0; then echo "(GNU MP wrapped config.guess)" $SHELL $configfsf_guess "$@" exit 1 fi guess_full=`$SHELL $configfsf_guess` if test $? != 0; then exit 1 fi guess_cpu=`echo "$guess_full" | sed 's/-.*$//'` guess_rest=`echo "$guess_full" | sed 's/^[^-]*//'` exact_cpu= # ------------------------------------------------------------------------- # The following should look at the current guess and probe the system to # establish a better guess in exact_cpu. Leave exact_cpu empty if probes # can't be done, or don't work. # # When a number of probes are done, test -z "$exact_cpu" can be used instead # of putting each probe under an "else" of the preceeding. That can stop # the code getting horribly nested and marching off the right side of the # screen. # Note that when a compile-and-link is done in one step we need to remove .o # files, since lame C compilers generate these even when not asked. # # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy $dummy.core ${dummy}0.s" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' case "$guess_full" in alpha-*-*) eval $set_cc_for_build # configfsf.guess detects exact alpha cpu types for OSF and GNU/Linux, but # not for *BSD and other systems. We try to get an exact type for any # plain "alpha" it leaves. # # configfsf.guess used to have a block of code not unlike this, but these # days does its thing with Linux kernel /proc/cpuinfo or OSF psrinfo. # cat <${dummy}0.s .data Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d91 # implver \$17 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,Lformat not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF $CC_FOR_BUILD ${dummy}0.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `$dummy` in 0-0) exact_cpu=alpha ;; 1-0) exact_cpu=alphaev5 ;; 1-1) exact_cpu=alphaev56 ;; 1-101) exact_cpu=alphapca56 ;; 2-303) exact_cpu=alphaev6 ;; 2-307) exact_cpu=alphaev67 ;; 2-1307) exact_cpu=alphaev68 ;; esac fi ;; arm*-*-*) cpu_code=`sed -n 's/^CPU part.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null | head -n 1 2>/dev/null` case "$cpu_code" in 0xa10 | 0xa11 | 0xb11) # v4 strongarm/sa1100 exact_cpu="armsa1";; 0x915 | 0x925 | \ 0x920 | 0x922 | 0x940) # v4 exact_cpu="arm9tdmi";; 0x210 | 0x290 | 0x2d0 | \ 0x212 | 0x292 | 0x2d2 | \ 0x411) exact_cpu="armxscale";; # v5 pxa2xx 0x926 | 0x946 | 0x966 | 0x968) # v5te/v5tej exact_cpu="arm9te";; 0xa20 | 0xa22 | 0xa26) # v5te exact_cpu="arm10";; 0xb02) exact_cpu="arm11mpcore";; # v6 0xb36) exact_cpu="arm1136";; # v6 0xb56) exact_cpu="arm1156";; # v6t2 0xb76) exact_cpu="arm1176";; # v6 0xc05) exact_cpu="armcortexa5";; # v7a 0xc07) exact_cpu="armcortexa7";; # v7a 0xc08) exact_cpu="armcortexa8";; # v7a 0xc09) exact_cpu="armcortexa9";; # v7a 0xc0f) exact_cpu="armcortexa15";; # v7a 0xc14) exact_cpu="armcortexr4";; # v7r 0xc15) exact_cpu="armcortexr5";; # v7r 0xc23) exact_cpu="armcortexm3";; # v7m *) exact_cpu=$guess_cpu;; esac exact_cpu="${exact_cpu}`sed -n 's;^Features.*\(neon\).*;\1;p' /proc/cpuinfo 2>/dev/null | head -n 1 2>/dev/null`" ;; ia64*-*-*) eval $set_cc_for_build # CPUID[3] bits 24 to 31 is the processor family. itanium2 is documented # as 0x1f, plain itanium has been seen returning 0x07 on two systems, but # haven't found any documentation on it as such. # # Defining both getcpuid and _getcpuid lets us ignore whether the system # expects underscores or not. # # "unsigned long long" is always 64 bits, in fact on hpux in ilp32 mode # (which is the default there), it's the only 64-bit type. # cat >${dummy}0.s <$dummy.c < unsigned long long getcpuid (); int main () { if (getcpuid(0LL) == 0x49656E69756E6547LL && getcpuid(1LL) == 0x6C65746ELL) { /* "GenuineIntel" */ switch ((getcpuid(3LL) >> 24) & 0xFF) { case 0x07: puts ("itanium"); break; case 0x1F: puts ("itanium2"); break; /* McKinley, Madison */ case 0x20: puts ("itanium2"); break; /* Montecito */ } } return 0; } EOF if $CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy >/dev/null 2>&1; then exact_cpu=`$dummy` fi ;; mips-*-irix[6789]*) # IRIX 6 and up always has a 64-bit mips cpu exact_cpu=mips64 ;; m68k-*-*) eval $set_cc_for_build # NetBSD (and presumably other *BSD) "sysctl hw.model" gives for example # hw.model = Apple Macintosh Quadra 610 (68040) exact_cpu=`(sysctl hw.model) 2>/dev/null | sed -n 's/^.*\(680[012346]0\).*$/m\1/p'` if test -z "$exact_cpu"; then # Linux kernel 2.2 gives for example "CPU: 68020" (tabs in between). exact_cpu=`sed -n 's/^CPU:.*\(680[012346]0\).*$/m\1/p' /proc/cpuinfo 2>/dev/null` fi if test -z "$exact_cpu"; then # Try: movel #0,%d0; rts # This is to check the compiler and our asm code works etc, before # assuming failures below indicate cpu characteristics. # .byte is used to avoid problems with assembler syntax variations. # For testing, provoke failures by adding "illegal" possibly as # ".byte 0x4A, 0xFC" cat >${dummy}0.s </dev/null 2>&1; then # $SHELL -c is used to execute $dummy below, since ($dummy) # 2>/dev/null still prints the SIGILL message on some shells. # # Try: movel #0,%d0 # rtd #0 cat >${dummy}0.s </dev/null 2>&1; then $SHELL -c $dummy >/dev/null 2>&1 if test $? != 0; then exact_cpu=m68000 # because rtd didn't work fi fi # if test -z "$exact_cpu"; then # Try: trapf # movel #0,%d0 # rts # Another possibility for identifying 68000 and 68010 is the # different value stored by "movem a0,(a0)+" cat >${dummy}0.s </dev/null 2>&1; then $SHELL -c $dummy >/dev/null 2>&1 if test $? != 0; then exact_cpu=m68010 # because trapf didn't work fi fi fi if test -z "$exact_cpu"; then # Try: bfffo %d1{0:31},%d0 # movel #0,%d0 # rts cat >${dummy}0.s </dev/null 2>&1; then $SHELL -c $dummy >/dev/null 2>&1 if test $? != 0; then exact_cpu=m68360 # cpu32, because bfffo didn't work fi fi fi if test -z "$exact_cpu"; then # FIXME: Now we know 68020 or up, but how to detect 030, 040 and 060? exact_cpu=m68020 fi fi fi if test -z "$exact_cpu"; then case "$guess_full" in *-*-next* | *-*-openstep*) # NeXTs are 68020 or better exact_cpu=m68020 ;; esac fi ;; rs6000-*-* | powerpc*-*-*) # Enhancement: On MacOS the "machine" command prints for instance # "ppc750". Interestingly on powerpc970-apple-darwin6.8.5 it prints # "ppc970" where there's no actual #define for 970 from NXGetLocalArchInfo # (as noted below). But the man page says the command is still "under # development", so it doesn't seem wise to use it just yet, not while # there's an alternative. # # Try to read the PVR. mfpvr is a protected instruction, NetBSD, MacOS # and AIX don't allow it in user mode, but the Linux kernel does. # # Using explicit bytes for mfpvr avoids worrying about assembler syntax # and underscores. "char"s are used instead of "int"s to avoid worrying # whether sizeof(int)==4 or if it's the right endianness. # # Note this is no good on AIX, since a C function there is the address of # a function descriptor, not actual code. But this doesn't matter since # AIX doesn't allow mfpvr anyway. # eval $set_cc_for_build cat >$dummy.c <<\EOF #include struct { int n; /* force 4-byte alignment */ char a[8]; } getpvr = { 0, { 0x7c, 0x7f, 0x42, 0xa6, /* mfpvr r3 */ 0x4e, 0x80, 0x00, 0x20, /* blr */ } }; int main () { unsigned (*fun)(); unsigned pvr; /* a separate "fun" variable is necessary for gcc 2.95.2 on MacOS, it gets a compiler error on a combined cast and call */ fun = (unsigned (*)()) getpvr.a; pvr = (*fun) (); switch (pvr >> 16) { case 0x0001: puts ("powerpc601"); break; case 0x0003: puts ("powerpc603"); break; case 0x0004: puts ("powerpc604"); break; case 0x0006: puts ("powerpc603e"); break; case 0x0007: puts ("powerpc603e"); break; /* 603ev */ case 0x0008: puts ("powerpc750"); break; case 0x0009: puts ("powerpc604e"); break; case 0x000a: puts ("powerpc604e"); break; /* 604ev5 */ case 0x000c: puts ("powerpc7400"); break; case 0x0041: puts ("powerpc630"); break; case 0x0050: puts ("powerpc860"); break; case 0x8000: puts ("powerpc7450"); break; case 0x8001: puts ("powerpc7455"); break; case 0x8002: puts ("powerpc7457"); break; case 0x8003: puts ("powerpc7447"); break; /* really 7447A */ case 0x800c: puts ("powerpc7410"); break; } return 0; } EOF if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then # This style construct is needed on AIX 4.3 to suppress the SIGILL error # from (*fun)(). Using $SHELL -c $dummy 2>/dev/null doesn't work. { x=`$dummy`; } 2>/dev/null if test -n "$x"; then exact_cpu=$x fi fi # Grep the linux kernel /proc/cpuinfo pseudo-file. # Anything unrecognised is ignored, since of course we mustn't spit out # a cpu type config.sub doesn't know. if test -z "$exact_cpu" && test -f /proc/cpuinfo; then x=`grep "^cpu[ ]" /proc/cpuinfo | head -n 1` x=`echo $x | sed -n 's/^cpu[ ]*:[ ]*\([A-Za-z0-9]*\).*/\1/p'` x=`echo $x | sed 's/PPC//'` case $x in 601) exact_cpu="power" ;; 603ev) exact_cpu="powerpc603e" ;; 604ev5) exact_cpu="powerpc604e" ;; 970??) exact_cpu="powerpc970" ;; 603 | 603e | 604 | 604e | 750 | 821 | 860) exact_cpu="powerpc$x" ;; POWER[4-9]*) exact_cpu=`echo $x | sed -e "s;POWER;power;" -e "s;[a-zA-Z]*$;;"` ;; esac fi if test -z "$exact_cpu"; then # On AIX, try looking at _system_configuration. This is present in # version 4 at least. cat >$dummy.c < #include int main () { switch (_system_configuration.implementation) { /* Old versions of AIX don't have all these constants, use ifdef for safety. */ #ifdef POWER_RS2 case POWER_RS2: puts ("power2"); break; #endif #ifdef POWER_601 case POWER_601: puts ("power"); break; #endif #ifdef POWER_603 case POWER_603: puts ("powerpc603"); break; #endif #ifdef POWER_604 case POWER_604: puts ("powerpc604"); break; #endif #ifdef POWER_620 case POWER_620: puts ("powerpc620"); break; #endif #ifdef POWER_630 case POWER_630: puts ("powerpc630"); break; #endif /* Dunno what this is, leave it out for now. case POWER_A35: puts ("powerpca35"); break; */ /* This is waiting for a bit more info. case POWER_RS64II: puts ("powerpcrs64ii"); break; */ #ifdef POWER_4 case POWER_4: puts ("power4"); break; #endif #ifdef POWER_5 case POWER_5: puts ("power5"); break; #endif #ifdef POWER_6 case POWER_6: puts ("power6"); break; #endif #ifdef POWER_7 case POWER_7: puts ("power7"); break; #endif #ifdef POWER_8 case POWER_8: puts ("power8"); break; #endif default: if (_system_configuration.architecture == POWER_RS) puts ("power"); else if (_system_configuration.width == 64) puts ("powerpc64"); } return 0; } EOF if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then x=`$dummy` if test -n "$x"; then exact_cpu=$x fi fi fi if test -z "$exact_cpu"; then # On MacOS X (or any Mach-O presumably), NXGetLocalArchInfo cpusubtype # can tell us the exact cpu. cat >$dummy.c < #include int main (void) { const NXArchInfo *a = NXGetLocalArchInfo(); if (a->cputype == CPU_TYPE_POWERPC) { switch (a->cpusubtype) { /* The following known to Darwin 1.3. */ case CPU_SUBTYPE_POWERPC_601: puts ("powerpc601"); break; case CPU_SUBTYPE_POWERPC_602: puts ("powerpc602"); break; case CPU_SUBTYPE_POWERPC_603: puts ("powerpc603"); break; case CPU_SUBTYPE_POWERPC_603e: puts ("powerpc603e"); break; case CPU_SUBTYPE_POWERPC_603ev: puts ("powerpc603e"); break; case CPU_SUBTYPE_POWERPC_604: puts ("powerpc604"); break; case CPU_SUBTYPE_POWERPC_604e: puts ("powerpc604e"); break; case CPU_SUBTYPE_POWERPC_620: puts ("powerpc620"); break; case CPU_SUBTYPE_POWERPC_750: puts ("powerpc750"); break; case CPU_SUBTYPE_POWERPC_7400: puts ("powerpc7400"); break; case CPU_SUBTYPE_POWERPC_7450: puts ("powerpc7450"); break; /* Darwin 6.8.5 doesn't define the following */ case 0x8001: puts ("powerpc7455"); break; case 0x8002: puts ("powerpc7457"); break; case 0x8003: puts ("powerpc7447"); break; case 100: puts ("powerpc970"); break; } } return 0; } EOF if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then x=`$dummy` if test -n "$x"; then exact_cpu=$x fi fi fi ;; sparc-*-* | sparc64-*-*) # If we can recognise an actual v7 then $exact_cpu is set to "sparc" so as # to short-circuit subsequent tests. # Grep the linux kernel /proc/cpuinfo pseudo-file. # A typical line is "cpu\t\t: TI UltraSparc II (BlackBird)" # See arch/sparc/kernel/cpu.c and arch/sparc64/kernel/cpu.c. # if test -f /proc/cpuinfo; then if grep 'cpu.*Cypress' /proc/cpuinfo >/dev/null; then exact_cpu="sparc" # ie. v7 elif grep 'cpu.*Power-UP' /proc/cpuinfo >/dev/null; then exact_cpu="sparc" # ie. v7 elif grep 'cpu.*HyperSparc' /proc/cpuinfo >/dev/null; then exact_cpu="sparcv8" elif grep 'cpu.*SuperSparc' /proc/cpuinfo >/dev/null; then exact_cpu="supersparc" elif grep 'cpu.*MicroSparc' /proc/cpuinfo >/dev/null; then exact_cpu="microsparc" elif grep 'cpu.*MB86904' /proc/cpuinfo >/dev/null; then # actually MicroSPARC-II exact_cpu=microsparc elif grep 'cpu.*UltraSparc T5' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparct5" elif grep 'cpu.*UltraSparc T4' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparct4" elif grep 'cpu.*UltraSparc T3' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparct3" elif grep 'cpu.*UltraSparc T2' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparct2" elif grep 'cpu.*UltraSparc T1' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparct1" elif grep 'cpu.*UltraSparc III' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparc3" elif grep 'cpu.*UltraSparc IIi' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparc2i" elif grep 'cpu.*UltraSparc II' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparc2" elif grep 'cpu.*UltraSparc' /proc/cpuinfo >/dev/null; then exact_cpu="ultrasparc" fi fi # Need to invoke this for setup of $dummy eval $set_cc_for_build # Grep the output from sysinfo on SunOS. # sysinfo has been seen living in /bin or in /usr/kvm # cpu0 is a "SuperSPARC Model 41 SPARCmodule" CPU # cpu0 is a "75 MHz TI,TMS390Z55" CPU # if test -z "$exact_cpu"; then for i in sysinfo /usr/kvm/sysinfo; do if $SHELL -c $i 2>/dev/null >$dummy; then if grep 'cpu0 is a "SuperSPARC' $dummy >/dev/null; then exact_cpu=supersparc break elif grep 'cpu0 is a .*TMS390Z5.' $dummy >/dev/null; then # TMS390Z50 and TMS390Z55 exact_cpu=supersparc break fi fi done fi # Grep the output from prtconf on Solaris. # Use an explicit /usr/sbin, since that directory might not be in a normal # user's path. # # SUNW,UltraSPARC (driver not attached) # SUNW,UltraSPARC-II (driver not attached) # SUNW,UltraSPARC-IIi (driver not attached) # SUNW,UltraSPARC-III+ (driver not attached) # Ross,RT625 (driver not attached) # TI,TMS390Z50 (driver not attached) # # /usr/sbin/sysdef prints similar information, but includes all loadable # cpu modules, not just the real cpu. # # We first try a plain prtconf, since that is known to work on older systems. # But for newer T1 systems, that doesn't produce any useful output, we need # "prtconf -vp" there. # for prtconfopt in "" "-vp"; do if test -z "$exact_cpu"; then if $SHELL -c "/usr/sbin/prtconf $prtconfopt" 2>/dev/null >$dummy; then if grep 'SUNW,UltraSPARC-T5' $dummy >/dev/null; then exact_cpu=ultrasparct5 elif grep 'SUNW,UltraSPARC-T4' $dummy >/dev/null; then exact_cpu=ultrasparct4 elif grep 'SUNW,UltraSPARC-T3' $dummy >/dev/null; then exact_cpu=ultrasparct3 elif grep 'SUNW,UltraSPARC-T2' $dummy >/dev/null; then exact_cpu=ultrasparct2 elif grep 'SUNW,UltraSPARC-T1' $dummy >/dev/null; then exact_cpu=ultrasparct1 elif grep 'SUNW,UltraSPARC-III' $dummy >/dev/null; then exact_cpu=ultrasparc3 elif grep 'SUNW,UltraSPARC-IIi' $dummy >/dev/null; then exact_cpu=ultrasparc2i elif grep 'SUNW,UltraSPARC-II' $dummy >/dev/null; then exact_cpu=ultrasparc2 elif grep 'SUNW,UltraSPARC' $dummy >/dev/null; then exact_cpu=ultrasparc elif grep 'Ross,RT62.' $dummy >/dev/null; then # RT620, RT625, RT626 hypersparcs (v8). exact_cpu=sparcv8 elif grep 'TI,TMS390Z5.' $dummy >/dev/null; then # TMS390Z50 and TMS390Z55 exact_cpu=supersparc elif grep 'TI,TMS390S10' $dummy >/dev/null; then exact_cpu=microsparc elif grep 'FMI,MB86904' $dummy >/dev/null; then # actually MicroSPARC-II exact_cpu=microsparc fi fi fi done # Grep the output from sysctl hw.model on sparc or sparc64 *BSD. # Use an explicit /sbin, since that directory might not be in a normal # user's path. Example outputs, # # hw.model: Sun Microsystems UltraSparc-IIi # if test -z "$exact_cpu"; then if $SHELL -c "/sbin/sysctl hw.model" 2>/dev/null >$dummy; then if grep -i 'UltraSparc-T5' $dummy >/dev/null; then exact_cpu=ultrasparct5 elif grep -i 'UltraSparc-T4' $dummy >/dev/null; then exact_cpu=ultrasparct4 elif grep -i 'UltraSparc-T3' $dummy >/dev/null; then exact_cpu=ultrasparct3 elif grep -i 'UltraSparc-T2' $dummy >/dev/null; then exact_cpu=ultrasparct2 elif grep -i 'UltraSparc-T1' $dummy >/dev/null; then exact_cpu=ultrasparct1 elif grep -i 'UltraSparc-III' $dummy >/dev/null; then exact_cpu=ultrasparc3 elif grep -i 'UltraSparc-IIi' $dummy >/dev/null; then exact_cpu=ultrasparc2i elif grep -i 'UltraSparc-II' $dummy >/dev/null; then exact_cpu=ultrasparc2 elif grep -i 'UltraSparc' $dummy >/dev/null; then exact_cpu=ultrasparc elif grep 'TMS390Z5.' $dummy >/dev/null; then # TMS390Z50 and TMS390Z55 exact_cpu=supersparc elif grep 'TMS390S10' $dummy >/dev/null; then exact_cpu=microsparc elif grep 'MB86904' $dummy >/dev/null; then # actually MicroSPARC-II exact_cpu=microsparc elif grep 'MB86907' $dummy >/dev/null; then exact_cpu=turbosparc fi fi fi # sun4m and sun4d are v8s of some sort, sun4u is a v9 of some sort # if test -z "$exact_cpu"; then case `uname -m` in sun4[md]) exact_cpu=sparcv8 ;; sun4u) exact_cpu=sparcv9 ;; esac fi ;; # Recognise x86 processors using a tricky cpuid with 4 arguments, repeating # arguments; for x86-64 we effectively pass the 1st in rdx and the 2nd in rcx. # This allows the same asm to work for both standard and Windoze calling # conventions. i?86-*-* | amd64-*-* | x86_64-*-*) eval $set_cc_for_build cat <$dummy.c #include #include #define CPUID(a,b) cpuid(b,a,a,b) #if __cplusplus extern "C" #endif unsigned int cpuid (int, char *, char *, int); int main () { char vendor_string[13]; char feature_string[12]; long fms; int family, model; const char *modelstr, *suffix; int cpu_64bit = 0, cpu_avx = 0; int cpuid_64bit, cpuid_avx, cpuid_osxsave; CPUID (vendor_string, 0); vendor_string[12] = 0; fms = CPUID (feature_string, 1); family = ((fms >> 8) & 0xf) + ((fms >> 20) & 0xff); model = ((fms >> 4) & 0xf) + ((fms >> 12) & 0xf0); cpuid_avx = (feature_string[11] >> 4) & 1; cpuid_osxsave = (feature_string[11] >> 3) & 1; modelstr = "$guess_cpu"; /**************************************************/ /*** WARNING: keep this list in sync with fat.c ***/ /**************************************************/ if (strcmp (vendor_string, "GenuineIntel") == 0) { switch (family) { case 5: if (model <= 2) modelstr = "pentium"; else if (model >= 4) modelstr = "pentiummmx"; break; case 6: if (model <= 1) modelstr = "pentiumpro"; else if (model <= 6) modelstr = "pentium2"; else if (model <= 8) modelstr = "pentium3"; else if (model <= 9) modelstr = "pentiumm"; else if (model <= 0x0c) modelstr = "pentium3"; else if (model <= 0x0e) modelstr = "pentiumm"; else if (model <= 0x19) cpu_64bit = 1, modelstr = "core2"; else if (model == 0x1a) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Gainestown */ else if (model == 0x1c) cpu_64bit = 1, modelstr = "atom"; /* Silverthorne */ else if (model == 0x1d) cpu_64bit = 1, modelstr = "core2"; /* PNR Dunnington */ else if (model == 0x1e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Lynnfield/Jasper */ else if (model == 0x25) cpu_64bit = 1, modelstr = "westmere"; /* WSM Clarkdale/Arrandale */ else if (model == 0x26) cpu_64bit = 1, modelstr = "atom"; /* Lincroft */ else if (model == 0x27) cpu_64bit = 1, modelstr = "atom"; /* Saltwell */ else if (model == 0x2a) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SB */ else if (model == 0x2c) cpu_64bit = 1, modelstr = "westmere"; /* WSM Gulftown */ else if (model == 0x2d) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SBC-EP */ else if (model == 0x2e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Beckton */ else if (model == 0x2f) cpu_64bit = 1, modelstr = "westmere"; /* WSM Eagleton */ else if (model == 0x36) cpu_64bit = 1, modelstr = "atom"; /* Cedarview/Saltwell */ else if (model == 0x37) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont */ else if (model == 0x3a) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge"; /* IBR */ else if (model == 0x3c) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell client */ else if (model == 0x3d) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell */ else if (model == 0x3e) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge"; /* Ivytown */ else if (model == 0x3f) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell server */ else if (model == 0x45) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell ULT */ else if (model == 0x46) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Crystal Well */ else if (model == 0x47) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell */ else if (model == 0x4a) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont */ else if (model == 0x4c) cpu_64bit = 1, modelstr = "silvermont"; /* Airmont */ else if (model == 0x4d) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont/Avoton */ else if (model == 0x4e) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake"; /* Skylake client */ else if (model == 0x4f) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell server */ else if (model == 0x55) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake"; /* Skylake server */ else if (model == 0x56) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell microserver */ else if (model == 0x57) cpu_64bit = 1, modelstr = "knightslanding"; /* aka Xeon Phi */ else if (model == 0x5a) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont */ else if (model == 0x5c) cpu_64bit = 1, modelstr = "goldmont"; /* Goldmont */ else if (model == 0x5e) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake"; /* Skylake */ else if (model == 0x5f) cpu_64bit = 1, modelstr = "goldmont"; /* Goldmont */ else if (model == 0x8e) cpu_64bit = 1, cpu_avx=1, modelstr = "cabylake"; /* Capylake Y/U */ else if (model == 0x9e) cpu_64bit = 1, cpu_avx=1, modelstr = "cabylake"; /* Capylake desktop */ else cpu_64bit = 1, modelstr = "nehalem"; /* default */ if (strcmp (modelstr, "haswell") == 0) { /* Some Haswells lack BMI2. Let them appear as Sandybridges for now. */ CPUID (feature_string, 7); if ((feature_string[0 + 8 / 8] & (1 << (8 % 8))) == 0) modelstr = "sandybridge"; } break; case 15: cpu_64bit = 1, modelstr = "pentium4"; break; } } else if (strcmp (vendor_string, "AuthenticAMD") == 0) { switch (family) { case 5: if (model <= 3) modelstr = "k5"; else if (model <= 7) modelstr = "k6"; else if (model == 8) modelstr = "k62"; else if (model == 9) modelstr = "k63"; else if (model == 10) modelstr = "geode"; else if (model == 13) modelstr = "k63"; break; case 6: modelstr = "athlon"; break; case 15: /* K8, K9 */ cpu_64bit = 1, modelstr = "k8"; break; case 16: /* K10 */ cpu_64bit = 1, modelstr = "k10"; break; case 17: /* Hybrid k8/k10, claim k8 */ cpu_64bit = 1, modelstr = "k8"; break; case 18: /* Llano, uses K10 core */ cpu_64bit = 1, modelstr = "k10"; break; case 19: /* AMD Internal, assume future K10 */ cpu_64bit = 1, modelstr = "k10"; break; case 20: /* Bobcat */ cpu_64bit = 1, modelstr = "bobcat"; break; case 21: /* Bulldozer */ cpu_64bit = 1, cpu_avx = 1; if (model <= 1) modelstr = "bulldozer"; else if (model < 0x20) /* really 2, [0x10-0x20) */ modelstr = "piledriver"; else if (model < 0x40) /* really [0x30-0x40) */ modelstr = "steamroller"; else /* really [0x60-0x70) */ modelstr = "excavator"; break; case 22: /* Jaguar, an improved bobcat */ cpu_64bit = 1, cpu_avx = 1, modelstr = "jaguar"; break; } } else if (strcmp (vendor_string, "CyrixInstead") == 0) { /* Should recognize Cyrix' processors too. */ } else if (strcmp (vendor_string, "CentaurHauls") == 0) { switch (family) { case 6: if (model < 9) modelstr = "viac3"; else if (model < 15) modelstr = "viac32"; else cpu_64bit = 1, modelstr = "nano"; break; } } CPUID (feature_string, 0x80000001); cpuid_64bit = (feature_string[7] >> 5) & 1; suffix = ""; if (cpuid_64bit && ! cpu_64bit) /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but cpuid claims AMD64 capabilities, then revert to the generic "x86_64". This is of course wrong, but it can happen in some virtualisers and emulators, and this workaround allows for successful 64-bit builds. */ modelstr = "x86_64"; else if (cpu_avx && ! (cpuid_avx && cpuid_osxsave)) /* For CPUs nominally capable of executing AVX, append "noavx" when not both the AVX and OSXSAVE cpuid bits are set. We tolerate weirdness here, as some virtualisers set a broken cpuid state here, while other virtualisers allow users to set a broken state. */ suffix = "noavx"; printf ("%s%s", modelstr, suffix); return 0; } EOF # The rcx/ecx zeroing here and in the variant below is needed for the BMI2 # check. cat <${dummy}0.s .globl cpuid .globl _cpuid cpuid: _cpuid: push %rbx mov %rdx, %r8 mov %ecx, %eax xor %ecx, %ecx .byte 0x0f .byte 0xa2 mov %ebx, (%r8) mov %edx, 4(%r8) mov %ecx, 8(%r8) pop %rbx ret EOF if ($CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy) >/dev/null 2>&1; then # On 80386 and early 80486 cpuid is not available and will result in a # SIGILL message, hence 2>/dev/null. # # On i386-unknown-freebsd4.9, "/bin/sh -c ./dummy" seems to send an # "Illegal instruction (core dumped)" message to stdout, so we test $? # to check if the program run was successful. # x=`$SHELL -c $dummy 2>/dev/null` if test $? = 0 && test -n "$x"; then exact_cpu=$x fi fi cat <${dummy}0.s .globl cpuid .globl _cpuid cpuid: _cpuid: pushl %esi pushl %ebx movl 24(%esp),%eax xor %ecx, %ecx .byte 0x0f .byte 0xa2 movl 20(%esp),%esi movl %ebx,(%esi) movl %edx,4(%esi) movl %ecx,8(%esi) popl %ebx popl %esi ret EOF if test -z "$exact_cpu"; then if ($CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy) >/dev/null 2>&1; then # On 80386 and early 80486 cpuid is not available and will result in a # SIGILL message, hence 2>/dev/null. # # On i386-unknown-freebsd4.9, "/bin/sh -c ./dummy" seems to send an # "Illegal instruction (core dumped)" message to stdout, so we test $? # to check if the program run was successful. # x=`$SHELL -c $dummy 2>/dev/null` if test $? = 0 && test -n "$x"; then exact_cpu=$x fi fi fi # We need to remove some .o files here since lame C compilers # generate these even when not asked. ;; s390*-*-*) model=`grep "^processor 0: version =" /proc/cpuinfo | sed -e 's/.*machine = //'` case $model in 2064 | 2066) zcpu="z900" ;; 2084 | 2086) zcpu="z990" ;; 2094 | 2096) zcpu="z9" ;; 2097 | 2098) zcpu="z10" ;; 2817 | 2818 | *) zcpu="z196" ;; esac case "$guess_full" in s390x-*-*) exact_cpu=${zcpu} ;; s390-*-*) exact_cpu=${zcpu}esa ;; esac ;; esac # ------------------------------------------------------------------------- # Use an exact cpu, if possible if test -n "$exact_cpu"; then echo "$exact_cpu$guess_rest" else echo "$guess_full" fi exit 0 # Local variables: # fill-column: 76 # End: gmp-6.1.0/doc/000755 001756 001756 00000000000 12615426653 014222 5ustar00bodratobodrato000000 000000 gmp-6.1.0/NEWS000664 001756 001756 00000105554 12615426624 014166 0ustar00bodratobodrato000000 000000 Copyright 1996, 1999-2015 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. Changes between GMP version 6.0.* and 6.1.0 BUGS FIXED * The public function mpn_com is now correctly declared in gmp.h. * Healed possible failures of mpn_sec_sqr for non-cryptographic sizes for some obsolete CPUs. * The option --disable-assembly now disables all inlined asm. * Fixed bug affecting mini-gmp's bitwise functions mpz_setbit, mpz_clrbit, and mpz_combit. * Various problems related to precision for mpf have been fixed. * Fixed ABI incompatible stack alignment in calls from assembly code. * Fixed PIC bug in popcount affecting Intel processors using the 32-bit ABI. SPEEDUPS * Speedup for Intel Broadwell and Skylake though assembly code making use of new ADX instructions. * Square root is now faster when the remainder is not needed. Also the speed to compute the k-th root improved, for small sizes. * Improved arm64 support. FEATURES * New C++ functions gcd and lcm for mpz_class. * New public mpn functions mpn_divexact_1, mpn_zero_p, and mpn_cnd_swap. * New public mpq_cmp_z function, to efficiently compare rationals with integers. * Support for Darwin in all x86 code, thereby enabling fat builds on Darwin. * Support for more 32-bit arm processors. * Support for compilation with clang/llvm on more platforms. Caution: GMP triggers mis-compilation bugs in clang for many platforms, such as arm, x86 (32-bit and 64-bit), powerpc, mips. * Support for AVX-less modern x86 CPUs. (Such support might be missing either because the CPU vendor chose to disable AVX, or because the running kernel lacks AVX context switch support.) * Stack usage trimmed; we believe 512 KiB is now sufficient for any GMP call, irrespective of operand size. * Support for NetBSD under Xen; we switch off AVX unconditionally under NetBSD since a bug in NetBSD makes AVX fail under Xen. MISC * We now use manufacturers' code names for x86 CPUs, e.g., "haswell" instead of names derived from the commercial brands. * Small improvements and better coverage for the test suite. * The various FreeBSD problems listed for 6.0.0 affect this release too. * Tuned values for FFT multiplications are provided for larger number on many platforms. Changes between GMP version 5.1.* and 6.0.0 BUGS FIXED * The function mpz_invert now considers any number invertible in Z/1Z. * The mpn multiply code now handles operands of more than 2^31 limbs correctly. (Note however that the mpz code is limited to 2^32 bits on 32-bit hosts and 2^37 bits on 64-bit hosts.) * Contains all fixes from release 5.1.3. SPEEDUPS * Plain division of large operands is faster and more monotonous in operand size. * Major speedup for ARM, in particular ARM Cortex-A15, thanks to improved assembly. * Major speedup for SPARC T4/T5 and speedup also for T3, thanks to a lot of new assembly. * Speedup for Intel Sandy Bridge, Ivy Bridge, Haswell, thanks to rewritten and vastly expanded assembly support. Speedup also for the older Core 2 and Nehalem. * Faster mixed arithmetic between mpq_class and double. * With g++, optimise more operations when one argument is a simple constant. FEATURES * Support for new Intel and AMD CPUs. * Support for ARM64 alias Aarch64 alias ARMv8. * New public functions mpn_sec_mul and mpn_sec_sqr, implementing side-channel silent multiplication and squaring. * New public functions mpn_sec_div_qr and mpn_sec_div_r, implementing side-channel silent division. * New public functions mpn_cnd_add_n and mpn_cnd_sub_n. Side-channel silent conditional addition and subtraction. * New public function mpn_sec_powm, implementing side-channel silent modexp. * New public function mpn_sec_invert, implementing side-channel silent modular inversion. * Better support for applications which use the mpz_t type, but nevertheless need to call some of the lower-level mpn functions. See the documentation for mpz_limbs_read and related functions. MISC * This release will not work on NetBSD 5.x, FreeBSD 7.x, 8.x or 9 series before 9.3. The reason is that the m4 command is not correctly implemented. (Workaround: Use an older GMP release, or install GNU m4 from /usr/ports and tell GMP to use it.) * This release will not build properly on FreeBSD/amd64 before version 10 using the 32-bit ABI (once a working m4 is installed). The reason is broken limits.h. (Workaround: Use an older GMP release if using the 32-bit ABI on these FreeBSD releases is important.) * This release will not work reliably on FreeBSD 10.0 for i386 or amd64 using the 32-bit ABI. The reason is bugs in the compiler 'clang'. Depending on CPU-dependent compiler flags, GMP may or may not be miscompiled in a particular build. (Workaround: Compiling gcc from /usr/ports should work, except that gcc circularly depends on GMP; we have not been able to test that workaround due to FreeBSD 10.0 bugs affecting its ability to run under KVM and Xen.) * This release will not compile on FreeBSD before version 10 for i386, targeting any modern AMD processor. The reason is bugs in the old gcc bundled with FreeBSD. (Workaround: install a less obsolete gcc from /usr/ports and tell GMP to use it, or override the -march=amdfam10 GMP configure command line argument.) Changes between GMP version 5.1.2 and 5.1.3 BUGS FIXED * The internal functions mpn_sbpi1_div_qr_sec mpn_sbpi1_div_r_sec could compute garbage with a low probability. They are now rewritten, and the test code has been improved. * A bug in the ia64 implementation of mpn_divrem_2, clobbering some callee-save registers, has been fixed. This is an internal function, with the bug manifesting itself as miscomputation in, e.g., mpn_sqrtrem. * The documentation now correctly says 'const' for input arguments. SPEEDUPS * None. FEATURES * None. MISC * None. Changes between GMP version 5.1.1 and 5.1.2 BUGS FIXED * A bug in mpz_powm_ui triggered by base arguments of at least 15000 decimal digits or mod arguments of at least 7500 decimal digits has been fixed. * An AMD Bulldozer specific bug affecting the 64-bit Windows ABI has been fixed. This bug was in a key function (mpn_mul_1) and made both Bulldozer specific builds and fat builds run on Bulldozer completely non-functional. SPEEDUPS * None. FEATURES * None. MISC * Fixes and generalisations to the test suite. * Minor portability enhancements. Changes between GMP version 5.1.0 and 5.1.1 BUGS FIXED * On Windows 64-bit, an error causing link errors about __gmp_binvert_limb_table has been fixed. * Aarch64 alias ARM64 support now works. * A possible buffer overrun in mpz_ior has been fixed. * A rare sign flip in mpz_remove has been fixed. * A bug causing problems with mpf numbers with absolute value >= 2^31 has been fixed. * Several bugs in mini-gmp have been fixed. * A bug caused by automake, related to the 'distcheck' target, has been fixed by upgrading the automake used for GMP release engineering. SPEEDUPS * None. FEATURES * Preliminary support for the x32 ABI under x86-64. MISC * The mini-gmp testsuite now tests the entire set of functions. * Various improvements of the GMP testsuite. Changes between GMP version 5.0.* and 5.1.0 BUGS FIXED * When reading a C++ number (like mpz_class) in an istream reaches the end of the stream, the eofbit is now set. * The result sign of mpz_rootrem's remainder is now always correct. * The mpz_remove function now handles negative divisors. * Contains all fixes from release 5.0.5. SPEEDUPS * The n-factorial and n-over-k functions have been reimplemented for great speedups for small and large operands. * New subquadratic algorithm for the Kronecker/Jacobi/Legendre symbol. * Major speedup for ARM, in particular ARM Cortex-A9 and A15, thanks to broad assembly support. * Significant speedup for POWER6 and POWER7 thanks to improved assembly. * The performance under M$ Windows' 64-bit ABI has been greatly improved thanks to complete assembly support. * Minor speed improvements of many functions and for many platforms. FEATURES * Many new CPUs recognised. * New functions for multi-factorials, and primorial: mpz_2fac_ui, mpz_mfac_uiui and mpz_primorial_ui. * The mpz_powm_sec function now uses side-channel silent division for converting into Montgomery residues. * The fat binary mechanism is now more robust in its CPU recognition. MISC * Inclusion of assembly code is now controlled by the configure options --enable-assembly and --disable-assembly. The "none" CPU target is gone. * In C++, the conversions mpq_class->mpz_class, mpf_class->mpz_class and mpf_class->mpq_class are now explicit. * Includes "mini-gmp", a small, portable, but less efficient, implementation of a subset of GMP's mpn and mpz interfaces. Used in GMP bootstrap, but it can also be bundled with applications as a fallback when the real GMP library is unavailable. * The ABIs under AIX are no longer called aix32 and aix64, but mode64 and 32. This is more consistent with other powerpc systems. * The coverage of the testsuite has been improved, using the lcov tool. See also https://gmplib.org/devel/lcov/. * It is now possible to compile GMP using a C++ compiler. * K&R C compilers are no longer supported. * The BSD MP compatibility functions have been removed. Changes between GMP version 5.0.4 and 5.0.5 BUGS FIXED * A bug causing AMD 11h processors to be treated like AMD 10h has been fixed. The 11h processors do not correctly handle all 10h (aka K10) instructions, and GMP's use of these instructions results in major miscomputations (not as one would have hoped CPU traps of some 'illegal instruction' sort). * A bug affecting recent Intel Sandy Bridge CPUs resulting in configuration failures has been fixed. SPEEDUPS * None. FEATURES * A couple of tests added to the self-check suite. MISC * None. Changes between GMP version 5.0.3 and 5.0.4 BUGS FIXED * Thresholds in mpn_powm_sec for both fat and non-fat builds are now used safely, plugging a one-word buffer overrun introduced in the 5.0.3 release (for non-fat) and a multi-word buffer overrun that existed since 5.0 (for fat). (We have not been able to provoke malign stack smashing in any of the ~100 configurations explored by the GMP nightly builds, but the bug should be assumed to be exploitable.) * Two bugs in multiplication code causing incorrect computation with extremely low probability have been fixed. * A bug in the test suite causing buffer overruns during "make check", sometimes leading to subsequent malloc crashes, has been fixed. * Two bugs in the gcd code have been fixed. They could lead to incorrect results, but for uniformly distributed random operands, the likelihood for that is infinitesimally small. (There was also a third bug, but that was an incorrect ASSERT, which furthermore was not enabled by default.) * A bug affecting 32-bit PowerPC division has been fixed. The bug caused miscomputation for certain divisors in the range 2^32 ... 2^64-1 (about 1 in 2^30 of these). SPEEDUPS * None, except indirectly through recognition of new CPUs, and through better tuning parameters. FEATURES * Some more tests added to the self-check suite. * The AMD "Bulldozer" CPU is now recognised. MISC * None. Changes between GMP version 5.0.2 and 5.0.3 BUGS FIXED * A few minor bugs related to portability fixed. * A slight timing leak of the powm_sec functions have been sealed. (This leak could possibly be used to extract the most significant few bits of the exponent. "Few" here means at most 10.) * The mpz_nextprime function now runs a safer number of pseudo-random prime tests. * A bug in division code possibly causing incorrect computation was fixed. SPEEDUPS * None, except indirectly through recognition of new CPUs, and through better tuning parameters. FEATURES * New CPUs recognised. * IBM S/390 are now supported in both 31/32-bit and 64-bit mode. (We have not been able to fully test this on any multilib machine, since IBM expired our guest account a few days before our release.) MISC * None. Changes between GMP version 5.0.1 and 5.0.2 BUGS FIXED * Many minor bugs related to portability fixed. * The support for HPPA 2.0N now works, after an assembly bug fix. * A test case type error has been fixed. The symptom of this bug was spurious 'make check' failures. SPEEDUPS * None, except indirectly through recognition of new CPUs. FEATURES * Fat builds are now supported for 64-bit x86 processors also under Darwin. MISC * None. Changes between GMP version 5.0.0 and 5.0.1 BUGS FIXED * Fat builds fixed. * Fixed crash for huge multiplies when old FFT_TABLE2 type of parameter selection tables' sentinel was smaller than multiplied operands. * The solib numbers now reflect the removal of the documented but preliminary mpn_bdivmod function; we correctly flag incompatibility with GMP 4.3. GMP 5.0.0 has this wrong, and should perhaps be uninstalled to avoid confusion. SPEEDUPS * Multiplication of large numbers has indirectly been sped up through better FFT tuning and processor recognition. Since many operations depend on multiplication, there will be a general speedup. FEATURES * More Core i3, i5 an Core i7 processor models are recognised. * Fixes and workarounds for Mac OS quirks should make this GMP version build using many of the different versions of "Xcode". MISC * The amount of scratch memory needed for multiplication of huge numbers has been reduced substantially (but is still larger than in GMP 4.3.) * Likewise, the amount of scratch memory needed for division of large numbers has been reduced substantially. * The FFT tuning code of tune/tuneup.c has been completely rewritten, and new, large FFT parameter selection tables are provided for many machines. * Upgraded to the latest autoconf, automake, libtool. Changes between GMP version 4.3.X and 5.0.0 BUGS FIXED * None (contains the same fixes as release 4.3.2). SPEEDUPS * Multiplication has been overhauled: (1) Multiplication of larger same size operands has been improved with the addition of two new Toom functions and a new internal function mpn_mulmod_bnm1 (computing U * V mod (B^n-1), B being the word base. This latter function is used for the largest products, waiting for a better Schoenhage-Strassen U * V mod (B^n+1) implementation. (2) Likewise for squaring. (3) Multiplication of different size operands has been improved with the addition of many new Toom function, and by selecting underlying functions better from the main multiply functions. * Division and mod have been overhauled: (1) Plain "schoolbook" division is reimplemented using faster quotient approximation. (2) Division Q = N/D, R = N mod D where both the quotient and remainder are needed now runs in time O(M(log(N))). This is an improvement of a factor log(log(N)) (3) Division where just the quotient is needed is now O(M(log(Q))) on average. (4) Modulo operations using Montgomery REDC form now take time O(M(n)). (5) Exact division Q = N/D by means of mpz_divexact has been improved for all sizes, and now runs in time O(M(log(N))). * The function mpz_powm is now faster for all sizes. Its complexity has gone from O(M(n)log(n)m) to O(M(n)m) where n is the size of the modulo argument and m is the size of the exponent. It is also radically faster for even modulus, since it now partially factors such modulus and performs two smaller modexp operations, then uses CRT. * The internal support for multiplication yielding just the lower n limbs has been improved by using Mulders' algorithm. * Computation of inverses, both plain 1/N and 1/N mod B^n have been improved by using well-tuned Newton iterations, and wrap-around multiplication using mpn_mulmod_bnm1. * A new algorithm makes mpz_perfect_power_p asymptotically faster. * The function mpz_remove uses a much faster algorithm, is better tuned, and also benefits from the division improvements. * Intel Atom and VIA Nano specific optimisations. * Plus hundreds of smaller improvements and tweaks! FEATURES * New mpz function: mpz_powm_sec for side-channel quiet modexp computations. * New mpn functions: mpn_sqr, mpn_and_n, mpn_ior_n, mpn_xor_n, mpn_nand_n, mpn_nior_n, mpn_xnor_n, mpn_andn_n, mpn_iorn_n, mpn_com, mpn_neg, mpn_copyi, mpn_copyd, mpn_zero. * The function mpn_tdiv_qr now allows certain argument overlap. * Support for fat binaries for 64-bit x86 processors has been added. * A new type, mp_bitcnt_t for bignum bit counts, has been introduced. * Support for Windows64 through mingw64 has been added. * The cofactors of mpz_gcdext and mpn_gcdext are now more strictly normalised, returning to how GMP 4.2 worked. (Note that also release 4.3.2 has this change.) MISC * The mpn_mul function should no longer be used for squaring, instead use the new mpn_sqr. * The algorithm selection has been improved, the number of thresholds have more than doubled, and the tuning and use of existing thresholds have been improved. * The tune/speed program can measure many of new functions. * The mpn_bdivmod function has been removed. We do not consider this an incompatible change, since the function was marked as preliminary. * The testsuite has been enhanced in various ways. Changes between GMP version 4.3.1 and 4.3.2 Bugs: * Fixed bug in mpf_eq. * Fixed overflow issues in mpz_set_str, mpz_inp_str, mpf_set_str, and mpf_get_str. * Avoid unbounded stack allocation for unbalanced multiplication. * Fixed bug in FFT multiplication. Speedups: * None, except that proper processor recognition helps affected processors. Features: * Recognise more "Core 2" processor variants. * The cofactors of mpz_gcdext and mpn_gcdext are now more strictly normalised, returning to how GMP 4.2 worked. Changes between GMP version 4.3.0 and 4.3.1 Bugs: * Fixed bug in mpn_gcdext, affecting also mpz_gcdext and mpz_invert. The bug could cause a cofactor to have a leading zero limb, which could lead to crashes or miscomputation later on. * Fixed some minor documentation issues. Speedups: * None. Features: * Workarounds for various issues with Mac OS X's build tools. * Recognise more IBM "POWER" processor variants. Changes between GMP version 4.2.X and 4.3.0 Bugs: * Fixed bug in mpz_perfect_power_p with recognition of negative perfect powers that can be written both as an even and odd power. * We might accidentally have added bugs since there is a large amount of new code in this release. Speedups: * Vastly improved assembly code for x86-64 processors from AMD and Intel. * Major improvements also for many other processor families, such as Alpha, PowerPC, and Itanium. * New sub-quadratic mpn_gcd and mpn_gcdext, as well as improved basecase gcd code. * The multiply FFT code has been slightly improved. * Balanced multiplication now uses 4-way Toom in addition to schoolbook, Karatsuba, 3-way Toom, and FFT. * Unbalanced multiplication has been vastly improved. * Improved schoolbook division by means of faster quotient approximation. * Several new algorithms for division and mod by single limbs, giving many-fold speedups. * Improved nth root computations. * The mpz_nextprime function uses sieving and is much faster. * Countless minor tweaks. Features: * Updated support for fat binaries for x86_32 include current processors * Lots of new mpn internal interfaces. Some of them will become public in a future GMP release. * Support for the 32-bit ABI under x86-apple-darwin. * x86 CPU recognition code should now default better for future processors. * The experimental nails feature does not work in this release, but it might be re-enabled in the future. Misc: * The gmp_version variable now always contains three parts. For this release, it is "4.3.0". Changes between GMP version 4.2.3 and 4.2.4 Bugs: * Fix bug with parsing exponent '+' sign in mpf. * Fix an allocation bug in mpf_set_str, also affecting mpf_init_set_str, and mpf_inp_str. Speedups: * None, except that proper processor recognition helps affected processors. Features: * Recognize new AMD processors. Changes between GMP version 4.2.2 and 4.2.3 Bugs: * Fix x86 CPU recognition code to properly identify recent AMD and Intel 64-bit processors. * The >> operator of the C++ wrapper gmpxx.h now does floor rounding, not truncation. * Inline semantics now follow the C99 standard, and works with recent GCC releases. * C++ bitwise logical operations work for more types. * For C++, gmp.h now includes cstdio, improving compiler compatibility. * Bases > 36 now work properly in mpf_set_str. Speedups: * None, except that proper processor recognition helps affected processors. Features: * The allocation functions now detect overflow of the mpz_t type. This means that overflow will now cause an abort, except when the allocation computation itself overflows. (Such overflow can probably only happen in powering functions; we will detect powering overflow in the future.) Changes between GMP version 4.2.1 and 4.2.2 * License is now LGPL version 3. Bugs: * Shared library numbers corrected for libcxx. * Fixed serious bug in gmpxx.h where a=a+b*c would generate garbage. Note that this only affects C++ programs. * Fix crash in mpz_set_d for arguments with large negative exponent. * Fix 32-bit ABI bug with Itanium assembly for popcount and hamdist. * Fix assembly syntax problem for powerpc-ibm-aix with AIX native assembler. * Fix problems with x86 --enable-fat, where the compiler where told to generate code for the build machine, not plain i386 code as it should. * Improved recognition of powerpc systems wrt Altivec/VMX capability. * Misc minor fixes, mainly workarounds for compiler/assembler bugs. Speedups: * "Core 2" and Pentium 4 processors, running in 64-bit mode will get a slight boost as they are now specifically recognized. Features: * New support for x86_64-solaris * New, rudimentary support for x86-apple-darwin and x86_64-apple-darwin. (Please see https://gmplib.org/macos.html for more information.) Changes between GMP version 4.2 and 4.2.1 Bugs: * Shared library numbers corrected. * Broken support for 32-bit AIX fixed. * Misc minor fixes. Speedups: * Exact division (mpz_divexact) now falls back to plain division for large operands. Features: * Support for some new systems. Changes between GMP version 4.1.4 and 4.2 Bugs: * Minor bug fixes and code generalizations. * Expanded and improved test suite. Speedups: * Many minor optimizations, too many to mention here. * Division now always subquadratic. * Computation of n-factorial much faster. * Added basic x86-64 assembly code. * Floating-point output is now subquadratic for all bases. * FFT multiply code now about 25% faster. * Toom3 multiply code faster. Features: * Much improved configure. * Workarounds for many more compiler bugs. * Temporary allocations are now made on the stack only if small. * New systems supported: HPPA-2.0 gcc, IA-64 HP-UX, PowerPC-64 Darwin, Sparc64 GNU/Linux. * New i386 fat binaries, selecting optimised code at runtime (--enable-fat). * New build option: --enable-profiling=instrument. * New memory function: mp_get_memory_functions. * New Mersenne Twister random numbers: gmp_randinit_mt, also now used for gmp_randinit_default. * New random functions: gmp_randinit_set, gmp_urandomb_ui, gmp_urandomm_ui. * New integer functions: mpz_combit, mpz_rootrem. * gmp_printf etc new type "M" for mp_limb_t. * gmp_scanf and friends now accept C99 hex floats. * Numeric input and output can now be in bases up to 62. * Comparisons mpz_cmp_d, mpz_cmpabs_d, mpf_cmp_d recognise infinities. * Conversions mpz_get_d, mpq_get_d, mpf_get_d truncate towards zero, previously their behaviour was unspecified. * Fixes for overflow issues with operands >= 2^31 bits. Caveats: * mpfr is gone, and will from now on be released only separately. Please see www.mpfr.org. Changes between GMP version 4.1.3 and 4.1.4 * Bug fix to FFT multiplication code (crash for huge operands). * Bug fix to mpf_sub (miscomputation). * Support for powerpc64-gnu-linux. * Better support for AMD64 in 32-bit mode. * Upwardly binary compatible with 4.1.3, 4.1.2, 4.1.1, 4.1, 4.0.1, 4.0, and 3.x versions. Changes between GMP version 4.1.2 and 4.1.3 * Bug fix for FFT multiplication code (miscomputation). * Bug fix to K6 assembly code for gcd. * Bug fix to IA-64 assembly code for population count. * Portability improvements, most notably functional AMD64 support. * mpz_export allows NULL for countp parameter. * Many minor bug fixes. * mpz_export allows NULL for countp parameter. * Upwardly binary compatible with 4.1.2, 4.1.1, 4.1, 4.0.1, 4.0, and 3.x versions. Changes between GMP version 4.1.1 and 4.1.2 * Bug fixes. Changes between GMP version 4.1 and 4.1.1 * Bug fixes. * New systems supported: NetBSD and OpenBSD sparc64. Changes between GMP version 4.0.1 and 4.1 * Bug fixes. * Speed improvements. * Upwardly binary compatible with 4.0, 4.0.1, and 3.x versions. * Asymptotically fast conversion to/from strings (mpz, mpq, mpn levels), but also major speed improvements for tiny operands. * mpn_get_str parameter restrictions relaxed. * Major speed improvements for HPPA 2.0 systems. * Major speed improvements for UltraSPARC systems. * Major speed improvements for IA-64 systems (but still sub-optimal code). * Extended test suite. * mpfr is back, with many bug fixes and portability improvements. * New function: mpz_ui_sub. * New functions: mpz_export, mpz_import. * Optimization for nth root functions (mpz_root, mpz_perfect_power_p). * Optimization for extended gcd (mpz_gcdext, mpz_invert, mpn_gcdext). * Generalized low-level number format, reserving a `nails' part of each limb. (Please note that this is really experimental; some functions are likely to compute garbage when nails are enabled.) * Nails-enabled Alpha 21264 assembly code, allowing up to 75% better performance. (Use --enable-nails=4 to enable it.) Changes between GMP version 4.0 and 4.0.1 * Bug fixes. Changes between GMP version 3.1.1 and 4.0 * Bug fixes. * Speed improvements. * Upwardly binary compatible with 3.x versions. * New CPU support: IA-64, Pentium 4. * Improved CPU support: 21264, Cray vector systems. * Support for all MIPS ABIs: o32, n32, 64. * New systems supported: Darwin, SCO, Windows DLLs. * New divide-and-conquer square root algorithm. * New algorithms chapter in the manual. * New malloc reentrant temporary memory method. * New C++ class interface by Gerardo Ballabio (beta). * Revamped configure, featuring ABI selection. * Speed improvements for mpz_powm and mpz_powm_ui (mainly affecting small operands). * mpz_perfect_power_p now properly recognizes 0, 1, and negative perfect powers. * mpz_hamdist now supports negative operands. * mpz_jacobi now accepts non-positive denominators. * mpz_powm now supports negative exponents. * mpn_mul_1 operand overlap requirements relaxed. * Float input and output uses locale specific decimal point where available. * New gmp_printf, gmp_scanf and related functions. * New division functions: mpz_cdiv_q_2exp, mpz_cdiv_r_2exp, mpz_divexact_ui. * New divisibility tests: mpz_divisible_p, mpz_divisible_ui_p, mpz_divisible_2exp_p, mpz_congruent_p, mpz_congruent_ui_p, mpz_congruent_2exp_p. * New Fibonacci function: mpz_fib2_ui. * New Lucas number functions: mpz_lucnum_ui, mpz_lucnum2_ui. * Other new integer functions: mpz_cmp_d, mpz_cmpabs_d, mpz_get_d_2exp, mpz_init2, mpz_kronecker, mpz_lcm_ui, mpz_realloc2. * New rational I/O: mpq_get_str, mpq_inp_str, mpq_out_str, mpq_set_str. * Other new rational functions: mpq_abs, mpq_cmp_si, mpq_div_2exp, mpq_mul_2exp, mpq_set_f. * New float tests: mpf_integer_p, mpf_fits_sint_p, mpf_fits_slong_p, mpf_fits_sshort_p, mpf_fits_uint_p, mpf_fits_ulong_p, mpf_fits_ushort_p. * Other new float functions: mpf_cmp_d, mpf_get_default_prec, mpf_get_si, mpf_get_ui, mpf_get_d_2exp. * New random functions: gmp_randinit_default, gmp_randinit_lc_2exp_size. * New demo expression string parser (see demos/expr). * New preliminary perl interface (see demos/perl). * Tuned algorithm thresholds for many more CPUs. Changes between GMP version 3.1 and 3.1.1 * Bug fixes for division (rare), mpf_get_str, FFT, and miscellaneous minor things. Changes between GMP version 3.0 and 3.1 * Bug fixes. * Improved `make check' running more tests. * Tuned algorithm cutoff points for many machines. This will improve speed for a lot of operations, in some cases by a large amount. * Major speed improvements: Alpha 21264. * Some speed improvements: Cray vector computers, AMD K6 and Athlon, Intel P5 and Pentium Pro/II/III. * The mpf_get_prec function now works as it did in GMP 2. * New utilities for auto-tuning and speed measuring. * Multiplication now optionally uses FFT for very large operands. (To enable it, pass --enable-fft to configure.) * Support for new systems: Solaris running on x86, FreeBSD 5, HP-UX 11, Cray vector computers, Rhapsody, Nextstep/Openstep, MacOS. * Support for shared libraries on 32-bit HPPA. * New integer functions: mpz_mul_si, mpz_odd_p, mpz_even_p. * New Kronecker symbol functions: mpz_kronecker_si, mpz_kronecker_ui, mpz_si_kronecker, mpz_ui_kronecker. * New rational functions: mpq_out_str, mpq_swap. * New float functions: mpf_swap. * New mpn functions: mpn_divexact_by3c, mpn_tdiv_qr. * New EXPERIMENTAL function layer for accurate floating-point arithmetic, mpfr. To try it, pass --enable-mpfr to configure. See the mpfr subdirectory for more information; it is not documented in the main GMP manual. Changes between GMP version 3.0 and 3.0.1 * Memory leaks in gmp_randinit and mpz_probab_prime_p fixed. * Documentation for gmp_randinit fixed. Misc documentation errors fixed. Changes between GMP version 2.0 and 3.0 * Source level compatibility with past releases (except mpn_gcd). * Bug fixes. * Much improved speed thanks to both host independent and host dependent optimizations. * Switch to autoconf/automake/libtool. * Support for building libgmp as a shared library. * Multiplication and squaring using 3-way Toom-Cook. * Division using the Burnikel-Ziegler method. * New functions computing binomial coefficients: mpz_bin_ui, mpz_bin_uiui. * New function computing Fibonacci numbers: mpz_fib_ui. * New random number generators: mpf_urandomb, mpz_rrandomb, mpz_urandomb, mpz_urandomm, gmp_randclear, gmp_randinit, gmp_randinit_lc_2exp, gmp_randseed, gmp_randseed_ui. * New function for quickly extracting limbs: mpz_getlimbn. * New functions performing integer size tests: mpz_fits_sint_p, mpz_fits_slong_p, mpz_fits_sshort_p, mpz_fits_uint_p, mpz_fits_ulong_p, mpz_fits_ushort_p. * New mpf functions: mpf_ceil, mpf_floor, mpf_pow_ui, mpf_trunc. * New mpq function: mpq_set_d. * New mpz functions: mpz_addmul_ui, mpz_cmpabs, mpz_cmpabs_ui, mpz_lcm, mpz_nextprime, mpz_perfect_power_p, mpz_remove, mpz_root, mpz_swap, mpz_tdiv_ui, mpz_tstbit, mpz_xor. * New mpn function: mpn_divexact_by3. * New CPU support: DEC Alpha 21264, AMD K6 and Athlon, HPPA 2.0 and 64, Intel Pentium Pro and Pentium-II/III, Sparc 64, PowerPC 64. * Almost 10 times faster mpz_invert and mpn_gcdext. * The interface of mpn_gcd has changed. * Better support for MIPS R4x000 and R5000 under Irix 6. * Improved support for SPARCv8 and SPARCv9 processors. Changes between GMP version 2.0 and 2.0.2 * Many bug fixes. Changes between GMP version 1.3.2 and 2.0 * Division routines in the mpz class have changed. There are three classes of functions, that rounds the quotient to -infinity, 0, and +infinity, respectively. The first class of functions have names that begin with mpz_fdiv (f is short for floor), the second class' names begin with mpz_tdiv (t is short for trunc), and the third class' names begin with mpz_cdiv (c is short for ceil). The old division routines beginning with mpz_m are similar to the new mpz_fdiv, with the exception that some of the new functions return useful values. The old function names can still be used. All the old functions names will now do floor division, not trunc division as some of them used to. This was changed to make the functions more compatible with common mathematical practice. The mpz_mod and mpz_mod_ui functions now compute the mathematical mod function. I.e., the sign of the 2nd argument is ignored. * The mpq assignment functions do not canonicalize their results. A new function, mpq_canonicalize must be called by the user if the result is not known to be canonical. * The mpn functions are now documented. These functions are intended for very time critical applications, or applications that need full control over memory allocation. Note that the mpn interface is irregular and hard to use. * New functions for arbitrary precision floating point arithmetic. Names begin with `mpf_'. Associated type mpf_t. * New and improved mpz functions, including much faster GCD, fast exact division (mpz_divexact), bit scan (mpz_scan0 and mpz_scan1), and number theoretical functions like Jacobi (mpz_jacobi) and multiplicative inverse (mpz_invert). * New variable types (mpz_t and mpq_t) are available that makes syntax of mpz and mpq calls nicer (no need for & before variables). The MP_INT and MP_RAT types are still available for compatibility. * Uses GNU configure. This makes it possible to choose target architecture and CPU variant, and to compile into a separate object directory. * Carefully optimized assembly for important inner loops. Support for DEC Alpha, Amd 29000, HPPA 1.0 and 1.1, Intel Pentium and generic x86, Intel i960, Motorola MC68000, MC68020, MC88100, and MC88110, Motorola/IBM PowerPC, National NS32000, IBM POWER, MIPS R3000, R4000, SPARCv7, SuperSPARC, generic SPARCv8, and DEC VAX. Some support also for ARM, Clipper, IBM ROMP (RT), and Pyramid AP/XP. * Faster. Thanks to the assembler code, new algorithms, and general tuning. In particular, the speed on machines without GCC is improved. * Support for machines without alloca. * Now under the LGPL. INCOMPATIBILITIES BETWEEN GMP 1 AND GMP 2 * mpq assignment functions do not canonicalize their results. * mpz division functions round differently. * mpz mod functions now really compute mod. * mpz_powm and mpz_powm_ui now really use mod for reduction. gmp-6.1.0/tal-notreent.c000664 001756 001756 00000007460 12615426624 016244 0ustar00bodratobodrato000000 000000 /* Stack allocation routines. This is intended for machines without support for the `alloca' function. Copyright 1996, 1997, 1999-2001, 2006 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" struct tmp_stack { void *end; void *alloc_point; struct tmp_stack *prev; }; typedef struct tmp_stack tmp_stack; static unsigned long max_total_allocation = 0; static unsigned long current_total_allocation = 0; static tmp_stack xxx = {&xxx, &xxx, 0}; static tmp_stack *current = &xxx; /* The rounded size of the header of each allocation block. */ #define HSIZ ROUND_UP_MULTIPLE (sizeof (tmp_stack), __TMP_ALIGN) /* Allocate a block of exactly bytes. This should only be called through the TMP_ALLOC macro, which takes care of rounding/alignment. */ void * __gmp_tmp_alloc (unsigned long size) { void *that; ASSERT ((size % __TMP_ALIGN) == 0); ASSERT (((unsigned) current->alloc_point % __TMP_ALIGN) == 0); if (size > (char *) current->end - (char *) current->alloc_point) { void *chunk; tmp_stack *header; unsigned long chunk_size; unsigned long now; /* Allocate a chunk that makes the total current allocation somewhat larger than the maximum allocation ever. If size is very large, we allocate that much. */ now = current_total_allocation + size; if (now > max_total_allocation) { /* We need more temporary memory than ever before. Increase for future needs. */ now = (now * 3 / 2 + __TMP_ALIGN - 1) & -__TMP_ALIGN; chunk_size = now - current_total_allocation + HSIZ; current_total_allocation = now; max_total_allocation = current_total_allocation; } else { chunk_size = max_total_allocation - current_total_allocation + HSIZ; current_total_allocation = max_total_allocation; } chunk = (*__gmp_allocate_func) (chunk_size); header = (tmp_stack *) chunk; header->end = (char *) chunk + chunk_size; header->alloc_point = (char *) chunk + HSIZ; header->prev = current; current = header; } that = current->alloc_point; current->alloc_point = (char *) that + size; ASSERT (((unsigned) that % __TMP_ALIGN) == 0); return that; } /* Typically called at function entry. is assigned so that __gmp_tmp_free can later be used to reclaim all subsequently allocated storage. */ void __gmp_tmp_mark (struct tmp_marker *mark) { mark->which_chunk = current; mark->alloc_point = current->alloc_point; } /* Free everything allocated since was assigned by __gmp_tmp_mark */ void __gmp_tmp_free (struct tmp_marker *mark) { while (mark->which_chunk != current) { tmp_stack *tmp; tmp = current; current = tmp->prev; current_total_allocation -= (((char *) (tmp->end) - (char *) tmp) - HSIZ); (*__gmp_free_func) (tmp, (char *) tmp->end - (char *) tmp); } current->alloc_point = mark->alloc_point; } gmp-6.1.0/mp_dv_tab.c000664 001756 001756 00000005772 12615426625 015570 0ustar00bodratobodrato000000 000000 /* __gmp_digit_value_tab -- support for mp*_set_str THE CONTENTS OF THIS FILE ARE FOR INTERNAL USE AND MAY CHANGE INCOMPATIBLY OR DISAPPEAR IN A FUTURE GNU MP RELEASE. Copyright 2003, 2013 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" /* Table to be indexed by character, to get its numerical value. Assumes ASCII character set. First part of table supports common usages, where 'A' and 'a' have the same value; this supports bases 2..36 At offset 208, values for bases 37..62 start. Here, 'A' has the value 10 (in decimal) and 'a' has the value 36. */ #define X 0xff const unsigned char __gmp_digit_value_tab[] = { X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, X, X, X, X, X, X, X,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,34,35,X, X, X, X, X, X,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,34,35,X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, X, X, X, X, X, X, X,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,34,35,X, X, X, X, X, X,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50, 51,52,53,54,55,56,57,58,59,60,61,X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X }; gmp-6.1.0/COPYING000644 001756 001756 00000104513 12572636756 014525 0ustar00bodratobodrato000000 000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . gmp-6.1.0/gen-psqr.c000664 001756 001756 00000042413 12615426624 015361 0ustar00bodratobodrato000000 000000 /* Generate perfect square testing data. Copyright 2002-2004, 2012, 2014 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include #include #include "bootstrap.c" /* The aim of this program is to choose either mpn_mod_34lsub1 or mpn_mod_1 (plus a PERFSQR_PP modulus), and generate tables indicating quadratic residues and non-residues modulo small factors of that modulus. For the usual 32 or 64 bit cases mpn_mod_34lsub1 gets used. That function exists specifically because 2^24-1 and 2^48-1 have nice sets of prime factors. For other limb sizes it's considered, but if it doesn't have good factors then mpn_mod_1 will be used instead. When mpn_mod_1 is used, the modulus PERFSQR_PP is created from a selection of small primes, chosen to fill PERFSQR_MOD_BITS of a limb, with that bit count chosen so (2*GMP_LIMB_BITS)*2^PERFSQR_MOD_BITS <= GMP_LIMB_MAX, allowing PERFSQR_MOD_IDX in mpn/generic/perfsqr.c to do its calculation within a single limb. In either case primes can be combined to make divisors. The table data then effectively indicates remainders which are quadratic residues mod all the primes. This sort of combining reduces the number of steps needed after mpn_mod_34lsub1 or mpn_mod_1, saving code size and time. Nothing is gained or lost in terms of detections, the same total fraction of non-residues will be identified. Nothing particularly sophisticated is attempted for combining factors to make divisors. This is probably a kind of knapsack problem so it'd be too hard to attempt anything completely general. For the usual 32 and 64 bit limbs we get a good enough result just pairing the biggest and smallest which fit together, repeatedly. Another aim is to get powerful combinations, ie. divisors which identify biggest fraction of non-residues, and have those run first. Again for the usual 32 and 64 bits it seems good enough just to pair for big divisors then sort according to the resulting fraction of non-residues identified. Also in this program, a table sq_res_0x100 of residues modulo 256 is generated. This simply fills bits into limbs of the appropriate build-time GMP_LIMB_BITS each. */ /* Normally we aren't using const in gen*.c programs, so as not to have to bother figuring out if it works, but using it with f_cmp_divisor and f_cmp_fraction avoids warnings from the qsort calls. */ /* Same tests as gmp.h. */ #if defined (__STDC__) \ || defined (__cplusplus) \ || defined (_AIX) \ || defined (__DECC) \ || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ || defined (_MSC_VER) \ || defined (_WIN32) #define HAVE_CONST 1 #endif #if ! HAVE_CONST #define const #endif mpz_t *sq_res_0x100; /* table of limbs */ int nsq_res_0x100; /* elements in sq_res_0x100 array */ int sq_res_0x100_num; /* squares in sq_res_0x100 */ double sq_res_0x100_fraction; /* sq_res_0x100_num / 256 */ int mod34_bits; /* 3*GMP_NUMB_BITS/4 */ int mod_bits; /* bits from PERFSQR_MOD_34 or MOD_PP */ int max_divisor; /* all divisors <= max_divisor */ int max_divisor_bits; /* ceil(log2(max_divisor)) */ double total_fraction; /* of squares */ mpz_t pp; /* product of primes, or 0 if mod_34lsub1 used */ mpz_t pp_norm; /* pp shifted so NUMB high bit set */ mpz_t pp_inverted; /* invert_limb style inverse */ mpz_t mod_mask; /* 2^mod_bits-1 */ char mod34_excuse[128]; /* why mod_34lsub1 not used (if it's not) */ /* raw list of divisors of 2^mod34_bits-1 or pp, just to show in a comment */ struct rawfactor_t { int divisor; int multiplicity; }; struct rawfactor_t *rawfactor; int nrawfactor; /* factors of 2^mod34_bits-1 or pp and associated data, after combining etc */ struct factor_t { int divisor; mpz_t inverse; /* 1/divisor mod 2^mod_bits */ mpz_t mask; /* indicating squares mod divisor */ double fraction; /* squares/total */ }; struct factor_t *factor; int nfactor; /* entries in use in factor array */ int factor_alloc; /* entries allocated to factor array */ int f_cmp_divisor (const void *parg, const void *qarg) { const struct factor_t *p, *q; p = (const struct factor_t *) parg; q = (const struct factor_t *) qarg; if (p->divisor > q->divisor) return 1; else if (p->divisor < q->divisor) return -1; else return 0; } int f_cmp_fraction (const void *parg, const void *qarg) { const struct factor_t *p, *q; p = (const struct factor_t *) parg; q = (const struct factor_t *) qarg; if (p->fraction > q->fraction) return 1; else if (p->fraction < q->fraction) return -1; else return 0; } /* Remove array[idx] by copying the remainder down, and adjust narray accordingly. */ #define COLLAPSE_ELEMENT(array, idx, narray) \ do { \ memmove (&(array)[idx], \ &(array)[idx+1], \ ((narray)-((idx)+1)) * sizeof (array[0])); \ (narray)--; \ } while (0) /* return n*2^p mod m */ int mul_2exp_mod (int n, int p, int m) { while (--p >= 0) n = (2 * n) % m; return n; } /* return -n mod m */ int neg_mod (int n, int m) { assert (n >= 0 && n < m); return (n == 0 ? 0 : m-n); } /* Set "mask" to a value such that "mask & (1< max_divisor / i) break; multiplicity++; mpz_set (m, q); mpz_tdiv_qr_ui (q, r, m, (unsigned long) i); } while (mpz_sgn (r) == 0); assert (nrawfactor < factor_alloc); rawfactor[nrawfactor].divisor = i; rawfactor[nrawfactor].multiplicity = multiplicity; nrawfactor++; } mpz_clear (m); mpz_clear (q); mpz_clear (r); } if (nrawfactor <= 2) { mpz_t new_pp; sprintf (mod34_excuse, "only %d small factor%s", nrawfactor, nrawfactor == 1 ? "" : "s"); use_pp: /* reset to two limbs of max_divisor, in case the mpn_mod_34lsub1 code tried with just one */ max_divisor = 2*limb_bits; max_divisor_bits = log2_ceil (max_divisor); mpz_init (new_pp); nrawfactor = 0; mod_bits = MIN (numb_bits, limb_bits - max_divisor_bits); /* one copy of each small prime */ mpz_set_ui (pp, 1L); for (i = 3; i <= max_divisor; i+=2) { if (! isprime (i)) continue; mpz_mul_ui (new_pp, pp, (unsigned long) i); if (mpz_sizeinbase (new_pp, 2) > mod_bits) break; mpz_set (pp, new_pp); assert (nrawfactor < factor_alloc); rawfactor[nrawfactor].divisor = i; rawfactor[nrawfactor].multiplicity = 1; nrawfactor++; } /* Plus an extra copy of one or more of the primes selected, if that still fits in max_divisor and the total in mod_bits. Usually only 3 or 5 will be candidates */ for (i = nrawfactor-1; i >= 0; i--) { if (rawfactor[i].divisor > max_divisor / rawfactor[i].divisor) continue; mpz_mul_ui (new_pp, pp, (unsigned long) rawfactor[i].divisor); if (mpz_sizeinbase (new_pp, 2) > mod_bits) continue; mpz_set (pp, new_pp); rawfactor[i].multiplicity++; } mod_bits = mpz_sizeinbase (pp, 2); mpz_set (pp_norm, pp); while (mpz_sizeinbase (pp_norm, 2) < numb_bits) mpz_add (pp_norm, pp_norm, pp_norm); mpz_preinv_invert (pp_inverted, pp_norm, numb_bits); mpz_clear (new_pp); } /* start the factor array */ for (i = 0; i < nrawfactor; i++) { int j; assert (nfactor < factor_alloc); factor[nfactor].divisor = 1; for (j = 0; j < rawfactor[i].multiplicity; j++) factor[nfactor].divisor *= rawfactor[i].divisor; nfactor++; } combine: /* Combine entries in the factor array. Combine the smallest entry with the biggest one that will fit with it (ie. under max_divisor), then repeat that with the new smallest entry. */ qsort (factor, nfactor, sizeof (factor[0]), f_cmp_divisor); for (i = nfactor-1; i >= 1; i--) { if (factor[i].divisor <= max_divisor / factor[0].divisor) { factor[0].divisor *= factor[i].divisor; COLLAPSE_ELEMENT (factor, i, nfactor); goto combine; } } total_fraction = 1.0; for (i = 0; i < nfactor; i++) { mpz_init (factor[i].inverse); mpz_invert_ui_2exp (factor[i].inverse, (unsigned long) factor[i].divisor, (unsigned long) mod_bits); mpz_init (factor[i].mask); square_mask (factor[i].mask, factor[i].divisor); /* fraction of possible squares */ factor[i].fraction = (double) mpz_popcount (factor[i].mask) / factor[i].divisor; /* total fraction of possible squares */ total_fraction *= factor[i].fraction; } /* best tests first (ie. smallest fraction) */ qsort (factor, nfactor, sizeof (factor[0]), f_cmp_fraction); } void print (int limb_bits, int nail_bits) { int i; mpz_t mhi, mlo; printf ("/* This file generated by gen-psqr.c - DO NOT EDIT. */\n"); printf ("\n"); printf ("#if GMP_LIMB_BITS != %d || GMP_NAIL_BITS != %d\n", limb_bits, nail_bits); printf ("Error, error, this data is for %d bit limb and %d bit nail\n", limb_bits, nail_bits); printf ("#endif\n"); printf ("\n"); printf ("/* Non-zero bit indicates a quadratic residue mod 0x100.\n"); printf (" This test identifies %.2f%% as non-squares (%d/256). */\n", (1.0 - sq_res_0x100_fraction) * 100.0, 0x100 - sq_res_0x100_num); printf ("static const mp_limb_t\n"); printf ("sq_res_0x100[%d] = {\n", nsq_res_0x100); for (i = 0; i < nsq_res_0x100; i++) { printf (" CNST_LIMB(0x"); mpz_out_str (stdout, 16, sq_res_0x100[i]); printf ("),\n"); } printf ("};\n"); printf ("\n"); if (mpz_sgn (pp) != 0) { printf ("/* mpn_mod_34lsub1 not used due to %s */\n", mod34_excuse); printf ("/* PERFSQR_PP = "); } else printf ("/* 2^%d-1 = ", mod34_bits); for (i = 0; i < nrawfactor; i++) { if (i != 0) printf (" * "); printf ("%d", rawfactor[i].divisor); if (rawfactor[i].multiplicity != 1) printf ("^%d", rawfactor[i].multiplicity); } printf (" %s*/\n", mpz_sgn (pp) == 0 ? "... " : ""); printf ("#define PERFSQR_MOD_BITS %d\n", mod_bits); if (mpz_sgn (pp) != 0) { printf ("#define PERFSQR_PP CNST_LIMB(0x"); mpz_out_str (stdout, 16, pp); printf (")\n"); printf ("#define PERFSQR_PP_NORM CNST_LIMB(0x"); mpz_out_str (stdout, 16, pp_norm); printf (")\n"); printf ("#define PERFSQR_PP_INVERTED CNST_LIMB(0x"); mpz_out_str (stdout, 16, pp_inverted); printf (")\n"); } printf ("\n"); mpz_init (mhi); mpz_init (mlo); printf ("/* This test identifies %.2f%% as non-squares. */\n", (1.0 - total_fraction) * 100.0); printf ("#define PERFSQR_MOD_TEST(up, usize) \\\n"); printf (" do { \\\n"); printf (" mp_limb_t r; \\\n"); if (mpz_sgn (pp) != 0) printf (" PERFSQR_MOD_PP (r, up, usize); \\\n"); else printf (" PERFSQR_MOD_34 (r, up, usize); \\\n"); for (i = 0; i < nfactor; i++) { printf (" \\\n"); printf (" /* %5.2f%% */ \\\n", (1.0 - factor[i].fraction) * 100.0); printf (" PERFSQR_MOD_%d (r, CNST_LIMB(%2d), CNST_LIMB(0x", factor[i].divisor <= limb_bits ? 1 : 2, factor[i].divisor); mpz_out_str (stdout, 16, factor[i].inverse); printf ("), \\\n"); printf (" CNST_LIMB(0x"); if ( factor[i].divisor <= limb_bits) { mpz_out_str (stdout, 16, factor[i].mask); } else { mpz_tdiv_r_2exp (mlo, factor[i].mask, (unsigned long) limb_bits); mpz_tdiv_q_2exp (mhi, factor[i].mask, (unsigned long) limb_bits); mpz_out_str (stdout, 16, mhi); printf ("), CNST_LIMB(0x"); mpz_out_str (stdout, 16, mlo); } printf (")); \\\n"); } printf (" } while (0)\n"); printf ("\n"); printf ("/* Grand total sq_res_0x100 and PERFSQR_MOD_TEST, %.2f%% non-squares. */\n", (1.0 - (total_fraction * 44.0/256.0)) * 100.0); printf ("\n"); printf ("/* helper for tests/mpz/t-perfsqr.c */\n"); printf ("#define PERFSQR_DIVISORS { 256,"); for (i = 0; i < nfactor; i++) printf (" %d,", factor[i].divisor); printf (" }\n"); mpz_clear (mhi); mpz_clear (mlo); } int main (int argc, char *argv[]) { int limb_bits, nail_bits; if (argc != 3) { fprintf (stderr, "Usage: gen-psqr \n"); exit (1); } limb_bits = atoi (argv[1]); nail_bits = atoi (argv[2]); if (limb_bits <= 0 || nail_bits < 0 || nail_bits >= limb_bits) { fprintf (stderr, "Invalid limb/nail bits: %d %d\n", limb_bits, nail_bits); exit (1); } generate_sq_res_0x100 (limb_bits); generate_mod (limb_bits, nail_bits); print (limb_bits, nail_bits); return 0; } gmp-6.1.0/rand/000755 001756 001756 00000000000 12615426653 014401 5ustar00bodratobodrato000000 000000 gmp-6.1.0/config.in000664 001756 001756 00000045667 12615426632 015273 0ustar00bodratobodrato000000 000000 /* config.in. Generated from configure.ac by autoheader. */ /* Copyright 1996-2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* The gmp-mparam.h file (a string) the tune program should suggest updating. */ #undef GMP_MPARAM_H_SUGGEST /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if alloca() works (via gmp-impl.h). */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if the compiler accepts gcc style __attribute__ ((const)) */ #undef HAVE_ATTRIBUTE_CONST /* Define to 1 if the compiler accepts gcc style __attribute__ ((malloc)) */ #undef HAVE_ATTRIBUTE_MALLOC /* Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX))) */ #undef HAVE_ATTRIBUTE_MODE /* Define to 1 if the compiler accepts gcc style __attribute__ ((noreturn)) */ #undef HAVE_ATTRIBUTE_NORETURN /* Define to 1 if you have the `attr_get' function. */ #undef HAVE_ATTR_GET /* Define to 1 if tests/libtests has calling conventions checking for the CPU */ #undef HAVE_CALLING_CONVENTIONS /* Define to 1 if you have the `clock' function. */ #undef HAVE_CLOCK /* Define to 1 if you have the `clock_gettime' function */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the `cputime' function. */ #undef HAVE_CPUTIME /* Define to 1 if you have the declaration of `fgetc', and to 0 if you don't. */ #undef HAVE_DECL_FGETC /* Define to 1 if you have the declaration of `fscanf', and to 0 if you don't. */ #undef HAVE_DECL_FSCANF /* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */ #undef HAVE_DECL_OPTARG /* Define to 1 if you have the declaration of `sys_errlist', and to 0 if you don't. */ #undef HAVE_DECL_SYS_ERRLIST /* Define to 1 if you have the declaration of `sys_nerr', and to 0 if you don't. */ #undef HAVE_DECL_SYS_NERR /* Define to 1 if you have the declaration of `ungetc', and to 0 if you don't. */ #undef HAVE_DECL_UNGETC /* Define to 1 if you have the declaration of `vfprintf', and to 0 if you don't. */ #undef HAVE_DECL_VFPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define one of the following to 1 for the format of a `double'. If your format is not among these choices, or you don't know what it is, then leave all undefined. IEEE_LITTLE_SWAPPED means little endian, but with the two 4-byte halves swapped, as used by ARM CPUs in little endian mode. */ #undef HAVE_DOUBLE_IEEE_BIG_ENDIAN #undef HAVE_DOUBLE_IEEE_LITTLE_ENDIAN #undef HAVE_DOUBLE_IEEE_LITTLE_SWAPPED #undef HAVE_DOUBLE_VAX_D #undef HAVE_DOUBLE_VAX_G #undef HAVE_DOUBLE_CRAY_CFP /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_FLOAT_H /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE /* Define to 1 if you have the `getrusage' function. */ #undef HAVE_GETRUSAGE /* Define to 1 if you have the `getsysinfo' function. */ #undef HAVE_GETSYSINFO /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if the compiler accepts gcc style __attribute__ ((visibility)) and __attribute__ ((alias)) */ #undef HAVE_HIDDEN_ALIAS /* Define one of these to 1 for the host CPU family. If your CPU is not in any of these families, leave all undefined. For an AMD64 chip, define "x86" in ABI=32, but not in ABI=64. */ #undef HAVE_HOST_CPU_FAMILY_alpha #undef HAVE_HOST_CPU_FAMILY_m68k #undef HAVE_HOST_CPU_FAMILY_power #undef HAVE_HOST_CPU_FAMILY_powerpc #undef HAVE_HOST_CPU_FAMILY_x86 #undef HAVE_HOST_CPU_FAMILY_x86_64 /* Define one of the following to 1 for the host CPU, as per the output of ./config.guess. If your CPU is not listed here, leave all undefined. */ #undef HAVE_HOST_CPU_alphaev67 #undef HAVE_HOST_CPU_alphaev68 #undef HAVE_HOST_CPU_alphaev7 #undef HAVE_HOST_CPU_m68020 #undef HAVE_HOST_CPU_m68030 #undef HAVE_HOST_CPU_m68040 #undef HAVE_HOST_CPU_m68060 #undef HAVE_HOST_CPU_m68360 #undef HAVE_HOST_CPU_powerpc604 #undef HAVE_HOST_CPU_powerpc604e #undef HAVE_HOST_CPU_powerpc750 #undef HAVE_HOST_CPU_powerpc7400 #undef HAVE_HOST_CPU_supersparc #undef HAVE_HOST_CPU_i386 #undef HAVE_HOST_CPU_i586 #undef HAVE_HOST_CPU_i686 #undef HAVE_HOST_CPU_pentium #undef HAVE_HOST_CPU_pentiummmx #undef HAVE_HOST_CPU_pentiumpro #undef HAVE_HOST_CPU_pentium2 #undef HAVE_HOST_CPU_pentium3 #undef HAVE_HOST_CPU_s390_z900 #undef HAVE_HOST_CPU_s390_z990 #undef HAVE_HOST_CPU_s390_z9 #undef HAVE_HOST_CPU_s390_z10 #undef HAVE_HOST_CPU_s390_z196 /* Define to 1 iff we have a s390 with 64-bit registers. */ #undef HAVE_HOST_CPU_s390_zarch /* Define to 1 if the system has the type `intmax_t'. */ #undef HAVE_INTMAX_T /* Define to 1 if the system has the type `intptr_t'. */ #undef HAVE_INTPTR_T /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_INVENT_H /* Define to 1 if you have the header file. */ #undef HAVE_LANGINFO_H /* Define one of these to 1 for the endianness of `mp_limb_t'. If the endianness is not a simple big or little, or you don't know what it is, then leave both undefined. */ #undef HAVE_LIMB_BIG_ENDIAN #undef HAVE_LIMB_LITTLE_ENDIAN /* Define to 1 if you have the `localeconv' function. */ #undef HAVE_LOCALECONV /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if the system has the type `long double'. */ #undef HAVE_LONG_DOUBLE /* Define to 1 if the system has the type `long long'. */ #undef HAVE_LONG_LONG /* Define to 1 if you have the header file. */ #undef HAVE_MACHINE_HAL_SYSINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP /* Define to 1 if you have the `mprotect' function. */ #undef HAVE_MPROTECT /* Define to 1 each of the following for which a native (ie. CPU specific) implementation of the corresponding routine exists. */ #undef HAVE_NATIVE_mpn_add_n #undef HAVE_NATIVE_mpn_add_n_sub_n #undef HAVE_NATIVE_mpn_add_nc #undef HAVE_NATIVE_mpn_addaddmul_1msb0 #undef HAVE_NATIVE_mpn_addlsh1_n #undef HAVE_NATIVE_mpn_addlsh2_n #undef HAVE_NATIVE_mpn_addlsh_n #undef HAVE_NATIVE_mpn_addlsh1_nc #undef HAVE_NATIVE_mpn_addlsh2_nc #undef HAVE_NATIVE_mpn_addlsh_nc #undef HAVE_NATIVE_mpn_addlsh1_n_ip1 #undef HAVE_NATIVE_mpn_addlsh2_n_ip1 #undef HAVE_NATIVE_mpn_addlsh_n_ip1 #undef HAVE_NATIVE_mpn_addlsh1_nc_ip1 #undef HAVE_NATIVE_mpn_addlsh2_nc_ip1 #undef HAVE_NATIVE_mpn_addlsh_nc_ip1 #undef HAVE_NATIVE_mpn_addlsh1_n_ip2 #undef HAVE_NATIVE_mpn_addlsh2_n_ip2 #undef HAVE_NATIVE_mpn_addlsh_n_ip2 #undef HAVE_NATIVE_mpn_addlsh1_nc_ip2 #undef HAVE_NATIVE_mpn_addlsh2_nc_ip2 #undef HAVE_NATIVE_mpn_addlsh_nc_ip2 #undef HAVE_NATIVE_mpn_addmul_1c #undef HAVE_NATIVE_mpn_addmul_2 #undef HAVE_NATIVE_mpn_addmul_3 #undef HAVE_NATIVE_mpn_addmul_4 #undef HAVE_NATIVE_mpn_addmul_5 #undef HAVE_NATIVE_mpn_addmul_6 #undef HAVE_NATIVE_mpn_addmul_7 #undef HAVE_NATIVE_mpn_addmul_8 #undef HAVE_NATIVE_mpn_addmul_2s #undef HAVE_NATIVE_mpn_and_n #undef HAVE_NATIVE_mpn_andn_n #undef HAVE_NATIVE_mpn_bdiv_dbm1c #undef HAVE_NATIVE_mpn_bdiv_q_1 #undef HAVE_NATIVE_mpn_pi1_bdiv_q_1 #undef HAVE_NATIVE_mpn_cnd_add_n #undef HAVE_NATIVE_mpn_cnd_sub_n #undef HAVE_NATIVE_mpn_com #undef HAVE_NATIVE_mpn_copyd #undef HAVE_NATIVE_mpn_copyi #undef HAVE_NATIVE_mpn_div_qr_1n_pi1 #undef HAVE_NATIVE_mpn_div_qr_2 #undef HAVE_NATIVE_mpn_divexact_1 #undef HAVE_NATIVE_mpn_divexact_by3c #undef HAVE_NATIVE_mpn_divrem_1 #undef HAVE_NATIVE_mpn_divrem_1c #undef HAVE_NATIVE_mpn_divrem_2 #undef HAVE_NATIVE_mpn_gcd_1 #undef HAVE_NATIVE_mpn_hamdist #undef HAVE_NATIVE_mpn_invert_limb #undef HAVE_NATIVE_mpn_ior_n #undef HAVE_NATIVE_mpn_iorn_n #undef HAVE_NATIVE_mpn_lshift #undef HAVE_NATIVE_mpn_lshiftc #undef HAVE_NATIVE_mpn_lshsub_n #undef HAVE_NATIVE_mpn_mod_1 #undef HAVE_NATIVE_mpn_mod_1_1p #undef HAVE_NATIVE_mpn_mod_1c #undef HAVE_NATIVE_mpn_mod_1s_2p #undef HAVE_NATIVE_mpn_mod_1s_4p #undef HAVE_NATIVE_mpn_mod_34lsub1 #undef HAVE_NATIVE_mpn_modexact_1_odd #undef HAVE_NATIVE_mpn_modexact_1c_odd #undef HAVE_NATIVE_mpn_mul_1 #undef HAVE_NATIVE_mpn_mul_1c #undef HAVE_NATIVE_mpn_mul_2 #undef HAVE_NATIVE_mpn_mul_3 #undef HAVE_NATIVE_mpn_mul_4 #undef HAVE_NATIVE_mpn_mul_5 #undef HAVE_NATIVE_mpn_mul_6 #undef HAVE_NATIVE_mpn_mul_basecase #undef HAVE_NATIVE_mpn_mullo_basecase #undef HAVE_NATIVE_mpn_nand_n #undef HAVE_NATIVE_mpn_nior_n #undef HAVE_NATIVE_mpn_popcount #undef HAVE_NATIVE_mpn_preinv_divrem_1 #undef HAVE_NATIVE_mpn_preinv_mod_1 #undef HAVE_NATIVE_mpn_redc_1 #undef HAVE_NATIVE_mpn_redc_2 #undef HAVE_NATIVE_mpn_rsblsh1_n #undef HAVE_NATIVE_mpn_rsblsh2_n #undef HAVE_NATIVE_mpn_rsblsh_n #undef HAVE_NATIVE_mpn_rsblsh1_nc #undef HAVE_NATIVE_mpn_rsblsh2_nc #undef HAVE_NATIVE_mpn_rsblsh_nc #undef HAVE_NATIVE_mpn_rsh1add_n #undef HAVE_NATIVE_mpn_rsh1add_nc #undef HAVE_NATIVE_mpn_rsh1sub_n #undef HAVE_NATIVE_mpn_rsh1sub_nc #undef HAVE_NATIVE_mpn_rshift #undef HAVE_NATIVE_mpn_sqr_basecase #undef HAVE_NATIVE_mpn_sqr_diagonal #undef HAVE_NATIVE_mpn_sqr_diag_addlsh1 #undef HAVE_NATIVE_mpn_sub_n #undef HAVE_NATIVE_mpn_sub_nc #undef HAVE_NATIVE_mpn_sublsh1_n #undef HAVE_NATIVE_mpn_sublsh2_n #undef HAVE_NATIVE_mpn_sublsh_n #undef HAVE_NATIVE_mpn_sublsh1_nc #undef HAVE_NATIVE_mpn_sublsh2_nc #undef HAVE_NATIVE_mpn_sublsh_nc #undef HAVE_NATIVE_mpn_sublsh1_n_ip1 #undef HAVE_NATIVE_mpn_sublsh2_n_ip1 #undef HAVE_NATIVE_mpn_sublsh_n_ip1 #undef HAVE_NATIVE_mpn_sublsh1_nc_ip1 #undef HAVE_NATIVE_mpn_sublsh2_nc_ip1 #undef HAVE_NATIVE_mpn_sublsh_nc_ip1 #undef HAVE_NATIVE_mpn_submul_1c #undef HAVE_NATIVE_mpn_tabselect #undef HAVE_NATIVE_mpn_udiv_qrnnd #undef HAVE_NATIVE_mpn_udiv_qrnnd_r #undef HAVE_NATIVE_mpn_umul_ppmm #undef HAVE_NATIVE_mpn_umul_ppmm_r #undef HAVE_NATIVE_mpn_xor_n #undef HAVE_NATIVE_mpn_xnor_n /* Define to 1 if you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO /* Define to 1 if you have the header file. */ #undef HAVE_NL_TYPES_H /* Define to 1 if you have the `obstack_vprintf' function. */ #undef HAVE_OBSTACK_VPRINTF /* Define to 1 if you have the `popen' function. */ #undef HAVE_POPEN /* Define to 1 if you have the `processor_info' function. */ #undef HAVE_PROCESSOR_INFO /* Define to 1 if `struct pst_processor' exists and contains `psp_iticksperclktick'. */ #undef HAVE_PSP_ITICKSPERCLKTICK /* Define to 1 if you have the `pstat_getprocessor' function. */ #undef HAVE_PSTAT_GETPROCESSOR /* Define to 1 if the system has the type `ptrdiff_t'. */ #undef HAVE_PTRDIFF_T /* Define to 1 if the system has the type `quad_t'. */ #undef HAVE_QUAD_T /* Define to 1 if you have the `raise' function. */ #undef HAVE_RAISE /* Define to 1 if you have the `read_real_time' function. */ #undef HAVE_READ_REAL_TIME /* Define to 1 if you have the `sigaction' function. */ #undef HAVE_SIGACTION /* Define to 1 if you have the `sigaltstack' function. */ #undef HAVE_SIGALTSTACK /* Define to 1 if you have the `sigstack' function. */ #undef HAVE_SIGSTACK /* Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits) */ #undef HAVE_SPEED_CYCLECOUNTER /* Define to 1 if you have the header file. */ #undef HAVE_SSTREAM /* Define to 1 if the system has the type `stack_t'. */ #undef HAVE_STACK_T /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if the system has the type `std::locale'. */ #undef HAVE_STD__LOCALE /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strnlen' function. */ #undef HAVE_STRNLEN /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL /* Define to 1 if you have the `sysconf' function. */ #undef HAVE_SYSCONF /* Define to 1 if you have the `sysctl' function. */ #undef HAVE_SYSCTL /* Define to 1 if you have the `sysctlbyname' function. */ #undef HAVE_SYSCTLBYNAME /* Define to 1 if you have the `syssgi' function. */ #undef HAVE_SYSSGI /* Define to 1 if you have the header file. */ #undef HAVE_SYS_ATTRIBUTES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOGRAPH_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MMAN_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PROCESSOR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PSTAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_RESOURCE_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSSGI_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSTEMCFG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIMES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the `times' function. */ #undef HAVE_TIMES /* Define to 1 if the system has the type `uint_least32_t'. */ #undef HAVE_UINT_LEAST32_T /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vsnprintf' function and it works properly. */ #undef HAVE_VSNPRINTF /* Define to 1 for Windos/64 */ #undef HOST_DOS64 /* Assembler local label prefix */ #undef LSYM_PREFIX /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* The size of `mp_limb_t', as computed by sizeof. */ #undef SIZEOF_MP_LIMB_T /* The size of `unsigned', as computed by sizeof. */ #undef SIZEOF_UNSIGNED /* The size of `unsigned long', as computed by sizeof. */ #undef SIZEOF_UNSIGNED_LONG /* The size of `unsigned short', as computed by sizeof. */ #undef SIZEOF_UNSIGNED_SHORT /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P /* Define to 1 if sscanf requires writable inputs */ #undef SSCANF_WRITABLE_INPUT /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Maximum size the tune program can test for SQR_TOOM2_THRESHOLD */ #undef TUNE_SQR_TOOM2_MAX /* Version number of package */ #undef VERSION /* Defined to 1 as per --enable-assembly */ #undef WANT_ASSEMBLY /* Define to 1 to enable ASSERT checking, per --enable-assert */ #undef WANT_ASSERT /* Define to 1 to enable GMP_CPU_TYPE faking cpuid, per --enable-fake-cpuid */ #undef WANT_FAKE_CPUID /* Define to 1 when building a fat binary. */ #undef WANT_FAT_BINARY /* Define to 1 to enable FFTs for multiplication, per --enable-fft */ #undef WANT_FFT /* Define to 1 to enable old mpn_mul_fft_full for multiplication, per --enable-old-fft-full */ #undef WANT_OLD_FFT_FULL /* Define to 1 if --enable-profiling=gprof */ #undef WANT_PROFILING_GPROF /* Define to 1 if --enable-profiling=instrument */ #undef WANT_PROFILING_INSTRUMENT /* Define to 1 if --enable-profiling=prof */ #undef WANT_PROFILING_PROF /* Define one of these to 1 for the desired temporary memory allocation method, per --enable-alloca. */ #undef WANT_TMP_ALLOCA #undef WANT_TMP_REENTRANT #undef WANT_TMP_NOTREENTRANT #undef WANT_TMP_DEBUG /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #undef YYTEXT_POINTER /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ #undef restrict /* Work around a bug in Sun C++: it does not support _Restrict or __restrict__, even though the corresponding Sun C compiler ends up with "#define restrict _Restrict" or "#define restrict __restrict__" in the previous line. Perhaps some future version of Sun C++ will work with restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ #if defined __SUNPRO_CC && !defined __RESTRICT # define _Restrict # define __restrict__ #endif /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile gmp-6.1.0/gmp-h.in000664 001756 001756 00000243762 12615426624 015033 0ustar00bodratobodrato000000 000000 /* Definitions for GNU multiple precision functions. -*- mode: c -*- Copyright 1991, 1993-1997, 1999-2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #ifndef __GMP_H__ #if defined (__cplusplus) #include /* for std::istream, std::ostream, std::string */ #include #endif /* Instantiated by configure. */ #if ! defined (__GMP_WITHIN_CONFIGURE) #define __GMP_HAVE_HOST_CPU_FAMILY_power @HAVE_HOST_CPU_FAMILY_power@ #define __GMP_HAVE_HOST_CPU_FAMILY_powerpc @HAVE_HOST_CPU_FAMILY_powerpc@ #define GMP_LIMB_BITS @GMP_LIMB_BITS@ #define GMP_NAIL_BITS @GMP_NAIL_BITS@ #endif #define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS) #define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS) #define GMP_NUMB_MAX GMP_NUMB_MASK #define GMP_NAIL_MASK (~ GMP_NUMB_MASK) /* The following (everything under ifndef __GNU_MP__) must be identical in gmp.h and mp.h to allow both to be included in an application or during the library build. */ #ifndef __GNU_MP__ #define __GNU_MP__ 5 #include /* for size_t */ #include /* Instantiated by configure. */ #if ! defined (__GMP_WITHIN_CONFIGURE) @DEFN_LONG_LONG_LIMB@ #define __GMP_LIBGMP_DLL @LIBGMP_DLL@ #endif /* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in all other circumstances. When compiling objects for libgmp, __GMP_DECLSPEC is an export directive, or when compiling for an application it's an import directive. The two cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles (and not defined from an application). __GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX indicates when building libgmpxx, and in that case libgmpxx functions are exports, but libgmp functions which might get called are imports. Libtool DLL_EXPORT define is not used. There's no attempt to support GMP built both static and DLL. Doing so would mean applications would have to tell us which of the two is going to be used when linking, and that seems very tedious and error prone if using GMP by hand, and equally tedious from a package since autoconf and automake don't give much help. __GMP_DECLSPEC is required on all documented global functions and variables, the various internals in gmp-impl.h etc can be left unadorned. But internals used by the test programs or speed measuring programs should have __GMP_DECLSPEC, and certainly constants or variables must have it or the wrong address will be resolved. In gcc __declspec can go at either the start or end of a prototype. In Microsoft C __declspec must go at the start, or after the type like void __declspec(...) *foo()". There's no __dllexport or anything to guard against someone foolish #defining dllexport. _export used to be available, but no longer. In Borland C _export still exists, but needs to go after the type, like "void _export foo();". Would have to change the __GMP_DECLSPEC syntax to make use of that. Probably more trouble than it's worth. */ #if defined (__GNUC__) #define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__) #define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__) #endif #if defined (_MSC_VER) || defined (__BORLANDC__) #define __GMP_DECLSPEC_EXPORT __declspec(dllexport) #define __GMP_DECLSPEC_IMPORT __declspec(dllimport) #endif #ifdef __WATCOMC__ #define __GMP_DECLSPEC_EXPORT __export #define __GMP_DECLSPEC_IMPORT __import #endif #ifdef __IBMC__ #define __GMP_DECLSPEC_EXPORT _Export #define __GMP_DECLSPEC_IMPORT _Import #endif #if __GMP_LIBGMP_DLL #ifdef __GMP_WITHIN_GMP /* compiling to go into a DLL libgmp */ #define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT #else /* compiling to go into an application which will link to a DLL libgmp */ #define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT #endif #else /* all other cases */ #define __GMP_DECLSPEC #endif #ifdef __GMP_SHORT_LIMB typedef unsigned int mp_limb_t; typedef int mp_limb_signed_t; #else #ifdef _LONG_LONG_LIMB typedef unsigned long long int mp_limb_t; typedef long long int mp_limb_signed_t; #else typedef unsigned long int mp_limb_t; typedef long int mp_limb_signed_t; #endif #endif typedef unsigned long int mp_bitcnt_t; /* For reference, note that the name __mpz_struct gets into C++ mangled function names, which means although the "__" suggests an internal, we must leave this name for binary compatibility. */ typedef struct { int _mp_alloc; /* Number of *limbs* allocated and pointed to by the _mp_d field. */ int _mp_size; /* abs(_mp_size) is the number of limbs the last field points to. If _mp_size is negative this is a negative number. */ mp_limb_t *_mp_d; /* Pointer to the limbs. */ } __mpz_struct; #endif /* __GNU_MP__ */ typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */ typedef __mpz_struct mpz_t[1]; typedef mp_limb_t * mp_ptr; typedef const mp_limb_t * mp_srcptr; #if defined (_CRAY) && ! defined (_CRAYMPP) /* plain `int' is much faster (48 bits) */ #define __GMP_MP_SIZE_T_INT 1 typedef int mp_size_t; typedef int mp_exp_t; #else #define __GMP_MP_SIZE_T_INT 0 typedef long int mp_size_t; typedef long int mp_exp_t; #endif typedef struct { __mpz_struct _mp_num; __mpz_struct _mp_den; } __mpq_struct; typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */ typedef __mpq_struct mpq_t[1]; typedef struct { int _mp_prec; /* Max precision, in number of `mp_limb_t's. Set by mpf_init and modified by mpf_set_prec. The area pointed to by the _mp_d field contains `prec' + 1 limbs. */ int _mp_size; /* abs(_mp_size) is the number of limbs the last field points to. If _mp_size is negative this is a negative number. */ mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */ mp_limb_t *_mp_d; /* Pointer to the limbs. */ } __mpf_struct; /* typedef __mpf_struct MP_FLOAT; */ typedef __mpf_struct mpf_t[1]; /* Available random number generation algorithms. */ typedef enum { GMP_RAND_ALG_DEFAULT = 0, GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */ } gmp_randalg_t; /* Random state struct. */ typedef struct { mpz_t _mp_seed; /* _mp_d member points to state of the generator. */ gmp_randalg_t _mp_alg; /* Currently unused. */ union { void *_mp_lc; /* Pointer to function pointers structure. */ } _mp_algdata; } __gmp_randstate_struct; typedef __gmp_randstate_struct gmp_randstate_t[1]; /* Types for function declarations in gmp files. */ /* ??? Should not pollute user name space with these ??? */ typedef const __mpz_struct *mpz_srcptr; typedef __mpz_struct *mpz_ptr; typedef const __mpf_struct *mpf_srcptr; typedef __mpf_struct *mpf_ptr; typedef const __mpq_struct *mpq_srcptr; typedef __mpq_struct *mpq_ptr; /* This is not wanted in mp.h, so put it outside the __GNU_MP__ common section. */ #if __GMP_LIBGMP_DLL #ifdef __GMP_WITHIN_GMPXX /* compiling to go into a DLL libgmpxx */ #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT #else /* compiling to go into a application which will link to a DLL libgmpxx */ #define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT #endif #else /* all other cases */ #define __GMP_DECLSPEC_XX #endif #ifndef __MPN #define __MPN(x) __gmpn_##x #endif /* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4, defines EOF but not FILE. */ #if defined (FILE) \ || defined (H_STDIO) \ || defined (_H_STDIO) /* AIX */ \ || defined (_STDIO_H) /* glibc, Sun, SCO */ \ || defined (_STDIO_H_) /* BSD, OSF */ \ || defined (__STDIO_H) /* Borland */ \ || defined (__STDIO_H__) /* IRIX */ \ || defined (_STDIO_INCLUDED) /* HPUX */ \ || defined (__dj_include_stdio_h_) /* DJGPP */ \ || defined (_FILE_DEFINED) /* Microsoft */ \ || defined (__STDIO__) /* Apple MPW MrC */ \ || defined (_MSL_STDIO_H) /* Metrowerks */ \ || defined (_STDIO_H_INCLUDED) /* QNX4 */ \ || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \ || defined (__STDIO_LOADED) /* VMS */ #define _GMP_H_HAVE_FILE 1 #endif /* In ISO C, if a prototype involving "struct obstack *" is given without that structure defined, then the struct is scoped down to just the prototype, causing a conflict if it's subsequently defined for real. So only give prototypes if we've got obstack.h. */ #if defined (_OBSTACK_H) /* glibc */ #define _GMP_H_HAVE_OBSTACK 1 #endif /* The prototypes for gmp_vprintf etc are provided only if va_list is defined, via an application having included . Usually va_list is a typedef so can't be tested directly, but C99 specifies that va_start is a macro. will define some sort of va_list for vprintf and vfprintf, but let's not bother trying to use that since it's not standard and since application uses for gmp_vprintf etc will almost certainly require the whole anyway. */ #ifdef va_start #define _GMP_H_HAVE_VA_LIST 1 #endif /* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */ #if defined (__GNUC__) && defined (__GNUC_MINOR__) #define __GMP_GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) #else #define __GMP_GNUC_PREREQ(maj, min) 0 #endif /* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically it means a function does nothing but examine its arguments and memory (global or via arguments) to generate a return value, but changes nothing and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets tune/common.c etc turn this off when trying to write timing loops. */ #if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE) #define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else #define __GMP_ATTRIBUTE_PURE #endif /* __GMP_CAST allows us to use static_cast in C++, so our macros are clean to "g++ -Wold-style-cast". Casts in "extern inline" code within an extern "C" block don't induce these warnings, so __GMP_CAST only needs to be used on documented macros. */ #ifdef __cplusplus #define __GMP_CAST(type, expr) (static_cast (expr)) #else #define __GMP_CAST(type, expr) ((type) (expr)) #endif /* An empty "throw ()" means the function doesn't throw any C++ exceptions, this can save some stack frame info in applications. Currently it's given only on functions which never divide-by-zero etc, don't allocate memory, and are expected to never need to allocate memory. This leaves open the possibility of a C++ throw from a future GMP exceptions scheme. mpz_set_ui etc are omitted to leave open the lazy allocation scheme described in doc/tasks.html. mpz_get_d etc are omitted to leave open exceptions for float overflows. Note that __GMP_NOTHROW must be given on any inlines the same as on their prototypes (for g++ at least, where they're used together). Note also that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like __GMP_ATTRIBUTE_PURE. */ #if defined (__cplusplus) #define __GMP_NOTHROW throw () #else #define __GMP_NOTHROW #endif /* PORTME: What other compilers have a useful "extern inline"? "static inline" would be an acceptable substitute if the compiler (or linker) discards unused statics. */ /* gcc has __inline__ in all modes, including strict ansi. Give a prototype for an inline too, so as to correctly specify "dllimport" on windows, in case the function is called rather than inlined. GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 inline semantics, unless -fgnu89-inline is used. */ #ifdef __GNUC__ #if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \ || (defined __GNUC_GNU_INLINE__ && defined __cplusplus) #define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__)) #else #define __GMP_EXTERN_INLINE extern __inline__ #endif #define __GMP_INLINE_PROTOTYPES 1 #endif /* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1 strict ANSI mode. Inlining is done even when not optimizing (ie. -O0 mode, which is the default), but an unnecessary local copy of foo is emitted unless -O is used. "extern __inline" is accepted, but the "extern" appears to be ignored, ie. it becomes a plain global function but which is inlined within its file. Don't know if all old versions of DEC C supported __inline, but as a start let's do the right thing for current versions. */ #ifdef __DECC #define __GMP_EXTERN_INLINE static __inline #endif /* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes place under -O. Without -O "foo" seems to be emitted whether it's used or not, which is wasteful. "extern inline foo()" isn't useful, the "extern" is apparently ignored, so foo is inlined if possible but also emitted as a global, which causes multiple definition errors when building a shared libgmp. */ #ifdef __SCO_VERSION__ #if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \ && ! defined (__GMP_EXTERN_INLINE) #define __GMP_EXTERN_INLINE static inline #endif #endif /* Microsoft's C compiler accepts __inline */ #ifdef _MSC_VER #define __GMP_EXTERN_INLINE __inline #endif /* Recent enough Sun C compilers want "inline" */ #if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \ && ! defined (__GMP_EXTERN_INLINE) #define __GMP_EXTERN_INLINE inline #endif /* Somewhat older Sun C compilers want "static inline" */ #if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \ && ! defined (__GMP_EXTERN_INLINE) #define __GMP_EXTERN_INLINE static inline #endif /* C++ always has "inline" and since it's a normal feature the linker should discard duplicate non-inlined copies, or if it doesn't then that's a problem for everyone, not just GMP. */ #if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE) #define __GMP_EXTERN_INLINE inline #endif /* Don't do any inlining within a configure run, since if the compiler ends up emitting copies of the code into the object file it can end up demanding the various support routines (like mpn_popcount) for linking, making the "alloca" test and perhaps others fail. And on hppa ia64 a pre-release gcc 3.2 was seen not respecting the "extern" in "extern __inline__", triggering this problem too. */ #if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE #undef __GMP_EXTERN_INLINE #endif /* By default, don't give a prototype when there's going to be an inline version. Note in particular that Cray C++ objects to the combination of prototype and inline. */ #ifdef __GMP_EXTERN_INLINE #ifndef __GMP_INLINE_PROTOTYPES #define __GMP_INLINE_PROTOTYPES 0 #endif #else #define __GMP_INLINE_PROTOTYPES 1 #endif #define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x)) #define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i)) /* __builtin_expect is in gcc 3.0, and not in 2.95. */ #if __GMP_GNUC_PREREQ (3,0) #define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1) #define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0) #else #define __GMP_LIKELY(cond) (cond) #define __GMP_UNLIKELY(cond) (cond) #endif #ifdef _CRAY #define __GMP_CRAY_Pragma(str) _Pragma (str) #else #define __GMP_CRAY_Pragma(str) #endif /* Allow direct user access to numerator and denominator of an mpq_t object. */ #define mpq_numref(Q) (&((Q)->_mp_num)) #define mpq_denref(Q) (&((Q)->_mp_den)) #if defined (__cplusplus) extern "C" { using std::FILE; #endif #define mp_set_memory_functions __gmp_set_memory_functions __GMP_DECLSPEC void mp_set_memory_functions (void *(*) (size_t), void *(*) (void *, size_t, size_t), void (*) (void *, size_t)) __GMP_NOTHROW; #define mp_get_memory_functions __gmp_get_memory_functions __GMP_DECLSPEC void mp_get_memory_functions (void *(**) (size_t), void *(**) (void *, size_t, size_t), void (**) (void *, size_t)) __GMP_NOTHROW; #define mp_bits_per_limb __gmp_bits_per_limb __GMP_DECLSPEC extern const int mp_bits_per_limb; #define gmp_errno __gmp_errno __GMP_DECLSPEC extern int gmp_errno; #define gmp_version __gmp_version __GMP_DECLSPEC extern const char * const gmp_version; /**************** Random number routines. ****************/ /* obsolete */ #define gmp_randinit __gmp_randinit __GMP_DECLSPEC void gmp_randinit (gmp_randstate_t, gmp_randalg_t, ...); #define gmp_randinit_default __gmp_randinit_default __GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_t); #define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp __GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t); #define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size __GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_t, mp_bitcnt_t); #define gmp_randinit_mt __gmp_randinit_mt __GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_t); #define gmp_randinit_set __gmp_randinit_set __GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_t, const __gmp_randstate_struct *); #define gmp_randseed __gmp_randseed __GMP_DECLSPEC void gmp_randseed (gmp_randstate_t, mpz_srcptr); #define gmp_randseed_ui __gmp_randseed_ui __GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_t, unsigned long int); #define gmp_randclear __gmp_randclear __GMP_DECLSPEC void gmp_randclear (gmp_randstate_t); #define gmp_urandomb_ui __gmp_urandomb_ui __GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_t, unsigned long); #define gmp_urandomm_ui __gmp_urandomm_ui __GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_t, unsigned long); /**************** Formatted output routines. ****************/ #define gmp_asprintf __gmp_asprintf __GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...); #define gmp_fprintf __gmp_fprintf #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...); #endif #define gmp_obstack_printf __gmp_obstack_printf #if defined (_GMP_H_HAVE_OBSTACK) __GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...); #endif #define gmp_obstack_vprintf __gmp_obstack_vprintf #if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list); #endif #define gmp_printf __gmp_printf __GMP_DECLSPEC int gmp_printf (const char *, ...); #define gmp_snprintf __gmp_snprintf __GMP_DECLSPEC int gmp_snprintf (char *, size_t, const char *, ...); #define gmp_sprintf __gmp_sprintf __GMP_DECLSPEC int gmp_sprintf (char *, const char *, ...); #define gmp_vasprintf __gmp_vasprintf #if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vasprintf (char **, const char *, va_list); #endif #define gmp_vfprintf __gmp_vfprintf #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vfprintf (FILE *, const char *, va_list); #endif #define gmp_vprintf __gmp_vprintf #if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vprintf (const char *, va_list); #endif #define gmp_vsnprintf __gmp_vsnprintf #if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vsnprintf (char *, size_t, const char *, va_list); #endif #define gmp_vsprintf __gmp_vsprintf #if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vsprintf (char *, const char *, va_list); #endif /**************** Formatted input routines. ****************/ #define gmp_fscanf __gmp_fscanf #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC int gmp_fscanf (FILE *, const char *, ...); #endif #define gmp_scanf __gmp_scanf __GMP_DECLSPEC int gmp_scanf (const char *, ...); #define gmp_sscanf __gmp_sscanf __GMP_DECLSPEC int gmp_sscanf (const char *, const char *, ...); #define gmp_vfscanf __gmp_vfscanf #if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vfscanf (FILE *, const char *, va_list); #endif #define gmp_vscanf __gmp_vscanf #if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vscanf (const char *, va_list); #endif #define gmp_vsscanf __gmp_vsscanf #if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vsscanf (const char *, const char *, va_list); #endif /**************** Integer (i.e. Z) routines. ****************/ #define _mpz_realloc __gmpz_realloc #define mpz_realloc __gmpz_realloc __GMP_DECLSPEC void *_mpz_realloc (mpz_ptr, mp_size_t); #define mpz_abs __gmpz_abs #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs) __GMP_DECLSPEC void mpz_abs (mpz_ptr, mpz_srcptr); #endif #define mpz_add __gmpz_add __GMP_DECLSPEC void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_add_ui __gmpz_add_ui __GMP_DECLSPEC void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_addmul __gmpz_addmul __GMP_DECLSPEC void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_addmul_ui __gmpz_addmul_ui __GMP_DECLSPEC void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_and __gmpz_and __GMP_DECLSPEC void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_array_init __gmpz_array_init __GMP_DECLSPEC void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t); #define mpz_bin_ui __gmpz_bin_ui __GMP_DECLSPEC void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_bin_uiui __gmpz_bin_uiui __GMP_DECLSPEC void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int); #define mpz_cdiv_q __gmpz_cdiv_q __GMP_DECLSPEC void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp __GMP_DECLSPEC void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); #define mpz_cdiv_q_ui __gmpz_cdiv_q_ui __GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_cdiv_qr __gmpz_cdiv_qr __GMP_DECLSPEC void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui __GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_cdiv_r __gmpz_cdiv_r __GMP_DECLSPEC void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp __GMP_DECLSPEC void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); #define mpz_cdiv_r_ui __gmpz_cdiv_r_ui __GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_cdiv_ui __gmpz_cdiv_ui __GMP_DECLSPEC unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; #define mpz_clear __gmpz_clear __GMP_DECLSPEC void mpz_clear (mpz_ptr); #define mpz_clears __gmpz_clears __GMP_DECLSPEC void mpz_clears (mpz_ptr, ...); #define mpz_clrbit __gmpz_clrbit __GMP_DECLSPEC void mpz_clrbit (mpz_ptr, mp_bitcnt_t); #define mpz_cmp __gmpz_cmp __GMP_DECLSPEC int mpz_cmp (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_cmp_d __gmpz_cmp_d __GMP_DECLSPEC int mpz_cmp_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE; #define _mpz_cmp_si __gmpz_cmp_si __GMP_DECLSPEC int _mpz_cmp_si (mpz_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define _mpz_cmp_ui __gmpz_cmp_ui __GMP_DECLSPEC int _mpz_cmp_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_cmpabs __gmpz_cmpabs __GMP_DECLSPEC int mpz_cmpabs (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_cmpabs_d __gmpz_cmpabs_d __GMP_DECLSPEC int mpz_cmpabs_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE; #define mpz_cmpabs_ui __gmpz_cmpabs_ui __GMP_DECLSPEC int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_com __gmpz_com __GMP_DECLSPEC void mpz_com (mpz_ptr, mpz_srcptr); #define mpz_combit __gmpz_combit __GMP_DECLSPEC void mpz_combit (mpz_ptr, mp_bitcnt_t); #define mpz_congruent_p __gmpz_congruent_p __GMP_DECLSPEC int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpz_congruent_2exp_p __gmpz_congruent_2exp_p __GMP_DECLSPEC int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_congruent_ui_p __gmpz_congruent_ui_p __GMP_DECLSPEC int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) __GMP_ATTRIBUTE_PURE; #define mpz_divexact __gmpz_divexact __GMP_DECLSPEC void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_divexact_ui __gmpz_divexact_ui __GMP_DECLSPEC void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long); #define mpz_divisible_p __gmpz_divisible_p __GMP_DECLSPEC int mpz_divisible_p (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpz_divisible_ui_p __gmpz_divisible_ui_p __GMP_DECLSPEC int mpz_divisible_ui_p (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE; #define mpz_divisible_2exp_p __gmpz_divisible_2exp_p __GMP_DECLSPEC int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_dump __gmpz_dump __GMP_DECLSPEC void mpz_dump (mpz_srcptr); #define mpz_export __gmpz_export __GMP_DECLSPEC void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr); #define mpz_fac_ui __gmpz_fac_ui __GMP_DECLSPEC void mpz_fac_ui (mpz_ptr, unsigned long int); #define mpz_2fac_ui __gmpz_2fac_ui __GMP_DECLSPEC void mpz_2fac_ui (mpz_ptr, unsigned long int); #define mpz_mfac_uiui __gmpz_mfac_uiui __GMP_DECLSPEC void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int); #define mpz_primorial_ui __gmpz_primorial_ui __GMP_DECLSPEC void mpz_primorial_ui (mpz_ptr, unsigned long int); #define mpz_fdiv_q __gmpz_fdiv_q __GMP_DECLSPEC void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp __GMP_DECLSPEC void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); #define mpz_fdiv_q_ui __gmpz_fdiv_q_ui __GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_fdiv_qr __gmpz_fdiv_qr __GMP_DECLSPEC void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui __GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_fdiv_r __gmpz_fdiv_r __GMP_DECLSPEC void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp __GMP_DECLSPEC void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); #define mpz_fdiv_r_ui __gmpz_fdiv_r_ui __GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_fdiv_ui __gmpz_fdiv_ui __GMP_DECLSPEC unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; #define mpz_fib_ui __gmpz_fib_ui __GMP_DECLSPEC void mpz_fib_ui (mpz_ptr, unsigned long int); #define mpz_fib2_ui __gmpz_fib2_ui __GMP_DECLSPEC void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int); #define mpz_fits_sint_p __gmpz_fits_sint_p __GMP_DECLSPEC int mpz_fits_sint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_fits_slong_p __gmpz_fits_slong_p __GMP_DECLSPEC int mpz_fits_slong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_fits_sshort_p __gmpz_fits_sshort_p __GMP_DECLSPEC int mpz_fits_sshort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_fits_uint_p __gmpz_fits_uint_p #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p) __GMP_DECLSPEC int mpz_fits_uint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_fits_ulong_p __gmpz_fits_ulong_p #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p) __GMP_DECLSPEC int mpz_fits_ulong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_fits_ushort_p __gmpz_fits_ushort_p #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p) __GMP_DECLSPEC int mpz_fits_ushort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_gcd __gmpz_gcd __GMP_DECLSPEC void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_gcd_ui __gmpz_gcd_ui __GMP_DECLSPEC unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_gcdext __gmpz_gcdext __GMP_DECLSPEC void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_get_d __gmpz_get_d __GMP_DECLSPEC double mpz_get_d (mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpz_get_d_2exp __gmpz_get_d_2exp __GMP_DECLSPEC double mpz_get_d_2exp (signed long int *, mpz_srcptr); #define mpz_get_si __gmpz_get_si __GMP_DECLSPEC /* signed */ long int mpz_get_si (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_get_str __gmpz_get_str __GMP_DECLSPEC char *mpz_get_str (char *, int, mpz_srcptr); #define mpz_get_ui __gmpz_get_ui #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui) __GMP_DECLSPEC unsigned long int mpz_get_ui (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_getlimbn __gmpz_getlimbn #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn) __GMP_DECLSPEC mp_limb_t mpz_getlimbn (mpz_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_hamdist __gmpz_hamdist __GMP_DECLSPEC mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_import __gmpz_import __GMP_DECLSPEC void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *); #define mpz_init __gmpz_init __GMP_DECLSPEC void mpz_init (mpz_ptr); #define mpz_init2 __gmpz_init2 __GMP_DECLSPEC void mpz_init2 (mpz_ptr, mp_bitcnt_t); #define mpz_inits __gmpz_inits __GMP_DECLSPEC void mpz_inits (mpz_ptr, ...); #define mpz_init_set __gmpz_init_set __GMP_DECLSPEC void mpz_init_set (mpz_ptr, mpz_srcptr); #define mpz_init_set_d __gmpz_init_set_d __GMP_DECLSPEC void mpz_init_set_d (mpz_ptr, double); #define mpz_init_set_si __gmpz_init_set_si __GMP_DECLSPEC void mpz_init_set_si (mpz_ptr, signed long int); #define mpz_init_set_str __gmpz_init_set_str __GMP_DECLSPEC int mpz_init_set_str (mpz_ptr, const char *, int); #define mpz_init_set_ui __gmpz_init_set_ui __GMP_DECLSPEC void mpz_init_set_ui (mpz_ptr, unsigned long int); #define mpz_inp_raw __gmpz_inp_raw #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpz_inp_raw (mpz_ptr, FILE *); #endif #define mpz_inp_str __gmpz_inp_str #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpz_inp_str (mpz_ptr, FILE *, int); #endif #define mpz_invert __gmpz_invert __GMP_DECLSPEC int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_ior __gmpz_ior __GMP_DECLSPEC void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_jacobi __gmpz_jacobi __GMP_DECLSPEC int mpz_jacobi (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpz_kronecker mpz_jacobi /* alias */ #define mpz_kronecker_si __gmpz_kronecker_si __GMP_DECLSPEC int mpz_kronecker_si (mpz_srcptr, long) __GMP_ATTRIBUTE_PURE; #define mpz_kronecker_ui __gmpz_kronecker_ui __GMP_DECLSPEC int mpz_kronecker_ui (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE; #define mpz_si_kronecker __gmpz_si_kronecker __GMP_DECLSPEC int mpz_si_kronecker (long, mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpz_ui_kronecker __gmpz_ui_kronecker __GMP_DECLSPEC int mpz_ui_kronecker (unsigned long, mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpz_lcm __gmpz_lcm __GMP_DECLSPEC void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_lcm_ui __gmpz_lcm_ui __GMP_DECLSPEC void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long); #define mpz_legendre mpz_jacobi /* alias */ #define mpz_lucnum_ui __gmpz_lucnum_ui __GMP_DECLSPEC void mpz_lucnum_ui (mpz_ptr, unsigned long int); #define mpz_lucnum2_ui __gmpz_lucnum2_ui __GMP_DECLSPEC void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int); #define mpz_millerrabin __gmpz_millerrabin __GMP_DECLSPEC int mpz_millerrabin (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE; #define mpz_mod __gmpz_mod __GMP_DECLSPEC void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */ #define mpz_mul __gmpz_mul __GMP_DECLSPEC void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_mul_2exp __gmpz_mul_2exp __GMP_DECLSPEC void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); #define mpz_mul_si __gmpz_mul_si __GMP_DECLSPEC void mpz_mul_si (mpz_ptr, mpz_srcptr, long int); #define mpz_mul_ui __gmpz_mul_ui __GMP_DECLSPEC void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_neg __gmpz_neg #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg) __GMP_DECLSPEC void mpz_neg (mpz_ptr, mpz_srcptr); #endif #define mpz_nextprime __gmpz_nextprime __GMP_DECLSPEC void mpz_nextprime (mpz_ptr, mpz_srcptr); #define mpz_out_raw __gmpz_out_raw #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpz_out_raw (FILE *, mpz_srcptr); #endif #define mpz_out_str __gmpz_out_str #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpz_out_str (FILE *, int, mpz_srcptr); #endif #define mpz_perfect_power_p __gmpz_perfect_power_p __GMP_DECLSPEC int mpz_perfect_power_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpz_perfect_square_p __gmpz_perfect_square_p #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p) __GMP_DECLSPEC int mpz_perfect_square_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE; #endif #define mpz_popcount __gmpz_popcount #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount) __GMP_DECLSPEC mp_bitcnt_t mpz_popcount (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_pow_ui __gmpz_pow_ui __GMP_DECLSPEC void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_powm __gmpz_powm __GMP_DECLSPEC void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); #define mpz_powm_sec __gmpz_powm_sec __GMP_DECLSPEC void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); #define mpz_powm_ui __gmpz_powm_ui __GMP_DECLSPEC void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr); #define mpz_probab_prime_p __gmpz_probab_prime_p __GMP_DECLSPEC int mpz_probab_prime_p (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE; #define mpz_random __gmpz_random __GMP_DECLSPEC void mpz_random (mpz_ptr, mp_size_t); #define mpz_random2 __gmpz_random2 __GMP_DECLSPEC void mpz_random2 (mpz_ptr, mp_size_t); #define mpz_realloc2 __gmpz_realloc2 __GMP_DECLSPEC void mpz_realloc2 (mpz_ptr, mp_bitcnt_t); #define mpz_remove __gmpz_remove __GMP_DECLSPEC mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_root __gmpz_root __GMP_DECLSPEC int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_rootrem __gmpz_rootrem __GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_rrandomb __gmpz_rrandomb __GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); #define mpz_scan0 __gmpz_scan0 __GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_scan1 __gmpz_scan1 __GMP_DECLSPEC mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_set __gmpz_set __GMP_DECLSPEC void mpz_set (mpz_ptr, mpz_srcptr); #define mpz_set_d __gmpz_set_d __GMP_DECLSPEC void mpz_set_d (mpz_ptr, double); #define mpz_set_f __gmpz_set_f __GMP_DECLSPEC void mpz_set_f (mpz_ptr, mpf_srcptr); #define mpz_set_q __gmpz_set_q #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q) __GMP_DECLSPEC void mpz_set_q (mpz_ptr, mpq_srcptr); #endif #define mpz_set_si __gmpz_set_si __GMP_DECLSPEC void mpz_set_si (mpz_ptr, signed long int); #define mpz_set_str __gmpz_set_str __GMP_DECLSPEC int mpz_set_str (mpz_ptr, const char *, int); #define mpz_set_ui __gmpz_set_ui __GMP_DECLSPEC void mpz_set_ui (mpz_ptr, unsigned long int); #define mpz_setbit __gmpz_setbit __GMP_DECLSPEC void mpz_setbit (mpz_ptr, mp_bitcnt_t); #define mpz_size __gmpz_size #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size) __GMP_DECLSPEC size_t mpz_size (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_sizeinbase __gmpz_sizeinbase __GMP_DECLSPEC size_t mpz_sizeinbase (mpz_srcptr, int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_sqrt __gmpz_sqrt __GMP_DECLSPEC void mpz_sqrt (mpz_ptr, mpz_srcptr); #define mpz_sqrtrem __gmpz_sqrtrem __GMP_DECLSPEC void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr); #define mpz_sub __gmpz_sub __GMP_DECLSPEC void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_sub_ui __gmpz_sub_ui __GMP_DECLSPEC void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_ui_sub __gmpz_ui_sub __GMP_DECLSPEC void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr); #define mpz_submul __gmpz_submul __GMP_DECLSPEC void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_submul_ui __gmpz_submul_ui __GMP_DECLSPEC void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_swap __gmpz_swap __GMP_DECLSPEC void mpz_swap (mpz_ptr, mpz_ptr) __GMP_NOTHROW; #define mpz_tdiv_ui __gmpz_tdiv_ui __GMP_DECLSPEC unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE; #define mpz_tdiv_q __gmpz_tdiv_q __GMP_DECLSPEC void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp __GMP_DECLSPEC void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); #define mpz_tdiv_q_ui __gmpz_tdiv_q_ui __GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_tdiv_qr __gmpz_tdiv_qr __GMP_DECLSPEC void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui __GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_tdiv_r __gmpz_tdiv_r __GMP_DECLSPEC void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp __GMP_DECLSPEC void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); #define mpz_tdiv_r_ui __gmpz_tdiv_r_ui __GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); #define mpz_tstbit __gmpz_tstbit __GMP_DECLSPEC int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_ui_pow_ui __gmpz_ui_pow_ui __GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int); #define mpz_urandomb __gmpz_urandomb __GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); #define mpz_urandomm __gmpz_urandomm __GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_t, mpz_srcptr); #define mpz_xor __gmpz_xor #define mpz_eor __gmpz_xor __GMP_DECLSPEC void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_limbs_read __gmpz_limbs_read __GMP_DECLSPEC mp_srcptr mpz_limbs_read (mpz_srcptr); #define mpz_limbs_write __gmpz_limbs_write __GMP_DECLSPEC mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t); #define mpz_limbs_modify __gmpz_limbs_modify __GMP_DECLSPEC mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t); #define mpz_limbs_finish __gmpz_limbs_finish __GMP_DECLSPEC void mpz_limbs_finish (mpz_ptr, mp_size_t); #define mpz_roinit_n __gmpz_roinit_n __GMP_DECLSPEC mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t); #define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }} /**************** Rational (i.e. Q) routines. ****************/ #define mpq_abs __gmpq_abs #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs) __GMP_DECLSPEC void mpq_abs (mpq_ptr, mpq_srcptr); #endif #define mpq_add __gmpq_add __GMP_DECLSPEC void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr); #define mpq_canonicalize __gmpq_canonicalize __GMP_DECLSPEC void mpq_canonicalize (mpq_ptr); #define mpq_clear __gmpq_clear __GMP_DECLSPEC void mpq_clear (mpq_ptr); #define mpq_clears __gmpq_clears __GMP_DECLSPEC void mpq_clears (mpq_ptr, ...); #define mpq_cmp __gmpq_cmp __GMP_DECLSPEC int mpq_cmp (mpq_srcptr, mpq_srcptr) __GMP_ATTRIBUTE_PURE; #define _mpq_cmp_si __gmpq_cmp_si __GMP_DECLSPEC int _mpq_cmp_si (mpq_srcptr, long, unsigned long) __GMP_ATTRIBUTE_PURE; #define _mpq_cmp_ui __gmpq_cmp_ui __GMP_DECLSPEC int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) __GMP_ATTRIBUTE_PURE; #define mpq_cmp_z __gmpq_cmp_z __GMP_DECLSPEC int mpq_cmp_z (mpq_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE; #define mpq_div __gmpq_div __GMP_DECLSPEC void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr); #define mpq_div_2exp __gmpq_div_2exp __GMP_DECLSPEC void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); #define mpq_equal __gmpq_equal __GMP_DECLSPEC int mpq_equal (mpq_srcptr, mpq_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpq_get_num __gmpq_get_num __GMP_DECLSPEC void mpq_get_num (mpz_ptr, mpq_srcptr); #define mpq_get_den __gmpq_get_den __GMP_DECLSPEC void mpq_get_den (mpz_ptr, mpq_srcptr); #define mpq_get_d __gmpq_get_d __GMP_DECLSPEC double mpq_get_d (mpq_srcptr) __GMP_ATTRIBUTE_PURE; #define mpq_get_str __gmpq_get_str __GMP_DECLSPEC char *mpq_get_str (char *, int, mpq_srcptr); #define mpq_init __gmpq_init __GMP_DECLSPEC void mpq_init (mpq_ptr); #define mpq_inits __gmpq_inits __GMP_DECLSPEC void mpq_inits (mpq_ptr, ...); #define mpq_inp_str __gmpq_inp_str #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpq_inp_str (mpq_ptr, FILE *, int); #endif #define mpq_inv __gmpq_inv __GMP_DECLSPEC void mpq_inv (mpq_ptr, mpq_srcptr); #define mpq_mul __gmpq_mul __GMP_DECLSPEC void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr); #define mpq_mul_2exp __gmpq_mul_2exp __GMP_DECLSPEC void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); #define mpq_neg __gmpq_neg #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg) __GMP_DECLSPEC void mpq_neg (mpq_ptr, mpq_srcptr); #endif #define mpq_out_str __gmpq_out_str #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpq_out_str (FILE *, int, mpq_srcptr); #endif #define mpq_set __gmpq_set __GMP_DECLSPEC void mpq_set (mpq_ptr, mpq_srcptr); #define mpq_set_d __gmpq_set_d __GMP_DECLSPEC void mpq_set_d (mpq_ptr, double); #define mpq_set_den __gmpq_set_den __GMP_DECLSPEC void mpq_set_den (mpq_ptr, mpz_srcptr); #define mpq_set_f __gmpq_set_f __GMP_DECLSPEC void mpq_set_f (mpq_ptr, mpf_srcptr); #define mpq_set_num __gmpq_set_num __GMP_DECLSPEC void mpq_set_num (mpq_ptr, mpz_srcptr); #define mpq_set_si __gmpq_set_si __GMP_DECLSPEC void mpq_set_si (mpq_ptr, signed long int, unsigned long int); #define mpq_set_str __gmpq_set_str __GMP_DECLSPEC int mpq_set_str (mpq_ptr, const char *, int); #define mpq_set_ui __gmpq_set_ui __GMP_DECLSPEC void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int); #define mpq_set_z __gmpq_set_z __GMP_DECLSPEC void mpq_set_z (mpq_ptr, mpz_srcptr); #define mpq_sub __gmpq_sub __GMP_DECLSPEC void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr); #define mpq_swap __gmpq_swap __GMP_DECLSPEC void mpq_swap (mpq_ptr, mpq_ptr) __GMP_NOTHROW; /**************** Float (i.e. F) routines. ****************/ #define mpf_abs __gmpf_abs __GMP_DECLSPEC void mpf_abs (mpf_ptr, mpf_srcptr); #define mpf_add __gmpf_add __GMP_DECLSPEC void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr); #define mpf_add_ui __gmpf_add_ui __GMP_DECLSPEC void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int); #define mpf_ceil __gmpf_ceil __GMP_DECLSPEC void mpf_ceil (mpf_ptr, mpf_srcptr); #define mpf_clear __gmpf_clear __GMP_DECLSPEC void mpf_clear (mpf_ptr); #define mpf_clears __gmpf_clears __GMP_DECLSPEC void mpf_clears (mpf_ptr, ...); #define mpf_cmp __gmpf_cmp __GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_cmp_z __gmpf_cmp_z __GMP_DECLSPEC int mpf_cmp_z (mpf_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_cmp_d __gmpf_cmp_d __GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE; #define mpf_cmp_si __gmpf_cmp_si __GMP_DECLSPEC int mpf_cmp_si (mpf_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_cmp_ui __gmpf_cmp_ui __GMP_DECLSPEC int mpf_cmp_ui (mpf_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_div __gmpf_div __GMP_DECLSPEC void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr); #define mpf_div_2exp __gmpf_div_2exp __GMP_DECLSPEC void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); #define mpf_div_ui __gmpf_div_ui __GMP_DECLSPEC void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int); #define mpf_dump __gmpf_dump __GMP_DECLSPEC void mpf_dump (mpf_srcptr); #define mpf_eq __gmpf_eq __GMP_DECLSPEC int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; #define mpf_fits_sint_p __gmpf_fits_sint_p __GMP_DECLSPEC int mpf_fits_sint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_fits_slong_p __gmpf_fits_slong_p __GMP_DECLSPEC int mpf_fits_slong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_fits_sshort_p __gmpf_fits_sshort_p __GMP_DECLSPEC int mpf_fits_sshort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_fits_uint_p __gmpf_fits_uint_p __GMP_DECLSPEC int mpf_fits_uint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_fits_ulong_p __gmpf_fits_ulong_p __GMP_DECLSPEC int mpf_fits_ulong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_fits_ushort_p __gmpf_fits_ushort_p __GMP_DECLSPEC int mpf_fits_ushort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_floor __gmpf_floor __GMP_DECLSPEC void mpf_floor (mpf_ptr, mpf_srcptr); #define mpf_get_d __gmpf_get_d __GMP_DECLSPEC double mpf_get_d (mpf_srcptr) __GMP_ATTRIBUTE_PURE; #define mpf_get_d_2exp __gmpf_get_d_2exp __GMP_DECLSPEC double mpf_get_d_2exp (signed long int *, mpf_srcptr); #define mpf_get_default_prec __gmpf_get_default_prec __GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec (void) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_get_prec __gmpf_get_prec __GMP_DECLSPEC mp_bitcnt_t mpf_get_prec (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_get_si __gmpf_get_si __GMP_DECLSPEC long mpf_get_si (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_get_str __gmpf_get_str __GMP_DECLSPEC char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr); #define mpf_get_ui __gmpf_get_ui __GMP_DECLSPEC unsigned long mpf_get_ui (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_init __gmpf_init __GMP_DECLSPEC void mpf_init (mpf_ptr); #define mpf_init2 __gmpf_init2 __GMP_DECLSPEC void mpf_init2 (mpf_ptr, mp_bitcnt_t); #define mpf_inits __gmpf_inits __GMP_DECLSPEC void mpf_inits (mpf_ptr, ...); #define mpf_init_set __gmpf_init_set __GMP_DECLSPEC void mpf_init_set (mpf_ptr, mpf_srcptr); #define mpf_init_set_d __gmpf_init_set_d __GMP_DECLSPEC void mpf_init_set_d (mpf_ptr, double); #define mpf_init_set_si __gmpf_init_set_si __GMP_DECLSPEC void mpf_init_set_si (mpf_ptr, signed long int); #define mpf_init_set_str __gmpf_init_set_str __GMP_DECLSPEC int mpf_init_set_str (mpf_ptr, const char *, int); #define mpf_init_set_ui __gmpf_init_set_ui __GMP_DECLSPEC void mpf_init_set_ui (mpf_ptr, unsigned long int); #define mpf_inp_str __gmpf_inp_str #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpf_inp_str (mpf_ptr, FILE *, int); #endif #define mpf_integer_p __gmpf_integer_p __GMP_DECLSPEC int mpf_integer_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_mul __gmpf_mul __GMP_DECLSPEC void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr); #define mpf_mul_2exp __gmpf_mul_2exp __GMP_DECLSPEC void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); #define mpf_mul_ui __gmpf_mul_ui __GMP_DECLSPEC void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int); #define mpf_neg __gmpf_neg __GMP_DECLSPEC void mpf_neg (mpf_ptr, mpf_srcptr); #define mpf_out_str __gmpf_out_str #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr); #endif #define mpf_pow_ui __gmpf_pow_ui __GMP_DECLSPEC void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int); #define mpf_random2 __gmpf_random2 __GMP_DECLSPEC void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t); #define mpf_reldiff __gmpf_reldiff __GMP_DECLSPEC void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr); #define mpf_set __gmpf_set __GMP_DECLSPEC void mpf_set (mpf_ptr, mpf_srcptr); #define mpf_set_d __gmpf_set_d __GMP_DECLSPEC void mpf_set_d (mpf_ptr, double); #define mpf_set_default_prec __gmpf_set_default_prec __GMP_DECLSPEC void mpf_set_default_prec (mp_bitcnt_t) __GMP_NOTHROW; #define mpf_set_prec __gmpf_set_prec __GMP_DECLSPEC void mpf_set_prec (mpf_ptr, mp_bitcnt_t); #define mpf_set_prec_raw __gmpf_set_prec_raw __GMP_DECLSPEC void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) __GMP_NOTHROW; #define mpf_set_q __gmpf_set_q __GMP_DECLSPEC void mpf_set_q (mpf_ptr, mpq_srcptr); #define mpf_set_si __gmpf_set_si __GMP_DECLSPEC void mpf_set_si (mpf_ptr, signed long int); #define mpf_set_str __gmpf_set_str __GMP_DECLSPEC int mpf_set_str (mpf_ptr, const char *, int); #define mpf_set_ui __gmpf_set_ui __GMP_DECLSPEC void mpf_set_ui (mpf_ptr, unsigned long int); #define mpf_set_z __gmpf_set_z __GMP_DECLSPEC void mpf_set_z (mpf_ptr, mpz_srcptr); #define mpf_size __gmpf_size __GMP_DECLSPEC size_t mpf_size (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpf_sqrt __gmpf_sqrt __GMP_DECLSPEC void mpf_sqrt (mpf_ptr, mpf_srcptr); #define mpf_sqrt_ui __gmpf_sqrt_ui __GMP_DECLSPEC void mpf_sqrt_ui (mpf_ptr, unsigned long int); #define mpf_sub __gmpf_sub __GMP_DECLSPEC void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr); #define mpf_sub_ui __gmpf_sub_ui __GMP_DECLSPEC void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int); #define mpf_swap __gmpf_swap __GMP_DECLSPEC void mpf_swap (mpf_ptr, mpf_ptr) __GMP_NOTHROW; #define mpf_trunc __gmpf_trunc __GMP_DECLSPEC void mpf_trunc (mpf_ptr, mpf_srcptr); #define mpf_ui_div __gmpf_ui_div __GMP_DECLSPEC void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr); #define mpf_ui_sub __gmpf_ui_sub __GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr); #define mpf_urandomb __gmpf_urandomb __GMP_DECLSPEC void mpf_urandomb (mpf_t, gmp_randstate_t, mp_bitcnt_t); /************ Low level positive-integer (i.e. N) routines. ************/ /* This is ugly, but we need to make user calls reach the prefixed function. */ #define mpn_add __MPN(add) #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add) __GMP_DECLSPEC mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #endif #define mpn_add_1 __MPN(add_1) #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1) __GMP_DECLSPEC mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW; #endif #define mpn_add_n __MPN(add_n) __GMP_DECLSPEC mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_addmul_1 __MPN(addmul_1) __GMP_DECLSPEC mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_cmp __MPN(cmp) #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp) __GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpn_zero_p __MPN(zero_p) #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_zero_p) __GMP_DECLSPEC int mpn_zero_p (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpn_divexact_1 __MPN(divexact_1) __GMP_DECLSPEC void mpn_divexact_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_divexact_by3(dst,src,size) \ mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0)) #define mpn_divexact_by3c __MPN(divexact_by3c) __GMP_DECLSPEC mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_divmod_1(qp,np,nsize,dlimb) \ mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb) #define mpn_divrem __MPN(divrem) __GMP_DECLSPEC mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_divrem_1 __MPN(divrem_1) __GMP_DECLSPEC mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_divrem_2 __MPN(divrem_2) __GMP_DECLSPEC mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr); #define mpn_div_qr_1 __MPN(div_qr_1) __GMP_DECLSPEC mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_div_qr_2 __MPN(div_qr_2) __GMP_DECLSPEC mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_gcd __MPN(gcd) __GMP_DECLSPEC mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); #define mpn_gcd_1 __MPN(gcd_1) __GMP_DECLSPEC mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; #define mpn_gcdext_1 __MPN(gcdext_1) __GMP_DECLSPEC mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t); #define mpn_gcdext __MPN(gcdext) __GMP_DECLSPEC mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t); #define mpn_get_str __MPN(get_str) __GMP_DECLSPEC size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t); #define mpn_hamdist __MPN(hamdist) __GMP_DECLSPEC mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpn_lshift __MPN(lshift) __GMP_DECLSPEC mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); #define mpn_mod_1 __MPN(mod_1) __GMP_DECLSPEC mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; #define mpn_mul __MPN(mul) __GMP_DECLSPEC mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_mul_1 __MPN(mul_1) __GMP_DECLSPEC mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_mul_n __MPN(mul_n) __GMP_DECLSPEC void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_sqr __MPN(sqr) __GMP_DECLSPEC void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t); #define mpn_neg __MPN(neg) #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg) __GMP_DECLSPEC mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t); #endif #define mpn_com __MPN(com) __GMP_DECLSPEC void mpn_com (mp_ptr, mp_srcptr, mp_size_t); #define mpn_perfect_square_p __MPN(perfect_square_p) __GMP_DECLSPEC int mpn_perfect_square_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_perfect_power_p __MPN(perfect_power_p) __GMP_DECLSPEC int mpn_perfect_power_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_popcount __MPN(popcount) __GMP_DECLSPEC mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpn_pow_1 __MPN(pow_1) __GMP_DECLSPEC mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); /* undocumented now, but retained here for upward compatibility */ #define mpn_preinv_mod_1 __MPN(preinv_mod_1) __GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; #define mpn_random __MPN(random) __GMP_DECLSPEC void mpn_random (mp_ptr, mp_size_t); #define mpn_random2 __MPN(random2) __GMP_DECLSPEC void mpn_random2 (mp_ptr, mp_size_t); #define mpn_rshift __MPN(rshift) __GMP_DECLSPEC mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); #define mpn_scan0 __MPN(scan0) __GMP_DECLSPEC mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; #define mpn_scan1 __MPN(scan1) __GMP_DECLSPEC mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE; #define mpn_set_str __MPN(set_str) __GMP_DECLSPEC mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int); #define mpn_sizeinbase __MPN(sizeinbase) __GMP_DECLSPEC size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int); #define mpn_sqrtrem __MPN(sqrtrem) __GMP_DECLSPEC mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); #define mpn_sub __MPN(sub) #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub) __GMP_DECLSPEC mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #endif #define mpn_sub_1 __MPN(sub_1) #if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1) __GMP_DECLSPEC mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW; #endif #define mpn_sub_n __MPN(sub_n) __GMP_DECLSPEC mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_submul_1 __MPN(submul_1) __GMP_DECLSPEC mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_tdiv_qr __MPN(tdiv_qr) __GMP_DECLSPEC void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_and_n __MPN(and_n) __GMP_DECLSPEC void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_andn_n __MPN(andn_n) __GMP_DECLSPEC void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_nand_n __MPN(nand_n) __GMP_DECLSPEC void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_ior_n __MPN(ior_n) __GMP_DECLSPEC void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_iorn_n __MPN(iorn_n) __GMP_DECLSPEC void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_nior_n __MPN(nior_n) __GMP_DECLSPEC void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_xor_n __MPN(xor_n) __GMP_DECLSPEC void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_xnor_n __MPN(xnor_n) __GMP_DECLSPEC void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_copyi __MPN(copyi) __GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t); #define mpn_copyd __MPN(copyd) __GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t); #define mpn_zero __MPN(zero) __GMP_DECLSPEC void mpn_zero (mp_ptr, mp_size_t); #define mpn_cnd_add_n __MPN(cnd_add_n) __GMP_DECLSPEC mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_cnd_sub_n __MPN(cnd_sub_n) __GMP_DECLSPEC mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_sec_add_1 __MPN(sec_add_1) __GMP_DECLSPEC mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); #define mpn_sec_add_1_itch __MPN(sec_add_1_itch) __GMP_DECLSPEC mp_size_t mpn_sec_add_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_sec_sub_1 __MPN(sec_sub_1) __GMP_DECLSPEC mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); #define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch) __GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_cnd_swap __MPN(cnd_swap) __GMP_DECLSPEC void mpn_cnd_swap (mp_limb_t, volatile mp_limb_t *, volatile mp_limb_t *, mp_size_t); #define mpn_sec_mul __MPN(sec_mul) __GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_sec_mul_itch __MPN(sec_mul_itch) __GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_sec_sqr __MPN(sec_sqr) __GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_sec_sqr_itch __MPN(sec_sqr_itch) __GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_sec_powm __MPN(sec_powm) __GMP_DECLSPEC void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_bitcnt_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_sec_powm_itch __MPN(sec_powm_itch) __GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_sec_tabselect __MPN(sec_tabselect) __GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t); #define mpn_sec_div_qr __MPN(sec_div_qr) __GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch) __GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_sec_div_r __MPN(sec_div_r) __GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_sec_div_r_itch __MPN(sec_div_r_itch) __GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_sec_invert __MPN(sec_invert) __GMP_DECLSPEC int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr); #define mpn_sec_invert_itch __MPN(sec_invert_itch) __GMP_DECLSPEC mp_size_t mpn_sec_invert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE; /**************** mpz inlines ****************/ /* The following are provided as inlines where possible, but always exist as library functions too, for binary compatibility. Within gmp itself this inlining generally isn't relied on, since it doesn't get done for all compilers, whereas if something is worth inlining then it's worth arranging always. There are two styles of inlining here. When the same bit of code is wanted for the inline as for the library version, then __GMP_FORCE_foo arranges for that code to be emitted and the __GMP_EXTERN_INLINE directive suppressed, eg. mpz_fits_uint_p. When a different bit of code is wanted for the inline than for the library version, then __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */ #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs) __GMP_EXTERN_INLINE void mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) { if (__gmp_w != __gmp_u) mpz_set (__gmp_w, __gmp_u); __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size); } #endif #if GMP_NAIL_BITS == 0 #define __GMPZ_FITS_UTYPE_P(z,maxval) \ mp_size_t __gmp_n = z->_mp_size; \ mp_ptr __gmp_p = z->_mp_d; \ return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval)); #else #define __GMPZ_FITS_UTYPE_P(z,maxval) \ mp_size_t __gmp_n = z->_mp_size; \ mp_ptr __gmp_p = z->_mp_d; \ return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \ || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS))); #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p) #if ! defined (__GMP_FORCE_mpz_fits_uint_p) __GMP_EXTERN_INLINE #endif int mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW { __GMPZ_FITS_UTYPE_P (__gmp_z, UINT_MAX); } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p) #if ! defined (__GMP_FORCE_mpz_fits_ulong_p) __GMP_EXTERN_INLINE #endif int mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW { __GMPZ_FITS_UTYPE_P (__gmp_z, ULONG_MAX); } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p) #if ! defined (__GMP_FORCE_mpz_fits_ushort_p) __GMP_EXTERN_INLINE #endif int mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW { __GMPZ_FITS_UTYPE_P (__gmp_z, USHRT_MAX); } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui) #if ! defined (__GMP_FORCE_mpz_get_ui) __GMP_EXTERN_INLINE #endif unsigned long mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW { mp_ptr __gmp_p = __gmp_z->_mp_d; mp_size_t __gmp_n = __gmp_z->_mp_size; mp_limb_t __gmp_l = __gmp_p[0]; /* This is a "#if" rather than a plain "if" so as to avoid gcc warnings about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland C++ 6.0 warnings about condition always true for something like "ULONG_MAX < GMP_NUMB_MASK". */ #if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB) /* limb==long and no nails, or limb==longlong, one limb is enough */ return (__gmp_n != 0 ? __gmp_l : 0); #else /* limb==long and nails, need two limbs when available */ __gmp_n = __GMP_ABS (__gmp_n); if (__gmp_n <= 1) return (__gmp_n != 0 ? __gmp_l : 0); else return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS); #endif } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn) #if ! defined (__GMP_FORCE_mpz_getlimbn) __GMP_EXTERN_INLINE #endif mp_limb_t mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW { mp_limb_t __gmp_result = 0; if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size))) __gmp_result = __gmp_z->_mp_d[__gmp_n]; return __gmp_result; } #endif #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg) __GMP_EXTERN_INLINE void mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) { if (__gmp_w != __gmp_u) mpz_set (__gmp_w, __gmp_u); __gmp_w->_mp_size = - __gmp_w->_mp_size; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p) #if ! defined (__GMP_FORCE_mpz_perfect_square_p) __GMP_EXTERN_INLINE #endif int mpz_perfect_square_p (mpz_srcptr __gmp_a) { mp_size_t __gmp_asize; int __gmp_result; __gmp_asize = __gmp_a->_mp_size; __gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */ if (__GMP_LIKELY (__gmp_asize > 0)) __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize); return __gmp_result; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount) #if ! defined (__GMP_FORCE_mpz_popcount) __GMP_EXTERN_INLINE #endif mp_bitcnt_t mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW { mp_size_t __gmp_usize; mp_bitcnt_t __gmp_result; __gmp_usize = __gmp_u->_mp_size; __gmp_result = (__gmp_usize < 0 ? ULONG_MAX : 0); if (__GMP_LIKELY (__gmp_usize > 0)) __gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize); return __gmp_result; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q) #if ! defined (__GMP_FORCE_mpz_set_q) __GMP_EXTERN_INLINE #endif void mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u) { mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u)); } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size) #if ! defined (__GMP_FORCE_mpz_size) __GMP_EXTERN_INLINE #endif size_t mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW { return __GMP_ABS (__gmp_z->_mp_size); } #endif /**************** mpq inlines ****************/ #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs) __GMP_EXTERN_INLINE void mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) { if (__gmp_w != __gmp_u) mpq_set (__gmp_w, __gmp_u); __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size); } #endif #if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg) __GMP_EXTERN_INLINE void mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) { if (__gmp_w != __gmp_u) mpq_set (__gmp_w, __gmp_u); __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size; } #endif /**************** mpn inlines ****************/ /* The comments with __GMPN_ADD_1 below apply here too. The test for FUNCTION returning 0 should predict well. If it's assumed {yp,ysize} will usually have a random number of bits then the high limb won't be full and a carry out will occur a good deal less than 50% of the time. ysize==0 isn't a documented feature, but is used internally in a few places. Producing cout last stops it using up a register during the main part of the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))" doesn't seem able to move the true and false legs of the conditional up to the two places cout is generated. */ #define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \ do { \ mp_size_t __gmp_i; \ mp_limb_t __gmp_x; \ \ /* ASSERT ((ysize) >= 0); */ \ /* ASSERT ((xsize) >= (ysize)); */ \ /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \ /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \ \ __gmp_i = (ysize); \ if (__gmp_i != 0) \ { \ if (FUNCTION (wp, xp, yp, __gmp_i)) \ { \ do \ { \ if (__gmp_i >= (xsize)) \ { \ (cout) = 1; \ goto __gmp_done; \ } \ __gmp_x = (xp)[__gmp_i]; \ } \ while (TEST); \ } \ } \ if ((wp) != (xp)) \ __GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \ (cout) = 0; \ __gmp_done: \ ; \ } while (0) #define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \ __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \ (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0)) #define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \ __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \ (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0)) /* The use of __gmp_i indexing is designed to ensure a compile time src==dst remains nice and clear to the compiler, so that __GMPN_COPY_REST can disappear, and the load/add/store gets a chance to become a read-modify-write on CISC CPUs. Alternatives: Using a pair of pointers instead of indexing would be possible, but gcc isn't able to recognise compile-time src==dst in that case, even when the pointers are incremented more or less together. Other compilers would very likely have similar difficulty. gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or similar to detect a compile-time src==dst. This works nicely on gcc 2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems to be always false, for a pointer p. But the current code form seems good enough for src==dst anyway. gcc on x86 as usual doesn't give particularly good flags handling for the carry/borrow detection. It's tempting to want some multi instruction asm blocks to help it, and this was tried, but in truth there's only a few instructions to save and any gain is all too easily lost by register juggling setting up for the asm. */ #if GMP_NAIL_BITS == 0 #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ do { \ mp_size_t __gmp_i; \ mp_limb_t __gmp_x, __gmp_r; \ \ /* ASSERT ((n) >= 1); */ \ /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ \ __gmp_x = (src)[0]; \ __gmp_r = __gmp_x OP (v); \ (dst)[0] = __gmp_r; \ if (CB (__gmp_r, __gmp_x, (v))) \ { \ (cout) = 1; \ for (__gmp_i = 1; __gmp_i < (n);) \ { \ __gmp_x = (src)[__gmp_i]; \ __gmp_r = __gmp_x OP 1; \ (dst)[__gmp_i] = __gmp_r; \ ++__gmp_i; \ if (!CB (__gmp_r, __gmp_x, 1)) \ { \ if ((src) != (dst)) \ __GMPN_COPY_REST (dst, src, n, __gmp_i); \ (cout) = 0; \ break; \ } \ } \ } \ else \ { \ if ((src) != (dst)) \ __GMPN_COPY_REST (dst, src, n, 1); \ (cout) = 0; \ } \ } while (0) #endif #if GMP_NAIL_BITS >= 1 #define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ do { \ mp_size_t __gmp_i; \ mp_limb_t __gmp_x, __gmp_r; \ \ /* ASSERT ((n) >= 1); */ \ /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ \ __gmp_x = (src)[0]; \ __gmp_r = __gmp_x OP (v); \ (dst)[0] = __gmp_r & GMP_NUMB_MASK; \ if (__gmp_r >> GMP_NUMB_BITS != 0) \ { \ (cout) = 1; \ for (__gmp_i = 1; __gmp_i < (n);) \ { \ __gmp_x = (src)[__gmp_i]; \ __gmp_r = __gmp_x OP 1; \ (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \ ++__gmp_i; \ if (__gmp_r >> GMP_NUMB_BITS == 0) \ { \ if ((src) != (dst)) \ __GMPN_COPY_REST (dst, src, n, __gmp_i); \ (cout) = 0; \ break; \ } \ } \ } \ else \ { \ if ((src) != (dst)) \ __GMPN_COPY_REST (dst, src, n, 1); \ (cout) = 0; \ } \ } while (0) #endif #define __GMPN_ADDCB(r,x,y) ((r) < (y)) #define __GMPN_SUBCB(r,x,y) ((x) < (y)) #define __GMPN_ADD_1(cout, dst, src, n, v) \ __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB) #define __GMPN_SUB_1(cout, dst, src, n, v) \ __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB) /* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or negative. size==0 is allowed. On random data usually only one limb will need to be examined to get a result, so it's worth having it inline. */ #define __GMPN_CMP(result, xp, yp, size) \ do { \ mp_size_t __gmp_i; \ mp_limb_t __gmp_x, __gmp_y; \ \ /* ASSERT ((size) >= 0); */ \ \ (result) = 0; \ __gmp_i = (size); \ while (--__gmp_i >= 0) \ { \ __gmp_x = (xp)[__gmp_i]; \ __gmp_y = (yp)[__gmp_i]; \ if (__gmp_x != __gmp_y) \ { \ /* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \ (result) = (__gmp_x > __gmp_y ? 1 : -1); \ break; \ } \ } \ } while (0) #if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST) #define __GMPN_COPY_REST(dst, src, size, start) \ do { \ /* ASSERT ((start) >= 0); */ \ /* ASSERT ((start) <= (size)); */ \ __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \ } while (0) #endif /* Copy {src,size} to {dst,size}, starting at "start". This is designed to keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1, __GMPN_ADD, etc. */ #if ! defined (__GMPN_COPY_REST) #define __GMPN_COPY_REST(dst, src, size, start) \ do { \ mp_size_t __gmp_j; \ /* ASSERT ((size) >= 0); */ \ /* ASSERT ((start) >= 0); */ \ /* ASSERT ((start) <= (size)); */ \ /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \ __GMP_CRAY_Pragma ("_CRI ivdep"); \ for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \ (dst)[__gmp_j] = (src)[__gmp_j]; \ } while (0) #endif /* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use mpn_copyi if there's a native version, and if we don't mind demanding binary compatibility for it (on targets which use it). */ #if ! defined (__GMPN_COPY) #define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0) #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add) #if ! defined (__GMP_FORCE_mpn_add) __GMP_EXTERN_INLINE #endif mp_limb_t mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) { mp_limb_t __gmp_c; __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); return __gmp_c; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1) #if ! defined (__GMP_FORCE_mpn_add_1) __GMP_EXTERN_INLINE #endif mp_limb_t mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW { mp_limb_t __gmp_c; __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); return __gmp_c; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp) #if ! defined (__GMP_FORCE_mpn_cmp) __GMP_EXTERN_INLINE #endif int mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW { int __gmp_result; __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size); return __gmp_result; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_zero_p) #if ! defined (__GMP_FORCE_mpn_zero_p) __GMP_EXTERN_INLINE #endif int mpn_zero_p (mp_srcptr __gmp_p, mp_size_t __gmp_n) __GMP_NOTHROW { /* if (__GMP_LIKELY (__gmp_n > 0)) */ do { if (__gmp_p[--__gmp_n] != 0) return 0; } while (__gmp_n != 0); return 1; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub) #if ! defined (__GMP_FORCE_mpn_sub) __GMP_EXTERN_INLINE #endif mp_limb_t mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) { mp_limb_t __gmp_c; __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); return __gmp_c; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1) #if ! defined (__GMP_FORCE_mpn_sub_1) __GMP_EXTERN_INLINE #endif mp_limb_t mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW { mp_limb_t __gmp_c; __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); return __gmp_c; } #endif #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg) #if ! defined (__GMP_FORCE_mpn_neg) __GMP_EXTERN_INLINE #endif mp_limb_t mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n) { while (*__gmp_up == 0) /* Low zero limbs are unchanged by negation. */ { *__gmp_rp = 0; if (!--__gmp_n) /* All zero */ return 0; ++__gmp_up; ++__gmp_rp; } *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK; if (--__gmp_n) /* Higher limbs get complemented. */ mpn_com (++__gmp_rp, ++__gmp_up, __gmp_n); return 1; } #endif #if defined (__cplusplus) } #endif /* Allow faster testing for negative, zero, and positive. */ #define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0) #define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0) #define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0) /* When using GCC, optimize certain common comparisons. */ #if defined (__GNUC__) && __GNUC__ >= 2 #define mpz_cmp_ui(Z,UI) \ (__builtin_constant_p (UI) && (UI) == 0 \ ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI)) #define mpz_cmp_si(Z,SI) \ (__builtin_constant_p ((SI) >= 0) && (SI) >= 0 \ ? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI)) \ : _mpz_cmp_si (Z,SI)) #define mpq_cmp_ui(Q,NUI,DUI) \ (__builtin_constant_p (NUI) && (NUI) == 0 ? mpq_sgn (Q) \ : __builtin_constant_p ((NUI) == (DUI)) && (NUI) == (DUI) \ ? mpz_cmp (mpq_numref (Q), mpq_denref (Q)) \ : _mpq_cmp_ui (Q,NUI,DUI)) #define mpq_cmp_si(q,n,d) \ (__builtin_constant_p ((n) >= 0) && (n) >= 0 \ ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \ : _mpq_cmp_si (q, n, d)) #else #define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI) #define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI) #define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI) #define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d) #endif /* Using "&" rather than "&&" means these can come out branch-free. Every mpz_t has at least one limb allocated, so fetching the low limb is always allowed. */ #define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0])) #define mpz_even_p(z) (! mpz_odd_p (z)) /**************** C++ routines ****************/ #ifdef __cplusplus __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr); __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr); __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr); __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr); __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr); __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr); #endif /* Source-level compatibility with GMP 2 and earlier. */ #define mpn_divmod(qp,np,nsize,dp,dsize) \ mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize) /* Source-level compatibility with GMP 1. */ #define mpz_mdiv mpz_fdiv_q #define mpz_mdivmod mpz_fdiv_qr #define mpz_mmod mpz_fdiv_r #define mpz_mdiv_ui mpz_fdiv_q_ui #define mpz_mdivmod_ui(q,r,n,d) \ (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d)) #define mpz_mmod_ui(r,n,d) \ (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d)) /* Useful synonyms, but not quite compatible with GMP 1. */ #define mpz_div mpz_fdiv_q #define mpz_divmod mpz_fdiv_qr #define mpz_div_ui mpz_fdiv_q_ui #define mpz_divmod_ui mpz_fdiv_qr_ui #define mpz_div_2exp mpz_fdiv_q_2exp #define mpz_mod_2exp mpz_fdiv_r_2exp enum { GMP_ERROR_NONE = 0, GMP_ERROR_UNSUPPORTED_ARGUMENT = 1, GMP_ERROR_DIVISION_BY_ZERO = 2, GMP_ERROR_SQRT_OF_NEGATIVE = 4, GMP_ERROR_INVALID_ARGUMENT = 8 }; /* Define CC and CFLAGS which were used to build this version of GMP */ #define __GMP_CC "@CC@" #define __GMP_CFLAGS "@CFLAGS@" /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */ #define __GNU_MP_VERSION 6 #define __GNU_MP_VERSION_MINOR 1 #define __GNU_MP_VERSION_PATCHLEVEL 0 #define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL) #define __GMP_H__ #endif /* __GMP_H__ */ gmp-6.1.0/scanf/000755 001756 001756 00000000000 12615426652 014546 5ustar00bodratobodrato000000 000000 gmp-6.1.0/Makefile.in000664 001756 001756 00000154375 12615426634 015542 0ustar00bodratobodrato000000 000000 # Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2015 Free # Software Foundation, Inc. # # This file is part of the GNU MP Library. # # The GNU MP Library is free software; you can redistribute it and/or modify # it under the terms of either: # # * the GNU Lesser General Public License as published by the Free # Software Foundation; either version 3 of the License, or (at your # option) any later version. # # or # # * the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any # later version. # # or both in parallel, as here. # # The GNU MP Library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received copies of the GNU General Public License and the # GNU Lesser General Public License along with the GNU MP Library. If not, # see https://www.gnu.org/licenses/. # The following options are the same as AM_INIT_AUTOMAKE in configure.in, # except no $(top_builddir) on ansi2knr. That directory is wanted for the # Makefiles in subdirectories, but here we must omit it so automake gives # the actual ansi2knr build rule, not "cd $(top_builddir) && make ansi2knr". # # AUTOMAKE_OPTIONS = 1.8 gnu no-dependencies # Libtool -version-info for libgmp.la and libmp.la. See "Versioning" in the # libtool manual. # # CURRENT:REVISION:AGE # # 1. No interfaces changed, only implementations (good): Increment REVISION. # # 2. Interfaces added, none removed (good): Increment CURRENT, increment # AGE, set REVISION to 0. # # 3. Interfaces removed (BAD, breaks upward compatibility): Increment # CURRENT, set AGE and REVISION to 0. # # Do this separately for libgmp, libgmpxx and libmp, and only for releases. # # GMP -version-info # release libgmp libgmpxx libmp # 2.0.x - - - # 3.0 3:0:0 - 3:0:0 # 3.0.1 3:1:0 - 3:0:0 # 3.1 4:0:1 - 4:0:1 # 3.1.1 4:1:1 - 4:1:1 # 4.0 5:0:2 3:0:0 4:2:1 # 4.0.1 5:1:2 3:1:0 4:3:1 # 4.1 6:0:3 3:2:0 4:4:1 # 4.1.1 6:1:3 3:3:0 4:5:1 # 4.1.2 6:2:3 3:4:0 4:6:1 # 4.1.3 6:3:3 3:5:0 4:7:1 # 4.1.4 6:3:3 3:5:0 4:7:1 WRONG, same as 4.1.3! # 4.2 6:0:3 3:2:0 4:4:1 REALLY WRONG, same as 4.1! # 4.2.1 7:1:4 4:1:1 4:10:1 WRONG for libgmpxx # 4.2.2 7:2:4 4:2:0 4:11:1 # 4.2.3 7:3:4 4:3:0 4:12:1 # 4.2.4 7:4:4 4:4:0 4:13:1 # 4.3.0 8:0:5 5:0:1 4:14:1 # 4.3.1 8:1:5 5:1:1 4:15:1 WRONG Really used same as 4.3.0 # 4.3.2 8:2:5 5:2:1 4:16:1 # 5.0.0 9:0:6 6:0:2 4:20:1 Should have been 10:0:0 # 5.0.1 10:1:0 6:1:2 4:21:1 # 5.0.2 10:2:0 6:2:2 4:22:1 # 5.0.3 10:3:0 6:3:2 4:23:1 # 5.0.4 10:4:0 6:4:2 4:24:1 # 5.0.5 10:5:0 6:5:2 4:25:1 # 5.1.0 11:0:1 7:0:3 - # 5.1.1 11:1:1 7:1:3 - # 5.1.2 11:2:1 7:2:3 - # 6.0.0 12:0:2 8:0:4 - # 6.1.0 13:0:3 9:0:5 - # # Starting at 3:0:0 is a slight abuse of the versioning system, but it # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux # packages of gmp 2. Pretend gmp 2 was 2:0:0, so the interface changes for # gmp 3 mean 3:0:0 is right. # # We interpret "implementation changed" in item "1." above as meaning any # release, ie. the REVISION is incremented every time (if nothing else). # Even if we thought the code generated will be identical on all systems, # it's still good to get the shared library filename (like # libgmpxx.so.3.0.4) incrementing, to make it clear which GMP it's from. VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__include_HEADERS_DIST) \ $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = gmp.h gmp-mparam.h CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" \ "$(DESTDIR)$(includeexecdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = $(MPF_OBJECTS) $(MPZ_OBJECTS) $(MPQ_OBJECTS) \ $(MPN_OBJECTS) $(PRINTF_OBJECTS) $(SCANF_OBJECTS) \ $(RANDOM_OBJECTS) am_libgmp_la_OBJECTS = assert.lo compat.lo errno.lo extract-dbl.lo \ invalid.lo memory.lo mp_bpl.lo mp_clz_tab.lo mp_dv_tab.lo \ mp_minv_tab.lo mp_get_fns.lo mp_set_fns.lo version.lo \ nextprime.lo primesieve.lo libgmp_la_OBJECTS = $(am_libgmp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libgmp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libgmp_la_LDFLAGS) $(LDFLAGS) -o $@ am_libgmpxx_la_OBJECTS = dummy.lo libgmpxx_la_OBJECTS = $(am_libgmpxx_la_OBJECTS) libgmpxx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(libgmpxx_la_LDFLAGS) $(LDFLAGS) -o $@ @WANT_CXX_TRUE@am_libgmpxx_la_rpath = -rpath $(libdir) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = am__depfiles_maybe = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libgmp_la_SOURCES) $(EXTRA_libgmp_la_SOURCES) \ $(libgmpxx_la_SOURCES) DIST_SOURCES = $(libgmp_la_SOURCES) $(EXTRA_libgmp_la_SOURCES) \ $(libgmpxx_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__include_HEADERS_DIST = gmpxx.h HEADERS = $(include_HEADERS) $(nodist_includeexec_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.in \ $(srcdir)/gmp-h.in AUTHORS COPYING ChangeLog INSTALL NEWS \ README compile config.guess config.sub install-sh ltmain.sh \ missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ABI = @ABI@ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ ASMFLAGS = @ASMFLAGS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@ CC = @CC@ CCAS = @CCAS@ CC_FOR_BUILD = @CC_FOR_BUILD@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPP_FOR_BUILD = @CPP_FOR_BUILD@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@ DEFS = @DEFS@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ FGREP = @FGREP@ GMP_LDFLAGS = @GMP_LDFLAGS@ GMP_LIMB_BITS = @GMP_LIMB_BITS@ GMP_NAIL_BITS = @GMP_NAIL_BITS@ GREP = @GREP@ HAVE_CLOCK_01 = @HAVE_CLOCK_01@ HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@ HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@ HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@ HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@ HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@ HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@ HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@ HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@ HAVE_STACK_T_01 = @HAVE_STACK_T_01@ HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCURSES = @LIBCURSES@ LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@ LIBGMP_DLL = @LIBGMP_DLL@ LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@ LIBM = @LIBM@ LIBM_FOR_BUILD = @LIBM_FOR_BUILD@ LIBOBJS = @LIBOBJS@ LIBREADLINE = @LIBREADLINE@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ M4 = @M4@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@ STRIP = @STRIP@ TAL_OBJECT = @TAL_OBJECT@ TUNE_LIBS = @TUNE_LIBS@ TUNE_SQR_OBJ = @TUNE_SQR_OBJ@ U_FOR_BUILD = @U_FOR_BUILD@ VERSION = @VERSION@ WITH_READLINE_01 = @WITH_READLINE_01@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ gmp_srclinks = @gmp_srclinks@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ mpn_objects = @mpn_objects@ mpn_objs_in_libgmp = @mpn_objs_in_libgmp@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ LIBGMP_LT_CURRENT = 13 LIBGMP_LT_REVISION = 0 LIBGMP_LT_AGE = 3 LIBGMPXX_LT_CURRENT = 9 LIBGMPXX_LT_REVISION = 0 LIBGMPXX_LT_AGE = 5 SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc # The "test -f" support for srcdir!=builddir is similar to the automake .c.o # etc rules, but with each foo.c explicitly, since $< is not portable # outside an inference rule. # # A quoted 'foo.c' is used with the "test -f"'s to avoid Sun make rewriting # it as part of its VPATH support. See the autoconf manual "Limitations of # Make". # # Generated .h files which are used by gmp-impl.h are BUILT_SOURCES since # they must exist before anything can be compiled. # # Other generated .h files are also BUILT_SOURCES so as to get all the # build-system stuff over and done with at the start. Also, dependencies on # the .h files are not properly expressed for the various objects that use # them. # Distribute mini-gmp. Test sources copied by dist-hook. EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \ COPYING.LESSERv3 COPYINGv2 COPYINGv3 gmpxx.h bootstrap.c \ gen-fac.c gen-fib.c gen-bases.c gen-trialdivtab.c \ gen-jacobitab.c gen-psqr.c mini-gmp/README mini-gmp/mini-gmp.c \ mini-gmp/mini-gmp.h mini-gmp/tests/Makefile \ mini-gmp/tests/run-tests @WANT_CXX_TRUE@GMPXX_HEADERS_OPTION = gmpxx.h # gmp.h and mp.h are architecture dependent, mainly since they encode the # limb size used in libgmp. For that reason they belong under $exec_prefix # not $prefix, strictly speaking. # # $exec_prefix/include is not in the default include path for gcc built to # the same $prefix and $exec_prefix, which might mean gmp.h is not found, # but anyone knowledgeable enough to be playing with exec_prefix will be able # to address that. # includeexecdir = $(exec_prefix)/include include_HEADERS = $(GMPXX_HEADERS_OPTION) nodist_includeexec_HEADERS = gmp.h lib_LTLIBRARIES = libgmp.la $(GMPXX_LTLIBRARIES_OPTION) BUILT_SOURCES = gmp.h fac_table.h fib_table.h mpn/fib_table.c \ mp_bases.h mpn/mp_bases.c trialdivtab.h mpn/jacobitab.h \ mpn/perfsqr.h DISTCLEANFILES = $(BUILT_SOURCES) config.m4 @gmp_srclinks@ \ gen-fac$(EXEEXT_FOR_BUILD) gen-fib$(EXEEXT_FOR_BUILD) \ gen-bases$(EXEEXT_FOR_BUILD) \ gen-trialdivtab$(EXEEXT_FOR_BUILD) \ gen-jacobitab$(EXEEXT_FOR_BUILD) gen-psqr$(EXEEXT_FOR_BUILD) # Tell gmp.h it's building gmp, not an application, used by windows DLL stuff. AM_CPPFLAGS = -D__GMP_WITHIN_GMP MPF_OBJECTS = mpf/init$U.lo mpf/init2$U.lo mpf/inits$U.lo mpf/set$U.lo \ mpf/set_ui$U.lo mpf/set_si$U.lo mpf/set_str$U.lo mpf/set_d$U.lo \ mpf/set_z$U.lo mpf/iset$U.lo mpf/iset_ui$U.lo mpf/iset_si$U.lo \ mpf/iset_str$U.lo mpf/iset_d$U.lo mpf/clear$U.lo mpf/clears$U.lo \ mpf/get_str$U.lo mpf/dump$U.lo mpf/size$U.lo mpf/eq$U.lo mpf/reldiff$U.lo \ mpf/sqrt$U.lo mpf/random2$U.lo mpf/inp_str$U.lo mpf/out_str$U.lo \ mpf/add$U.lo mpf/add_ui$U.lo mpf/sub$U.lo mpf/sub_ui$U.lo mpf/ui_sub$U.lo \ mpf/mul$U.lo mpf/mul_ui$U.lo mpf/div$U.lo mpf/div_ui$U.lo mpf/cmp_z$U.lo \ mpf/cmp$U.lo mpf/cmp_d$U.lo mpf/cmp_ui$U.lo mpf/cmp_si$U.lo \ mpf/mul_2exp$U.lo mpf/div_2exp$U.lo mpf/abs$U.lo mpf/neg$U.lo \ mpf/set_q$U.lo mpf/get_d$U.lo mpf/get_d_2exp$U.lo mpf/set_dfl_prec$U.lo \ mpf/set_prc$U.lo mpf/set_prc_raw$U.lo mpf/get_dfl_prec$U.lo \ mpf/get_prc$U.lo mpf/ui_div$U.lo mpf/sqrt_ui$U.lo \ mpf/ceilfloor$U.lo mpf/trunc$U.lo mpf/pow_ui$U.lo \ mpf/urandomb$U.lo mpf/swap$U.lo \ mpf/fits_sint$U.lo mpf/fits_slong$U.lo mpf/fits_sshort$U.lo \ mpf/fits_uint$U.lo mpf/fits_ulong$U.lo mpf/fits_ushort$U.lo \ mpf/get_si$U.lo mpf/get_ui$U.lo \ mpf/int_p$U.lo MPZ_OBJECTS = mpz/abs$U.lo mpz/add$U.lo mpz/add_ui$U.lo \ mpz/aorsmul$U.lo mpz/aorsmul_i$U.lo mpz/and$U.lo mpz/array_init$U.lo \ mpz/bin_ui$U.lo mpz/bin_uiui$U.lo \ mpz/cdiv_q$U.lo mpz/cdiv_q_ui$U.lo \ mpz/cdiv_qr$U.lo mpz/cdiv_qr_ui$U.lo \ mpz/cdiv_r$U.lo mpz/cdiv_r_ui$U.lo mpz/cdiv_ui$U.lo \ mpz/cfdiv_q_2exp$U.lo mpz/cfdiv_r_2exp$U.lo \ mpz/clear$U.lo mpz/clears$U.lo mpz/clrbit$U.lo \ mpz/cmp$U.lo mpz/cmp_d$U.lo mpz/cmp_si$U.lo mpz/cmp_ui$U.lo \ mpz/cmpabs$U.lo mpz/cmpabs_d$U.lo mpz/cmpabs_ui$U.lo \ mpz/com$U.lo mpz/combit$U.lo \ mpz/cong$U.lo mpz/cong_2exp$U.lo mpz/cong_ui$U.lo \ mpz/divexact$U.lo mpz/divegcd$U.lo mpz/dive_ui$U.lo \ mpz/divis$U.lo mpz/divis_ui$U.lo mpz/divis_2exp$U.lo mpz/dump$U.lo \ mpz/export$U.lo mpz/mfac_uiui$U.lo \ mpz/2fac_ui$U.lo mpz/fac_ui$U.lo mpz/oddfac_1$U.lo mpz/prodlimbs$U.lo \ mpz/fdiv_q_ui$U.lo mpz/fdiv_qr$U.lo mpz/fdiv_qr_ui$U.lo \ mpz/fdiv_r$U.lo mpz/fdiv_r_ui$U.lo mpz/fdiv_q$U.lo \ mpz/fdiv_ui$U.lo mpz/fib_ui$U.lo mpz/fib2_ui$U.lo mpz/fits_sint$U.lo \ mpz/fits_slong$U.lo mpz/fits_sshort$U.lo mpz/fits_uint$U.lo \ mpz/fits_ulong$U.lo mpz/fits_ushort$U.lo mpz/gcd$U.lo \ mpz/gcd_ui$U.lo mpz/gcdext$U.lo mpz/get_d$U.lo mpz/get_d_2exp$U.lo \ mpz/get_si$U.lo mpz/get_str$U.lo mpz/get_ui$U.lo mpz/getlimbn$U.lo \ mpz/hamdist$U.lo \ mpz/import$U.lo mpz/init$U.lo mpz/init2$U.lo mpz/inits$U.lo \ mpz/inp_raw$U.lo mpz/inp_str$U.lo mpz/invert$U.lo \ mpz/ior$U.lo mpz/iset$U.lo mpz/iset_d$U.lo mpz/iset_si$U.lo \ mpz/iset_str$U.lo mpz/iset_ui$U.lo mpz/jacobi$U.lo mpz/kronsz$U.lo \ mpz/kronuz$U.lo mpz/kronzs$U.lo mpz/kronzu$U.lo \ mpz/lcm$U.lo mpz/lcm_ui$U.lo mpz/limbs_finish$U.lo \ mpz/limbs_modify$U.lo mpz/limbs_read$U.lo mpz/limbs_write$U.lo \ mpz/lucnum_ui$U.lo mpz/lucnum2_ui$U.lo \ mpz/millerrabin$U.lo mpz/mod$U.lo mpz/mul$U.lo mpz/mul_2exp$U.lo \ mpz/mul_si$U.lo mpz/mul_ui$U.lo \ mpz/n_pow_ui$U.lo mpz/neg$U.lo mpz/nextprime$U.lo \ mpz/out_raw$U.lo mpz/out_str$U.lo mpz/perfpow$U.lo mpz/perfsqr$U.lo \ mpz/popcount$U.lo mpz/pow_ui$U.lo mpz/powm$U.lo mpz/powm_sec$U.lo \ mpz/powm_ui$U.lo mpz/primorial_ui$U.lo \ mpz/pprime_p$U.lo mpz/random$U.lo mpz/random2$U.lo \ mpz/realloc$U.lo mpz/realloc2$U.lo mpz/remove$U.lo mpz/roinit_n$U.lo \ mpz/root$U.lo mpz/rootrem$U.lo mpz/rrandomb$U.lo mpz/scan0$U.lo \ mpz/scan1$U.lo mpz/set$U.lo mpz/set_d$U.lo mpz/set_f$U.lo \ mpz/set_q$U.lo mpz/set_si$U.lo mpz/set_str$U.lo mpz/set_ui$U.lo \ mpz/setbit$U.lo \ mpz/size$U.lo mpz/sizeinbase$U.lo mpz/sqrt$U.lo \ mpz/sqrtrem$U.lo mpz/sub$U.lo mpz/sub_ui$U.lo mpz/swap$U.lo \ mpz/tdiv_ui$U.lo mpz/tdiv_q$U.lo mpz/tdiv_q_2exp$U.lo \ mpz/tdiv_q_ui$U.lo mpz/tdiv_qr$U.lo mpz/tdiv_qr_ui$U.lo \ mpz/tdiv_r$U.lo mpz/tdiv_r_2exp$U.lo mpz/tdiv_r_ui$U.lo \ mpz/tstbit$U.lo mpz/ui_pow_ui$U.lo mpz/ui_sub$U.lo mpz/urandomb$U.lo \ mpz/urandomm$U.lo mpz/xor$U.lo MPQ_OBJECTS = mpq/abs$U.lo mpq/aors$U.lo \ mpq/canonicalize$U.lo mpq/clear$U.lo mpq/clears$U.lo \ mpq/cmp$U.lo mpq/cmp_si$U.lo mpq/cmp_ui$U.lo mpq/div$U.lo \ mpq/get_d$U.lo mpq/get_den$U.lo mpq/get_num$U.lo mpq/get_str$U.lo \ mpq/init$U.lo mpq/inits$U.lo mpq/inp_str$U.lo mpq/inv$U.lo \ mpq/md_2exp$U.lo mpq/mul$U.lo mpq/neg$U.lo mpq/out_str$U.lo \ mpq/set$U.lo mpq/set_den$U.lo mpq/set_num$U.lo \ mpq/set_si$U.lo mpq/set_str$U.lo mpq/set_ui$U.lo \ mpq/equal$U.lo mpq/set_z$U.lo mpq/set_d$U.lo \ mpq/set_f$U.lo mpq/swap$U.lo MPN_OBJECTS = mpn/fib_table$U.lo mpn/mp_bases$U.lo PRINTF_OBJECTS = \ printf/asprintf$U.lo printf/asprntffuns$U.lo \ printf/doprnt$U.lo printf/doprntf$U.lo printf/doprnti$U.lo \ printf/fprintf$U.lo \ printf/obprintf$U.lo printf/obvprintf$U.lo printf/obprntffuns$U.lo \ printf/printf$U.lo printf/printffuns$U.lo \ printf/snprintf$U.lo printf/snprntffuns$U.lo \ printf/sprintf$U.lo printf/sprintffuns$U.lo \ printf/vasprintf$U.lo printf/vfprintf$U.lo printf/vprintf$U.lo \ printf/vsnprintf$U.lo printf/vsprintf$U.lo \ printf/repl-vsnprintf$U.lo SCANF_OBJECTS = \ scanf/doscan$U.lo scanf/fscanf$U.lo scanf/fscanffuns$U.lo \ scanf/scanf$U.lo scanf/sscanf$U.lo scanf/sscanffuns$U.lo \ scanf/vfscanf$U.lo scanf/vscanf$U.lo scanf/vsscanf$U.lo RANDOM_OBJECTS = \ rand/rand$U.lo rand/randclr$U.lo rand/randdef$U.lo rand/randiset$U.lo \ rand/randlc2s$U.lo rand/randlc2x$U.lo rand/randmt$U.lo \ rand/randmts$U.lo rand/rands$U.lo rand/randsd$U.lo rand/randsdui$U.lo \ rand/randbui$U.lo rand/randmui$U.lo # no $U for C++ files CXX_OBJECTS = \ cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo cxx/ismpznw.lo \ cxx/limits.lo cxx/osdoprnti.lo cxx/osfuns.lo \ cxx/osmpf.lo cxx/osmpq.lo cxx/osmpz.lo # In libtool 1.5 it doesn't work to build libgmp.la from the convenience # libraries like mpz/libmpz.la. Or rather it works, but it ends up putting # PIC objects into libgmp.a if shared and static are both built. (The PIC # objects go into mpz/.libs/libmpz.a, and thence into .libs/libgmp.a.) # # For now the big lists of objects above are used. Something like mpz/*.lo # would probably work, but might risk missing something out or getting # something extra. The source files for each .lo are listed in the # Makefile.am's in the subdirectories. # # Currently, for libgmp, unlike libmp below, we're not using # -export-symbols, since the tune and speed programs, and perhaps some of # the test programs, want to access undocumented symbols. libgmp_la_SOURCES = gmp-impl.h longlong.h \ assert.c compat.c errno.c extract-dbl.c invalid.c memory.c \ mp_bpl.c mp_clz_tab.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c mp_set_fns.c \ version.c nextprime.c primesieve.c EXTRA_libgmp_la_SOURCES = tal-debug.c tal-notreent.c tal-reent.c libgmp_la_DEPENDENCIES = @TAL_OBJECT@ \ $(MPF_OBJECTS) $(MPZ_OBJECTS) $(MPQ_OBJECTS) \ $(MPN_OBJECTS) @mpn_objs_in_libgmp@ \ $(PRINTF_OBJECTS) $(SCANF_OBJECTS) $(RANDOM_OBJECTS) libgmp_la_LIBADD = $(libgmp_la_DEPENDENCIES) libgmp_la_LDFLAGS = $(GMP_LDFLAGS) $(LIBGMP_LDFLAGS) \ -version-info $(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE) # We need at least one .cc file in $(libgmpxx_la_SOURCES) so automake will # use $(CXXLINK) rather than the plain C $(LINK). cxx/dummy.cc is that # file. @WANT_CXX_TRUE@GMPXX_LTLIBRARIES_OPTION = libgmpxx.la libgmpxx_la_SOURCES = cxx/dummy.cc libgmpxx_la_DEPENDENCIES = $(CXX_OBJECTS) libgmp.la libgmpxx_la_LIBADD = $(libgmpxx_la_DEPENDENCIES) libgmpxx_la_LDFLAGS = $(GMP_LDFLAGS) $(LIBGMPXX_LDFLAGS) \ -version-info $(LIBGMPXX_LT_CURRENT):$(LIBGMPXX_LT_REVISION):$(LIBGMPXX_LT_AGE) all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .cc .lo .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu --ignore-deps'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu --ignore-deps \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 gmp.h: $(top_builddir)/config.status $(srcdir)/gmp-h.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libgmp.la: $(libgmp_la_OBJECTS) $(libgmp_la_DEPENDENCIES) $(EXTRA_libgmp_la_DEPENDENCIES) $(AM_V_CCLD)$(libgmp_la_LINK) -rpath $(libdir) $(libgmp_la_OBJECTS) $(libgmp_la_LIBADD) $(LIBS) libgmpxx.la: $(libgmpxx_la_OBJECTS) $(libgmpxx_la_DEPENDENCIES) $(EXTRA_libgmpxx_la_DEPENDENCIES) $(AM_V_CXXLD)$(libgmpxx_la_LINK) $(am_libgmpxx_la_rpath) $(libgmpxx_la_OBJECTS) $(libgmpxx_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .c.o: $(AM_V_CC)$(COMPILE) -c -o $@ $< .c.obj: $(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: $(AM_V_CC)$(LTCOMPILE) -c -o $@ $< .cc.o: $(AM_V_CXX)$(CXXCOMPILE) -c -o $@ $< .cc.obj: $(AM_V_CXX)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: $(AM_V_CXX)$(LTCXXCOMPILE) -c -o $@ $< dummy.lo: cxx/dummy.cc $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dummy.lo `test -f 'cxx/dummy.cc' || echo '$(srcdir)/'`cxx/dummy.cc mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) install-nodist_includeexecHEADERS: $(nodist_includeexec_HEADERS) @$(NORMAL_INSTALL) @list='$(nodist_includeexec_HEADERS)'; test -n "$(includeexecdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includeexecdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includeexecdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includeexecdir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includeexecdir)" || exit $$?; \ done uninstall-nodist_includeexecHEADERS: @$(NORMAL_UNINSTALL) @list='$(nodist_includeexec_HEADERS)'; test -n "$(includeexecdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includeexecdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includeexecdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-recursive clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-local distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-includeHEADERS @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libLTLIBRARIES \ install-nodist_includeexecHEADERS install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \ uninstall-nodist_includeexecHEADERS .MAKE: $(am__recursive_targets) all check install install-am \ install-data-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libLTLIBRARIES clean-libtool clean-local cscope \ cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-hook dist-lzip dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-hdr distclean-libtool \ distclean-local distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-data-hook install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am \ install-includeHEADERS install-info install-info-am \ install-libLTLIBRARIES install-man \ install-nodist_includeexecHEADERS install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-includeHEADERS \ uninstall-libLTLIBRARIES uninstall-nodist_includeexecHEADERS .PRECIOUS: Makefile install-data-hook: @echo '' @echo '+-------------------------------------------------------------+' @echo '| CAUTION: |' @echo '| |' @echo '| If you have not already run "make check", then we strongly |' @echo '| recommend you do so. |' @echo '| |' @echo '| GMP has been carefully tested by its authors, but compilers |' @echo '| are all too often released with serious bugs. GMP tends to |' @echo '| explore interesting corners in compilers and has hit bugs |' @echo '| on quite a few occasions. |' @echo '| |' @echo '+-------------------------------------------------------------+' @echo '' fac_table.h: gen-fac$(EXEEXT_FOR_BUILD) ./gen-fac $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fac_table.h || (rm -f fac_table.h; exit 1) gen-fac$(EXEEXT_FOR_BUILD): gen-fac$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-fac$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fac$(U_FOR_BUILD).c -o gen-fac$(EXEEXT_FOR_BUILD) fib_table.h: gen-fib$(EXEEXT_FOR_BUILD) ./gen-fib header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fib_table.h || (rm -f fib_table.h; exit 1) mpn/fib_table.c: gen-fib$(EXEEXT_FOR_BUILD) ./gen-fib table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1) gen-fib$(EXEEXT_FOR_BUILD): gen-fib$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD) mp_bases.h: gen-bases$(EXEEXT_FOR_BUILD) ./gen-bases header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mp_bases.h || (rm -f mp_bases.h; exit 1) mpn/mp_bases.c: gen-bases$(EXEEXT_FOR_BUILD) ./gen-bases table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/mp_bases.c || (rm -f mpn/mp_bases.c; exit 1) gen-bases$(EXEEXT_FOR_BUILD): gen-bases$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-bases$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-bases$(U_FOR_BUILD).c -o gen-bases$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) trialdivtab.h: gen-trialdivtab$(EXEEXT_FOR_BUILD) ./gen-trialdivtab $(GMP_LIMB_BITS) 8000 >trialdivtab.h || (rm -f trialdivtab.h; exit 1) gen-trialdivtab$(EXEEXT_FOR_BUILD): gen-trialdivtab$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-trialdivtab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-trialdivtab$(U_FOR_BUILD).c -o gen-trialdivtab$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) mpn/jacobitab.h: gen-jacobitab$(EXEEXT_FOR_BUILD) ./gen-jacobitab >mpn/jacobitab.h || (rm -f mpn/jacobitab.h; exit 1) gen-jacobitab$(EXEEXT_FOR_BUILD): gen-jacobitab$(U_FOR_BUILD).c $(CC_FOR_BUILD) `test -f 'gen-jacobitab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-jacobitab$(U_FOR_BUILD).c -o gen-jacobitab$(EXEEXT_FOR_BUILD) mpn/perfsqr.h: gen-psqr$(EXEEXT_FOR_BUILD) ./gen-psqr $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1) gen-psqr$(EXEEXT_FOR_BUILD): gen-psqr$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-psqr$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-psqr$(U_FOR_BUILD).c -o gen-psqr$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) # Avoid: CVS - cvs directories # *~ - emacs backups # .#* - cvs merge originals # # *~ and .#* only occur when a whole directory without it's own Makefile.am # is distributed, like "doc" or the mpn cpu subdirectories. # dist-hook: -find $(distdir) \( -name CVS -type d \) -o -name "*~" -o -name ".#*" \ | xargs rm -rf cp "$(srcdir)"/mini-gmp/tests/*.[ch] "$(distdir)/mini-gmp/tests" # grep -F $(VERSION) $(srcdir)/Makefile.am \ # | grep -q "^# *$(VERSION) *$(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE) *$(LIBGMPXX_LT_CURRENT):$(LIBGMPXX_LT_REVISION):$(LIBGMPXX_LT_AGE)" # test -z "`sed -n 's/^# *[0-9]*\.[0-9]*\.[0-9]* *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\).*/A\1\nB\2\nC\3/p' $(srcdir)/Makefile.am | grep -v 'A6:3:3\|B3:5:0\|C4:7:1' | sort | uniq -d`" .PHONY: check-mini-gmp clean-mini-gmp check-mini-gmp: abs_srcdir="`cd $(srcdir) && pwd`" ; \ $(MKDIR_P) mini-gmp/tests \ && cd mini-gmp/tests \ && LD_LIBRARY_PATH="../../.libs:$$LD_LIBRARY_PATH" \ DYLD_LIBRARY_PATH="../../.libs:$$DYLD_LIBRARY_PATH" \ $(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" \ VPATH="$$abs_srcdir/mini-gmp/tests" \ srcdir="$$abs_srcdir/mini-gmp/tests" \ MINI_GMP_DIR="$$abs_srcdir/mini-gmp" \ LDFLAGS="-L../../.libs" \ LIBS="-lgmp -lm" \ CC="$(CC_FOR_BUILD)" EXTRA_CFLAGS="-g -I../.." check clean-mini-gmp: if [ -d mini-gmp/tests ] ; then \ abs_srcdir="`cd $(srcdir) && pwd`" ; \ cd mini-gmp/tests \ && $(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" clean ; \ fi clean-local: clean-mini-gmp distclean-local: clean-mini-gmp # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: gmp-6.1.0/compile000755 001756 001756 00000016245 12572636756 015054 0ustar00bodratobodrato000000 000000 #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2014 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gmp-6.1.0/AUTHORS000664 001756 001756 00000007156 12615426624 014536 0ustar00bodratobodrato000000 000000 Authors of GNU MP (in chronological order of initial contribution) Torbjörn Granlund Main author John Amanatides Original version of mpz/pprime_p.c Paul Zimmermann mpn/generic/mul_fft.c, now defunct dc_divrem_n.c, rootrem.c, old mpz/powm.c, old toom3 code. Ken Weber Now defunct mpn/generic/bdivmod.c, old mpn/generic/gcd.c Bennet Yee Previous versions of mpz/jacobi.c mpz/legendre.c Andreas Schwab mpn/m68k/lshift.asm, mpn/m68k/rshift.asm Robert Harley Old mpn/generic/mul_n.c, previous versions of files in mpn/arm Linus Nordberg Random number framework, original autoconfery Kent Boortz MacOS 9 port, now defunct. Kevin Ryde Most x86 assembly, new autoconfery, and countless other things (please see the GMP manual for complete list) Gerardo Ballabio gmpxx.h and C++ istream input Pedro Gimeno Mersenne Twister random generator, other random number revisions Jason Moxham Previous versions of mpz/fac_ui.c and gen-fac_ui.c Niels Möller gen-jacobitab.c, mpn/generic/hgcd2.c, hgcd.c, hgcd_step.c, hgcd_appr.c, hgcd_matrix.c, hgcd_reduce.c, gcd.c, gcdext.c, matrix22_mul.c, gcdext_1.c, gcd_subdiv_step.c, gcd_lehmer.c, gcdext_subdiv_step.c, gcdext_lehmer.c, jacobi_2.c, jacbase.c, hgcd_jacobi.c, hgcd2_jacobi.c matrix22_mul1_inverse_vector.c, toom_interpolate_7pts, mulmod_bnm1.c, dcpi1_bdiv_qr.c, dcpi1_bdiv_q.c, sbpi1_bdiv_qr.c, sbpi1_bdiv_q.c, sec_invert.c, toom_eval_dgr3_pm1.c, toom_eval_dgr3_pm2.c, toom_eval_pm1.c, toom_eval_pm2.c, toom_eval_pm2exp.c, divexact.c, mod_1_1.c, div_qr_2.c, div_qr_2n_pi1.c, div_qr_2u_pi1.c, broot.c, brootinv.c, mpn/x86/k7/invert_limb.asm, mod_1_1.asm, mpn/x86_64/invert_limb.asm, invert_limb_table.asm, mod_1_1.asm, div_qr_2n_pi1.asm, div_qr_2u_pi1.asm, mpn/x86_64/core2/aorsmul_1.asm, mpz/nextprime.c, divexact.c, gcd.c, gcdext.c, jacobi.c, combit.c, mini-gmp/mini-gmp.c. Marco Bodrato mpn/generic/toom44_mul.c, toom4_sqr.c, toom53_mul.c, toom62_mul.c, toom43_mul.c, toom52_mul.c, toom54_mul.c, toom_interpolate_6pts.c, toom_couple_handling.c, toom63_mul.c, toom_interpolate_8pts.c, toom6h_mul.c, toom6_sqr.c, toom_interpolate_12pts.c, toom8h_mul.c, toom8_sqr.c, toom_interpolate_16pts.c, mulmod_bnm1.c, sqrmod_bnm1.c, nussbaumer_mul.c, toom_eval_pm2.c, toom_eval_pm2rexp.c, mullo_n.c, sqrlo.c, invert.c, invertappr.c; mpz/fac_ui.c, 2fac_ui.c, mfac_uiui.c, oddfac_1.c, primorial_ui.c, prodlimbs.c, goetgheluck_bin_uiui.c. David Harvey mpn/generic/add_err1_n.c, add_err2_n.c, add_err3_n.c, sub_err1_n.c, sub_err2_n.c, sub_err3_n.c, mulmid_basecase.c, mulmid_n.c, toom42_mulmid.c, mpn/x86_64/mul_basecase.asm, aors_err1_n.asm, aors_err2_n.asm, aors_err3_n.asm, mulmid_basecase.asm, mpn/x86_64/core2/aors_err1_n.asm. Martin Boij mpn/generic/perfpow.c Marc Glisse gmpxx.h improvements David Miller mpn/sparc32/ultrasparct1/{addmul_1,mul_1,submul_1}.asm mpn/sparc64/ultrasparct3/{mul_1,addmul_1,submul_1}.asm mpn/sparc64/ultrasparct3/{add_n,sub_n}.asm mpn/sparc64/ultrasparct3/{popcount,hamdist}.asm mpn/sparc64/ultrasparct3/cnd_aors_n.asm mpn/sparc64/{rshift,lshift,lshiftc}.asm mpn/sparc64/tabselect.asm Mark Sofroniou mpn/generic/mul_fft.c type cleanup. Ulrich Weigand Changes to support powerpc64le: configure.ac, mpn/powerpc64/{elf,aix,darwin}.m4, mpn/powerpc32/{darwin,elf}.m4, mpn/powerpc64/mode64/{dive_1,divrem_1,divrem_2}.asm, mpn/powerpc64/mode64/{gcd_1,invert_limb,mode1o}.asm, mpn/powerpc64/mode64/{mod_1_1,mod_1_4}.asm, mpn/powerpc64/mode64/p7/gcd_1.asm, mpn/powerpc64/p6/{lshift,lshiftc,rshift}.asm, mpn/powerpc64/vmx/popcount.asm. gmp-6.1.0/gen-bases.c000664 001756 001756 00000014010 12615426624 015461 0ustar00bodratobodrato000000 000000 /* Generate mp_bases data. Copyright 1991, 1993, 1994, 1996, 2000, 2002, 2004, 2011, 2012 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "bootstrap.c" int chars_per_limb; mpz_t big_base; int normalization_steps; mpz_t big_base_inverted; mpz_t t; #define POW2_P(n) (((n) & ((n) - 1)) == 0) unsigned int ulog2 (unsigned int x) { unsigned int i; for (i = 0; x != 0; i++) x >>= 1; return i; } void generate (int limb_bits, int nail_bits, int base) { int numb_bits = limb_bits - nail_bits; mpz_set_ui (t, 1L); mpz_mul_2exp (t, t, numb_bits); mpz_set_ui (big_base, 1L); chars_per_limb = 0; for (;;) { mpz_mul_ui (big_base, big_base, (long) base); if (mpz_cmp (big_base, t) > 0) break; chars_per_limb++; } mpz_ui_pow_ui (big_base, (long) base, (long) chars_per_limb); normalization_steps = limb_bits - mpz_sizeinbase (big_base, 2); mpz_set_ui (t, 1L); mpz_mul_2exp (t, t, 2*limb_bits - normalization_steps); mpz_tdiv_q (big_base_inverted, t, big_base); mpz_set_ui (t, 1L); mpz_mul_2exp (t, t, limb_bits); mpz_sub (big_base_inverted, big_base_inverted, t); } void header (int limb_bits, int nail_bits) { int numb_bits = limb_bits - nail_bits; generate (limb_bits, nail_bits, 10); printf ("/* This file generated by gen-bases.c - DO NOT EDIT. */\n"); printf ("\n"); printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); printf ("Error, error, this data is for %d bits\n", numb_bits); printf ("#endif\n"); printf ("\n"); printf ("/* mp_bases[10] data, as literal values */\n"); printf ("#define MP_BASES_CHARS_PER_LIMB_10 %d\n", chars_per_limb); printf ("#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x"); mpz_out_str (stdout, 16, big_base); printf (")\n"); printf ("#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0x"); mpz_out_str (stdout, 16, big_base_inverted); printf (")\n"); printf ("#define MP_BASES_NORMALIZATION_STEPS_10 %d\n", normalization_steps); } #define EXTRA 16 /* Compute log(2)/log(b) as a fixnum. */ void mp_2logb (mpz_t r, int bi, int prec) { mpz_t t, t2, two, b; int i; mpz_init_set_ui (t, 1); mpz_mul_2exp (t, t, prec+EXTRA); mpz_init (t2); mpz_init_set_ui (two, 2); mpz_mul_2exp (two, two, prec+EXTRA); mpz_set_ui (r, 0); mpz_init_set_ui (b, bi); mpz_mul_2exp (b, b, prec+EXTRA); for (i = prec-1; i >= 0; i--) { mpz_mul_2exp (b, b, prec+EXTRA); mpz_sqrt (b, b); mpz_mul (t2, t, b); mpz_tdiv_q_2exp (t2, t2, prec+EXTRA); if (mpz_cmp (t2, two) < 0) /* not too large? */ { mpz_setbit (r, i); /* set next less significant bit */ mpz_set (t, t2); /* new value acceptable */ } } mpz_clear (t); mpz_clear (t2); mpz_clear (two); mpz_clear (b); } void table (int limb_bits, int nail_bits) { int numb_bits = limb_bits - nail_bits; int base; mpz_t r, t, logb2, log2b; mpz_init (r); mpz_init (t); mpz_init (logb2); mpz_init (log2b); printf ("/* This file generated by gen-bases.c - DO NOT EDIT. */\n"); printf ("\n"); printf ("#include \"gmp.h\"\n"); printf ("#include \"gmp-impl.h\"\n"); printf ("\n"); printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); printf ("Error, error, this data is for %d bits\n", numb_bits); printf ("#endif\n"); printf ("\n"); puts ("const struct bases mp_bases[257] =\n{"); puts (" /* 0 */ { 0, 0, 0, 0, 0 },"); puts (" /* 1 */ { 0, 0, 0, 0, 0 },"); for (base = 2; base <= 256; base++) { generate (limb_bits, nail_bits, base); mp_2logb (r, base, limb_bits + 8); mpz_tdiv_q_2exp (logb2, r, 8); mpz_set_ui (t, 1); mpz_mul_2exp (t, t, 2*limb_bits + 5); mpz_sub_ui (t, t, 1); mpz_add_ui (r, r, 1); mpz_tdiv_q (log2b, t, r); printf (" /* %3u */ { ", base); if (POW2_P (base)) { mpz_set_ui (big_base, ulog2 (base) - 1); mpz_set_ui (big_base_inverted, 0); } printf ("%u,", chars_per_limb); printf (" CNST_LIMB(0x"); mpz_out_str (stdout, 16, logb2); printf ("), CNST_LIMB(0x"); mpz_out_str (stdout, 16, log2b); printf ("), CNST_LIMB(0x"); mpz_out_str (stdout, 16, big_base); printf ("), CNST_LIMB(0x"); mpz_out_str (stdout, 16, big_base_inverted); printf (") },\n"); } puts ("};"); mpz_clear (r); mpz_clear (t); mpz_clear (logb2); mpz_clear (log2b); } int main (int argc, char **argv) { int limb_bits, nail_bits; mpz_init (big_base); mpz_init (big_base_inverted); mpz_init (t); if (argc != 4) { fprintf (stderr, "Usage: gen-bases \n"); exit (1); } limb_bits = atoi (argv[2]); nail_bits = atoi (argv[3]); if (limb_bits <= 0 || nail_bits < 0 || nail_bits >= limb_bits) { fprintf (stderr, "Invalid limb/nail bits: %d %d\n", limb_bits, nail_bits); exit (1); } if (strcmp (argv[1], "header") == 0) header (limb_bits, nail_bits); else if (strcmp (argv[1], "table") == 0) table (limb_bits, nail_bits); else { fprintf (stderr, "Invalid header/table choice: %s\n", argv[1]); exit (1); } return 0; } gmp-6.1.0/gmpxx.h000664 001756 001756 00000343577 12615426624 015014 0ustar00bodratobodrato000000 000000 /* gmpxx.h -- C++ class wrapper for GMP types. -*- C++ -*- Copyright 2001-2003, 2006, 2008, 2011, 2012 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #ifndef __GMP_PLUSPLUS__ #define __GMP_PLUSPLUS__ #include #include /* for strlen */ #include /* numeric_limits */ #include #include /* swap */ #include #include #include #include // wrapper for gcc's __builtin_constant_p // __builtin_constant_p has been in gcc since forever, // but g++-3.4 miscompiles it. #if __GMP_GNUC_PREREQ(4, 2) #define __GMPXX_CONSTANT(X) __builtin_constant_p(X) #else #define __GMPXX_CONSTANT(X) false #endif #define __GMPXX_CONSTANT_TRUE(X) (__GMPXX_CONSTANT(X) && (X)) // Use C++11 features #ifndef __GMPXX_USE_CXX11 #if __cplusplus >= 201103L #define __GMPXX_USE_CXX11 1 #else #define __GMPXX_USE_CXX11 0 #endif #endif #if __GMPXX_USE_CXX11 #define __GMPXX_NOEXCEPT noexcept #include // for common_type #else #define __GMPXX_NOEXCEPT #endif // Max allocations for plain types when converted to GMP types #if GMP_NAIL_BITS != 0 && ! defined _LONG_LONG_LIMB #define __GMPZ_ULI_LIMBS 2 #else #define __GMPZ_ULI_LIMBS 1 #endif #define __GMPXX_BITS_TO_LIMBS(n) (((n) + (GMP_NUMB_BITS - 1)) / GMP_NUMB_BITS) #define __GMPZ_DBL_LIMBS __GMPXX_BITS_TO_LIMBS(DBL_MAX_EXP)+1 #define __GMPQ_NUM_DBL_LIMBS __GMPZ_DBL_LIMBS #define __GMPQ_DEN_DBL_LIMBS __GMPXX_BITS_TO_LIMBS(DBL_MANT_DIG+1-DBL_MIN_EXP)+1 // The final +1s are a security margin. The current implementation of // mpq_set_d seems to need it for the denominator. inline void __mpz_set_ui_safe(mpz_ptr p, unsigned long l) { p->_mp_size = (l != 0); p->_mp_d[0] = l & GMP_NUMB_MASK; #if __GMPZ_ULI_LIMBS > 1 l >>= GMP_NUMB_BITS; p->_mp_d[1] = l; p->_mp_size += (l != 0); #endif } inline void __mpz_set_si_safe(mpz_ptr p, long l) { if(l < 0) { __mpz_set_ui_safe(p, -static_cast(l)); mpz_neg(p, p); } else __mpz_set_ui_safe(p, l); // Note: we know the high bit of l is 0 so we could do slightly better } // Fake temporary variables #define __GMPXX_TMPZ_UI \ mpz_t temp; \ mp_limb_t limbs[__GMPZ_ULI_LIMBS]; \ temp->_mp_d = limbs; \ __mpz_set_ui_safe (temp, l) #define __GMPXX_TMPZ_SI \ mpz_t temp; \ mp_limb_t limbs[__GMPZ_ULI_LIMBS]; \ temp->_mp_d = limbs; \ __mpz_set_si_safe (temp, l) #define __GMPXX_TMPZ_D \ mpz_t temp; \ mp_limb_t limbs[__GMPZ_DBL_LIMBS]; \ temp->_mp_d = limbs; \ temp->_mp_alloc = __GMPZ_DBL_LIMBS; \ mpz_set_d (temp, d) #define __GMPXX_TMPQ_UI \ mpq_t temp; \ mp_limb_t limbs[__GMPZ_ULI_LIMBS+1]; \ mpq_numref(temp)->_mp_d = limbs; \ __mpz_set_ui_safe (mpq_numref(temp), l); \ mpq_denref(temp)->_mp_d = limbs + __GMPZ_ULI_LIMBS; \ mpq_denref(temp)->_mp_size = 1; \ mpq_denref(temp)->_mp_d[0] = 1 #define __GMPXX_TMPQ_SI \ mpq_t temp; \ mp_limb_t limbs[__GMPZ_ULI_LIMBS+1]; \ mpq_numref(temp)->_mp_d = limbs; \ __mpz_set_si_safe (mpq_numref(temp), l); \ mpq_denref(temp)->_mp_d = limbs + __GMPZ_ULI_LIMBS; \ mpq_denref(temp)->_mp_size = 1; \ mpq_denref(temp)->_mp_d[0] = 1 #define __GMPXX_TMPQ_D \ mpq_t temp; \ mp_limb_t limbs[__GMPQ_NUM_DBL_LIMBS + __GMPQ_DEN_DBL_LIMBS]; \ mpq_numref(temp)->_mp_d = limbs; \ mpq_numref(temp)->_mp_alloc = __GMPQ_NUM_DBL_LIMBS; \ mpq_denref(temp)->_mp_d = limbs + __GMPQ_NUM_DBL_LIMBS; \ mpq_denref(temp)->_mp_alloc = __GMPQ_DEN_DBL_LIMBS; \ mpq_set_d (temp, d) inline unsigned long __gmpxx_abs_ui (signed long l) { return l >= 0 ? static_cast(l) : -static_cast(l); } /**************** Function objects ****************/ /* Any evaluation of a __gmp_expr ends up calling one of these functions all intermediate functions being inline, the evaluation should optimize to a direct call to the relevant function, thus yielding no overhead over the C interface. */ struct __gmp_unary_plus { static void eval(mpz_ptr z, mpz_srcptr w) { mpz_set(z, w); } static void eval(mpq_ptr q, mpq_srcptr r) { mpq_set(q, r); } static void eval(mpf_ptr f, mpf_srcptr g) { mpf_set(f, g); } }; struct __gmp_unary_minus { static void eval(mpz_ptr z, mpz_srcptr w) { mpz_neg(z, w); } static void eval(mpq_ptr q, mpq_srcptr r) { mpq_neg(q, r); } static void eval(mpf_ptr f, mpf_srcptr g) { mpf_neg(f, g); } }; struct __gmp_unary_com { static void eval(mpz_ptr z, mpz_srcptr w) { mpz_com(z, w); } }; struct __gmp_binary_plus { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_add(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { // Ideally, those checks should happen earlier so that the tree // generated for a+0+b would just be sum(a,b). if (__GMPXX_CONSTANT(l) && l == 0) { if (z != w) mpz_set(z, w); } else mpz_add_ui(z, w, l); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { if (l >= 0) eval(z, w, static_cast(l)); else mpz_sub_ui(z, w, -static_cast(l)); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_add (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { eval(z, w, d); } static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) { mpq_add(q, r, s); } static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) { if (__GMPXX_CONSTANT(l) && l == 0) { if (q != r) mpq_set(q, r); } else { if (q == r) mpz_addmul_ui(mpq_numref(q), mpq_denref(q), l); else { mpz_mul_ui(mpq_numref(q), mpq_denref(r), l); mpz_add(mpq_numref(q), mpq_numref(q), mpq_numref(r)); mpz_set(mpq_denref(q), mpq_denref(r)); } } } static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) { eval(q, r, l); } static inline void eval(mpq_ptr q, mpq_srcptr r, signed long int l); // defined after __gmp_binary_minus static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) { eval(q, r, l); } static void eval(mpq_ptr q, mpq_srcptr r, double d) { __GMPXX_TMPQ_D; mpq_add (q, r, temp); } static void eval(mpq_ptr q, double d, mpq_srcptr r) { eval(q, r, d); } static void eval(mpq_ptr q, mpq_srcptr r, mpz_srcptr z) { if (q == r) mpz_addmul(mpq_numref(q), mpq_denref(q), z); else { mpz_mul(mpq_numref(q), mpq_denref(r), z); mpz_add(mpq_numref(q), mpq_numref(q), mpq_numref(r)); mpz_set(mpq_denref(q), mpq_denref(r)); } } static void eval(mpq_ptr q, mpz_srcptr z, mpq_srcptr r) { eval(q, r, z); } static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) { mpf_add(f, g, h); } static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) { mpf_add_ui(f, g, l); } static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) { mpf_add_ui(f, g, l); } static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) { if (l >= 0) mpf_add_ui(f, g, l); else mpf_sub_ui(f, g, -static_cast(l)); } static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) { eval(f, g, l); } static void eval(mpf_ptr f, mpf_srcptr g, double d) { mpf_t temp; mpf_init2(temp, 8*sizeof(double)); mpf_set_d(temp, d); mpf_add(f, g, temp); mpf_clear(temp); } static void eval(mpf_ptr f, double d, mpf_srcptr g) { eval(f, g, d); } }; struct __gmp_binary_minus { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_sub(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { if (__GMPXX_CONSTANT(l) && l == 0) { if (z != w) mpz_set(z, w); } else mpz_sub_ui(z, w, l); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { if (__GMPXX_CONSTANT(l) && l == 0) { mpz_neg(z, w); } else mpz_ui_sub(z, l, w); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { if (l >= 0) eval(z, w, static_cast(l)); else mpz_add_ui(z, w, -static_cast(l)); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { if (l >= 0) eval(z, static_cast(l), w); else { mpz_add_ui(z, w, -static_cast(l)); mpz_neg(z, z); } } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_sub (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { __GMPXX_TMPZ_D; mpz_sub (z, temp, w); } static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) { mpq_sub(q, r, s); } static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) { if (__GMPXX_CONSTANT(l) && l == 0) { if (q != r) mpq_set(q, r); } else { if (q == r) mpz_submul_ui(mpq_numref(q), mpq_denref(q), l); else { mpz_mul_ui(mpq_numref(q), mpq_denref(r), l); mpz_sub(mpq_numref(q), mpq_numref(r), mpq_numref(q)); mpz_set(mpq_denref(q), mpq_denref(r)); } } } static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) { eval(q, r, l); mpq_neg(q, q); } static void eval(mpq_ptr q, mpq_srcptr r, signed long int l) { if (l >= 0) eval(q, r, static_cast(l)); else __gmp_binary_plus::eval(q, r, -static_cast(l)); } static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) { eval(q, r, l); mpq_neg(q, q); } static void eval(mpq_ptr q, mpq_srcptr r, double d) { __GMPXX_TMPQ_D; mpq_sub (q, r, temp); } static void eval(mpq_ptr q, double d, mpq_srcptr r) { __GMPXX_TMPQ_D; mpq_sub (q, temp, r); } static void eval(mpq_ptr q, mpq_srcptr r, mpz_srcptr z) { if (q == r) mpz_submul(mpq_numref(q), mpq_denref(q), z); else { mpz_mul(mpq_numref(q), mpq_denref(r), z); mpz_sub(mpq_numref(q), mpq_numref(r), mpq_numref(q)); mpz_set(mpq_denref(q), mpq_denref(r)); } } static void eval(mpq_ptr q, mpz_srcptr z, mpq_srcptr r) { eval(q, r, z); mpq_neg(q, q); } static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) { mpf_sub(f, g, h); } static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) { mpf_sub_ui(f, g, l); } static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) { mpf_ui_sub(f, l, g); } static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) { if (l >= 0) mpf_sub_ui(f, g, l); else mpf_add_ui(f, g, -static_cast(l)); } static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) { if (l >= 0) mpf_sub_ui(f, g, l); else mpf_add_ui(f, g, -static_cast(l)); mpf_neg(f, f); } static void eval(mpf_ptr f, mpf_srcptr g, double d) { mpf_t temp; mpf_init2(temp, 8*sizeof(double)); mpf_set_d(temp, d); mpf_sub(f, g, temp); mpf_clear(temp); } static void eval(mpf_ptr f, double d, mpf_srcptr g) { mpf_t temp; mpf_init2(temp, 8*sizeof(double)); mpf_set_d(temp, d); mpf_sub(f, temp, g); mpf_clear(temp); } }; // defined here so it can reference __gmp_binary_minus inline void __gmp_binary_plus::eval(mpq_ptr q, mpq_srcptr r, signed long int l) { if (l >= 0) eval(q, r, static_cast(l)); else __gmp_binary_minus::eval(q, r, -static_cast(l)); } struct __gmp_binary_lshift { static void eval(mpz_ptr z, mpz_srcptr w, mp_bitcnt_t l) { if (__GMPXX_CONSTANT(l) && (l == 0)) { if (z != w) mpz_set(z, w); } else mpz_mul_2exp(z, w, l); } static void eval(mpq_ptr q, mpq_srcptr r, mp_bitcnt_t l) { if (__GMPXX_CONSTANT(l) && (l == 0)) { if (q != r) mpq_set(q, r); } else mpq_mul_2exp(q, r, l); } static void eval(mpf_ptr f, mpf_srcptr g, mp_bitcnt_t l) { mpf_mul_2exp(f, g, l); } }; struct __gmp_binary_rshift { static void eval(mpz_ptr z, mpz_srcptr w, mp_bitcnt_t l) { if (__GMPXX_CONSTANT(l) && (l == 0)) { if (z != w) mpz_set(z, w); } else mpz_fdiv_q_2exp(z, w, l); } static void eval(mpq_ptr q, mpq_srcptr r, mp_bitcnt_t l) { if (__GMPXX_CONSTANT(l) && (l == 0)) { if (q != r) mpq_set(q, r); } else mpq_div_2exp(q, r, l); } static void eval(mpf_ptr f, mpf_srcptr g, mp_bitcnt_t l) { mpf_div_2exp(f, g, l); } }; struct __gmp_binary_multiplies { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_mul(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { // gcc-3.3 doesn't have __builtin_ctzl. Don't bother optimizing for old gcc. #if __GMP_GNUC_PREREQ(3, 4) if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0) { if (l == 0) { z->_mp_size = 0; } else { __gmp_binary_lshift::eval(z, w, __builtin_ctzl(l)); } } else #endif mpz_mul_ui(z, w, l); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) eval(z, w, static_cast(l)); else if (__GMPXX_CONSTANT_TRUE(l <= 0)) { eval(z, w, -static_cast(l)); mpz_neg(z, z); } else mpz_mul_si (z, w, l); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_mul (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { eval(z, w, d); } static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) { mpq_mul(q, r, s); } static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) { #if __GMP_GNUC_PREREQ(3, 4) if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0) { if (l == 0) { mpq_set_ui(q, 0, 1); } else { __gmp_binary_lshift::eval(q, r, __builtin_ctzl(l)); } } else #endif { __GMPXX_TMPQ_UI; mpq_mul (q, r, temp); } } static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) { eval(q, r, l); } static void eval(mpq_ptr q, mpq_srcptr r, signed long int l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) eval(q, r, static_cast(l)); else if (__GMPXX_CONSTANT_TRUE(l <= 0)) { eval(q, r, -static_cast(l)); mpq_neg(q, q); } else { __GMPXX_TMPQ_SI; mpq_mul (q, r, temp); } } static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) { eval(q, r, l); } static void eval(mpq_ptr q, mpq_srcptr r, double d) { __GMPXX_TMPQ_D; mpq_mul (q, r, temp); } static void eval(mpq_ptr q, double d, mpq_srcptr r) { eval(q, r, d); } static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) { mpf_mul(f, g, h); } static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) { mpf_mul_ui(f, g, l); } static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) { mpf_mul_ui(f, g, l); } static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) { if (l >= 0) mpf_mul_ui(f, g, l); else { mpf_mul_ui(f, g, -static_cast(l)); mpf_neg(f, f); } } static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) { eval(f, g, l); } static void eval(mpf_ptr f, mpf_srcptr g, double d) { mpf_t temp; mpf_init2(temp, 8*sizeof(double)); mpf_set_d(temp, d); mpf_mul(f, g, temp); mpf_clear(temp); } static void eval(mpf_ptr f, double d, mpf_srcptr g) { eval(f, g, d); } }; struct __gmp_binary_divides { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_tdiv_q(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { #if __GMP_GNUC_PREREQ(3, 4) // Don't optimize division by 0... if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0 && l != 0) { if (l == 1) { if (z != w) mpz_set(z, w); } else mpz_tdiv_q_2exp(z, w, __builtin_ctzl(l)); // warning: do not use rshift (fdiv) } else #endif mpz_tdiv_q_ui(z, w, l); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { if (mpz_sgn(w) >= 0) { if (mpz_fits_ulong_p(w)) mpz_set_ui(z, l / mpz_get_ui(w)); else mpz_set_ui(z, 0); } else { mpz_neg(z, w); if (mpz_fits_ulong_p(z)) { mpz_set_ui(z, l / mpz_get_ui(z)); mpz_neg(z, z); } else mpz_set_ui(z, 0); } } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { if (l >= 0) eval(z, w, static_cast(l)); else { eval(z, w, -static_cast(l)); mpz_neg(z, z); } } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { if (mpz_fits_slong_p(w)) mpz_set_si(z, l / mpz_get_si(w)); else { /* if w is bigger than a long then the quotient must be zero, unless l==LONG_MIN and w==-LONG_MIN in which case the quotient is -1 */ mpz_set_si (z, (mpz_cmpabs_ui (w, __gmpxx_abs_ui(l)) == 0 ? -1 : 0)); } } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_tdiv_q (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { __GMPXX_TMPZ_D; mpz_tdiv_q (z, temp, w); } static void eval(mpq_ptr q, mpq_srcptr r, mpq_srcptr s) { mpq_div(q, r, s); } static void eval(mpq_ptr q, mpq_srcptr r, unsigned long int l) { #if __GMP_GNUC_PREREQ(3, 4) if (__GMPXX_CONSTANT(l) && (l & (l-1)) == 0 && l != 0) __gmp_binary_rshift::eval(q, r, __builtin_ctzl(l)); else #endif { __GMPXX_TMPQ_UI; mpq_div (q, r, temp); } } static void eval(mpq_ptr q, unsigned long int l, mpq_srcptr r) { __GMPXX_TMPQ_UI; mpq_div (q, temp, r); } static void eval(mpq_ptr q, mpq_srcptr r, signed long int l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) eval(q, r, static_cast(l)); else if (__GMPXX_CONSTANT_TRUE(l <= 0)) { eval(q, r, -static_cast(l)); mpq_neg(q, q); } else { __GMPXX_TMPQ_SI; mpq_div (q, r, temp); } } static void eval(mpq_ptr q, signed long int l, mpq_srcptr r) { __GMPXX_TMPQ_SI; mpq_div (q, temp, r); } static void eval(mpq_ptr q, mpq_srcptr r, double d) { __GMPXX_TMPQ_D; mpq_div (q, r, temp); } static void eval(mpq_ptr q, double d, mpq_srcptr r) { __GMPXX_TMPQ_D; mpq_div (q, temp, r); } static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) { mpf_div(f, g, h); } static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) { mpf_div_ui(f, g, l); } static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) { mpf_ui_div(f, l, g); } static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) { if (l >= 0) mpf_div_ui(f, g, l); else { mpf_div_ui(f, g, -static_cast(l)); mpf_neg(f, f); } } static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) { if (l >= 0) mpf_ui_div(f, l, g); else { mpf_ui_div(f, -static_cast(l), g); mpf_neg(f, f); } } static void eval(mpf_ptr f, mpf_srcptr g, double d) { mpf_t temp; mpf_init2(temp, 8*sizeof(double)); mpf_set_d(temp, d); mpf_div(f, g, temp); mpf_clear(temp); } static void eval(mpf_ptr f, double d, mpf_srcptr g) { mpf_t temp; mpf_init2(temp, 8*sizeof(double)); mpf_set_d(temp, d); mpf_div(f, temp, g); mpf_clear(temp); } }; struct __gmp_binary_modulus { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_tdiv_r(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { mpz_tdiv_r_ui(z, w, l); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { if (mpz_sgn(w) >= 0) { if (mpz_fits_ulong_p(w)) mpz_set_ui(z, l % mpz_get_ui(w)); else mpz_set_ui(z, l); } else { mpz_neg(z, w); if (mpz_fits_ulong_p(z)) mpz_set_ui(z, l % mpz_get_ui(z)); else mpz_set_ui(z, l); } } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { mpz_tdiv_r_ui (z, w, __gmpxx_abs_ui(l)); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { if (mpz_fits_slong_p(w)) mpz_set_si(z, l % mpz_get_si(w)); else { /* if w is bigger than a long then the remainder is l unchanged, unless l==LONG_MIN and w==-LONG_MIN in which case it's 0 */ mpz_set_si (z, mpz_cmpabs_ui (w, __gmpxx_abs_ui(l)) == 0 ? 0 : l); } } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_tdiv_r (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { __GMPXX_TMPZ_D; mpz_tdiv_r (z, temp, w); } }; struct __gmp_binary_and { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_and(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { __GMPXX_TMPZ_UI; mpz_and (z, w, temp); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { __GMPXX_TMPZ_SI; mpz_and (z, w, temp); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_and (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { eval(z, w, d); } }; struct __gmp_binary_ior { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_ior(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { __GMPXX_TMPZ_UI; mpz_ior (z, w, temp); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { __GMPXX_TMPZ_SI; mpz_ior (z, w, temp); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_ior (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { eval(z, w, d); } }; struct __gmp_binary_xor { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_xor(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { __GMPXX_TMPZ_UI; mpz_xor (z, w, temp); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { __GMPXX_TMPZ_SI; mpz_xor (z, w, temp); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_xor (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { eval(z, w, d); } }; struct __gmp_cmp_function { static int eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w); } static int eval(mpz_srcptr z, unsigned long int l) { return mpz_cmp_ui(z, l); } static int eval(unsigned long int l, mpz_srcptr z) { return -mpz_cmp_ui(z, l); } static int eval(mpz_srcptr z, signed long int l) { return mpz_cmp_si(z, l); } static int eval(signed long int l, mpz_srcptr z) { return -mpz_cmp_si(z, l); } static int eval(mpz_srcptr z, double d) { return mpz_cmp_d(z, d); } static int eval(double d, mpz_srcptr z) { return -mpz_cmp_d(z, d); } static int eval(mpq_srcptr q, mpq_srcptr r) { return mpq_cmp(q, r); } static int eval(mpq_srcptr q, unsigned long int l) { return mpq_cmp_ui(q, l, 1); } static int eval(unsigned long int l, mpq_srcptr q) { return -mpq_cmp_ui(q, l, 1); } static int eval(mpq_srcptr q, signed long int l) { return mpq_cmp_si(q, l, 1); } static int eval(signed long int l, mpq_srcptr q) { return -mpq_cmp_si(q, l, 1); } static int eval(mpq_srcptr q, double d) { __GMPXX_TMPQ_D; return mpq_cmp (q, temp); } static int eval(double d, mpq_srcptr q) { __GMPXX_TMPQ_D; return mpq_cmp (temp, q); } static int eval(mpq_srcptr q, mpz_srcptr z) { return mpq_cmp_z(q, z); } static int eval(mpz_srcptr z, mpq_srcptr q) { return -mpq_cmp_z(q, z); } static int eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g); } static int eval(mpf_srcptr f, unsigned long int l) { return mpf_cmp_ui(f, l); } static int eval(unsigned long int l, mpf_srcptr f) { return -mpf_cmp_ui(f, l); } static int eval(mpf_srcptr f, signed long int l) { return mpf_cmp_si(f, l); } static int eval(signed long int l, mpf_srcptr f) { return -mpf_cmp_si(f, l); } static int eval(mpf_srcptr f, double d) { return mpf_cmp_d(f, d); } static int eval(double d, mpf_srcptr f) { return -mpf_cmp_d(f, d); } static int eval(mpf_srcptr f, mpz_srcptr z) { return mpf_cmp_z(f, z); } static int eval(mpz_srcptr z, mpf_srcptr f) { return -mpf_cmp_z(f, z); } static int eval(mpf_srcptr f, mpq_srcptr q) { mpf_t qf; mpf_init(qf); /* Should we use the precision of f? */ mpf_set_q(qf, q); int ret = eval(f, qf); mpf_clear(qf); return ret; } static int eval(mpq_srcptr q, mpf_srcptr f) { return -eval(f, q); } }; struct __gmp_binary_equal { static bool eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w) == 0; } static bool eval(mpz_srcptr z, unsigned long int l) { return mpz_cmp_ui(z, l) == 0; } static bool eval(unsigned long int l, mpz_srcptr z) { return eval(z, l); } static bool eval(mpz_srcptr z, signed long int l) { return mpz_cmp_si(z, l) == 0; } static bool eval(signed long int l, mpz_srcptr z) { return eval(z, l); } static bool eval(mpz_srcptr z, double d) { return mpz_cmp_d(z, d) == 0; } static bool eval(double d, mpz_srcptr z) { return eval(z, d); } static bool eval(mpq_srcptr q, mpq_srcptr r) { return mpq_equal(q, r) != 0; } static bool eval(mpq_srcptr q, unsigned long int l) { return mpq_cmp_ui(q, l, 1) == 0; } static bool eval(unsigned long int l, mpq_srcptr q) { return eval(q, l); } static bool eval(mpq_srcptr q, signed long int l) { return mpq_cmp_si(q, l, 1) == 0; } static bool eval(signed long int l, mpq_srcptr q) { return eval(q, l); } static bool eval(mpq_srcptr q, double d) { __GMPXX_TMPQ_D; return mpq_equal (q, temp) != 0; } static bool eval(double d, mpq_srcptr q) { return eval(q, d); } static bool eval(mpq_srcptr q, mpz_srcptr z) { return mpq_cmp_z(q, z) == 0; } static bool eval(mpz_srcptr z, mpq_srcptr q) { return eval(q, z); } static bool eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g) == 0; } static bool eval(mpf_srcptr f, unsigned long int l) { return mpf_cmp_ui(f, l) == 0; } static bool eval(unsigned long int l, mpf_srcptr f) { return eval(f, l); } static bool eval(mpf_srcptr f, signed long int l) { return mpf_cmp_si(f, l) == 0; } static bool eval(signed long int l, mpf_srcptr f) { return eval(f, l); } static bool eval(mpf_srcptr f, double d) { return mpf_cmp_d(f, d) == 0; } static bool eval(double d, mpf_srcptr f) { return eval(f, d); } static bool eval(mpf_srcptr f, mpz_srcptr z) { return mpf_cmp_z(f, z) == 0; } static bool eval(mpz_srcptr z, mpf_srcptr f) { return eval(f, z); } static bool eval(mpf_srcptr f, mpq_srcptr q) { return __gmp_cmp_function::eval(f, q) == 0; } static bool eval(mpq_srcptr q, mpf_srcptr f) { return eval(f, q); } }; struct __gmp_binary_less { static bool eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w) < 0; } static bool eval(mpz_srcptr z, unsigned long int l) { return mpz_cmp_ui(z, l) < 0; } static bool eval(unsigned long int l, mpz_srcptr z) { return mpz_cmp_ui(z, l) > 0; } static bool eval(mpz_srcptr z, signed long int l) { return mpz_cmp_si(z, l) < 0; } static bool eval(signed long int l, mpz_srcptr z) { return mpz_cmp_si(z, l) > 0; } static bool eval(mpz_srcptr z, double d) { return mpz_cmp_d(z, d) < 0; } static bool eval(double d, mpz_srcptr z) { return mpz_cmp_d(z, d) > 0; } static bool eval(mpq_srcptr q, mpq_srcptr r) { return mpq_cmp(q, r) < 0; } static bool eval(mpq_srcptr q, unsigned long int l) { return mpq_cmp_ui(q, l, 1) < 0; } static bool eval(unsigned long int l, mpq_srcptr q) { return mpq_cmp_ui(q, l, 1) > 0; } static bool eval(mpq_srcptr q, signed long int l) { return mpq_cmp_si(q, l, 1) < 0; } static bool eval(signed long int l, mpq_srcptr q) { return mpq_cmp_si(q, l, 1) > 0; } static bool eval(mpq_srcptr q, double d) { __GMPXX_TMPQ_D; return mpq_cmp (q, temp) < 0; } static bool eval(double d, mpq_srcptr q) { __GMPXX_TMPQ_D; return mpq_cmp (temp, q) < 0; } static bool eval(mpq_srcptr q, mpz_srcptr z) { return mpq_cmp_z(q, z) < 0; } static bool eval(mpz_srcptr z, mpq_srcptr q) { return mpq_cmp_z(q, z) > 0; } static bool eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g) < 0; } static bool eval(mpf_srcptr f, unsigned long int l) { return mpf_cmp_ui(f, l) < 0; } static bool eval(unsigned long int l, mpf_srcptr f) { return mpf_cmp_ui(f, l) > 0; } static bool eval(mpf_srcptr f, signed long int l) { return mpf_cmp_si(f, l) < 0; } static bool eval(signed long int l, mpf_srcptr f) { return mpf_cmp_si(f, l) > 0; } static bool eval(mpf_srcptr f, double d) { return mpf_cmp_d(f, d) < 0; } static bool eval(double d, mpf_srcptr f) { return mpf_cmp_d(f, d) > 0; } static bool eval(mpf_srcptr f, mpz_srcptr z) { return mpf_cmp_z(f, z) < 0; } static bool eval(mpz_srcptr z, mpf_srcptr f) { return mpf_cmp_z(f, z) > 0; } static bool eval(mpf_srcptr f, mpq_srcptr q) { return __gmp_cmp_function::eval(f, q) < 0; } static bool eval(mpq_srcptr q, mpf_srcptr f) { return __gmp_cmp_function::eval(q, f) < 0; } }; struct __gmp_binary_greater { template static inline bool eval(T t, U u) { return __gmp_binary_less::eval(u, t); } }; struct __gmp_unary_increment { static void eval(mpz_ptr z) { mpz_add_ui(z, z, 1); } static void eval(mpq_ptr q) { mpz_add(mpq_numref(q), mpq_numref(q), mpq_denref(q)); } static void eval(mpf_ptr f) { mpf_add_ui(f, f, 1); } }; struct __gmp_unary_decrement { static void eval(mpz_ptr z) { mpz_sub_ui(z, z, 1); } static void eval(mpq_ptr q) { mpz_sub(mpq_numref(q), mpq_numref(q), mpq_denref(q)); } static void eval(mpf_ptr f) { mpf_sub_ui(f, f, 1); } }; struct __gmp_abs_function { static void eval(mpz_ptr z, mpz_srcptr w) { mpz_abs(z, w); } static void eval(mpq_ptr q, mpq_srcptr r) { mpq_abs(q, r); } static void eval(mpf_ptr f, mpf_srcptr g) { mpf_abs(f, g); } }; struct __gmp_trunc_function { static void eval(mpf_ptr f, mpf_srcptr g) { mpf_trunc(f, g); } }; struct __gmp_floor_function { static void eval(mpf_ptr f, mpf_srcptr g) { mpf_floor(f, g); } }; struct __gmp_ceil_function { static void eval(mpf_ptr f, mpf_srcptr g) { mpf_ceil(f, g); } }; struct __gmp_sqrt_function { static void eval(mpz_ptr z, mpz_srcptr w) { mpz_sqrt(z, w); } static void eval(mpf_ptr f, mpf_srcptr g) { mpf_sqrt(f, g); } }; struct __gmp_hypot_function { static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h) { mpf_t temp; mpf_init2(temp, mpf_get_prec(f)); mpf_mul(temp, g, g); mpf_mul(f, h, h); mpf_add(f, f, temp); mpf_sqrt(f, f); mpf_clear(temp); } static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l) { mpf_t temp; mpf_init2(temp, mpf_get_prec(f)); mpf_mul(temp, g, g); mpf_set_ui(f, l); mpf_mul_ui(f, f, l); mpf_add(f, f, temp); mpf_clear(temp); mpf_sqrt(f, f); } static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g) { eval(f, g, l); } static void eval(mpf_ptr f, mpf_srcptr g, signed long int l) { eval(f, g, __gmpxx_abs_ui(l)); } static void eval(mpf_ptr f, signed long int l, mpf_srcptr g) { eval(f, g, l); } static void eval(mpf_ptr f, mpf_srcptr g, double d) { mpf_t temp; mpf_init2(temp, mpf_get_prec(f)); mpf_mul(temp, g, g); mpf_set_d(f, d); mpf_mul(f, f, f); mpf_add(f, f, temp); mpf_sqrt(f, f); mpf_clear(temp); } static void eval(mpf_ptr f, double d, mpf_srcptr g) { eval(f, g, d); } }; struct __gmp_sgn_function { static int eval(mpz_srcptr z) { return mpz_sgn(z); } static int eval(mpq_srcptr q) { return mpq_sgn(q); } static int eval(mpf_srcptr f) { return mpf_sgn(f); } }; struct __gmp_gcd_function { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_gcd(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { mpz_gcd_ui(z, w, l); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { eval(z, w, __gmpxx_abs_ui(l)); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_gcd (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { eval(z, w, d); } }; struct __gmp_lcm_function { static void eval(mpz_ptr z, mpz_srcptr w, mpz_srcptr v) { mpz_lcm(z, w, v); } static void eval(mpz_ptr z, mpz_srcptr w, unsigned long int l) { mpz_lcm_ui(z, w, l); } static void eval(mpz_ptr z, unsigned long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { eval(z, w, __gmpxx_abs_ui(l)); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { eval(z, w, l); } static void eval(mpz_ptr z, mpz_srcptr w, double d) { __GMPXX_TMPZ_D; mpz_lcm (z, w, temp); } static void eval(mpz_ptr z, double d, mpz_srcptr w) { eval(z, w, d); } }; struct __gmp_rand_function { static void eval(mpz_ptr z, gmp_randstate_t s, mp_bitcnt_t l) { mpz_urandomb(z, s, l); } static void eval(mpz_ptr z, gmp_randstate_t s, mpz_srcptr w) { mpz_urandomm(z, s, w); } static void eval(mpf_ptr f, gmp_randstate_t s, mp_bitcnt_t prec) { mpf_urandomb(f, s, prec); } }; /**************** Auxiliary classes ****************/ /* this is much the same as gmp_allocated_string in gmp-impl.h since gmp-impl.h is not publicly available, I redefine it here I use a different name to avoid possible clashes */ extern "C" { typedef void (*__gmp_freefunc_t) (void *, size_t); } struct __gmp_alloc_cstring { char *str; __gmp_alloc_cstring(char *s) { str = s; } ~__gmp_alloc_cstring() { __gmp_freefunc_t freefunc; mp_get_memory_functions (NULL, NULL, &freefunc); (*freefunc) (str, std::strlen(str)+1); } }; // general expression template class template class __gmp_expr; // templates for resolving expression types template struct __gmp_resolve_ref { typedef T ref_type; }; template struct __gmp_resolve_ref<__gmp_expr > { typedef const __gmp_expr & ref_type; }; template struct __gmp_resolve_expr; template <> struct __gmp_resolve_expr { typedef mpz_t value_type; typedef mpz_ptr ptr_type; typedef mpz_srcptr srcptr_type; }; template <> struct __gmp_resolve_expr { typedef mpq_t value_type; typedef mpq_ptr ptr_type; typedef mpq_srcptr srcptr_type; }; template <> struct __gmp_resolve_expr { typedef mpf_t value_type; typedef mpf_ptr ptr_type; typedef mpf_srcptr srcptr_type; }; template <> struct __gmp_resolve_expr { typedef mpq_t value_type; }; template <> struct __gmp_resolve_expr { typedef mpq_t value_type; }; template <> struct __gmp_resolve_expr { typedef mpf_t value_type; }; template <> struct __gmp_resolve_expr { typedef mpf_t value_type; }; template <> struct __gmp_resolve_expr { typedef mpf_t value_type; }; template <> struct __gmp_resolve_expr { typedef mpf_t value_type; }; #if __GMPXX_USE_CXX11 namespace std { template struct common_type <__gmp_expr, __gmp_expr > { private: typedef typename __gmp_resolve_expr::value_type X; public: typedef __gmp_expr type; }; template struct common_type <__gmp_expr > { typedef __gmp_expr type; }; #define __GMPXX_DECLARE_COMMON_TYPE(typ) \ template \ struct common_type <__gmp_expr, typ > \ { \ typedef __gmp_expr type; \ }; \ \ template \ struct common_type > \ { \ typedef __gmp_expr type; \ } __GMPXX_DECLARE_COMMON_TYPE(signed char); __GMPXX_DECLARE_COMMON_TYPE(unsigned char); __GMPXX_DECLARE_COMMON_TYPE(signed int); __GMPXX_DECLARE_COMMON_TYPE(unsigned int); __GMPXX_DECLARE_COMMON_TYPE(signed short int); __GMPXX_DECLARE_COMMON_TYPE(unsigned short int); __GMPXX_DECLARE_COMMON_TYPE(signed long int); __GMPXX_DECLARE_COMMON_TYPE(unsigned long int); __GMPXX_DECLARE_COMMON_TYPE(float); __GMPXX_DECLARE_COMMON_TYPE(double); #undef __GMPXX_DECLARE_COMMON_TYPE } #endif // classes for evaluating unary and binary expressions template struct __gmp_unary_expr { typename __gmp_resolve_ref::ref_type val; __gmp_unary_expr(const T &v) : val(v) { } private: __gmp_unary_expr(); }; template struct __gmp_binary_expr { typename __gmp_resolve_ref::ref_type val1; typename __gmp_resolve_ref::ref_type val2; __gmp_binary_expr(const T &v1, const U &v2) : val1(v1), val2(v2) { } private: __gmp_binary_expr(); }; /**************** Macros for in-class declarations ****************/ /* This is just repetitive code that is easier to maintain if it's written only once */ #define __GMPP_DECLARE_COMPOUND_OPERATOR(fun) \ template \ __gmp_expr & fun(const __gmp_expr &); #define __GMPN_DECLARE_COMPOUND_OPERATOR(fun) \ __gmp_expr & fun(signed char); \ __gmp_expr & fun(unsigned char); \ __gmp_expr & fun(signed int); \ __gmp_expr & fun(unsigned int); \ __gmp_expr & fun(signed short int); \ __gmp_expr & fun(unsigned short int); \ __gmp_expr & fun(signed long int); \ __gmp_expr & fun(unsigned long int); \ __gmp_expr & fun(float); \ __gmp_expr & fun(double); \ /* __gmp_expr & fun(long double); */ #define __GMP_DECLARE_COMPOUND_OPERATOR(fun) \ __GMPP_DECLARE_COMPOUND_OPERATOR(fun) \ __GMPN_DECLARE_COMPOUND_OPERATOR(fun) #define __GMP_DECLARE_COMPOUND_OPERATOR_UI(fun) \ __gmp_expr & fun(mp_bitcnt_t); #define __GMP_DECLARE_INCREMENT_OPERATOR(fun) \ inline __gmp_expr & fun(); \ inline __gmp_expr fun(int); #define __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS \ __gmp_expr(signed char c) { init_si(c); } \ __gmp_expr(unsigned char c) { init_ui(c); } \ __gmp_expr(signed int i) { init_si(i); } \ __gmp_expr(unsigned int i) { init_ui(i); } \ __gmp_expr(signed short int s) { init_si(s); } \ __gmp_expr(unsigned short int s) { init_ui(s); } \ __gmp_expr(signed long int l) { init_si(l); } \ __gmp_expr(unsigned long int l) { init_ui(l); } \ __gmp_expr(float f) { init_d(f); } \ __gmp_expr(double d) { init_d(d); } #define __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS \ __gmp_expr & operator=(signed char c) { assign_si(c); return *this; } \ __gmp_expr & operator=(unsigned char c) { assign_ui(c); return *this; } \ __gmp_expr & operator=(signed int i) { assign_si(i); return *this; } \ __gmp_expr & operator=(unsigned int i) { assign_ui(i); return *this; } \ __gmp_expr & operator=(signed short int s) { assign_si(s); return *this; } \ __gmp_expr & operator=(unsigned short int s) { assign_ui(s); return *this; } \ __gmp_expr & operator=(signed long int l) { assign_si(l); return *this; } \ __gmp_expr & operator=(unsigned long int l) { assign_ui(l); return *this; } \ __gmp_expr & operator=(float f) { assign_d(f); return *this; } \ __gmp_expr & operator=(double d) { assign_d(d); return *this; } /**************** mpz_class -- wrapper for mpz_t ****************/ template <> class __gmp_expr { private: typedef mpz_t value_type; value_type mp; // Helper functions used for all arithmetic types void assign_ui(unsigned long l) { if (__GMPXX_CONSTANT_TRUE(l == 0)) mp->_mp_size = 0; else mpz_set_ui(mp, l); } void assign_si(signed long l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) assign_ui(l); else if (__GMPXX_CONSTANT_TRUE(l <= 0)) { assign_ui(-static_cast(l)); mpz_neg(mp, mp); } else mpz_set_si(mp, l); } void assign_d (double d) { mpz_set_d (mp, d); } void init_ui(unsigned long l) { if (__GMPXX_CONSTANT_TRUE(l == 0)) mpz_init(mp); else mpz_init_set_ui(mp, l); } void init_si(signed long l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) init_ui(l); else if (__GMPXX_CONSTANT_TRUE(l <= 0)) { init_ui(-static_cast(l)); mpz_neg(mp, mp); } else mpz_init_set_si(mp, l); } void init_d (double d) { mpz_init_set_d (mp, d); } public: mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } // constructors and destructor __gmp_expr() { mpz_init(mp); } __gmp_expr(const __gmp_expr &z) { mpz_init_set(mp, z.mp); } #if __GMPXX_USE_CXX11 __gmp_expr(__gmp_expr &&z) { *mp = *z.mp; mpz_init(z.mp); } #endif template __gmp_expr(const __gmp_expr &expr) { mpz_init(mp); __gmp_set_expr(mp, expr); } template explicit __gmp_expr(const __gmp_expr &expr) { mpz_init(mp); __gmp_set_expr(mp, expr); } __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS explicit __gmp_expr(const char *s, int base = 0) { if (mpz_init_set_str (mp, s, base) != 0) { mpz_clear (mp); throw std::invalid_argument ("mpz_set_str"); } } explicit __gmp_expr(const std::string &s, int base = 0) { if (mpz_init_set_str(mp, s.c_str(), base) != 0) { mpz_clear (mp); throw std::invalid_argument ("mpz_set_str"); } } explicit __gmp_expr(mpz_srcptr z) { mpz_init_set(mp, z); } ~__gmp_expr() { mpz_clear(mp); } void swap(__gmp_expr& z) __GMPXX_NOEXCEPT { std::swap(*mp, *z.mp); } // assignment operators __gmp_expr & operator=(const __gmp_expr &z) { mpz_set(mp, z.mp); return *this; } #if __GMPXX_USE_CXX11 __gmp_expr & operator=(__gmp_expr &&z) noexcept { swap(z); return *this; } #endif template __gmp_expr & operator=(const __gmp_expr &expr) { __gmp_set_expr(mp, expr); return *this; } __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS __gmp_expr & operator=(const char *s) { if (mpz_set_str (mp, s, 0) != 0) throw std::invalid_argument ("mpz_set_str"); return *this; } __gmp_expr & operator=(const std::string &s) { if (mpz_set_str(mp, s.c_str(), 0) != 0) throw std::invalid_argument ("mpz_set_str"); return *this; } // string input/output functions int set_str(const char *s, int base) { return mpz_set_str(mp, s, base); } int set_str(const std::string &s, int base) { return mpz_set_str(mp, s.c_str(), base); } std::string get_str(int base = 10) const { __gmp_alloc_cstring temp(mpz_get_str(0, base, mp)); return std::string(temp.str); } // conversion functions mpz_srcptr __get_mp() const { return mp; } mpz_ptr __get_mp() { return mp; } mpz_srcptr get_mpz_t() const { return mp; } mpz_ptr get_mpz_t() { return mp; } signed long int get_si() const { return mpz_get_si(mp); } unsigned long int get_ui() const { return mpz_get_ui(mp); } double get_d() const { return mpz_get_d(mp); } // bool fits_schar_p() const { return mpz_fits_schar_p(mp); } // bool fits_uchar_p() const { return mpz_fits_uchar_p(mp); } bool fits_sint_p() const { return mpz_fits_sint_p(mp); } bool fits_uint_p() const { return mpz_fits_uint_p(mp); } bool fits_sshort_p() const { return mpz_fits_sshort_p(mp); } bool fits_ushort_p() const { return mpz_fits_ushort_p(mp); } bool fits_slong_p() const { return mpz_fits_slong_p(mp); } bool fits_ulong_p() const { return mpz_fits_ulong_p(mp); } // bool fits_float_p() const { return mpz_fits_float_p(mp); } // bool fits_double_p() const { return mpz_fits_double_p(mp); } // bool fits_ldouble_p() const { return mpz_fits_ldouble_p(mp); } #if __GMPXX_USE_CXX11 explicit operator bool() const { return mp->_mp_size != 0; } #endif // member operators __GMP_DECLARE_COMPOUND_OPERATOR(operator+=) __GMP_DECLARE_COMPOUND_OPERATOR(operator-=) __GMP_DECLARE_COMPOUND_OPERATOR(operator*=) __GMP_DECLARE_COMPOUND_OPERATOR(operator/=) __GMP_DECLARE_COMPOUND_OPERATOR(operator%=) __GMP_DECLARE_COMPOUND_OPERATOR(operator&=) __GMP_DECLARE_COMPOUND_OPERATOR(operator|=) __GMP_DECLARE_COMPOUND_OPERATOR(operator^=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator<<=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator>>=) __GMP_DECLARE_INCREMENT_OPERATOR(operator++) __GMP_DECLARE_INCREMENT_OPERATOR(operator--) }; typedef __gmp_expr mpz_class; /**************** mpq_class -- wrapper for mpq_t ****************/ template <> class __gmp_expr { private: typedef mpq_t value_type; value_type mp; // Helper functions used for all arithmetic types void assign_ui(unsigned long l) { mpq_set_ui(mp, l, 1); } void assign_si(signed long l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) assign_ui(l); else mpq_set_si(mp, l, 1); } void assign_d (double d) { mpq_set_d (mp, d); } void init_ui(unsigned long l) { mpq_init(mp); get_num() = l; } void init_si(signed long l) { mpq_init(mp); get_num() = l; } void init_d (double d) { mpq_init(mp); assign_d (d); } public: mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } void canonicalize() { mpq_canonicalize(mp); } // constructors and destructor __gmp_expr() { mpq_init(mp); } __gmp_expr(const __gmp_expr &q) { mpz_init_set(mpq_numref(mp), mpq_numref(q.mp)); mpz_init_set(mpq_denref(mp), mpq_denref(q.mp)); } #if __GMPXX_USE_CXX11 __gmp_expr(__gmp_expr &&q) { *mp = *q.mp; mpq_init(q.mp); } #endif template __gmp_expr(const __gmp_expr &expr) { mpq_init(mp); __gmp_set_expr(mp, expr); } template __gmp_expr(const __gmp_expr &expr) { mpq_init(mp); __gmp_set_expr(mp, expr); } template explicit __gmp_expr(const __gmp_expr &expr) { mpq_init(mp); __gmp_set_expr(mp, expr); } __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS explicit __gmp_expr(const char *s, int base = 0) { mpq_init (mp); // If s is the literal 0, we meant to call another constructor. // If s just happens to evaluate to 0, we would crash, so whatever. if (s == 0) { // Don't turn mpq_class(0,0) into 0 mpz_set_si(mpq_denref(mp), base); } else if (mpq_set_str(mp, s, base) != 0) { mpq_clear (mp); throw std::invalid_argument ("mpq_set_str"); } } explicit __gmp_expr(const std::string &s, int base = 0) { mpq_init(mp); if (mpq_set_str (mp, s.c_str(), base) != 0) { mpq_clear (mp); throw std::invalid_argument ("mpq_set_str"); } } explicit __gmp_expr(mpq_srcptr q) { mpz_init_set(mpq_numref(mp), mpq_numref(q)); mpz_init_set(mpq_denref(mp), mpq_denref(q)); } __gmp_expr(const mpz_class &num, const mpz_class &den) { mpz_init_set(mpq_numref(mp), num.get_mpz_t()); mpz_init_set(mpq_denref(mp), den.get_mpz_t()); } ~__gmp_expr() { mpq_clear(mp); } void swap(__gmp_expr& q) __GMPXX_NOEXCEPT { std::swap(*mp, *q.mp); } // assignment operators __gmp_expr & operator=(const __gmp_expr &q) { mpq_set(mp, q.mp); return *this; } #if __GMPXX_USE_CXX11 __gmp_expr & operator=(__gmp_expr &&q) noexcept { swap(q); return *this; } __gmp_expr & operator=(mpz_class &&z) noexcept { get_num() = std::move(z); get_den() = 1u; return *this; } #endif template __gmp_expr & operator=(const __gmp_expr &expr) { __gmp_set_expr(mp, expr); return *this; } __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS __gmp_expr & operator=(const char *s) { if (mpq_set_str (mp, s, 0) != 0) throw std::invalid_argument ("mpq_set_str"); return *this; } __gmp_expr & operator=(const std::string &s) { if (mpq_set_str(mp, s.c_str(), 0) != 0) throw std::invalid_argument ("mpq_set_str"); return *this; } // string input/output functions int set_str(const char *s, int base) { return mpq_set_str(mp, s, base); } int set_str(const std::string &s, int base) { return mpq_set_str(mp, s.c_str(), base); } std::string get_str(int base = 10) const { __gmp_alloc_cstring temp(mpq_get_str(0, base, mp)); return std::string(temp.str); } // conversion functions // casting a reference to an mpz_t to mpz_class & is a dirty hack, // but works because the internal representation of mpz_class is // exactly an mpz_t const mpz_class & get_num() const { return reinterpret_cast(*mpq_numref(mp)); } mpz_class & get_num() { return reinterpret_cast(*mpq_numref(mp)); } const mpz_class & get_den() const { return reinterpret_cast(*mpq_denref(mp)); } mpz_class & get_den() { return reinterpret_cast(*mpq_denref(mp)); } mpq_srcptr __get_mp() const { return mp; } mpq_ptr __get_mp() { return mp; } mpq_srcptr get_mpq_t() const { return mp; } mpq_ptr get_mpq_t() { return mp; } mpz_srcptr get_num_mpz_t() const { return mpq_numref(mp); } mpz_ptr get_num_mpz_t() { return mpq_numref(mp); } mpz_srcptr get_den_mpz_t() const { return mpq_denref(mp); } mpz_ptr get_den_mpz_t() { return mpq_denref(mp); } double get_d() const { return mpq_get_d(mp); } #if __GMPXX_USE_CXX11 explicit operator bool() const { return mpq_numref(mp)->_mp_size != 0; } #endif // compound assignments __GMP_DECLARE_COMPOUND_OPERATOR(operator+=) __GMP_DECLARE_COMPOUND_OPERATOR(operator-=) __GMP_DECLARE_COMPOUND_OPERATOR(operator*=) __GMP_DECLARE_COMPOUND_OPERATOR(operator/=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator<<=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator>>=) __GMP_DECLARE_INCREMENT_OPERATOR(operator++) __GMP_DECLARE_INCREMENT_OPERATOR(operator--) }; typedef __gmp_expr mpq_class; /**************** mpf_class -- wrapper for mpf_t ****************/ template <> class __gmp_expr { private: typedef mpf_t value_type; value_type mp; // Helper functions used for all arithmetic types void assign_ui(unsigned long l) { mpf_set_ui(mp, l); } void assign_si(signed long l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) assign_ui(l); else mpf_set_si(mp, l); } void assign_d (double d) { mpf_set_d (mp, d); } void init_ui(unsigned long l) { if (__GMPXX_CONSTANT_TRUE(l == 0)) mpf_init(mp); else mpf_init_set_ui(mp, l); } void init_si(signed long l) { if (__GMPXX_CONSTANT_TRUE(l >= 0)) init_ui(l); else mpf_init_set_si(mp, l); } void init_d (double d) { mpf_init_set_d (mp, d); } public: mp_bitcnt_t get_prec() const { return mpf_get_prec(mp); } void set_prec(mp_bitcnt_t prec) { mpf_set_prec(mp, prec); } void set_prec_raw(mp_bitcnt_t prec) { mpf_set_prec_raw(mp, prec); } // constructors and destructor __gmp_expr() { mpf_init(mp); } __gmp_expr(const __gmp_expr &f) { mpf_init2(mp, f.get_prec()); mpf_set(mp, f.mp); } #if __GMPXX_USE_CXX11 __gmp_expr(__gmp_expr &&f) { *mp = *f.mp; mpf_init2(f.mp, get_prec()); } #endif __gmp_expr(const __gmp_expr &f, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set(mp, f.mp); } template __gmp_expr(const __gmp_expr &expr) { mpf_init2(mp, expr.get_prec()); __gmp_set_expr(mp, expr); } template __gmp_expr(const __gmp_expr &expr, mp_bitcnt_t prec) { mpf_init2(mp, prec); __gmp_set_expr(mp, expr); } __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS __gmp_expr(signed char c, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_si(mp, c); } __gmp_expr(unsigned char c, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_ui(mp, c); } __gmp_expr(signed int i, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_si(mp, i); } __gmp_expr(unsigned int i, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_ui(mp, i); } __gmp_expr(signed short int s, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_si(mp, s); } __gmp_expr(unsigned short int s, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_ui(mp, s); } __gmp_expr(signed long int l, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_si(mp, l); } __gmp_expr(unsigned long int l, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_ui(mp, l); } __gmp_expr(float f, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_d(mp, f); } __gmp_expr(double d, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set_d(mp, d); } // __gmp_expr(long double ld) { mpf_init_set_d(mp, ld); } // __gmp_expr(long double ld, mp_bitcnt_t prec) // { mpf_init2(mp, prec); mpf_set_d(mp, ld); } explicit __gmp_expr(const char *s) { if (mpf_init_set_str (mp, s, 0) != 0) { mpf_clear (mp); throw std::invalid_argument ("mpf_set_str"); } } __gmp_expr(const char *s, mp_bitcnt_t prec, int base = 0) { mpf_init2(mp, prec); if (mpf_set_str(mp, s, base) != 0) { mpf_clear (mp); throw std::invalid_argument ("mpf_set_str"); } } explicit __gmp_expr(const std::string &s) { if (mpf_init_set_str(mp, s.c_str(), 0) != 0) { mpf_clear (mp); throw std::invalid_argument ("mpf_set_str"); } } __gmp_expr(const std::string &s, mp_bitcnt_t prec, int base = 0) { mpf_init2(mp, prec); if (mpf_set_str(mp, s.c_str(), base) != 0) { mpf_clear (mp); throw std::invalid_argument ("mpf_set_str"); } } explicit __gmp_expr(mpf_srcptr f) { mpf_init2(mp, mpf_get_prec(f)); mpf_set(mp, f); } __gmp_expr(mpf_srcptr f, mp_bitcnt_t prec) { mpf_init2(mp, prec); mpf_set(mp, f); } ~__gmp_expr() { mpf_clear(mp); } void swap(__gmp_expr& f) __GMPXX_NOEXCEPT { std::swap(*mp, *f.mp); } // assignment operators __gmp_expr & operator=(const __gmp_expr &f) { mpf_set(mp, f.mp); return *this; } #if __GMPXX_USE_CXX11 __gmp_expr & operator=(__gmp_expr &&f) noexcept { swap(f); return *this; } #endif template __gmp_expr & operator=(const __gmp_expr &expr) { __gmp_set_expr(mp, expr); return *this; } __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS __gmp_expr & operator=(const char *s) { if (mpf_set_str (mp, s, 0) != 0) throw std::invalid_argument ("mpf_set_str"); return *this; } __gmp_expr & operator=(const std::string &s) { if (mpf_set_str(mp, s.c_str(), 0) != 0) throw std::invalid_argument ("mpf_set_str"); return *this; } // string input/output functions int set_str(const char *s, int base) { return mpf_set_str(mp, s, base); } int set_str(const std::string &s, int base) { return mpf_set_str(mp, s.c_str(), base); } std::string get_str(mp_exp_t &expo, int base = 10, size_t size = 0) const { __gmp_alloc_cstring temp(mpf_get_str(0, &expo, base, size, mp)); return std::string(temp.str); } // conversion functions mpf_srcptr __get_mp() const { return mp; } mpf_ptr __get_mp() { return mp; } mpf_srcptr get_mpf_t() const { return mp; } mpf_ptr get_mpf_t() { return mp; } signed long int get_si() const { return mpf_get_si(mp); } unsigned long int get_ui() const { return mpf_get_ui(mp); } double get_d() const { return mpf_get_d(mp); } // bool fits_schar_p() const { return mpf_fits_schar_p(mp); } // bool fits_uchar_p() const { return mpf_fits_uchar_p(mp); } bool fits_sint_p() const { return mpf_fits_sint_p(mp); } bool fits_uint_p() const { return mpf_fits_uint_p(mp); } bool fits_sshort_p() const { return mpf_fits_sshort_p(mp); } bool fits_ushort_p() const { return mpf_fits_ushort_p(mp); } bool fits_slong_p() const { return mpf_fits_slong_p(mp); } bool fits_ulong_p() const { return mpf_fits_ulong_p(mp); } // bool fits_float_p() const { return mpf_fits_float_p(mp); } // bool fits_double_p() const { return mpf_fits_double_p(mp); } // bool fits_ldouble_p() const { return mpf_fits_ldouble_p(mp); } #if __GMPXX_USE_CXX11 explicit operator bool() const { return mp->_mp_size != 0; } #endif // compound assignments __GMP_DECLARE_COMPOUND_OPERATOR(operator+=) __GMP_DECLARE_COMPOUND_OPERATOR(operator-=) __GMP_DECLARE_COMPOUND_OPERATOR(operator*=) __GMP_DECLARE_COMPOUND_OPERATOR(operator/=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator<<=) __GMP_DECLARE_COMPOUND_OPERATOR_UI(operator>>=) __GMP_DECLARE_INCREMENT_OPERATOR(operator++) __GMP_DECLARE_INCREMENT_OPERATOR(operator--) }; typedef __gmp_expr mpf_class; /**************** User-defined literals ****************/ #if __GMPXX_USE_CXX11 inline mpz_class operator"" _mpz(const char* s) { return mpz_class(s); } inline mpq_class operator"" _mpq(const char* s) { mpq_class q; q.get_num() = s; return q; } inline mpf_class operator"" _mpf(const char* s) { return mpf_class(s); } #endif /**************** I/O operators ****************/ // these should (and will) be provided separately template inline std::ostream & operator<< (std::ostream &o, const __gmp_expr &expr) { __gmp_expr const& temp(expr); return o << temp.__get_mp(); } template inline std::istream & operator>>(std::istream &i, __gmp_expr &expr) { return i >> expr.__get_mp(); } /* // you might want to uncomment this inline std::istream & operator>>(std::istream &i, mpq_class &q) { i >> q.get_mpq_t(); q.canonicalize(); return i; } */ /**************** Functions for type conversion ****************/ inline void __gmp_set_expr(mpz_ptr z, const mpz_class &w) { mpz_set(z, w.get_mpz_t()); } template inline void __gmp_set_expr(mpz_ptr z, const __gmp_expr &expr) { expr.eval(z); } template inline void __gmp_set_expr(mpz_ptr z, const __gmp_expr &expr) { mpq_class const& temp(expr); mpz_set_q(z, temp.get_mpq_t()); } template inline void __gmp_set_expr(mpz_ptr z, const __gmp_expr &expr) { mpf_class const& temp(expr); mpz_set_f(z, temp.get_mpf_t()); } inline void __gmp_set_expr(mpq_ptr q, const mpz_class &z) { mpq_set_z(q, z.get_mpz_t()); } template inline void __gmp_set_expr(mpq_ptr q, const __gmp_expr &expr) { __gmp_set_expr(mpq_numref(q), expr); mpz_set_ui(mpq_denref(q), 1); } inline void __gmp_set_expr(mpq_ptr q, const mpq_class &r) { mpq_set(q, r.get_mpq_t()); } template inline void __gmp_set_expr(mpq_ptr q, const __gmp_expr &expr) { expr.eval(q); } template inline void __gmp_set_expr(mpq_ptr q, const __gmp_expr &expr) { mpf_class const& temp(expr); mpq_set_f(q, temp.get_mpf_t()); } template inline void __gmp_set_expr(mpf_ptr f, const __gmp_expr &expr) { mpz_class const& temp(expr); mpf_set_z(f, temp.get_mpz_t()); } template inline void __gmp_set_expr(mpf_ptr f, const __gmp_expr &expr) { mpq_class const& temp(expr); mpf_set_q(f, temp.get_mpq_t()); } inline void __gmp_set_expr(mpf_ptr f, const mpf_class &g) { mpf_set(f, g.get_mpf_t()); } template inline void __gmp_set_expr(mpf_ptr f, const __gmp_expr &expr) { expr.eval(f); } /* Temporary objects */ template class __gmp_temp { __gmp_expr val; public: template __gmp_temp(U const& u, V) : val (u) {} typename __gmp_resolve_expr::srcptr_type __get_mp() const { return val.__get_mp(); } }; template <> class __gmp_temp { mpf_class val; public: template __gmp_temp(U const& u, mpf_ptr res) : val (u, mpf_get_prec(res)) {} mpf_srcptr __get_mp() const { return val.__get_mp(); } }; /**************** Specializations of __gmp_expr ****************/ /* The eval() method of __gmp_expr evaluates the corresponding expression and assigns the result to its argument, which is either an mpz_t, mpq_t, or mpf_t as specified by the T argument. Compound expressions are evaluated recursively (temporaries are created to hold intermediate values), while for simple expressions the eval() method of the appropriate function object (available as the Op argument of either __gmp_unary_expr or __gmp_binary_expr) is called. */ /**************** Unary expressions ****************/ /* cases: - simple: argument is mp*_class, that is, __gmp_expr - compound: argument is __gmp_expr (with U not equal to T) */ // simple expressions template class __gmp_expr, Op> > { private: typedef __gmp_expr val_type; __gmp_unary_expr expr; public: explicit __gmp_expr(const val_type &val) : expr(val) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { Op::eval(p, expr.val.__get_mp()); } const val_type & get_val() const { return expr.val; } mp_bitcnt_t get_prec() const { return expr.val.get_prec(); } }; // simple expressions, U is a built-in numerical type template class __gmp_expr > { private: typedef U val_type; __gmp_unary_expr expr; public: explicit __gmp_expr(const val_type &val) : expr(val) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { Op::eval(p, expr.val); } const val_type & get_val() const { return expr.val; } mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } }; // compound expressions template class __gmp_expr, Op> > { private: typedef __gmp_expr val_type; __gmp_unary_expr expr; public: explicit __gmp_expr(const val_type &val) : expr(val) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { expr.val.eval(p); Op::eval(p, p); } const val_type & get_val() const { return expr.val; } mp_bitcnt_t get_prec() const { return expr.val.get_prec(); } }; /**************** Binary expressions ****************/ /* simple: - arguments are both mp*_class - one argument is mp*_class, one is a built-in type compound: - one is mp*_class, one is __gmp_expr - one is __gmp_expr, one is built-in - both arguments are __gmp_expr<...> */ // simple expressions template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { Op::eval(p, expr.val1.__get_mp(), expr.val2.__get_mp()); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; // simple expressions, U is a built-in numerical type template class __gmp_expr, U, Op> > { private: typedef __gmp_expr val1_type; typedef U val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { Op::eval(p, expr.val1.__get_mp(), expr.val2); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { return expr.val1.get_prec(); } }; template class __gmp_expr, Op> > { private: typedef U val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { Op::eval(p, expr.val1, expr.val2.__get_mp()); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { return expr.val2.get_prec(); } }; // compound expressions, one argument is a subexpression template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { if(p != expr.val1.__get_mp()) { __gmp_set_expr(p, expr.val2); Op::eval(p, expr.val1.__get_mp(), p); } else { __gmp_temp temp(expr.val2, p); Op::eval(p, expr.val1.__get_mp(), temp.__get_mp()); } } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { if(p != expr.val2.__get_mp()) { __gmp_set_expr(p, expr.val1); Op::eval(p, p, expr.val2.__get_mp()); } else { __gmp_temp temp(expr.val1, p); Op::eval(p, temp.__get_mp(), expr.val2.__get_mp()); } } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { if(p != expr.val1.__get_mp()) { __gmp_set_expr(p, expr.val2); Op::eval(p, expr.val1.__get_mp(), p); } else { __gmp_temp temp(expr.val2, p); Op::eval(p, expr.val1.__get_mp(), temp.__get_mp()); } } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { if(p != expr.val2.__get_mp()) { __gmp_set_expr(p, expr.val1); Op::eval(p, p, expr.val2.__get_mp()); } else { __gmp_temp temp(expr.val1, p); Op::eval(p, temp.__get_mp(), expr.val2.__get_mp()); } } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; // one argument is a subexpression, one is a built-in template class __gmp_expr, V, Op> > { private: typedef __gmp_expr val1_type; typedef V val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { expr.val1.eval(p); Op::eval(p, p, expr.val2); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { return expr.val1.get_prec(); } }; template class __gmp_expr, Op> > { private: typedef U val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { expr.val2.eval(p); Op::eval(p, expr.val1, p); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { return expr.val2.get_prec(); } }; // both arguments are subexpressions template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { __gmp_temp temp2(expr.val2, p); expr.val1.eval(p); Op::eval(p, p, temp2.__get_mp()); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { __gmp_temp temp1(expr.val1, p); expr.val2.eval(p); Op::eval(p, temp1.__get_mp(), p); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; template class __gmp_expr , __gmp_expr, Op> > { private: typedef __gmp_expr val1_type; typedef __gmp_expr val2_type; __gmp_binary_expr expr; public: __gmp_expr(const val1_type &val1, const val2_type &val2) : expr(val1, val2) { } void eval(typename __gmp_resolve_expr::ptr_type p) const { __gmp_temp temp2(expr.val2, p); expr.val1.eval(p); Op::eval(p, p, temp2.__get_mp()); } const val1_type & get_val1() const { return expr.val1; } const val2_type & get_val2() const { return expr.val2; } mp_bitcnt_t get_prec() const { mp_bitcnt_t prec1 = expr.val1.get_prec(), prec2 = expr.val2.get_prec(); return (prec1 > prec2) ? prec1 : prec2; } }; /**************** Special cases ****************/ /* Some operations (i.e., add and subtract) with mixed mpz/mpq arguments can be done directly without first converting the mpz to mpq. Appropriate specializations of __gmp_expr are required. */ #define __GMPZQ_DEFINE_EXPR(eval_fun) \ \ template <> \ class __gmp_expr > \ { \ private: \ typedef mpz_class val1_type; \ typedef mpq_class val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { eval_fun::eval(q, expr.val1.get_mpz_t(), expr.val2.get_mpq_t()); } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; \ \ template <> \ class __gmp_expr > \ { \ private: \ typedef mpq_class val1_type; \ typedef mpz_class val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { eval_fun::eval(q, expr.val1.get_mpq_t(), expr.val2.get_mpz_t()); } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; \ \ template \ class __gmp_expr \ , eval_fun> > \ { \ private: \ typedef mpz_class val1_type; \ typedef __gmp_expr val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { \ mpq_class temp(expr.val2); \ eval_fun::eval(q, expr.val1.get_mpz_t(), temp.get_mpq_t()); \ } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; \ \ template \ class __gmp_expr \ , eval_fun> > \ { \ private: \ typedef mpq_class val1_type; \ typedef __gmp_expr val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { \ mpz_class temp(expr.val2); \ eval_fun::eval(q, expr.val1.get_mpq_t(), temp.get_mpz_t()); \ } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; \ \ template \ class __gmp_expr \ , mpq_class, eval_fun> > \ { \ private: \ typedef __gmp_expr val1_type; \ typedef mpq_class val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { \ mpz_class temp(expr.val1); \ eval_fun::eval(q, temp.get_mpz_t(), expr.val2.get_mpq_t()); \ } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; \ \ template \ class __gmp_expr \ , mpz_class, eval_fun> > \ { \ private: \ typedef __gmp_expr val1_type; \ typedef mpz_class val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { \ mpq_class temp(expr.val1); \ eval_fun::eval(q, temp.get_mpq_t(), expr.val2.get_mpz_t()); \ } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; \ \ template \ class __gmp_expr, __gmp_expr, eval_fun> > \ { \ private: \ typedef __gmp_expr val1_type; \ typedef __gmp_expr val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { \ mpz_class temp1(expr.val1); \ expr.val2.eval(q); \ eval_fun::eval(q, temp1.get_mpz_t(), q); \ } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; \ \ template \ class __gmp_expr, __gmp_expr, eval_fun> > \ { \ private: \ typedef __gmp_expr val1_type; \ typedef __gmp_expr val2_type; \ \ __gmp_binary_expr expr; \ public: \ __gmp_expr(const val1_type &val1, const val2_type &val2) \ : expr(val1, val2) { } \ void eval(mpq_ptr q) const \ { \ mpz_class temp2(expr.val2); \ expr.val1.eval(q); \ eval_fun::eval(q, q, temp2.get_mpz_t()); \ } \ const val1_type & get_val1() const { return expr.val1; } \ const val2_type & get_val2() const { return expr.val2; } \ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } \ }; __GMPZQ_DEFINE_EXPR(__gmp_binary_plus) __GMPZQ_DEFINE_EXPR(__gmp_binary_minus) /**************** Macros for defining functions ****************/ /* Results of operators and functions are instances of __gmp_expr. T determines the numerical type of the expression: it can be either mpz_t, mpq_t, or mpf_t. When the arguments of a binary expression have different numerical types, __gmp_resolve_expr is used to determine the "larger" type. U is either __gmp_unary_expr or __gmp_binary_expr, where V and W are the arguments' types -- they can in turn be expressions, thus allowing to build compound expressions to any degree of complexity. Op is a function object that must have an eval() method accepting appropriate arguments. Actual evaluation of a __gmp_expr object is done when it gets assigned to an mp*_class ("lazy" evaluation): this is done by calling its eval() method. */ // non-member unary operators and functions #define __GMP_DEFINE_UNARY_FUNCTION(fun, eval_fun) \ \ template \ inline __gmp_expr, eval_fun> > \ fun(const __gmp_expr &expr) \ { \ return __gmp_expr, eval_fun> >(expr); \ } #define __GMP_DEFINE_UNARY_TYPE_FUNCTION(type, fun, eval_fun) \ \ template \ inline type fun(const __gmp_expr &expr) \ { \ __gmp_expr const& temp(expr); \ return eval_fun::eval(temp.__get_mp()); \ } // non-member binary operators and functions #define __GMPP_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ \ template \ inline __gmp_expr::value_type, \ __gmp_binary_expr<__gmp_expr, __gmp_expr, eval_fun> > \ fun(const __gmp_expr &expr1, const __gmp_expr &expr2) \ { \ return __gmp_expr::value_type, \ __gmp_binary_expr<__gmp_expr, __gmp_expr, eval_fun> > \ (expr1, expr2); \ } #define __GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, bigtype) \ \ template \ inline __gmp_expr \ , bigtype, eval_fun> > \ fun(const __gmp_expr &expr, type t) \ { \ return __gmp_expr \ , bigtype, eval_fun> >(expr, t); \ } \ \ template \ inline __gmp_expr \ , eval_fun> > \ fun(type t, const __gmp_expr &expr) \ { \ return __gmp_expr \ , eval_fun> >(t, expr); \ } #define __GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ __GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, signed long int) #define __GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ __GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, unsigned long int) #define __GMPND_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ __GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, double) #define __GMPNLD_DEFINE_BINARY_FUNCTION(fun, eval_fun, type) \ __GMPNN_DEFINE_BINARY_FUNCTION(fun, eval_fun, type, long double) #define __GMPN_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ __GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed char) \ __GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned char) \ __GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed int) \ __GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned int) \ __GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed short int) \ __GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned short int) \ __GMPNS_DEFINE_BINARY_FUNCTION(fun, eval_fun, signed long int) \ __GMPNU_DEFINE_BINARY_FUNCTION(fun, eval_fun, unsigned long int) \ __GMPND_DEFINE_BINARY_FUNCTION(fun, eval_fun, float) \ __GMPND_DEFINE_BINARY_FUNCTION(fun, eval_fun, double) \ /* __GMPNLD_DEFINE_BINARY_FUNCTION(fun, eval_fun, long double) */ #define __GMP_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ __GMPP_DEFINE_BINARY_FUNCTION(fun, eval_fun) \ __GMPN_DEFINE_BINARY_FUNCTION(fun, eval_fun) #define __GMP_DEFINE_BINARY_FUNCTION_UI(fun, eval_fun) \ \ template \ inline __gmp_expr \ , mp_bitcnt_t, eval_fun> > \ fun(const __gmp_expr &expr, mp_bitcnt_t l) \ { \ return __gmp_expr, mp_bitcnt_t, eval_fun> >(expr, l); \ } #define __GMPP_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ \ template \ inline type fun(const __gmp_expr &expr1, \ const __gmp_expr &expr2) \ { \ __gmp_expr const& temp1(expr1); \ __gmp_expr const& temp2(expr2); \ return eval_fun::eval(temp1.__get_mp(), temp2.__get_mp()); \ } #define __GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, \ type2, bigtype) \ \ template \ inline type fun(const __gmp_expr &expr, type2 t) \ { \ __gmp_expr const& temp(expr); \ return eval_fun::eval(temp.__get_mp(), static_cast(t)); \ } \ \ template \ inline type fun(type2 t, const __gmp_expr &expr) \ { \ __gmp_expr const& temp(expr); \ return eval_fun::eval(static_cast(t), temp.__get_mp()); \ } #define __GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, \ type2, signed long int) #define __GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, \ type2, unsigned long int) #define __GMPND_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2, double) #define __GMPNLD_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, type2, long double) #define __GMPN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ __GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed char) \ __GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned char) \ __GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed int) \ __GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned int) \ __GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed short int) \ __GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned short int) \ __GMPNS_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, signed long int) \ __GMPNU_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, unsigned long int) \ __GMPND_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, float) \ __GMPND_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, double) \ /* __GMPNLD_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun, long double) */ #define __GMP_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ __GMPP_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) \ __GMPN_DEFINE_BINARY_TYPE_FUNCTION(type, fun, eval_fun) // member operators #define __GMPP_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ \ template \ inline type##_class & type##_class::fun(const __gmp_expr &expr) \ { \ __gmp_set_expr(mp, __gmp_expr, eval_fun> >(*this, expr)); \ return *this; \ } #define __GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, \ type2, bigtype) \ \ inline type##_class & type##_class::fun(type2 t) \ { \ __gmp_set_expr(mp, __gmp_expr >(*this, t)); \ return *this; \ } #define __GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, \ type2, signed long int) #define __GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, \ type2, unsigned long int) #define __GMPND_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2, double) #define __GMPNLD_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2) \ __GMPNN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, type2, long double) #define __GMPN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ __GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed char) \ __GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned char) \ __GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed int) \ __GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned int) \ __GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed short int) \ __GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned short int) \ __GMPNS_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, signed long int) \ __GMPNU_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, unsigned long int) \ __GMPND_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, float) \ __GMPND_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, double) \ /* __GMPNLD_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun, long double) */ #define __GMP_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ __GMPP_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) \ __GMPN_DEFINE_COMPOUND_OPERATOR(type, fun, eval_fun) #define __GMPZ_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR(mpz, fun, eval_fun) #define __GMPQ_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR(mpq, fun, eval_fun) #define __GMPF_DEFINE_COMPOUND_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR(mpf, fun, eval_fun) #define __GMP_DEFINE_COMPOUND_OPERATOR_UI(type, fun, eval_fun) \ \ inline type##_class & type##_class::fun(mp_bitcnt_t l) \ { \ __gmp_set_expr(mp, __gmp_expr >(*this, l)); \ return *this; \ } #define __GMPZ_DEFINE_COMPOUND_OPERATOR_UI(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR_UI(mpz, fun, eval_fun) #define __GMPQ_DEFINE_COMPOUND_OPERATOR_UI(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR_UI(mpq, fun, eval_fun) #define __GMPF_DEFINE_COMPOUND_OPERATOR_UI(fun, eval_fun) \ __GMP_DEFINE_COMPOUND_OPERATOR_UI(mpf, fun, eval_fun) #define __GMP_DEFINE_INCREMENT_OPERATOR(type, fun, eval_fun) \ \ inline type##_class & type##_class::fun() \ { \ eval_fun::eval(mp); \ return *this; \ } \ \ inline type##_class type##_class::fun(int) \ { \ type##_class temp(*this); \ eval_fun::eval(mp); \ return temp; \ } #define __GMPZ_DEFINE_INCREMENT_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_INCREMENT_OPERATOR(mpz, fun, eval_fun) #define __GMPQ_DEFINE_INCREMENT_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_INCREMENT_OPERATOR(mpq, fun, eval_fun) #define __GMPF_DEFINE_INCREMENT_OPERATOR(fun, eval_fun) \ __GMP_DEFINE_INCREMENT_OPERATOR(mpf, fun, eval_fun) /**************** Arithmetic operators and functions ****************/ // non-member operators and functions __GMP_DEFINE_UNARY_FUNCTION(operator+, __gmp_unary_plus) __GMP_DEFINE_UNARY_FUNCTION(operator-, __gmp_unary_minus) __GMP_DEFINE_UNARY_FUNCTION(operator~, __gmp_unary_com) __GMP_DEFINE_BINARY_FUNCTION(operator+, __gmp_binary_plus) __GMP_DEFINE_BINARY_FUNCTION(operator-, __gmp_binary_minus) __GMP_DEFINE_BINARY_FUNCTION(operator*, __gmp_binary_multiplies) __GMP_DEFINE_BINARY_FUNCTION(operator/, __gmp_binary_divides) __GMP_DEFINE_BINARY_FUNCTION(operator%, __gmp_binary_modulus) __GMP_DEFINE_BINARY_FUNCTION(operator&, __gmp_binary_and) __GMP_DEFINE_BINARY_FUNCTION(operator|, __gmp_binary_ior) __GMP_DEFINE_BINARY_FUNCTION(operator^, __gmp_binary_xor) __GMP_DEFINE_BINARY_FUNCTION_UI(operator<<, __gmp_binary_lshift) __GMP_DEFINE_BINARY_FUNCTION_UI(operator>>, __gmp_binary_rshift) __GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator==, __gmp_binary_equal) __GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator!=, ! __gmp_binary_equal) __GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator<, __gmp_binary_less) __GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator<=, ! __gmp_binary_greater) __GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator>, __gmp_binary_greater) __GMP_DEFINE_BINARY_TYPE_FUNCTION(bool, operator>=, ! __gmp_binary_less) __GMP_DEFINE_UNARY_FUNCTION(abs, __gmp_abs_function) __GMP_DEFINE_UNARY_FUNCTION(trunc, __gmp_trunc_function) __GMP_DEFINE_UNARY_FUNCTION(floor, __gmp_floor_function) __GMP_DEFINE_UNARY_FUNCTION(ceil, __gmp_ceil_function) __GMP_DEFINE_UNARY_FUNCTION(sqrt, __gmp_sqrt_function) __GMP_DEFINE_BINARY_FUNCTION(hypot, __gmp_hypot_function) __GMP_DEFINE_BINARY_FUNCTION(gcd, __gmp_gcd_function) __GMP_DEFINE_BINARY_FUNCTION(lcm, __gmp_lcm_function) __GMP_DEFINE_UNARY_TYPE_FUNCTION(int, sgn, __gmp_sgn_function) __GMP_DEFINE_BINARY_TYPE_FUNCTION(int, cmp, __gmp_cmp_function) template void swap(__gmp_expr& x, __gmp_expr& y) __GMPXX_NOEXCEPT { x.swap(y); } // member operators for mpz_class __GMPZ_DEFINE_COMPOUND_OPERATOR(operator+=, __gmp_binary_plus) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator-=, __gmp_binary_minus) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator*=, __gmp_binary_multiplies) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator/=, __gmp_binary_divides) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator%=, __gmp_binary_modulus) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator&=, __gmp_binary_and) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator|=, __gmp_binary_ior) __GMPZ_DEFINE_COMPOUND_OPERATOR(operator^=, __gmp_binary_xor) __GMPZ_DEFINE_COMPOUND_OPERATOR_UI(operator<<=, __gmp_binary_lshift) __GMPZ_DEFINE_COMPOUND_OPERATOR_UI(operator>>=, __gmp_binary_rshift) __GMPZ_DEFINE_INCREMENT_OPERATOR(operator++, __gmp_unary_increment) __GMPZ_DEFINE_INCREMENT_OPERATOR(operator--, __gmp_unary_decrement) // member operators for mpq_class __GMPQ_DEFINE_COMPOUND_OPERATOR(operator+=, __gmp_binary_plus) __GMPQ_DEFINE_COMPOUND_OPERATOR(operator-=, __gmp_binary_minus) __GMPQ_DEFINE_COMPOUND_OPERATOR(operator*=, __gmp_binary_multiplies) __GMPQ_DEFINE_COMPOUND_OPERATOR(operator/=, __gmp_binary_divides) __GMPQ_DEFINE_COMPOUND_OPERATOR_UI(operator<<=, __gmp_binary_lshift) __GMPQ_DEFINE_COMPOUND_OPERATOR_UI(operator>>=, __gmp_binary_rshift) __GMPQ_DEFINE_INCREMENT_OPERATOR(operator++, __gmp_unary_increment) __GMPQ_DEFINE_INCREMENT_OPERATOR(operator--, __gmp_unary_decrement) // member operators for mpf_class __GMPF_DEFINE_COMPOUND_OPERATOR(operator+=, __gmp_binary_plus) __GMPF_DEFINE_COMPOUND_OPERATOR(operator-=, __gmp_binary_minus) __GMPF_DEFINE_COMPOUND_OPERATOR(operator*=, __gmp_binary_multiplies) __GMPF_DEFINE_COMPOUND_OPERATOR(operator/=, __gmp_binary_divides) __GMPF_DEFINE_COMPOUND_OPERATOR_UI(operator<<=, __gmp_binary_lshift) __GMPF_DEFINE_COMPOUND_OPERATOR_UI(operator>>=, __gmp_binary_rshift) __GMPF_DEFINE_INCREMENT_OPERATOR(operator++, __gmp_unary_increment) __GMPF_DEFINE_INCREMENT_OPERATOR(operator--, __gmp_unary_decrement) /**************** Class wrapper for gmp_randstate_t ****************/ class __gmp_urandomb_value { }; class __gmp_urandomm_value { }; template <> class __gmp_expr { private: __gmp_randstate_struct *state; mp_bitcnt_t bits; public: __gmp_expr(gmp_randstate_t s, mp_bitcnt_t l) : state(s), bits(l) { } void eval(mpz_ptr z) const { __gmp_rand_function::eval(z, state, bits); } mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } }; template <> class __gmp_expr { private: __gmp_randstate_struct *state; mpz_class range; public: __gmp_expr(gmp_randstate_t s, const mpz_class &z) : state(s), range(z) { } void eval(mpz_ptr z) const { __gmp_rand_function::eval(z, state, range.get_mpz_t()); } mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); } }; template <> class __gmp_expr { private: __gmp_randstate_struct *state; mp_bitcnt_t bits; public: __gmp_expr(gmp_randstate_t s, mp_bitcnt_t l) : state(s), bits(l) { } void eval(mpf_ptr f) const { __gmp_rand_function::eval(f, state, (bits>0) ? bits : mpf_get_prec(f)); } mp_bitcnt_t get_prec() const { if (bits == 0) return mpf_get_default_prec(); else return bits; } }; extern "C" { typedef void __gmp_randinit_default_t (gmp_randstate_t); typedef void __gmp_randinit_lc_2exp_t (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t); typedef int __gmp_randinit_lc_2exp_size_t (gmp_randstate_t, mp_bitcnt_t); } class gmp_randclass { private: gmp_randstate_t state; // copy construction and assignment not allowed gmp_randclass(const gmp_randclass &); void operator=(const gmp_randclass &); public: // constructors and destructor gmp_randclass(gmp_randalg_t alg, unsigned long int size) { switch (alg) { case GMP_RAND_ALG_LC: // no other cases for now default: gmp_randinit(state, alg, size); break; } } // gmp_randinit_default gmp_randclass(__gmp_randinit_default_t* f) { f(state); } // gmp_randinit_lc_2exp gmp_randclass(__gmp_randinit_lc_2exp_t* f, mpz_class z, unsigned long int l1, mp_bitcnt_t l2) { f(state, z.get_mpz_t(), l1, l2); } // gmp_randinit_lc_2exp_size gmp_randclass(__gmp_randinit_lc_2exp_size_t* f, mp_bitcnt_t size) { if (f (state, size) == 0) throw std::length_error ("gmp_randinit_lc_2exp_size"); } ~gmp_randclass() { gmp_randclear(state); } // initialize void seed(); // choose a random seed some way (?) void seed(unsigned long int s) { gmp_randseed_ui(state, s); } void seed(const mpz_class &z) { gmp_randseed(state, z.get_mpz_t()); } // get random number __gmp_expr get_z_bits(mp_bitcnt_t l) { return __gmp_expr(state, l); } __gmp_expr get_z_bits(const mpz_class &z) { return get_z_bits(z.get_ui()); } // FIXME: z.get_bitcnt_t() ? __gmp_expr get_z_range(const mpz_class &z) { return __gmp_expr(state, z); } __gmp_expr get_f(mp_bitcnt_t prec = 0) { return __gmp_expr(state, prec); } }; /**************** Specialize std::numeric_limits ****************/ namespace std { template <> class numeric_limits { public: static const bool is_specialized = true; static mpz_class min() { return mpz_class(); } static mpz_class max() { return mpz_class(); } static mpz_class lowest() { return mpz_class(); } static const int digits = 0; static const int digits10 = 0; static const int max_digits10 = 0; static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; static const int radix = 2; static mpz_class epsilon() { return mpz_class(); } static mpz_class round_error() { return mpz_class(); } static const int min_exponent = 0; static const int min_exponent10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; static const bool has_infinity = false; static const bool has_quiet_NaN = false; static const bool has_signaling_NaN = false; static const float_denorm_style has_denorm = denorm_absent; static const bool has_denorm_loss = false; static mpz_class infinity() { return mpz_class(); } static mpz_class quiet_NaN() { return mpz_class(); } static mpz_class signaling_NaN() { return mpz_class(); } static mpz_class denorm_min() { return mpz_class(); } static const bool is_iec559 = false; static const bool is_bounded = false; static const bool is_modulo = false; static const bool traps = false; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; template <> class numeric_limits { public: static const bool is_specialized = true; static mpq_class min() { return mpq_class(); } static mpq_class max() { return mpq_class(); } static mpq_class lowest() { return mpq_class(); } static const int digits = 0; static const int digits10 = 0; static const int max_digits10 = 0; static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = true; static const int radix = 2; static mpq_class epsilon() { return mpq_class(); } static mpq_class round_error() { return mpq_class(); } static const int min_exponent = 0; static const int min_exponent10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; static const bool has_infinity = false; static const bool has_quiet_NaN = false; static const bool has_signaling_NaN = false; static const float_denorm_style has_denorm = denorm_absent; static const bool has_denorm_loss = false; static mpq_class infinity() { return mpq_class(); } static mpq_class quiet_NaN() { return mpq_class(); } static mpq_class signaling_NaN() { return mpq_class(); } static mpq_class denorm_min() { return mpq_class(); } static const bool is_iec559 = false; static const bool is_bounded = false; static const bool is_modulo = false; static const bool traps = false; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; template <> class numeric_limits { public: static const bool is_specialized = true; static mpf_class min() { return mpf_class(); } static mpf_class max() { return mpf_class(); } static mpf_class lowest() { return mpf_class(); } static const int digits = 0; static const int digits10 = 0; static const int max_digits10 = 0; static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = false; static const int radix = 2; static mpf_class epsilon() { return mpf_class(); } static mpf_class round_error() { return mpf_class(); } static const int min_exponent = 0; static const int min_exponent10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; static const bool has_infinity = false; static const bool has_quiet_NaN = false; static const bool has_signaling_NaN = false; static const float_denorm_style has_denorm = denorm_absent; static const bool has_denorm_loss = false; static mpf_class infinity() { return mpf_class(); } static mpf_class quiet_NaN() { return mpf_class(); } static mpf_class signaling_NaN() { return mpf_class(); } static mpf_class denorm_min() { return mpf_class(); } static const bool is_iec559 = false; static const bool is_bounded = false; static const bool is_modulo = false; static const bool traps = false; static const bool tinyness_before = false; static const float_round_style round_style = round_indeterminate; }; } /**************** #undef all private macros ****************/ #undef __GMPP_DECLARE_COMPOUND_OPERATOR #undef __GMPN_DECLARE_COMPOUND_OPERATOR #undef __GMP_DECLARE_COMPOUND_OPERATOR #undef __GMP_DECLARE_COMPOUND_OPERATOR_UI #undef __GMP_DECLARE_INCREMENT_OPERATOR #undef __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS #undef __GMPXX_DEFINE_ARITHMETIC_ASSIGNMENTS #undef __GMPZQ_DEFINE_EXPR #undef __GMP_DEFINE_UNARY_FUNCTION #undef __GMP_DEFINE_UNARY_TYPE_FUNCTION #undef __GMPP_DEFINE_BINARY_FUNCTION #undef __GMPNN_DEFINE_BINARY_FUNCTION #undef __GMPNS_DEFINE_BINARY_FUNCTION #undef __GMPNU_DEFINE_BINARY_FUNCTION #undef __GMPND_DEFINE_BINARY_FUNCTION #undef __GMPNLD_DEFINE_BINARY_FUNCTION #undef __GMPN_DEFINE_BINARY_FUNCTION #undef __GMP_DEFINE_BINARY_FUNCTION #undef __GMP_DEFINE_BINARY_FUNCTION_UI #undef __GMPP_DEFINE_BINARY_TYPE_FUNCTION #undef __GMPNN_DEFINE_BINARY_TYPE_FUNCTION #undef __GMPNS_DEFINE_BINARY_TYPE_FUNCTION #undef __GMPNU_DEFINE_BINARY_TYPE_FUNCTION #undef __GMPND_DEFINE_BINARY_TYPE_FUNCTION #undef __GMPNLD_DEFINE_BINARY_TYPE_FUNCTION #undef __GMPN_DEFINE_BINARY_TYPE_FUNCTION #undef __GMP_DEFINE_BINARY_TYPE_FUNCTION #undef __GMPZ_DEFINE_COMPOUND_OPERATOR #undef __GMPP_DEFINE_COMPOUND_OPERATOR #undef __GMPNN_DEFINE_COMPOUND_OPERATOR #undef __GMPNS_DEFINE_COMPOUND_OPERATOR #undef __GMPNU_DEFINE_COMPOUND_OPERATOR #undef __GMPND_DEFINE_COMPOUND_OPERATOR #undef __GMPNLD_DEFINE_COMPOUND_OPERATOR #undef __GMPN_DEFINE_COMPOUND_OPERATOR #undef __GMP_DEFINE_COMPOUND_OPERATOR #undef __GMPQ_DEFINE_COMPOUND_OPERATOR #undef __GMPF_DEFINE_COMPOUND_OPERATOR #undef __GMP_DEFINE_COMPOUND_OPERATOR_UI #undef __GMPZ_DEFINE_COMPOUND_OPERATOR_UI #undef __GMPQ_DEFINE_COMPOUND_OPERATOR_UI #undef __GMPF_DEFINE_COMPOUND_OPERATOR_UI #undef __GMP_DEFINE_INCREMENT_OPERATOR #undef __GMPZ_DEFINE_INCREMENT_OPERATOR #undef __GMPQ_DEFINE_INCREMENT_OPERATOR #undef __GMPF_DEFINE_INCREMENT_OPERATOR #undef __GMPXX_CONSTANT_TRUE #undef __GMPXX_CONSTANT #endif /* __GMP_PLUSPLUS__ */ gmp-6.1.0/longlong.h000664 001756 001756 00000233647 12615426624 015464 0ustar00bodratobodrato000000 000000 /* longlong.h -- definitions for mixed size 32/64 bit arithmetic. Copyright 1991-1994, 1996, 1997, 1999-2005, 2007-2009, 2011-2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ /* You have to define the following before including this file: UWtype -- An unsigned type, default type for operations (typically a "word") UHWtype -- An unsigned type, at least half the size of UWtype UDWtype -- An unsigned type, at least twice as large a UWtype W_TYPE_SIZE -- size in bits of UWtype SItype, USItype -- Signed and unsigned 32 bit types DItype, UDItype -- Signed and unsigned 64 bit types On a 32 bit machine UWtype should typically be USItype; on a 64 bit machine, UWtype should typically be UDItype. Optionally, define: LONGLONG_STANDALONE -- Avoid code that needs machine-dependent support files NO_ASM -- Disable inline asm CAUTION! Using this version of longlong.h outside of GMP is not safe. You need to include gmp.h and gmp-impl.h, or certain things might not work as expected. */ #define __BITS4 (W_TYPE_SIZE / 4) #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2)) #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1)) #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2)) /* This is used to make sure no undesirable sharing between different libraries that use this file takes place. */ #ifndef __MPN #define __MPN(x) __##x #endif /* Define auxiliary asm macros. 1) umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype word product in HIGH_PROD and LOW_PROD. 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a UDWtype product. This is just a variant of umul_ppmm. 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, denominator) divides a UDWtype, composed by the UWtype integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less than DENOMINATOR for correct operation. If, in addition, the most significant bit of DENOMINATOR must be 1, then the pre-processor symbol UDIV_NEEDS_NORMALIZATION is defined to 1. 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator, denominator). Like udiv_qrnnd but the numbers are signed. The quotient is rounded towards 0. 5) count_leading_zeros(count, x) counts the number of zero-bits from the msb to the first non-zero bit in the UWtype X. This is the number of steps X needs to be shifted left to set the msb. Undefined for X == 0, unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value. 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts from the least significant end. 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1, high_addend_2, low_addend_2) adds two UWtype integers, composed by HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2 respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow (i.e. carry out) is not stored anywhere, and is lost. 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend, high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers, composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere, and is lost. If any of these macros are left undefined for a particular CPU, C macros are used. Notes: For add_ssaaaa the two high and two low addends can both commute, but unfortunately gcc only supports one "%" commutative in each asm block. This has always been so but is only documented in recent versions (eg. pre-release 3.3). Having two or more "%"s can cause an internal compiler error in certain rare circumstances. Apparently it was only the last "%" that was ever actually respected, so the code has been updated to leave just that. Clearly there's a free choice whether high or low should get it, if there's a reason to favour one over the other. Also obviously when the constraints on the two operands are identical there's no benefit to the reloader in any "%" at all. */ /* The CPUs come in alphabetical order below. Please add support for more CPUs here, or improve the current support for the CPUs below! */ /* count_leading_zeros_gcc_clz is count_leading_zeros implemented with gcc 3.4 __builtin_clzl or __builtin_clzll, according to our limb size. Similarly count_trailing_zeros_gcc_ctz using __builtin_ctzl or __builtin_ctzll. These builtins are only used when we check what code comes out, on some chips they're merely libgcc calls, where we will instead want an inline in that case (either asm or generic C). These builtins are better than an asm block of the same insn, since an asm block doesn't give gcc any information about scheduling or resource usage. We keep an asm block for use on prior versions of gcc though. For reference, __builtin_ffs existed in gcc prior to __builtin_clz, but it's not used (for count_leading_zeros) because it generally gives extra code to ensure the result is 0 when the input is 0, which we don't need or want. */ #ifdef _LONG_LONG_LIMB #define count_leading_zeros_gcc_clz(count,x) \ do { \ ASSERT ((x) != 0); \ (count) = __builtin_clzll (x); \ } while (0) #else #define count_leading_zeros_gcc_clz(count,x) \ do { \ ASSERT ((x) != 0); \ (count) = __builtin_clzl (x); \ } while (0) #endif #ifdef _LONG_LONG_LIMB #define count_trailing_zeros_gcc_ctz(count,x) \ do { \ ASSERT ((x) != 0); \ (count) = __builtin_ctzll (x); \ } while (0) #else #define count_trailing_zeros_gcc_ctz(count,x) \ do { \ ASSERT ((x) != 0); \ (count) = __builtin_ctzl (x); \ } while (0) #endif /* FIXME: The macros using external routines like __MPN(count_leading_zeros) don't need to be under !NO_ASM */ #if ! defined (NO_ASM) #if defined (__alpha) && W_TYPE_SIZE == 64 /* Most alpha-based machines, except Cray systems. */ #if defined (__GNUC__) #if __GMP_GNUC_PREREQ (3,3) #define umul_ppmm(ph, pl, m0, m1) \ do { \ UDItype __m0 = (m0), __m1 = (m1); \ (ph) = __builtin_alpha_umulh (__m0, __m1); \ (pl) = __m0 * __m1; \ } while (0) #else #define umul_ppmm(ph, pl, m0, m1) \ do { \ UDItype __m0 = (m0), __m1 = (m1); \ __asm__ ("umulh %r1,%2,%0" \ : "=r" (ph) \ : "%rJ" (__m0), "rI" (__m1)); \ (pl) = __m0 * __m1; \ } while (0) #endif #define UMUL_TIME 18 #else /* ! __GNUC__ */ #include #define umul_ppmm(ph, pl, m0, m1) \ do { \ UDItype __m0 = (m0), __m1 = (m1); \ (ph) = __UMULH (__m0, __m1); \ (pl) = __m0 * __m1; \ } while (0) #endif #ifndef LONGLONG_STANDALONE #define udiv_qrnnd(q, r, n1, n0, d) \ do { UWtype __di; \ __di = __MPN(invert_limb) (d); \ udiv_qrnnd_preinv (q, r, n1, n0, d, __di); \ } while (0) #define UDIV_PREINV_ALWAYS 1 #define UDIV_NEEDS_NORMALIZATION 1 #define UDIV_TIME 220 #endif /* LONGLONG_STANDALONE */ /* clz_tab is required in all configurations, since mpn/alpha/cntlz.asm always goes into libgmp.so, even when not actually used. */ #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB #if defined (__GNUC__) && HAVE_HOST_CPU_alpha_CIX #define count_leading_zeros(COUNT,X) \ __asm__("ctlz %1,%0" : "=r"(COUNT) : "r"(X)) #define count_trailing_zeros(COUNT,X) \ __asm__("cttz %1,%0" : "=r"(COUNT) : "r"(X)) #endif /* clz/ctz using cix */ #if ! defined (count_leading_zeros) \ && defined (__GNUC__) && ! defined (LONGLONG_STANDALONE) /* ALPHA_CMPBGE_0 gives "cmpbge $31,src,dst", ie. test src bytes == 0. "$31" is written explicitly in the asm, since an "r" constraint won't select reg 31. There seems no need to worry about "r31" syntax for cray, since gcc itself (pre-release 3.4) emits just $31 in various places. */ #define ALPHA_CMPBGE_0(dst, src) \ do { asm ("cmpbge $31, %1, %0" : "=r" (dst) : "r" (src)); } while (0) /* Zero bytes are turned into bits with cmpbge, a __clz_tab lookup counts them, locating the highest non-zero byte. A second __clz_tab lookup counts the leading zero bits in that byte, giving the result. */ #define count_leading_zeros(count, x) \ do { \ UWtype __clz__b, __clz__c, __clz__x = (x); \ ALPHA_CMPBGE_0 (__clz__b, __clz__x); /* zero bytes */ \ __clz__b = __clz_tab [(__clz__b >> 1) ^ 0x7F]; /* 8 to 1 byte */ \ __clz__b = __clz__b * 8 - 7; /* 57 to 1 shift */ \ __clz__x >>= __clz__b; \ __clz__c = __clz_tab [__clz__x]; /* 8 to 1 bit */ \ __clz__b = 65 - __clz__b; \ (count) = __clz__b - __clz__c; \ } while (0) #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB #endif /* clz using cmpbge */ #if ! defined (count_leading_zeros) && ! defined (LONGLONG_STANDALONE) #if HAVE_ATTRIBUTE_CONST long __MPN(count_leading_zeros) (UDItype) __attribute__ ((const)); #else long __MPN(count_leading_zeros) (UDItype); #endif #define count_leading_zeros(count, x) \ ((count) = __MPN(count_leading_zeros) (x)) #endif /* clz using mpn */ #endif /* __alpha */ #if defined (__AVR) && W_TYPE_SIZE == 8 #define umul_ppmm(ph, pl, m0, m1) \ do { \ unsigned short __p = (unsigned short) (m0) * (m1); \ (ph) = __p >> 8; \ (pl) = __p; \ } while (0) #endif /* AVR */ #if defined (_CRAY) && W_TYPE_SIZE == 64 #include #define UDIV_PREINV_ALWAYS 1 #define UDIV_NEEDS_NORMALIZATION 1 #define UDIV_TIME 220 long __MPN(count_leading_zeros) (UDItype); #define count_leading_zeros(count, x) \ ((count) = _leadz ((UWtype) (x))) #if defined (_CRAYIEEE) /* I.e., Cray T90/ieee, T3D, and T3E */ #define umul_ppmm(ph, pl, m0, m1) \ do { \ UDItype __m0 = (m0), __m1 = (m1); \ (ph) = _int_mult_upper (__m0, __m1); \ (pl) = __m0 * __m1; \ } while (0) #ifndef LONGLONG_STANDALONE #define udiv_qrnnd(q, r, n1, n0, d) \ do { UWtype __di; \ __di = __MPN(invert_limb) (d); \ udiv_qrnnd_preinv (q, r, n1, n0, d, __di); \ } while (0) #endif /* LONGLONG_STANDALONE */ #endif /* _CRAYIEEE */ #endif /* _CRAY */ #if defined (__ia64) && W_TYPE_SIZE == 64 /* This form encourages gcc (pre-release 3.4 at least) to emit predicated "sub r=r,r" and "sub r=r,r,1", giving a 2 cycle latency. The generic code using "al>= _c; \ if (_x >= 1 << 4) \ _x >>= 4, _c += 4; \ if (_x >= 1 << 2) \ _x >>= 2, _c += 2; \ _c += _x >> 1; \ (count) = W_TYPE_SIZE - 1 - _c; \ } while (0) /* similar to what gcc does for __builtin_ffs, but 0 based rather than 1 based, and we don't need a special case for x==0 here */ #define count_trailing_zeros(count, x) \ do { \ UWtype __ctz_x = (x); \ __asm__ ("popcnt %0 = %1" \ : "=r" (count) \ : "r" ((__ctz_x-1) & ~__ctz_x)); \ } while (0) #endif #if defined (__INTEL_COMPILER) #include #define umul_ppmm(ph, pl, m0, m1) \ do { \ UWtype __m0 = (m0), __m1 = (m1); \ ph = _m64_xmahu (__m0, __m1, 0); \ pl = __m0 * __m1; \ } while (0) #endif #ifndef LONGLONG_STANDALONE #define udiv_qrnnd(q, r, n1, n0, d) \ do { UWtype __di; \ __di = __MPN(invert_limb) (d); \ udiv_qrnnd_preinv (q, r, n1, n0, d, __di); \ } while (0) #define UDIV_PREINV_ALWAYS 1 #define UDIV_NEEDS_NORMALIZATION 1 #endif #define UDIV_TIME 220 #endif #if defined (__GNUC__) /* We sometimes need to clobber "cc" with gcc2, but that would not be understood by gcc1. Use cpp to avoid major code duplication. */ #if __GNUC__ < 2 #define __CLOBBER_CC #define __AND_CLOBBER_CC #else /* __GNUC__ >= 2 */ #define __CLOBBER_CC : "cc" #define __AND_CLOBBER_CC , "cc" #endif /* __GNUC__ < 2 */ #if (defined (__a29k__) || defined (_AM29K)) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %1,%4,%5\n\taddc %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %1,%4,%5\n\tsubc %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "rI" (bh), "r" (al), "rI" (bl)) #define umul_ppmm(xh, xl, m0, m1) \ do { \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("multiplu %0,%1,%2" \ : "=r" (xl) \ : "r" (__m0), "r" (__m1)); \ __asm__ ("multmu %0,%1,%2" \ : "=r" (xh) \ : "r" (__m0), "r" (__m1)); \ } while (0) #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("dividu %0,%3,%4" \ : "=r" (q), "=q" (r) \ : "1" (n1), "r" (n0), "r" (d)) #define count_leading_zeros(count, x) \ __asm__ ("clz %0,%1" \ : "=r" (count) \ : "r" (x)) #define COUNT_LEADING_ZEROS_0 32 #endif /* __a29k__ */ #if defined (__arc__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add.f\t%1, %4, %5\n\tadc\t%0, %2, %3" \ : "=r" (sh), \ "=&r" (sl) \ : "r" ((USItype) (ah)), \ "rIJ" ((USItype) (bh)), \ "%r" ((USItype) (al)), \ "rIJ" ((USItype) (bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub.f\t%1, %4, %5\n\tsbc\t%0, %2, %3" \ : "=r" (sh), \ "=&r" (sl) \ : "r" ((USItype) (ah)), \ "rIJ" ((USItype) (bh)), \ "r" ((USItype) (al)), \ "rIJ" ((USItype) (bl))) #endif #if defined (__arm__) && (defined (__thumb2__) || !defined (__thumb__)) \ && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("adds\t%1, %4, %5\n\tadc\t%0, %2, %3" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (al)) \ { \ if (__builtin_constant_p (ah)) \ __asm__ ("rsbs\t%1, %5, %4\n\trsc\t%0, %3, %2" \ : "=r" (sh), "=&r" (sl) \ : "rI" (ah), "r" (bh), "rI" (al), "r" (bl) __CLOBBER_CC); \ else \ __asm__ ("rsbs\t%1, %5, %4\n\tsbc\t%0, %2, %3" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "rI" (bh), "rI" (al), "r" (bl) __CLOBBER_CC); \ } \ else if (__builtin_constant_p (ah)) \ { \ if (__builtin_constant_p (bl)) \ __asm__ ("subs\t%1, %4, %5\n\trsc\t%0, %3, %2" \ : "=r" (sh), "=&r" (sl) \ : "rI" (ah), "r" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \ else \ __asm__ ("rsbs\t%1, %5, %4\n\trsc\t%0, %3, %2" \ : "=r" (sh), "=&r" (sl) \ : "rI" (ah), "r" (bh), "rI" (al), "r" (bl) __CLOBBER_CC); \ } \ else if (__builtin_constant_p (bl)) \ { \ if (__builtin_constant_p (bh)) \ __asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \ else \ __asm__ ("subs\t%1, %4, %5\n\trsc\t%0, %3, %2" \ : "=r" (sh), "=&r" (sl) \ : "rI" (ah), "r" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \ } \ else /* only bh might be a constant */ \ __asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC);\ } while (0) #if defined (__ARM_ARCH_2__) || defined (__ARM_ARCH_2A__) \ || defined (__ARM_ARCH_3__) #define umul_ppmm(xh, xl, a, b) \ do { \ register USItype __t0, __t1, __t2; \ __asm__ ("%@ Inlined umul_ppmm\n" \ " mov %2, %5, lsr #16\n" \ " mov %0, %6, lsr #16\n" \ " bic %3, %5, %2, lsl #16\n" \ " bic %4, %6, %0, lsl #16\n" \ " mul %1, %3, %4\n" \ " mul %4, %2, %4\n" \ " mul %3, %0, %3\n" \ " mul %0, %2, %0\n" \ " adds %3, %4, %3\n" \ " addcs %0, %0, #65536\n" \ " adds %1, %1, %3, lsl #16\n" \ " adc %0, %0, %3, lsr #16" \ : "=&r" ((USItype) (xh)), "=r" ((USItype) (xl)), \ "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \ : "r" ((USItype) (a)), "r" ((USItype) (b)) __CLOBBER_CC); \ } while (0) #define UMUL_TIME 20 #define udiv_qrnnd(q, r, n1, n0, d) \ do { UWtype __r; \ (q) = __MPN(udiv_qrnnd) (&__r, (n1), (n0), (d)); \ (r) = __r; \ } while (0) extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype); #define UDIV_TIME 200 #else /* ARMv4 or newer */ #define umul_ppmm(xh, xl, a, b) \ __asm__ ("umull %0,%1,%2,%3" : "=&r" (xl), "=&r" (xh) : "r" (a), "r" (b)) #define UMUL_TIME 5 #define smul_ppmm(xh, xl, a, b) \ __asm__ ("smull %0,%1,%2,%3" : "=&r" (xl), "=&r" (xh) : "r" (a), "r" (b)) #ifndef LONGLONG_STANDALONE #define udiv_qrnnd(q, r, n1, n0, d) \ do { UWtype __di; \ __di = __MPN(invert_limb) (d); \ udiv_qrnnd_preinv (q, r, n1, n0, d, __di); \ } while (0) #define UDIV_PREINV_ALWAYS 1 #define UDIV_NEEDS_NORMALIZATION 1 #define UDIV_TIME 70 #endif /* LONGLONG_STANDALONE */ #endif /* defined(__ARM_ARCH_2__) ... */ #define count_leading_zeros(count, x) count_leading_zeros_gcc_clz(count, x) #define count_trailing_zeros(count, x) count_trailing_zeros_gcc_ctz(count, x) #define COUNT_LEADING_ZEROS_0 32 #endif /* __arm__ */ #if defined (__aarch64__) && W_TYPE_SIZE == 64 /* FIXME: Extend the immediate range for the low word by using both ADDS and SUBS, since they set carry in the same way. */ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("adds\t%1, %x4, %5\n\tadc\t%0, %x2, %x3" \ : "=r" (sh), "=&r" (sl) \ : "rZ" ((UDItype)(ah)), "rZ" ((UDItype)(bh)), \ "%r" ((UDItype)(al)), "rI" ((UDItype)(bl)) __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subs\t%1, %x4, %5\n\tsbc\t%0, %x2, %x3" \ : "=r,r" (sh), "=&r,&r" (sl) \ : "rZ,rZ" ((UDItype)(ah)), "rZ,rZ" ((UDItype)(bh)), \ "r,Z" ((UDItype)(al)), "rI,r" ((UDItype)(bl)) __CLOBBER_CC) #define umul_ppmm(ph, pl, m0, m1) \ do { \ UDItype __m0 = (m0), __m1 = (m1); \ __asm__ ("umulh\t%0, %1, %2" : "=r" (ph) : "r" (__m0), "r" (__m1)); \ (pl) = __m0 * __m1; \ } while (0) #define count_leading_zeros(count, x) count_leading_zeros_gcc_clz(count, x) #define count_trailing_zeros(count, x) count_trailing_zeros_gcc_ctz(count, x) #define COUNT_LEADING_ZEROS_0 64 #endif /* __aarch64__ */ #if defined (__clipper__) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ ({union {UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __x; \ __asm__ ("mulwux %2,%0" \ : "=r" (__x.__ll) \ : "%0" ((USItype)(u)), "r" ((USItype)(v))); \ (w1) = __x.__i.__h; (w0) = __x.__i.__l;}) #define smul_ppmm(w1, w0, u, v) \ ({union {DItype __ll; \ struct {SItype __l, __h;} __i; \ } __x; \ __asm__ ("mulwx %2,%0" \ : "=r" (__x.__ll) \ : "%0" ((SItype)(u)), "r" ((SItype)(v))); \ (w1) = __x.__i.__h; (w0) = __x.__i.__l;}) #define __umulsidi3(u, v) \ ({UDItype __w; \ __asm__ ("mulwux %2,%0" \ : "=r" (__w) : "%0" ((USItype)(u)), "r" ((USItype)(v))); \ __w; }) #endif /* __clipper__ */ /* Fujitsu vector computers. */ #if defined (__uxp__) && W_TYPE_SIZE == 32 #define umul_ppmm(ph, pl, u, v) \ do { \ union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __asm__ ("mult.lu %1,%2,%0" : "=r" (__x.__ll) : "%r" (u), "rK" (v));\ (ph) = __x.__i.__h; \ (pl) = __x.__i.__l; \ } while (0) #define smul_ppmm(ph, pl, u, v) \ do { \ union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __asm__ ("mult.l %1,%2,%0" : "=r" (__x.__ll) : "%r" (u), "rK" (v)); \ (ph) = __x.__i.__h; \ (pl) = __x.__i.__l; \ } while (0) #endif #if defined (__gmicro__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add.w %5,%1\n\taddx %3,%0" \ : "=g" (sh), "=&g" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub.w %5,%1\n\tsubx %3,%0" \ : "=g" (sh), "=&g" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "1" ((USItype)(al)), "g" ((USItype)(bl))) #define umul_ppmm(ph, pl, m0, m1) \ __asm__ ("mulx %3,%0,%1" \ : "=g" (ph), "=r" (pl) \ : "%0" ((USItype)(m0)), "g" ((USItype)(m1))) #define udiv_qrnnd(q, r, nh, nl, d) \ __asm__ ("divx %4,%0,%1" \ : "=g" (q), "=r" (r) \ : "1" ((USItype)(nh)), "0" ((USItype)(nl)), "g" ((USItype)(d))) #define count_leading_zeros(count, x) \ __asm__ ("bsch/1 %1,%0" \ : "=g" (count) : "g" ((USItype)(x)), "0" ((USItype)0)) #endif #if defined (__hppa) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add%I5 %5,%r4,%1\n\taddc %r2,%r3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rM" (ah), "rM" (bh), "%rM" (al), "rI" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub%I4 %4,%r5,%1\n\tsubb %r2,%r3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rM" (ah), "rM" (bh), "rI" (al), "rM" (bl)) #if defined (_PA_RISC1_1) #define umul_ppmm(wh, wl, u, v) \ do { \ union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __asm__ ("xmpyu %1,%2,%0" : "=*f" (__x.__ll) : "*f" (u), "*f" (v)); \ (wh) = __x.__i.__h; \ (wl) = __x.__i.__l; \ } while (0) #define UMUL_TIME 8 #define UDIV_TIME 60 #else #define UMUL_TIME 40 #define UDIV_TIME 80 #endif #define count_leading_zeros(count, x) \ do { \ USItype __tmp; \ __asm__ ( \ "ldi 1,%0\n" \ " extru,= %1,15,16,%%r0 ; Bits 31..16 zero?\n" \ " extru,tr %1,15,16,%1 ; No. Shift down, skip add.\n" \ " ldo 16(%0),%0 ; Yes. Perform add.\n" \ " extru,= %1,23,8,%%r0 ; Bits 15..8 zero?\n" \ " extru,tr %1,23,8,%1 ; No. Shift down, skip add.\n" \ " ldo 8(%0),%0 ; Yes. Perform add.\n" \ " extru,= %1,27,4,%%r0 ; Bits 7..4 zero?\n" \ " extru,tr %1,27,4,%1 ; No. Shift down, skip add.\n" \ " ldo 4(%0),%0 ; Yes. Perform add.\n" \ " extru,= %1,29,2,%%r0 ; Bits 3..2 zero?\n" \ " extru,tr %1,29,2,%1 ; No. Shift down, skip add.\n" \ " ldo 2(%0),%0 ; Yes. Perform add.\n" \ " extru %1,30,1,%1 ; Extract bit 1.\n" \ " sub %0,%1,%0 ; Subtract it.\n" \ : "=r" (count), "=r" (__tmp) : "1" (x)); \ } while (0) #endif /* hppa */ /* These macros are for ABI=2.0w. In ABI=2.0n they can't be used, since GCC (3.2) puts longlong into two adjacent 32-bit registers. Presumably this is just a case of no direct support for 2.0n but treating it like 1.0. */ #if defined (__hppa) && W_TYPE_SIZE == 64 && ! defined (_LONG_LONG_LIMB) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add%I5 %5,%r4,%1\n\tadd,dc %r2,%r3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rM" (ah), "rM" (bh), "%rM" (al), "rI" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub%I4 %4,%r5,%1\n\tsub,db %r2,%r3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rM" (ah), "rM" (bh), "rI" (al), "rM" (bl)) #endif /* hppa */ #if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32 #if defined (__zarch__) || defined (HAVE_HOST_CPU_s390_zarch) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ /* if (__builtin_constant_p (bl)) \ __asm__ ("alfi\t%1,%o5\n\talcr\t%0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" (ah), "r" (bh), "%1" (al), "n" (bl) __CLOBBER_CC);\ else \ */ __asm__ ("alr\t%1,%5\n\talcr\t%0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" (ah), "r" (bh), "%1" (al), "r" (bl)__CLOBBER_CC); \ } while (0) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ /* if (__builtin_constant_p (bl)) \ __asm__ ("slfi\t%1,%o5\n\tslbr\t%0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" (ah), "r" (bh), "1" (al), "n" (bl) __CLOBBER_CC); \ else \ */ __asm__ ("slr\t%1,%5\n\tslbr\t%0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" (ah), "r" (bh), "1" (al), "r" (bl) __CLOBBER_CC); \ } while (0) #if __GMP_GNUC_PREREQ (4,5) #define umul_ppmm(xh, xl, m0, m1) \ do { \ union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __x.__ll = (UDItype) (m0) * (UDItype) (m1); \ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \ } while (0) #else #if 0 /* FIXME: this fails if gcc knows about the 64-bit registers. Use only with a new enough processor pretending we have 32-bit registers. */ #define umul_ppmm(xh, xl, m0, m1) \ do { \ union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __asm__ ("mlr\t%0,%2" \ : "=r" (__x.__ll) \ : "%0" (m0), "r" (m1)); \ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \ } while (0) #else #define umul_ppmm(xh, xl, m0, m1) \ do { \ /* When we have 64-bit regs and gcc is aware of that, we cannot simply use DImode for the product, since that would be allocated to a single 64-bit register, whereas mlr uses the low 32-bits of an even-odd register pair. */ \ register USItype __r0 __asm__ ("0"); \ register USItype __r1 __asm__ ("1") = (m0); \ __asm__ ("mlr\t%0,%3" \ : "=r" (__r0), "=r" (__r1) \ : "r" (__r1), "r" (m1)); \ (xh) = __r0; (xl) = __r1; \ } while (0) #endif /* if 0 */ #endif #if 0 /* FIXME: this fails if gcc knows about the 64-bit registers. Use only with a new enough processor pretending we have 32-bit registers. */ #define udiv_qrnnd(q, r, n1, n0, d) \ do { \ union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __x.__i.__h = n1; __x.__i.__l = n0; \ __asm__ ("dlr\t%0,%2" \ : "=r" (__x.__ll) \ : "0" (__x.__ll), "r" (d)); \ (q) = __x.__i.__l; (r) = __x.__i.__h; \ } while (0) #else #define udiv_qrnnd(q, r, n1, n0, d) \ do { \ register USItype __r0 __asm__ ("0") = (n1); \ register USItype __r1 __asm__ ("1") = (n0); \ __asm__ ("dlr\t%0,%4" \ : "=r" (__r0), "=r" (__r1) \ : "r" (__r0), "r" (__r1), "r" (d)); \ (q) = __r1; (r) = __r0; \ } while (0) #endif /* if 0 */ #else /* if __zarch__ */ /* FIXME: this fails if gcc knows about the 64-bit registers. */ #define smul_ppmm(xh, xl, m0, m1) \ do { \ union {DItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __asm__ ("mr\t%0,%2" \ : "=r" (__x.__ll) \ : "%0" (m0), "r" (m1)); \ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \ } while (0) /* FIXME: this fails if gcc knows about the 64-bit registers. */ #define sdiv_qrnnd(q, r, n1, n0, d) \ do { \ union {DItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __x.__i.__h = n1; __x.__i.__l = n0; \ __asm__ ("dr\t%0,%2" \ : "=r" (__x.__ll) \ : "0" (__x.__ll), "r" (d)); \ (q) = __x.__i.__l; (r) = __x.__i.__h; \ } while (0) #endif /* if __zarch__ */ #endif #if defined (__s390x__) && W_TYPE_SIZE == 64 /* We need to cast operands with register constraints, otherwise their types will be assumed to be SImode by gcc. For these machines, such operations will insert a value into the low 32 bits, and leave the high 32 bits with garbage. */ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ __asm__ ("algr\t%1,%5\n\talcgr\t%0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" ((UDItype)(ah)), "r" ((UDItype)(bh)), \ "%1" ((UDItype)(al)), "r" ((UDItype)(bl)) __CLOBBER_CC); \ } while (0) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ __asm__ ("slgr\t%1,%5\n\tslbgr\t%0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" ((UDItype)(ah)), "r" ((UDItype)(bh)), \ "1" ((UDItype)(al)), "r" ((UDItype)(bl)) __CLOBBER_CC); \ } while (0) #define umul_ppmm(xh, xl, m0, m1) \ do { \ union {unsigned int __attribute__ ((mode(TI))) __ll; \ struct {UDItype __h, __l;} __i; \ } __x; \ __asm__ ("mlgr\t%0,%2" \ : "=r" (__x.__ll) \ : "%0" ((UDItype)(m0)), "r" ((UDItype)(m1))); \ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \ } while (0) #define udiv_qrnnd(q, r, n1, n0, d) \ do { \ union {unsigned int __attribute__ ((mode(TI))) __ll; \ struct {UDItype __h, __l;} __i; \ } __x; \ __x.__i.__h = n1; __x.__i.__l = n0; \ __asm__ ("dlgr\t%0,%2" \ : "=r" (__x.__ll) \ : "0" (__x.__ll), "r" ((UDItype)(d))); \ (q) = __x.__i.__l; (r) = __x.__i.__h; \ } while (0) #if 0 /* FIXME: Enable for z10 (?) */ #define count_leading_zeros(cnt, x) \ do { \ union {unsigned int __attribute__ ((mode(TI))) __ll; \ struct {UDItype __h, __l;} __i; \ } __clr_cnt; \ __asm__ ("flogr\t%0,%1" \ : "=r" (__clr_cnt.__ll) \ : "r" (x) __CLOBBER_CC); \ (cnt) = __clr_cnt.__i.__h; \ } while (0) #endif #endif /* On x86 and x86_64, every asm implicitly clobbers "flags" and "fpsr", so we don't need __CLOBBER_CC. */ #if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl %5,%k1\n\tadcl %3,%k0" \ : "=r" (sh), "=&r" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl %5,%k1\n\tsbbl %3,%k0" \ : "=r" (sh), "=&r" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "1" ((USItype)(al)), "g" ((USItype)(bl))) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mull %3" \ : "=a" (w0), "=d" (w1) \ : "%0" ((USItype)(u)), "rm" ((USItype)(v))) #define udiv_qrnnd(q, r, n1, n0, dx) /* d renamed to dx avoiding "=d" */\ __asm__ ("divl %4" /* stringification in K&R C */ \ : "=a" (q), "=d" (r) \ : "0" ((USItype)(n0)), "1" ((USItype)(n1)), "rm" ((USItype)(dx))) #if HAVE_HOST_CPU_i586 || HAVE_HOST_CPU_pentium || HAVE_HOST_CPU_pentiummmx /* Pentium bsrl takes between 10 and 72 cycles depending where the most significant 1 bit is, hence the use of the following alternatives. bsfl is slow too, between 18 and 42 depending where the least significant 1 bit is, so let the generic count_trailing_zeros below make use of the count_leading_zeros here too. */ #if HAVE_HOST_CPU_pentiummmx && ! defined (LONGLONG_STANDALONE) /* The following should be a fixed 14 or 15 cycles, but possibly plus an L1 cache miss reading from __clz_tab. For P55 it's favoured over the float below so as to avoid mixing MMX and x87, since the penalty for switching between the two is about 100 cycles. The asm block sets __shift to -3 if the high 24 bits are clear, -2 for 16, -1 for 8, or 0 otherwise. This could be written equivalently as follows, but as of gcc 2.95.2 it results in conditional jumps. __shift = -(__n < 0x1000000); __shift -= (__n < 0x10000); __shift -= (__n < 0x100); The middle two sbbl and cmpl's pair, and with luck something gcc generates might pair with the first cmpl and the last sbbl. The "32+1" constant could be folded into __clz_tab[], but it doesn't seem worth making a different table just for that. */ #define count_leading_zeros(c,n) \ do { \ USItype __n = (n); \ USItype __shift; \ __asm__ ("cmpl $0x1000000, %1\n" \ "sbbl %0, %0\n" \ "cmpl $0x10000, %1\n" \ "sbbl $0, %0\n" \ "cmpl $0x100, %1\n" \ "sbbl $0, %0\n" \ : "=&r" (__shift) : "r" (__n)); \ __shift = __shift*8 + 24 + 1; \ (c) = 32 + 1 - __shift - __clz_tab[__n >> __shift]; \ } while (0) #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB #define COUNT_LEADING_ZEROS_0 31 /* n==0 indistinguishable from n==1 */ #else /* ! pentiummmx || LONGLONG_STANDALONE */ /* The following should be a fixed 14 cycles or so. Some scheduling opportunities should be available between the float load/store too. This sort of code is used in gcc 3 for __builtin_ffs (with "n&-n") and is apparently suggested by the Intel optimizing manual (don't know exactly where). gcc 2.95 or up will be best for this, so the "double" is correctly aligned on the stack. */ #define count_leading_zeros(c,n) \ do { \ union { \ double d; \ unsigned a[2]; \ } __u; \ ASSERT ((n) != 0); \ __u.d = (UWtype) (n); \ (c) = 0x3FF + 31 - (__u.a[1] >> 20); \ } while (0) #define COUNT_LEADING_ZEROS_0 (0x3FF + 31) #endif /* pentiummx */ #else /* ! pentium */ #if __GMP_GNUC_PREREQ (3,4) /* using bsrl */ #define count_leading_zeros(count,x) count_leading_zeros_gcc_clz(count,x) #endif /* gcc clz */ /* On P6, gcc prior to 3.0 generates a partial register stall for __cbtmp^31, due to using "xorb $31" instead of "xorl $31", the former being 1 code byte smaller. "31-__cbtmp" is a workaround, probably at the cost of one extra instruction. Do this for "i386" too, since that means generic x86. */ #if ! defined (count_leading_zeros) && __GNUC__ < 3 \ && (HAVE_HOST_CPU_i386 \ || HAVE_HOST_CPU_i686 \ || HAVE_HOST_CPU_pentiumpro \ || HAVE_HOST_CPU_pentium2 \ || HAVE_HOST_CPU_pentium3) #define count_leading_zeros(count, x) \ do { \ USItype __cbtmp; \ ASSERT ((x) != 0); \ __asm__ ("bsrl %1,%0" : "=r" (__cbtmp) : "rm" ((USItype)(x))); \ (count) = 31 - __cbtmp; \ } while (0) #endif /* gcc<3 asm bsrl */ #ifndef count_leading_zeros #define count_leading_zeros(count, x) \ do { \ USItype __cbtmp; \ ASSERT ((x) != 0); \ __asm__ ("bsrl %1,%0" : "=r" (__cbtmp) : "rm" ((USItype)(x))); \ (count) = __cbtmp ^ 31; \ } while (0) #endif /* asm bsrl */ #if __GMP_GNUC_PREREQ (3,4) /* using bsfl */ #define count_trailing_zeros(count,x) count_trailing_zeros_gcc_ctz(count,x) #endif /* gcc ctz */ #ifndef count_trailing_zeros #define count_trailing_zeros(count, x) \ do { \ ASSERT ((x) != 0); \ __asm__ ("bsfl %1,%k0" : "=r" (count) : "rm" ((USItype)(x))); \ } while (0) #endif /* asm bsfl */ #endif /* ! pentium */ #ifndef UMUL_TIME #define UMUL_TIME 10 #endif #ifndef UDIV_TIME #define UDIV_TIME 40 #endif #endif /* 80x86 */ #if defined (__amd64__) && W_TYPE_SIZE == 64 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addq %5,%q1\n\tadcq %3,%q0" \ : "=r" (sh), "=&r" (sl) \ : "0" ((UDItype)(ah)), "rme" ((UDItype)(bh)), \ "%1" ((UDItype)(al)), "rme" ((UDItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subq %5,%q1\n\tsbbq %3,%q0" \ : "=r" (sh), "=&r" (sl) \ : "0" ((UDItype)(ah)), "rme" ((UDItype)(bh)), \ "1" ((UDItype)(al)), "rme" ((UDItype)(bl))) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mulq %3" \ : "=a" (w0), "=d" (w1) \ : "%0" ((UDItype)(u)), "rm" ((UDItype)(v))) #define udiv_qrnnd(q, r, n1, n0, dx) /* d renamed to dx avoiding "=d" */\ __asm__ ("divq %4" /* stringification in K&R C */ \ : "=a" (q), "=d" (r) \ : "0" ((UDItype)(n0)), "1" ((UDItype)(n1)), "rm" ((UDItype)(dx))) /* bsrq destination must be a 64-bit register, hence UDItype for __cbtmp. */ #define count_leading_zeros(count, x) \ do { \ UDItype __cbtmp; \ ASSERT ((x) != 0); \ __asm__ ("bsrq %1,%0" : "=r" (__cbtmp) : "rm" ((UDItype)(x))); \ (count) = __cbtmp ^ 63; \ } while (0) /* bsfq destination must be a 64-bit register, "%q0" forces this in case count is only an int. */ #define count_trailing_zeros(count, x) \ do { \ ASSERT ((x) != 0); \ __asm__ ("bsfq %1,%q0" : "=r" (count) : "rm" ((UDItype)(x))); \ } while (0) #endif /* __amd64__ */ #if defined (__i860__) && W_TYPE_SIZE == 32 #define rshift_rhlc(r,h,l,c) \ __asm__ ("shr %3,r0,r0\;shrd %1,%2,%0" \ "=r" (r) : "r" (h), "r" (l), "rn" (c)) #endif /* i860 */ #if defined (__i960__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("cmpo 1,0\;addc %5,%4,%1\;addc %3,%2,%0" \ : "=r" (sh), "=&r" (sl) \ : "dI" (ah), "dI" (bh), "%dI" (al), "dI" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("cmpo 0,0\;subc %5,%4,%1\;subc %3,%2,%0" \ : "=r" (sh), "=&r" (sl) \ : "dI" (ah), "dI" (bh), "dI" (al), "dI" (bl)) #define umul_ppmm(w1, w0, u, v) \ ({union {UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __x; \ __asm__ ("emul %2,%1,%0" \ : "=d" (__x.__ll) : "%dI" (u), "dI" (v)); \ (w1) = __x.__i.__h; (w0) = __x.__i.__l;}) #define __umulsidi3(u, v) \ ({UDItype __w; \ __asm__ ("emul %2,%1,%0" : "=d" (__w) : "%dI" (u), "dI" (v)); \ __w; }) #define udiv_qrnnd(q, r, nh, nl, d) \ do { \ union {UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __nn; \ __nn.__i.__h = (nh); __nn.__i.__l = (nl); \ __asm__ ("ediv %d,%n,%0" \ : "=d" (__rq.__ll) : "dI" (__nn.__ll), "dI" (d)); \ (r) = __rq.__i.__l; (q) = __rq.__i.__h; \ } while (0) #define count_leading_zeros(count, x) \ do { \ USItype __cbtmp; \ __asm__ ("scanbit %1,%0" : "=r" (__cbtmp) : "r" (x)); \ (count) = __cbtmp ^ 31; \ } while (0) #define COUNT_LEADING_ZEROS_0 (-32) /* sic */ #if defined (__i960mx) /* what is the proper symbol to test??? */ #define rshift_rhlc(r,h,l,c) \ do { \ union {UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __nn; \ __nn.__i.__h = (h); __nn.__i.__l = (l); \ __asm__ ("shre %2,%1,%0" : "=d" (r) : "dI" (__nn.__ll), "dI" (c)); \ } #endif /* i960mx */ #endif /* i960 */ #if (defined (__mc68000__) || defined (__mc68020__) || defined(mc68020) \ || defined (__m68k__) || defined (__mc5200__) || defined (__mc5206e__) \ || defined (__mc5307__)) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \ : "=d" (sh), "=&d" (sl) \ : "0" ((USItype)(ah)), "d" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \ : "=d" (sh), "=&d" (sl) \ : "0" ((USItype)(ah)), "d" ((USItype)(bh)), \ "1" ((USItype)(al)), "g" ((USItype)(bl))) /* The '020, '030, '040 and CPU32 have 32x32->64 and 64/32->32q-32r. */ #if defined (__mc68020__) || defined(mc68020) \ || defined (__mc68030__) || defined (mc68030) \ || defined (__mc68040__) || defined (mc68040) \ || defined (__mcpu32__) || defined (mcpu32) \ || defined (__NeXT__) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mulu%.l %3,%1:%0" \ : "=d" (w0), "=d" (w1) \ : "%0" ((USItype)(u)), "dmi" ((USItype)(v))) #define UMUL_TIME 45 #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divu%.l %4,%1:%0" \ : "=d" (q), "=d" (r) \ : "0" ((USItype)(n0)), "1" ((USItype)(n1)), "dmi" ((USItype)(d))) #define UDIV_TIME 90 #define sdiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divs%.l %4,%1:%0" \ : "=d" (q), "=d" (r) \ : "0" ((USItype)(n0)), "1" ((USItype)(n1)), "dmi" ((USItype)(d))) #else /* for other 68k family members use 16x16->32 multiplication */ #define umul_ppmm(xh, xl, a, b) \ do { USItype __umul_tmp1, __umul_tmp2; \ __asm__ ("| Inlined umul_ppmm\n" \ " move%.l %5,%3\n" \ " move%.l %2,%0\n" \ " move%.w %3,%1\n" \ " swap %3\n" \ " swap %0\n" \ " mulu%.w %2,%1\n" \ " mulu%.w %3,%0\n" \ " mulu%.w %2,%3\n" \ " swap %2\n" \ " mulu%.w %5,%2\n" \ " add%.l %3,%2\n" \ " jcc 1f\n" \ " add%.l %#0x10000,%0\n" \ "1: move%.l %2,%3\n" \ " clr%.w %2\n" \ " swap %2\n" \ " swap %3\n" \ " clr%.w %3\n" \ " add%.l %3,%1\n" \ " addx%.l %2,%0\n" \ " | End inlined umul_ppmm" \ : "=&d" (xh), "=&d" (xl), \ "=d" (__umul_tmp1), "=&d" (__umul_tmp2) \ : "%2" ((USItype)(a)), "d" ((USItype)(b))); \ } while (0) #define UMUL_TIME 100 #define UDIV_TIME 400 #endif /* not mc68020 */ /* The '020, '030, '040 and '060 have bitfield insns. GCC 3.4 defines __mc68020__ when in CPU32 mode, check for __mcpu32__ to exclude bfffo on that chip (bitfield insns not available). */ #if (defined (__mc68020__) || defined (mc68020) \ || defined (__mc68030__) || defined (mc68030) \ || defined (__mc68040__) || defined (mc68040) \ || defined (__mc68060__) || defined (mc68060) \ || defined (__NeXT__)) \ && ! defined (__mcpu32__) #define count_leading_zeros(count, x) \ __asm__ ("bfffo %1{%b2:%b2},%0" \ : "=d" (count) \ : "od" ((USItype) (x)), "n" (0)) #define COUNT_LEADING_ZEROS_0 32 #endif #endif /* mc68000 */ #if defined (__m88000__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \ : "=r" (sh), "=&r" (sl) \ : "rJ" (ah), "rJ" (bh), "%rJ" (al), "rJ" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \ : "=r" (sh), "=&r" (sl) \ : "rJ" (ah), "rJ" (bh), "rJ" (al), "rJ" (bl)) #define count_leading_zeros(count, x) \ do { \ USItype __cbtmp; \ __asm__ ("ff1 %0,%1" : "=r" (__cbtmp) : "r" (x)); \ (count) = __cbtmp ^ 31; \ } while (0) #define COUNT_LEADING_ZEROS_0 63 /* sic */ #if defined (__m88110__) #define umul_ppmm(wh, wl, u, v) \ do { \ union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __asm__ ("mulu.d %0,%1,%2" : "=r" (__x.__ll) : "r" (u), "r" (v)); \ (wh) = __x.__i.__h; \ (wl) = __x.__i.__l; \ } while (0) #define udiv_qrnnd(q, r, n1, n0, d) \ ({union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x, __q; \ __x.__i.__h = (n1); __x.__i.__l = (n0); \ __asm__ ("divu.d %0,%1,%2" \ : "=r" (__q.__ll) : "r" (__x.__ll), "r" (d)); \ (r) = (n0) - __q.__l * (d); (q) = __q.__l; }) #define UMUL_TIME 5 #define UDIV_TIME 25 #else #define UMUL_TIME 17 #define UDIV_TIME 150 #endif /* __m88110__ */ #endif /* __m88000__ */ #if defined (__mips) && W_TYPE_SIZE == 32 #if __GMP_GNUC_PREREQ (4,4) #define umul_ppmm(w1, w0, u, v) \ do { \ UDItype __ll = (UDItype)(u) * (v); \ w1 = __ll >> 32; \ w0 = __ll; \ } while (0) #endif #if !defined (umul_ppmm) && __GMP_GNUC_PREREQ (2,7) && !defined (__clang__) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("multu %2,%3" : "=l" (w0), "=h" (w1) : "d" (u), "d" (v)) #endif #if !defined (umul_ppmm) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("multu %2,%3\n\tmflo %0\n\tmfhi %1" \ : "=d" (w0), "=d" (w1) : "d" (u), "d" (v)) #endif #define UMUL_TIME 10 #define UDIV_TIME 100 #endif /* __mips */ #if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64 #if __GMP_GNUC_PREREQ (4,4) #define umul_ppmm(w1, w0, u, v) \ do { \ typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \ __ll_UTItype __ll = (__ll_UTItype)(u) * (v); \ w1 = __ll >> 64; \ w0 = __ll; \ } while (0) #endif #if !defined (umul_ppmm) && __GMP_GNUC_PREREQ (2,7) && !defined (__clang__) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("dmultu %2,%3" \ : "=l" (w0), "=h" (w1) \ : "d" ((UDItype)(u)), "d" ((UDItype)(v))) #endif #if !defined (umul_ppmm) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("dmultu %2,%3\n\tmflo %0\n\tmfhi %1" \ : "=d" (w0), "=d" (w1) \ : "d" ((UDItype)(u)), "d" ((UDItype)(v))) #endif #define UMUL_TIME 20 #define UDIV_TIME 140 #endif /* __mips */ #if defined (__mmix__) && W_TYPE_SIZE == 64 #define umul_ppmm(w1, w0, u, v) \ __asm__ ("MULU %0,%2,%3" : "=r" (w0), "=z" (w1) : "r" (u), "r" (v)) #endif #if defined (__ns32000__) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ ({union {UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __x; \ __asm__ ("meid %2,%0" \ : "=g" (__x.__ll) \ : "%0" ((USItype)(u)), "g" ((USItype)(v))); \ (w1) = __x.__i.__h; (w0) = __x.__i.__l;}) #define __umulsidi3(u, v) \ ({UDItype __w; \ __asm__ ("meid %2,%0" \ : "=g" (__w) \ : "%0" ((USItype)(u)), "g" ((USItype)(v))); \ __w; }) #define udiv_qrnnd(q, r, n1, n0, d) \ ({union {UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __x; \ __x.__i.__h = (n1); __x.__i.__l = (n0); \ __asm__ ("deid %2,%0" \ : "=g" (__x.__ll) \ : "0" (__x.__ll), "g" ((USItype)(d))); \ (r) = __x.__i.__l; (q) = __x.__i.__h; }) #define count_trailing_zeros(count,x) \ do { \ __asm__ ("ffsd %2,%0" \ : "=r" (count) \ : "0" ((USItype) 0), "r" ((USItype) (x))); \ } while (0) #endif /* __ns32000__ */ /* In the past we had a block of various #defines tested _ARCH_PPC - AIX _ARCH_PWR - AIX __powerpc__ - gcc __POWERPC__ - BEOS __ppc__ - Darwin PPC - old gcc, GNU/Linux, SysV The plain PPC test was not good for vxWorks, since PPC is defined on all CPUs there (eg. m68k too), as a constant one is expected to compare CPU_FAMILY against. At any rate, this was pretty unattractive and a bit fragile. The use of HAVE_HOST_CPU_FAMILY is designed to cut through it all and be sure of getting the desired effect. ENHANCE-ME: We should test _IBMR2 here when we add assembly support for the system vendor compilers. (Is that vendor compilers with inline asm, or what?) */ #if (HAVE_HOST_CPU_FAMILY_power || HAVE_HOST_CPU_FAMILY_powerpc) \ && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (bh) && (bh) == 0) \ __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2" \ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl)); \ else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \ __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2" \ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl)); \ else \ __asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \ } while (0) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (ah) && (ah) == 0) \ __asm__ ("subf%I3c %1,%4,%3\n\tsubfze %0,%2" \ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0) \ __asm__ ("subf%I3c %1,%4,%3\n\tsubfme %0,%2" \ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ else if (__builtin_constant_p (bh) && (bh) == 0) \ __asm__ ("subf%I3c %1,%4,%3\n\taddme %0,%2" \ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \ __asm__ ("subf%I3c %1,%4,%3\n\taddze %0,%2" \ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ else \ __asm__ ("subf%I4c %1,%5,%4\n\tsubfe %0,%3,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \ } while (0) #define count_leading_zeros(count, x) \ __asm__ ("cntlzw %0,%1" : "=r" (count) : "r" (x)) #define COUNT_LEADING_ZEROS_0 32 #if HAVE_HOST_CPU_FAMILY_powerpc #if __GMP_GNUC_PREREQ (4,4) #define umul_ppmm(w1, w0, u, v) \ do { \ UDItype __ll = (UDItype)(u) * (v); \ w1 = __ll >> 32; \ w0 = __ll; \ } while (0) #endif #if !defined (umul_ppmm) #define umul_ppmm(ph, pl, m0, m1) \ do { \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \ (pl) = __m0 * __m1; \ } while (0) #endif #define UMUL_TIME 15 #define smul_ppmm(ph, pl, m0, m1) \ do { \ SItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mulhw %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \ (pl) = __m0 * __m1; \ } while (0) #define SMUL_TIME 14 #define UDIV_TIME 120 #else #define UMUL_TIME 8 #define smul_ppmm(xh, xl, m0, m1) \ __asm__ ("mul %0,%2,%3" : "=r" (xh), "=q" (xl) : "r" (m0), "r" (m1)) #define SMUL_TIME 4 #define sdiv_qrnnd(q, r, nh, nl, d) \ __asm__ ("div %0,%2,%4" : "=r" (q), "=q" (r) : "r" (nh), "1" (nl), "r" (d)) #define UDIV_TIME 100 #endif #endif /* 32-bit POWER architecture variants. */ /* We should test _IBMR2 here when we add assembly support for the system vendor compilers. */ #if HAVE_HOST_CPU_FAMILY_powerpc && W_TYPE_SIZE == 64 #if !defined (_LONG_LONG_LIMB) /* _LONG_LONG_LIMB is ABI=mode32 where adde operates on 32-bit values. So use adde etc only when not _LONG_LONG_LIMB. */ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (bh) && (bh) == 0) \ __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), \ "%r" ((UDItype)(al)), "rI" ((UDItype)(bl))); \ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \ __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), \ "%r" ((UDItype)(al)), "rI" ((UDItype)(bl))); \ else \ __asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), "r" ((UDItype)(bh)), \ "%r" ((UDItype)(al)), "rI" ((UDItype)(bl))); \ } while (0) /* We use "*rI" for the constant operand here, since with just "I", gcc barfs. This might seem strange, but gcc folds away the dead code late. */ #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (bl) && bl > -0x8000 && bl <= 0x8000) { \ if (__builtin_constant_p (ah) && (ah) == 0) \ __asm__ ("addic %1,%3,%4\n\tsubfze %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(bh)), \ "rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl)))); \ else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \ __asm__ ("addic %1,%3,%4\n\tsubfme %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(bh)), \ "rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl)))); \ else if (__builtin_constant_p (bh) && (bh) == 0) \ __asm__ ("addic %1,%3,%4\n\taddme %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), \ "rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl)))); \ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \ __asm__ ("addic %1,%3,%4\n\taddze %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), \ "rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl)))); \ else \ __asm__ ("addic %1,%4,%5\n\tsubfe %0,%3,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), "r" ((UDItype)(bh)), \ "rI" ((UDItype)(al)), "*rI" (-((UDItype)(bl)))); \ } else { \ if (__builtin_constant_p (ah) && (ah) == 0) \ __asm__ ("subf%I3c %1,%4,%3\n\tsubfze %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(bh)), \ "rI" ((UDItype)(al)), "r" ((UDItype)(bl))); \ else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \ __asm__ ("subf%I3c %1,%4,%3\n\tsubfme %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(bh)), \ "rI" ((UDItype)(al)), "r" ((UDItype)(bl))); \ else if (__builtin_constant_p (bh) && (bh) == 0) \ __asm__ ("subf%I3c %1,%4,%3\n\taddme %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), \ "rI" ((UDItype)(al)), "r" ((UDItype)(bl))); \ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \ __asm__ ("subf%I3c %1,%4,%3\n\taddze %0,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), \ "rI" ((UDItype)(al)), "r" ((UDItype)(bl))); \ else \ __asm__ ("subf%I4c %1,%5,%4\n\tsubfe %0,%3,%2" \ : "=r" (sh), "=&r" (sl) \ : "r" ((UDItype)(ah)), "r" ((UDItype)(bh)), \ "rI" ((UDItype)(al)), "r" ((UDItype)(bl))); \ } \ } while (0) #endif /* ! _LONG_LONG_LIMB */ #define count_leading_zeros(count, x) \ __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x)) #define COUNT_LEADING_ZEROS_0 64 #if 0 && __GMP_GNUC_PREREQ (4,4) /* Disable, this results in libcalls! */ #define umul_ppmm(w1, w0, u, v) \ do { \ typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \ __ll_UTItype __ll = (__ll_UTItype)(u) * (v); \ w1 = __ll >> 64; \ w0 = __ll; \ } while (0) #endif #if !defined (umul_ppmm) #define umul_ppmm(ph, pl, m0, m1) \ do { \ UDItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (__m0), "r" (__m1)); \ (pl) = __m0 * __m1; \ } while (0) #endif #define UMUL_TIME 15 #define smul_ppmm(ph, pl, m0, m1) \ do { \ DItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (__m0), "r" (__m1)); \ (pl) = __m0 * __m1; \ } while (0) #define SMUL_TIME 14 /* ??? */ #define UDIV_TIME 120 /* ??? */ #endif /* 64-bit PowerPC. */ #if defined (__pyr__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addw %5,%1\n\taddwc %3,%0" \ : "=r" (sh), "=&r" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subw %5,%1\n\tsubwb %3,%0" \ : "=r" (sh), "=&r" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "1" ((USItype)(al)), "g" ((USItype)(bl))) /* This insn works on Pyramids with AP, XP, or MI CPUs, but not with SP. */ #define umul_ppmm(w1, w0, u, v) \ ({union {UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __x; \ __asm__ ("movw %1,%R0\n\tuemul %2,%0" \ : "=&r" (__x.__ll) \ : "g" ((USItype) (u)), "g" ((USItype)(v))); \ (w1) = __x.__i.__h; (w0) = __x.__i.__l;}) #endif /* __pyr__ */ #if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("a %1,%5\n\tae %0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" ((USItype)(ah)), "r" ((USItype)(bh)), \ "%1" ((USItype)(al)), "r" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("s %1,%5\n\tse %0,%3" \ : "=r" (sh), "=&r" (sl) \ : "0" ((USItype)(ah)), "r" ((USItype)(bh)), \ "1" ((USItype)(al)), "r" ((USItype)(bl))) #define smul_ppmm(ph, pl, m0, m1) \ __asm__ ( \ "s r2,r2\n" \ " mts r10,%2\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " m r2,%3\n" \ " cas %0,r2,r0\n" \ " mfs r10,%1" \ : "=r" (ph), "=r" (pl) \ : "%r" ((USItype)(m0)), "r" ((USItype)(m1)) \ : "r2") #define UMUL_TIME 20 #define UDIV_TIME 200 #define count_leading_zeros(count, x) \ do { \ if ((x) >= 0x10000) \ __asm__ ("clz %0,%1" \ : "=r" (count) : "r" ((USItype)(x) >> 16)); \ else \ { \ __asm__ ("clz %0,%1" \ : "=r" (count) : "r" ((USItype)(x))); \ (count) += 16; \ } \ } while (0) #endif /* RT/ROMP */ #if (defined (__SH2__) || defined (__SH3__) || defined (__SH4__)) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ __asm__ ("dmulu.l %2,%3\n\tsts macl,%1\n\tsts mach,%0" \ : "=r" (w1), "=r" (w0) : "r" (u), "r" (v) : "macl", "mach") #define UMUL_TIME 5 #endif #if defined (__sparc__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rJ" (ah), "rI" (bh),"%rJ" (al), "rI" (bl) \ __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rJ" (ah), "rI" (bh), "rJ" (al), "rI" (bl) \ __CLOBBER_CC) /* FIXME: When gcc -mcpu=v9 is used on solaris, gcc/config/sol2-sld-64.h doesn't define anything to indicate that to us, it only sets __sparcv8. */ #if defined (__sparc_v9__) || defined (__sparcv9) /* Perhaps we should use floating-point operations here? */ #if 0 /* Triggers a bug making mpz/tests/t-gcd.c fail. Perhaps we simply need explicitly zero-extend the inputs? */ #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mulx %2,%3,%%g1; srl %%g1,0,%1; srlx %%g1,32,%0" : \ "=r" (w1), "=r" (w0) : "r" (u), "r" (v) : "g1") #else /* Use v8 umul until above bug is fixed. */ #define umul_ppmm(w1, w0, u, v) \ __asm__ ("umul %2,%3,%1;rd %%y,%0" : "=r" (w1), "=r" (w0) : "r" (u), "r" (v)) #endif /* Use a plain v8 divide for v9. */ #define udiv_qrnnd(q, r, n1, n0, d) \ do { \ USItype __q; \ __asm__ ("mov %1,%%y;nop;nop;nop;udiv %2,%3,%0" \ : "=r" (__q) : "r" (n1), "r" (n0), "r" (d)); \ (r) = (n0) - __q * (d); \ (q) = __q; \ } while (0) #else #if defined (__sparc_v8__) /* gcc normal */ \ || defined (__sparcv8) /* gcc solaris */ \ || HAVE_HOST_CPU_supersparc /* Don't match immediate range because, 1) it is not often useful, 2) the 'I' flag thinks of the range as a 13 bit signed interval, while we want to match a 13 bit interval, sign extended to 32 bits, but INTERPRETED AS UNSIGNED. */ #define umul_ppmm(w1, w0, u, v) \ __asm__ ("umul %2,%3,%1;rd %%y,%0" : "=r" (w1), "=r" (w0) : "r" (u), "r" (v)) #define UMUL_TIME 5 #if HAVE_HOST_CPU_supersparc #define UDIV_TIME 60 /* SuperSPARC timing */ #else /* Don't use this on SuperSPARC because its udiv only handles 53 bit dividends and will trap to the kernel for the rest. */ #define udiv_qrnnd(q, r, n1, n0, d) \ do { \ USItype __q; \ __asm__ ("mov %1,%%y;nop;nop;nop;udiv %2,%3,%0" \ : "=r" (__q) : "r" (n1), "r" (n0), "r" (d)); \ (r) = (n0) - __q * (d); \ (q) = __q; \ } while (0) #define UDIV_TIME 25 #endif /* HAVE_HOST_CPU_supersparc */ #else /* ! __sparc_v8__ */ #if defined (__sparclite__) /* This has hardware multiply but not divide. It also has two additional instructions scan (ffs from high bit) and divscc. */ #define umul_ppmm(w1, w0, u, v) \ __asm__ ("umul %2,%3,%1;rd %%y,%0" : "=r" (w1), "=r" (w0) : "r" (u), "r" (v)) #define UMUL_TIME 5 #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("! Inlined udiv_qrnnd\n" \ " wr %%g0,%2,%%y ! Not a delayed write for sparclite\n" \ " tst %%g0\n" \ " divscc %3,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%%g1\n" \ " divscc %%g1,%4,%0\n" \ " rd %%y,%1\n" \ " bl,a 1f\n" \ " add %1,%4,%1\n" \ "1: ! End of inline udiv_qrnnd" \ : "=r" (q), "=r" (r) : "r" (n1), "r" (n0), "rI" (d) \ : "%g1" __AND_CLOBBER_CC) #define UDIV_TIME 37 #define count_leading_zeros(count, x) \ __asm__ ("scan %1,1,%0" : "=r" (count) : "r" (x)) /* Early sparclites return 63 for an argument of 0, but they warn that future implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0 undefined. */ #endif /* __sparclite__ */ #endif /* __sparc_v8__ */ #endif /* __sparc_v9__ */ /* Default to sparc v7 versions of umul_ppmm and udiv_qrnnd. */ #ifndef umul_ppmm #define umul_ppmm(w1, w0, u, v) \ __asm__ ("! Inlined umul_ppmm\n" \ " wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr\n" \ " sra %3,31,%%g2 ! Don't move this insn\n" \ " and %2,%%g2,%%g2 ! Don't move this insn\n" \ " andcc %%g0,0,%%g1 ! Don't move this insn\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,%3,%%g1\n" \ " mulscc %%g1,0,%%g1\n" \ " add %%g1,%%g2,%0\n" \ " rd %%y,%1" \ : "=r" (w1), "=r" (w0) : "%rI" (u), "r" (v) \ : "%g1", "%g2" __AND_CLOBBER_CC) #define UMUL_TIME 39 /* 39 instructions */ #endif #ifndef udiv_qrnnd #ifndef LONGLONG_STANDALONE #define udiv_qrnnd(q, r, n1, n0, d) \ do { UWtype __r; \ (q) = __MPN(udiv_qrnnd) (&__r, (n1), (n0), (d)); \ (r) = __r; \ } while (0) extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype); #ifndef UDIV_TIME #define UDIV_TIME 140 #endif #endif /* LONGLONG_STANDALONE */ #endif /* udiv_qrnnd */ #endif /* __sparc__ */ #if defined (__sparc__) && W_TYPE_SIZE == 64 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ( \ "addcc %r4,%5,%1\n" \ " addccc %r6,%7,%%g0\n" \ " addc %r2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rJ" ((UDItype)(ah)), "rI" ((UDItype)(bh)), \ "%rJ" ((UDItype)(al)), "rI" ((UDItype)(bl)), \ "%rJ" ((UDItype)(al) >> 32), "rI" ((UDItype)(bl) >> 32) \ __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ( \ "subcc %r4,%5,%1\n" \ " subccc %r6,%7,%%g0\n" \ " subc %r2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ : "rJ" ((UDItype)(ah)), "rI" ((UDItype)(bh)), \ "rJ" ((UDItype)(al)), "rI" ((UDItype)(bl)), \ "rJ" ((UDItype)(al) >> 32), "rI" ((UDItype)(bl) >> 32) \ __CLOBBER_CC) #if __VIS__ >= 0x300 #undef add_ssaaaa #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ( \ "addcc %r4, %5, %1\n" \ " addxc %r2, %r3, %0" \ : "=r" (sh), "=&r" (sl) \ : "rJ" ((UDItype)(ah)), "rJ" ((UDItype)(bh)), \ "%rJ" ((UDItype)(al)), "rI" ((UDItype)(bl)) __CLOBBER_CC) #define umul_ppmm(ph, pl, m0, m1) \ do { \ UDItype __m0 = (m0), __m1 = (m1); \ (pl) = __m0 * __m1; \ __asm__ ("umulxhi\t%2, %1, %0" \ : "=r" (ph) \ : "%r" (__m0), "r" (__m1)); \ } while (0) #define count_leading_zeros(count, x) \ __asm__ ("lzd\t%1,%0" : "=r" (count) : "r" (x)) /* Needed by count_leading_zeros_32 in sparc64.h. */ #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB #endif #endif #if (defined (__vax) || defined (__vax__)) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl2 %5,%1\n\tadwc %3,%0" \ : "=g" (sh), "=&g" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \ : "=g" (sh), "=&g" (sl) \ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "1" ((USItype)(al)), "g" ((USItype)(bl))) #define smul_ppmm(xh, xl, m0, m1) \ do { \ union {UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __x; \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("emul %1,%2,$0,%0" \ : "=g" (__x.__ll) : "g" (__m0), "g" (__m1)); \ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \ } while (0) #define sdiv_qrnnd(q, r, n1, n0, d) \ do { \ union {DItype __ll; \ struct {SItype __l, __h;} __i; \ } __x; \ __x.__i.__h = n1; __x.__i.__l = n0; \ __asm__ ("ediv %3,%2,%0,%1" \ : "=g" (q), "=g" (r) : "g" (__x.__ll), "g" (d)); \ } while (0) #if 0 /* FIXME: This instruction appears to be unimplemented on some systems (vax 8800 maybe). */ #define count_trailing_zeros(count,x) \ do { \ __asm__ ("ffs 0, 31, %1, %0" \ : "=g" (count) \ : "g" ((USItype) (x))); \ } while (0) #endif #endif /* vax */ #if defined (__z8000__) && W_TYPE_SIZE == 16 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \ : "=r" (sh), "=&r" (sl) \ : "0" ((unsigned int)(ah)), "r" ((unsigned int)(bh)), \ "%1" ((unsigned int)(al)), "rQR" ((unsigned int)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \ : "=r" (sh), "=&r" (sl) \ : "0" ((unsigned int)(ah)), "r" ((unsigned int)(bh)), \ "1" ((unsigned int)(al)), "rQR" ((unsigned int)(bl))) #define umul_ppmm(xh, xl, m0, m1) \ do { \ union {long int __ll; \ struct {unsigned int __h, __l;} __i; \ } __x; \ unsigned int __m0 = (m0), __m1 = (m1); \ __asm__ ("mult %S0,%H3" \ : "=r" (__x.__i.__h), "=r" (__x.__i.__l) \ : "%1" (m0), "rQR" (m1)); \ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \ (xh) += ((((signed int) __m0 >> 15) & __m1) \ + (((signed int) __m1 >> 15) & __m0)); \ } while (0) #endif /* __z8000__ */ #endif /* __GNUC__ */ #endif /* NO_ASM */ /* FIXME: "sidi" here is highly doubtful, should sometimes be "diti". */ #if !defined (umul_ppmm) && defined (__umulsidi3) #define umul_ppmm(ph, pl, m0, m1) \ { \ UDWtype __ll = __umulsidi3 (m0, m1); \ ph = (UWtype) (__ll >> W_TYPE_SIZE); \ pl = (UWtype) __ll; \ } #endif #if !defined (__umulsidi3) #define __umulsidi3(u, v) \ ({UWtype __hi, __lo; \ umul_ppmm (__hi, __lo, u, v); \ ((UDWtype) __hi << W_TYPE_SIZE) | __lo; }) #endif #if defined (__cplusplus) #define __longlong_h_C "C" #else #define __longlong_h_C #endif /* Use mpn_umul_ppmm or mpn_udiv_qrnnd functions, if they exist. The "_r" forms have "reversed" arguments, meaning the pointer is last, which sometimes allows better parameter passing, in particular on 64-bit hppa. */ #define mpn_umul_ppmm __MPN(umul_ppmm) extern __longlong_h_C UWtype mpn_umul_ppmm (UWtype *, UWtype, UWtype); #if ! defined (umul_ppmm) && HAVE_NATIVE_mpn_umul_ppmm \ && ! defined (LONGLONG_STANDALONE) #define umul_ppmm(wh, wl, u, v) \ do { \ UWtype __umul_ppmm__p0; \ (wh) = mpn_umul_ppmm (&__umul_ppmm__p0, (UWtype) (u), (UWtype) (v));\ (wl) = __umul_ppmm__p0; \ } while (0) #endif #define mpn_umul_ppmm_r __MPN(umul_ppmm_r) extern __longlong_h_C UWtype mpn_umul_ppmm_r (UWtype, UWtype, UWtype *); #if ! defined (umul_ppmm) && HAVE_NATIVE_mpn_umul_ppmm_r \ && ! defined (LONGLONG_STANDALONE) #define umul_ppmm(wh, wl, u, v) \ do { \ UWtype __umul_p0; \ (wh) = mpn_umul_ppmm_r ((UWtype) (u), (UWtype) (v), &__umul_p0); \ (wl) = __umul_p0; \ } while (0) #endif #define mpn_udiv_qrnnd __MPN(udiv_qrnnd) extern __longlong_h_C UWtype mpn_udiv_qrnnd (UWtype *, UWtype, UWtype, UWtype); #if ! defined (udiv_qrnnd) && HAVE_NATIVE_mpn_udiv_qrnnd \ && ! defined (LONGLONG_STANDALONE) #define udiv_qrnnd(q, r, n1, n0, d) \ do { \ UWtype __udiv_qrnnd_r; \ (q) = mpn_udiv_qrnnd (&__udiv_qrnnd_r, \ (UWtype) (n1), (UWtype) (n0), (UWtype) d); \ (r) = __udiv_qrnnd_r; \ } while (0) #endif #define mpn_udiv_qrnnd_r __MPN(udiv_qrnnd_r) extern __longlong_h_C UWtype mpn_udiv_qrnnd_r (UWtype, UWtype, UWtype, UWtype *); #if ! defined (udiv_qrnnd) && HAVE_NATIVE_mpn_udiv_qrnnd_r \ && ! defined (LONGLONG_STANDALONE) #define udiv_qrnnd(q, r, n1, n0, d) \ do { \ UWtype __udiv_qrnnd_r; \ (q) = mpn_udiv_qrnnd_r ((UWtype) (n1), (UWtype) (n0), (UWtype) d, \ &__udiv_qrnnd_r); \ (r) = __udiv_qrnnd_r; \ } while (0) #endif /* If this machine has no inline assembler, use C macros. */ #if !defined (add_ssaaaa) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ UWtype __x; \ __x = (al) + (bl); \ (sh) = (ah) + (bh) + (__x < (al)); \ (sl) = __x; \ } while (0) #endif #if !defined (sub_ddmmss) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ UWtype __x; \ __x = (al) - (bl); \ (sh) = (ah) - (bh) - ((al) < (bl)); \ (sl) = __x; \ } while (0) #endif /* If we lack umul_ppmm but have smul_ppmm, define umul_ppmm in terms of smul_ppmm. */ #if !defined (umul_ppmm) && defined (smul_ppmm) #define umul_ppmm(w1, w0, u, v) \ do { \ UWtype __w1; \ UWtype __xm0 = (u), __xm1 = (v); \ smul_ppmm (__w1, w0, __xm0, __xm1); \ (w1) = __w1 + (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \ + (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \ } while (0) #endif /* If we still don't have umul_ppmm, define it using plain C. For reference, when this code is used for squaring (ie. u and v identical expressions), gcc recognises __x1 and __x2 are the same and generates 3 multiplies, not 4. The subsequent additions could be optimized a bit, but the only place GMP currently uses such a square is mpn_sqr_basecase, and chips obliged to use this generic C umul will have plenty of worse performance problems than a couple of extra instructions on the diagonal of sqr_basecase. */ #if !defined (umul_ppmm) #define umul_ppmm(w1, w0, u, v) \ do { \ UWtype __x0, __x1, __x2, __x3; \ UHWtype __ul, __vl, __uh, __vh; \ UWtype __u = (u), __v = (v); \ \ __ul = __ll_lowpart (__u); \ __uh = __ll_highpart (__u); \ __vl = __ll_lowpart (__v); \ __vh = __ll_highpart (__v); \ \ __x0 = (UWtype) __ul * __vl; \ __x1 = (UWtype) __ul * __vh; \ __x2 = (UWtype) __uh * __vl; \ __x3 = (UWtype) __uh * __vh; \ \ __x1 += __ll_highpart (__x0);/* this can't give carry */ \ __x1 += __x2; /* but this indeed can */ \ if (__x1 < __x2) /* did we get it? */ \ __x3 += __ll_B; /* yes, add it in the proper pos. */ \ \ (w1) = __x3 + __ll_highpart (__x1); \ (w0) = (__x1 << W_TYPE_SIZE/2) + __ll_lowpart (__x0); \ } while (0) #endif /* If we don't have smul_ppmm, define it using umul_ppmm (which surely will exist in one form or another. */ #if !defined (smul_ppmm) #define smul_ppmm(w1, w0, u, v) \ do { \ UWtype __w1; \ UWtype __xm0 = (u), __xm1 = (v); \ umul_ppmm (__w1, w0, __xm0, __xm1); \ (w1) = __w1 - (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \ - (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \ } while (0) #endif /* Define this unconditionally, so it can be used for debugging. */ #define __udiv_qrnnd_c(q, r, n1, n0, d) \ do { \ UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \ \ ASSERT ((d) != 0); \ ASSERT ((n1) < (d)); \ \ __d1 = __ll_highpart (d); \ __d0 = __ll_lowpart (d); \ \ __q1 = (n1) / __d1; \ __r1 = (n1) - __q1 * __d1; \ __m = __q1 * __d0; \ __r1 = __r1 * __ll_B | __ll_highpart (n0); \ if (__r1 < __m) \ { \ __q1--, __r1 += (d); \ if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\ if (__r1 < __m) \ __q1--, __r1 += (d); \ } \ __r1 -= __m; \ \ __q0 = __r1 / __d1; \ __r0 = __r1 - __q0 * __d1; \ __m = __q0 * __d0; \ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \ if (__r0 < __m) \ { \ __q0--, __r0 += (d); \ if (__r0 >= (d)) \ if (__r0 < __m) \ __q0--, __r0 += (d); \ } \ __r0 -= __m; \ \ (q) = __q1 * __ll_B | __q0; \ (r) = __r0; \ } while (0) /* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through __udiv_w_sdiv (defined in libgcc or elsewhere). */ #if !defined (udiv_qrnnd) && defined (sdiv_qrnnd) #define udiv_qrnnd(q, r, nh, nl, d) \ do { \ UWtype __r; \ (q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d); \ (r) = __r; \ } while (0) __GMP_DECLSPEC UWtype __MPN(udiv_w_sdiv) (UWtype *, UWtype, UWtype, UWtype); #endif /* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */ #if !defined (udiv_qrnnd) #define UDIV_NEEDS_NORMALIZATION 1 #define udiv_qrnnd __udiv_qrnnd_c #endif #if !defined (count_leading_zeros) #define count_leading_zeros(count, x) \ do { \ UWtype __xr = (x); \ UWtype __a; \ \ if (W_TYPE_SIZE == 32) \ { \ __a = __xr < ((UWtype) 1 << 2*__BITS4) \ ? (__xr < ((UWtype) 1 << __BITS4) ? 1 : __BITS4 + 1) \ : (__xr < ((UWtype) 1 << 3*__BITS4) ? 2*__BITS4 + 1 \ : 3*__BITS4 + 1); \ } \ else \ { \ for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \ if (((__xr >> __a) & 0xff) != 0) \ break; \ ++__a; \ } \ \ (count) = W_TYPE_SIZE + 1 - __a - __clz_tab[__xr >> __a]; \ } while (0) /* This version gives a well-defined value for zero. */ #define COUNT_LEADING_ZEROS_0 (W_TYPE_SIZE - 1) #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB #define COUNT_LEADING_ZEROS_SLOW #endif /* clz_tab needed by mpn/x86/pentium/mod_1.asm in a fat binary */ #if HAVE_HOST_CPU_FAMILY_x86 && WANT_FAT_BINARY #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB #endif #ifdef COUNT_LEADING_ZEROS_NEED_CLZ_TAB extern const unsigned char __GMP_DECLSPEC __clz_tab[129]; #endif #if !defined (count_trailing_zeros) #if !defined (COUNT_LEADING_ZEROS_SLOW) /* Define count_trailing_zeros using an asm count_leading_zeros. */ #define count_trailing_zeros(count, x) \ do { \ UWtype __ctz_x = (x); \ UWtype __ctz_c; \ ASSERT (__ctz_x != 0); \ count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \ (count) = W_TYPE_SIZE - 1 - __ctz_c; \ } while (0) #else /* Define count_trailing_zeros in plain C, assuming small counts are common. We use clz_tab without ado, since the C count_leading_zeros above will have pulled it in. */ #define count_trailing_zeros(count, x) \ do { \ UWtype __ctz_x = (x); \ int __ctz_c; \ \ if (LIKELY ((__ctz_x & 0xff) != 0)) \ (count) = __clz_tab[__ctz_x & -__ctz_x] - 2; \ else \ { \ for (__ctz_c = 8 - 2; __ctz_c < W_TYPE_SIZE - 2; __ctz_c += 8) \ { \ __ctz_x >>= 8; \ if (LIKELY ((__ctz_x & 0xff) != 0)) \ break; \ } \ \ (count) = __ctz_c + __clz_tab[__ctz_x & -__ctz_x]; \ } \ } while (0) #endif #endif #ifndef UDIV_NEEDS_NORMALIZATION #define UDIV_NEEDS_NORMALIZATION 0 #endif /* Whether udiv_qrnnd is actually implemented with udiv_qrnnd_preinv, and that hence the latter should always be used. */ #ifndef UDIV_PREINV_ALWAYS #define UDIV_PREINV_ALWAYS 0 #endif /* Give defaults for UMUL_TIME and UDIV_TIME. */ #ifndef UMUL_TIME #define UMUL_TIME 1 #endif #ifndef UDIV_TIME #define UDIV_TIME UMUL_TIME #endif gmp-6.1.0/install-sh000755 001756 001756 00000034523 12572636756 015501 0ustar00bodratobodrato000000 000000 #!/bin/sh # install - install a program, script, or datafile scriptversion=2013-12-25.23; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gmp-6.1.0/test-driver000755 001756 001756 00000011040 12572636756 015660 0ustar00bodratobodrato000000 000000 #! /bin/sh # test-driver - basic testsuite driver script. scriptversion=2013-07-13.22; # UTC # Copyright (C) 2011-2014 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # Make unconditional expansion of undefined variables an error. This # helps a lot in preventing typo-related bugs. set -u usage_error () { echo "$0: $*" >&2 print_usage >&2 exit 2 } print_usage () { cat <$log_file 2>&1 estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then tweaked_estatus=1 else tweaked_estatus=$estatus fi case $tweaked_estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; *:*) col=$red res=FAIL recheck=yes gcopy=yes;; esac # Report the test outcome and exit status in the logs, so that one can # know whether the test passed or failed simply by looking at the '.log' # file, without the need of also peaking into the corresponding '.trs' # file (automake bug#11814). echo "$res $test_name (exit status: $estatus)" >>$log_file # Report outcome to console. echo "${col}${res}${std}: $test_name" # Register the test result, and other relevant metadata. echo ":test-result: $res" > $trs_file echo ":global-test-result: $res" >> $trs_file echo ":recheck: $recheck" >> $trs_file echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gmp-6.1.0/primesieve.c000664 001756 001756 00000017625 12615426624 016004 0ustar00bodratobodrato000000 000000 /* primesieve (BIT_ARRAY, N) -- Fills the BIT_ARRAY with a mask for primes up to N. Contributed to the GNU project by Marco Bodrato. THE FUNCTION IN THIS FILE IS INTERNAL WITH A MUTABLE INTERFACE. IT IS ONLY SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. Copyright 2010-2012 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" /**************************************************************/ /* Section macros: common macros, for mswing/fac/bin (&sieve) */ /**************************************************************/ #define LOOP_ON_SIEVE_CONTINUE(prime,end,sieve) \ __max_i = (end); \ \ do { \ ++__i; \ if (((sieve)[__index] & __mask) == 0) \ { \ (prime) = id_to_n(__i) #define LOOP_ON_SIEVE_BEGIN(prime,start,end,off,sieve) \ do { \ mp_limb_t __mask, __index, __max_i, __i; \ \ __i = (start)-(off); \ __index = __i / GMP_LIMB_BITS; \ __mask = CNST_LIMB(1) << (__i % GMP_LIMB_BITS); \ __i += (off); \ \ LOOP_ON_SIEVE_CONTINUE(prime,end,sieve) #define LOOP_ON_SIEVE_STOP \ } \ __mask = __mask << 1 | __mask >> (GMP_LIMB_BITS-1); \ __index += __mask & 1; \ } while (__i <= __max_i) \ #define LOOP_ON_SIEVE_END \ LOOP_ON_SIEVE_STOP; \ } while (0) /*********************************************************/ /* Section sieve: sieving functions and tools for primes */ /*********************************************************/ #if 0 static mp_limb_t bit_to_n (mp_limb_t bit) { return (bit*3+4)|1; } #endif /* id_to_n (x) = bit_to_n (x-1) = (id*3+1)|1*/ static mp_limb_t id_to_n (mp_limb_t id) { return id*3+1+(id&1); } /* n_to_bit (n) = ((n-1)&(-CNST_LIMB(2)))/3U-1 */ static mp_limb_t n_to_bit (mp_limb_t n) { return ((n-5)|1)/3U; } #if 0 static mp_size_t primesieve_size (mp_limb_t n) { return n_to_bit(n) / GMP_LIMB_BITS + 1; } #endif #if GMP_LIMB_BITS > 61 #define SIEVE_SEED CNST_LIMB(0x3294C9E069128480) #define SEED_LIMIT 202 #else #if GMP_LIMB_BITS > 30 #define SIEVE_SEED CNST_LIMB(0x69128480) #define SEED_LIMIT 114 #else #if GMP_LIMB_BITS > 15 #define SIEVE_SEED CNST_LIMB(0x8480) #define SEED_LIMIT 54 #else #if GMP_LIMB_BITS > 7 #define SIEVE_SEED CNST_LIMB(0x80) #define SEED_LIMIT 34 #else #define SIEVE_SEED CNST_LIMB(0x0) #define SEED_LIMIT 24 #endif /* 7 */ #endif /* 15 */ #endif /* 30 */ #endif /* 61 */ static void first_block_primesieve (mp_ptr bit_array, mp_limb_t n) { mp_size_t bits, limbs; ASSERT (n > 4); bits = n_to_bit(n); limbs = bits / GMP_LIMB_BITS + 1; /* FIXME: We can skip 5 too, filling with a 5-part pattern. */ MPN_ZERO (bit_array, limbs); bit_array[0] = SIEVE_SEED; if ((bits + 1) % GMP_LIMB_BITS != 0) bit_array[limbs-1] |= MP_LIMB_T_MAX << ((bits + 1) % GMP_LIMB_BITS); if (n > SEED_LIMIT) { mp_limb_t mask, index, i; ASSERT (n > 49); mask = 1; index = 0; i = 1; do { if ((bit_array[index] & mask) == 0) { mp_size_t step, lindex; mp_limb_t lmask; unsigned maskrot; step = id_to_n(i); /* lindex = n_to_bit(id_to_n(i)*id_to_n(i)); */ lindex = i*(step+1)-1+(-(i&1)&(i+1)); /* lindex = i*(step+1+(i&1))-1+(i&1); */ if (lindex > bits) break; step <<= 1; maskrot = step % GMP_LIMB_BITS; lmask = CNST_LIMB(1) << (lindex % GMP_LIMB_BITS); do { bit_array[lindex / GMP_LIMB_BITS] |= lmask; lmask = lmask << maskrot | lmask >> (GMP_LIMB_BITS - maskrot); lindex += step; } while (lindex <= bits); /* lindex = n_to_bit(id_to_n(i)*bit_to_n(i)); */ lindex = i*(i*3+6)+(i&1); lmask = CNST_LIMB(1) << (lindex % GMP_LIMB_BITS); for ( ; lindex <= bits; lindex += step) { bit_array[lindex / GMP_LIMB_BITS] |= lmask; lmask = lmask << maskrot | lmask >> (GMP_LIMB_BITS - maskrot); }; } mask = mask << 1 | mask >> (GMP_LIMB_BITS-1); index += mask & 1; i++; } while (1); } } static void block_resieve (mp_ptr bit_array, mp_size_t limbs, mp_limb_t offset, mp_srcptr sieve, mp_limb_t sieve_bits) { mp_size_t bits, step; ASSERT (limbs > 0); bits = limbs * GMP_LIMB_BITS - 1; /* FIXME: We can skip 5 too, filling with a 5-part pattern. */ MPN_ZERO (bit_array, limbs); LOOP_ON_SIEVE_BEGIN(step,0,sieve_bits,0,sieve); { mp_size_t lindex; mp_limb_t lmask; unsigned maskrot; /* lindex = n_to_bit(id_to_n(i)*id_to_n(i)); */ lindex = __i*(step+1)-1+(-(__i&1)&(__i+1)); /* lindex = __i*(step+1+(__i&1))-1+(__i&1); */ if (lindex > bits + offset) break; step <<= 1; maskrot = step % GMP_LIMB_BITS; if (lindex < offset) lindex += step * ((offset - lindex - 1) / step + 1); lindex -= offset; lmask = CNST_LIMB(1) << (lindex % GMP_LIMB_BITS); for ( ; lindex <= bits; lindex += step) { bit_array[lindex / GMP_LIMB_BITS] |= lmask; lmask = lmask << maskrot | lmask >> (GMP_LIMB_BITS - maskrot); }; /* lindex = n_to_bit(id_to_n(i)*bit_to_n(i)); */ lindex = __i*(__i*3+6)+(__i&1); if (lindex > bits + offset) continue; if (lindex < offset) lindex += step * ((offset - lindex - 1) / step + 1); lindex -= offset; lmask = CNST_LIMB(1) << (lindex % GMP_LIMB_BITS); for ( ; lindex <= bits; lindex += step) { bit_array[lindex / GMP_LIMB_BITS] |= lmask; lmask = lmask << maskrot | lmask >> (GMP_LIMB_BITS - maskrot); }; } LOOP_ON_SIEVE_END; } #define BLOCK_SIZE 2048 /* Fills bit_array with the characteristic function of composite numbers up to the parameter n. I.e. a bit set to "1" represent a composite, a "0" represent a prime. The primesieve_size(n) limbs pointed to by bit_array are overwritten. The returned value counts prime integers in the interval [4, n]. Note that n > 4. Even numbers and multiples of 3 are excluded "a priori", only numbers equivalent to +/- 1 mod 6 have their bit in the array. Once sieved, if the bit b is ZERO it represent a prime, the represented prime is bit_to_n(b), if the LSbit is bit 0, or id_to_n(b), if you call "1" the first bit. */ mp_limb_t gmp_primesieve (mp_ptr bit_array, mp_limb_t n) { mp_size_t size; mp_limb_t bits; ASSERT (n > 4); bits = n_to_bit(n); size = bits / GMP_LIMB_BITS + 1; if (size > BLOCK_SIZE * 2) { mp_size_t off; off = BLOCK_SIZE + (size % BLOCK_SIZE); first_block_primesieve (bit_array, id_to_n (off * GMP_LIMB_BITS)); for ( ; off < size; off += BLOCK_SIZE) block_resieve (bit_array + off, BLOCK_SIZE, off * GMP_LIMB_BITS, bit_array, off * GMP_LIMB_BITS - 1); } else { first_block_primesieve (bit_array, n); } if ((bits + 1) % GMP_LIMB_BITS != 0) bit_array[size-1] |= MP_LIMB_T_MAX << ((bits + 1) % GMP_LIMB_BITS); return size * GMP_LIMB_BITS - mpn_popcount (bit_array, size); } #undef BLOCK_SIZE #undef SEED_LIMIT #undef SIEVE_SEED #undef LOOP_ON_SIEVE_END #undef LOOP_ON_SIEVE_STOP #undef LOOP_ON_SIEVE_BEGIN #undef LOOP_ON_SIEVE_CONTINUE gmp-6.1.0/README000664 001756 001756 00000007723 12615426624 014346 0ustar00bodratobodrato000000 000000 Copyright 1991, 1996, 1999, 2000, 2007 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. THE GNU MP LIBRARY GNU MP is a library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. It has a rich set of functions, and the functions have a regular interface. GNU MP is designed to be as fast as possible, both for small operands and huge operands. The speed is achieved by using fullwords as the basic arithmetic type, by using fast algorithms, with carefully optimized assembly code for the most common inner loops for lots of CPUs, and by a general emphasis on speed (instead of simplicity or elegance). GNU MP is believed to be faster than any other similar library. Its advantage increases with operand sizes for certain operations, since GNU MP in many cases has asymptotically faster algorithms. GNU MP is free software and may be freely copied on the terms contained in the files COPYING* (see the manual for information on which license(s) applies to which components of GNU MP). OVERVIEW OF GNU MP There are four classes of functions in GNU MP. 1. Signed integer arithmetic functions (mpz). These functions are intended to be easy to use, with their regular interface. The associated type is `mpz_t'. 2. Rational arithmetic functions (mpq). For now, just a small set of functions necessary for basic rational arithmetics. The associated type is `mpq_t'. 3. Floating-point arithmetic functions (mpf). If the C type `double' doesn't give enough precision for your application, declare your variables as `mpf_t' instead, set the precision to any number desired, and call the functions in the mpf class for the arithmetic operations. 4. Positive-integer, hard-to-use, very low overhead functions are in the mpn class. No memory management is performed. The caller must ensure enough space is available for the results. The set of functions is not regular, nor is the calling interface. These functions accept input arguments in the form of pairs consisting of a pointer to the least significant word, and an integral size telling how many limbs (= words) the pointer points to. Almost all calculations, in the entire package, are made by calling these low-level functions. For more information on how to use GNU MP, please refer to the documentation. It is composed from the file doc/gmp.texi, and can be displayed on the screen or printed. How to do that, as well how to build the library, is described in the INSTALL file in this directory. REPORTING BUGS If you find a bug in the library, please make sure to tell us about it! You should first check the GNU MP web pages at https://gmplib.org/, under "Status of the current release". There will be patches for all known serious bugs there. Report bugs to gmp-bugs@gmplib.org. What information is needed in a useful bug report is described in the manual. The same address can be used for suggesting modifications and enhancements. ---------------- Local variables: mode: text fill-column: 78 End: gmp-6.1.0/aclocal.m4000664 001756 001756 00001305117 12615426627 015330 0ustar00bodratobodrato000000 000000 # generated automatically by aclocal 1.15 -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . ]) # serial 58 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_PREPARE_CC_BASENAME # ----------------------- m4_defun([_LT_PREPARE_CC_BASENAME], [ # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in @S|@*""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } ])# _LT_PREPARE_CC_BASENAME # _LT_CC_BASENAME(CC) # ------------------- # It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, # but that macro is also expanded into generated libtool script, which # arranges for $SED and $ECHO to be set by different means. m4_defun([_LT_CC_BASENAME], [m4_require([_LT_PREPARE_CC_BASENAME])dnl AC_REQUIRE([_LT_DECL_SED])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl func_cc_basename $1 cc_basename=$func_cc_basename_result ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl m4_require([_LT_CMD_TRUNCATE])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from 'configure', and 'config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # 'config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain=$ac_aux_dir/ltmain.sh ])# _LT_PROG_LTMAIN # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the 'libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to 'config.status' so that its # declaration there will have the same value as in 'configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags='_LT_TAGS'dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into 'config.status', and then the shell code to quote escape them in # for loops in 'config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # '#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test 0 = "$lt_write_fail" && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ '$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test 0 != $[#] do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try '$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try '$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test yes = "$silent" && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 _LT_COPYING _LT_LIBTOOL_TAGS # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE _LT_PREPARE_MUNGE_PATH_LIST _LT_PREPARE_CC_BASENAME # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS=$save_LDFLAGS ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[[012]][[,.]]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test yes = "$lt_cv_ld_force_load"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" m4_if([$1], [CXX], [ if test yes != "$lt_cv_apple_cc_single_mod"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script that will find a shell with a builtin # printf (that we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case $ECHO in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], [Search for dependent libraries within DIR (or the compiler's sysroot if not specified).])], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([$with_sysroot]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and where our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test yes = "[$]$2"; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS ]) if test yes = "[$]$2"; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n "$lt_cv_sys_max_cmd_len"; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes = "$cross_compiling"; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen=shl_load], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen=dlopen], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) ]) ]) ]) ]) ]) ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links=nottested if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test no = "$hard_links"; then AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", [Define to the sub-directory where libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then # We can hardcode non-existent directories. if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_PREPARE_MUNGE_PATH_LIST # --------------------------- # Make sure func_munge_path_list() is defined correctly. m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], [[# func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x@S|@2 in x) ;; *:) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" ;; x:*) eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; *::*) eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" ;; *) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; esac } ]])# _LT_PREPARE_PATH_LIST # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown AC_ARG_VAR([LT_SYS_LIBRARY_PATH], [User-defined run-time library search path.]) case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a[(]lib.so.V[)]' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], [Detected run-time system search path for libraries]) _LT_DECL([], [configure_time_lt_sys_library_path], [2], [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program that can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$1"; then lt_cv_path_MAGIC_CMD=$ac_dir/"$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac]) MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program that can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test no = "$withval" || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], [if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi]) rm -f conftest.i conftest2.i conftest.out]) ])# _LT_PATH_DD # _LT_CMD_TRUNCATE # ---------------- # find command to truncate a binary pipe m4_defun([_LT_CMD_TRUNCATE], [m4_require([_LT_PATH_DD]) AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], [printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) _LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], [Command to truncate a binary pipe]) ])# _LT_CMD_TRUNCATE # _LT_CHECK_MAGIC_METHOD # ---------------------- # how to check for library dependencies # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_MAGIC_METHOD], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) AC_CACHE_CHECK([how to recognize dependent libraries], lt_cv_deplibs_check_method, [lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[[4-9]]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[[45]]*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi]) if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # _LT_DLL_DEF_P([FILE]) # --------------------- # True iff FILE is a Windows DLL '.def' file. # Keep in sync with func_dll_def_p in the libtool script AC_DEFUN([_LT_DLL_DEF_P], [dnl test DEF = "`$SED -n dnl -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl -e q dnl Only consider the first "real" line $1`" dnl ])# _LT_DLL_DEF_P # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM=-lm) ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test yes = "$GCC"; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], [Transform the output of nm into a list of symbols to manually relocate]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([nm_interface], [lt_cv_nm_interface], [1], [The name lister interface]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' if test ia64 != "$host_cpu"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64, which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test yes = "$GCC"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS=$save_LDFLAGS]) if test yes = "$lt_cv_irix_exported_symbol"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(ld_shlibs, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; osf3*) if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test yes = "$GCC"; then wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test yes,yes = "$GCC,$enable_shared"; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting $shlibpath_var if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC=$CC AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report what library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC=$lt_save_CC ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test no != "$CXX" && ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || (test g++ != "$CXX"))); then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test yes = "$GXX"; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test yes = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GXX"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag=$shared_flag' $wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. # The "-G" linker flag allows undefined symbols. _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ func_to_tool_file "$lt_outputfile"~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(GCC, $1)=$GXX _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test yes != "$_lt_caught_CXX_error" AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case @S|@2 in .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test x-L = "$p" || test x-R = "$p"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test no = "$pre_test_object_deps_done"; then case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)=$prev$p else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test no = "$pre_test_object_deps_done"; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)=$p else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)=$p else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test no = "$F77"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_F77"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$G77 _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_F77" AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test no = "$FC"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_FC"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_FC" AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code=$lt_simple_compile_test_code # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f "$lt_ac_sed" && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test 10 -lt "$lt_ac_count" && break lt_ac_count=`expr $lt_ac_count + 1` if test "$lt_ac_count" -gt "$lt_ac_max"; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine what file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS # Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 8 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option '$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl 'shared' nor 'disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], [_LT_WITH_AIX_SONAME([aix])]) ]) ])# _LT_SET_OPTIONS # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the 'shared' and # 'disable-shared' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the 'static' and # 'disable-static' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the 'fast-install' # and 'disable-fast-install' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_AIX_SONAME([DEFAULT]) # ---------------------------------- # implement the --with-aix-soname flag, and support the `aix-soname=aix' # and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT # is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. m4_define([_LT_WITH_AIX_SONAME], [m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[[5-9]]*,yes) AC_MSG_CHECKING([which variant of shared library versioning to provide]) AC_ARG_WITH([aix-soname], [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], [case $withval in aix|svr4|both) ;; *) AC_MSG_ERROR([Unknown argument to --with-aix-soname]) ;; esac lt_cv_with_aix_soname=$with_aix_soname], [AC_CACHE_VAL([lt_cv_with_aix_soname], [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) with_aix_soname=$lt_cv_with_aix_soname]) AC_MSG_RESULT([$with_aix_soname]) if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac _LT_DECL([], [shared_archive_member_spec], [0], [Shared archive member basename, for filename based shared library versioning on AIX])dnl ])# _LT_WITH_AIX_SONAME LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the 'pic-only' and 'no-pic' # LT_INIT options. # MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac], [pic_mode=m4_default([$1], [default])]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59, which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) # ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 4179 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.6]) m4_define([LT_PACKAGE_REVISION], [2.4.6]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.6' macro_revision='2.4.6' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software # Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) # Copyright (C) 2002-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.15' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.15], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.15])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Copyright (C) 1998-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_LEX # ----------- # Autoconf leaves LEX=: if lex or flex can't be found. Change that to a # "missing" invocation, for better error output. AC_DEFUN([AM_PROG_LEX], [AC_PREREQ([2.50])dnl AC_REQUIRE([AM_MISSING_HAS_RUN])dnl AC_REQUIRE([AC_PROG_LEX])dnl if test "$LEX" = :; then LEX=${am_missing_run}flex fi]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. # Default is to disable them, unless 'enable' is passed literally. # For symmetry, 'disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), [enable], [m4_define([am_maintainer_other], [disable])], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], am_maintainer_other[ make rules and dependencies not useful (and sometimes confusing) to the casual installer])], [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) gmp-6.1.0/gen-fib.c000664 001756 001756 00000007302 12615426624 015132 0ustar00bodratobodrato000000 000000 /* Generate Fibonacci table data. Copyright 2001, 2002, 2004, 2012, 2014, 2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include #include "bootstrap.c" mpz_t *f; int fnum, fib_limit, luc_limit; void generate (int numb_bits) { mpz_t limit, l; int falloc, i; mpz_init2 (limit, numb_bits + 1); mpz_setbit (limit, numb_bits); /* fib(2n) > 2^n, so use 2n as a limit for the table size */ falloc = 2 * numb_bits; f = (mpz_t*) xmalloc (falloc * sizeof (*f)); mpz_init_set_ui (f[0], 1L); /* F[-1] */ mpz_init_set_ui (f[1], 0L); /* F[0] */ mpz_init (l); for (i = 2; ; i++) { assert (i < falloc); /* F[i] = F[i-1] + F[i-2] */ mpz_init (f[i]); mpz_add (f[i], f[i-1], f[i-2]); if (mpz_cmp (f[i], limit) >= 0) break; fnum = i+1; fib_limit = i-1; /* L[i] = F[i]+2*F[i-1] */ mpz_add (l, f[i], f[i-1]); mpz_add (l, l, f[i-1]); if (mpz_cmp (l, limit) < 0) luc_limit = i-1; } mpz_clear (limit); } void header (int numb_bits) { printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n"); printf ("\n"); printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); printf ("Error, error, this data is for %d bits\n", numb_bits); printf ("#endif\n"); printf ("\n"); printf ("#define FIB_TABLE_LIMIT %d\n", fib_limit); printf ("#define FIB_TABLE_LUCNUM_LIMIT %d\n", luc_limit); } void table (int numb_bits) { int i; printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n"); printf ("\n"); printf ("#include \"gmp.h\"\n"); printf ("#include \"gmp-impl.h\"\n"); printf ("\n"); printf ("#if GMP_NUMB_BITS != %d\n", numb_bits); printf ("Error, error, this data is for %d bits\n", numb_bits); printf ("#endif\n"); printf ("\n"); printf ("const mp_limb_t\n"); printf ("__gmp_fib_table[FIB_TABLE_LIMIT+2] = {\n"); for (i = 0; i < fnum; i++) { printf (" CNST_LIMB (0x"); mpz_out_str (stdout, 16, f[i]); printf ("), /* %d */\n", i-1); } printf ("};\n"); } int main (int argc, char *argv[]) { int limb_bits, nail_bits, numb_bits; if (argc != 4) { fprintf (stderr, "Usage: gen-fib \n"); exit (1); } limb_bits = atoi (argv[2]); nail_bits = atoi (argv[3]); if (limb_bits <= 0 || nail_bits < 0 || nail_bits >= limb_bits) { fprintf (stderr, "Invalid limb/nail bits: %d %d\n", limb_bits, nail_bits); exit (1); } numb_bits = limb_bits - nail_bits; generate (numb_bits); if (strcmp (argv[1], "header") == 0) header (numb_bits); else if (strcmp (argv[1], "table") == 0) table (numb_bits); else { fprintf (stderr, "Invalid header/table choice: %s\n", argv[1]); exit (1); } return 0; } gmp-6.1.0/version.c000664 001756 001756 00000002170 12615426625 015307 0ustar00bodratobodrato000000 000000 /* gmp_version -- version number compiled into the library. Copyright 1996, 1999-2001 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" const char * const gmp_version = VERSION; gmp-6.1.0/mpn/000755 001756 001756 00000000000 12615426652 014246 5ustar00bodratobodrato000000 000000 gmp-6.1.0/gmp-impl.h000664 001756 001756 00000542214 12615426624 015360 0ustar00bodratobodrato000000 000000 /* Include file for internal GNU MP types and definitions. THE CONTENTS OF THIS FILE ARE FOR INTERNAL USE AND ARE ALMOST CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES IN FUTURE GNU MP RELEASES. Copyright 1991, 1993-1997, 1999-2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ /* __GMP_DECLSPEC must be given on any global data that will be accessed from outside libgmp, meaning from the test or development programs, or from libgmpxx. Failing to do this will result in an incorrect address being used for the accesses. On functions __GMP_DECLSPEC makes calls from outside libgmp more efficient, but they'll still work fine without it. */ #ifndef __GMP_IMPL_H__ #define __GMP_IMPL_H__ #if defined _CRAY #include /* for _popcnt */ #endif /* For INT_MAX, etc. We used to avoid it because of a bug (on solaris, gcc 2.95 under -mcpu=ultrasparc in ABI=32 ends up getting wrong values (the ABI=64 values)), but it should be safe now. On Cray vector systems, however, we need the system limits.h since sizes of signed and unsigned types can differ there, depending on compiler options (eg. -hnofastmd), making our SHRT_MAX etc expressions fail. For reference, int can be 46 or 64 bits, whereas uint is always 64 bits; and short can be 24, 32, 46 or 64 bits, and different for ushort. */ #include /* For fat.h and other fat binary stuff. No need for __GMP_ATTRIBUTE_PURE or __GMP_NOTHROW, since functions declared this way are only used to set function pointers in __gmpn_cpuvec, they're not called directly. */ #define DECL_add_n(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t) #define DECL_addlsh1_n(name) \ DECL_add_n (name) #define DECL_addlsh2_n(name) \ DECL_add_n (name) #define DECL_addmul_1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) #define DECL_addmul_2(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr) #define DECL_bdiv_dbm1c(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) #define DECL_cnd_add_n(name) \ __GMP_DECLSPEC mp_limb_t name (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t) #define DECL_cnd_sub_n(name) \ __GMP_DECLSPEC mp_limb_t name (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t) #define DECL_com(name) \ __GMP_DECLSPEC void name (mp_ptr, mp_srcptr, mp_size_t) #define DECL_copyd(name) \ __GMP_DECLSPEC void name (mp_ptr, mp_srcptr, mp_size_t) #define DECL_copyi(name) \ DECL_copyd (name) #define DECL_divexact_1(name) \ __GMP_DECLSPEC void name (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) #define DECL_divexact_by3c(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) #define DECL_divrem_1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t) #define DECL_gcd_1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_srcptr, mp_size_t, mp_limb_t) #define DECL_lshift(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_srcptr, mp_size_t, unsigned) #define DECL_lshiftc(name) \ DECL_lshift (name) #define DECL_mod_1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_srcptr, mp_size_t, mp_limb_t) #define DECL_mod_1_1p(name) \ __GMP_DECLSPEC mp_limb_t name (mp_srcptr, mp_size_t, mp_limb_t, const mp_limb_t []) #define DECL_mod_1_1p_cps(name) \ __GMP_DECLSPEC void name (mp_limb_t cps[], mp_limb_t b) #define DECL_mod_1s_2p(name) \ DECL_mod_1_1p (name) #define DECL_mod_1s_2p_cps(name) \ DECL_mod_1_1p_cps (name) #define DECL_mod_1s_4p(name) \ DECL_mod_1_1p (name) #define DECL_mod_1s_4p_cps(name) \ DECL_mod_1_1p_cps (name) #define DECL_mod_34lsub1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_srcptr, mp_size_t) #define DECL_modexact_1c_odd(name) \ __GMP_DECLSPEC mp_limb_t name (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) #define DECL_mul_1(name) \ DECL_addmul_1 (name) #define DECL_mul_basecase(name) \ __GMP_DECLSPEC void name (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t) #define DECL_mullo_basecase(name) \ __GMP_DECLSPEC void name (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t) #define DECL_preinv_divrem_1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, int) #define DECL_preinv_mod_1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) #define DECL_redc_1(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) #define DECL_redc_2(name) \ __GMP_DECLSPEC mp_limb_t name (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr) #define DECL_rshift(name) \ DECL_lshift (name) #define DECL_sqr_basecase(name) \ __GMP_DECLSPEC void name (mp_ptr, mp_srcptr, mp_size_t) #define DECL_sub_n(name) \ DECL_add_n (name) #define DECL_sublsh1_n(name) \ DECL_add_n (name) #define DECL_submul_1(name) \ DECL_addmul_1 (name) #if ! defined (__GMP_WITHIN_CONFIGURE) #include "config.h" #include "gmp-mparam.h" #include "fib_table.h" #include "fac_table.h" #include "mp_bases.h" #if WANT_FAT_BINARY #include "fat.h" #endif #endif #if HAVE_INTTYPES_H /* for uint_least32_t */ # include #else # if HAVE_STDINT_H # include # endif #endif #ifdef __cplusplus #include /* for strlen */ #include /* for std::string */ #endif #ifndef WANT_TMP_DEBUG /* for TMP_ALLOC_LIMBS_2 and others */ #define WANT_TMP_DEBUG 0 #endif /* The following tries to get a good version of alloca. The tests are adapted from autoconf AC_FUNC_ALLOCA, with a couple of additions. Whether this succeeds is tested by GMP_FUNC_ALLOCA and HAVE_ALLOCA will be setup appropriately. ifndef alloca - a cpp define might already exist. glibc includes which uses GCC __builtin_alloca. HP cc +Olibcalls adds a #define of alloca to __builtin_alloca. GCC __builtin_alloca - preferred whenever available. _AIX pragma - IBM compilers need a #pragma in "each module that needs to use alloca". Pragma indented to protect pre-ANSI cpp's. _IBMR2 was used in past versions of GMP, retained still in case it matters. The autoconf manual says this pragma needs to be at the start of a C file, apart from comments and preprocessor directives. Is that true? xlc on aix 4.xxx doesn't seem to mind it being after prototypes etc from gmp.h. */ #ifndef alloca # ifdef __GNUC__ # define alloca __builtin_alloca # else # ifdef __DECC # define alloca(x) __ALLOCA(x) # else # ifdef _MSC_VER # include # define alloca _alloca # else # if HAVE_ALLOCA_H # include # else # if defined (_AIX) || defined (_IBMR2) #pragma alloca # else char *alloca (); # endif # endif # endif # endif # endif #endif /* if not provided by gmp-mparam.h */ #ifndef GMP_LIMB_BYTES #define GMP_LIMB_BYTES SIZEOF_MP_LIMB_T #endif #ifndef GMP_LIMB_BITS #define GMP_LIMB_BITS (8 * SIZEOF_MP_LIMB_T) #endif #define BITS_PER_ULONG (8 * SIZEOF_UNSIGNED_LONG) /* gmp_uint_least32_t is an unsigned integer type with at least 32 bits. */ #if HAVE_UINT_LEAST32_T typedef uint_least32_t gmp_uint_least32_t; #else #if SIZEOF_UNSIGNED_SHORT >= 4 typedef unsigned short gmp_uint_least32_t; #else #if SIZEOF_UNSIGNED >= 4 typedef unsigned gmp_uint_least32_t; #else typedef unsigned long gmp_uint_least32_t; #endif #endif #endif /* gmp_intptr_t, for pointer to integer casts */ #if HAVE_INTPTR_T typedef intptr_t gmp_intptr_t; #else /* fallback */ typedef size_t gmp_intptr_t; #endif /* pre-inverse types for truncating division and modulo */ typedef struct {mp_limb_t inv32;} gmp_pi1_t; typedef struct {mp_limb_t inv21, inv32, inv53;} gmp_pi2_t; /* "const" basically means a function does nothing but examine its arguments and give a return value, it doesn't read or write any memory (neither global nor pointed to by arguments), and has no other side-effects. This is more restrictive than "pure". See info node "(gcc)Function Attributes". __GMP_NO_ATTRIBUTE_CONST_PURE lets tune/common.c etc turn this off when trying to write timing loops. */ #if HAVE_ATTRIBUTE_CONST && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE) #define ATTRIBUTE_CONST __attribute__ ((const)) #else #define ATTRIBUTE_CONST #endif #if HAVE_ATTRIBUTE_NORETURN #define ATTRIBUTE_NORETURN __attribute__ ((noreturn)) #else #define ATTRIBUTE_NORETURN #endif /* "malloc" means a function behaves like malloc in that the pointer it returns doesn't alias anything. */ #if HAVE_ATTRIBUTE_MALLOC #define ATTRIBUTE_MALLOC __attribute__ ((malloc)) #else #define ATTRIBUTE_MALLOC #endif #if ! HAVE_STRCHR #define strchr(s,c) index(s,c) #endif #if ! HAVE_MEMSET #define memset(p, c, n) \ do { \ ASSERT ((n) >= 0); \ char *__memset__p = (p); \ int __i; \ for (__i = 0; __i < (n); __i++) \ __memset__p[__i] = (c); \ } while (0) #endif /* va_copy is standard in C99, and gcc provides __va_copy when in strict C89 mode. Falling back to a memcpy will give maximum portability, since it works no matter whether va_list is a pointer, struct or array. */ #if ! defined (va_copy) && defined (__va_copy) #define va_copy(dst,src) __va_copy(dst,src) #endif #if ! defined (va_copy) #define va_copy(dst,src) \ do { memcpy (&(dst), &(src), sizeof (va_list)); } while (0) #endif /* HAVE_HOST_CPU_alpha_CIX is 1 on an alpha with the CIX instructions (ie. ctlz, ctpop, cttz). */ #if HAVE_HOST_CPU_alphaev67 || HAVE_HOST_CPU_alphaev68 \ || HAVE_HOST_CPU_alphaev7 #define HAVE_HOST_CPU_alpha_CIX 1 #endif #if defined (__cplusplus) extern "C" { #endif /* Usage: TMP_DECL; TMP_MARK; ptr = TMP_ALLOC (bytes); TMP_FREE; Small allocations should use TMP_SALLOC, big allocations should use TMP_BALLOC. Allocations that might be small or big should use TMP_ALLOC. Functions that use just TMP_SALLOC should use TMP_SDECL, TMP_SMARK, and TMP_SFREE. TMP_DECL just declares a variable, but might be empty and so must be last in a list of variables. TMP_MARK must be done before any TMP_ALLOC. TMP_ALLOC(0) is not allowed. TMP_FREE doesn't need to be done if a TMP_MARK was made, but then no TMP_ALLOCs. */ /* The alignment in bytes, used for TMP_ALLOCed blocks, when alloca or __gmp_allocate_func doesn't already determine it. Currently TMP_ALLOC isn't used for "double"s, so that's not in the union. */ union tmp_align_t { mp_limb_t l; char *p; }; #define __TMP_ALIGN sizeof (union tmp_align_t) /* Return "a" rounded upwards to a multiple of "m", if it isn't already. "a" must be an unsigned type. This is designed for use with a compile-time constant "m". The POW2 case is expected to be usual, and gcc 3.0 and up recognises "(-(8*n))%8" or the like is always zero, which means the rounding up in the WANT_TMP_NOTREENTRANT version of TMP_ALLOC below will be a noop. */ #define ROUND_UP_MULTIPLE(a,m) \ (POW2_P(m) ? (a) + (-(a))%(m) \ : (a)+(m)-1 - (((a)+(m)-1) % (m))) #if defined (WANT_TMP_ALLOCA) || defined (WANT_TMP_REENTRANT) struct tmp_reentrant_t { struct tmp_reentrant_t *next; size_t size; /* bytes, including header */ }; __GMP_DECLSPEC void *__gmp_tmp_reentrant_alloc (struct tmp_reentrant_t **, size_t) ATTRIBUTE_MALLOC; __GMP_DECLSPEC void __gmp_tmp_reentrant_free (struct tmp_reentrant_t *); #endif #if WANT_TMP_ALLOCA #define TMP_SDECL #define TMP_DECL struct tmp_reentrant_t *__tmp_marker #define TMP_SMARK #define TMP_MARK __tmp_marker = 0 #define TMP_SALLOC(n) alloca(n) #define TMP_BALLOC(n) __gmp_tmp_reentrant_alloc (&__tmp_marker, n) /* The peculiar stack allocation limit here is chosen for efficient asm. */ #define TMP_ALLOC(n) \ (LIKELY ((n) <= 0x7f00) ? TMP_SALLOC(n) : TMP_BALLOC(n)) #define TMP_SFREE #define TMP_FREE \ do { \ if (UNLIKELY (__tmp_marker != 0)) \ __gmp_tmp_reentrant_free (__tmp_marker); \ } while (0) #endif #if WANT_TMP_REENTRANT #define TMP_SDECL TMP_DECL #define TMP_DECL struct tmp_reentrant_t *__tmp_marker #define TMP_SMARK TMP_MARK #define TMP_MARK __tmp_marker = 0 #define TMP_SALLOC(n) TMP_ALLOC(n) #define TMP_BALLOC(n) TMP_ALLOC(n) #define TMP_ALLOC(n) __gmp_tmp_reentrant_alloc (&__tmp_marker, n) #define TMP_SFREE TMP_FREE #define TMP_FREE __gmp_tmp_reentrant_free (__tmp_marker) #endif #if WANT_TMP_NOTREENTRANT struct tmp_marker { struct tmp_stack *which_chunk; void *alloc_point; }; __GMP_DECLSPEC void *__gmp_tmp_alloc (unsigned long) ATTRIBUTE_MALLOC; __GMP_DECLSPEC void __gmp_tmp_mark (struct tmp_marker *); __GMP_DECLSPEC void __gmp_tmp_free (struct tmp_marker *); #define TMP_SDECL TMP_DECL #define TMP_DECL struct tmp_marker __tmp_marker #define TMP_SMARK TMP_MARK #define TMP_MARK __gmp_tmp_mark (&__tmp_marker) #define TMP_SALLOC(n) TMP_ALLOC(n) #define TMP_BALLOC(n) TMP_ALLOC(n) #define TMP_ALLOC(n) \ __gmp_tmp_alloc (ROUND_UP_MULTIPLE ((unsigned long) (n), __TMP_ALIGN)) #define TMP_SFREE TMP_FREE #define TMP_FREE __gmp_tmp_free (&__tmp_marker) #endif #if WANT_TMP_DEBUG /* See tal-debug.c for some comments. */ struct tmp_debug_t { struct tmp_debug_entry_t *list; const char *file; int line; }; struct tmp_debug_entry_t { struct tmp_debug_entry_t *next; void *block; size_t size; }; __GMP_DECLSPEC void __gmp_tmp_debug_mark (const char *, int, struct tmp_debug_t **, struct tmp_debug_t *, const char *, const char *); __GMP_DECLSPEC void *__gmp_tmp_debug_alloc (const char *, int, int, struct tmp_debug_t **, const char *, size_t) ATTRIBUTE_MALLOC; __GMP_DECLSPEC void __gmp_tmp_debug_free (const char *, int, int, struct tmp_debug_t **, const char *, const char *); #define TMP_SDECL TMP_DECL_NAME(__tmp_xmarker, "__tmp_marker") #define TMP_DECL TMP_DECL_NAME(__tmp_xmarker, "__tmp_marker") #define TMP_SMARK TMP_MARK_NAME(__tmp_xmarker, "__tmp_marker") #define TMP_MARK TMP_MARK_NAME(__tmp_xmarker, "__tmp_marker") #define TMP_SFREE TMP_FREE_NAME(__tmp_xmarker, "__tmp_marker") #define TMP_FREE TMP_FREE_NAME(__tmp_xmarker, "__tmp_marker") /* The marker variable is designed to provoke an uninitialized variable warning from the compiler if TMP_FREE is used without a TMP_MARK. __tmp_marker_inscope does the same for TMP_ALLOC. Runtime tests pick these things up too. */ #define TMP_DECL_NAME(marker, marker_name) \ int marker; \ int __tmp_marker_inscope; \ const char *__tmp_marker_name = marker_name; \ struct tmp_debug_t __tmp_marker_struct; \ /* don't demand NULL, just cast a zero */ \ struct tmp_debug_t *__tmp_marker = (struct tmp_debug_t *) 0 #define TMP_MARK_NAME(marker, marker_name) \ do { \ marker = 1; \ __tmp_marker_inscope = 1; \ __gmp_tmp_debug_mark (ASSERT_FILE, ASSERT_LINE, \ &__tmp_marker, &__tmp_marker_struct, \ __tmp_marker_name, marker_name); \ } while (0) #define TMP_SALLOC(n) TMP_ALLOC(n) #define TMP_BALLOC(n) TMP_ALLOC(n) #define TMP_ALLOC(size) \ __gmp_tmp_debug_alloc (ASSERT_FILE, ASSERT_LINE, \ __tmp_marker_inscope, \ &__tmp_marker, __tmp_marker_name, size) #define TMP_FREE_NAME(marker, marker_name) \ do { \ __gmp_tmp_debug_free (ASSERT_FILE, ASSERT_LINE, \ marker, &__tmp_marker, \ __tmp_marker_name, marker_name); \ } while (0) #endif /* WANT_TMP_DEBUG */ /* Allocating various types. */ #define TMP_ALLOC_TYPE(n,type) ((type *) TMP_ALLOC ((n) * sizeof (type))) #define TMP_SALLOC_TYPE(n,type) ((type *) TMP_SALLOC ((n) * sizeof (type))) #define TMP_BALLOC_TYPE(n,type) ((type *) TMP_BALLOC ((n) * sizeof (type))) #define TMP_ALLOC_LIMBS(n) TMP_ALLOC_TYPE(n,mp_limb_t) #define TMP_SALLOC_LIMBS(n) TMP_SALLOC_TYPE(n,mp_limb_t) #define TMP_BALLOC_LIMBS(n) TMP_BALLOC_TYPE(n,mp_limb_t) #define TMP_ALLOC_MP_PTRS(n) TMP_ALLOC_TYPE(n,mp_ptr) #define TMP_SALLOC_MP_PTRS(n) TMP_SALLOC_TYPE(n,mp_ptr) #define TMP_BALLOC_MP_PTRS(n) TMP_BALLOC_TYPE(n,mp_ptr) /* It's more efficient to allocate one block than many. This is certainly true of the malloc methods, but it can even be true of alloca if that involves copying a chunk of stack (various RISCs), or a call to a stack bounds check (mingw). In any case, when debugging keep separate blocks so a redzoning malloc debugger can protect each individually. */ #define TMP_ALLOC_LIMBS_2(xp,xsize, yp,ysize) \ do { \ if (WANT_TMP_DEBUG) \ { \ (xp) = TMP_ALLOC_LIMBS (xsize); \ (yp) = TMP_ALLOC_LIMBS (ysize); \ } \ else \ { \ (xp) = TMP_ALLOC_LIMBS ((xsize) + (ysize)); \ (yp) = (xp) + (xsize); \ } \ } while (0) #define TMP_ALLOC_LIMBS_3(xp,xsize, yp,ysize, zp,zsize) \ do { \ if (WANT_TMP_DEBUG) \ { \ (xp) = TMP_ALLOC_LIMBS (xsize); \ (yp) = TMP_ALLOC_LIMBS (ysize); \ (zp) = TMP_ALLOC_LIMBS (zsize); \ } \ else \ { \ (xp) = TMP_ALLOC_LIMBS ((xsize) + (ysize) + (zsize)); \ (yp) = (xp) + (xsize); \ (zp) = (yp) + (ysize); \ } \ } while (0) /* From gmp.h, nicer names for internal use. */ #define CRAY_Pragma(str) __GMP_CRAY_Pragma(str) #define MPN_CMP(result, xp, yp, size) __GMPN_CMP(result, xp, yp, size) #define LIKELY(cond) __GMP_LIKELY(cond) #define UNLIKELY(cond) __GMP_UNLIKELY(cond) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define NEG_CAST(T,x) (- (__GMP_CAST (T, (x) + 1) - 1)) #define ABS_CAST(T,x) ((x) >= 0 ? __GMP_CAST (T, x) : NEG_CAST (T,x)) #undef MIN #define MIN(l,o) ((l) < (o) ? (l) : (o)) #undef MAX #define MAX(h,i) ((h) > (i) ? (h) : (i)) #define numberof(x) (sizeof (x) / sizeof ((x)[0])) /* Field access macros. */ #define SIZ(x) ((x)->_mp_size) #define ABSIZ(x) ABS (SIZ (x)) #define PTR(x) ((x)->_mp_d) #define EXP(x) ((x)->_mp_exp) #define PREC(x) ((x)->_mp_prec) #define ALLOC(x) ((x)->_mp_alloc) #define NUM(x) mpq_numref(x) #define DEN(x) mpq_denref(x) /* n-1 inverts any low zeros and the lowest one bit. If n&(n-1) leaves zero then that lowest one bit must have been the only bit set. n==0 will return true though, so avoid that. */ #define POW2_P(n) (((n) & ((n) - 1)) == 0) /* This is intended for constant THRESHOLDs only, where the compiler can completely fold the result. */ #define LOG2C(n) \ (((n) >= 0x1) + ((n) >= 0x2) + ((n) >= 0x4) + ((n) >= 0x8) + \ ((n) >= 0x10) + ((n) >= 0x20) + ((n) >= 0x40) + ((n) >= 0x80) + \ ((n) >= 0x100) + ((n) >= 0x200) + ((n) >= 0x400) + ((n) >= 0x800) + \ ((n) >= 0x1000) + ((n) >= 0x2000) + ((n) >= 0x4000) + ((n) >= 0x8000)) #define MP_LIMB_T_MAX (~ (mp_limb_t) 0) /* Must cast ULONG_MAX etc to unsigned long etc, since they might not be unsigned on a K&R compiler. In particular the HP-UX 10 bundled K&R cc treats the plain decimal values in as signed. */ #define ULONG_HIGHBIT (ULONG_MAX ^ ((unsigned long) ULONG_MAX >> 1)) #define UINT_HIGHBIT (UINT_MAX ^ ((unsigned) UINT_MAX >> 1)) #define USHRT_HIGHBIT (USHRT_MAX ^ ((unsigned short) USHRT_MAX >> 1)) #define GMP_LIMB_HIGHBIT (MP_LIMB_T_MAX ^ (MP_LIMB_T_MAX >> 1)) #if __GMP_MP_SIZE_T_INT #define MP_SIZE_T_MAX INT_MAX #define MP_SIZE_T_MIN INT_MIN #else #define MP_SIZE_T_MAX LONG_MAX #define MP_SIZE_T_MIN LONG_MIN #endif /* mp_exp_t is the same as mp_size_t */ #define MP_EXP_T_MAX MP_SIZE_T_MAX #define MP_EXP_T_MIN MP_SIZE_T_MIN #define LONG_HIGHBIT LONG_MIN #define INT_HIGHBIT INT_MIN #define SHRT_HIGHBIT SHRT_MIN #define GMP_NUMB_HIGHBIT (CNST_LIMB(1) << (GMP_NUMB_BITS-1)) #if GMP_NAIL_BITS == 0 #define GMP_NAIL_LOWBIT CNST_LIMB(0) #else #define GMP_NAIL_LOWBIT (CNST_LIMB(1) << GMP_NUMB_BITS) #endif #if GMP_NAIL_BITS != 0 /* Set various *_THRESHOLD values to be used for nails. Thus we avoid using code that has not yet been qualified. */ #undef DC_DIV_QR_THRESHOLD #define DC_DIV_QR_THRESHOLD 50 #undef DIVREM_1_NORM_THRESHOLD #undef DIVREM_1_UNNORM_THRESHOLD #undef MOD_1_NORM_THRESHOLD #undef MOD_1_UNNORM_THRESHOLD #undef USE_PREINV_DIVREM_1 #undef DIVREM_2_THRESHOLD #undef DIVEXACT_1_THRESHOLD #define DIVREM_1_NORM_THRESHOLD MP_SIZE_T_MAX /* no preinv */ #define DIVREM_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* no preinv */ #define MOD_1_NORM_THRESHOLD MP_SIZE_T_MAX /* no preinv */ #define MOD_1_UNNORM_THRESHOLD MP_SIZE_T_MAX /* no preinv */ #define USE_PREINV_DIVREM_1 0 /* no preinv */ #define DIVREM_2_THRESHOLD MP_SIZE_T_MAX /* no preinv */ /* mpn/generic/mul_fft.c is not nails-capable. */ #undef MUL_FFT_THRESHOLD #undef SQR_FFT_THRESHOLD #define MUL_FFT_THRESHOLD MP_SIZE_T_MAX #define SQR_FFT_THRESHOLD MP_SIZE_T_MAX #endif /* Swap macros. */ #define MP_LIMB_T_SWAP(x, y) \ do { \ mp_limb_t __mp_limb_t_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_limb_t_swap__tmp; \ } while (0) #define MP_SIZE_T_SWAP(x, y) \ do { \ mp_size_t __mp_size_t_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_size_t_swap__tmp; \ } while (0) #define MP_PTR_SWAP(x, y) \ do { \ mp_ptr __mp_ptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_ptr_swap__tmp; \ } while (0) #define MP_SRCPTR_SWAP(x, y) \ do { \ mp_srcptr __mp_srcptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_srcptr_swap__tmp; \ } while (0) #define MPN_PTR_SWAP(xp,xs, yp,ys) \ do { \ MP_PTR_SWAP (xp, yp); \ MP_SIZE_T_SWAP (xs, ys); \ } while(0) #define MPN_SRCPTR_SWAP(xp,xs, yp,ys) \ do { \ MP_SRCPTR_SWAP (xp, yp); \ MP_SIZE_T_SWAP (xs, ys); \ } while(0) #define MPZ_PTR_SWAP(x, y) \ do { \ mpz_ptr __mpz_ptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mpz_ptr_swap__tmp; \ } while (0) #define MPZ_SRCPTR_SWAP(x, y) \ do { \ mpz_srcptr __mpz_srcptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mpz_srcptr_swap__tmp; \ } while (0) #define MPQ_PTR_SWAP(x, y) \ do { \ mpq_ptr __mpq_ptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mpq_ptr_swap__tmp; \ } while (0) #define MPQ_SRCPTR_SWAP(x, y) \ do { \ mpq_srcptr __mpq_srcptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mpq_srcptr_swap__tmp; \ } while (0) /* Enhancement: __gmp_allocate_func could have "__attribute__ ((malloc))", but current gcc (3.0) doesn't seem to support that. */ __GMP_DECLSPEC extern void * (*__gmp_allocate_func) (size_t); __GMP_DECLSPEC extern void * (*__gmp_reallocate_func) (void *, size_t, size_t); __GMP_DECLSPEC extern void (*__gmp_free_func) (void *, size_t); __GMP_DECLSPEC void *__gmp_default_allocate (size_t); __GMP_DECLSPEC void *__gmp_default_reallocate (void *, size_t, size_t); __GMP_DECLSPEC void __gmp_default_free (void *, size_t); #define __GMP_ALLOCATE_FUNC_TYPE(n,type) \ ((type *) (*__gmp_allocate_func) ((n) * sizeof (type))) #define __GMP_ALLOCATE_FUNC_LIMBS(n) __GMP_ALLOCATE_FUNC_TYPE (n, mp_limb_t) #define __GMP_REALLOCATE_FUNC_TYPE(p, old_size, new_size, type) \ ((type *) (*__gmp_reallocate_func) \ (p, (old_size) * sizeof (type), (new_size) * sizeof (type))) #define __GMP_REALLOCATE_FUNC_LIMBS(p, old_size, new_size) \ __GMP_REALLOCATE_FUNC_TYPE(p, old_size, new_size, mp_limb_t) #define __GMP_FREE_FUNC_TYPE(p,n,type) (*__gmp_free_func) (p, (n) * sizeof (type)) #define __GMP_FREE_FUNC_LIMBS(p,n) __GMP_FREE_FUNC_TYPE (p, n, mp_limb_t) #define __GMP_REALLOCATE_FUNC_MAYBE(ptr, oldsize, newsize) \ do { \ if ((oldsize) != (newsize)) \ (ptr) = (*__gmp_reallocate_func) (ptr, oldsize, newsize); \ } while (0) #define __GMP_REALLOCATE_FUNC_MAYBE_TYPE(ptr, oldsize, newsize, type) \ do { \ if ((oldsize) != (newsize)) \ (ptr) = (type *) (*__gmp_reallocate_func) \ (ptr, (oldsize) * sizeof (type), (newsize) * sizeof (type)); \ } while (0) /* Dummy for non-gcc, code involving it will go dead. */ #if ! defined (__GNUC__) || __GNUC__ < 2 #define __builtin_constant_p(x) 0 #endif /* In gcc 2.96 and up on i386, tail calls are optimized to jumps if the stack usage is compatible. __attribute__ ((regparm (N))) helps by putting leading parameters in registers, avoiding extra stack. regparm cannot be used with calls going through the PLT, because the binding code there may clobber the registers (%eax, %edx, %ecx) used for the regparm parameters. Calls to local (ie. static) functions could still use this, if we cared to differentiate locals and globals. On athlon-unknown-freebsd4.9 with gcc 3.3.3, regparm cannot be used with -p or -pg profiling, since that version of gcc doesn't realize the .mcount calls will clobber the parameter registers. Other systems are ok, like debian with glibc 2.3.2 (mcount doesn't clobber), but we don't bother to try to detect this. regparm is only an optimization so we just disable it when profiling (profiling being a slowdown anyway). */ #if HAVE_HOST_CPU_FAMILY_x86 && __GMP_GNUC_PREREQ (2,96) && ! defined (PIC) \ && ! WANT_PROFILING_PROF && ! WANT_PROFILING_GPROF #define USE_LEADING_REGPARM 1 #else #define USE_LEADING_REGPARM 0 #endif /* Macros for altering parameter order according to regparm usage. */ #if USE_LEADING_REGPARM #define REGPARM_2_1(a,b,x) x,a,b #define REGPARM_3_1(a,b,c,x) x,a,b,c #define REGPARM_ATTR(n) __attribute__ ((regparm (n))) #else #define REGPARM_2_1(a,b,x) a,b,x #define REGPARM_3_1(a,b,c,x) a,b,c,x #define REGPARM_ATTR(n) #endif /* ASM_L gives a local label for a gcc asm block, for use when temporary local labels like "1:" might not be available, which is the case for instance on the x86s (the SCO assembler doesn't support them). The label generated is made unique by including "%=" which is a unique number for each insn. This ensures the same name can be used in multiple asm blocks, perhaps via a macro. Since jumps between asm blocks are not allowed there's no need for a label to be usable outside a single block. */ #define ASM_L(name) LSYM_PREFIX "asm_%=_" #name #if defined (__GNUC__) && HAVE_HOST_CPU_FAMILY_x86 #if 0 /* FIXME: Check that these actually improve things. FIXME: Need a cld after each std. FIXME: Can't have inputs in clobbered registers, must describe them as dummy outputs, and add volatile. */ #define MPN_COPY_INCR(DST, SRC, N) \ __asm__ ("cld\n\trep\n\tmovsl" : : \ "D" (DST), "S" (SRC), "c" (N) : \ "cx", "di", "si", "memory") #define MPN_COPY_DECR(DST, SRC, N) \ __asm__ ("std\n\trep\n\tmovsl" : : \ "D" ((DST) + (N) - 1), "S" ((SRC) + (N) - 1), "c" (N) : \ "cx", "di", "si", "memory") #endif #endif __GMP_DECLSPEC void __gmpz_aorsmul_1 (REGPARM_3_1 (mpz_ptr, mpz_srcptr, mp_limb_t, mp_size_t)) REGPARM_ATTR(1); #define mpz_aorsmul_1(w,u,v,sub) __gmpz_aorsmul_1 (REGPARM_3_1 (w, u, v, sub)) #define mpz_n_pow_ui __gmpz_n_pow_ui __GMP_DECLSPEC void mpz_n_pow_ui (mpz_ptr, mp_srcptr, mp_size_t, unsigned long); #define mpn_addmul_1c __MPN(addmul_1c) __GMP_DECLSPEC mp_limb_t mpn_addmul_1c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t); #ifndef mpn_addmul_2 /* if not done with cpuvec in a fat binary */ #define mpn_addmul_2 __MPN(addmul_2) __GMP_DECLSPEC mp_limb_t mpn_addmul_2 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #endif #define mpn_addmul_3 __MPN(addmul_3) __GMP_DECLSPEC mp_limb_t mpn_addmul_3 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_addmul_4 __MPN(addmul_4) __GMP_DECLSPEC mp_limb_t mpn_addmul_4 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_addmul_5 __MPN(addmul_5) __GMP_DECLSPEC mp_limb_t mpn_addmul_5 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_addmul_6 __MPN(addmul_6) __GMP_DECLSPEC mp_limb_t mpn_addmul_6 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_addmul_7 __MPN(addmul_7) __GMP_DECLSPEC mp_limb_t mpn_addmul_7 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_addmul_8 __MPN(addmul_8) __GMP_DECLSPEC mp_limb_t mpn_addmul_8 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); /* Alternative entry point in mpn_addmul_2 for the benefit of mpn_sqr_basecase. */ #define mpn_addmul_2s __MPN(addmul_2s) __GMP_DECLSPEC mp_limb_t mpn_addmul_2s (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); /* mpn_addlsh1_n(c,a,b,n), when it exists, sets {c,n} to {a,n}+2*{b,n}, and returns the carry out (0, 1 or 2). Use _ip1 when a=c. */ #ifndef mpn_addlsh1_n /* if not done with cpuvec in a fat binary */ #define mpn_addlsh1_n __MPN(addlsh1_n) __GMP_DECLSPEC mp_limb_t mpn_addlsh1_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #endif #define mpn_addlsh1_nc __MPN(addlsh1_nc) __GMP_DECLSPEC mp_limb_t mpn_addlsh1_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #if HAVE_NATIVE_mpn_addlsh1_n && ! HAVE_NATIVE_mpn_addlsh1_n_ip1 #define mpn_addlsh1_n_ip1(dst,src,n) mpn_addlsh1_n(dst,dst,src,n) #define HAVE_NATIVE_mpn_addlsh1_n_ip1 1 #else #define mpn_addlsh1_n_ip1 __MPN(addlsh1_n_ip1) __GMP_DECLSPEC mp_limb_t mpn_addlsh1_n_ip1 (mp_ptr, mp_srcptr, mp_size_t); #endif #if HAVE_NATIVE_mpn_addlsh1_nc && ! HAVE_NATIVE_mpn_addlsh1_nc_ip1 #define mpn_addlsh1_nc_ip1(dst,src,n,c) mpn_addlsh1_nc(dst,dst,src,n,c) #define HAVE_NATIVE_mpn_addlsh1_nc_ip1 1 #else #define mpn_addlsh1_nc_ip1 __MPN(addlsh1_nc_ip1) __GMP_DECLSPEC mp_limb_t mpn_addlsh1_nc_ip1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #endif #ifndef mpn_addlsh2_n /* if not done with cpuvec in a fat binary */ /* mpn_addlsh2_n(c,a,b,n), when it exists, sets {c,n} to {a,n}+4*{b,n}, and returns the carry out (0, ..., 4). Use _ip1 when a=c. */ #define mpn_addlsh2_n __MPN(addlsh2_n) __GMP_DECLSPEC mp_limb_t mpn_addlsh2_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #endif #define mpn_addlsh2_nc __MPN(addlsh2_nc) __GMP_DECLSPEC mp_limb_t mpn_addlsh2_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #if HAVE_NATIVE_mpn_addlsh2_n && ! HAVE_NATIVE_mpn_addlsh2_n_ip1 #define mpn_addlsh2_n_ip1(dst,src,n) mpn_addlsh2_n(dst,dst,src,n) #define HAVE_NATIVE_mpn_addlsh2_n_ip1 1 #else #define mpn_addlsh2_n_ip1 __MPN(addlsh2_n_ip1) __GMP_DECLSPEC mp_limb_t mpn_addlsh2_n_ip1 (mp_ptr, mp_srcptr, mp_size_t); #endif #if HAVE_NATIVE_mpn_addlsh2_nc && ! HAVE_NATIVE_mpn_addlsh2_nc_ip1 #define mpn_addlsh2_nc_ip1(dst,src,n,c) mpn_addlsh2_nc(dst,dst,src,n,c) #define HAVE_NATIVE_mpn_addlsh2_nc_ip1 1 #else #define mpn_addlsh2_nc_ip1 __MPN(addlsh2_nc_ip1) __GMP_DECLSPEC mp_limb_t mpn_addlsh2_nc_ip1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #endif /* mpn_addlsh_n(c,a,b,n,k), when it exists, sets {c,n} to {a,n}+2^k*{b,n}, and returns the carry out (0, ..., 2^k). Use _ip1 when a=c. */ #define mpn_addlsh_n __MPN(addlsh_n) __GMP_DECLSPEC mp_limb_t mpn_addlsh_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, unsigned int); #define mpn_addlsh_nc __MPN(addlsh_nc) __GMP_DECLSPEC mp_limb_t mpn_addlsh_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, unsigned int, mp_limb_t); #if HAVE_NATIVE_mpn_addlsh_n && ! HAVE_NATIVE_mpn_addlsh_n_ip1 #define mpn_addlsh_n_ip1(dst,src,n,s) mpn_addlsh_n(dst,dst,src,n,s) #define HAVE_NATIVE_mpn_addlsh_n_ip1 1 #else #define mpn_addlsh_n_ip1 __MPN(addlsh_n_ip1) __GMP_DECLSPEC mp_limb_t mpn_addlsh_n_ip1 (mp_ptr, mp_srcptr, mp_size_t, unsigned int); #endif #if HAVE_NATIVE_mpn_addlsh_nc && ! HAVE_NATIVE_mpn_addlsh_nc_ip1 #define mpn_addlsh_nc_ip1(dst,src,n,s,c) mpn_addlsh_nc(dst,dst,src,n,s,c) #define HAVE_NATIVE_mpn_addlsh_nc_ip1 1 #else #define mpn_addlsh_nc_ip1 __MPN(addlsh_nc_ip1) __GMP_DECLSPEC mp_limb_t mpn_addlsh_nc_ip1 (mp_ptr, mp_srcptr, mp_size_t, unsigned int, mp_limb_t); #endif #ifndef mpn_sublsh1_n /* if not done with cpuvec in a fat binary */ /* mpn_sublsh1_n(c,a,b,n), when it exists, sets {c,n} to {a,n}-2*{b,n}, and returns the borrow out (0, 1 or 2). Use _ip1 when a=c. */ #define mpn_sublsh1_n __MPN(sublsh1_n) __GMP_DECLSPEC mp_limb_t mpn_sublsh1_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #endif #define mpn_sublsh1_nc __MPN(sublsh1_nc) __GMP_DECLSPEC mp_limb_t mpn_sublsh1_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #if HAVE_NATIVE_mpn_sublsh1_n && ! HAVE_NATIVE_mpn_sublsh1_n_ip1 #define mpn_sublsh1_n_ip1(dst,src,n) mpn_sublsh1_n(dst,dst,src,n) #define HAVE_NATIVE_mpn_sublsh1_n_ip1 1 #else #define mpn_sublsh1_n_ip1 __MPN(sublsh1_n_ip1) __GMP_DECLSPEC mp_limb_t mpn_sublsh1_n_ip1 (mp_ptr, mp_srcptr, mp_size_t); #endif #if HAVE_NATIVE_mpn_sublsh1_nc && ! HAVE_NATIVE_mpn_sublsh1_nc_ip1 #define mpn_sublsh1_nc_ip1(dst,src,n,c) mpn_sublsh1_nc(dst,dst,src,n,c) #define HAVE_NATIVE_mpn_sublsh1_nc_ip1 1 #else #define mpn_sublsh1_nc_ip1 __MPN(sublsh1_nc_ip1) __GMP_DECLSPEC mp_limb_t mpn_sublsh1_nc_ip1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #endif /* mpn_rsblsh1_n(c,a,b,n), when it exists, sets {c,n} to 2*{b,n}-{a,n}, and returns the carry out (-1, 0, 1). */ #define mpn_rsblsh1_n __MPN(rsblsh1_n) __GMP_DECLSPEC mp_limb_signed_t mpn_rsblsh1_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_rsblsh1_nc __MPN(rsblsh1_nc) __GMP_DECLSPEC mp_limb_signed_t mpn_rsblsh1_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); /* mpn_sublsh2_n(c,a,b,n), when it exists, sets {c,n} to {a,n}-4*{b,n}, and returns the borrow out (0, ..., 4). Use _ip1 when a=c. */ #define mpn_sublsh2_n __MPN(sublsh2_n) __GMP_DECLSPEC mp_limb_t mpn_sublsh2_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_sublsh2_nc __MPN(sublsh2_nc) __GMP_DECLSPEC mp_limb_t mpn_sublsh2_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #if HAVE_NATIVE_mpn_sublsh2_n && ! HAVE_NATIVE_mpn_sublsh2_n_ip1 #define mpn_sublsh2_n_ip1(dst,src,n) mpn_sublsh2_n(dst,dst,src,n) #define HAVE_NATIVE_mpn_sublsh2_n_ip1 1 #else #define mpn_sublsh2_n_ip1 __MPN(sublsh2_n_ip1) __GMP_DECLSPEC mp_limb_t mpn_sublsh2_n_ip1 (mp_ptr, mp_srcptr, mp_size_t); #endif #if HAVE_NATIVE_mpn_sublsh2_nc && ! HAVE_NATIVE_mpn_sublsh2_nc_ip1 #define mpn_sublsh2_nc_ip1(dst,src,n,c) mpn_sublsh2_nc(dst,dst,src,n,c) #define HAVE_NATIVE_mpn_sublsh2_nc_ip1 1 #else #define mpn_sublsh2_nc_ip1 __MPN(sublsh2_nc_ip1) __GMP_DECLSPEC mp_limb_t mpn_sublsh2_nc_ip1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #endif /* mpn_sublsh_n(c,a,b,n,k), when it exists, sets {c,n} to {a,n}-2^k*{b,n}, and returns the carry out (0, ..., 2^k). Use _ip1 when a=c. */ #define mpn_sublsh_n __MPN(sublsh_n) __GMP_DECLSPEC mp_limb_t mpn_sublsh_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, unsigned int); #if HAVE_NATIVE_mpn_sublsh_n && ! HAVE_NATIVE_mpn_sublsh_n_ip1 #define mpn_sublsh_n_ip1(dst,src,n,s) mpn_sublsh_n(dst,dst,src,n,s) #define HAVE_NATIVE_mpn_sublsh_n_ip1 1 #else #define mpn_sublsh_n_ip1 __MPN(sublsh_n_ip1) __GMP_DECLSPEC mp_limb_t mpn_sublsh_n_ip1 (mp_ptr, mp_srcptr, mp_size_t, unsigned int); #endif #if HAVE_NATIVE_mpn_sublsh_nc && ! HAVE_NATIVE_mpn_sublsh_nc_ip1 #define mpn_sublsh_nc_ip1(dst,src,n,s,c) mpn_sublsh_nc(dst,dst,src,n,s,c) #define HAVE_NATIVE_mpn_sublsh_nc_ip1 1 #else #define mpn_sublsh_nc_ip1 __MPN(sublsh_nc_ip1) __GMP_DECLSPEC mp_limb_t mpn_sublsh_nc_ip1 (mp_ptr, mp_srcptr, mp_size_t, unsigned int, mp_limb_t); #endif /* mpn_rsblsh2_n(c,a,b,n), when it exists, sets {c,n} to 4*{b,n}-{a,n}, and returns the carry out (-1, ..., 3). */ #define mpn_rsblsh2_n __MPN(rsblsh2_n) __GMP_DECLSPEC mp_limb_signed_t mpn_rsblsh2_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_rsblsh2_nc __MPN(rsblsh2_nc) __GMP_DECLSPEC mp_limb_signed_t mpn_rsblsh2_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); /* mpn_rsblsh_n(c,a,b,n,k), when it exists, sets {c,n} to 2^k*{b,n}-{a,n}, and returns the carry out (-1, 0, ..., 2^k-1). */ #define mpn_rsblsh_n __MPN(rsblsh_n) __GMP_DECLSPEC mp_limb_signed_t mpn_rsblsh_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, unsigned int); #define mpn_rsblsh_nc __MPN(rsblsh_nc) __GMP_DECLSPEC mp_limb_signed_t mpn_rsblsh_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, unsigned int, mp_limb_t); /* mpn_rsh1add_n(c,a,b,n), when it exists, sets {c,n} to ({a,n} + {b,n}) >> 1, and returns the bit rshifted out (0 or 1). */ #define mpn_rsh1add_n __MPN(rsh1add_n) __GMP_DECLSPEC mp_limb_t mpn_rsh1add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_rsh1add_nc __MPN(rsh1add_nc) __GMP_DECLSPEC mp_limb_t mpn_rsh1add_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); /* mpn_rsh1sub_n(c,a,b,n), when it exists, sets {c,n} to ({a,n} - {b,n}) >> 1, and returns the bit rshifted out (0 or 1). If there's a borrow from the subtract, it's stored as a 1 in the high bit of c[n-1], like a twos complement negative. */ #define mpn_rsh1sub_n __MPN(rsh1sub_n) __GMP_DECLSPEC mp_limb_t mpn_rsh1sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_rsh1sub_nc __MPN(rsh1sub_nc) __GMP_DECLSPEC mp_limb_t mpn_rsh1sub_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #ifndef mpn_lshiftc /* if not done with cpuvec in a fat binary */ #define mpn_lshiftc __MPN(lshiftc) __GMP_DECLSPEC mp_limb_t mpn_lshiftc (mp_ptr, mp_srcptr, mp_size_t, unsigned int); #endif #define mpn_add_err1_n __MPN(add_err1_n) __GMP_DECLSPEC mp_limb_t mpn_add_err1_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_add_err2_n __MPN(add_err2_n) __GMP_DECLSPEC mp_limb_t mpn_add_err2_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_add_err3_n __MPN(add_err3_n) __GMP_DECLSPEC mp_limb_t mpn_add_err3_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_sub_err1_n __MPN(sub_err1_n) __GMP_DECLSPEC mp_limb_t mpn_sub_err1_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_sub_err2_n __MPN(sub_err2_n) __GMP_DECLSPEC mp_limb_t mpn_sub_err2_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_sub_err3_n __MPN(sub_err3_n) __GMP_DECLSPEC mp_limb_t mpn_sub_err3_n (mp_ptr, mp_srcptr, mp_srcptr, mp_ptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_add_n_sub_n __MPN(add_n_sub_n) __GMP_DECLSPEC mp_limb_t mpn_add_n_sub_n (mp_ptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_add_n_sub_nc __MPN(add_n_sub_nc) __GMP_DECLSPEC mp_limb_t mpn_add_n_sub_nc (mp_ptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_addaddmul_1msb0 __MPN(addaddmul_1msb0) __GMP_DECLSPEC mp_limb_t mpn_addaddmul_1msb0 (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t); #define mpn_divrem_1c __MPN(divrem_1c) __GMP_DECLSPEC mp_limb_t mpn_divrem_1c (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t); #define mpn_dump __MPN(dump) __GMP_DECLSPEC void mpn_dump (mp_srcptr, mp_size_t); #define mpn_fib2_ui __MPN(fib2_ui) __GMP_DECLSPEC mp_size_t mpn_fib2_ui (mp_ptr, mp_ptr, unsigned long); /* Remap names of internal mpn functions. */ #define __clz_tab __MPN(clz_tab) #define mpn_udiv_w_sdiv __MPN(udiv_w_sdiv) #define mpn_jacobi_base __MPN(jacobi_base) __GMP_DECLSPEC int mpn_jacobi_base (mp_limb_t, mp_limb_t, int) ATTRIBUTE_CONST; #define mpn_jacobi_2 __MPN(jacobi_2) __GMP_DECLSPEC int mpn_jacobi_2 (mp_srcptr, mp_srcptr, unsigned); #define mpn_jacobi_n __MPN(jacobi_n) __GMP_DECLSPEC int mpn_jacobi_n (mp_ptr, mp_ptr, mp_size_t, unsigned); #define mpn_mod_1c __MPN(mod_1c) __GMP_DECLSPEC mp_limb_t mpn_mod_1c (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; #define mpn_mul_1c __MPN(mul_1c) __GMP_DECLSPEC mp_limb_t mpn_mul_1c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t); #define mpn_mul_2 __MPN(mul_2) __GMP_DECLSPEC mp_limb_t mpn_mul_2 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_mul_3 __MPN(mul_3) __GMP_DECLSPEC mp_limb_t mpn_mul_3 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_mul_4 __MPN(mul_4) __GMP_DECLSPEC mp_limb_t mpn_mul_4 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_mul_5 __MPN(mul_5) __GMP_DECLSPEC mp_limb_t mpn_mul_5 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #define mpn_mul_6 __MPN(mul_6) __GMP_DECLSPEC mp_limb_t mpn_mul_6 (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #ifndef mpn_mul_basecase /* if not done with cpuvec in a fat binary */ #define mpn_mul_basecase __MPN(mul_basecase) __GMP_DECLSPEC void mpn_mul_basecase (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #endif #define mpn_mullo_n __MPN(mullo_n) __GMP_DECLSPEC void mpn_mullo_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #ifndef mpn_mullo_basecase /* if not done with cpuvec in a fat binary */ #define mpn_mullo_basecase __MPN(mullo_basecase) __GMP_DECLSPEC void mpn_mullo_basecase (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #endif #ifndef mpn_sqr_basecase /* if not done with cpuvec in a fat binary */ #define mpn_sqr_basecase __MPN(sqr_basecase) __GMP_DECLSPEC void mpn_sqr_basecase (mp_ptr, mp_srcptr, mp_size_t); #endif #define mpn_sqrlo __MPN(sqrlo) __GMP_DECLSPEC void mpn_sqrlo (mp_ptr, mp_srcptr, mp_size_t); #define mpn_sqrlo_basecase __MPN(sqrlo_basecase) __GMP_DECLSPEC void mpn_sqrlo_basecase (mp_ptr, mp_srcptr, mp_size_t); #define mpn_mulmid_basecase __MPN(mulmid_basecase) __GMP_DECLSPEC void mpn_mulmid_basecase (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_mulmid_n __MPN(mulmid_n) __GMP_DECLSPEC void mpn_mulmid_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_mulmid __MPN(mulmid) __GMP_DECLSPEC void mpn_mulmid (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_submul_1c __MPN(submul_1c) __GMP_DECLSPEC mp_limb_t mpn_submul_1c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t); #ifndef mpn_redc_1 /* if not done with cpuvec in a fat binary */ #define mpn_redc_1 __MPN(redc_1) __GMP_DECLSPEC mp_limb_t mpn_redc_1 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #endif #ifndef mpn_redc_2 /* if not done with cpuvec in a fat binary */ #define mpn_redc_2 __MPN(redc_2) __GMP_DECLSPEC mp_limb_t mpn_redc_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #endif #define mpn_redc_n __MPN(redc_n) __GMP_DECLSPEC void mpn_redc_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); #ifndef mpn_mod_1_1p_cps /* if not done with cpuvec in a fat binary */ #define mpn_mod_1_1p_cps __MPN(mod_1_1p_cps) __GMP_DECLSPEC void mpn_mod_1_1p_cps (mp_limb_t [4], mp_limb_t); #endif #ifndef mpn_mod_1_1p /* if not done with cpuvec in a fat binary */ #define mpn_mod_1_1p __MPN(mod_1_1p) __GMP_DECLSPEC mp_limb_t mpn_mod_1_1p (mp_srcptr, mp_size_t, mp_limb_t, const mp_limb_t [4]) __GMP_ATTRIBUTE_PURE; #endif #ifndef mpn_mod_1s_2p_cps /* if not done with cpuvec in a fat binary */ #define mpn_mod_1s_2p_cps __MPN(mod_1s_2p_cps) __GMP_DECLSPEC void mpn_mod_1s_2p_cps (mp_limb_t [5], mp_limb_t); #endif #ifndef mpn_mod_1s_2p /* if not done with cpuvec in a fat binary */ #define mpn_mod_1s_2p __MPN(mod_1s_2p) __GMP_DECLSPEC mp_limb_t mpn_mod_1s_2p (mp_srcptr, mp_size_t, mp_limb_t, const mp_limb_t [5]) __GMP_ATTRIBUTE_PURE; #endif #ifndef mpn_mod_1s_3p_cps /* if not done with cpuvec in a fat binary */ #define mpn_mod_1s_3p_cps __MPN(mod_1s_3p_cps) __GMP_DECLSPEC void mpn_mod_1s_3p_cps (mp_limb_t [6], mp_limb_t); #endif #ifndef mpn_mod_1s_3p /* if not done with cpuvec in a fat binary */ #define mpn_mod_1s_3p __MPN(mod_1s_3p) __GMP_DECLSPEC mp_limb_t mpn_mod_1s_3p (mp_srcptr, mp_size_t, mp_limb_t, const mp_limb_t [6]) __GMP_ATTRIBUTE_PURE; #endif #ifndef mpn_mod_1s_4p_cps /* if not done with cpuvec in a fat binary */ #define mpn_mod_1s_4p_cps __MPN(mod_1s_4p_cps) __GMP_DECLSPEC void mpn_mod_1s_4p_cps (mp_limb_t [7], mp_limb_t); #endif #ifndef mpn_mod_1s_4p /* if not done with cpuvec in a fat binary */ #define mpn_mod_1s_4p __MPN(mod_1s_4p) __GMP_DECLSPEC mp_limb_t mpn_mod_1s_4p (mp_srcptr, mp_size_t, mp_limb_t, const mp_limb_t [7]) __GMP_ATTRIBUTE_PURE; #endif #define mpn_bc_mulmod_bnm1 __MPN(bc_mulmod_bnm1) __GMP_DECLSPEC void mpn_bc_mulmod_bnm1 (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mulmod_bnm1 __MPN(mulmod_bnm1) __GMP_DECLSPEC void mpn_mulmod_bnm1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mulmod_bnm1_next_size __MPN(mulmod_bnm1_next_size) __GMP_DECLSPEC mp_size_t mpn_mulmod_bnm1_next_size (mp_size_t) ATTRIBUTE_CONST; static inline mp_size_t mpn_mulmod_bnm1_itch (mp_size_t rn, mp_size_t an, mp_size_t bn) { mp_size_t n, itch; n = rn >> 1; itch = rn + 4 + (an > n ? (bn > n ? rn : n) : 0); return itch; } #define mpn_sqrmod_bnm1 __MPN(sqrmod_bnm1) __GMP_DECLSPEC void mpn_sqrmod_bnm1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_sqrmod_bnm1_next_size __MPN(sqrmod_bnm1_next_size) __GMP_DECLSPEC mp_size_t mpn_sqrmod_bnm1_next_size (mp_size_t) ATTRIBUTE_CONST; static inline mp_size_t mpn_sqrmod_bnm1_itch (mp_size_t rn, mp_size_t an) { mp_size_t n, itch; n = rn >> 1; itch = rn + 3 + (an > n ? an : 0); return itch; } typedef __gmp_randstate_struct *gmp_randstate_ptr; typedef const __gmp_randstate_struct *gmp_randstate_srcptr; /* Pseudo-random number generator function pointers structure. */ typedef struct { void (*randseed_fn) (gmp_randstate_t, mpz_srcptr); void (*randget_fn) (gmp_randstate_t, mp_ptr, unsigned long int); void (*randclear_fn) (gmp_randstate_t); void (*randiset_fn) (gmp_randstate_ptr, gmp_randstate_srcptr); } gmp_randfnptr_t; /* Macro to obtain a void pointer to the function pointers structure. */ #define RNG_FNPTR(rstate) ((rstate)->_mp_algdata._mp_lc) /* Macro to obtain a pointer to the generator's state. When used as a lvalue the rvalue needs to be cast to mp_ptr. */ #define RNG_STATE(rstate) ((rstate)->_mp_seed->_mp_d) /* Write a given number of random bits to rp. */ #define _gmp_rand(rp, state, bits) \ do { \ gmp_randstate_ptr __rstate = (state); \ (*((gmp_randfnptr_t *) RNG_FNPTR (__rstate))->randget_fn) \ (__rstate, rp, bits); \ } while (0) __GMP_DECLSPEC void __gmp_randinit_mt_noseed (gmp_randstate_t); /* __gmp_rands is the global state for the old-style random functions, and is also used in the test programs (hence the __GMP_DECLSPEC). There's no seeding here, so mpz_random etc will generate the same sequence every time. This is not unlike the C library random functions if you don't seed them, so perhaps it's acceptable. Digging up a seed from /dev/random or the like would work on many systems, but might encourage a false confidence, since it'd be pretty much impossible to do something that would work reliably everywhere. In any case the new style functions are recommended to applications which care about randomness, so the old functions aren't too important. */ __GMP_DECLSPEC extern char __gmp_rands_initialized; __GMP_DECLSPEC extern gmp_randstate_t __gmp_rands; #define RANDS \ ((__gmp_rands_initialized ? 0 \ : (__gmp_rands_initialized = 1, \ __gmp_randinit_mt_noseed (__gmp_rands), 0)), \ __gmp_rands) /* this is used by the test programs, to free memory */ #define RANDS_CLEAR() \ do { \ if (__gmp_rands_initialized) \ { \ __gmp_rands_initialized = 0; \ gmp_randclear (__gmp_rands); \ } \ } while (0) /* For a threshold between algorithms A and B, size>=thresh is where B should be used. Special value MP_SIZE_T_MAX means only ever use A, or value 0 means only ever use B. The tests for these special values will be compile-time constants, so the compiler should be able to eliminate the code for the unwanted algorithm. */ #if ! defined (__GNUC__) || __GNUC__ < 2 #define ABOVE_THRESHOLD(size,thresh) \ ((thresh) == 0 \ || ((thresh) != MP_SIZE_T_MAX \ && (size) >= (thresh))) #else #define ABOVE_THRESHOLD(size,thresh) \ ((__builtin_constant_p (thresh) && (thresh) == 0) \ || (!(__builtin_constant_p (thresh) && (thresh) == MP_SIZE_T_MAX) \ && (size) >= (thresh))) #endif #define BELOW_THRESHOLD(size,thresh) (! ABOVE_THRESHOLD (size, thresh)) #define MPN_TOOM22_MUL_MINSIZE 4 #define MPN_TOOM2_SQR_MINSIZE 4 #define MPN_TOOM33_MUL_MINSIZE 17 #define MPN_TOOM3_SQR_MINSIZE 17 #define MPN_TOOM44_MUL_MINSIZE 30 #define MPN_TOOM4_SQR_MINSIZE 30 #define MPN_TOOM6H_MUL_MINSIZE 46 #define MPN_TOOM6_SQR_MINSIZE 46 #define MPN_TOOM8H_MUL_MINSIZE 86 #define MPN_TOOM8_SQR_MINSIZE 86 #define MPN_TOOM32_MUL_MINSIZE 10 #define MPN_TOOM42_MUL_MINSIZE 10 #define MPN_TOOM43_MUL_MINSIZE 25 #define MPN_TOOM53_MUL_MINSIZE 17 #define MPN_TOOM54_MUL_MINSIZE 31 #define MPN_TOOM63_MUL_MINSIZE 49 #define MPN_TOOM42_MULMID_MINSIZE 4 #define mpn_sqr_diagonal __MPN(sqr_diagonal) __GMP_DECLSPEC void mpn_sqr_diagonal (mp_ptr, mp_srcptr, mp_size_t); #define mpn_sqr_diag_addlsh1 __MPN(sqr_diag_addlsh1) __GMP_DECLSPEC void mpn_sqr_diag_addlsh1 (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); #define mpn_toom_interpolate_5pts __MPN(toom_interpolate_5pts) __GMP_DECLSPEC void mpn_toom_interpolate_5pts (mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_size_t, int, mp_limb_t); enum toom6_flags {toom6_all_pos = 0, toom6_vm1_neg = 1, toom6_vm2_neg = 2}; #define mpn_toom_interpolate_6pts __MPN(toom_interpolate_6pts) __GMP_DECLSPEC void mpn_toom_interpolate_6pts (mp_ptr, mp_size_t, enum toom6_flags, mp_ptr, mp_ptr, mp_ptr, mp_size_t); enum toom7_flags { toom7_w1_neg = 1, toom7_w3_neg = 2 }; #define mpn_toom_interpolate_7pts __MPN(toom_interpolate_7pts) __GMP_DECLSPEC void mpn_toom_interpolate_7pts (mp_ptr, mp_size_t, enum toom7_flags, mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_ptr); #define mpn_toom_interpolate_8pts __MPN(toom_interpolate_8pts) __GMP_DECLSPEC void mpn_toom_interpolate_8pts (mp_ptr, mp_size_t, mp_ptr, mp_ptr, mp_size_t, mp_ptr); #define mpn_toom_interpolate_12pts __MPN(toom_interpolate_12pts) __GMP_DECLSPEC void mpn_toom_interpolate_12pts (mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_size_t, int, mp_ptr); #define mpn_toom_interpolate_16pts __MPN(toom_interpolate_16pts) __GMP_DECLSPEC void mpn_toom_interpolate_16pts (mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_size_t, int, mp_ptr); #define mpn_toom_couple_handling __MPN(toom_couple_handling) __GMP_DECLSPEC void mpn_toom_couple_handling (mp_ptr, mp_size_t, mp_ptr, int, mp_size_t, int, int); #define mpn_toom_eval_dgr3_pm1 __MPN(toom_eval_dgr3_pm1) __GMP_DECLSPEC int mpn_toom_eval_dgr3_pm1 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_size_t, mp_ptr); #define mpn_toom_eval_dgr3_pm2 __MPN(toom_eval_dgr3_pm2) __GMP_DECLSPEC int mpn_toom_eval_dgr3_pm2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_size_t, mp_ptr); #define mpn_toom_eval_pm1 __MPN(toom_eval_pm1) __GMP_DECLSPEC int mpn_toom_eval_pm1 (mp_ptr, mp_ptr, unsigned, mp_srcptr, mp_size_t, mp_size_t, mp_ptr); #define mpn_toom_eval_pm2 __MPN(toom_eval_pm2) __GMP_DECLSPEC int mpn_toom_eval_pm2 (mp_ptr, mp_ptr, unsigned, mp_srcptr, mp_size_t, mp_size_t, mp_ptr); #define mpn_toom_eval_pm2exp __MPN(toom_eval_pm2exp) __GMP_DECLSPEC int mpn_toom_eval_pm2exp (mp_ptr, mp_ptr, unsigned, mp_srcptr, mp_size_t, mp_size_t, unsigned, mp_ptr); #define mpn_toom_eval_pm2rexp __MPN(toom_eval_pm2rexp) __GMP_DECLSPEC int mpn_toom_eval_pm2rexp (mp_ptr, mp_ptr, unsigned, mp_srcptr, mp_size_t, mp_size_t, unsigned, mp_ptr); #define mpn_toom22_mul __MPN(toom22_mul) __GMP_DECLSPEC void mpn_toom22_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom32_mul __MPN(toom32_mul) __GMP_DECLSPEC void mpn_toom32_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom42_mul __MPN(toom42_mul) __GMP_DECLSPEC void mpn_toom42_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom52_mul __MPN(toom52_mul) __GMP_DECLSPEC void mpn_toom52_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom62_mul __MPN(toom62_mul) __GMP_DECLSPEC void mpn_toom62_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom2_sqr __MPN(toom2_sqr) __GMP_DECLSPEC void mpn_toom2_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom33_mul __MPN(toom33_mul) __GMP_DECLSPEC void mpn_toom33_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom43_mul __MPN(toom43_mul) __GMP_DECLSPEC void mpn_toom43_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom53_mul __MPN(toom53_mul) __GMP_DECLSPEC void mpn_toom53_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom54_mul __MPN(toom54_mul) __GMP_DECLSPEC void mpn_toom54_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom63_mul __MPN(toom63_mul) __GMP_DECLSPEC void mpn_toom63_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom3_sqr __MPN(toom3_sqr) __GMP_DECLSPEC void mpn_toom3_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom44_mul __MPN(toom44_mul) __GMP_DECLSPEC void mpn_toom44_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom4_sqr __MPN(toom4_sqr) __GMP_DECLSPEC void mpn_toom4_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom6h_mul __MPN(toom6h_mul) __GMP_DECLSPEC void mpn_toom6h_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom6_sqr __MPN(toom6_sqr) __GMP_DECLSPEC void mpn_toom6_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom8h_mul __MPN(toom8h_mul) __GMP_DECLSPEC void mpn_toom8h_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom8_sqr __MPN(toom8_sqr) __GMP_DECLSPEC void mpn_toom8_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_toom42_mulmid __MPN(toom42_mulmid) __GMP_DECLSPEC void mpn_toom42_mulmid (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_fft_best_k __MPN(fft_best_k) __GMP_DECLSPEC int mpn_fft_best_k (mp_size_t, int) ATTRIBUTE_CONST; #define mpn_mul_fft __MPN(mul_fft) __GMP_DECLSPEC mp_limb_t mpn_mul_fft (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, int); #define mpn_mul_fft_full __MPN(mul_fft_full) __GMP_DECLSPEC void mpn_mul_fft_full (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_nussbaumer_mul __MPN(nussbaumer_mul) __GMP_DECLSPEC void mpn_nussbaumer_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_fft_next_size __MPN(fft_next_size) __GMP_DECLSPEC mp_size_t mpn_fft_next_size (mp_size_t, int) ATTRIBUTE_CONST; #define mpn_div_qr_1n_pi1 __MPN(div_qr_1n_pi1) __GMP_DECLSPEC mp_limb_t mpn_div_qr_1n_pi1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, mp_limb_t); #define mpn_div_qr_2n_pi1 __MPN(div_qr_2n_pi1) __GMP_DECLSPEC mp_limb_t mpn_div_qr_2n_pi1 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, mp_limb_t); #define mpn_div_qr_2u_pi1 __MPN(div_qr_2u_pi1) __GMP_DECLSPEC mp_limb_t mpn_div_qr_2u_pi1 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, int, mp_limb_t); #define mpn_sbpi1_div_qr __MPN(sbpi1_div_qr) __GMP_DECLSPEC mp_limb_t mpn_sbpi1_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_sbpi1_div_q __MPN(sbpi1_div_q) __GMP_DECLSPEC mp_limb_t mpn_sbpi1_div_q (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_sbpi1_divappr_q __MPN(sbpi1_divappr_q) __GMP_DECLSPEC mp_limb_t mpn_sbpi1_divappr_q (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_dcpi1_div_qr __MPN(dcpi1_div_qr) __GMP_DECLSPEC mp_limb_t mpn_dcpi1_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, gmp_pi1_t *); #define mpn_dcpi1_div_qr_n __MPN(dcpi1_div_qr_n) __GMP_DECLSPEC mp_limb_t mpn_dcpi1_div_qr_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, gmp_pi1_t *, mp_ptr); #define mpn_dcpi1_div_q __MPN(dcpi1_div_q) __GMP_DECLSPEC mp_limb_t mpn_dcpi1_div_q (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, gmp_pi1_t *); #define mpn_dcpi1_divappr_q __MPN(dcpi1_divappr_q) __GMP_DECLSPEC mp_limb_t mpn_dcpi1_divappr_q (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, gmp_pi1_t *); #define mpn_dcpi1_divappr_q_n __MPN(dcpi1_divappr_q_n) __GMP_DECLSPEC mp_limb_t mpn_dcpi1_divappr_q_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, gmp_pi1_t *, mp_ptr); #define mpn_mu_div_qr __MPN(mu_div_qr) __GMP_DECLSPEC mp_limb_t mpn_mu_div_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mu_div_qr_itch __MPN(mu_div_qr_itch) __GMP_DECLSPEC mp_size_t mpn_mu_div_qr_itch (mp_size_t, mp_size_t, int) ATTRIBUTE_CONST; #define mpn_mu_div_qr_choose_in __MPN(mu_div_qr_choose_in) __GMP_DECLSPEC mp_size_t mpn_mu_div_qr_choose_in (mp_size_t, mp_size_t, int); #define mpn_preinv_mu_div_qr __MPN(preinv_mu_div_qr) __GMP_DECLSPEC mp_limb_t mpn_preinv_mu_div_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_preinv_mu_div_qr_itch __MPN(preinv_mu_div_qr_itch) __GMP_DECLSPEC mp_size_t mpn_preinv_mu_div_qr_itch (mp_size_t, mp_size_t, mp_size_t) ATTRIBUTE_CONST; #define mpn_mu_divappr_q __MPN(mu_divappr_q) __GMP_DECLSPEC mp_limb_t mpn_mu_divappr_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mu_divappr_q_itch __MPN(mu_divappr_q_itch) __GMP_DECLSPEC mp_size_t mpn_mu_divappr_q_itch (mp_size_t, mp_size_t, int) ATTRIBUTE_CONST; #define mpn_mu_divappr_q_choose_in __MPN(mu_divappr_q_choose_in) __GMP_DECLSPEC mp_size_t mpn_mu_divappr_q_choose_in (mp_size_t, mp_size_t, int); #define mpn_preinv_mu_divappr_q __MPN(preinv_mu_divappr_q) __GMP_DECLSPEC mp_limb_t mpn_preinv_mu_divappr_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mu_div_q __MPN(mu_div_q) __GMP_DECLSPEC mp_limb_t mpn_mu_div_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mu_div_q_itch __MPN(mu_div_q_itch) __GMP_DECLSPEC mp_size_t mpn_mu_div_q_itch (mp_size_t, mp_size_t, int) ATTRIBUTE_CONST; #define mpn_div_q __MPN(div_q) __GMP_DECLSPEC void mpn_div_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_invert __MPN(invert) __GMP_DECLSPEC void mpn_invert (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_invert_itch(n) mpn_invertappr_itch(n) #define mpn_ni_invertappr __MPN(ni_invertappr) __GMP_DECLSPEC mp_limb_t mpn_ni_invertappr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_invertappr __MPN(invertappr) __GMP_DECLSPEC mp_limb_t mpn_invertappr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_invertappr_itch(n) (2 * (n)) #define mpn_binvert __MPN(binvert) __GMP_DECLSPEC void mpn_binvert (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_binvert_itch __MPN(binvert_itch) __GMP_DECLSPEC mp_size_t mpn_binvert_itch (mp_size_t) ATTRIBUTE_CONST; #define mpn_bdiv_q_1 __MPN(bdiv_q_1) __GMP_DECLSPEC mp_limb_t mpn_bdiv_q_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_pi1_bdiv_q_1 __MPN(pi1_bdiv_q_1) __GMP_DECLSPEC mp_limb_t mpn_pi1_bdiv_q_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, int); #define mpn_sbpi1_bdiv_qr __MPN(sbpi1_bdiv_qr) __GMP_DECLSPEC mp_limb_t mpn_sbpi1_bdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_sbpi1_bdiv_q __MPN(sbpi1_bdiv_q) __GMP_DECLSPEC void mpn_sbpi1_bdiv_q (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_dcpi1_bdiv_qr __MPN(dcpi1_bdiv_qr) __GMP_DECLSPEC mp_limb_t mpn_dcpi1_bdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_dcpi1_bdiv_qr_n_itch __MPN(dcpi1_bdiv_qr_n_itch) __GMP_DECLSPEC mp_size_t mpn_dcpi1_bdiv_qr_n_itch (mp_size_t) ATTRIBUTE_CONST; #define mpn_dcpi1_bdiv_qr_n __MPN(dcpi1_bdiv_qr_n) __GMP_DECLSPEC mp_limb_t mpn_dcpi1_bdiv_qr_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); #define mpn_dcpi1_bdiv_q __MPN(dcpi1_bdiv_q) __GMP_DECLSPEC void mpn_dcpi1_bdiv_q (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_dcpi1_bdiv_q_n __MPN(dcpi1_bdiv_q_n) __GMP_DECLSPEC void mpn_dcpi1_bdiv_q_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); #define mpn_dcpi1_bdiv_q_n_itch __MPN(dcpi1_bdiv_q_n_itch) __GMP_DECLSPEC mp_size_t mpn_dcpi1_bdiv_q_n_itch (mp_size_t) ATTRIBUTE_CONST; #define mpn_mu_bdiv_qr __MPN(mu_bdiv_qr) __GMP_DECLSPEC mp_limb_t mpn_mu_bdiv_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mu_bdiv_qr_itch __MPN(mu_bdiv_qr_itch) __GMP_DECLSPEC mp_size_t mpn_mu_bdiv_qr_itch (mp_size_t, mp_size_t) ATTRIBUTE_CONST; #define mpn_mu_bdiv_q __MPN(mu_bdiv_q) __GMP_DECLSPEC void mpn_mu_bdiv_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_mu_bdiv_q_itch __MPN(mu_bdiv_q_itch) __GMP_DECLSPEC mp_size_t mpn_mu_bdiv_q_itch (mp_size_t, mp_size_t) ATTRIBUTE_CONST; #define mpn_bdiv_qr __MPN(bdiv_qr) __GMP_DECLSPEC mp_limb_t mpn_bdiv_qr (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_bdiv_qr_itch __MPN(bdiv_qr_itch) __GMP_DECLSPEC mp_size_t mpn_bdiv_qr_itch (mp_size_t, mp_size_t) ATTRIBUTE_CONST; #define mpn_bdiv_q __MPN(bdiv_q) __GMP_DECLSPEC void mpn_bdiv_q (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_bdiv_q_itch __MPN(bdiv_q_itch) __GMP_DECLSPEC mp_size_t mpn_bdiv_q_itch (mp_size_t, mp_size_t) ATTRIBUTE_CONST; #define mpn_divexact __MPN(divexact) __GMP_DECLSPEC void mpn_divexact (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); #define mpn_divexact_itch __MPN(divexact_itch) __GMP_DECLSPEC mp_size_t mpn_divexact_itch (mp_size_t, mp_size_t) ATTRIBUTE_CONST; #ifndef mpn_bdiv_dbm1c /* if not done with cpuvec in a fat binary */ #define mpn_bdiv_dbm1c __MPN(bdiv_dbm1c) __GMP_DECLSPEC mp_limb_t mpn_bdiv_dbm1c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t); #endif #define mpn_bdiv_dbm1(dst, src, size, divisor) \ mpn_bdiv_dbm1c (dst, src, size, divisor, __GMP_CAST (mp_limb_t, 0)) #define mpn_powm __MPN(powm) __GMP_DECLSPEC void mpn_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); #define mpn_powlo __MPN(powlo) __GMP_DECLSPEC void mpn_powlo (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_size_t, mp_ptr); #define mpn_sec_pi1_div_qr __MPN(sec_pi1_div_qr) __GMP_DECLSPEC mp_limb_t mpn_sec_pi1_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); #define mpn_sec_pi1_div_r __MPN(sec_pi1_div_r) __GMP_DECLSPEC void mpn_sec_pi1_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); /* Override mpn_addlsh1_n, mpn_addlsh2_n, mpn_sublsh1_n, etc with mpn_addlsh_n, etc when !HAVE_NATIVE the former but HAVE_NATIVE_ the latter. We then lie and say these macros represent native functions, but leave a trace by using the value 2 rather than 1. */ #if HAVE_NATIVE_mpn_addlsh_n && ! HAVE_NATIVE_mpn_addlsh1_n #undef mpn_addlsh1_n #define mpn_addlsh1_n(a,b,c,d) mpn_addlsh_n(a,b,c,d,1) #define HAVE_NATIVE_mpn_addlsh1_n 2 #endif #if HAVE_NATIVE_mpn_addlsh_n && ! HAVE_NATIVE_mpn_addlsh2_n #undef mpn_addlsh2_n #define mpn_addlsh2_n(a,b,c,d) mpn_addlsh_n(a,b,c,d,2) #define HAVE_NATIVE_mpn_addlsh2_n 2 #endif #if HAVE_NATIVE_mpn_sublsh_n && ! HAVE_NATIVE_mpn_sublsh1_n #undef mpn_sublsh1_n #define mpn_sublsh1_n(a,b,c,d) mpn_sublsh_n(a,b,c,d,1) #define HAVE_NATIVE_mpn_sublsh1_n 2 #endif #if HAVE_NATIVE_mpn_sublsh_n && ! HAVE_NATIVE_mpn_sublsh2_n #undef mpn_sublsh2_n #define mpn_sublsh2_n(a,b,c,d) mpn_sublsh_n(a,b,c,d,2) #define HAVE_NATIVE_mpn_sublsh2_n 2 #endif #if HAVE_NATIVE_mpn_rsblsh_n && ! HAVE_NATIVE_mpn_rsblsh1_n #undef mpn_rsblsh1_n #define mpn_rsblsh1_n(a,b,c,d) mpn_rsblsh_n(a,b,c,d,1) #define HAVE_NATIVE_mpn_rsblsh1_n 2 #endif #if HAVE_NATIVE_mpn_rsblsh_n && ! HAVE_NATIVE_mpn_rsblsh2_n #undef mpn_rsblsh2_n #define mpn_rsblsh2_n(a,b,c,d) mpn_rsblsh_n(a,b,c,d,2) #define HAVE_NATIVE_mpn_rsblsh2_n 2 #endif #ifndef DIVEXACT_BY3_METHOD #if GMP_NUMB_BITS % 2 == 0 && ! defined (HAVE_NATIVE_mpn_divexact_by3c) #define DIVEXACT_BY3_METHOD 0 /* default to using mpn_bdiv_dbm1c */ #else #define DIVEXACT_BY3_METHOD 1 #endif #endif #if DIVEXACT_BY3_METHOD == 0 #undef mpn_divexact_by3 #define mpn_divexact_by3(dst,src,size) \ (3 & mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 3))) /* override mpn_divexact_by3c defined in gmp.h */ /* #undef mpn_divexact_by3c #define mpn_divexact_by3c(dst,src,size,cy) \ (3 & mpn_bdiv_dbm1c (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 3, GMP_NUMB_MASK / 3 * cy))) */ #endif #if GMP_NUMB_BITS % 4 == 0 #define mpn_divexact_by5(dst,src,size) \ (7 & 3 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 5))) #endif #if GMP_NUMB_BITS % 3 == 0 #define mpn_divexact_by7(dst,src,size) \ (7 & 1 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 7))) #endif #if GMP_NUMB_BITS % 6 == 0 #define mpn_divexact_by9(dst,src,size) \ (15 & 7 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 9))) #endif #if GMP_NUMB_BITS % 10 == 0 #define mpn_divexact_by11(dst,src,size) \ (15 & 5 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 11))) #endif #if GMP_NUMB_BITS % 12 == 0 #define mpn_divexact_by13(dst,src,size) \ (15 & 3 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 13))) #endif #if GMP_NUMB_BITS % 4 == 0 #define mpn_divexact_by15(dst,src,size) \ (15 & 1 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 15))) #endif #define mpz_divexact_gcd __gmpz_divexact_gcd __GMP_DECLSPEC void mpz_divexact_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr); #define mpz_prodlimbs __gmpz_prodlimbs __GMP_DECLSPEC mp_size_t mpz_prodlimbs (mpz_ptr, mp_ptr, mp_size_t); #define mpz_oddfac_1 __gmpz_oddfac_1 __GMP_DECLSPEC void mpz_oddfac_1 (mpz_ptr, mp_limb_t, unsigned); #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite #ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC size_t mpz_inp_str_nowhite (mpz_ptr, FILE *, int, int, size_t); #endif #define mpn_divisible_p __MPN(divisible_p) __GMP_DECLSPEC int mpn_divisible_p (mp_srcptr, mp_size_t, mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; #define mpn_rootrem __MPN(rootrem) __GMP_DECLSPEC mp_size_t mpn_rootrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_broot __MPN(broot) __GMP_DECLSPEC void mpn_broot (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_broot_invm1 __MPN(broot_invm1) __GMP_DECLSPEC void mpn_broot_invm1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); #define mpn_brootinv __MPN(brootinv) __GMP_DECLSPEC void mpn_brootinv (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); #define mpn_bsqrt __MPN(bsqrt) __GMP_DECLSPEC void mpn_bsqrt (mp_ptr, mp_srcptr, mp_bitcnt_t, mp_ptr); #define mpn_bsqrtinv __MPN(bsqrtinv) __GMP_DECLSPEC int mpn_bsqrtinv (mp_ptr, mp_srcptr, mp_bitcnt_t, mp_ptr); #if defined (_CRAY) #define MPN_COPY_INCR(dst, src, n) \ do { \ int __i; /* Faster on some Crays with plain int */ \ _Pragma ("_CRI ivdep"); \ for (__i = 0; __i < (n); __i++) \ (dst)[__i] = (src)[__i]; \ } while (0) #endif /* used by test programs, hence __GMP_DECLSPEC */ #ifndef mpn_copyi /* if not done with cpuvec in a fat binary */ #define mpn_copyi __MPN(copyi) __GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t); #endif #if ! defined (MPN_COPY_INCR) && HAVE_NATIVE_mpn_copyi #define MPN_COPY_INCR(dst, src, size) \ do { \ ASSERT ((size) >= 0); \ ASSERT (MPN_SAME_OR_INCR_P (dst, src, size)); \ mpn_copyi (dst, src, size); \ } while (0) #endif /* Copy N limbs from SRC to DST incrementing, N==0 allowed. */ #if ! defined (MPN_COPY_INCR) #define MPN_COPY_INCR(dst, src, n) \ do { \ ASSERT ((n) >= 0); \ ASSERT (MPN_SAME_OR_INCR_P (dst, src, n)); \ if ((n) != 0) \ { \ mp_size_t __n = (n) - 1; \ mp_ptr __dst = (dst); \ mp_srcptr __src = (src); \ mp_limb_t __x; \ __x = *__src++; \ if (__n != 0) \ { \ do \ { \ *__dst++ = __x; \ __x = *__src++; \ } \ while (--__n); \ } \ *__dst++ = __x; \ } \ } while (0) #endif #if defined (_CRAY) #define MPN_COPY_DECR(dst, src, n) \ do { \ int __i; /* Faster on some Crays with plain int */ \ _Pragma ("_CRI ivdep"); \ for (__i = (n) - 1; __i >= 0; __i--) \ (dst)[__i] = (src)[__i]; \ } while (0) #endif /* used by test programs, hence __GMP_DECLSPEC */ #ifndef mpn_copyd /* if not done with cpuvec in a fat binary */ #define mpn_copyd __MPN(copyd) __GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t); #endif #if ! defined (MPN_COPY_DECR) && HAVE_NATIVE_mpn_copyd #define MPN_COPY_DECR(dst, src, size) \ do { \ ASSERT ((size) >= 0); \ ASSERT (MPN_SAME_OR_DECR_P (dst, src, size)); \ mpn_copyd (dst, src, size); \ } while (0) #endif /* Copy N limbs from SRC to DST decrementing, N==0 allowed. */ #if ! defined (MPN_COPY_DECR) #define MPN_COPY_DECR(dst, src, n) \ do { \ ASSERT ((n) >= 0); \ ASSERT (MPN_SAME_OR_DECR_P (dst, src, n)); \ if ((n) != 0) \ { \ mp_size_t __n = (n) - 1; \ mp_ptr __dst = (dst) + __n; \ mp_srcptr __src = (src) + __n; \ mp_limb_t __x; \ __x = *__src--; \ if (__n != 0) \ { \ do \ { \ *__dst-- = __x; \ __x = *__src--; \ } \ while (--__n); \ } \ *__dst-- = __x; \ } \ } while (0) #endif #ifndef MPN_COPY #define MPN_COPY(d,s,n) \ do { \ ASSERT (MPN_SAME_OR_SEPARATE_P (d, s, n)); \ MPN_COPY_INCR (d, s, n); \ } while (0) #endif /* Set {dst,size} to the limbs of {src,size} in reverse order. */ #define MPN_REVERSE(dst, src, size) \ do { \ mp_ptr __dst = (dst); \ mp_size_t __size = (size); \ mp_srcptr __src = (src) + __size - 1; \ mp_size_t __i; \ ASSERT ((size) >= 0); \ ASSERT (! MPN_OVERLAP_P (dst, size, src, size)); \ CRAY_Pragma ("_CRI ivdep"); \ for (__i = 0; __i < __size; __i++) \ { \ *__dst = *__src; \ __dst++; \ __src--; \ } \ } while (0) /* Zero n limbs at dst. For power and powerpc we want an inline stu/bdnz loop for zeroing. On ppc630 for instance this is optimal since it can sustain only 1 store per cycle. gcc 2.95.x (for powerpc64 -maix64, or powerpc32) doesn't recognise the "for" loop in the generic code below can become stu/bdnz. The do/while here helps it get to that. The same caveat about plain -mpowerpc64 mode applies here as to __GMPN_COPY_INCR in gmp.h. xlc 3.1 already generates stu/bdnz from the generic C, and does so from this loop too. Enhancement: GLIBC does some trickery with dcbz to zero whole cache lines at a time. MPN_ZERO isn't all that important in GMP, so it might be more trouble than it's worth to do the same, though perhaps a call to memset would be good when on a GNU system. */ #if HAVE_HOST_CPU_FAMILY_power || HAVE_HOST_CPU_FAMILY_powerpc #define MPN_FILL(dst, n, f) \ do { \ mp_ptr __dst = (dst) - 1; \ mp_size_t __n = (n); \ ASSERT (__n > 0); \ do \ *++__dst = (f); \ while (--__n); \ } while (0) #endif #ifndef MPN_FILL #define MPN_FILL(dst, n, f) \ do { \ mp_ptr __dst = (dst); \ mp_size_t __n = (n); \ ASSERT (__n > 0); \ do \ *__dst++ = (f); \ while (--__n); \ } while (0) #endif #define MPN_ZERO(dst, n) \ do { \ ASSERT ((n) >= 0); \ if ((n) != 0) \ MPN_FILL (dst, n, CNST_LIMB (0)); \ } while (0) /* On the x86s repe/scasl doesn't seem useful, since it takes many cycles to start up and would need to strip a lot of zeros before it'd be faster than a simple cmpl loop. Here are some times in cycles for std/repe/scasl/cld and cld/repe/scasl (the latter would be for stripping low zeros). std cld P5 18 16 P6 46 38 K6 36 13 K7 21 20 */ #ifndef MPN_NORMALIZE #define MPN_NORMALIZE(DST, NLIMBS) \ do { \ while ((NLIMBS) > 0) \ { \ if ((DST)[(NLIMBS) - 1] != 0) \ break; \ (NLIMBS)--; \ } \ } while (0) #endif #ifndef MPN_NORMALIZE_NOT_ZERO #define MPN_NORMALIZE_NOT_ZERO(DST, NLIMBS) \ do { \ while (1) \ { \ ASSERT ((NLIMBS) >= 1); \ if ((DST)[(NLIMBS) - 1] != 0) \ break; \ (NLIMBS)--; \ } \ } while (0) #endif /* Strip least significant zero limbs from {ptr,size} by incrementing ptr and decrementing size. low should be ptr[0], and will be the new ptr[0] on returning. The number in {ptr,size} must be non-zero, ie. size!=0 and somewhere a non-zero limb. */ #define MPN_STRIP_LOW_ZEROS_NOT_ZERO(ptr, size, low) \ do { \ ASSERT ((size) >= 1); \ ASSERT ((low) == (ptr)[0]); \ \ while ((low) == 0) \ { \ (size)--; \ ASSERT ((size) >= 1); \ (ptr)++; \ (low) = *(ptr); \ } \ } while (0) /* Initialize X of type mpz_t with space for NLIMBS limbs. X should be a temporary variable; it will be automatically cleared out at function return. We use __x here to make it possible to accept both mpz_ptr and mpz_t arguments. */ #define MPZ_TMP_INIT(X, NLIMBS) \ do { \ mpz_ptr __x = (X); \ ASSERT ((NLIMBS) >= 1); \ __x->_mp_alloc = (NLIMBS); \ __x->_mp_d = TMP_ALLOC_LIMBS (NLIMBS); \ } while (0) #if WANT_ASSERT static inline void * _mpz_newalloc (mpz_ptr z, mp_size_t n) { void * res = _mpz_realloc(z,n); /* If we are checking the code, force a random change to limbs. */ ((mp_ptr) res)[0] = ~ ((mp_ptr) res)[ALLOC (z) - 1]; return res; } #else #define _mpz_newalloc _mpz_realloc #endif /* Realloc for an mpz_t WHAT if it has less than NEEDED limbs. */ #define MPZ_REALLOC(z,n) (UNLIKELY ((n) > ALLOC(z)) \ ? (mp_ptr) _mpz_realloc(z,n) \ : PTR(z)) #define MPZ_NEWALLOC(z,n) (UNLIKELY ((n) > ALLOC(z)) \ ? (mp_ptr) _mpz_newalloc(z,n) \ : PTR(z)) #define MPZ_EQUAL_1_P(z) (SIZ(z)==1 && PTR(z)[0] == 1) /* MPN_FIB2_SIZE(n) is the size in limbs required by mpn_fib2_ui for fp and f1p. From Knuth vol 1 section 1.2.8, F[n] = phi^n/sqrt(5) rounded to the nearest integer, where phi=(1+sqrt(5))/2 is the golden ratio. So the number of bits required is n*log_2((1+sqrt(5))/2) = n*0.6942419. The multiplier used is 23/32=0.71875 for efficient calculation on CPUs without good floating point. There's +2 for rounding up, and a further +2 since at the last step x limbs are doubled into a 2x+1 limb region whereas the actual F[2k] value might be only 2x-1 limbs. Note that a division is done first, since on a 32-bit system it's at least conceivable to go right up to n==ULONG_MAX. (F[2^32-1] would be about 380Mbytes, plus temporary workspace of about 1.2Gbytes here and whatever a multiply of two 190Mbyte numbers takes.) Enhancement: When GMP_NUMB_BITS is not a power of 2 the division could be worked into the multiplier. */ #define MPN_FIB2_SIZE(n) \ ((mp_size_t) ((n) / 32 * 23 / GMP_NUMB_BITS) + 4) /* FIB_TABLE(n) returns the Fibonacci number F[n]. Must have n in the range -1 <= n <= FIB_TABLE_LIMIT (that constant in fib_table.h). FIB_TABLE_LUCNUM_LIMIT (in fib_table.h) is the largest n for which L[n] = F[n] + 2*F[n-1] fits in a limb. */ __GMP_DECLSPEC extern const mp_limb_t __gmp_fib_table[]; #define FIB_TABLE(n) (__gmp_fib_table[(n)+1]) extern const mp_limb_t __gmp_oddfac_table[]; extern const mp_limb_t __gmp_odd2fac_table[]; extern const unsigned char __gmp_fac2cnt_table[]; extern const mp_limb_t __gmp_limbroots_table[]; /* n^log <= GMP_NUMB_MAX, a limb can store log factors less than n */ static inline unsigned log_n_max (mp_limb_t n) { unsigned log; for (log = 8; n > __gmp_limbroots_table[log - 1]; log--); return log; } #define SIEVESIZE 512 /* FIXME: Allow gmp_init_primesieve to choose */ typedef struct { unsigned long d; /* current index in s[] */ unsigned long s0; /* number corresponding to s[0] */ unsigned long sqrt_s0; /* misnomer for sqrt(s[SIEVESIZE-1]) */ unsigned char s[SIEVESIZE + 1]; /* sieve table */ } gmp_primesieve_t; #define gmp_init_primesieve __gmp_init_primesieve __GMP_DECLSPEC void gmp_init_primesieve (gmp_primesieve_t *); #define gmp_nextprime __gmp_nextprime __GMP_DECLSPEC unsigned long int gmp_nextprime (gmp_primesieve_t *); #define gmp_primesieve __gmp_primesieve __GMP_DECLSPEC mp_limb_t gmp_primesieve (mp_ptr, mp_limb_t); #ifndef MUL_TOOM22_THRESHOLD #define MUL_TOOM22_THRESHOLD 30 #endif #ifndef MUL_TOOM33_THRESHOLD #define MUL_TOOM33_THRESHOLD 100 #endif #ifndef MUL_TOOM44_THRESHOLD #define MUL_TOOM44_THRESHOLD 300 #endif #ifndef MUL_TOOM6H_THRESHOLD #define MUL_TOOM6H_THRESHOLD 350 #endif #ifndef SQR_TOOM6_THRESHOLD #define SQR_TOOM6_THRESHOLD MUL_TOOM6H_THRESHOLD #endif #ifndef MUL_TOOM8H_THRESHOLD #define MUL_TOOM8H_THRESHOLD 450 #endif #ifndef SQR_TOOM8_THRESHOLD #define SQR_TOOM8_THRESHOLD MUL_TOOM8H_THRESHOLD #endif #ifndef MUL_TOOM32_TO_TOOM43_THRESHOLD #define MUL_TOOM32_TO_TOOM43_THRESHOLD 100 #endif #ifndef MUL_TOOM32_TO_TOOM53_THRESHOLD #define MUL_TOOM32_TO_TOOM53_THRESHOLD 110 #endif #ifndef MUL_TOOM42_TO_TOOM53_THRESHOLD #define MUL_TOOM42_TO_TOOM53_THRESHOLD 100 #endif #ifndef MUL_TOOM42_TO_TOOM63_THRESHOLD #define MUL_TOOM42_TO_TOOM63_THRESHOLD 110 #endif #ifndef MUL_TOOM43_TO_TOOM54_THRESHOLD #define MUL_TOOM43_TO_TOOM54_THRESHOLD 150 #endif /* MUL_TOOM22_THRESHOLD_LIMIT is the maximum for MUL_TOOM22_THRESHOLD. In a normal build MUL_TOOM22_THRESHOLD is a constant and we use that. In a fat binary or tune program build MUL_TOOM22_THRESHOLD is a variable and a separate hard limit will have been defined. Similarly for TOOM3. */ #ifndef MUL_TOOM22_THRESHOLD_LIMIT #define MUL_TOOM22_THRESHOLD_LIMIT MUL_TOOM22_THRESHOLD #endif #ifndef MUL_TOOM33_THRESHOLD_LIMIT #define MUL_TOOM33_THRESHOLD_LIMIT MUL_TOOM33_THRESHOLD #endif #ifndef MULLO_BASECASE_THRESHOLD_LIMIT #define MULLO_BASECASE_THRESHOLD_LIMIT MULLO_BASECASE_THRESHOLD #endif #ifndef SQRLO_BASECASE_THRESHOLD_LIMIT #define SQRLO_BASECASE_THRESHOLD_LIMIT SQRLO_BASECASE_THRESHOLD #endif #ifndef SQRLO_DC_THRESHOLD_LIMIT #define SQRLO_DC_THRESHOLD_LIMIT SQRLO_DC_THRESHOLD #endif /* SQR_BASECASE_THRESHOLD is where mpn_sqr_basecase should take over from mpn_mul_basecase. Default is to use mpn_sqr_basecase from 0. (Note that we certainly always want it if there's a native assembler mpn_sqr_basecase.) If it turns out that mpn_toom2_sqr becomes faster than mpn_mul_basecase before mpn_sqr_basecase does, then SQR_BASECASE_THRESHOLD is the toom2 threshold and SQR_TOOM2_THRESHOLD is 0. This oddity arises more or less because SQR_TOOM2_THRESHOLD represents the size up to which mpn_sqr_basecase should be used, and that may be never. */ #ifndef SQR_BASECASE_THRESHOLD #define SQR_BASECASE_THRESHOLD 0 /* never use mpn_mul_basecase */ #endif #ifndef SQR_TOOM2_THRESHOLD #define SQR_TOOM2_THRESHOLD 50 #endif #ifndef SQR_TOOM3_THRESHOLD #define SQR_TOOM3_THRESHOLD 120 #endif #ifndef SQR_TOOM4_THRESHOLD #define SQR_TOOM4_THRESHOLD 400 #endif /* See comments above about MUL_TOOM33_THRESHOLD_LIMIT. */ #ifndef SQR_TOOM3_THRESHOLD_LIMIT #define SQR_TOOM3_THRESHOLD_LIMIT SQR_TOOM3_THRESHOLD #endif #ifndef MULMID_TOOM42_THRESHOLD #define MULMID_TOOM42_THRESHOLD MUL_TOOM22_THRESHOLD #endif #ifndef MULLO_BASECASE_THRESHOLD #define MULLO_BASECASE_THRESHOLD 0 /* never use mpn_mul_basecase */ #endif #ifndef MULLO_DC_THRESHOLD #define MULLO_DC_THRESHOLD (2*MUL_TOOM22_THRESHOLD) #endif #ifndef MULLO_MUL_N_THRESHOLD #define MULLO_MUL_N_THRESHOLD (2*MUL_FFT_THRESHOLD) #endif #ifndef SQRLO_BASECASE_THRESHOLD #define SQRLO_BASECASE_THRESHOLD 0 /* never use mpn_sqr_basecase */ #endif #ifndef SQRLO_DC_THRESHOLD #define SQRLO_DC_THRESHOLD (MULLO_DC_THRESHOLD) #endif #ifndef SQRLO_SQR_THRESHOLD #define SQRLO_SQR_THRESHOLD (MULLO_MUL_N_THRESHOLD) #endif #ifndef DC_DIV_QR_THRESHOLD #define DC_DIV_QR_THRESHOLD (2*MUL_TOOM22_THRESHOLD) #endif #ifndef DC_DIVAPPR_Q_THRESHOLD #define DC_DIVAPPR_Q_THRESHOLD 200 #endif #ifndef DC_BDIV_QR_THRESHOLD #define DC_BDIV_QR_THRESHOLD (2*MUL_TOOM22_THRESHOLD) #endif #ifndef DC_BDIV_Q_THRESHOLD #define DC_BDIV_Q_THRESHOLD 180 #endif #ifndef DIVEXACT_JEB_THRESHOLD #define DIVEXACT_JEB_THRESHOLD 25 #endif #ifndef INV_MULMOD_BNM1_THRESHOLD #define INV_MULMOD_BNM1_THRESHOLD (4*MULMOD_BNM1_THRESHOLD) #endif #ifndef INV_APPR_THRESHOLD #define INV_APPR_THRESHOLD INV_NEWTON_THRESHOLD #endif #ifndef INV_NEWTON_THRESHOLD #define INV_NEWTON_THRESHOLD 200 #endif #ifndef BINV_NEWTON_THRESHOLD #define BINV_NEWTON_THRESHOLD 300 #endif #ifndef MU_DIVAPPR_Q_THRESHOLD #define MU_DIVAPPR_Q_THRESHOLD 2000 #endif #ifndef MU_DIV_QR_THRESHOLD #define MU_DIV_QR_THRESHOLD 2000 #endif #ifndef MUPI_DIV_QR_THRESHOLD #define MUPI_DIV_QR_THRESHOLD 200 #endif #ifndef MU_BDIV_Q_THRESHOLD #define MU_BDIV_Q_THRESHOLD 2000 #endif #ifndef MU_BDIV_QR_THRESHOLD #define MU_BDIV_QR_THRESHOLD 2000 #endif #ifndef MULMOD_BNM1_THRESHOLD #define MULMOD_BNM1_THRESHOLD 16 #endif #ifndef SQRMOD_BNM1_THRESHOLD #define SQRMOD_BNM1_THRESHOLD 16 #endif #ifndef MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD #define MUL_TO_MULMOD_BNM1_FOR_2NXN_THRESHOLD (INV_MULMOD_BNM1_THRESHOLD/2) #endif #if HAVE_NATIVE_mpn_addmul_2 || HAVE_NATIVE_mpn_redc_2 #ifndef REDC_1_TO_REDC_2_THRESHOLD #define REDC_1_TO_REDC_2_THRESHOLD 15 #endif #ifndef REDC_2_TO_REDC_N_THRESHOLD #define REDC_2_TO_REDC_N_THRESHOLD 100 #endif #else #ifndef REDC_1_TO_REDC_N_THRESHOLD #define REDC_1_TO_REDC_N_THRESHOLD 100 #endif #endif /* HAVE_NATIVE_mpn_addmul_2 || HAVE_NATIVE_mpn_redc_2 */ /* First k to use for an FFT modF multiply. A modF FFT is an order log(2^k)/log(2^(k-1)) algorithm, so k=3 is merely 1.5 like karatsuba, whereas k=4 is 1.33 which is faster than toom3 at 1.485. */ #define FFT_FIRST_K 4 /* Threshold at which FFT should be used to do a modF NxN -> N multiply. */ #ifndef MUL_FFT_MODF_THRESHOLD #define MUL_FFT_MODF_THRESHOLD (MUL_TOOM33_THRESHOLD * 3) #endif #ifndef SQR_FFT_MODF_THRESHOLD #define SQR_FFT_MODF_THRESHOLD (SQR_TOOM3_THRESHOLD * 3) #endif /* Threshold at which FFT should be used to do an NxN -> 2N multiply. This will be a size where FFT is using k=7 or k=8, since an FFT-k used for an NxN->2N multiply and not recursing into itself is an order log(2^k)/log(2^(k-2)) algorithm, so it'll be at least k=7 at 1.39 which is the first better than toom3. */ #ifndef MUL_FFT_THRESHOLD #define MUL_FFT_THRESHOLD (MUL_FFT_MODF_THRESHOLD * 10) #endif #ifndef SQR_FFT_THRESHOLD #define SQR_FFT_THRESHOLD (SQR_FFT_MODF_THRESHOLD * 10) #endif /* Table of thresholds for successive modF FFT "k"s. The first entry is where FFT_FIRST_K+1 should be used, the second FFT_FIRST_K+2, etc. See mpn_fft_best_k(). */ #ifndef MUL_FFT_TABLE #define MUL_FFT_TABLE \ { MUL_TOOM33_THRESHOLD * 4, /* k=5 */ \ MUL_TOOM33_THRESHOLD * 8, /* k=6 */ \ MUL_TOOM33_THRESHOLD * 16, /* k=7 */ \ MUL_TOOM33_THRESHOLD * 32, /* k=8 */ \ MUL_TOOM33_THRESHOLD * 96, /* k=9 */ \ MUL_TOOM33_THRESHOLD * 288, /* k=10 */ \ 0 } #endif #ifndef SQR_FFT_TABLE #define SQR_FFT_TABLE \ { SQR_TOOM3_THRESHOLD * 4, /* k=5 */ \ SQR_TOOM3_THRESHOLD * 8, /* k=6 */ \ SQR_TOOM3_THRESHOLD * 16, /* k=7 */ \ SQR_TOOM3_THRESHOLD * 32, /* k=8 */ \ SQR_TOOM3_THRESHOLD * 96, /* k=9 */ \ SQR_TOOM3_THRESHOLD * 288, /* k=10 */ \ 0 } #endif struct fft_table_nk { unsigned int n:27; unsigned int k:5; }; #ifndef FFT_TABLE_ATTRS #define FFT_TABLE_ATTRS static const #endif #define MPN_FFT_TABLE_SIZE 16 #ifndef DC_DIV_QR_THRESHOLD #define DC_DIV_QR_THRESHOLD (3 * MUL_TOOM22_THRESHOLD) #endif #ifndef GET_STR_DC_THRESHOLD #define GET_STR_DC_THRESHOLD 18 #endif #ifndef GET_STR_PRECOMPUTE_THRESHOLD #define GET_STR_PRECOMPUTE_THRESHOLD 35 #endif #ifndef SET_STR_DC_THRESHOLD #define SET_STR_DC_THRESHOLD 750 #endif #ifndef SET_STR_PRECOMPUTE_THRESHOLD #define SET_STR_PRECOMPUTE_THRESHOLD 2000 #endif #ifndef FAC_ODD_THRESHOLD #define FAC_ODD_THRESHOLD 35 #endif #ifndef FAC_DSC_THRESHOLD #define FAC_DSC_THRESHOLD 400 #endif /* Return non-zero if xp,xsize and yp,ysize overlap. If xp+xsize<=yp there's no overlap, or if yp+ysize<=xp there's no overlap. If both these are false, there's an overlap. */ #define MPN_OVERLAP_P(xp, xsize, yp, ysize) \ ((xp) + (xsize) > (yp) && (yp) + (ysize) > (xp)) #define MEM_OVERLAP_P(xp, xsize, yp, ysize) \ ( (char *) (xp) + (xsize) > (char *) (yp) \ && (char *) (yp) + (ysize) > (char *) (xp)) /* Return non-zero if xp,xsize and yp,ysize are either identical or not overlapping. Return zero if they're partially overlapping. */ #define MPN_SAME_OR_SEPARATE_P(xp, yp, size) \ MPN_SAME_OR_SEPARATE2_P(xp, size, yp, size) #define MPN_SAME_OR_SEPARATE2_P(xp, xsize, yp, ysize) \ ((xp) == (yp) || ! MPN_OVERLAP_P (xp, xsize, yp, ysize)) /* Return non-zero if dst,dsize and src,ssize are either identical or overlapping in a way suitable for an incrementing/decrementing algorithm. Return zero if they're partially overlapping in an unsuitable fashion. */ #define MPN_SAME_OR_INCR2_P(dst, dsize, src, ssize) \ ((dst) <= (src) || ! MPN_OVERLAP_P (dst, dsize, src, ssize)) #define MPN_SAME_OR_INCR_P(dst, src, size) \ MPN_SAME_OR_INCR2_P(dst, size, src, size) #define MPN_SAME_OR_DECR2_P(dst, dsize, src, ssize) \ ((dst) >= (src) || ! MPN_OVERLAP_P (dst, dsize, src, ssize)) #define MPN_SAME_OR_DECR_P(dst, src, size) \ MPN_SAME_OR_DECR2_P(dst, size, src, size) /* ASSERT() is a private assertion checking scheme, similar to . ASSERT() does the check only if WANT_ASSERT is selected, ASSERT_ALWAYS() does it always. Generally assertions are meant for development, but might help when looking for a problem later too. */ #ifdef __LINE__ #define ASSERT_LINE __LINE__ #else #define ASSERT_LINE -1 #endif #ifdef __FILE__ #define ASSERT_FILE __FILE__ #else #define ASSERT_FILE "" #endif __GMP_DECLSPEC void __gmp_assert_header (const char *, int); __GMP_DECLSPEC void __gmp_assert_fail (const char *, int, const char *) ATTRIBUTE_NORETURN; #define ASSERT_FAIL(expr) __gmp_assert_fail (ASSERT_FILE, ASSERT_LINE, #expr) #define ASSERT_ALWAYS(expr) \ do { \ if (UNLIKELY (!(expr))) \ ASSERT_FAIL (expr); \ } while (0) #if WANT_ASSERT #define ASSERT(expr) ASSERT_ALWAYS (expr) #else #define ASSERT(expr) do {} while (0) #endif /* ASSERT_CARRY checks the expression is non-zero, and ASSERT_NOCARRY checks that it's zero. In both cases if assertion checking is disabled the expression is still evaluated. These macros are meant for use with routines like mpn_add_n() where the return value represents a carry or whatever that should or shouldn't occur in some context. For example, ASSERT_NOCARRY (mpn_add_n (rp, s1p, s2p, size)); */ #if WANT_ASSERT #define ASSERT_CARRY(expr) ASSERT_ALWAYS ((expr) != 0) #define ASSERT_NOCARRY(expr) ASSERT_ALWAYS ((expr) == 0) #else #define ASSERT_CARRY(expr) (expr) #define ASSERT_NOCARRY(expr) (expr) #endif /* ASSERT_CODE includes code when assertion checking is wanted. This is the same as writing "#if WANT_ASSERT", but more compact. */ #if WANT_ASSERT #define ASSERT_CODE(expr) expr #else #define ASSERT_CODE(expr) #endif /* Test that an mpq_t is in fully canonical form. This can be used as protection on routines like mpq_equal which give wrong results on non-canonical inputs. */ #if WANT_ASSERT #define ASSERT_MPQ_CANONICAL(q) \ do { \ ASSERT (q->_mp_den._mp_size > 0); \ if (q->_mp_num._mp_size == 0) \ { \ /* zero should be 0/1 */ \ ASSERT (mpz_cmp_ui (mpq_denref(q), 1L) == 0); \ } \ else \ { \ /* no common factors */ \ mpz_t __g; \ mpz_init (__g); \ mpz_gcd (__g, mpq_numref(q), mpq_denref(q)); \ ASSERT (mpz_cmp_ui (__g, 1) == 0); \ mpz_clear (__g); \ } \ } while (0) #else #define ASSERT_MPQ_CANONICAL(q) do {} while (0) #endif /* Check that the nail parts are zero. */ #define ASSERT_ALWAYS_LIMB(limb) \ do { \ mp_limb_t __nail = (limb) & GMP_NAIL_MASK; \ ASSERT_ALWAYS (__nail == 0); \ } while (0) #define ASSERT_ALWAYS_MPN(ptr, size) \ do { \ /* let whole loop go dead when no nails */ \ if (GMP_NAIL_BITS != 0) \ { \ mp_size_t __i; \ for (__i = 0; __i < (size); __i++) \ ASSERT_ALWAYS_LIMB ((ptr)[__i]); \ } \ } while (0) #if WANT_ASSERT #define ASSERT_LIMB(limb) ASSERT_ALWAYS_LIMB (limb) #define ASSERT_MPN(ptr, size) ASSERT_ALWAYS_MPN (ptr, size) #else #define ASSERT_LIMB(limb) do {} while (0) #define ASSERT_MPN(ptr, size) do {} while (0) #endif /* Assert that an mpn region {ptr,size} is zero, or non-zero. size==0 is allowed, and in that case {ptr,size} considered to be zero. */ #if WANT_ASSERT #define ASSERT_MPN_ZERO_P(ptr,size) \ do { \ mp_size_t __i; \ ASSERT ((size) >= 0); \ for (__i = 0; __i < (size); __i++) \ ASSERT ((ptr)[__i] == 0); \ } while (0) #define ASSERT_MPN_NONZERO_P(ptr,size) \ do { \ mp_size_t __i; \ int __nonzero = 0; \ ASSERT ((size) >= 0); \ for (__i = 0; __i < (size); __i++) \ if ((ptr)[__i] != 0) \ { \ __nonzero = 1; \ break; \ } \ ASSERT (__nonzero); \ } while (0) #else #define ASSERT_MPN_ZERO_P(ptr,size) do {} while (0) #define ASSERT_MPN_NONZERO_P(ptr,size) do {} while (0) #endif #if ! HAVE_NATIVE_mpn_com #undef mpn_com #define mpn_com(d,s,n) \ do { \ mp_ptr __d = (d); \ mp_srcptr __s = (s); \ mp_size_t __n = (n); \ ASSERT (__n >= 1); \ ASSERT (MPN_SAME_OR_SEPARATE_P (__d, __s, __n)); \ do \ *__d++ = (~ *__s++) & GMP_NUMB_MASK; \ while (--__n); \ } while (0) #endif #define MPN_LOGOPS_N_INLINE(rp, up, vp, n, operation) \ do { \ mp_srcptr __up = (up); \ mp_srcptr __vp = (vp); \ mp_ptr __rp = (rp); \ mp_size_t __n = (n); \ mp_limb_t __a, __b; \ ASSERT (__n > 0); \ ASSERT (MPN_SAME_OR_SEPARATE_P (__rp, __up, __n)); \ ASSERT (MPN_SAME_OR_SEPARATE_P (__rp, __vp, __n)); \ __up += __n; \ __vp += __n; \ __rp += __n; \ __n = -__n; \ do { \ __a = __up[__n]; \ __b = __vp[__n]; \ __rp[__n] = operation; \ } while (++__n); \ } while (0) #if ! HAVE_NATIVE_mpn_and_n #undef mpn_and_n #define mpn_and_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, __a & __b) #endif #if ! HAVE_NATIVE_mpn_andn_n #undef mpn_andn_n #define mpn_andn_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, __a & ~__b) #endif #if ! HAVE_NATIVE_mpn_nand_n #undef mpn_nand_n #define mpn_nand_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, ~(__a & __b) & GMP_NUMB_MASK) #endif #if ! HAVE_NATIVE_mpn_ior_n #undef mpn_ior_n #define mpn_ior_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, __a | __b) #endif #if ! HAVE_NATIVE_mpn_iorn_n #undef mpn_iorn_n #define mpn_iorn_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, (__a | ~__b) & GMP_NUMB_MASK) #endif #if ! HAVE_NATIVE_mpn_nior_n #undef mpn_nior_n #define mpn_nior_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, ~(__a | __b) & GMP_NUMB_MASK) #endif #if ! HAVE_NATIVE_mpn_xor_n #undef mpn_xor_n #define mpn_xor_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, __a ^ __b) #endif #if ! HAVE_NATIVE_mpn_xnor_n #undef mpn_xnor_n #define mpn_xnor_n(rp, up, vp, n) \ MPN_LOGOPS_N_INLINE (rp, up, vp, n, ~(__a ^ __b) & GMP_NUMB_MASK) #endif #define mpn_trialdiv __MPN(trialdiv) __GMP_DECLSPEC mp_limb_t mpn_trialdiv (mp_srcptr, mp_size_t, mp_size_t, int *); #define mpn_remove __MPN(remove) __GMP_DECLSPEC mp_bitcnt_t mpn_remove (mp_ptr, mp_size_t *, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_bitcnt_t); /* ADDC_LIMB sets w=x+y and cout to 0 or 1 for a carry from that addition. */ #if GMP_NAIL_BITS == 0 #define ADDC_LIMB(cout, w, x, y) \ do { \ mp_limb_t __x = (x); \ mp_limb_t __y = (y); \ mp_limb_t __w = __x + __y; \ (w) = __w; \ (cout) = __w < __x; \ } while (0) #else #define ADDC_LIMB(cout, w, x, y) \ do { \ mp_limb_t __w; \ ASSERT_LIMB (x); \ ASSERT_LIMB (y); \ __w = (x) + (y); \ (w) = __w & GMP_NUMB_MASK; \ (cout) = __w >> GMP_NUMB_BITS; \ } while (0) #endif /* SUBC_LIMB sets w=x-y and cout to 0 or 1 for a borrow from that subtract. */ #if GMP_NAIL_BITS == 0 #define SUBC_LIMB(cout, w, x, y) \ do { \ mp_limb_t __x = (x); \ mp_limb_t __y = (y); \ mp_limb_t __w = __x - __y; \ (w) = __w; \ (cout) = __w > __x; \ } while (0) #else #define SUBC_LIMB(cout, w, x, y) \ do { \ mp_limb_t __w = (x) - (y); \ (w) = __w & GMP_NUMB_MASK; \ (cout) = __w >> (GMP_LIMB_BITS-1); \ } while (0) #endif /* MPN_INCR_U does {ptr,size} += n, MPN_DECR_U does {ptr,size} -= n, both expecting no carry (or borrow) from that. The size parameter is only for the benefit of assertion checking. In a normal build it's unused and the carry/borrow is just propagated as far as it needs to go. On random data, usually only one or two limbs of {ptr,size} get updated, so there's no need for any sophisticated looping, just something compact and sensible. FIXME: Switch all code from mpn_{incr,decr}_u to MPN_{INCR,DECR}_U, declaring their operand sizes, then remove the former. This is purely for the benefit of assertion checking. */ #if defined (__GNUC__) && GMP_NAIL_BITS == 0 && ! defined (NO_ASM) \ && (defined(HAVE_HOST_CPU_FAMILY_x86) || defined(HAVE_HOST_CPU_FAMILY_x86_64)) \ && ! WANT_ASSERT /* Better flags handling than the generic C gives on i386, saving a few bytes of code and maybe a cycle or two. */ #define MPN_IORD_U(ptr, incr, aors) \ do { \ mp_ptr __ptr_dummy; \ if (__builtin_constant_p (incr) && (incr) == 0) \ { \ } \ else if (__builtin_constant_p (incr) && (incr) == 1) \ { \ __asm__ __volatile__ \ ("\n" ASM_L(top) ":\n" \ "\t" aors "\t$1, (%0)\n" \ "\tlea\t%c2(%0), %0\n" \ "\tjc\t" ASM_L(top) \ : "=r" (__ptr_dummy) \ : "0" (ptr), "n" (sizeof(mp_limb_t)) \ : "memory"); \ } \ else \ { \ __asm__ __volatile__ \ ( aors "\t%2, (%0)\n" \ "\tjnc\t" ASM_L(done) "\n" \ ASM_L(top) ":\n" \ "\t" aors "\t$1, %c3(%0)\n" \ "\tlea\t%c3(%0), %0\n" \ "\tjc\t" ASM_L(top) "\n" \ ASM_L(done) ":\n" \ : "=r" (__ptr_dummy) \ : "0" (ptr), \ "ri" ((mp_limb_t) (incr)), "n" (sizeof(mp_limb_t)) \ : "memory"); \ } \ } while (0) #if GMP_LIMB_BITS == 32 #define MPN_INCR_U(ptr, size, incr) MPN_IORD_U (ptr, incr, "addl") #define MPN_DECR_U(ptr, size, incr) MPN_IORD_U (ptr, incr, "subl") #endif #if GMP_LIMB_BITS == 64 #define MPN_INCR_U(ptr, size, incr) MPN_IORD_U (ptr, incr, "addq") #define MPN_DECR_U(ptr, size, incr) MPN_IORD_U (ptr, incr, "subq") #endif #define mpn_incr_u(ptr, incr) MPN_INCR_U (ptr, 0, incr) #define mpn_decr_u(ptr, incr) MPN_DECR_U (ptr, 0, incr) #endif #if GMP_NAIL_BITS == 0 #ifndef mpn_incr_u #define mpn_incr_u(p,incr) \ do { \ mp_limb_t __x; \ mp_ptr __p = (p); \ if (__builtin_constant_p (incr) && (incr) == 1) \ { \ while (++(*(__p++)) == 0) \ ; \ } \ else \ { \ __x = *__p + (incr); \ *__p = __x; \ if (__x < (incr)) \ while (++(*(++__p)) == 0) \ ; \ } \ } while (0) #endif #ifndef mpn_decr_u #define mpn_decr_u(p,incr) \ do { \ mp_limb_t __x; \ mp_ptr __p = (p); \ if (__builtin_constant_p (incr) && (incr) == 1) \ { \ while ((*(__p++))-- == 0) \ ; \ } \ else \ { \ __x = *__p; \ *__p = __x - (incr); \ if (__x < (incr)) \ while ((*(++__p))-- == 0) \ ; \ } \ } while (0) #endif #endif #if GMP_NAIL_BITS >= 1 #ifndef mpn_incr_u #define mpn_incr_u(p,incr) \ do { \ mp_limb_t __x; \ mp_ptr __p = (p); \ if (__builtin_constant_p (incr) && (incr) == 1) \ { \ do \ { \ __x = (*__p + 1) & GMP_NUMB_MASK; \ *__p++ = __x; \ } \ while (__x == 0); \ } \ else \ { \ __x = (*__p + (incr)); \ *__p++ = __x & GMP_NUMB_MASK; \ if (__x >> GMP_NUMB_BITS != 0) \ { \ do \ { \ __x = (*__p + 1) & GMP_NUMB_MASK; \ *__p++ = __x; \ } \ while (__x == 0); \ } \ } \ } while (0) #endif #ifndef mpn_decr_u #define mpn_decr_u(p,incr) \ do { \ mp_limb_t __x; \ mp_ptr __p = (p); \ if (__builtin_constant_p (incr) && (incr) == 1) \ { \ do \ { \ __x = *__p; \ *__p++ = (__x - 1) & GMP_NUMB_MASK; \ } \ while (__x == 0); \ } \ else \ { \ __x = *__p - (incr); \ *__p++ = __x & GMP_NUMB_MASK; \ if (__x >> GMP_NUMB_BITS != 0) \ { \ do \ { \ __x = *__p; \ *__p++ = (__x - 1) & GMP_NUMB_MASK; \ } \ while (__x == 0); \ } \ } \ } while (0) #endif #endif #ifndef MPN_INCR_U #if WANT_ASSERT #define MPN_INCR_U(ptr, size, n) \ do { \ ASSERT ((size) >= 1); \ ASSERT_NOCARRY (mpn_add_1 (ptr, ptr, size, n)); \ } while (0) #else #define MPN_INCR_U(ptr, size, n) mpn_incr_u (ptr, n) #endif #endif #ifndef MPN_DECR_U #if WANT_ASSERT #define MPN_DECR_U(ptr, size, n) \ do { \ ASSERT ((size) >= 1); \ ASSERT_NOCARRY (mpn_sub_1 (ptr, ptr, size, n)); \ } while (0) #else #define MPN_DECR_U(ptr, size, n) mpn_decr_u (ptr, n) #endif #endif /* Structure for conversion between internal binary format and strings. */ struct bases { /* Number of digits in the conversion base that always fits in an mp_limb_t. For example, for base 10 on a machine where an mp_limb_t has 32 bits this is 9, since 10**9 is the largest number that fits into an mp_limb_t. */ int chars_per_limb; /* log(2)/log(conversion_base) */ mp_limb_t logb2; /* log(conversion_base)/log(2) */ mp_limb_t log2b; /* base**chars_per_limb, i.e. the biggest number that fits a word, built by factors of base. Exception: For 2, 4, 8, etc, big_base is log2(base), i.e. the number of bits used to represent each digit in the base. */ mp_limb_t big_base; /* A GMP_LIMB_BITS bit approximation to 1/big_base, represented as a fixed-point number. Instead of dividing by big_base an application can choose to multiply by big_base_inverted. */ mp_limb_t big_base_inverted; }; #define mp_bases __MPN(bases) __GMP_DECLSPEC extern const struct bases mp_bases[257]; /* Compute the number of digits in base for nbits bits, making sure the result is never too small. The two variants of the macro implement the same function; the GT2 variant below works just for bases > 2. */ #define DIGITS_IN_BASE_FROM_BITS(res, nbits, b) \ do { \ mp_limb_t _ph, _dummy; \ size_t _nbits = (nbits); \ umul_ppmm (_ph, _dummy, mp_bases[b].logb2, _nbits); \ _ph += (_dummy + _nbits < _dummy); \ res = _ph + 1; \ } while (0) #define DIGITS_IN_BASEGT2_FROM_BITS(res, nbits, b) \ do { \ mp_limb_t _ph, _dummy; \ size_t _nbits = (nbits); \ umul_ppmm (_ph, _dummy, mp_bases[b].logb2 + 1, _nbits); \ res = _ph + 1; \ } while (0) /* For power of 2 bases this is exact. For other bases the result is either exact or one too big. To be exact always it'd be necessary to examine all the limbs of the operand, since numbers like 100..000 and 99...999 generally differ only in the lowest limb. It'd be possible to examine just a couple of high limbs to increase the probability of being exact, but that doesn't seem worth bothering with. */ #define MPN_SIZEINBASE(result, ptr, size, base) \ do { \ int __lb_base, __cnt; \ size_t __totbits; \ \ ASSERT ((size) >= 0); \ ASSERT ((base) >= 2); \ ASSERT ((base) < numberof (mp_bases)); \ \ /* Special case for X == 0. */ \ if ((size) == 0) \ (result) = 1; \ else \ { \ /* Calculate the total number of significant bits of X. */ \ count_leading_zeros (__cnt, (ptr)[(size)-1]); \ __totbits = (size_t) (size) * GMP_NUMB_BITS - (__cnt - GMP_NAIL_BITS);\ \ if (POW2_P (base)) \ { \ __lb_base = mp_bases[base].big_base; \ (result) = (__totbits + __lb_base - 1) / __lb_base; \ } \ else \ { \ DIGITS_IN_BASEGT2_FROM_BITS (result, __totbits, base); \ } \ } \ } while (0) #define MPN_SIZEINBASE_2EXP(result, ptr, size, base2exp) \ do { \ int __cnt; \ mp_bitcnt_t __totbits; \ ASSERT ((size) > 0); \ ASSERT ((ptr)[(size)-1] != 0); \ count_leading_zeros (__cnt, (ptr)[(size)-1]); \ __totbits = (mp_bitcnt_t) (size) * GMP_NUMB_BITS - (__cnt - GMP_NAIL_BITS); \ (result) = (__totbits + (base2exp)-1) / (base2exp); \ } while (0) /* bit count to limb count, rounding up */ #define BITS_TO_LIMBS(n) (((n) + (GMP_NUMB_BITS - 1)) / GMP_NUMB_BITS) /* MPN_SET_UI sets an mpn (ptr, cnt) to given ui. MPZ_FAKE_UI creates fake mpz_t from ui. The zp argument must have room for LIMBS_PER_ULONG limbs in both cases (LIMBS_PER_ULONG is also defined here.) */ #if BITS_PER_ULONG <= GMP_NUMB_BITS /* need one limb per ulong */ #define LIMBS_PER_ULONG 1 #define MPN_SET_UI(zp, zn, u) \ (zp)[0] = (u); \ (zn) = ((zp)[0] != 0); #define MPZ_FAKE_UI(z, zp, u) \ (zp)[0] = (u); \ PTR (z) = (zp); \ SIZ (z) = ((zp)[0] != 0); \ ASSERT_CODE (ALLOC (z) = 1); #else /* need two limbs per ulong */ #define LIMBS_PER_ULONG 2 #define MPN_SET_UI(zp, zn, u) \ (zp)[0] = (u) & GMP_NUMB_MASK; \ (zp)[1] = (u) >> GMP_NUMB_BITS; \ (zn) = ((zp)[1] != 0 ? 2 : (zp)[0] != 0 ? 1 : 0); #define MPZ_FAKE_UI(z, zp, u) \ (zp)[0] = (u) & GMP_NUMB_MASK; \ (zp)[1] = (u) >> GMP_NUMB_BITS; \ SIZ (z) = ((zp)[1] != 0 ? 2 : (zp)[0] != 0 ? 1 : 0); \ PTR (z) = (zp); \ ASSERT_CODE (ALLOC (z) = 2); #endif #if HAVE_HOST_CPU_FAMILY_x86 #define TARGET_REGISTER_STARVED 1 #else #define TARGET_REGISTER_STARVED 0 #endif /* LIMB_HIGHBIT_TO_MASK(n) examines the high bit of a limb value and turns 1 or 0 there into a limb 0xFF..FF or 0 respectively. On most CPUs this is just an arithmetic right shift by GMP_LIMB_BITS-1, but C99 doesn't guarantee signed right shifts are arithmetic, so we have a little compile-time test and a fallback to a "? :" form. The latter is necessary for instance on Cray vector systems. Recent versions of gcc (eg. 3.3) will in fact optimize a "? :" like this to an arithmetic right shift anyway, but it's good to get the desired shift on past versions too (in particular since an important use of LIMB_HIGHBIT_TO_MASK is in udiv_qrnnd_preinv). */ #define LIMB_HIGHBIT_TO_MASK(n) \ (((mp_limb_signed_t) -1 >> 1) < 0 \ ? (mp_limb_signed_t) (n) >> (GMP_LIMB_BITS - 1) \ : (n) & GMP_LIMB_HIGHBIT ? MP_LIMB_T_MAX : CNST_LIMB(0)) /* Use a library function for invert_limb, if available. */ #define mpn_invert_limb __MPN(invert_limb) __GMP_DECLSPEC mp_limb_t mpn_invert_limb (mp_limb_t) ATTRIBUTE_CONST; #if ! defined (invert_limb) && HAVE_NATIVE_mpn_invert_limb #define invert_limb(invxl,xl) \ do { \ (invxl) = mpn_invert_limb (xl); \ } while (0) #endif #ifndef invert_limb #define invert_limb(invxl,xl) \ do { \ mp_limb_t _dummy; \ ASSERT ((xl) != 0); \ udiv_qrnnd (invxl, _dummy, ~(xl), ~CNST_LIMB(0), xl); \ } while (0) #endif #define invert_pi1(dinv, d1, d0) \ do { \ mp_limb_t _v, _p, _t1, _t0, _mask; \ invert_limb (_v, d1); \ _p = (d1) * _v; \ _p += (d0); \ if (_p < (d0)) \ { \ _v--; \ _mask = -(mp_limb_t) (_p >= (d1)); \ _p -= (d1); \ _v += _mask; \ _p -= _mask & (d1); \ } \ umul_ppmm (_t1, _t0, d0, _v); \ _p += _t1; \ if (_p < _t1) \ { \ _v--; \ if (UNLIKELY (_p >= (d1))) \ { \ if (_p > (d1) || _t0 >= (d0)) \ _v--; \ } \ } \ (dinv).inv32 = _v; \ } while (0) /* udiv_qrnnd_preinv -- Based on work by Niels Möller and Torbjörn Granlund. We write things strangely below, to help gcc. A more straightforward version: _r = (nl) - _qh * (d); _t = _r + (d); if (_r >= _ql) { _qh--; _r = _t; } For one operation shorter critical path, one may want to use this form: _p = _qh * (d) _s = (nl) + (d); _r = (nl) - _p; _t = _s - _p; if (_r >= _ql) { _qh--; _r = _t; } */ #define udiv_qrnnd_preinv(q, r, nh, nl, d, di) \ do { \ mp_limb_t _qh, _ql, _r, _mask; \ umul_ppmm (_qh, _ql, (nh), (di)); \ if (__builtin_constant_p (nl) && (nl) == 0) \ { \ _qh += (nh) + 1; \ _r = - _qh * (d); \ _mask = -(mp_limb_t) (_r > _ql); /* both > and >= are OK */ \ _qh += _mask; \ _r += _mask & (d); \ } \ else \ { \ add_ssaaaa (_qh, _ql, _qh, _ql, (nh) + 1, (nl)); \ _r = (nl) - _qh * (d); \ _mask = -(mp_limb_t) (_r > _ql); /* both > and >= are OK */ \ _qh += _mask; \ _r += _mask & (d); \ if (UNLIKELY (_r >= (d))) \ { \ _r -= (d); \ _qh++; \ } \ } \ (r) = _r; \ (q) = _qh; \ } while (0) /* Dividing (NH, NL) by D, returning the remainder only. Unlike udiv_qrnnd_preinv, works also for the case NH == D, where the quotient doesn't quite fit in a single limb. */ #define udiv_rnnd_preinv(r, nh, nl, d, di) \ do { \ mp_limb_t _qh, _ql, _r, _mask; \ umul_ppmm (_qh, _ql, (nh), (di)); \ if (__builtin_constant_p (nl) && (nl) == 0) \ { \ _r = ~(_qh + (nh)) * (d); \ _mask = -(mp_limb_t) (_r > _ql); /* both > and >= are OK */ \ _r += _mask & (d); \ } \ else \ { \ add_ssaaaa (_qh, _ql, _qh, _ql, (nh) + 1, (nl)); \ _r = (nl) - _qh * (d); \ _mask = -(mp_limb_t) (_r > _ql); /* both > and >= are OK */ \ _r += _mask & (d); \ if (UNLIKELY (_r >= (d))) \ _r -= (d); \ } \ (r) = _r; \ } while (0) /* Compute quotient the quotient and remainder for n / d. Requires d >= B^2 / 2 and n < d B. di is the inverse floor ((B^3 - 1) / (d0 + d1 B)) - B. NOTE: Output variables are updated multiple times. Only some inputs and outputs may overlap. */ #define udiv_qr_3by2(q, r1, r0, n2, n1, n0, d1, d0, dinv) \ do { \ mp_limb_t _q0, _t1, _t0, _mask; \ umul_ppmm ((q), _q0, (n2), (dinv)); \ add_ssaaaa ((q), _q0, (q), _q0, (n2), (n1)); \ \ /* Compute the two most significant limbs of n - q'd */ \ (r1) = (n1) - (d1) * (q); \ sub_ddmmss ((r1), (r0), (r1), (n0), (d1), (d0)); \ umul_ppmm (_t1, _t0, (d0), (q)); \ sub_ddmmss ((r1), (r0), (r1), (r0), _t1, _t0); \ (q)++; \ \ /* Conditionally adjust q and the remainders */ \ _mask = - (mp_limb_t) ((r1) >= _q0); \ (q) += _mask; \ add_ssaaaa ((r1), (r0), (r1), (r0), _mask & (d1), _mask & (d0)); \ if (UNLIKELY ((r1) >= (d1))) \ { \ if ((r1) > (d1) || (r0) >= (d0)) \ { \ (q)++; \ sub_ddmmss ((r1), (r0), (r1), (r0), (d1), (d0)); \ } \ } \ } while (0) #ifndef mpn_preinv_divrem_1 /* if not done with cpuvec in a fat binary */ #define mpn_preinv_divrem_1 __MPN(preinv_divrem_1) __GMP_DECLSPEC mp_limb_t mpn_preinv_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, int); #endif /* USE_PREINV_DIVREM_1 is whether to use mpn_preinv_divrem_1, as opposed to the plain mpn_divrem_1. The default is yes, since the few CISC chips where preinv is not good have defines saying so. */ #ifndef USE_PREINV_DIVREM_1 #define USE_PREINV_DIVREM_1 1 #endif #if USE_PREINV_DIVREM_1 #define MPN_DIVREM_OR_PREINV_DIVREM_1(qp,xsize,ap,size,d,dinv,shift) \ mpn_preinv_divrem_1 (qp, xsize, ap, size, d, dinv, shift) #else #define MPN_DIVREM_OR_PREINV_DIVREM_1(qp,xsize,ap,size,d,dinv,shift) \ mpn_divrem_1 (qp, xsize, ap, size, d) #endif #ifndef PREINV_MOD_1_TO_MOD_1_THRESHOLD #define PREINV_MOD_1_TO_MOD_1_THRESHOLD 10 #endif /* This selection may seem backwards. The reason mpn_mod_1 typically takes over for larger sizes is that it uses the mod_1_1 function. */ #define MPN_MOD_OR_PREINV_MOD_1(src,size,divisor,inverse) \ (BELOW_THRESHOLD (size, PREINV_MOD_1_TO_MOD_1_THRESHOLD) \ ? mpn_preinv_mod_1 (src, size, divisor, inverse) \ : mpn_mod_1 (src, size, divisor)) #ifndef mpn_mod_34lsub1 /* if not done with cpuvec in a fat binary */ #define mpn_mod_34lsub1 __MPN(mod_34lsub1) __GMP_DECLSPEC mp_limb_t mpn_mod_34lsub1 (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE; #endif /* DIVEXACT_1_THRESHOLD is at what size to use mpn_divexact_1, as opposed to plain mpn_divrem_1. Likewise BMOD_1_TO_MOD_1_THRESHOLD for mpn_modexact_1_odd against plain mpn_mod_1. On most CPUs divexact and modexact are faster at all sizes, so the defaults are 0. Those CPUs where this is not right have a tuned threshold. */ #ifndef DIVEXACT_1_THRESHOLD #define DIVEXACT_1_THRESHOLD 0 #endif #ifndef BMOD_1_TO_MOD_1_THRESHOLD #define BMOD_1_TO_MOD_1_THRESHOLD 10 #endif #define MPN_DIVREM_OR_DIVEXACT_1(rp, up, n, d) \ do { \ if (BELOW_THRESHOLD (n, DIVEXACT_1_THRESHOLD)) \ ASSERT_NOCARRY (mpn_divrem_1 (rp, (mp_size_t) 0, up, n, d)); \ else \ { \ ASSERT (mpn_mod_1 (up, n, d) == 0); \ mpn_divexact_1 (rp, up, n, d); \ } \ } while (0) #ifndef mpn_modexact_1c_odd /* if not done with cpuvec in a fat binary */ #define mpn_modexact_1c_odd __MPN(modexact_1c_odd) __GMP_DECLSPEC mp_limb_t mpn_modexact_1c_odd (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; #endif #if HAVE_NATIVE_mpn_modexact_1_odd #define mpn_modexact_1_odd __MPN(modexact_1_odd) __GMP_DECLSPEC mp_limb_t mpn_modexact_1_odd (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE; #else #define mpn_modexact_1_odd(src,size,divisor) \ mpn_modexact_1c_odd (src, size, divisor, CNST_LIMB(0)) #endif #define MPN_MOD_OR_MODEXACT_1_ODD(src,size,divisor) \ (BELOW_THRESHOLD (size, BMOD_1_TO_MOD_1_THRESHOLD) \ ? mpn_modexact_1_odd (src, size, divisor) \ : mpn_mod_1 (src, size, divisor)) /* binvert_limb() sets inv to the multiplicative inverse of n modulo 2^GMP_NUMB_BITS, ie. satisfying inv*n == 1 mod 2^GMP_NUMB_BITS. n must be odd (otherwise such an inverse doesn't exist). This is not to be confused with invert_limb(), which is completely different. The table lookup gives an inverse with the low 8 bits valid, and each multiply step doubles the number of bits. See Jebelean "An algorithm for exact division" end of section 4 (reference in gmp.texi). Possible enhancement: Could use UHWtype until the last step, if half-size multiplies are faster (might help under _LONG_LONG_LIMB). Alternative: As noted in Granlund and Montgomery "Division by Invariant Integers using Multiplication" (reference in gmp.texi), n itself gives a 3-bit inverse immediately, and could be used instead of a table lookup. A 4-bit inverse can be obtained effectively from xoring bits 1 and 2 into bit 3, for instance with (((n + 2) & 4) << 1) ^ n. */ #define binvert_limb_table __gmp_binvert_limb_table __GMP_DECLSPEC extern const unsigned char binvert_limb_table[128]; #define binvert_limb(inv,n) \ do { \ mp_limb_t __n = (n); \ mp_limb_t __inv; \ ASSERT ((__n & 1) == 1); \ \ __inv = binvert_limb_table[(__n/2) & 0x7F]; /* 8 */ \ if (GMP_NUMB_BITS > 8) __inv = 2 * __inv - __inv * __inv * __n; \ if (GMP_NUMB_BITS > 16) __inv = 2 * __inv - __inv * __inv * __n; \ if (GMP_NUMB_BITS > 32) __inv = 2 * __inv - __inv * __inv * __n; \ \ if (GMP_NUMB_BITS > 64) \ { \ int __invbits = 64; \ do { \ __inv = 2 * __inv - __inv * __inv * __n; \ __invbits *= 2; \ } while (__invbits < GMP_NUMB_BITS); \ } \ \ ASSERT ((__inv * __n & GMP_NUMB_MASK) == 1); \ (inv) = __inv & GMP_NUMB_MASK; \ } while (0) #define modlimb_invert binvert_limb /* backward compatibility */ /* Multiplicative inverse of 3, modulo 2^GMP_NUMB_BITS. Eg. 0xAAAAAAAB for 32 bits, 0xAAAAAAAAAAAAAAAB for 64 bits. GMP_NUMB_MAX/3*2+1 is right when GMP_NUMB_BITS is even, but when it's odd we need to start from GMP_NUMB_MAX>>1. */ #define MODLIMB_INVERSE_3 (((GMP_NUMB_MAX >> (GMP_NUMB_BITS % 2)) / 3) * 2 + 1) /* ceil(GMP_NUMB_MAX/3) and ceil(2*GMP_NUMB_MAX/3). These expressions work because GMP_NUMB_MAX%3 != 0 for all GMP_NUMB_BITS. */ #define GMP_NUMB_CEIL_MAX_DIV3 (GMP_NUMB_MAX / 3 + 1) #define GMP_NUMB_CEIL_2MAX_DIV3 ((GMP_NUMB_MAX>>1) / 3 + 1 + GMP_NUMB_HIGHBIT) /* Set r to -a mod d. a>=d is allowed. Can give r>d. All should be limbs. It's not clear whether this is the best way to do this calculation. Anything congruent to -a would be fine for the one limb congruence tests. */ #define NEG_MOD(r, a, d) \ do { \ ASSERT ((d) != 0); \ ASSERT_LIMB (a); \ ASSERT_LIMB (d); \ \ if ((a) <= (d)) \ { \ /* small a is reasonably likely */ \ (r) = (d) - (a); \ } \ else \ { \ unsigned __twos; \ mp_limb_t __dnorm; \ count_leading_zeros (__twos, d); \ __twos -= GMP_NAIL_BITS; \ __dnorm = (d) << __twos; \ (r) = ((a) <= __dnorm ? __dnorm : 2*__dnorm) - (a); \ } \ \ ASSERT_LIMB (r); \ } while (0) /* A bit mask of all the least significant zero bits of n, or -1 if n==0. */ #define LOW_ZEROS_MASK(n) (((n) & -(n)) - 1) /* ULONG_PARITY sets "p" to 1 if there's an odd number of 1 bits in "n", or to 0 if there's an even number. "n" should be an unsigned long and "p" an int. */ #if defined (__GNUC__) && ! defined (NO_ASM) && HAVE_HOST_CPU_alpha_CIX #define ULONG_PARITY(p, n) \ do { \ int __p; \ __asm__ ("ctpop %1, %0" : "=r" (__p) : "r" (n)); \ (p) = __p & 1; \ } while (0) #endif /* Cray intrinsic _popcnt. */ #ifdef _CRAY #define ULONG_PARITY(p, n) \ do { \ (p) = _popcnt (n) & 1; \ } while (0) #endif #if defined (__GNUC__) && ! defined (__INTEL_COMPILER) \ && ! defined (NO_ASM) && defined (__ia64) /* unsigned long is either 32 or 64 bits depending on the ABI, zero extend to a 64 bit unsigned long long for popcnt */ #define ULONG_PARITY(p, n) \ do { \ unsigned long long __n = (unsigned long) (n); \ int __p; \ __asm__ ("popcnt %0 = %1" : "=r" (__p) : "r" (__n)); \ (p) = __p & 1; \ } while (0) #endif #if defined (__GNUC__) && ! defined (__INTEL_COMPILER) \ && ! defined (NO_ASM) && HAVE_HOST_CPU_FAMILY_x86 #if __GMP_GNUC_PREREQ (3,1) #define __GMP_qm "=Qm" #define __GMP_q "=Q" #else #define __GMP_qm "=qm" #define __GMP_q "=q" #endif #define ULONG_PARITY(p, n) \ do { \ char __p; \ unsigned long __n = (n); \ __n ^= (__n >> 16); \ __asm__ ("xorb %h1, %b1\n\t" \ "setpo %0" \ : __GMP_qm (__p), __GMP_q (__n) \ : "1" (__n)); \ (p) = __p; \ } while (0) #endif #if ! defined (ULONG_PARITY) #define ULONG_PARITY(p, n) \ do { \ unsigned long __n = (n); \ int __p = 0; \ do \ { \ __p ^= 0x96696996L >> (__n & 0x1F); \ __n >>= 5; \ } \ while (__n != 0); \ \ (p) = __p & 1; \ } while (0) #endif /* 3 cycles on 604 or 750 since shifts and rlwimi's can pair. gcc (as of version 3.1 at least) doesn't seem to know how to generate rlwimi for anything other than bit-fields, so use "asm". */ #if defined (__GNUC__) && ! defined (NO_ASM) \ && HAVE_HOST_CPU_FAMILY_powerpc && GMP_LIMB_BITS == 32 #define BSWAP_LIMB(dst, src) \ do { \ mp_limb_t __bswapl_src = (src); \ mp_limb_t __tmp1 = __bswapl_src >> 24; /* low byte */ \ mp_limb_t __tmp2 = __bswapl_src << 24; /* high byte */ \ __asm__ ("rlwimi %0, %2, 24, 16, 23" /* 2nd low */ \ : "=r" (__tmp1) : "0" (__tmp1), "r" (__bswapl_src)); \ __asm__ ("rlwimi %0, %2, 8, 8, 15" /* 3nd high */ \ : "=r" (__tmp2) : "0" (__tmp2), "r" (__bswapl_src)); \ (dst) = __tmp1 | __tmp2; /* whole */ \ } while (0) #endif /* bswap is available on i486 and up and is fast. A combination rorw $8 / roll $16 / rorw $8 is used in glibc for plain i386 (and in the linux kernel with xchgb instead of rorw), but this is not done here, because i386 means generic x86 and mixing word and dword operations will cause partial register stalls on P6 chips. */ #if defined (__GNUC__) && ! defined (NO_ASM) \ && HAVE_HOST_CPU_FAMILY_x86 && ! HAVE_HOST_CPU_i386 \ && GMP_LIMB_BITS == 32 #define BSWAP_LIMB(dst, src) \ do { \ __asm__ ("bswap %0" : "=r" (dst) : "0" (src)); \ } while (0) #endif #if defined (__GNUC__) && ! defined (NO_ASM) \ && defined (__amd64__) && GMP_LIMB_BITS == 64 #define BSWAP_LIMB(dst, src) \ do { \ __asm__ ("bswap %q0" : "=r" (dst) : "0" (src)); \ } while (0) #endif #if defined (__GNUC__) && ! defined (__INTEL_COMPILER) \ && ! defined (NO_ASM) && defined (__ia64) && GMP_LIMB_BITS == 64 #define BSWAP_LIMB(dst, src) \ do { \ __asm__ ("mux1 %0 = %1, @rev" : "=r" (dst) : "r" (src)); \ } while (0) #endif /* As per glibc. */ #if defined (__GNUC__) && ! defined (NO_ASM) \ && HAVE_HOST_CPU_FAMILY_m68k && GMP_LIMB_BITS == 32 #define BSWAP_LIMB(dst, src) \ do { \ mp_limb_t __bswapl_src = (src); \ __asm__ ("ror%.w %#8, %0\n\t" \ "swap %0\n\t" \ "ror%.w %#8, %0" \ : "=d" (dst) \ : "0" (__bswapl_src)); \ } while (0) #endif #if ! defined (BSWAP_LIMB) #if GMP_LIMB_BITS == 8 #define BSWAP_LIMB(dst, src) \ do { (dst) = (src); } while (0) #endif #if GMP_LIMB_BITS == 16 #define BSWAP_LIMB(dst, src) \ do { \ (dst) = ((src) << 8) + ((src) >> 8); \ } while (0) #endif #if GMP_LIMB_BITS == 32 #define BSWAP_LIMB(dst, src) \ do { \ (dst) = \ ((src) << 24) \ + (((src) & 0xFF00) << 8) \ + (((src) >> 8) & 0xFF00) \ + ((src) >> 24); \ } while (0) #endif #if GMP_LIMB_BITS == 64 #define BSWAP_LIMB(dst, src) \ do { \ (dst) = \ ((src) << 56) \ + (((src) & 0xFF00) << 40) \ + (((src) & 0xFF0000) << 24) \ + (((src) & 0xFF000000) << 8) \ + (((src) >> 8) & 0xFF000000) \ + (((src) >> 24) & 0xFF0000) \ + (((src) >> 40) & 0xFF00) \ + ((src) >> 56); \ } while (0) #endif #endif #if ! defined (BSWAP_LIMB) #define BSWAP_LIMB(dst, src) \ do { \ mp_limb_t __bswapl_src = (src); \ mp_limb_t __dstl = 0; \ int __i; \ for (__i = 0; __i < GMP_LIMB_BYTES; __i++) \ { \ __dstl = (__dstl << 8) | (__bswapl_src & 0xFF); \ __bswapl_src >>= 8; \ } \ (dst) = __dstl; \ } while (0) #endif /* Apparently lwbrx might be slow on some PowerPC chips, so restrict it to those we know are fast. */ #if defined (__GNUC__) && ! defined (NO_ASM) \ && GMP_LIMB_BITS == 32 && HAVE_LIMB_BIG_ENDIAN \ && (HAVE_HOST_CPU_powerpc604 \ || HAVE_HOST_CPU_powerpc604e \ || HAVE_HOST_CPU_powerpc750 \ || HAVE_HOST_CPU_powerpc7400) #define BSWAP_LIMB_FETCH(limb, src) \ do { \ mp_srcptr __blf_src = (src); \ mp_limb_t __limb; \ __asm__ ("lwbrx %0, 0, %1" \ : "=r" (__limb) \ : "r" (__blf_src), \ "m" (*__blf_src)); \ (limb) = __limb; \ } while (0) #endif #if ! defined (BSWAP_LIMB_FETCH) #define BSWAP_LIMB_FETCH(limb, src) BSWAP_LIMB (limb, *(src)) #endif /* On the same basis that lwbrx might be slow, restrict stwbrx to those we know are fast. FIXME: Is this necessary? */ #if defined (__GNUC__) && ! defined (NO_ASM) \ && GMP_LIMB_BITS == 32 && HAVE_LIMB_BIG_ENDIAN \ && (HAVE_HOST_CPU_powerpc604 \ || HAVE_HOST_CPU_powerpc604e \ || HAVE_HOST_CPU_powerpc750 \ || HAVE_HOST_CPU_powerpc7400) #define BSWAP_LIMB_STORE(dst, limb) \ do { \ mp_ptr __dst = (dst); \ mp_limb_t __limb = (limb); \ __asm__ ("stwbrx %1, 0, %2" \ : "=m" (*__dst) \ : "r" (__limb), \ "r" (__dst)); \ } while (0) #endif #if ! defined (BSWAP_LIMB_STORE) #define BSWAP_LIMB_STORE(dst, limb) BSWAP_LIMB (*(dst), limb) #endif /* Byte swap limbs from {src,size} and store at {dst,size}. */ #define MPN_BSWAP(dst, src, size) \ do { \ mp_ptr __dst = (dst); \ mp_srcptr __src = (src); \ mp_size_t __size = (size); \ mp_size_t __i; \ ASSERT ((size) >= 0); \ ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); \ CRAY_Pragma ("_CRI ivdep"); \ for (__i = 0; __i < __size; __i++) \ { \ BSWAP_LIMB_FETCH (*__dst, __src); \ __dst++; \ __src++; \ } \ } while (0) /* Byte swap limbs from {dst,size} and store in reverse order at {src,size}. */ #define MPN_BSWAP_REVERSE(dst, src, size) \ do { \ mp_ptr __dst = (dst); \ mp_size_t __size = (size); \ mp_srcptr __src = (src) + __size - 1; \ mp_size_t __i; \ ASSERT ((size) >= 0); \ ASSERT (! MPN_OVERLAP_P (dst, size, src, size)); \ CRAY_Pragma ("_CRI ivdep"); \ for (__i = 0; __i < __size; __i++) \ { \ BSWAP_LIMB_FETCH (*__dst, __src); \ __dst++; \ __src--; \ } \ } while (0) /* No processor claiming to be SPARC v9 compliant seems to implement the POPC instruction. Disable pattern for now. */ #if 0 #if defined __GNUC__ && defined __sparc_v9__ && GMP_LIMB_BITS == 64 #define popc_limb(result, input) \ do { \ DItype __res; \ __asm__ ("popc %1,%0" : "=r" (result) : "rI" (input)); \ } while (0) #endif #endif #if defined (__GNUC__) && ! defined (NO_ASM) && HAVE_HOST_CPU_alpha_CIX #define popc_limb(result, input) \ do { \ __asm__ ("ctpop %1, %0" : "=r" (result) : "r" (input)); \ } while (0) #endif /* Cray intrinsic. */ #ifdef _CRAY #define popc_limb(result, input) \ do { \ (result) = _popcnt (input); \ } while (0) #endif #if defined (__GNUC__) && ! defined (__INTEL_COMPILER) \ && ! defined (NO_ASM) && defined (__ia64) && GMP_LIMB_BITS == 64 #define popc_limb(result, input) \ do { \ __asm__ ("popcnt %0 = %1" : "=r" (result) : "r" (input)); \ } while (0) #endif /* Cool population count of an mp_limb_t. You have to figure out how this works, We won't tell you! The constants could also be expressed as: 0x55... = [2^N / 3] = [(2^N-1)/3] 0x33... = [2^N / 5] = [(2^N-1)/5] 0x0f... = [2^N / 17] = [(2^N-1)/17] (N is GMP_LIMB_BITS, [] denotes truncation.) */ #if ! defined (popc_limb) && GMP_LIMB_BITS == 8 #define popc_limb(result, input) \ do { \ mp_limb_t __x = (input); \ __x -= (__x >> 1) & MP_LIMB_T_MAX/3; \ __x = ((__x >> 2) & MP_LIMB_T_MAX/5) + (__x & MP_LIMB_T_MAX/5); \ __x = ((__x >> 4) + __x); \ (result) = __x & 0x0f; \ } while (0) #endif #if ! defined (popc_limb) && GMP_LIMB_BITS == 16 #define popc_limb(result, input) \ do { \ mp_limb_t __x = (input); \ __x -= (__x >> 1) & MP_LIMB_T_MAX/3; \ __x = ((__x >> 2) & MP_LIMB_T_MAX/5) + (__x & MP_LIMB_T_MAX/5); \ __x = ((__x >> 4) + __x) & MP_LIMB_T_MAX/17; \ __x = ((__x >> 8) + __x); \ (result) = __x & 0xff; \ } while (0) #endif #if ! defined (popc_limb) && GMP_LIMB_BITS == 32 #define popc_limb(result, input) \ do { \ mp_limb_t __x = (input); \ __x -= (__x >> 1) & MP_LIMB_T_MAX/3; \ __x = ((__x >> 2) & MP_LIMB_T_MAX/5) + (__x & MP_LIMB_T_MAX/5); \ __x = ((__x >> 4) + __x) & MP_LIMB_T_MAX/17; \ __x = ((__x >> 8) + __x); \ __x = ((__x >> 16) + __x); \ (result) = __x & 0xff; \ } while (0) #endif #if ! defined (popc_limb) && GMP_LIMB_BITS == 64 #define popc_limb(result, input) \ do { \ mp_limb_t __x = (input); \ __x -= (__x >> 1) & MP_LIMB_T_MAX/3; \ __x = ((__x >> 2) & MP_LIMB_T_MAX/5) + (__x & MP_LIMB_T_MAX/5); \ __x = ((__x >> 4) + __x) & MP_LIMB_T_MAX/17; \ __x = ((__x >> 8) + __x); \ __x = ((__x >> 16) + __x); \ __x = ((__x >> 32) + __x); \ (result) = __x & 0xff; \ } while (0) #endif /* Define stuff for longlong.h. */ #if HAVE_ATTRIBUTE_MODE typedef unsigned int UQItype __attribute__ ((mode (QI))); typedef int SItype __attribute__ ((mode (SI))); typedef unsigned int USItype __attribute__ ((mode (SI))); typedef int DItype __attribute__ ((mode (DI))); typedef unsigned int UDItype __attribute__ ((mode (DI))); #else typedef unsigned char UQItype; typedef long SItype; typedef unsigned long USItype; #if HAVE_LONG_LONG typedef long long int DItype; typedef unsigned long long int UDItype; #else /* Assume `long' gives us a wide enough type. Needed for hppa2.0w. */ typedef long int DItype; typedef unsigned long int UDItype; #endif #endif typedef mp_limb_t UWtype; typedef unsigned int UHWtype; #define W_TYPE_SIZE GMP_LIMB_BITS /* Define ieee_double_extract and _GMP_IEEE_FLOATS. Bit field packing is "implementation defined" according to C99, which leaves us at the compiler's mercy here. For some systems packing is defined in the ABI (eg. x86). In any case so far it seems universal that little endian systems pack from low to high, and big endian from high to low within the given type. Within the fields we rely on the integer endianness being the same as the float endianness, this is true everywhere we know of and it'd be a fairly strange system that did anything else. */ #if HAVE_DOUBLE_IEEE_LITTLE_SWAPPED #define _GMP_IEEE_FLOATS 1 union ieee_double_extract { struct { gmp_uint_least32_t manh:20; gmp_uint_least32_t exp:11; gmp_uint_least32_t sig:1; gmp_uint_least32_t manl:32; } s; double d; }; #endif #if HAVE_DOUBLE_IEEE_LITTLE_ENDIAN #define _GMP_IEEE_FLOATS 1 union ieee_double_extract { struct { gmp_uint_least32_t manl:32; gmp_uint_least32_t manh:20; gmp_uint_least32_t exp:11; gmp_uint_least32_t sig:1; } s; double d; }; #endif #if HAVE_DOUBLE_IEEE_BIG_ENDIAN #define _GMP_IEEE_FLOATS 1 union ieee_double_extract { struct { gmp_uint_least32_t sig:1; gmp_uint_least32_t exp:11; gmp_uint_least32_t manh:20; gmp_uint_least32_t manl:32; } s; double d; }; #endif #if HAVE_DOUBLE_VAX_D union double_extract { struct { gmp_uint_least32_t man3:7; /* highest 7 bits */ gmp_uint_least32_t exp:8; /* excess-128 exponent */ gmp_uint_least32_t sig:1; gmp_uint_least32_t man2:16; gmp_uint_least32_t man1:16; gmp_uint_least32_t man0:16; /* lowest 16 bits */ } s; double d; }; #endif /* Use (4.0 * ...) instead of (2.0 * ...) to work around buggy compilers that don't convert ulong->double correctly (eg. SunOS 4 native cc). */ #define MP_BASE_AS_DOUBLE (4.0 * ((mp_limb_t) 1 << (GMP_NUMB_BITS - 2))) /* Maximum number of limbs it will take to store any `double'. We assume doubles have 53 mantissa bits. */ #define LIMBS_PER_DOUBLE ((53 + GMP_NUMB_BITS - 2) / GMP_NUMB_BITS + 1) __GMP_DECLSPEC int __gmp_extract_double (mp_ptr, double); #define mpn_get_d __gmpn_get_d __GMP_DECLSPEC double mpn_get_d (mp_srcptr, mp_size_t, mp_size_t, long) __GMP_ATTRIBUTE_PURE; /* DOUBLE_NAN_INF_ACTION executes code a_nan if x is a NaN, or executes a_inf if x is an infinity. Both are considered unlikely values, for branch prediction. */ #if _GMP_IEEE_FLOATS #define DOUBLE_NAN_INF_ACTION(x, a_nan, a_inf) \ do { \ union ieee_double_extract u; \ u.d = (x); \ if (UNLIKELY (u.s.exp == 0x7FF)) \ { \ if (u.s.manl == 0 && u.s.manh == 0) \ { a_inf; } \ else \ { a_nan; } \ } \ } while (0) #endif #if HAVE_DOUBLE_VAX_D || HAVE_DOUBLE_VAX_G || HAVE_DOUBLE_CRAY_CFP /* no nans or infs in these formats */ #define DOUBLE_NAN_INF_ACTION(x, a_nan, a_inf) \ do { } while (0) #endif #ifndef DOUBLE_NAN_INF_ACTION /* Unknown format, try something generic. NaN should be "unordered", so x!=x. Inf should be bigger than DBL_MAX. */ #define DOUBLE_NAN_INF_ACTION(x, a_nan, a_inf) \ do { \ { \ if (UNLIKELY ((x) != (x))) \ { a_nan; } \ else if (UNLIKELY ((x) > DBL_MAX || (x) < -DBL_MAX)) \ { a_inf; } \ } \ } while (0) #endif /* On m68k, x86 and amd64, gcc (and maybe other compilers) can hold doubles in the coprocessor, which means a bigger exponent range than normal, and depending on the rounding mode, a bigger mantissa than normal. (See "Disappointments" in the gcc manual.) FORCE_DOUBLE stores and fetches "d" through memory to force any rounding and overflows to occur. On amd64, and on x86s with SSE2, gcc (depending on options) uses the xmm registers, where there's no such extra precision and no need for the FORCE_DOUBLE. We don't bother to detect this since the present uses for FORCE_DOUBLE are only in test programs and default generic C code. Not quite sure that an "automatic volatile" will use memory, but it does in gcc. An asm("":"=m"(d):"0"(d)) can't be used to trick gcc, since apparently matching operands like "0" are only allowed on a register output. gcc 3.4 warns about this, though in fact it and past versions seem to put the operand through memory as hoped. */ #if (HAVE_HOST_CPU_FAMILY_m68k || HAVE_HOST_CPU_FAMILY_x86 \ || defined (__amd64__)) #define FORCE_DOUBLE(d) \ do { volatile double __gmp_force = (d); (d) = __gmp_force; } while (0) #else #define FORCE_DOUBLE(d) do { } while (0) #endif __GMP_DECLSPEC extern const unsigned char __gmp_digit_value_tab[]; __GMP_DECLSPEC extern int __gmp_junk; __GMP_DECLSPEC extern const int __gmp_0; __GMP_DECLSPEC void __gmp_exception (int) ATTRIBUTE_NORETURN; __GMP_DECLSPEC void __gmp_divide_by_zero (void) ATTRIBUTE_NORETURN; __GMP_DECLSPEC void __gmp_sqrt_of_negative (void) ATTRIBUTE_NORETURN; __GMP_DECLSPEC void __gmp_invalid_operation (void) ATTRIBUTE_NORETURN; #define GMP_ERROR(code) __gmp_exception (code) #define DIVIDE_BY_ZERO __gmp_divide_by_zero () #define SQRT_OF_NEGATIVE __gmp_sqrt_of_negative () #if defined _LONG_LONG_LIMB #define CNST_LIMB(C) ((mp_limb_t) C##LL) #else /* not _LONG_LONG_LIMB */ #define CNST_LIMB(C) ((mp_limb_t) C##L) #endif /* _LONG_LONG_LIMB */ /* Stuff used by mpn/generic/perfsqr.c and mpz/prime_p.c */ #if GMP_NUMB_BITS == 2 #define PP 0x3 /* 3 */ #define PP_FIRST_OMITTED 5 #endif #if GMP_NUMB_BITS == 4 #define PP 0xF /* 3 x 5 */ #define PP_FIRST_OMITTED 7 #endif #if GMP_NUMB_BITS == 8 #define PP 0x69 /* 3 x 5 x 7 */ #define PP_FIRST_OMITTED 11 #endif #if GMP_NUMB_BITS == 16 #define PP 0x3AA7 /* 3 x 5 x 7 x 11 x 13 */ #define PP_FIRST_OMITTED 17 #endif #if GMP_NUMB_BITS == 32 #define PP 0xC0CFD797L /* 3 x 5 x 7 x 11 x ... x 29 */ #define PP_INVERTED 0x53E5645CL #define PP_FIRST_OMITTED 31 #endif #if GMP_NUMB_BITS == 64 #define PP CNST_LIMB(0xE221F97C30E94E1D) /* 3 x 5 x 7 x 11 x ... x 53 */ #define PP_INVERTED CNST_LIMB(0x21CFE6CFC938B36B) #define PP_FIRST_OMITTED 59 #endif #ifndef PP_FIRST_OMITTED #define PP_FIRST_OMITTED 3 #endif /* BIT1 means a result value in bit 1 (second least significant bit), with a zero bit representing +1 and a one bit representing -1. Bits other than bit 1 are garbage. These are meant to be kept in "int"s, and casts are used to ensure the expressions are "int"s even if a and/or b might be other types. JACOBI_TWOS_U_BIT1 and JACOBI_RECIP_UU_BIT1 are used in mpn_jacobi_base and their speed is important. Expressions are used rather than conditionals to accumulate sign changes, which effectively means XORs instead of conditional JUMPs. */ /* (a/0), with a signed; is 1 if a=+/-1, 0 otherwise */ #define JACOBI_S0(a) (((a) == 1) | ((a) == -1)) /* (a/0), with a unsigned; is 1 if a=+/-1, 0 otherwise */ #define JACOBI_U0(a) ((a) == 1) /* FIXME: JACOBI_LS0 and JACOBI_0LS are the same, so delete one and come up with a better name. */ /* (a/0), with a given by low and size; is 1 if a=+/-1, 0 otherwise */ #define JACOBI_LS0(alow,asize) \ (((asize) == 1 || (asize) == -1) && (alow) == 1) /* (a/0), with a an mpz_t; fetch of low limb always valid, even if size is zero */ #define JACOBI_Z0(a) JACOBI_LS0 (PTR(a)[0], SIZ(a)) /* (0/b), with b unsigned; is 1 if b=1, 0 otherwise */ #define JACOBI_0U(b) ((b) == 1) /* (0/b), with b unsigned; is 1 if b=+/-1, 0 otherwise */ #define JACOBI_0S(b) ((b) == 1 || (b) == -1) /* (0/b), with b given by low and size; is 1 if b=+/-1, 0 otherwise */ #define JACOBI_0LS(blow,bsize) \ (((bsize) == 1 || (bsize) == -1) && (blow) == 1) /* Convert a bit1 to +1 or -1. */ #define JACOBI_BIT1_TO_PN(result_bit1) \ (1 - ((int) (result_bit1) & 2)) /* (2/b), with b unsigned and odd; is (-1)^((b^2-1)/8) which is 1 if b==1,7mod8 or -1 if b==3,5mod8 and hence obtained from (b>>1)^b */ #define JACOBI_TWO_U_BIT1(b) \ ((int) (((b) >> 1) ^ (b))) /* (2/b)^twos, with b unsigned and odd */ #define JACOBI_TWOS_U_BIT1(twos, b) \ ((int) ((twos) << 1) & JACOBI_TWO_U_BIT1 (b)) /* (2/b)^twos, with b unsigned and odd */ #define JACOBI_TWOS_U(twos, b) \ (JACOBI_BIT1_TO_PN (JACOBI_TWOS_U_BIT1 (twos, b))) /* (-1/b), with b odd (signed or unsigned); is (-1)^((b-1)/2) */ #define JACOBI_N1B_BIT1(b) \ ((int) (b)) /* (a/b) effect due to sign of a: signed/unsigned, b odd; is (-1/b) if a<0, or +1 if a>=0 */ #define JACOBI_ASGN_SU_BIT1(a, b) \ ((((a) < 0) << 1) & JACOBI_N1B_BIT1(b)) /* (a/b) effect due to sign of b: signed/signed; is -1 if a and b both negative, +1 otherwise */ #define JACOBI_BSGN_SS_BIT1(a, b) \ ((((a)<0) & ((b)<0)) << 1) /* (a/b) effect due to sign of b: signed/mpz; is -1 if a and b both negative, +1 otherwise */ #define JACOBI_BSGN_SZ_BIT1(a, b) \ JACOBI_BSGN_SS_BIT1 (a, SIZ(b)) /* (a/b) effect due to sign of b: mpz/signed; is -1 if a and b both negative, +1 otherwise */ #define JACOBI_BSGN_ZS_BIT1(a, b) \ JACOBI_BSGN_SZ_BIT1 (b, a) /* (a/b) reciprocity to switch to (b/a), a,b both unsigned and odd; is (-1)^((a-1)*(b-1)/4), which means +1 if either a,b==1mod4, or -1 if both a,b==3mod4, achieved in bit 1 by a&b. No ASSERT()s about a,b odd because this is used in a couple of places with only bit 1 of a or b valid. */ #define JACOBI_RECIP_UU_BIT1(a, b) \ ((int) ((a) & (b))) /* Strip low zero limbs from {b_ptr,b_size} by incrementing b_ptr and decrementing b_size. b_low should be b_ptr[0] on entry, and will be updated for the new b_ptr. result_bit1 is updated according to the factors of 2 stripped, as per (a/2). */ #define JACOBI_STRIP_LOW_ZEROS(result_bit1, a, b_ptr, b_size, b_low) \ do { \ ASSERT ((b_size) >= 1); \ ASSERT ((b_low) == (b_ptr)[0]); \ \ while (UNLIKELY ((b_low) == 0)) \ { \ (b_size)--; \ ASSERT ((b_size) >= 1); \ (b_ptr)++; \ (b_low) = *(b_ptr); \ \ ASSERT (((a) & 1) != 0); \ if ((GMP_NUMB_BITS % 2) == 1) \ (result_bit1) ^= JACOBI_TWO_U_BIT1(a); \ } \ } while (0) /* Set a_rem to {a_ptr,a_size} reduced modulo b, either using mod_1 or modexact_1_odd, but in either case leaving a_rem= 1); \ ASSERT (__b & 1); \ \ if ((GMP_NUMB_BITS % 2) != 0 \ || ABOVE_THRESHOLD (__a_size, BMOD_1_TO_MOD_1_THRESHOLD)) \ { \ (a_rem) = mpn_mod_1 (__a_ptr, __a_size, __b); \ } \ else \ { \ (result_bit1) ^= JACOBI_N1B_BIT1 (__b); \ (a_rem) = mpn_modexact_1_odd (__a_ptr, __a_size, __b); \ } \ } while (0) /* State for the Jacobi computation using Lehmer. */ #define jacobi_table __gmp_jacobi_table __GMP_DECLSPEC extern const unsigned char jacobi_table[208]; /* Bit layout for the initial state. b must be odd. 3 2 1 0 +--+--+--+--+ |a1|a0|b1| s| +--+--+--+--+ */ static inline unsigned mpn_jacobi_init (unsigned a, unsigned b, unsigned s) { ASSERT (b & 1); ASSERT (s <= 1); return ((a & 3) << 2) + (b & 2) + s; } static inline int mpn_jacobi_finish (unsigned bits) { /* (a, b) = (1,0) or (0,1) */ ASSERT ( (bits & 14) == 0); return 1-2*(bits & 1); } static inline unsigned mpn_jacobi_update (unsigned bits, unsigned denominator, unsigned q) { /* FIXME: Could halve table size by not including the e bit in the * index, and instead xor when updating. Then the lookup would be * like * * bits ^= table[((bits & 30) << 2) + (denominator << 2) + q]; */ ASSERT (bits < 26); ASSERT (denominator < 2); ASSERT (q < 4); /* For almost all calls, denominator is constant and quite often q is constant too. So use addition rather than or, so the compiler can put the constant part can into the offset of an indexed addressing instruction. With constant denominator, the below table lookup is compiled to C Constant q = 1, constant denominator = 1 movzbl table+5(%eax,8), %eax or C q in %edx, constant denominator = 1 movzbl table+4(%edx,%eax,8), %eax One could maintain the state preshifted 3 bits, to save a shift here, but at least on x86, that's no real saving. */ return bits = jacobi_table[(bits << 3) + (denominator << 2) + q]; } /* Matrix multiplication */ #define mpn_matrix22_mul __MPN(matrix22_mul) __GMP_DECLSPEC void mpn_matrix22_mul (mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_matrix22_mul_strassen __MPN(matrix22_mul_strassen) __GMP_DECLSPEC void mpn_matrix22_mul_strassen (mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_srcptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr); #define mpn_matrix22_mul_itch __MPN(matrix22_mul_itch) __GMP_DECLSPEC mp_size_t mpn_matrix22_mul_itch (mp_size_t, mp_size_t) ATTRIBUTE_CONST; #ifndef MATRIX22_STRASSEN_THRESHOLD #define MATRIX22_STRASSEN_THRESHOLD 30 #endif /* HGCD definitions */ /* Extract one numb, shifting count bits left ________ ________ |___xh___||___xl___| |____r____| >count < The count includes any nail bits, so it should work fine if count is computed using count_leading_zeros. If GMP_NAIL_BITS > 0, all of xh, xl and r include nail bits. Must have 0 < count < GMP_LIMB_BITS. FIXME: Omit masking with GMP_NUMB_MASK, and let callers do that for those calls where the count high bits of xh may be non-zero. */ #define MPN_EXTRACT_NUMB(count, xh, xl) \ ((((xh) << ((count) - GMP_NAIL_BITS)) & GMP_NUMB_MASK) | \ ((xl) >> (GMP_LIMB_BITS - (count)))) /* The matrix non-negative M = (u, u'; v,v') keeps track of the reduction (a;b) = M (alpha; beta) where alpha, beta are smaller than a, b. The determinant must always be one, so that M has an inverse (v', -u'; -v, u). Elements always fit in GMP_NUMB_BITS - 1 bits. */ struct hgcd_matrix1 { mp_limb_t u[2][2]; }; #define mpn_hgcd2 __MPN (hgcd2) __GMP_DECLSPEC int mpn_hgcd2 (mp_limb_t, mp_limb_t, mp_limb_t, mp_limb_t, struct hgcd_matrix1 *); #define mpn_hgcd_mul_matrix1_vector __MPN (hgcd_mul_matrix1_vector) __GMP_DECLSPEC mp_size_t mpn_hgcd_mul_matrix1_vector (const struct hgcd_matrix1 *, mp_ptr, mp_srcptr, mp_ptr, mp_size_t); #define mpn_matrix22_mul1_inverse_vector __MPN (matrix22_mul1_inverse_vector) __GMP_DECLSPEC mp_size_t mpn_matrix22_mul1_inverse_vector (const struct hgcd_matrix1 *, mp_ptr, mp_srcptr, mp_ptr, mp_size_t); #define mpn_hgcd2_jacobi __MPN (hgcd2_jacobi) __GMP_DECLSPEC int mpn_hgcd2_jacobi (mp_limb_t, mp_limb_t, mp_limb_t, mp_limb_t, struct hgcd_matrix1 *, unsigned *); struct hgcd_matrix { mp_size_t alloc; /* for sanity checking only */ mp_size_t n; mp_ptr p[2][2]; }; #define MPN_HGCD_MATRIX_INIT_ITCH(n) (4 * ((n+1)/2 + 1)) #define mpn_hgcd_matrix_init __MPN (hgcd_matrix_init) __GMP_DECLSPEC void mpn_hgcd_matrix_init (struct hgcd_matrix *, mp_size_t, mp_ptr); #define mpn_hgcd_matrix_update_q __MPN (hgcd_matrix_update_q) __GMP_DECLSPEC void mpn_hgcd_matrix_update_q (struct hgcd_matrix *, mp_srcptr, mp_size_t, unsigned, mp_ptr); #define mpn_hgcd_matrix_mul_1 __MPN (hgcd_matrix_mul_1) __GMP_DECLSPEC void mpn_hgcd_matrix_mul_1 (struct hgcd_matrix *, const struct hgcd_matrix1 *, mp_ptr); #define mpn_hgcd_matrix_mul __MPN (hgcd_matrix_mul) __GMP_DECLSPEC void mpn_hgcd_matrix_mul (struct hgcd_matrix *, const struct hgcd_matrix *, mp_ptr); #define mpn_hgcd_matrix_adjust __MPN (hgcd_matrix_adjust) __GMP_DECLSPEC mp_size_t mpn_hgcd_matrix_adjust (const struct hgcd_matrix *, mp_size_t, mp_ptr, mp_ptr, mp_size_t, mp_ptr); #define mpn_hgcd_step __MPN(hgcd_step) __GMP_DECLSPEC mp_size_t mpn_hgcd_step (mp_size_t, mp_ptr, mp_ptr, mp_size_t, struct hgcd_matrix *, mp_ptr); #define mpn_hgcd_reduce __MPN(hgcd_reduce) __GMP_DECLSPEC mp_size_t mpn_hgcd_reduce (struct hgcd_matrix *, mp_ptr, mp_ptr, mp_size_t, mp_size_t, mp_ptr); #define mpn_hgcd_reduce_itch __MPN(hgcd_reduce_itch) __GMP_DECLSPEC mp_size_t mpn_hgcd_reduce_itch (mp_size_t, mp_size_t) ATTRIBUTE_CONST; #define mpn_hgcd_itch __MPN (hgcd_itch) __GMP_DECLSPEC mp_size_t mpn_hgcd_itch (mp_size_t) ATTRIBUTE_CONST; #define mpn_hgcd __MPN (hgcd) __GMP_DECLSPEC mp_size_t mpn_hgcd (mp_ptr, mp_ptr, mp_size_t, struct hgcd_matrix *, mp_ptr); #define mpn_hgcd_appr_itch __MPN (hgcd_appr_itch) __GMP_DECLSPEC mp_size_t mpn_hgcd_appr_itch (mp_size_t) ATTRIBUTE_CONST; #define mpn_hgcd_appr __MPN (hgcd_appr) __GMP_DECLSPEC int mpn_hgcd_appr (mp_ptr, mp_ptr, mp_size_t, struct hgcd_matrix *, mp_ptr); #define mpn_hgcd_jacobi __MPN (hgcd_jacobi) __GMP_DECLSPEC mp_size_t mpn_hgcd_jacobi (mp_ptr, mp_ptr, mp_size_t, struct hgcd_matrix *, unsigned *, mp_ptr); typedef void gcd_subdiv_step_hook(void *, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, int); /* Needs storage for the quotient */ #define MPN_GCD_SUBDIV_STEP_ITCH(n) (n) #define mpn_gcd_subdiv_step __MPN(gcd_subdiv_step) __GMP_DECLSPEC mp_size_t mpn_gcd_subdiv_step (mp_ptr, mp_ptr, mp_size_t, mp_size_t, gcd_subdiv_step_hook *, void *, mp_ptr); struct gcdext_ctx { /* Result parameters. */ mp_ptr gp; mp_size_t gn; mp_ptr up; mp_size_t *usize; /* Cofactors updated in each step. */ mp_size_t un; mp_ptr u0, u1, tp; }; #define mpn_gcdext_hook __MPN (gcdext_hook) gcd_subdiv_step_hook mpn_gcdext_hook; #define MPN_GCDEXT_LEHMER_N_ITCH(n) (4*(n) + 3) #define mpn_gcdext_lehmer_n __MPN(gcdext_lehmer_n) __GMP_DECLSPEC mp_size_t mpn_gcdext_lehmer_n (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_ptr, mp_size_t, mp_ptr); /* 4*(an + 1) + 4*(bn + 1) + an */ #define MPN_GCDEXT_LEHMER_ITCH(an, bn) (5*(an) + 4*(bn) + 8) #ifndef HGCD_THRESHOLD #define HGCD_THRESHOLD 400 #endif #ifndef HGCD_APPR_THRESHOLD #define HGCD_APPR_THRESHOLD 400 #endif #ifndef HGCD_REDUCE_THRESHOLD #define HGCD_REDUCE_THRESHOLD 1000 #endif #ifndef GCD_DC_THRESHOLD #define GCD_DC_THRESHOLD 1000 #endif #ifndef GCDEXT_DC_THRESHOLD #define GCDEXT_DC_THRESHOLD 600 #endif /* Definitions for mpn_set_str and mpn_get_str */ struct powers { mp_ptr p; /* actual power value */ mp_size_t n; /* # of limbs at p */ mp_size_t shift; /* weight of lowest limb, in limb base B */ size_t digits_in_base; /* number of corresponding digits */ int base; }; typedef struct powers powers_t; #define mpn_dc_set_str_powtab_alloc(n) ((n) + GMP_LIMB_BITS) #define mpn_dc_set_str_itch(n) ((n) + GMP_LIMB_BITS) #define mpn_dc_get_str_powtab_alloc(n) ((n) + 2 * GMP_LIMB_BITS) #define mpn_dc_get_str_itch(n) ((n) + GMP_LIMB_BITS) #define mpn_dc_set_str __MPN(dc_set_str) __GMP_DECLSPEC mp_size_t mpn_dc_set_str (mp_ptr, const unsigned char *, size_t, const powers_t *, mp_ptr); #define mpn_bc_set_str __MPN(bc_set_str) __GMP_DECLSPEC mp_size_t mpn_bc_set_str (mp_ptr, const unsigned char *, size_t, int); #define mpn_set_str_compute_powtab __MPN(set_str_compute_powtab) __GMP_DECLSPEC void mpn_set_str_compute_powtab (powers_t *, mp_ptr, mp_size_t, int); /* __GMPF_BITS_TO_PREC applies a minimum 53 bits, rounds upwards to a whole limb and adds an extra limb. __GMPF_PREC_TO_BITS drops that extra limb, hence giving back the user's size in bits rounded up. Notice that converting prec->bits->prec gives an unchanged value. */ #define __GMPF_BITS_TO_PREC(n) \ ((mp_size_t) ((__GMP_MAX (53, n) + 2 * GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)) #define __GMPF_PREC_TO_BITS(n) \ ((mp_bitcnt_t) (n) * GMP_NUMB_BITS - GMP_NUMB_BITS) __GMP_DECLSPEC extern mp_size_t __gmp_default_fp_limb_precision; /* Compute the number of base-b digits corresponding to nlimbs limbs, rounding down. */ #define DIGITS_IN_BASE_PER_LIMB(res, nlimbs, b) \ do { \ mp_limb_t _ph, _dummy; \ umul_ppmm (_ph, _dummy, \ mp_bases[b].logb2, GMP_NUMB_BITS * (mp_limb_t) (nlimbs));\ res = _ph; \ } while (0) /* Compute the number of limbs corresponding to ndigits base-b digits, rounding up. */ #define LIMBS_PER_DIGIT_IN_BASE(res, ndigits, b) \ do { \ mp_limb_t _ph, _dummy; \ umul_ppmm (_ph, _dummy, mp_bases[b].log2b, (mp_limb_t) (ndigits)); \ res = 8 * _ph / GMP_NUMB_BITS + 2; \ } while (0) /* Set n to the number of significant digits an mpf of the given _mp_prec field, in the given base. This is a rounded up value, designed to ensure there's enough digits to reproduce all the guaranteed part of the value. There are prec many limbs, but the high might be only "1" so forget it and just count prec-1 limbs into chars. +1 rounds that upwards, and a further +1 is because the limbs usually won't fall on digit boundaries. FIXME: If base is a power of 2 and the bits per digit divides GMP_LIMB_BITS then the +2 is unnecessary. This happens always for base==2, and in base==16 with the current 32 or 64 bit limb sizes. */ #define MPF_SIGNIFICANT_DIGITS(n, base, prec) \ do { \ size_t rawn; \ ASSERT (base >= 2 && base < numberof (mp_bases)); \ DIGITS_IN_BASE_PER_LIMB (rawn, (prec) - 1, base); \ n = rawn + 2; \ } while (0) /* Decimal point string, from the current C locale. Needs for nl_langinfo and constants, preferably with _GNU_SOURCE defined to get DECIMAL_POINT from glibc, and needs for localeconv, each under their respective #if HAVE_FOO_H. GLIBC recommends nl_langinfo because getting only one facet can be faster, apparently. */ /* DECIMAL_POINT seems to need _GNU_SOURCE defined to get it from glibc. */ #if HAVE_NL_LANGINFO && defined (DECIMAL_POINT) #define GMP_DECIMAL_POINT (nl_langinfo (DECIMAL_POINT)) #endif /* RADIXCHAR is deprecated, still in unix98 or some such. */ #if HAVE_NL_LANGINFO && defined (RADIXCHAR) && ! defined (GMP_DECIMAL_POINT) #define GMP_DECIMAL_POINT (nl_langinfo (RADIXCHAR)) #endif /* localeconv is slower since it returns all locale stuff */ #if HAVE_LOCALECONV && ! defined (GMP_DECIMAL_POINT) #define GMP_DECIMAL_POINT (localeconv()->decimal_point) #endif #if ! defined (GMP_DECIMAL_POINT) #define GMP_DECIMAL_POINT (".") #endif #define DOPRNT_CONV_FIXED 1 #define DOPRNT_CONV_SCIENTIFIC 2 #define DOPRNT_CONV_GENERAL 3 #define DOPRNT_JUSTIFY_NONE 0 #define DOPRNT_JUSTIFY_LEFT 1 #define DOPRNT_JUSTIFY_RIGHT 2 #define DOPRNT_JUSTIFY_INTERNAL 3 #define DOPRNT_SHOWBASE_YES 1 #define DOPRNT_SHOWBASE_NO 2 #define DOPRNT_SHOWBASE_NONZERO 3 struct doprnt_params_t { int base; /* negative for upper case */ int conv; /* choices above */ const char *expfmt; /* exponent format */ int exptimes4; /* exponent multiply by 4 */ char fill; /* character */ int justify; /* choices above */ int prec; /* prec field, or -1 for all digits */ int showbase; /* choices above */ int showpoint; /* if radix point always shown */ int showtrailing; /* if trailing zeros wanted */ char sign; /* '+', ' ', or '\0' */ int width; /* width field */ }; #if _GMP_H_HAVE_VA_LIST typedef int (*doprnt_format_t) (void *, const char *, va_list); typedef int (*doprnt_memory_t) (void *, const char *, size_t); typedef int (*doprnt_reps_t) (void *, int, int); typedef int (*doprnt_final_t) (void *); struct doprnt_funs_t { doprnt_format_t format; doprnt_memory_t memory; doprnt_reps_t reps; doprnt_final_t final; /* NULL if not required */ }; extern const struct doprnt_funs_t __gmp_fprintf_funs; extern const struct doprnt_funs_t __gmp_sprintf_funs; extern const struct doprnt_funs_t __gmp_snprintf_funs; extern const struct doprnt_funs_t __gmp_obstack_printf_funs; extern const struct doprnt_funs_t __gmp_ostream_funs; /* "buf" is a __gmp_allocate_func block of "alloc" many bytes. The first "size" of these have been written. "alloc > size" is maintained, so there's room to store a '\0' at the end. "result" is where the application wants the final block pointer. */ struct gmp_asprintf_t { char **result; char *buf; size_t size; size_t alloc; }; #define GMP_ASPRINTF_T_INIT(d, output) \ do { \ (d).result = (output); \ (d).alloc = 256; \ (d).buf = (char *) (*__gmp_allocate_func) ((d).alloc); \ (d).size = 0; \ } while (0) /* If a realloc is necessary, use twice the size actually required, so as to avoid repeated small reallocs. */ #define GMP_ASPRINTF_T_NEED(d, n) \ do { \ size_t alloc, newsize, newalloc; \ ASSERT ((d)->alloc >= (d)->size + 1); \ \ alloc = (d)->alloc; \ newsize = (d)->size + (n); \ if (alloc <= newsize) \ { \ newalloc = 2*newsize; \ (d)->alloc = newalloc; \ (d)->buf = __GMP_REALLOCATE_FUNC_TYPE ((d)->buf, \ alloc, newalloc, char); \ } \ } while (0) __GMP_DECLSPEC int __gmp_asprintf_memory (struct gmp_asprintf_t *, const char *, size_t); __GMP_DECLSPEC int __gmp_asprintf_reps (struct gmp_asprintf_t *, int, int); __GMP_DECLSPEC int __gmp_asprintf_final (struct gmp_asprintf_t *); /* buf is where to write the next output, and size is how much space is left there. If the application passed size==0 then that's what we'll have here, and nothing at all should be written. */ struct gmp_snprintf_t { char *buf; size_t size; }; /* Add the bytes printed by the call to the total retval, or bail out on an error. */ #define DOPRNT_ACCUMULATE(call) \ do { \ int __ret; \ __ret = call; \ if (__ret == -1) \ goto error; \ retval += __ret; \ } while (0) #define DOPRNT_ACCUMULATE_FUN(fun, params) \ do { \ ASSERT ((fun) != NULL); \ DOPRNT_ACCUMULATE ((*(fun)) params); \ } while (0) #define DOPRNT_FORMAT(fmt, ap) \ DOPRNT_ACCUMULATE_FUN (funs->format, (data, fmt, ap)) #define DOPRNT_MEMORY(ptr, len) \ DOPRNT_ACCUMULATE_FUN (funs->memory, (data, ptr, len)) #define DOPRNT_REPS(c, n) \ DOPRNT_ACCUMULATE_FUN (funs->reps, (data, c, n)) #define DOPRNT_STRING(str) DOPRNT_MEMORY (str, strlen (str)) #define DOPRNT_REPS_MAYBE(c, n) \ do { \ if ((n) != 0) \ DOPRNT_REPS (c, n); \ } while (0) #define DOPRNT_MEMORY_MAYBE(ptr, len) \ do { \ if ((len) != 0) \ DOPRNT_MEMORY (ptr, len); \ } while (0) __GMP_DECLSPEC int __gmp_doprnt (const struct doprnt_funs_t *, void *, const char *, va_list); __GMP_DECLSPEC int __gmp_doprnt_integer (const struct doprnt_funs_t *, void *, const struct doprnt_params_t *, const char *); #define __gmp_doprnt_mpf __gmp_doprnt_mpf2 __GMP_DECLSPEC int __gmp_doprnt_mpf (const struct doprnt_funs_t *, void *, const struct doprnt_params_t *, const char *, mpf_srcptr); __GMP_DECLSPEC int __gmp_replacement_vsnprintf (char *, size_t, const char *, va_list); #endif /* _GMP_H_HAVE_VA_LIST */ typedef int (*gmp_doscan_scan_t) (void *, const char *, ...); typedef void *(*gmp_doscan_step_t) (void *, int); typedef int (*gmp_doscan_get_t) (void *); typedef int (*gmp_doscan_unget_t) (int, void *); struct gmp_doscan_funs_t { gmp_doscan_scan_t scan; gmp_doscan_step_t step; gmp_doscan_get_t get; gmp_doscan_unget_t unget; }; extern const struct gmp_doscan_funs_t __gmp_fscanf_funs; extern const struct gmp_doscan_funs_t __gmp_sscanf_funs; #if _GMP_H_HAVE_VA_LIST __GMP_DECLSPEC int __gmp_doscan (const struct gmp_doscan_funs_t *, void *, const char *, va_list); #endif /* For testing and debugging. */ #define MPZ_CHECK_FORMAT(z) \ do { \ ASSERT_ALWAYS (SIZ(z) == 0 || PTR(z)[ABSIZ(z) - 1] != 0); \ ASSERT_ALWAYS (ALLOC(z) >= ABSIZ(z)); \ ASSERT_ALWAYS_MPN (PTR(z), ABSIZ(z)); \ } while (0) #define MPQ_CHECK_FORMAT(q) \ do { \ MPZ_CHECK_FORMAT (mpq_numref (q)); \ MPZ_CHECK_FORMAT (mpq_denref (q)); \ ASSERT_ALWAYS (SIZ(mpq_denref(q)) >= 1); \ \ if (SIZ(mpq_numref(q)) == 0) \ { \ /* should have zero as 0/1 */ \ ASSERT_ALWAYS (SIZ(mpq_denref(q)) == 1 \ && PTR(mpq_denref(q))[0] == 1); \ } \ else \ { \ /* should have no common factors */ \ mpz_t g; \ mpz_init (g); \ mpz_gcd (g, mpq_numref(q), mpq_denref(q)); \ ASSERT_ALWAYS (mpz_cmp_ui (g, 1) == 0); \ mpz_clear (g); \ } \ } while (0) #define MPF_CHECK_FORMAT(f) \ do { \ ASSERT_ALWAYS (PREC(f) >= __GMPF_BITS_TO_PREC(53)); \ ASSERT_ALWAYS (ABSIZ(f) <= PREC(f)+1); \ if (SIZ(f) == 0) \ ASSERT_ALWAYS (EXP(f) == 0); \ if (SIZ(f) != 0) \ ASSERT_ALWAYS (PTR(f)[ABSIZ(f) - 1] != 0); \ } while (0) /* Enhancement: The "mod" and "gcd_1" functions below could have __GMP_ATTRIBUTE_PURE, but currently (gcc 3.3) that's not supported on function pointers, only actual functions. It probably doesn't make much difference to the gmp code, since hopefully we arrange calls so there's no great need for the compiler to move things around. */ #if WANT_FAT_BINARY && (HAVE_HOST_CPU_FAMILY_x86 || HAVE_HOST_CPU_FAMILY_x86_64) /* NOTE: The function pointers in this struct are also in CPUVEC_FUNCS_LIST in mpn/x86/x86-defs.m4 and mpn/x86_64/x86_64-defs.m4. Be sure to update those when changing here. */ struct cpuvec_t { DECL_add_n ((*add_n)); DECL_addlsh1_n ((*addlsh1_n)); DECL_addlsh2_n ((*addlsh2_n)); DECL_addmul_1 ((*addmul_1)); DECL_addmul_2 ((*addmul_2)); DECL_bdiv_dbm1c ((*bdiv_dbm1c)); DECL_cnd_add_n ((*cnd_add_n)); DECL_cnd_sub_n ((*cnd_sub_n)); DECL_com ((*com)); DECL_copyd ((*copyd)); DECL_copyi ((*copyi)); DECL_divexact_1 ((*divexact_1)); DECL_divrem_1 ((*divrem_1)); DECL_gcd_1 ((*gcd_1)); DECL_lshift ((*lshift)); DECL_lshiftc ((*lshiftc)); DECL_mod_1 ((*mod_1)); DECL_mod_1_1p ((*mod_1_1p)); DECL_mod_1_1p_cps ((*mod_1_1p_cps)); DECL_mod_1s_2p ((*mod_1s_2p)); DECL_mod_1s_2p_cps ((*mod_1s_2p_cps)); DECL_mod_1s_4p ((*mod_1s_4p)); DECL_mod_1s_4p_cps ((*mod_1s_4p_cps)); DECL_mod_34lsub1 ((*mod_34lsub1)); DECL_modexact_1c_odd ((*modexact_1c_odd)); DECL_mul_1 ((*mul_1)); DECL_mul_basecase ((*mul_basecase)); DECL_mullo_basecase ((*mullo_basecase)); DECL_preinv_divrem_1 ((*preinv_divrem_1)); DECL_preinv_mod_1 ((*preinv_mod_1)); DECL_redc_1 ((*redc_1)); DECL_redc_2 ((*redc_2)); DECL_rshift ((*rshift)); DECL_sqr_basecase ((*sqr_basecase)); DECL_sub_n ((*sub_n)); DECL_sublsh1_n ((*sublsh1_n)); DECL_submul_1 ((*submul_1)); mp_size_t mul_toom22_threshold; mp_size_t mul_toom33_threshold; mp_size_t sqr_toom2_threshold; mp_size_t sqr_toom3_threshold; mp_size_t bmod_1_to_mod_1_threshold; }; __GMP_DECLSPEC extern struct cpuvec_t __gmpn_cpuvec; __GMP_DECLSPEC extern int __gmpn_cpuvec_initialized; #endif /* x86 fat binary */ __GMP_DECLSPEC void __gmpn_cpuvec_init (void); /* Get a threshold "field" from __gmpn_cpuvec, running __gmpn_cpuvec_init() if that hasn't yet been done (to establish the right values). */ #define CPUVEC_THRESHOLD(field) \ ((LIKELY (__gmpn_cpuvec_initialized) ? 0 : (__gmpn_cpuvec_init (), 0)), \ __gmpn_cpuvec.field) #if HAVE_NATIVE_mpn_add_nc #define mpn_add_nc __MPN(add_nc) __GMP_DECLSPEC mp_limb_t mpn_add_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #else static inline mp_limb_t mpn_add_nc (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n, mp_limb_t ci) { mp_limb_t co; co = mpn_add_n (rp, up, vp, n); co += mpn_add_1 (rp, rp, n, ci); return co; } #endif #if HAVE_NATIVE_mpn_sub_nc #define mpn_sub_nc __MPN(sub_nc) __GMP_DECLSPEC mp_limb_t mpn_sub_nc (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_limb_t); #else static inline mp_limb_t mpn_sub_nc (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n, mp_limb_t ci) { mp_limb_t co; co = mpn_sub_n (rp, up, vp, n); co += mpn_sub_1 (rp, rp, n, ci); return co; } #endif #if TUNE_PROGRAM_BUILD /* Some extras wanted when recompiling some .c files for use by the tune program. Not part of a normal build. It's necessary to keep these thresholds as #defines (just to an identically named variable), since various defaults are established based on #ifdef in the .c files. For some this is not so (the defaults are instead established above), but all are done this way for consistency. */ #undef MUL_TOOM22_THRESHOLD #define MUL_TOOM22_THRESHOLD mul_toom22_threshold extern mp_size_t mul_toom22_threshold; #undef MUL_TOOM33_THRESHOLD #define MUL_TOOM33_THRESHOLD mul_toom33_threshold extern mp_size_t mul_toom33_threshold; #undef MUL_TOOM44_THRESHOLD #define MUL_TOOM44_THRESHOLD mul_toom44_threshold extern mp_size_t mul_toom44_threshold; #undef MUL_TOOM6H_THRESHOLD #define MUL_TOOM6H_THRESHOLD mul_toom6h_threshold extern mp_size_t mul_toom6h_threshold; #undef MUL_TOOM8H_THRESHOLD #define MUL_TOOM8H_THRESHOLD mul_toom8h_threshold extern mp_size_t mul_toom8h_threshold; #undef MUL_TOOM32_TO_TOOM43_THRESHOLD #define MUL_TOOM32_TO_TOOM43_THRESHOLD mul_toom32_to_toom43_threshold extern mp_size_t mul_toom32_to_toom43_threshold; #undef MUL_TOOM32_TO_TOOM53_THRESHOLD #define MUL_TOOM32_TO_TOOM53_THRESHOLD mul_toom32_to_toom53_threshold extern mp_size_t mul_toom32_to_toom53_threshold; #undef MUL_TOOM42_TO_TOOM53_THRESHOLD #define MUL_TOOM42_TO_TOOM53_THRESHOLD mul_toom42_to_toom53_threshold extern mp_size_t mul_toom42_to_toom53_threshold; #undef MUL_TOOM42_TO_TOOM63_THRESHOLD #define MUL_TOOM42_TO_TOOM63_THRESHOLD mul_toom42_to_toom63_threshold extern mp_size_t mul_toom42_to_toom63_threshold; #undef MUL_TOOM43_TO_TOOM54_THRESHOLD #define MUL_TOOM43_TO_TOOM54_THRESHOLD mul_toom43_to_toom54_threshold; extern mp_size_t mul_toom43_to_toom54_threshold; #undef MUL_FFT_THRESHOLD #define MUL_FFT_THRESHOLD mul_fft_threshold extern mp_size_t mul_fft_threshold; #undef MUL_FFT_MODF_THRESHOLD #define MUL_FFT_MODF_THRESHOLD mul_fft_modf_threshold extern mp_size_t mul_fft_modf_threshold; #undef MUL_FFT_TABLE #define MUL_FFT_TABLE { 0 } #undef MUL_FFT_TABLE3 #define MUL_FFT_TABLE3 { {0,0} } /* A native mpn_sqr_basecase is not tuned and SQR_BASECASE_THRESHOLD should remain as zero (always use it). */ #if ! HAVE_NATIVE_mpn_sqr_basecase #undef SQR_BASECASE_THRESHOLD #define SQR_BASECASE_THRESHOLD sqr_basecase_threshold extern mp_size_t sqr_basecase_threshold; #endif #if TUNE_PROGRAM_BUILD_SQR #undef SQR_TOOM2_THRESHOLD #define SQR_TOOM2_THRESHOLD SQR_TOOM2_MAX_GENERIC #else #undef SQR_TOOM2_THRESHOLD #define SQR_TOOM2_THRESHOLD sqr_toom2_threshold extern mp_size_t sqr_toom2_threshold; #endif #undef SQR_TOOM3_THRESHOLD #define SQR_TOOM3_THRESHOLD sqr_toom3_threshold extern mp_size_t sqr_toom3_threshold; #undef SQR_TOOM4_THRESHOLD #define SQR_TOOM4_THRESHOLD sqr_toom4_threshold extern mp_size_t sqr_toom4_threshold; #undef SQR_TOOM6_THRESHOLD #define SQR_TOOM6_THRESHOLD sqr_toom6_threshold extern mp_size_t sqr_toom6_threshold; #undef SQR_TOOM8_THRESHOLD #define SQR_TOOM8_THRESHOLD sqr_toom8_threshold extern mp_size_t sqr_toom8_threshold; #undef SQR_FFT_THRESHOLD #define SQR_FFT_THRESHOLD sqr_fft_threshold extern mp_size_t sqr_fft_threshold; #undef SQR_FFT_MODF_THRESHOLD #define SQR_FFT_MODF_THRESHOLD sqr_fft_modf_threshold extern mp_size_t sqr_fft_modf_threshold; #undef SQR_FFT_TABLE #define SQR_FFT_TABLE { 0 } #undef SQR_FFT_TABLE3 #define SQR_FFT_TABLE3 { {0,0} } #undef MULLO_BASECASE_THRESHOLD #define MULLO_BASECASE_THRESHOLD mullo_basecase_threshold extern mp_size_t mullo_basecase_threshold; #undef MULLO_DC_THRESHOLD #define MULLO_DC_THRESHOLD mullo_dc_threshold extern mp_size_t mullo_dc_threshold; #undef MULLO_MUL_N_THRESHOLD #define MULLO_MUL_N_THRESHOLD mullo_mul_n_threshold extern mp_size_t mullo_mul_n_threshold; #undef SQRLO_BASECASE_THRESHOLD #define SQRLO_BASECASE_THRESHOLD sqrlo_basecase_threshold extern mp_size_t sqrlo_basecase_threshold; #undef SQRLO_DC_THRESHOLD #define SQRLO_DC_THRESHOLD sqrlo_dc_threshold extern mp_size_t sqrlo_dc_threshold; #undef SQRLO_SQR_THRESHOLD #define SQRLO_SQR_THRESHOLD sqrlo_sqr_threshold extern mp_size_t sqrlo_sqr_threshold; #undef MULMID_TOOM42_THRESHOLD #define MULMID_TOOM42_THRESHOLD mulmid_toom42_threshold extern mp_size_t mulmid_toom42_threshold; #undef DIV_QR_2_PI2_THRESHOLD #define DIV_QR_2_PI2_THRESHOLD div_qr_2_pi2_threshold extern mp_size_t div_qr_2_pi2_threshold; #undef DC_DIV_QR_THRESHOLD #define DC_DIV_QR_THRESHOLD dc_div_qr_threshold extern mp_size_t dc_div_qr_threshold; #undef DC_DIVAPPR_Q_THRESHOLD #define DC_DIVAPPR_Q_THRESHOLD dc_divappr_q_threshold extern mp_size_t dc_divappr_q_threshold; #undef DC_BDIV_Q_THRESHOLD #define DC_BDIV_Q_THRESHOLD dc_bdiv_q_threshold extern mp_size_t dc_bdiv_q_threshold; #undef DC_BDIV_QR_THRESHOLD #define DC_BDIV_QR_THRESHOLD dc_bdiv_qr_threshold extern mp_size_t dc_bdiv_qr_threshold; #undef MU_DIV_QR_THRESHOLD #define MU_DIV_QR_THRESHOLD mu_div_qr_threshold extern mp_size_t mu_div_qr_threshold; #undef MU_DIVAPPR_Q_THRESHOLD #define MU_DIVAPPR_Q_THRESHOLD mu_divappr_q_threshold extern mp_size_t mu_divappr_q_threshold; #undef MUPI_DIV_QR_THRESHOLD #define MUPI_DIV_QR_THRESHOLD mupi_div_qr_threshold extern mp_size_t mupi_div_qr_threshold; #undef MU_BDIV_QR_THRESHOLD #define MU_BDIV_QR_THRESHOLD mu_bdiv_qr_threshold extern mp_size_t mu_bdiv_qr_threshold; #undef MU_BDIV_Q_THRESHOLD #define MU_BDIV_Q_THRESHOLD mu_bdiv_q_threshold extern mp_size_t mu_bdiv_q_threshold; #undef INV_MULMOD_BNM1_THRESHOLD #define INV_MULMOD_BNM1_THRESHOLD inv_mulmod_bnm1_threshold extern mp_size_t inv_mulmod_bnm1_threshold; #undef INV_NEWTON_THRESHOLD #define INV_NEWTON_THRESHOLD inv_newton_threshold extern mp_size_t inv_newton_threshold; #undef INV_APPR_THRESHOLD #define INV_APPR_THRESHOLD inv_appr_threshold extern mp_size_t inv_appr_threshold; #undef BINV_NEWTON_THRESHOLD #define BINV_NEWTON_THRESHOLD binv_newton_threshold extern mp_size_t binv_newton_threshold; #undef REDC_1_TO_REDC_2_THRESHOLD #define REDC_1_TO_REDC_2_THRESHOLD redc_1_to_redc_2_threshold extern mp_size_t redc_1_to_redc_2_threshold; #undef REDC_2_TO_REDC_N_THRESHOLD #define REDC_2_TO_REDC_N_THRESHOLD redc_2_to_redc_n_threshold extern mp_size_t redc_2_to_redc_n_threshold; #undef REDC_1_TO_REDC_N_THRESHOLD #define REDC_1_TO_REDC_N_THRESHOLD redc_1_to_redc_n_threshold extern mp_size_t redc_1_to_redc_n_threshold; #undef MATRIX22_STRASSEN_THRESHOLD #define MATRIX22_STRASSEN_THRESHOLD matrix22_strassen_threshold extern mp_size_t matrix22_strassen_threshold; #undef HGCD_THRESHOLD #define HGCD_THRESHOLD hgcd_threshold extern mp_size_t hgcd_threshold; #undef HGCD_APPR_THRESHOLD #define HGCD_APPR_THRESHOLD hgcd_appr_threshold extern mp_size_t hgcd_appr_threshold; #undef HGCD_REDUCE_THRESHOLD #define HGCD_REDUCE_THRESHOLD hgcd_reduce_threshold extern mp_size_t hgcd_reduce_threshold; #undef GCD_DC_THRESHOLD #define GCD_DC_THRESHOLD gcd_dc_threshold extern mp_size_t gcd_dc_threshold; #undef GCDEXT_DC_THRESHOLD #define GCDEXT_DC_THRESHOLD gcdext_dc_threshold extern mp_size_t gcdext_dc_threshold; #undef DIV_QR_1N_PI1_METHOD #define DIV_QR_1N_PI1_METHOD div_qr_1n_pi1_method extern int div_qr_1n_pi1_method; #undef DIV_QR_1_NORM_THRESHOLD #define DIV_QR_1_NORM_THRESHOLD div_qr_1_norm_threshold extern mp_size_t div_qr_1_norm_threshold; #undef DIV_QR_1_UNNORM_THRESHOLD #define DIV_QR_1_UNNORM_THRESHOLD div_qr_1_unnorm_threshold extern mp_size_t div_qr_1_unnorm_threshold; #undef DIVREM_1_NORM_THRESHOLD #define DIVREM_1_NORM_THRESHOLD divrem_1_norm_threshold extern mp_size_t divrem_1_norm_threshold; #undef DIVREM_1_UNNORM_THRESHOLD #define DIVREM_1_UNNORM_THRESHOLD divrem_1_unnorm_threshold extern mp_size_t divrem_1_unnorm_threshold; #undef MOD_1_NORM_THRESHOLD #define MOD_1_NORM_THRESHOLD mod_1_norm_threshold extern mp_size_t mod_1_norm_threshold; #undef MOD_1_UNNORM_THRESHOLD #define MOD_1_UNNORM_THRESHOLD mod_1_unnorm_threshold extern mp_size_t mod_1_unnorm_threshold; #undef MOD_1_1P_METHOD #define MOD_1_1P_METHOD mod_1_1p_method extern int mod_1_1p_method; #undef MOD_1N_TO_MOD_1_1_THRESHOLD #define MOD_1N_TO_MOD_1_1_THRESHOLD mod_1n_to_mod_1_1_threshold extern mp_size_t mod_1n_to_mod_1_1_threshold; #undef MOD_1U_TO_MOD_1_1_THRESHOLD #define MOD_1U_TO_MOD_1_1_THRESHOLD mod_1u_to_mod_1_1_threshold extern mp_size_t mod_1u_to_mod_1_1_threshold; #undef MOD_1_1_TO_MOD_1_2_THRESHOLD #define MOD_1_1_TO_MOD_1_2_THRESHOLD mod_1_1_to_mod_1_2_threshold extern mp_size_t mod_1_1_to_mod_1_2_threshold; #undef MOD_1_2_TO_MOD_1_4_THRESHOLD #define MOD_1_2_TO_MOD_1_4_THRESHOLD mod_1_2_to_mod_1_4_threshold extern mp_size_t mod_1_2_to_mod_1_4_threshold; #undef PREINV_MOD_1_TO_MOD_1_THRESHOLD #define PREINV_MOD_1_TO_MOD_1_THRESHOLD preinv_mod_1_to_mod_1_threshold extern mp_size_t preinv_mod_1_to_mod_1_threshold; #if ! UDIV_PREINV_ALWAYS #undef DIVREM_2_THRESHOLD #define DIVREM_2_THRESHOLD divrem_2_threshold extern mp_size_t divrem_2_threshold; #endif #undef MULMOD_BNM1_THRESHOLD #define MULMOD_BNM1_THRESHOLD mulmod_bnm1_threshold extern mp_size_t mulmod_bnm1_threshold; #undef SQRMOD_BNM1_THRESHOLD #define SQRMOD_BNM1_THRESHOLD sqrmod_bnm1_threshold extern mp_size_t sqrmod_bnm1_threshold; #undef GET_STR_DC_THRESHOLD #define GET_STR_DC_THRESHOLD get_str_dc_threshold extern mp_size_t get_str_dc_threshold; #undef GET_STR_PRECOMPUTE_THRESHOLD #define GET_STR_PRECOMPUTE_THRESHOLD get_str_precompute_threshold extern mp_size_t get_str_precompute_threshold; #undef SET_STR_DC_THRESHOLD #define SET_STR_DC_THRESHOLD set_str_dc_threshold extern mp_size_t set_str_dc_threshold; #undef SET_STR_PRECOMPUTE_THRESHOLD #define SET_STR_PRECOMPUTE_THRESHOLD set_str_precompute_threshold extern mp_size_t set_str_precompute_threshold; #undef FAC_ODD_THRESHOLD #define FAC_ODD_THRESHOLD fac_odd_threshold extern mp_size_t fac_odd_threshold; #undef FAC_DSC_THRESHOLD #define FAC_DSC_THRESHOLD fac_dsc_threshold extern mp_size_t fac_dsc_threshold; #undef FFT_TABLE_ATTRS #define FFT_TABLE_ATTRS extern mp_size_t mpn_fft_table[2][MPN_FFT_TABLE_SIZE]; #define FFT_TABLE3_SIZE 2000 /* generous space for tuning */ extern struct fft_table_nk mpn_fft_table3[2][FFT_TABLE3_SIZE]; /* Sizes the tune program tests up to, used in a couple of recompilations. */ #undef MUL_TOOM22_THRESHOLD_LIMIT #undef MUL_TOOM33_THRESHOLD_LIMIT #undef MULLO_BASECASE_THRESHOLD_LIMIT #undef SQRLO_BASECASE_THRESHOLD_LIMIT #undef SQRLO_DC_THRESHOLD_LIMIT #undef SQR_TOOM3_THRESHOLD_LIMIT #define SQR_TOOM2_MAX_GENERIC 200 #define MUL_TOOM22_THRESHOLD_LIMIT 700 #define MUL_TOOM33_THRESHOLD_LIMIT 700 #define SQR_TOOM3_THRESHOLD_LIMIT 400 #define MUL_TOOM44_THRESHOLD_LIMIT 1000 #define SQR_TOOM4_THRESHOLD_LIMIT 1000 #define MUL_TOOM6H_THRESHOLD_LIMIT 1100 #define SQR_TOOM6_THRESHOLD_LIMIT 1100 #define MUL_TOOM8H_THRESHOLD_LIMIT 1200 #define SQR_TOOM8_THRESHOLD_LIMIT 1200 #define MULLO_BASECASE_THRESHOLD_LIMIT 200 #define SQRLO_BASECASE_THRESHOLD_LIMIT 200 #define SQRLO_DC_THRESHOLD_LIMIT 400 #define GET_STR_THRESHOLD_LIMIT 150 #define FAC_DSC_THRESHOLD_LIMIT 2048 #endif /* TUNE_PROGRAM_BUILD */ #if defined (__cplusplus) } #endif /* FIXME: Make these itch functions less conservative. Also consider making them dependent on just 'an', and compute the allocation directly from 'an' instead of via n. */ /* toom22/toom2: Scratch need is 2*(an + k), k is the recursion depth. k is ths smallest k such that ceil(an/2^k) < MUL_TOOM22_THRESHOLD. which implies that k = bitsize of floor ((an-1)/(MUL_TOOM22_THRESHOLD-1)) = 1 + floor (log_2 (floor ((an-1)/(MUL_TOOM22_THRESHOLD-1)))) */ #define mpn_toom22_mul_itch(an, bn) \ (2 * ((an) + GMP_NUMB_BITS)) #define mpn_toom2_sqr_itch(an) \ (2 * ((an) + GMP_NUMB_BITS)) /* toom33/toom3: Scratch need is 5an/2 + 10k, k is the recursion depth. We use 3an + C, so that we can use a smaller constant. */ #define mpn_toom33_mul_itch(an, bn) \ (3 * (an) + GMP_NUMB_BITS) #define mpn_toom3_sqr_itch(an) \ (3 * (an) + GMP_NUMB_BITS) /* toom33/toom3: Scratch need is 8an/3 + 13k, k is the recursion depth. We use 3an + C, so that we can use a smaller constant. */ #define mpn_toom44_mul_itch(an, bn) \ (3 * (an) + GMP_NUMB_BITS) #define mpn_toom4_sqr_itch(an) \ (3 * (an) + GMP_NUMB_BITS) #define mpn_toom6_sqr_itch(n) \ (((n) - SQR_TOOM6_THRESHOLD)*2 + \ MAX(SQR_TOOM6_THRESHOLD*2 + GMP_NUMB_BITS*6, \ mpn_toom4_sqr_itch(SQR_TOOM6_THRESHOLD))) #define MUL_TOOM6H_MIN \ ((MUL_TOOM6H_THRESHOLD > MUL_TOOM44_THRESHOLD) ? \ MUL_TOOM6H_THRESHOLD : MUL_TOOM44_THRESHOLD) #define mpn_toom6_mul_n_itch(n) \ (((n) - MUL_TOOM6H_MIN)*2 + \ MAX(MUL_TOOM6H_MIN*2 + GMP_NUMB_BITS*6, \ mpn_toom44_mul_itch(MUL_TOOM6H_MIN,MUL_TOOM6H_MIN))) static inline mp_size_t mpn_toom6h_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t estimatedN; estimatedN = (an + bn) / (size_t) 10 + 1; return mpn_toom6_mul_n_itch (estimatedN * 6); } #define mpn_toom8_sqr_itch(n) \ ((((n)*15)>>3) - ((SQR_TOOM8_THRESHOLD*15)>>3) + \ MAX(((SQR_TOOM8_THRESHOLD*15)>>3) + GMP_NUMB_BITS*6, \ mpn_toom6_sqr_itch(SQR_TOOM8_THRESHOLD))) #define MUL_TOOM8H_MIN \ ((MUL_TOOM8H_THRESHOLD > MUL_TOOM6H_MIN) ? \ MUL_TOOM8H_THRESHOLD : MUL_TOOM6H_MIN) #define mpn_toom8_mul_n_itch(n) \ ((((n)*15)>>3) - ((MUL_TOOM8H_MIN*15)>>3) + \ MAX(((MUL_TOOM8H_MIN*15)>>3) + GMP_NUMB_BITS*6, \ mpn_toom6_mul_n_itch(MUL_TOOM8H_MIN))) static inline mp_size_t mpn_toom8h_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t estimatedN; estimatedN = (an + bn) / (size_t) 14 + 1; return mpn_toom8_mul_n_itch (estimatedN * 8); } static inline mp_size_t mpn_toom32_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = 1 + (2 * an >= 3 * bn ? (an - 1) / (size_t) 3 : (bn - 1) >> 1); mp_size_t itch = 2 * n + 1; return itch; } static inline mp_size_t mpn_toom42_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = an >= 2 * bn ? (an + 3) >> 2 : (bn + 1) >> 1; return 6 * n + 3; } static inline mp_size_t mpn_toom43_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = 1 + (3 * an >= 4 * bn ? (an - 1) >> 2 : (bn - 1) / (size_t) 3); return 6*n + 4; } static inline mp_size_t mpn_toom52_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = 1 + (2 * an >= 5 * bn ? (an - 1) / (size_t) 5 : (bn - 1) >> 1); return 6*n + 4; } static inline mp_size_t mpn_toom53_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = 1 + (3 * an >= 5 * bn ? (an - 1) / (size_t) 5 : (bn - 1) / (size_t) 3); return 10 * n + 10; } static inline mp_size_t mpn_toom62_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = 1 + (an >= 3 * bn ? (an - 1) / (size_t) 6 : (bn - 1) >> 1); return 10 * n + 10; } static inline mp_size_t mpn_toom63_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = 1 + (an >= 2 * bn ? (an - 1) / (size_t) 6 : (bn - 1) / (size_t) 3); return 9 * n + 3; } static inline mp_size_t mpn_toom54_mul_itch (mp_size_t an, mp_size_t bn) { mp_size_t n = 1 + (4 * an >= 5 * bn ? (an - 1) / (size_t) 5 : (bn - 1) / (size_t) 4); return 9 * n + 3; } /* let S(n) = space required for input size n, then S(n) = 3 floor(n/2) + 1 + S(floor(n/2)). */ #define mpn_toom42_mulmid_itch(n) \ (3 * (n) + GMP_NUMB_BITS) #if 0 #define mpn_fft_mul mpn_mul_fft_full #else #define mpn_fft_mul mpn_nussbaumer_mul #endif #ifdef __cplusplus /* A little helper for a null-terminated __gmp_allocate_func string. The destructor ensures it's freed even if an exception is thrown. The len field is needed by the destructor, and can be used by anyone else to avoid a second strlen pass over the data. Since our input is a C string, using strlen is correct. Perhaps it'd be more C++-ish style to use std::char_traits::length, but char_traits isn't available in gcc 2.95.4. */ class gmp_allocated_string { public: char *str; size_t len; gmp_allocated_string(char *arg) { str = arg; len = std::strlen (str); } ~gmp_allocated_string() { (*__gmp_free_func) (str, len+1); } }; std::istream &__gmpz_operator_in_nowhite (std::istream &, mpz_ptr, char); int __gmp_istream_set_base (std::istream &, char &, bool &, bool &); void __gmp_istream_set_digits (std::string &, std::istream &, char &, bool &, int); void __gmp_doprnt_params_from_ios (struct doprnt_params_t *, std::ios &); std::ostream& __gmp_doprnt_integer_ostream (std::ostream &, struct doprnt_params_t *, char *); extern const struct doprnt_funs_t __gmp_asprintf_funs_noformat; #endif /* __cplusplus */ #endif /* __GMP_IMPL_H__ */ gmp-6.1.0/invalid.c000664 001756 001756 00000005071 12615426624 015252 0ustar00bodratobodrato000000 000000 /* __gmp_invalid_operation -- invalid floating point operation. THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN FUTURE GNU MP RELEASES. Copyright 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "config.h" #include #include #if HAVE_UNISTD_H #include /* for getpid */ #endif #include "gmp.h" #include "gmp-impl.h" /* Incidentally, kill is not available on mingw, but that's ok, it has raise and we'll be using that. */ #if ! HAVE_RAISE #define raise(sig) kill (getpid(), sig) #endif /* __gmp_invalid_operation is for an invalid floating point operation, like mpz_set_d on a NaN or Inf. It's done as a subroutine to minimize code in places raising an exception. feraiseexcept(FE_INVALID) is not used here, since unfortunately on most systems it would require libm. Alternatives: It might be possible to check whether a hardware "invalid operation" trap is enabled or not before raising a signal. This would require all callers to be prepared to continue with some bogus result. Bogus returns are bad, but presumably an application disabling the trap is prepared for that. On some systems (eg. BSD) the signal handler can find out the reason for a SIGFPE (overflow, invalid, div-by-zero, etc). Perhaps we could get that into our raise too. i386 GLIBC implements feraiseexcept(FE_INVALID) with an asm fdiv 0/0. That would both respect the exceptions mask and give a reason code in a BSD signal. */ void __gmp_invalid_operation (void) { raise (SIGFPE); abort (); } gmp-6.1.0/mpz/000755 001756 001756 00000000000 12615426652 014262 5ustar00bodratobodrato000000 000000 gmp-6.1.0/cxx/000755 001756 001756 00000000000 12615426653 014257 5ustar00bodratobodrato000000 000000 gmp-6.1.0/missing000755 001756 001756 00000015330 12572636756 015067 0ustar00bodratobodrato000000 000000 #! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gmp-6.1.0/mp_bpl.c000664 001756 001756 00000002134 12615426625 015073 0ustar00bodratobodrato000000 000000 /* Copyright 1996 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" const int mp_bits_per_limb = GMP_LIMB_BITS; const int __gmp_0 = 0; int __gmp_junk; gmp-6.1.0/ltmain.sh000644 001756 001756 00001170771 12572637012 015306 0ustar00bodratobodrato000000 000000 #! /bin/sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in ## by inline-source v2014-01-03.01 # libtool (GNU libtool) 2.4.6 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . PROGRAM=libtool PACKAGE=libtool VERSION=2.4.6 package_revision=2.4.6 ## ------ ## ## Usage. ## ## ------ ## # Run './libtool --help' for help with using this script from the # command line. ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # After configure completes, it has a better idea of some of the # shell tools we need than the defaults used by the functions shared # with bootstrap, so set those here where they can still be over- # ridden by the user, but otherwise take precedence. : ${AUTOCONF="autoconf"} : ${AUTOMAKE="automake"} ## -------------------------- ## ## Source external libraries. ## ## -------------------------- ## # Much of our low-level functionality needs to be sourced from external # libraries, which are installed to $pkgauxdir. # Set a version string for this script. scriptversion=2015-01-20.17; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 # Copyright (C) 2004-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # As a special exception to the GNU General Public License, if you distribute # this file as part of a program or library that is built using GNU Libtool, # you may include this file under the same distribution terms that you use # for the rest of that program. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # Evaluate this file near the top of your script to gain access to # the functions and variables defined here: # # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh # # If you need to override any of the default environment variable # settings, do that before evaluating this file. ## -------------------- ## ## Shell normalisation. ## ## -------------------- ## # Some shells need a little help to be as Bourne compatible as possible. # Before doing anything else, make sure all that help has been provided! DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # NLS nuisances: We save the old values in case they are required later. _G_user_locale= _G_safe_locale= for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test set = \"\${$_G_var+set}\"; then save_$_G_var=\$$_G_var $_G_var=C export $_G_var _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Make sure IFS has a sensible default sp=' ' nl=' ' IFS="$sp $nl" # There are apparently some retarded systems that use ';' as a PATH separator! if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi ## ------------------------- ## ## Locate command utilities. ## ## ------------------------- ## # func_executable_p FILE # ---------------------- # Check that FILE is an executable regular file. func_executable_p () { test -f "$1" && test -x "$1" } # func_path_progs PROGS_LIST CHECK_FUNC [PATH] # -------------------------------------------- # Search for either a program that responds to --version with output # containing "GNU", or else returned by CHECK_FUNC otherwise, by # trying all the directories in PATH with each of the elements of # PROGS_LIST. # # CHECK_FUNC should accept the path to a candidate program, and # set $func_check_prog_result if it truncates its output less than # $_G_path_prog_max characters. func_path_progs () { _G_progs_list=$1 _G_check_func=$2 _G_PATH=${3-"$PATH"} _G_path_prog_max=0 _G_path_prog_found=false _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} for _G_dir in $_G_PATH; do IFS=$_G_save_IFS test -z "$_G_dir" && _G_dir=. for _G_prog_name in $_G_progs_list; do for _exeext in '' .EXE; do _G_path_prog=$_G_dir/$_G_prog_name$_exeext func_executable_p "$_G_path_prog" || continue case `"$_G_path_prog" --version 2>&1` in *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; *) $_G_check_func $_G_path_prog func_path_progs_result=$func_check_prog_result ;; esac $_G_path_prog_found && break 3 done done done IFS=$_G_save_IFS test -z "$func_path_progs_result" && { echo "no acceptable sed could be found in \$PATH" >&2 exit 1 } } # We want to be able to use the functions in this file before configure # has figured out where the best binaries are kept, which means we have # to search for them ourselves - except when the results are already set # where we skip the searches. # Unless the user overrides by setting SED, search the path for either GNU # sed, or the sed that truncates its output the least. test -z "$SED" && { _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for _G_i in 1 2 3 4 5 6 7; do _G_sed_script=$_G_sed_script$nl$_G_sed_script done echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed _G_sed_script= func_check_prog_sed () { _G_path_prog=$1 _G_count=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo '' >> conftest.nl "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin rm -f conftest.sed SED=$func_path_progs_result } # Unless the user overrides by setting GREP, search the path for either GNU # grep, or the grep that truncates its output the least. test -z "$GREP" && { func_check_prog_grep () { _G_path_prog=$1 _G_count=0 _G_path_prog_max=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo 'GREP' >> conftest.nl "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin GREP=$func_path_progs_result } ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # All uppercase variable names are used for environment variables. These # variables can be overridden by the user before calling a script that # uses them if a suitable command of that name is not already available # in the command search PATH. : ${CP="cp -f"} : ${ECHO="printf %s\n"} : ${EGREP="$GREP -E"} : ${FGREP="$GREP -F"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} ## -------------------- ## ## Useful sed snippets. ## ## -------------------- ## sed_dirname='s|/[^/]*$||' sed_basename='s|^.*/||' # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s|\([`"$\\]\)|\\\1|g' # Same as above, but do not quote variable references. sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' # Sed substitution that converts a w32 file name or path # that contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-'\' parameter expansions in output of sed_double_quote_subst that # were '\'-ed in input to the same. If an odd number of '\' preceded a # '$' in input to sed_double_quote_subst, that '$' was protected from # expansion. Since each input '\' is now two '\'s, look for any number # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. _G_bs='\\' _G_bs2='\\\\' _G_bs4='\\\\\\\\' _G_dollar='\$' sed_double_backslash="\ s/$_G_bs4/&\\ /g s/^$_G_bs2$_G_dollar/$_G_bs&/ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" ## ----------------- ## ## Global variables. ## ## ----------------- ## # Except for the global variables explicitly listed below, the following # functions in the '^func_' namespace, and the '^require_' namespace # variables initialised in the 'Resource management' section, sourcing # this file will not pollute your global namespace with anything # else. There's no portable way to scope variables in Bourne shell # though, so actually running these functions will sometimes place # results into a variable named after the function, and often use # temporary variables in the '^_G_' namespace. If you are careful to # avoid using those namespaces casually in your sourcing script, things # should continue to work as you expect. And, of course, you can freely # overwrite any of the functions or variables defined here before # calling anything to customize them. EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. # Allow overriding, eg assuming that you follow the convention of # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: # By convention, finish your script with: # # exit $exit_status # # so that you can set exit_status to non-zero if you want to indicate # something went wrong during execution without actually bailing out at # the point of failure. exit_status=$EXIT_SUCCESS # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath=$0 # The name of this program. progname=`$ECHO "$progpath" |$SED "$sed_basename"` # Make sure we have an absolute progpath for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` progdir=`cd "$progdir" && pwd` progpath=$progdir/$progname ;; *) _G_IFS=$IFS IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS=$_G_IFS test -x "$progdir/$progname" && break done IFS=$_G_IFS test -n "$progdir" || progdir=`pwd` progpath=$progdir/$progname ;; esac ## ----------------- ## ## Standard options. ## ## ----------------- ## # The following options affect the operation of the functions defined # below, and should be set appropriately depending on run-time para- # meters passed on the command line. opt_dry_run=false opt_quiet=false opt_verbose=false # Categories 'all' and 'none' are always available. Append any others # you will pass as the first argument to func_warning from your own # code. warning_categories= # By default, display warnings according to 'opt_warning_types'. Set # 'warning_func' to ':' to elide all warnings, or func_fatal_error to # treat the next displayed warning as a fatal error. warning_func=func_warn_and_continue # Set to 'all' to display all warnings, 'none' to suppress all # warnings, or a space delimited list of some subset of # 'warning_categories' to display only the listed warnings. opt_warning_types=all ## -------------------- ## ## Resource management. ## ## -------------------- ## # This section contains definitions for functions that each ensure a # particular resource (a file, or a non-empty configuration variable for # example) is available, and if appropriate to extract default values # from pertinent package files. Call them using their associated # 'require_*' variable to ensure that they are executed, at most, once. # # It's entirely deliberate that calling these functions can set # variables that don't obey the namespace limitations obeyed by the rest # of this file, in order that that they be as useful as possible to # callers. # require_term_colors # ------------------- # Allow display of bold text on terminals that support it. require_term_colors=func_require_term_colors func_require_term_colors () { $debug_cmd test -t 1 && { # COLORTERM and USE_ANSI_COLORS environment variables take # precedence, because most terminfo databases neglect to describe # whether color sequences are supported. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} if test 1 = "$USE_ANSI_COLORS"; then # Standard ANSI escape sequences tc_reset='' tc_bold=''; tc_standout='' tc_red=''; tc_green='' tc_blue=''; tc_cyan='' else # Otherwise trust the terminfo database after all. test -n "`tput sgr0 2>/dev/null`" && { tc_reset=`tput sgr0` test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` tc_standout=$tc_bold test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` } fi } require_term_colors=: } ## ----------------- ## ## Function library. ## ## ----------------- ## # This section contains a variety of useful functions to call in your # scripts. Take note of the portable wrappers for features provided by # some modern shells, which will fall back to slower equivalents on # less featureful shells. # func_append VAR VALUE # --------------------- # Append VALUE onto the existing contents of VAR. # We should try to minimise forks, especially on Windows where they are # unreasonably slow, so skip the feature probes when bash or zsh are # being used: if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then : ${_G_HAVE_ARITH_OP="yes"} : ${_G_HAVE_XSI_OPS="yes"} # The += operator was introduced in bash 3.1 case $BASH_VERSION in [12].* | 3.0 | 3.0*) ;; *) : ${_G_HAVE_PLUSEQ_OP="yes"} ;; esac fi # _G_HAVE_PLUSEQ_OP # Can be empty, in which case the shell is probed, "yes" if += is # useable or anything else if it does not work. test -z "$_G_HAVE_PLUSEQ_OP" \ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ && _G_HAVE_PLUSEQ_OP=yes if test yes = "$_G_HAVE_PLUSEQ_OP" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_append () { $debug_cmd eval "$1+=\$2" }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_append () { $debug_cmd eval "$1=\$$1\$2" } fi # func_append_quoted VAR VALUE # ---------------------------- # Quote VALUE and append to the end of shell variable VAR, separated # by a space. if test yes = "$_G_HAVE_PLUSEQ_OP"; then eval 'func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1+=\\ \$func_quote_for_eval_result" }' else func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1=\$$1\\ \$func_quote_for_eval_result" } fi # func_append_uniq VAR VALUE # -------------------------- # Append unique VALUE onto the existing contents of VAR, assuming # entries are delimited by the first character of VALUE. For example: # # func_append_uniq options " --another-option option-argument" # # will only append to $options if " --another-option option-argument " # is not already present somewhere in $options already (note spaces at # each end implied by leading space in second argument). func_append_uniq () { $debug_cmd eval _G_current_value='`$ECHO $'$1'`' _G_delim=`expr "$2" : '\(.\)'` case $_G_delim$_G_current_value$_G_delim in *"$2$_G_delim"*) ;; *) func_append "$@" ;; esac } # func_arith TERM... # ------------------ # Set func_arith_result to the result of evaluating TERMs. test -z "$_G_HAVE_ARITH_OP" \ && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ && _G_HAVE_ARITH_OP=yes if test yes = "$_G_HAVE_ARITH_OP"; then eval 'func_arith () { $debug_cmd func_arith_result=$(( $* )) }' else func_arith () { $debug_cmd func_arith_result=`expr "$@"` } fi # func_basename FILE # ------------------ # Set func_basename_result to FILE with everything up to and including # the last / stripped. if test yes = "$_G_HAVE_XSI_OPS"; then # If this shell supports suffix pattern removal, then use it to avoid # forking. Hide the definitions single quotes in case the shell chokes # on unsupported syntax... _b='func_basename_result=${1##*/}' _d='case $1 in */*) func_dirname_result=${1%/*}$2 ;; * ) func_dirname_result=$3 ;; esac' else # ...otherwise fall back to using sed. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else func_append func_dirname_result "$2" fi' fi eval 'func_basename () { $debug_cmd '"$_b"' }' # func_dirname FILE APPEND NONDIR_REPLACEMENT # ------------------------------------------- # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. eval 'func_dirname () { $debug_cmd '"$_d"' }' # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT # -------------------------------------------------------- # Perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # For efficiency, we do not delegate to the functions above but instead # duplicate the functionality here. eval 'func_dirname_and_basename () { $debug_cmd '"$_b"' '"$_d"' }' # func_echo ARG... # ---------------- # Echo program name prefixed message. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname: $_G_line" done IFS=$func_echo_IFS } # func_echo_all ARG... # -------------------- # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_echo_infix_1 INFIX ARG... # ------------------------------ # Echo program name, followed by INFIX on the first line, with any # additional lines not showing INFIX. func_echo_infix_1 () { $debug_cmd $require_term_colors _G_infix=$1; shift _G_indent=$_G_infix _G_prefix="$progname: $_G_infix: " _G_message=$* # Strip color escape sequences before counting printable length for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" do test -n "$_G_tc" && { _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` } done _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes func_echo_infix_1_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_infix_1_IFS $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 _G_prefix=$_G_indent done IFS=$func_echo_infix_1_IFS } # func_error ARG... # ----------------- # Echo program name prefixed message to standard error. func_error () { $debug_cmd $require_term_colors func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 } # func_fatal_error ARG... # ----------------------- # Echo program name prefixed message to standard error, and exit. func_fatal_error () { $debug_cmd func_error "$*" exit $EXIT_FAILURE } # func_grep EXPRESSION FILENAME # ----------------------------- # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $debug_cmd $GREP "$1" "$2" >/dev/null 2>&1 } # func_len STRING # --------------- # Set func_len_result to the length of STRING. STRING may not # start with a hyphen. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_len () { $debug_cmd func_len_result=${#1} }' else func_len () { $debug_cmd func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } fi # func_mkdir_p DIRECTORY-PATH # --------------------------- # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { $debug_cmd _G_directory_path=$1 _G_dir_list= if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then # Protect directory names starting with '-' case $_G_directory_path in -*) _G_directory_path=./$_G_directory_path ;; esac # While some portion of DIR does not yet exist... while test ! -d "$_G_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. _G_dir_list=$_G_directory_path:$_G_dir_list # If the last portion added has no slash in it, the list is done case $_G_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` done _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` func_mkdir_p_IFS=$IFS; IFS=: for _G_dir in $_G_dir_list; do IFS=$func_mkdir_p_IFS # mkdir can fail with a 'File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$_G_dir" 2>/dev/null || : done IFS=$func_mkdir_p_IFS # Bail out if we (or some other process) failed to create a directory. test -d "$_G_directory_path" || \ func_fatal_error "Failed to create '$1'" fi } # func_mktempdir [BASENAME] # ------------------------- # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, BASENAME is the basename for that directory. func_mktempdir () { $debug_cmd _G_template=${TMPDIR-/tmp}/${1-$progname} if test : = "$opt_dry_run"; then # Return a directory name, but don't create it in dry-run mode _G_tmpdir=$_G_template-$$ else # If mktemp works, use that first and foremost _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` if test ! -d "$_G_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race _G_tmpdir=$_G_template-${RANDOM-0}$$ func_mktempdir_umask=`umask` umask 0077 $MKDIR "$_G_tmpdir" umask $func_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$_G_tmpdir" || \ func_fatal_error "cannot create temporary directory '$_G_tmpdir'" fi $ECHO "$_G_tmpdir" } # func_normal_abspath PATH # ------------------------ # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. func_normal_abspath () { $debug_cmd # These SED scripts presuppose an absolute path with a trailing slash. _G_pathcar='s|^/\([^/]*\).*$|\1|' _G_pathcdr='s|^/[^/]*||' _G_removedotparts=':dotsl s|/\./|/|g t dotsl s|/\.$|/|' _G_collapseslashes='s|/\{1,\}|/|g' _G_finalslash='s|/*$|/|' # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` while :; do # Processed it all yet? if test / = "$func_normal_abspath_tpath"; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result"; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_notquiet ARG... # -------------------- # Echo program name prefixed message only when not in quiet mode. func_notquiet () { $debug_cmd $opt_quiet || func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_relative_path SRCDIR DSTDIR # -------------------------------- # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. func_relative_path () { $debug_cmd func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=$func_dirname_result if test -z "$func_relative_path_tlibdir"; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test -n "$func_stripname_result"; then func_append func_relative_path_result "/$func_stripname_result" fi # Normalisation. If bindir is libdir, return '.' else relative path. if test -n "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result" func_relative_path_result=$func_stripname_result fi test -n "$func_relative_path_result" || func_relative_path_result=. : } # func_quote_for_eval ARG... # -------------------------- # Aesthetically quote ARGs to be evaled later. # This function returns two values: # i) func_quote_for_eval_result # double-quoted, suitable for a subsequent eval # ii) func_quote_for_eval_unquoted_result # has all characters that are still active within double # quotes backslashified. func_quote_for_eval () { $debug_cmd func_quote_for_eval_unquoted_result= func_quote_for_eval_result= while test 0 -lt $#; do case $1 in *[\\\`\"\$]*) _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; *) _G_unquoted_arg=$1 ;; esac if test -n "$func_quote_for_eval_unquoted_result"; then func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" else func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" fi case $_G_unquoted_arg in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and variable expansion # for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_quoted_arg=\"$_G_unquoted_arg\" ;; *) _G_quoted_arg=$_G_unquoted_arg ;; esac if test -n "$func_quote_for_eval_result"; then func_append func_quote_for_eval_result " $_G_quoted_arg" else func_append func_quote_for_eval_result "$_G_quoted_arg" fi shift done } # func_quote_for_expand ARG # ------------------------- # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { $debug_cmd case $1 in *[\\\`\"]*) _G_arg=`$ECHO "$1" | $SED \ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; *) _G_arg=$1 ;; esac case $_G_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_arg=\"$_G_arg\" ;; esac func_quote_for_expand_result=$_G_arg } # func_stripname PREFIX SUFFIX NAME # --------------------------------- # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_stripname () { $debug_cmd # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary variable first. func_stripname_result=$3 func_stripname_result=${func_stripname_result#"$1"} func_stripname_result=${func_stripname_result%"$2"} }' else func_stripname () { $debug_cmd case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; esac } fi # func_show_eval CMD [FAIL_EXP] # ----------------------------- # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} func_quote_for_expand "$_G_cmd" eval "func_notquiet $func_quote_for_expand_result" $opt_dry_run || { eval "$_G_cmd" _G_status=$? if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_show_eval_locale CMD [FAIL_EXP] # ------------------------------------ # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} $opt_quiet || { func_quote_for_expand "$_G_cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || { eval "$_G_user_locale $_G_cmd" _G_status=$? eval "$_G_safe_locale" if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_tr_sh # ---------- # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { $debug_cmd case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_verbose ARG... # ------------------- # Echo program name prefixed message in verbose mode only. func_verbose () { $debug_cmd $opt_verbose && func_echo "$*" : } # func_warn_and_continue ARG... # ----------------------------- # Echo program name prefixed warning message to standard error. func_warn_and_continue () { $debug_cmd $require_term_colors func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 } # func_warning CATEGORY ARG... # ---------------------------- # Echo program name prefixed warning message to standard error. Warning # messages can be filtered according to CATEGORY, where this function # elides messages where CATEGORY is not listed in the global variable # 'opt_warning_types'. func_warning () { $debug_cmd # CATEGORY must be in the warning_categories list! case " $warning_categories " in *" $1 "*) ;; *) func_internal_error "invalid warning category '$1'" ;; esac _G_category=$1 shift case " $opt_warning_types " in *" $_G_category "*) $warning_func ${1+"$@"} ;; esac } # func_sort_ver VER1 VER2 # ----------------------- # 'sort -V' is not generally available. # Note this deviates from the version comparison in automake # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a # but this should suffice as we won't be specifying old # version formats or redundant trailing .0 in bootstrap.conf. # If we did want full compatibility then we should probably # use m4_version_compare from autoconf. func_sort_ver () { $debug_cmd printf '%s\n%s\n' "$1" "$2" \ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n } # func_lt_ver PREV CURR # --------------------- # Return true if PREV and CURR are in the correct order according to # func_sort_ver, otherwise false. Use it like this: # # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." func_lt_ver () { $debug_cmd test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: #! /bin/sh # Set a version string for this script. scriptversion=2014-01-07.03; # UTC # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 # Copyright (C) 2010-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # This file is a library for parsing options in your shell scripts along # with assorted other useful supporting features that you can make use # of too. # # For the simplest scripts you might need only: # # #!/bin/sh # . relative/path/to/funclib.sh # . relative/path/to/options-parser # scriptversion=1.0 # func_options ${1+"$@"} # eval set dummy "$func_options_result"; shift # ...rest of your script... # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file # starting with '# Written by ' and ending with '# warranty; '. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the # '# Written by ' line, like the one at the top of this file. # # The default options also support '--debug', which will turn on shell # execution tracing (see the comment above debug_cmd below for another # use), and '--verbose' and the func_verbose function to allow your script # to display verbose messages only when your user has specified # '--verbose'. # # After sourcing this file, you can plug processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. ## -------------- ## ## Configuration. ## ## -------------- ## # You should override these variables in your script after sourcing this # file so that they reflect the customisations you have added to the # option parser. # The usage line for option parsing errors and the start of '-h' and # '--help' output messages. You can embed shell variables for delayed # expansion at the time the message is displayed, but you will need to # quote other shell meta-characters carefully to prevent them being # expanded when the contents are evaled. usage='$progpath [OPTION]...' # Short help message in response to '-h' and '--help'. Add to this or # override it after sourcing this library to reflect the full set of # options your script accepts. usage_message="\ --debug enable verbose shell tracing -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -v, --verbose verbosely report processing --version print version information and exit -h, --help print short or long help message and exit " # Additional text appended to 'usage_message' in response to '--help'. long_help_message=" Warning categories include: 'all' show all warnings 'none' turn off all the warnings 'error' warnings are treated as fatal errors" # Help message printed before fatal option parsing errors. fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## ## Hook function management. ## ## ------------------------- ## # This section contains functions for adding, removing, and running hooks # to the main code. A hook is just a named list of of function, that can # be run in order later on. # func_hookable FUNC_NAME # ----------------------- # Declare that FUNC_NAME will run hooks added with # 'func_add_hook FUNC_NAME ...'. func_hookable () { $debug_cmd func_append hookable_fns " $1" } # func_add_hook FUNC_NAME HOOK_FUNC # --------------------------------- # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must # first have been declared "hookable" by a call to 'func_hookable'. func_add_hook () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not accept hook functions." ;; esac eval func_append ${1}_hooks '" $2"' } # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. func_remove_hook () { $debug_cmd eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' } # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. # It is assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. func_run_hooks () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not support hook funcions.n" ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do eval $_G_hook '"$@"' # store returned options list back into positional # parameters for next 'cmd' execution. eval _G_hook_result=\$${_G_hook}_result eval set dummy "$_G_hook_result"; shift done func_quote_for_eval ${1+"$@"} func_run_hooks_result=$func_quote_for_eval_result } ## --------------- ## ## Option parsing. ## ## --------------- ## # In order to add your own option parsing hooks, you must accept the # full positional parameter list in your hook function, remove any # options that you action, and then pass back the remaining unprocessed # options in '_result', escaped suitably for # 'eval'. Like this: # # my_options_prep () # { # $debug_cmd # # # Extend the existing usage message. # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' # # func_quote_for_eval ${1+"$@"} # my_options_prep_result=$func_quote_for_eval_result # } # func_add_hook func_options_prep my_options_prep # # # my_silent_option () # { # $debug_cmd # # # Note that for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in # --silent|-s) opt_silent=: ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift # ;; # *) set dummy "$_G_opt" "$*"; shift; break ;; # esac # done # # func_quote_for_eval ${1+"$@"} # my_silent_option_result=$func_quote_for_eval_result # } # func_add_hook func_parse_options my_silent_option # # # my_option_validation () # { # $debug_cmd # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." # # func_quote_for_eval ${1+"$@"} # my_option_validation_result=$func_quote_for_eval_result # } # func_add_hook func_validate_options my_option_validation # # You'll alse need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the # individual implementations for details. func_hookable func_options func_options () { $debug_cmd func_options_prep ${1+"$@"} eval func_parse_options \ ${func_options_prep_result+"$func_options_prep_result"} eval func_validate_options \ ${func_parse_options_result+"$func_parse_options_result"} eval func_run_hooks func_options \ ${func_validate_options_result+"$func_validate_options_result"} # save modified positional parameters for caller func_options_result=$func_run_hooks_result } # func_options_prep [ARG]... # -------------------------- # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and # needs to propogate that back to rest of this script, then the complete # modified list must be put in 'func_run_hooks_result' before # returning. func_hookable func_options_prep func_options_prep () { $debug_cmd # Option defaults: opt_verbose=false opt_warning_types= func_run_hooks func_options_prep ${1+"$@"} # save modified positional parameters for caller func_options_prep_result=$func_run_hooks_result } # func_parse_options [ARG]... # --------------------------- # The main option parsing loop. func_hookable func_parse_options func_parse_options () { $debug_cmd func_parse_options_result= # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. func_run_hooks func_parse_options ${1+"$@"} # Adjust func_parse_options positional parameters to match eval set dummy "$func_run_hooks_result"; shift # Break out of the loop if we already parsed every option. test $# -gt 0 || break _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' func_echo "enabling shell trace mode" $debug_cmd ;; --no-warnings|--no-warning|--no-warn) set dummy --warnings none ${1+"$@"} shift ;; --warnings|--warning|-W) test $# = 0 && func_missing_arg $_G_opt && break case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above func_append_uniq opt_warning_types " $1" ;; *all) opt_warning_types=$warning_categories ;; *none) opt_warning_types=none warning_func=: ;; *error) opt_warning_types=$warning_categories warning_func=func_fatal_error ;; *) func_fatal_error \ "unsupported warning category: '$1'" ;; esac shift ;; --verbose|-v) opt_verbose=: ;; --version) func_version ;; -\?|-h) func_usage ;; --help) func_help ;; # Separate optargs to long options (plugins may need this): --*=*) func_split_equals "$_G_opt" set dummy "$func_split_equals_lhs" \ "$func_split_equals_rhs" ${1+"$@"} shift ;; # Separate optargs to short options: -W*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "$func_split_short_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-v*|-x*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} func_parse_options_result=$func_quote_for_eval_result } # func_validate_options [ARG]... # ------------------------------ # Perform any sanity checks on option settings and/or unconsumed # arguments. func_hookable func_validate_options func_validate_options () { $debug_cmd # Display all warnings if -W was not given. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" func_run_hooks func_validate_options ${1+"$@"} # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE # save modified positional parameters for caller func_validate_options_result=$func_run_hooks_result } ## ----------------- ## ## Helper functions. ## ## ----------------- ## # This section contains the helper functions used by the rest of the # hookable option parser framework in ascii-betical order. # func_fatal_help ARG... # ---------------------- # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { $debug_cmd eval \$ECHO \""Usage: $usage"\" eval \$ECHO \""$fatal_help"\" func_error ${1+"$@"} exit $EXIT_FAILURE } # func_help # --------- # Echo long help message to standard output and exit. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message" exit 0 } # func_missing_arg ARGNAME # ------------------------ # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $debug_cmd func_error "Missing argument for '$1'." exit_cmd=exit } # func_split_equals STRING # ------------------------ # Set func_split_equals_lhs and func_split_equals_rhs shell variables after # splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_equals () { $debug_cmd func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} test "x$func_split_equals_lhs" = "x$1" \ && func_split_equals_rhs= }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_equals () { $debug_cmd func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= test "x$func_split_equals_lhs" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals # func_split_short_opt SHORTOPT # ----------------------------- # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_short_opt () { $debug_cmd func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"} }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_short_opt () { $debug_cmd func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt # func_usage # ---------- # Echo short help message to standard output and exit. func_usage () { $debug_cmd func_usage_message $ECHO "Run '$progname --help |${PAGER-more}' for full usage" exit 0 } # func_usage_message # ------------------ # Echo short help message to standard output. func_usage_message () { $debug_cmd eval \$ECHO \""Usage: $usage"\" echo $SED -n 's|^# || /^Written by/{ x;p;x } h /^Written by/q' < "$progpath" echo eval \$ECHO \""$usage_message"\" } # func_version # ------------ # Echo version message to standard output and exit. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' /(C)/!b go :more /\./!{ N s|\n# | | b more } :go /^# Written by /,/# warranty; / { s|^# || s|^# *$|| s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| p } /^# Written by / { s|^# || p } /^warranty; /q' < "$progpath" exit $? } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. scriptversion='(GNU libtool) 2.4.6' # func_echo ARG... # ---------------- # Libtool also displays the current mode in messages, so override # funclib.sh func_echo with this custom definition. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" done IFS=$func_echo_IFS } # func_warning ARG... # ------------------- # Libtool warnings are not categorized, so override funclib.sh # func_warning with this simpler definition. func_warning () { $debug_cmd $warning_func ${1+"$@"} } ## ---------------- ## ## Options parsing. ## ## ---------------- ## # Hook in the functions to make sure our own options are parsed during # the option parsing loop. usage='$progpath [OPTION]... [MODE-ARG]...' # Short help message in response to '-h'. usage_message="Options: --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --mode=MODE use operation mode MODE --no-warnings equivalent to '-Wnone' --preserve-dup-deps don't remove duplicate dependency libraries --quiet, --silent don't print informational messages --tag=TAG use configuration variables from tag TAG -v, --verbose print more informational messages than default --version print version information -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -h, --help, --help-all print short, long, or detailed help message " # Additional text appended to 'usage_message' in response to '--help'. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. When passed as first option, '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. Try '$progname --help --mode=MODE' for a more detailed description of MODE. When reporting a bug, please describe a test case to reproduce it and include the following information: host-triplet: $host shell: $SHELL compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) version: $progname (GNU libtool) 2.4.6 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . GNU libtool home page: . General help using GNU software: ." exit 0 } # func_lo2o OBJECT-NAME # --------------------- # Transform OBJECT-NAME from a '.lo' suffix to the platform specific # object suffix. lo2o=s/\\.lo\$/.$objext/ o2lo=s/\\.$objext\$/.lo/ if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_lo2o () { case $1 in *.lo) func_lo2o_result=${1%.lo}.$objext ;; * ) func_lo2o_result=$1 ;; esac }' # func_xform LIBOBJ-OR-SOURCE # --------------------------- # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) # suffix to a '.lo' libtool-object suffix. eval 'func_xform () { func_xform_result=${1%.*}.lo }' else # ...otherwise fall back to using sed. func_lo2o () { func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` } func_xform () { func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` } fi # func_fatal_configuration ARG... # ------------------------------- # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func__fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } # func_config # ----------- # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # ------------- # Display the features supported by this script. func_features () { echo "host: $host" if test yes = "$build_libtool_libs"; then echo "enable shared libraries" else echo "disable shared libraries" fi if test yes = "$build_old_libs"; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag TAGNAME # ----------------------- # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname=$1 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf=/$re_begincf/,/$re_endcf/p # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # ------------------------ # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # libtool_options_prep [ARG]... # ----------------------------- # Preparation for options parsed by libtool. libtool_options_prep () { $debug_mode # Option defaults: opt_config=false opt_dlopen= opt_dry_run=false opt_help=false opt_mode= opt_preserve_dup_deps=false opt_quiet=false nonopt= preserve_args= # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Pass back the list of options. func_quote_for_eval ${1+"$@"} libtool_options_prep_result=$func_quote_for_eval_result } func_add_hook func_options_prep libtool_options_prep # libtool_parse_options [ARG]... # --------------------------------- # Provide handling for libtool specific options. libtool_parse_options () { $debug_cmd # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do _G_opt=$1 shift case $_G_opt in --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) func_config ;; --dlopen|-dlopen) opt_dlopen="${opt_dlopen+$opt_dlopen }$1" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) func_features ;; --finish) set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $_G_opt && break opt_mode=$1 case $1 in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $_G_opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_quiet=false func_append preserve_args " $_G_opt" ;; --no-warnings|--no-warning|--no-warn) opt_warning=false func_append preserve_args " $_G_opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $_G_opt" ;; --silent|--quiet) opt_quiet=: opt_verbose=false func_append preserve_args " $_G_opt" ;; --tag) test $# = 0 && func_missing_arg $_G_opt && break opt_tag=$1 func_append preserve_args " $_G_opt $1" func_enable_tag "$1" shift ;; --verbose|-v) opt_quiet=false opt_verbose=: func_append preserve_args " $_G_opt" ;; # An option not handled by this hook function: *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} libtool_parse_options_result=$func_quote_for_eval_result } func_add_hook func_parse_options libtool_parse_options # libtool_validate_options [ARG]... # --------------------------------- # Perform any sanity checks on option settings and/or unconsumed # arguments. libtool_validate_options () { # save first non-option argument if test 0 -lt $#; then nonopt=$1 shift fi # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" case $host in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match test yes != "$build_libtool_libs" \ && test yes != "$build_old_libs" \ && func_fatal_configuration "not configured to build any kind of library" # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test execute != "$opt_mode"; then func_error "unrecognized option '-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help=$help help="Try '$progname --help --mode=$opt_mode' for more information." } # Pass back the unparsed argument list func_quote_for_eval ${1+"$@"} libtool_validate_options_result=$func_quote_for_eval_result } func_add_hook func_validate_options libtool_validate_options # Process options as early as possible so that --help and --version # can return quickly. func_options ${1+"$@"} eval set dummy "$func_options_result"; shift ## ----------- ## ## Main. ## ## ----------- ## magic='%%%MAGIC variable%%%' magic_exe='%%%MAGIC EXE variable%%%' # Global variables. extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # func_generated_by_libtool # True iff stdin has been generated by Libtool. This function is only # a basic sanity check; it will hardly flush out determined imposters. func_generated_by_libtool_p () { $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p } # func_lalib_unsafe_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if 'file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case $lalib_p_line in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test yes = "$lalib_p" } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { test -f "$1" && $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $debug_cmd save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # 'FILE.' does not work on cygwin managed mounts. func_source () { $debug_cmd case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case $lt_sysroot:$1 in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result='='$func_stripname_result ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $debug_cmd if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with '--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=$1 if test yes = "$build_libtool_libs"; then write_lobj=\'$2\' else write_lobj=none fi if test yes = "$build_old_libs"; then write_oldobj=\'$3\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $debug_cmd # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result= if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result"; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $debug_cmd if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $debug_cmd # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $debug_cmd if test -z "$2" && test -n "$1"; then func_error "Could not determine host file name corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result=$1 fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $debug_cmd if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " '$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result=$3 fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $debug_cmd case $4 in $1 ) func_to_host_path_result=$3$func_to_host_path_result ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via '$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $debug_cmd $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $debug_cmd case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result=$1 } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result=$func_convert_core_msys_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result=$func_convert_core_file_wine_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via '$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $debug_cmd if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd=func_convert_path_$func_stripname_result fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $debug_cmd func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result=$1 } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_msys_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_path_wine_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_dll_def_p FILE # True iff FILE is a Windows DLL '.def' file. # Keep in sync with _LT_DLL_DEF_P in libtool.m4 func_dll_def_p () { $debug_cmd func_dll_def_p_tmp=`$SED -n \ -e 's/^[ ]*//' \ -e '/^\(;.*\)*$/d' \ -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ -e q \ "$1"` test DEF = "$func_dll_def_p_tmp" } # func_mode_compile arg... func_mode_compile () { $debug_cmd # Get the compilation command and the source file. base_compile= srcfile=$nonopt # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg=$arg arg_mode=normal ;; target ) libobj=$arg arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify '-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs=$IFS; IFS=, for arg in $args; do IFS=$save_ifs func_append_quoted lastarg "$arg" done IFS=$save_ifs func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg=$srcfile srcfile=$arg ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with '-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj=$func_basename_result } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from '$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test yes = "$build_libtool_libs" \ || func_fatal_configuration "cannot build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname=$func_basename_result xdir=$func_dirname_result lobj=$xdir$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test yes = "$build_old_libs"; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test no = "$compiler_c_o"; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext lockfile=$output_obj.lock else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test yes = "$need_locks"; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test warn = "$need_locks"; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test no != "$pic_mode"; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test yes = "$suppress_opt"; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test yes = "$build_old_libs"; then if test yes != "$pic_mode"; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test yes = "$compiler_c_o"; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test no != "$need_locks"; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test compile = "$opt_mode" && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a '.o' file suitable for static linking -static only build a '.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix '.c' with the library object suffix, '.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to '-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the '--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the 'install' or 'cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE use a list of object files found in FILE to specify objects -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with '-') are ignored. Every other argument is treated as a filename. Files ending in '.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in '.la', then a libtool library is created, only library objects ('.lo' files) may be specified, and '-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created using 'ar' and 'ranlib', or on Windows using 'lib'. If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode '$opt_mode'" ;; esac echo $ECHO "Try '$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test : = "$opt_help"; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | $SED -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | $SED '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $debug_cmd # The first argument is the command name. cmd=$nonopt test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "'$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "'$file' was not linked with '-export-dynamic'" continue fi func_dirname "$file" "" "." dir=$func_dirname_result if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir=$func_dirname_result ;; *) func_warning "'-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir=$absdir # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic=$magic # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file=$progdir/$program elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file=$progdir/$program fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if $opt_dry_run; then # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS else if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd=\$cmd$args fi } test execute = "$opt_mode" && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $debug_cmd libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "'$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument '$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and '=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_quiet && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the '-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the '$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the '$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the '$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test finish = "$opt_mode" && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $debug_cmd # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=false stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=: ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test X-m = "X$prev" && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the '$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=: if $isdir; then destdir=$dest destname= else func_dirname_and_basename "$dest" "" "." destdir=$func_dirname_result destname=$func_basename_result # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "'$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "'$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir=$func_dirname_result func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking '$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname=$1 shift srcname=$realname test -n "$relink_command" && srcname=${realname}T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme=$stripme case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= ;; esac ;; os2*) case $realname in *_dll.a) tstripme= ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try 'ln -sf' first, because the 'ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib=$destdir/$realname func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name=$func_basename_result instname=$dir/${name}i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest=$destfile destfile= ;; *) func_fatal_help "cannot copy a libtool object to '$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test yes = "$build_old_libs"; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext= case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=.exe fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script '$wrapper'" finalize=: for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` if test -n "$libdir" && test ! -f "$libfile"; then func_warning "'$lib' has not been installed in '$libdir'" finalize=false fi done relink_command= func_source "$wrapper" outputname= if test no = "$fast_install" && test -n "$relink_command"; then $opt_dry_run || { if $finalize; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file=$func_basename_result outputname=$tmpdir/$file # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink '$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file=$outputname else func_warning "cannot relink '$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name=$func_basename_result # Set up the ranlib parameters. oldlib=$destdir/$name func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run '$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test install = "$opt_mode" && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $debug_cmd my_outputname=$1 my_originator=$2 my_pic_p=${3-false} my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms=${my_outputname}S.c else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist=$output_objdir/$my_outputname.nm func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* External symbol declarations for the compiler. */\ " if test yes = "$dlself"; then func_verbose "generating symbol list for '$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from '$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols=$output_objdir/$outputname.exp $opt_dry_run || { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from '$dlprefile'" func_basename "$dlprefile" name=$func_basename_result case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename= if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname"; then func_basename "$dlprefile_dlname" dlprefile_dlbasename=$func_basename_result else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename"; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi func_show_eval '$RM "${nlist}I"' if test -n "$global_symbol_to_import"; then eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[];\ " if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ static void lt_syminit(void) { LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; for (; symbol->name; ++symbol) {" $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" echo >> "$output_objdir/$my_dlsyms" "\ } }" fi echo >> "$output_objdir/$my_dlsyms" "\ LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = { {\"$my_originator\", (void *) 0}," if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ {\"@INIT@\", (void *) <_syminit}," fi case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) $my_pic_p && pic_flag_for_symtable=" $pic_flag" ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for '$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $debug_cmd win32_libid_type=unknown win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || func_cygming_gnu_implib_p "$1" then win32_nmres=import else win32_nmres= fi ;; *) func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s|.*|import| p q } }'` ;; esac case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $debug_cmd sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $debug_cmd match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive that possess that section. Heuristic: eliminate # all those that have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $debug_cmd if func_cygming_gnu_implib_p "$1"; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1"; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result= fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $debug_cmd f_ex_an_ar_dir=$1; shift f_ex_an_ar_oldlib=$1 if test yes = "$lock_old_archive_extraction"; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test yes = "$lock_old_archive_extraction"; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $debug_cmd my_gentop=$1; shift my_oldlibs=${1+"$@"} my_oldobjs= my_xlib= my_xabs= my_xdir= for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib=$func_basename_result my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir=$my_gentop/$my_xlib_u func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` func_basename "$darwin_archive" darwin_base_archive=$func_basename_result darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches; do func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" cd "unfat-$$/$darwin_base_archive-$darwin_arch" func_extract_an_archive "`pwd`" "$darwin_base_archive" cd "$darwin_curdir" $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result=$my_oldobjs } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ that is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options that match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test yes = "$fast_install"; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else \$ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined other_platform || defined ... */ #endif /* portability defines, excluding path handling macros */ #if defined _MSC_VER # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC #elif defined __MINGW32__ # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined __CYGWIN__ # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined other platforms ... */ #endif #if defined PATH_MAX # define LT_PATHMAX PATH_MAX #elif defined MAXPATHLEN # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ defined __OS2__ # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free (stale); stale = 0; } \ } while (0) #if defined LT_DEBUGWRAPPER static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; size_t tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined HAVE_DOS_BASED_FILE_SYSTEM if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined HAVE_DOS_BASED_FILE_SYSTEM } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = (size_t) (q - p); p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (STREQ (str, pat)) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else size_t len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { size_t orig_value_len = strlen (orig_value); size_t add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ size_t len = strlen (new_value); while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[--len] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $debug_cmd case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_suncc_cstd_abi # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! # Several compiler flags select an ABI that is incompatible with the # Cstd library. Avoid specifying it if any are in CXXFLAGS. func_suncc_cstd_abi () { $debug_cmd case " $compile_command " in *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) suncc_use_cstd_abi=no ;; *) suncc_use_cstd_abi=yes ;; esac } # func_mode_link arg... func_mode_link () { $debug_cmd case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll that has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= os2dllname= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=false prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module=$wl-single_module func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test yes != "$build_libtool_libs" \ && func_fatal_configuration "cannot build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg=$1 shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir=$arg prev= continue ;; dlfiles|dlprefiles) $preload || { # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=: } case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test no = "$dlself"; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test dlprefiles = "$prev"; then dlself=yes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test dlfiles = "$prev"; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols=$arg test -f "$arg" \ || func_fatal_error "symbol file '$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex=$arg prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir=$arg prev= continue ;; mllvm) # Clang does not use LLVM to link, so we can simply discard any # '-mllvm $arg' options when doing the link step. prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result if test none != "$pic_object"; then # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object fi # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file '$arg' does not exist" fi arg=$save_arg prev= continue ;; os2dllname) os2dllname=$arg prev= continue ;; precious_regex) precious_files_regex=$arg prev= continue ;; release) release=-$arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test rpath = "$prev"; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds=$arg prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg=$arg case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "'-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test X-export-symbols = "X$arg"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between '-L' and '$1'" else func_fatal_error "need path for '-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of '$dir'" dir=$absdir ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test X-lc = "X$arg" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test X-lc = "X$arg" && continue ;; esac elif test X-lc_r = "X$arg"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -mllvm) prev=mllvm continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module=$wl-multi_module continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "'-no-install' is ignored for $host" func_warning "assuming '-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -os2dllname) prev=os2dllname continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # -fstack-protector* stack protector flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -stdlib=* select c++ std lib with clang -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; -Z*) if test os2 = "`expr $host : '.*\(os2\)'`"; then # OS/2 uses -Zxxx to specify OS/2-specific options compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case $arg in -Zlinker | -Zstack) prev=xcompiler ;; esac continue else # Otherwise treat like 'Some other compiler flag' below func_quote_for_eval "$arg" arg=$func_quote_for_eval_result fi ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result test none = "$pic_object" || { # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object } # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test dlfiles = "$prev"; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test dlprefiles = "$prev"; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the '$prevarg' option requires an argument" if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname=$func_basename_result libobjs_save=$libobjs if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" # Definition is injected by LT_CONFIG during libtool generation. func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" func_dirname "$output" "/" "" output_objdir=$func_dirname_result$objdir func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test lib = "$linkmode"; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=false newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test lib,link = "$linkmode,$pass"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs=$tmp_deplibs fi if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass"; then libs=$deplibs deplibs= fi if test prog = "$linkmode"; then case $pass in dlopen) libs=$dlfiles ;; dlpreopen) libs=$dlprefiles ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test lib,dlpreopen = "$linkmode,$pass"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs=$dlprefiles fi if test dlopen = "$pass"; then # Collect dlpreopened libraries save_deplibs=$deplibs deplibs= fi for deplib in $libs; do lib= found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test lib != "$linkmode" && test prog != "$linkmode"; then func_warning "'-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test lib = "$linkmode"; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib=$searchdir/lib$name$search_ext if test -f "$lib"; then if test .la = "$search_ext"; then found=: else found=false fi break 2 fi done done if $found; then # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll=$l done if test "X$ll" = "X$old_library"; then # only static version available found=false func_dirname "$lib" "" "." ladir=$func_dirname_result lib=$ladir/$old_library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi else # deplib doesn't seem to be a libtool library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l *.ltframework) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test conv = "$pass" && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi if test scan = "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "'-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test link = "$pass"; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=false case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=: fi ;; pass_all) valid_a_lib=: ;; esac if $valid_a_lib; then echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" else echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." fi ;; esac continue ;; prog) if test link != "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test conv = "$pass"; then deplibs="$deplib $deplibs" elif test prog = "$linkmode"; then if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=: continue ;; esac # case $deplib $found || test -f "$lib" \ || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "'$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir=$func_dirname_result dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass" || { test prog != "$linkmode" && test lib != "$linkmode"; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test conv = "$pass"; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for '$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test prog != "$linkmode" && test lib != "$linkmode"; then func_fatal_error "'$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test yes = "$prefer_static_libs" || test built,no = "$prefer_static_libs,$installed"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib=$l done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for '$lib'" fi # This library was specified with -dlopen. if test dlopen = "$pass"; then test -z "$libdir" \ && func_fatal_error "cannot -dlopen a convenience library: '$lib'" if test -z "$dlname" || test yes != "$dlopen_support" || test no = "$build_libtool_libs" then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of '$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir=$ladir fi ;; esac func_basename "$lib" laname=$func_basename_result # Find the relevant object directory and library name. if test yes = "$installed"; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library '$lib' was moved." dir=$ladir absdir=$abs_ladir libdir=$abs_ladir else dir=$lt_sysroot$libdir absdir=$lt_sysroot$libdir fi test yes = "$hardcode_automatic" && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir=$ladir absdir=$abs_ladir # Remove this search path later func_append notinst_path " $abs_ladir" else dir=$ladir/$objdir absdir=$abs_ladir/$objdir # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test dlpreopen = "$pass"; then if test -z "$libdir" && test prog = "$linkmode"; then func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" fi case $host in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test lib = "$linkmode"; then deplibs="$dir/$old_library $deplibs" elif test prog,link = "$linkmode,$pass"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test prog = "$linkmode" && test link != "$pass"; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=false if test no != "$link_all_deplibs" || test -z "$library_names" || test no = "$build_libtool_libs"; then linkalldeplibs=: fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if $linkalldeplibs; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test prog,link = "$linkmode,$pass"; then if test -n "$library_names" && { { test no = "$prefer_static_libs" || test built,yes = "$prefer_static_libs,$installed"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then # Make sure the rpath contains only unique directories. case $temp_rpath: in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if $alldeplibs && { test pass_all = "$deplibs_check_method" || { test yes = "$build_libtool_libs" && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test built = "$use_static_libs" && test yes = "$installed"; then use_static_libs=no fi if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test no = "$installed"; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule= for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule=$dlpremoduletest break fi done if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then echo if test prog = "$linkmode"; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test lib = "$linkmode" && test yes = "$hardcode_into_libs"; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname=$1 shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname=$dlname elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc* | *os2*) func_arith $current - $age major=$func_arith_result versuffix=-$major ;; esac eval soname=\"$soname_spec\" else soname=$realname fi # Make a new name for the extract_expsyms_cmds to use soroot=$soname func_basename "$soroot" soname=$func_basename_result func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from '$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for '$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test prog = "$linkmode" || test relink != "$opt_mode"; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test no = "$hardcode_direct"; then add=$dir/$linklib case $host in *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; *-*-sysv4*uw2*) add_dir=-L$dir ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir=-L$dir ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we cannot # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library"; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add=$dir/$old_library fi elif test -n "$old_library"; then add=$dir/$old_library fi fi esac elif test no = "$hardcode_minus_L"; then case $host in *-*-sunos*) add_shlibpath=$dir ;; esac add_dir=-L$dir add=-l$name elif test no = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; relink) if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$dir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$absdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name elif test yes = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; *) lib_linked=no ;; esac if test yes != "$lib_linked"; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test prog = "$linkmode"; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test yes != "$hardcode_direct" && test yes != "$hardcode_minus_L" && test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test prog = "$linkmode" || test relink = "$opt_mode"; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$libdir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$libdir add=-l$name elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add=-l$name elif test yes = "$hardcode_automatic"; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib"; then add=$inst_prefix_dir$libdir/$linklib else add=$libdir/$linklib fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir=-L$libdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name fi if test prog = "$linkmode"; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test prog = "$linkmode"; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test unsupported != "$hardcode_direct"; then test -n "$old_library" && linklib=$old_library compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test yes = "$build_libtool_libs"; then # Not a shared library if test pass_all != "$deplibs_check_method"; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system cannot link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test yes = "$module"; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test lib = "$linkmode"; then if test -n "$dependency_libs" && { test yes != "$hardcode_into_libs" || test yes = "$build_old_libs" || test yes = "$link_static"; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs=$temp_deplibs fi func_append newlib_search_path " $absdir" # Link against this library test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test no != "$link_all_deplibs"; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path=$deplib ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of '$dir'" absdir=$dir fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names"; then for tmp in $deplibrary_names; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl"; then depdepl=$absdir/$objdir/$depdepl darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" path= fi fi ;; *) path=-L$absdir/$objdir ;; esac else eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "'$deplib' seems to be moved" path=-L$absdir fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test link = "$pass"; then if test prog = "$linkmode"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs=$newdependency_libs if test dlpreopen = "$pass"; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test dlopen != "$pass"; then test conv = "$pass" || { # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= } if test prog,link = "$linkmode,$pass"; then vars="compile_deplibs finalize_deplibs" else vars=deplibs fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Add Sun CC postdeps if required: test CXX = "$tagname" && { case $host_os in linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; solaris*) func_cc_basename "$CC" case $func_cc_basename_result in CC* | sunCC*) func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; esac } # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i= ;; esac if test -n "$i"; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test prog = "$linkmode"; then dlfiles=$newdlfiles fi if test prog = "$linkmode" || test lib = "$linkmode"; then dlprefiles=$newdlprefiles fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "'-R' is ignored for archives" test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "'-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "'-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs=$output func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form 'libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test no = "$module" \ && func_fatal_help "libtool library '$output' must begin with 'lib'" if test no != "$need_lib_prefix"; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test pass_all != "$deplibs_check_method"; then func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test no = "$dlself" \ || func_warning "'-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test 1 -lt "$#" \ && func_warning "ignoring multiple '-rpath's for a libtool library" install_libdir=$1 oldlibs= if test -z "$rpath"; then if test yes = "$build_libtool_libs"; then # Building a libtool convenience library. # Some compilers have problems with a '.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "'-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs=$IFS; IFS=: set dummy $vinfo 0 0 0 shift IFS=$save_ifs test -n "$7" && \ func_fatal_help "too many parameters to '-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major=$1 number_minor=$2 number_revision=$3 # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # that has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|freebsd-elf|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_revision ;; freebsd-aout|qnx|sunos) current=$number_major revision=$number_minor age=0 ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_minor lt_irix_increment=no ;; esac ;; no) current=$1 revision=$2 age=$3 ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT '$current' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION '$revision' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE '$age' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE '$age' is greater than the current interface number '$current'" func_fatal_error "'$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" # On Darwin other compilers case $CC in nagfor*) verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" ;; *) verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; esac ;; freebsd-aout) major=.$current versuffix=.$current.$revision ;; freebsd-elf) func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; irix | nonstopux) if test no = "$lt_irix_increment"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring=$verstring_prefix$major.$revision # Add in all the interfaces that we are compatible with. loop=$revision while test 0 -ne "$loop"; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring_prefix$major.$iface:$verstring done # Before this point, $major must not contain '.'. major=.$major versuffix=$major.$revision ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=.$current.$age.$revision verstring=$current.$age.$revision # Add in all the interfaces that we are compatible with. loop=$age while test 0 -ne "$loop"; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring:$iface.0 done # Make executables depend on our current version. func_append verstring ":$current.0" ;; qnx) major=.$current versuffix=.$current ;; sco) major=.$current versuffix=.$current ;; sunos) major=.$current versuffix=.$current.$revision ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 file systems. func_arith $current - $age major=$func_arith_result versuffix=-$major ;; *) func_fatal_configuration "unknown library version type '$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring=0.0 ;; esac if test no = "$need_version"; then versuffix= else versuffix=.0.0 fi fi # Remove version info from name if versioning should be avoided if test yes,no = "$avoid_version,$need_version"; then major= versuffix= verstring= fi # Check to see if the archive will have undefined symbols. if test yes = "$allow_undefined"; then if test unsupported = "$allow_undefined_flag"; then if test yes = "$build_old_libs"; then func_warning "undefined symbols not allowed in $host shared libraries; building static only" build_libtool_libs=no else func_fatal_error "can't build $host shared library unless -no-undefined is specified" fi fi else # Don't allow undefined symbols. allow_undefined_flag=$no_undefined_flag fi fi func_generate_dlsyms "$libname" "$libname" : func_append libobjs " $symfileobj" test " " = "$libobjs" && libobjs= if test relink != "$opt_mode"; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) if test -n "$precious_files_regex"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles=$dlfiles dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles=$dlprefiles dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test yes = "$build_libtool_need_lc"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release= versuffix= major= newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib=$potent_lib while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | $SED 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib= ;; esac fi if test -n "$a_deplib"; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib=$potent_lib # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs= tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test yes = "$allow_libtool_libs_with_static_runtimes"; then for i in $predeps $postdeps; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test none = "$deplibs_check_method"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test yes = "$droppeddeps"; then if test yes = "$module"; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test no = "$allow_undefined"; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs=$new_libs # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test yes = "$build_libtool_libs"; then # Remove $wl instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test yes = "$hardcode_into_libs"; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath=$finalize_rpath test relink = "$opt_mode" || rpath=$compile_rpath$rpath for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath=$finalize_shlibpath test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname=$1 shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname=$realname fi if test -z "$dlname"; then dlname=$soname fi lib=$output_objdir/$realname linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols=$output_objdir/$libname.uexp func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile func_dll_def_p "$export_symbols" || { # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols=$export_symbols export_symbols= always_export_symbols=yes } fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs=$IFS; IFS='~' for cmd1 in $cmds; do IFS=$save_ifs # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test yes = "$try_normal_branch" \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=$output_objdir/$output_la.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS=$save_ifs if test -n "$export_symbols_regex" && test : != "$skipped_export"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test : != "$skipped_export" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs=$tmp_deplibs if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test yes = "$compiler_needs_object" && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test : != "$skipped_export" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then output=$output_objdir/$output_la.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then output=$output_objdir/$output_la.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test yes = "$compiler_needs_object"; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-$k.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test -z "$objlist" || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test 1 -eq "$k"; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-$k.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-$k.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi ${skipped_export-false} && { func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi } test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs=$IFS; IFS='~' for cmd in $concat_cmds; do IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi ${skipped_export-false} && { if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi } libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs=$IFS; IFS='~' for cmd in $cmds; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs # Restore the uninstalled library and exit if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test yes = "$module" || test yes = "$export_dynamic"; then # On all known operating systems, these are identical. dlname=$soname fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "'-R' is ignored for objects" test -n "$vinfo" && \ func_warning "'-version-info' is ignored for objects" test -n "$release" && \ func_warning "'-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object '$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj=$output ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # if reload_cmds runs $LD directly, get rid of -Wl from # whole_archive_flag_spec and hope we can get by with turning comma # into space. case $reload_cmds in *\$LD[\ \$]*) wl= ;; esac if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags else gentop=$output_objdir/${obj}x func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test yes = "$build_libtool_libs" || libobjs=$non_pic_objects # Create the old-style object. reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs output=$obj func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi test yes = "$build_libtool_libs" || { if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS } if test -n "$pic_flag" || test default != "$pic_mode"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output=$libobj func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "'-version-info' is ignored for programs" test -n "$release" && \ func_warning "'-release' is ignored for programs" $preload \ && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test CXX = "$tagname"; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " $wl-bind_at_load" func_append finalize_command " $wl-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs=$new_libs func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath=$rpath rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath=$rpath if test -n "$libobjs" && test yes = "$build_old_libs"; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" false # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=: case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=false ;; *cygwin* | *mingw* ) test yes = "$build_libtool_libs" || wrappers_required=false ;; *) if test no = "$need_relink" || test yes != "$build_libtool_libs"; then wrappers_required=false fi ;; esac $wrappers_required || { # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command=$compile_command$compile_rpath # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.$objext"; then func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' fi exit $exit_status } if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test yes = "$no_install"; then # We don't need to create a wrapper script. link_command=$compile_var$compile_command$compile_rpath # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi case $hardcode_action,$fast_install in relink,*) # Fast installation is not supported link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath func_warning "this platform does not like uninstalled shared libraries" func_warning "'$output' will be relinked during installation" ;; *,yes) link_command=$finalize_var$compile_command$finalize_rpath relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` ;; *,no) link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath ;; *,needless) link_command=$finalize_var$compile_command$finalize_rpath relink_command= ;; esac # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource=$output_path/$objdir/lt-$output_name.c cwrapper=$output_path/$output_name.exe $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host"; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do case $build_libtool_libs in convenience) oldobjs="$libobjs_save $symfileobj" addlibs=$convenience build_libtool_libs=no ;; module) oldobjs=$libobjs_save addlibs=$old_convenience build_libtool_libs=no ;; *) oldobjs="$old_deplibs $non_pic_objects" $preload && test -f "$symfileobj" \ && func_append oldobjs " $symfileobj" addlibs=$old_convenience ;; esac if test -n "$addlibs"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase=$func_basename_result case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj"; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test -z "$oldobjs"; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test yes = "$build_old_libs" && old_library=$libname.$libext func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test yes = "$hardcode_automatic"; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test yes = "$installed"; then if test -z "$install_libdir"; then break fi output=$output_objdir/${outputname}i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name=$func_basename_result func_resolve_sysroot "$deplib" eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs=$newdependency_libs newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles=$newdlprefiles else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles=$newdlprefiles fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test -n "$bindir"; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result/$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that cannot go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test no,yes = "$installed,$need_relink"; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } if test link = "$opt_mode" || test relink = "$opt_mode"; then func_mode_link ${1+"$@"} fi # func_mode_uninstall arg... func_mode_uninstall () { $debug_cmd RM=$nonopt files= rmforce=false exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic for arg do case $arg in -f) func_append RM " $arg"; rmforce=: ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir=$func_dirname_result if test . = "$dir"; then odir=$objdir else odir=$dir/$objdir fi func_basename "$file" name=$func_basename_result test uninstall = "$opt_mode" && odir=$dir # Remember odir for removal later, being careful to avoid duplicates if test clean = "$opt_mode"; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif $rmforce; then continue fi rmfiles=$file case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case $opt_mode in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test none != "$pic_object"; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test none != "$non_pic_object"; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test clean = "$opt_mode"; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.$objext" if test yes = "$fast_install" && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name"; then func_append rmfiles " $odir/lt-$noexename.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the $objdir's in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then func_mode_uninstall ${1+"$@"} fi test -z "$opt_mode" && { help=$generic_help func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode '$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # where we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: gmp-6.1.0/mini-gmp/000755 001756 001756 00000000000 12615426651 015170 5ustar00bodratobodrato000000 000000 gmp-6.1.0/COPYINGv3000664 001756 001756 00000104516 12615426624 014770 0ustar00bodratobodrato000000 000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . gmp-6.1.0/Makefile.am000664 001756 001756 00000046550 12615426624 015523 0ustar00bodratobodrato000000 000000 ## Process this file with automake to generate Makefile.in # Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2015 Free # Software Foundation, Inc. # # This file is part of the GNU MP Library. # # The GNU MP Library is free software; you can redistribute it and/or modify # it under the terms of either: # # * the GNU Lesser General Public License as published by the Free # Software Foundation; either version 3 of the License, or (at your # option) any later version. # # or # # * the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any # later version. # # or both in parallel, as here. # # The GNU MP Library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received copies of the GNU General Public License and the # GNU Lesser General Public License along with the GNU MP Library. If not, # see https://www.gnu.org/licenses/. # The following options are the same as AM_INIT_AUTOMAKE in configure.in, # except no $(top_builddir) on ansi2knr. That directory is wanted for the # Makefiles in subdirectories, but here we must omit it so automake gives # the actual ansi2knr build rule, not "cd $(top_builddir) && make ansi2knr". # # AUTOMAKE_OPTIONS = 1.8 gnu no-dependencies # Libtool -version-info for libgmp.la and libmp.la. See "Versioning" in the # libtool manual. # # CURRENT:REVISION:AGE # # 1. No interfaces changed, only implementations (good): Increment REVISION. # # 2. Interfaces added, none removed (good): Increment CURRENT, increment # AGE, set REVISION to 0. # # 3. Interfaces removed (BAD, breaks upward compatibility): Increment # CURRENT, set AGE and REVISION to 0. # # Do this separately for libgmp, libgmpxx and libmp, and only for releases. # # GMP -version-info # release libgmp libgmpxx libmp # 2.0.x - - - # 3.0 3:0:0 - 3:0:0 # 3.0.1 3:1:0 - 3:0:0 # 3.1 4:0:1 - 4:0:1 # 3.1.1 4:1:1 - 4:1:1 # 4.0 5:0:2 3:0:0 4:2:1 # 4.0.1 5:1:2 3:1:0 4:3:1 # 4.1 6:0:3 3:2:0 4:4:1 # 4.1.1 6:1:3 3:3:0 4:5:1 # 4.1.2 6:2:3 3:4:0 4:6:1 # 4.1.3 6:3:3 3:5:0 4:7:1 # 4.1.4 6:3:3 3:5:0 4:7:1 WRONG, same as 4.1.3! # 4.2 6:0:3 3:2:0 4:4:1 REALLY WRONG, same as 4.1! # 4.2.1 7:1:4 4:1:1 4:10:1 WRONG for libgmpxx # 4.2.2 7:2:4 4:2:0 4:11:1 # 4.2.3 7:3:4 4:3:0 4:12:1 # 4.2.4 7:4:4 4:4:0 4:13:1 # 4.3.0 8:0:5 5:0:1 4:14:1 # 4.3.1 8:1:5 5:1:1 4:15:1 WRONG Really used same as 4.3.0 # 4.3.2 8:2:5 5:2:1 4:16:1 # 5.0.0 9:0:6 6:0:2 4:20:1 Should have been 10:0:0 # 5.0.1 10:1:0 6:1:2 4:21:1 # 5.0.2 10:2:0 6:2:2 4:22:1 # 5.0.3 10:3:0 6:3:2 4:23:1 # 5.0.4 10:4:0 6:4:2 4:24:1 # 5.0.5 10:5:0 6:5:2 4:25:1 # 5.1.0 11:0:1 7:0:3 - # 5.1.1 11:1:1 7:1:3 - # 5.1.2 11:2:1 7:2:3 - # 6.0.0 12:0:2 8:0:4 - # 6.1.0 13:0:3 9:0:5 - # # Starting at 3:0:0 is a slight abuse of the versioning system, but it # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux # packages of gmp 2. Pretend gmp 2 was 2:0:0, so the interface changes for # gmp 3 mean 3:0:0 is right. # # We interpret "implementation changed" in item "1." above as meaning any # release, ie. the REVISION is incremented every time (if nothing else). # Even if we thought the code generated will be identical on all systems, # it's still good to get the shared library filename (like # libgmpxx.so.3.0.4) incrementing, to make it clear which GMP it's from. LIBGMP_LT_CURRENT = 13 LIBGMP_LT_REVISION = 0 LIBGMP_LT_AGE = 3 LIBGMPXX_LT_CURRENT = 9 LIBGMPXX_LT_REVISION = 0 LIBGMPXX_LT_AGE = 5 SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \ COPYING.LESSERv3 COPYINGv2 COPYINGv3 if WANT_CXX GMPXX_HEADERS_OPTION = gmpxx.h endif EXTRA_DIST += gmpxx.h # gmp.h and mp.h are architecture dependent, mainly since they encode the # limb size used in libgmp. For that reason they belong under $exec_prefix # not $prefix, strictly speaking. # # $exec_prefix/include is not in the default include path for gcc built to # the same $prefix and $exec_prefix, which might mean gmp.h is not found, # but anyone knowledgeable enough to be playing with exec_prefix will be able # to address that. # includeexecdir = $(exec_prefix)/include include_HEADERS = $(GMPXX_HEADERS_OPTION) nodist_includeexec_HEADERS = gmp.h lib_LTLIBRARIES = libgmp.la $(GMPXX_LTLIBRARIES_OPTION) BUILT_SOURCES = gmp.h DISTCLEANFILES = $(BUILT_SOURCES) config.m4 @gmp_srclinks@ # Tell gmp.h it's building gmp, not an application, used by windows DLL stuff. AM_CPPFLAGS=-D__GMP_WITHIN_GMP MPF_OBJECTS = mpf/init$U.lo mpf/init2$U.lo mpf/inits$U.lo mpf/set$U.lo \ mpf/set_ui$U.lo mpf/set_si$U.lo mpf/set_str$U.lo mpf/set_d$U.lo \ mpf/set_z$U.lo mpf/iset$U.lo mpf/iset_ui$U.lo mpf/iset_si$U.lo \ mpf/iset_str$U.lo mpf/iset_d$U.lo mpf/clear$U.lo mpf/clears$U.lo \ mpf/get_str$U.lo mpf/dump$U.lo mpf/size$U.lo mpf/eq$U.lo mpf/reldiff$U.lo \ mpf/sqrt$U.lo mpf/random2$U.lo mpf/inp_str$U.lo mpf/out_str$U.lo \ mpf/add$U.lo mpf/add_ui$U.lo mpf/sub$U.lo mpf/sub_ui$U.lo mpf/ui_sub$U.lo \ mpf/mul$U.lo mpf/mul_ui$U.lo mpf/div$U.lo mpf/div_ui$U.lo mpf/cmp_z$U.lo \ mpf/cmp$U.lo mpf/cmp_d$U.lo mpf/cmp_ui$U.lo mpf/cmp_si$U.lo \ mpf/mul_2exp$U.lo mpf/div_2exp$U.lo mpf/abs$U.lo mpf/neg$U.lo \ mpf/set_q$U.lo mpf/get_d$U.lo mpf/get_d_2exp$U.lo mpf/set_dfl_prec$U.lo \ mpf/set_prc$U.lo mpf/set_prc_raw$U.lo mpf/get_dfl_prec$U.lo \ mpf/get_prc$U.lo mpf/ui_div$U.lo mpf/sqrt_ui$U.lo \ mpf/ceilfloor$U.lo mpf/trunc$U.lo mpf/pow_ui$U.lo \ mpf/urandomb$U.lo mpf/swap$U.lo \ mpf/fits_sint$U.lo mpf/fits_slong$U.lo mpf/fits_sshort$U.lo \ mpf/fits_uint$U.lo mpf/fits_ulong$U.lo mpf/fits_ushort$U.lo \ mpf/get_si$U.lo mpf/get_ui$U.lo \ mpf/int_p$U.lo MPZ_OBJECTS = mpz/abs$U.lo mpz/add$U.lo mpz/add_ui$U.lo \ mpz/aorsmul$U.lo mpz/aorsmul_i$U.lo mpz/and$U.lo mpz/array_init$U.lo \ mpz/bin_ui$U.lo mpz/bin_uiui$U.lo \ mpz/cdiv_q$U.lo mpz/cdiv_q_ui$U.lo \ mpz/cdiv_qr$U.lo mpz/cdiv_qr_ui$U.lo \ mpz/cdiv_r$U.lo mpz/cdiv_r_ui$U.lo mpz/cdiv_ui$U.lo \ mpz/cfdiv_q_2exp$U.lo mpz/cfdiv_r_2exp$U.lo \ mpz/clear$U.lo mpz/clears$U.lo mpz/clrbit$U.lo \ mpz/cmp$U.lo mpz/cmp_d$U.lo mpz/cmp_si$U.lo mpz/cmp_ui$U.lo \ mpz/cmpabs$U.lo mpz/cmpabs_d$U.lo mpz/cmpabs_ui$U.lo \ mpz/com$U.lo mpz/combit$U.lo \ mpz/cong$U.lo mpz/cong_2exp$U.lo mpz/cong_ui$U.lo \ mpz/divexact$U.lo mpz/divegcd$U.lo mpz/dive_ui$U.lo \ mpz/divis$U.lo mpz/divis_ui$U.lo mpz/divis_2exp$U.lo mpz/dump$U.lo \ mpz/export$U.lo mpz/mfac_uiui$U.lo \ mpz/2fac_ui$U.lo mpz/fac_ui$U.lo mpz/oddfac_1$U.lo mpz/prodlimbs$U.lo \ mpz/fdiv_q_ui$U.lo mpz/fdiv_qr$U.lo mpz/fdiv_qr_ui$U.lo \ mpz/fdiv_r$U.lo mpz/fdiv_r_ui$U.lo mpz/fdiv_q$U.lo \ mpz/fdiv_ui$U.lo mpz/fib_ui$U.lo mpz/fib2_ui$U.lo mpz/fits_sint$U.lo \ mpz/fits_slong$U.lo mpz/fits_sshort$U.lo mpz/fits_uint$U.lo \ mpz/fits_ulong$U.lo mpz/fits_ushort$U.lo mpz/gcd$U.lo \ mpz/gcd_ui$U.lo mpz/gcdext$U.lo mpz/get_d$U.lo mpz/get_d_2exp$U.lo \ mpz/get_si$U.lo mpz/get_str$U.lo mpz/get_ui$U.lo mpz/getlimbn$U.lo \ mpz/hamdist$U.lo \ mpz/import$U.lo mpz/init$U.lo mpz/init2$U.lo mpz/inits$U.lo \ mpz/inp_raw$U.lo mpz/inp_str$U.lo mpz/invert$U.lo \ mpz/ior$U.lo mpz/iset$U.lo mpz/iset_d$U.lo mpz/iset_si$U.lo \ mpz/iset_str$U.lo mpz/iset_ui$U.lo mpz/jacobi$U.lo mpz/kronsz$U.lo \ mpz/kronuz$U.lo mpz/kronzs$U.lo mpz/kronzu$U.lo \ mpz/lcm$U.lo mpz/lcm_ui$U.lo mpz/limbs_finish$U.lo \ mpz/limbs_modify$U.lo mpz/limbs_read$U.lo mpz/limbs_write$U.lo \ mpz/lucnum_ui$U.lo mpz/lucnum2_ui$U.lo \ mpz/millerrabin$U.lo mpz/mod$U.lo mpz/mul$U.lo mpz/mul_2exp$U.lo \ mpz/mul_si$U.lo mpz/mul_ui$U.lo \ mpz/n_pow_ui$U.lo mpz/neg$U.lo mpz/nextprime$U.lo \ mpz/out_raw$U.lo mpz/out_str$U.lo mpz/perfpow$U.lo mpz/perfsqr$U.lo \ mpz/popcount$U.lo mpz/pow_ui$U.lo mpz/powm$U.lo mpz/powm_sec$U.lo \ mpz/powm_ui$U.lo mpz/primorial_ui$U.lo \ mpz/pprime_p$U.lo mpz/random$U.lo mpz/random2$U.lo \ mpz/realloc$U.lo mpz/realloc2$U.lo mpz/remove$U.lo mpz/roinit_n$U.lo \ mpz/root$U.lo mpz/rootrem$U.lo mpz/rrandomb$U.lo mpz/scan0$U.lo \ mpz/scan1$U.lo mpz/set$U.lo mpz/set_d$U.lo mpz/set_f$U.lo \ mpz/set_q$U.lo mpz/set_si$U.lo mpz/set_str$U.lo mpz/set_ui$U.lo \ mpz/setbit$U.lo \ mpz/size$U.lo mpz/sizeinbase$U.lo mpz/sqrt$U.lo \ mpz/sqrtrem$U.lo mpz/sub$U.lo mpz/sub_ui$U.lo mpz/swap$U.lo \ mpz/tdiv_ui$U.lo mpz/tdiv_q$U.lo mpz/tdiv_q_2exp$U.lo \ mpz/tdiv_q_ui$U.lo mpz/tdiv_qr$U.lo mpz/tdiv_qr_ui$U.lo \ mpz/tdiv_r$U.lo mpz/tdiv_r_2exp$U.lo mpz/tdiv_r_ui$U.lo \ mpz/tstbit$U.lo mpz/ui_pow_ui$U.lo mpz/ui_sub$U.lo mpz/urandomb$U.lo \ mpz/urandomm$U.lo mpz/xor$U.lo MPQ_OBJECTS = mpq/abs$U.lo mpq/aors$U.lo \ mpq/canonicalize$U.lo mpq/clear$U.lo mpq/clears$U.lo \ mpq/cmp$U.lo mpq/cmp_si$U.lo mpq/cmp_ui$U.lo mpq/div$U.lo \ mpq/get_d$U.lo mpq/get_den$U.lo mpq/get_num$U.lo mpq/get_str$U.lo \ mpq/init$U.lo mpq/inits$U.lo mpq/inp_str$U.lo mpq/inv$U.lo \ mpq/md_2exp$U.lo mpq/mul$U.lo mpq/neg$U.lo mpq/out_str$U.lo \ mpq/set$U.lo mpq/set_den$U.lo mpq/set_num$U.lo \ mpq/set_si$U.lo mpq/set_str$U.lo mpq/set_ui$U.lo \ mpq/equal$U.lo mpq/set_z$U.lo mpq/set_d$U.lo \ mpq/set_f$U.lo mpq/swap$U.lo MPN_OBJECTS = mpn/fib_table$U.lo mpn/mp_bases$U.lo PRINTF_OBJECTS = \ printf/asprintf$U.lo printf/asprntffuns$U.lo \ printf/doprnt$U.lo printf/doprntf$U.lo printf/doprnti$U.lo \ printf/fprintf$U.lo \ printf/obprintf$U.lo printf/obvprintf$U.lo printf/obprntffuns$U.lo \ printf/printf$U.lo printf/printffuns$U.lo \ printf/snprintf$U.lo printf/snprntffuns$U.lo \ printf/sprintf$U.lo printf/sprintffuns$U.lo \ printf/vasprintf$U.lo printf/vfprintf$U.lo printf/vprintf$U.lo \ printf/vsnprintf$U.lo printf/vsprintf$U.lo \ printf/repl-vsnprintf$U.lo SCANF_OBJECTS = \ scanf/doscan$U.lo scanf/fscanf$U.lo scanf/fscanffuns$U.lo \ scanf/scanf$U.lo scanf/sscanf$U.lo scanf/sscanffuns$U.lo \ scanf/vfscanf$U.lo scanf/vscanf$U.lo scanf/vsscanf$U.lo RANDOM_OBJECTS = \ rand/rand$U.lo rand/randclr$U.lo rand/randdef$U.lo rand/randiset$U.lo \ rand/randlc2s$U.lo rand/randlc2x$U.lo rand/randmt$U.lo \ rand/randmts$U.lo rand/rands$U.lo rand/randsd$U.lo rand/randsdui$U.lo \ rand/randbui$U.lo rand/randmui$U.lo # no $U for C++ files CXX_OBJECTS = \ cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo cxx/ismpznw.lo \ cxx/limits.lo cxx/osdoprnti.lo cxx/osfuns.lo \ cxx/osmpf.lo cxx/osmpq.lo cxx/osmpz.lo # In libtool 1.5 it doesn't work to build libgmp.la from the convenience # libraries like mpz/libmpz.la. Or rather it works, but it ends up putting # PIC objects into libgmp.a if shared and static are both built. (The PIC # objects go into mpz/.libs/libmpz.a, and thence into .libs/libgmp.a.) # # For now the big lists of objects above are used. Something like mpz/*.lo # would probably work, but might risk missing something out or getting # something extra. The source files for each .lo are listed in the # Makefile.am's in the subdirectories. # # Currently, for libgmp, unlike libmp below, we're not using # -export-symbols, since the tune and speed programs, and perhaps some of # the test programs, want to access undocumented symbols. libgmp_la_SOURCES = gmp-impl.h longlong.h \ assert.c compat.c errno.c extract-dbl.c invalid.c memory.c \ mp_bpl.c mp_clz_tab.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c mp_set_fns.c \ version.c nextprime.c primesieve.c EXTRA_libgmp_la_SOURCES = tal-debug.c tal-notreent.c tal-reent.c libgmp_la_DEPENDENCIES = @TAL_OBJECT@ \ $(MPF_OBJECTS) $(MPZ_OBJECTS) $(MPQ_OBJECTS) \ $(MPN_OBJECTS) @mpn_objs_in_libgmp@ \ $(PRINTF_OBJECTS) $(SCANF_OBJECTS) $(RANDOM_OBJECTS) libgmp_la_LIBADD = $(libgmp_la_DEPENDENCIES) libgmp_la_LDFLAGS = $(GMP_LDFLAGS) $(LIBGMP_LDFLAGS) \ -version-info $(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE) # We need at least one .cc file in $(libgmpxx_la_SOURCES) so automake will # use $(CXXLINK) rather than the plain C $(LINK). cxx/dummy.cc is that # file. if WANT_CXX GMPXX_LTLIBRARIES_OPTION = libgmpxx.la endif libgmpxx_la_SOURCES = cxx/dummy.cc libgmpxx_la_DEPENDENCIES = $(CXX_OBJECTS) libgmp.la libgmpxx_la_LIBADD = $(libgmpxx_la_DEPENDENCIES) libgmpxx_la_LDFLAGS = $(GMP_LDFLAGS) $(LIBGMPXX_LDFLAGS) \ -version-info $(LIBGMPXX_LT_CURRENT):$(LIBGMPXX_LT_REVISION):$(LIBGMPXX_LT_AGE) install-data-hook: @echo '' @echo '+-------------------------------------------------------------+' @echo '| CAUTION: |' @echo '| |' @echo '| If you have not already run "make check", then we strongly |' @echo '| recommend you do so. |' @echo '| |' @echo '| GMP has been carefully tested by its authors, but compilers |' @echo '| are all too often released with serious bugs. GMP tends to |' @echo '| explore interesting corners in compilers and has hit bugs |' @echo '| on quite a few occasions. |' @echo '| |' @echo '+-------------------------------------------------------------+' @echo '' # The "test -f" support for srcdir!=builddir is similar to the automake .c.o # etc rules, but with each foo.c explicitly, since $< is not portable # outside an inference rule. # # A quoted 'foo.c' is used with the "test -f"'s to avoid Sun make rewriting # it as part of its VPATH support. See the autoconf manual "Limitations of # Make". # # Generated .h files which are used by gmp-impl.h are BUILT_SOURCES since # they must exist before anything can be compiled. # # Other generated .h files are also BUILT_SOURCES so as to get all the # build-system stuff over and done with at the start. Also, dependencies on # the .h files are not properly expressed for the various objects that use # them. EXTRA_DIST += bootstrap.c fac_table.h: gen-fac$(EXEEXT_FOR_BUILD) ./gen-fac $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fac_table.h || (rm -f fac_table.h; exit 1) BUILT_SOURCES += fac_table.h gen-fac$(EXEEXT_FOR_BUILD): gen-fac$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-fac$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fac$(U_FOR_BUILD).c -o gen-fac$(EXEEXT_FOR_BUILD) DISTCLEANFILES += gen-fac$(EXEEXT_FOR_BUILD) EXTRA_DIST += gen-fac.c fib_table.h: gen-fib$(EXEEXT_FOR_BUILD) ./gen-fib header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fib_table.h || (rm -f fib_table.h; exit 1) BUILT_SOURCES += fib_table.h mpn/fib_table.c: gen-fib$(EXEEXT_FOR_BUILD) ./gen-fib table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1) BUILT_SOURCES += mpn/fib_table.c gen-fib$(EXEEXT_FOR_BUILD): gen-fib$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD) DISTCLEANFILES += gen-fib$(EXEEXT_FOR_BUILD) EXTRA_DIST += gen-fib.c mp_bases.h: gen-bases$(EXEEXT_FOR_BUILD) ./gen-bases header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mp_bases.h || (rm -f mp_bases.h; exit 1) BUILT_SOURCES += mp_bases.h mpn/mp_bases.c: gen-bases$(EXEEXT_FOR_BUILD) ./gen-bases table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/mp_bases.c || (rm -f mpn/mp_bases.c; exit 1) BUILT_SOURCES += mpn/mp_bases.c gen-bases$(EXEEXT_FOR_BUILD): gen-bases$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-bases$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-bases$(U_FOR_BUILD).c -o gen-bases$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) DISTCLEANFILES += gen-bases$(EXEEXT_FOR_BUILD) EXTRA_DIST += gen-bases.c trialdivtab.h: gen-trialdivtab$(EXEEXT_FOR_BUILD) ./gen-trialdivtab $(GMP_LIMB_BITS) 8000 >trialdivtab.h || (rm -f trialdivtab.h; exit 1) BUILT_SOURCES += trialdivtab.h gen-trialdivtab$(EXEEXT_FOR_BUILD): gen-trialdivtab$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-trialdivtab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-trialdivtab$(U_FOR_BUILD).c -o gen-trialdivtab$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) DISTCLEANFILES += gen-trialdivtab$(EXEEXT_FOR_BUILD) EXTRA_DIST += gen-trialdivtab.c mpn/jacobitab.h: gen-jacobitab$(EXEEXT_FOR_BUILD) ./gen-jacobitab >mpn/jacobitab.h || (rm -f mpn/jacobitab.h; exit 1) BUILT_SOURCES += mpn/jacobitab.h gen-jacobitab$(EXEEXT_FOR_BUILD): gen-jacobitab$(U_FOR_BUILD).c $(CC_FOR_BUILD) `test -f 'gen-jacobitab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-jacobitab$(U_FOR_BUILD).c -o gen-jacobitab$(EXEEXT_FOR_BUILD) DISTCLEANFILES += gen-jacobitab$(EXEEXT_FOR_BUILD) EXTRA_DIST += gen-jacobitab.c mpn/perfsqr.h: gen-psqr$(EXEEXT_FOR_BUILD) ./gen-psqr $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1) BUILT_SOURCES += mpn/perfsqr.h gen-psqr$(EXEEXT_FOR_BUILD): gen-psqr$(U_FOR_BUILD).c bootstrap.c $(CC_FOR_BUILD) `test -f 'gen-psqr$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-psqr$(U_FOR_BUILD).c -o gen-psqr$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD) DISTCLEANFILES += gen-psqr$(EXEEXT_FOR_BUILD) EXTRA_DIST += gen-psqr.c # Distribute mini-gmp. Test sources copied by dist-hook. EXTRA_DIST += mini-gmp/README mini-gmp/mini-gmp.c mini-gmp/mini-gmp.h \ mini-gmp/tests/Makefile mini-gmp/tests/run-tests # Avoid: CVS - cvs directories # *~ - emacs backups # .#* - cvs merge originals # # *~ and .#* only occur when a whole directory without it's own Makefile.am # is distributed, like "doc" or the mpn cpu subdirectories. # dist-hook: -find $(distdir) \( -name CVS -type d \) -o -name "*~" -o -name ".#*" \ | xargs rm -rf cp "$(srcdir)"/mini-gmp/tests/*.[ch] "$(distdir)/mini-gmp/tests" # grep -F $(VERSION) $(srcdir)/Makefile.am \ # | grep -q "^# *$(VERSION) *$(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE) *$(LIBGMPXX_LT_CURRENT):$(LIBGMPXX_LT_REVISION):$(LIBGMPXX_LT_AGE)" # test -z "`sed -n 's/^# *[0-9]*\.[0-9]*\.[0-9]* *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\).*/A\1\nB\2\nC\3/p' $(srcdir)/Makefile.am | grep -v 'A6:3:3\|B3:5:0\|C4:7:1' | sort | uniq -d`" .PHONY: check-mini-gmp clean-mini-gmp check-mini-gmp: abs_srcdir="`cd $(srcdir) && pwd`" ; \ $(MKDIR_P) mini-gmp/tests \ && cd mini-gmp/tests \ && LD_LIBRARY_PATH="../../.libs:$$LD_LIBRARY_PATH" \ DYLD_LIBRARY_PATH="../../.libs:$$DYLD_LIBRARY_PATH" \ $(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" \ VPATH="$$abs_srcdir/mini-gmp/tests" \ srcdir="$$abs_srcdir/mini-gmp/tests" \ MINI_GMP_DIR="$$abs_srcdir/mini-gmp" \ LDFLAGS="-L../../.libs" \ LIBS="-lgmp -lm" \ CC="$(CC_FOR_BUILD)" EXTRA_CFLAGS="-g -I../.." check clean-mini-gmp: if [ -d mini-gmp/tests ] ; then \ abs_srcdir="`cd $(srcdir) && pwd`" ; \ cd mini-gmp/tests \ && $(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" clean ; \ fi clean-local: clean-mini-gmp distclean-local: clean-mini-gmp gmp-6.1.0/gen-fac.c000664 001756 001756 00000016565 12615426624 015136 0ustar00bodratobodrato000000 000000 /* Generate data for combinatorics: fac_ui, bin_uiui, ... Copyright 2002, 2011-2015 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include #include #include "bootstrap.c" int mpz_remove_twos (mpz_t x) { mp_bitcnt_t r = mpz_scan1(x, 0); mpz_tdiv_q_2exp (x, x, r); return r; } /* returns 0 on success */ int gen_consts (int numb, int nail, int limb) { mpz_t x, mask, y, last; unsigned long a, b; unsigned long ofl, ofe; printf ("/* This file is automatically generated by gen-fac.c */\n\n"); printf ("#if GMP_NUMB_BITS != %d\n", numb); printf ("Error , error this data is for %d GMP_NUMB_BITS only\n", numb); printf ("#endif\n"); #if 0 printf ("#if GMP_LIMB_BITS != %d\n", limb); printf ("Error , error this data is for %d GMP_LIMB_BITS only\n", limb); printf ("#endif\n"); #endif printf ("/* This table is 0!,1!,2!,3!,...,n! where n! has <= GMP_NUMB_BITS bits */\n"); printf ("#define ONE_LIMB_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1"); mpz_init_set_ui (x, 1); mpz_init (last); for (b = 2;; b++) { mpz_mul_ui (x, x, b); /* so b!=a */ if (mpz_sizeinbase (x, 2) > numb) break; printf ("),CNST_LIMB(0x"); mpz_out_str (stdout, 16, x); } printf (")\n"); printf ("\n/* This table is 0!,1!,2!/2,3!/2,...,n!/2^sn where n!/2^sn is an */\n"); printf ("/* odd integer for each n, and n!/2^sn has <= GMP_NUMB_BITS bits */\n"); printf ("#define ONE_LIMB_ODD_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x1"); mpz_set_ui (x, 1); for (b = 3;; b++) { for (a = b; (a & 1) == 0; a >>= 1); mpz_swap (last, x); mpz_mul_ui (x, last, a); if (mpz_sizeinbase (x, 2) > numb) break; printf ("),CNST_LIMB(0x"); mpz_out_str (stdout, 16, x); } printf (")\n"); printf ("#define ODD_FACTORIAL_TABLE_MAX CNST_LIMB(0x"); mpz_out_str (stdout, 16, last); printf (")\n"); ofl = b - 1; printf ("#define ODD_FACTORIAL_TABLE_LIMIT (%lu)\n", ofl); mpz_init2 (mask, numb + 1); mpz_setbit (mask, numb); mpz_sub_ui (mask, mask, 1); printf ("\n/* Previous table, continued, values modulo 2^GMP_NUMB_BITS */\n"); printf ("#define ONE_LIMB_ODD_FACTORIAL_EXTTABLE CNST_LIMB(0x"); mpz_and (x, x, mask); mpz_out_str (stdout, 16, x); mpz_init (y); mpz_bin_uiui (y, b, b/2); b++; for (;; b++) { for (a = b; (a & 1) == 0; a >>= 1); if (a == b) { mpz_divexact_ui (y, y, a/2+1); mpz_mul_ui (y, y, a); } else mpz_mul_2exp (y, y, 1); if (mpz_sizeinbase (y, 2) > numb) break; mpz_mul_ui (x, x, a); mpz_and (x, x, mask); printf ("),CNST_LIMB(0x"); mpz_out_str (stdout, 16, x); } printf (")\n"); ofe = b - 1; printf ("#define ODD_FACTORIAL_EXTTABLE_LIMIT (%lu)\n", ofe); printf ("\n/* This table is 1!!,3!!,...,(2n+1)!! where (2n+1)!! has <= GMP_NUMB_BITS bits */\n"); printf ("#define ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE CNST_LIMB(0x1"); mpz_set_ui (x, 1); for (b = 3;; b+=2) { mpz_swap (last, x); mpz_mul_ui (x, last, b); if (mpz_sizeinbase (x, 2) > numb) break; printf ("),CNST_LIMB(0x"); mpz_out_str (stdout, 16, x); } printf (")\n"); printf ("#define ODD_DOUBLEFACTORIAL_TABLE_MAX CNST_LIMB(0x"); mpz_out_str (stdout, 16, last); printf (")\n"); printf ("#define ODD_DOUBLEFACTORIAL_TABLE_LIMIT (%lu)\n", b - 2); printf ("\n/* This table x_1, x_2,... contains values s.t. x_n^n has <= GMP_NUMB_BITS bits */\n"); printf ("#define NTH_ROOT_NUMB_MASK_TABLE (GMP_NUMB_MASK"); for (b = 2;b <= 8; b++) { mpz_root (x, mask, b); printf ("),CNST_LIMB(0x"); mpz_out_str (stdout, 16, x); } printf (")\n"); mpz_add_ui (mask, mask, 1); printf ("\n/* This table contains inverses of odd factorials, modulo 2^GMP_NUMB_BITS */\n"); printf ("\n/* It begins with (2!/2)^-1=1 */\n"); printf ("#define ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE CNST_LIMB(0x1"); mpz_set_ui (x, 1); for (b = 3;b <= ofe - 2; b++) { for (a = b; (a & 1) == 0; a >>= 1); mpz_mul_ui (x, x, a); mpz_invert (y, x, mask); printf ("),CNST_LIMB(0x"); mpz_out_str (stdout, 16, y); } printf (")\n"); ofe = (ofe / 16 + 1) * 16; printf ("\n/* This table contains 2n-popc(2n) for small n */\n"); printf ("\n/* It begins with 2-1=1 (n=1) */\n"); printf ("#define TABLE_2N_MINUS_POPC_2N 1"); for (b = 4; b <= ofe; b += 2) { mpz_set_ui (x, b); printf (",%lu",b - mpz_popcount (x)); } printf ("\n"); printf ("#define TABLE_LIMIT_2N_MINUS_POPC_2N %lu\n", ofe + 1); ofl = (ofl + 1) / 2; printf ("#define ODD_CENTRAL_BINOMIAL_OFFSET (%lu)\n", ofl); printf ("\n/* This table contains binomial(2k,k)/2^t */\n"); printf ("\n/* It begins with ODD_CENTRAL_BINOMIAL_TABLE_MIN */\n"); printf ("#define ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE "); for (b = ofl;; b++) { mpz_bin_uiui (x, 2 * b, b); mpz_remove_twos (x); if (mpz_sizeinbase (x, 2) > numb) break; if (b != ofl) printf ("),"); printf("CNST_LIMB(0x"); mpz_out_str (stdout, 16, x); } printf (")\n"); ofe = b - 1; printf ("#define ODD_CENTRAL_BINOMIAL_TABLE_LIMIT (%lu)\n", ofe); printf ("\n/* This table contains the inverses of elements in the previous table. */\n"); printf ("#define ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE CNST_LIMB(0x"); for (b = ofl; b <= ofe; b++) { mpz_bin_uiui (x, 2 * b, b); mpz_remove_twos (x); mpz_invert (x, x, mask); mpz_out_str (stdout, 16, x); if (b != ofe) printf ("),CNST_LIMB(0x"); } printf (")\n"); printf ("\n/* This table contains the values t in the formula binomial(2k,k)/2^t */\n"); printf ("#define CENTRAL_BINOMIAL_2FAC_TABLE "); for (b = ofl; b <= ofe; b++) { mpz_bin_uiui (x, 2 * b, b); printf ("%d", mpz_remove_twos (x)); if (b != ofe) printf (","); } printf ("\n"); return 0; } int main (int argc, char *argv[]) { int nail_bits, limb_bits, numb_bits; if (argc != 3) { fprintf (stderr, "Usage: gen-fac limbbits nailbits\n"); exit (1); } limb_bits = atoi (argv[1]); nail_bits = atoi (argv[2]); numb_bits = limb_bits - nail_bits; if (limb_bits < 2 || nail_bits < 0 || numb_bits < 1) { fprintf (stderr, "Invalid limb/nail bits %d,%d\n", limb_bits, nail_bits); exit (1); } gen_consts (numb_bits, nail_bits, limb_bits); return 0; } gmp-6.1.0/extract-dbl.c000664 001756 001756 00000016370 12615426624 016041 0ustar00bodratobodrato000000 000000 /* __gmp_extract_double -- convert from double to array of mp_limb_t. Copyright 1996, 1999-2002, 2006, 2012 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "gmp.h" #include "gmp-impl.h" #ifdef XDEBUG #undef _GMP_IEEE_FLOATS #endif #ifndef _GMP_IEEE_FLOATS #define _GMP_IEEE_FLOATS 0 #endif /* Extract a non-negative double in d. */ int __gmp_extract_double (mp_ptr rp, double d) { long exp; unsigned sc; #ifdef _LONG_LONG_LIMB #define BITS_PER_PART 64 /* somewhat bogus */ unsigned long long int manl; #else #define BITS_PER_PART GMP_LIMB_BITS unsigned long int manh, manl; #endif /* BUGS 1. Should handle Inf and NaN in IEEE specific code. 2. Handle Inf and NaN also in default code, to avoid hangs. 3. Generalize to handle all GMP_LIMB_BITS >= 32. 4. This lits is incomplete and misspelled. */ ASSERT (d >= 0.0); if (d == 0.0) { MPN_ZERO (rp, LIMBS_PER_DOUBLE); return 0; } #if _GMP_IEEE_FLOATS { #if defined (__alpha) && __GNUC__ == 2 && __GNUC_MINOR__ == 8 /* Work around alpha-specific bug in GCC 2.8.x. */ volatile #endif union ieee_double_extract x; x.d = d; exp = x.s.exp; #if BITS_PER_PART == 64 /* generalize this to BITS_PER_PART > BITS_IN_MANTISSA */ manl = (((mp_limb_t) 1 << 63) | ((mp_limb_t) x.s.manh << 43) | ((mp_limb_t) x.s.manl << 11)); if (exp == 0) { /* Denormalized number. Don't try to be clever about this, since it is not an important case to make fast. */ exp = 1; do { manl = manl << 1; exp--; } while ((manl & GMP_LIMB_HIGHBIT) == 0); } #endif #if BITS_PER_PART == 32 manh = ((mp_limb_t) 1 << 31) | (x.s.manh << 11) | (x.s.manl >> 21); manl = x.s.manl << 11; if (exp == 0) { /* Denormalized number. Don't try to be clever about this, since it is not an important case to make fast. */ exp = 1; do { manh = (manh << 1) | (manl >> 31); manl = manl << 1; exp--; } while ((manh & GMP_LIMB_HIGHBIT) == 0); } #endif #if BITS_PER_PART != 32 && BITS_PER_PART != 64 You need to generalize the code above to handle this. #endif exp -= 1022; /* Remove IEEE bias. */ } #else { /* Unknown (or known to be non-IEEE) double format. */ exp = 0; if (d >= 1.0) { ASSERT_ALWAYS (d * 0.5 != d); while (d >= 32768.0) { d *= (1.0 / 65536.0); exp += 16; } while (d >= 1.0) { d *= 0.5; exp += 1; } } else if (d < 0.5) { while (d < (1.0 / 65536.0)) { d *= 65536.0; exp -= 16; } while (d < 0.5) { d *= 2.0; exp -= 1; } } d *= (4.0 * ((unsigned long int) 1 << (BITS_PER_PART - 2))); #if BITS_PER_PART == 64 manl = d; #endif #if BITS_PER_PART == 32 manh = d; manl = (d - manh) * (4.0 * ((unsigned long int) 1 << (BITS_PER_PART - 2))); #endif } #endif /* IEEE */ sc = (unsigned) (exp + 64 * GMP_NUMB_BITS) % GMP_NUMB_BITS; /* We add something here to get rounding right. */ exp = (exp + 64 * GMP_NUMB_BITS) / GMP_NUMB_BITS - 64 * GMP_NUMB_BITS / GMP_NUMB_BITS + 1; #if BITS_PER_PART == 64 && LIMBS_PER_DOUBLE == 2 #if GMP_NAIL_BITS == 0 if (sc != 0) { rp[1] = manl >> (GMP_LIMB_BITS - sc); rp[0] = manl << sc; } else { rp[1] = manl; rp[0] = 0; exp--; } #else if (sc > GMP_NAIL_BITS) { rp[1] = manl >> (GMP_LIMB_BITS - sc); rp[0] = (manl << (sc - GMP_NAIL_BITS)) & GMP_NUMB_MASK; } else { if (sc == 0) { rp[1] = manl >> GMP_NAIL_BITS; rp[0] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS) & GMP_NUMB_MASK; exp--; } else { rp[1] = manl >> (GMP_LIMB_BITS - sc); rp[0] = (manl >> (GMP_NAIL_BITS - sc)) & GMP_NUMB_MASK; } } #endif #endif #if BITS_PER_PART == 64 && LIMBS_PER_DOUBLE == 3 if (sc > GMP_NAIL_BITS) { rp[2] = manl >> (GMP_LIMB_BITS - sc); rp[1] = (manl << sc - GMP_NAIL_BITS) & GMP_NUMB_MASK; if (sc >= 2 * GMP_NAIL_BITS) rp[0] = 0; else rp[0] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS + sc) & GMP_NUMB_MASK; } else { if (sc == 0) { rp[2] = manl >> GMP_NAIL_BITS; rp[1] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS) & GMP_NUMB_MASK; rp[0] = 0; exp--; } else { rp[2] = manl >> (GMP_LIMB_BITS - sc); rp[1] = (manl >> GMP_NAIL_BITS - sc) & GMP_NUMB_MASK; rp[0] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS + sc) & GMP_NUMB_MASK; } } #endif #if BITS_PER_PART == 32 && LIMBS_PER_DOUBLE == 3 #if GMP_NAIL_BITS == 0 if (sc != 0) { rp[2] = manh >> (GMP_LIMB_BITS - sc); rp[1] = (manh << sc) | (manl >> (GMP_LIMB_BITS - sc)); rp[0] = manl << sc; } else { rp[2] = manh; rp[1] = manl; rp[0] = 0; exp--; } #else if (sc > GMP_NAIL_BITS) { rp[2] = (manh >> (GMP_LIMB_BITS - sc)); rp[1] = ((manh << (sc - GMP_NAIL_BITS)) | (manl >> (GMP_LIMB_BITS - sc + GMP_NAIL_BITS))) & GMP_NUMB_MASK; if (sc >= 2 * GMP_NAIL_BITS) rp[0] = (manl << sc - 2 * GMP_NAIL_BITS) & GMP_NUMB_MASK; else rp[0] = manl >> (2 * GMP_NAIL_BITS - sc) & GMP_NUMB_MASK; } else { if (sc == 0) { rp[2] = manh >> GMP_NAIL_BITS; rp[1] = ((manh << GMP_NUMB_BITS - GMP_NAIL_BITS) | (manl >> 2 * GMP_NAIL_BITS)) & GMP_NUMB_MASK; rp[0] = (manl << GMP_NUMB_BITS - 2 * GMP_NAIL_BITS) & GMP_NUMB_MASK; exp--; } else { rp[2] = (manh >> (GMP_LIMB_BITS - sc)); rp[1] = (manh >> (GMP_NAIL_BITS - sc)) & GMP_NUMB_MASK; rp[0] = ((manh << (GMP_NUMB_BITS - GMP_NAIL_BITS + sc)) | (manl >> (GMP_LIMB_BITS - (GMP_NUMB_BITS - GMP_NAIL_BITS + sc)))) & GMP_NUMB_MASK; } } #endif #endif #if BITS_PER_PART == 32 && LIMBS_PER_DOUBLE > 3 if (sc == 0) { int i; for (i = LIMBS_PER_DOUBLE - 1; i >= 0; i--) { rp[i] = manh >> (BITS_PER_ULONG - GMP_NUMB_BITS); manh = ((manh << GMP_NUMB_BITS) | (manl >> (BITS_PER_ULONG - GMP_NUMB_BITS))); manl = manl << GMP_NUMB_BITS; } exp--; } else { int i; rp[LIMBS_PER_DOUBLE - 1] = (manh >> (GMP_LIMB_BITS - sc)); manh = (manh << sc) | (manl >> (GMP_LIMB_BITS - sc)); manl = (manl << sc); for (i = LIMBS_PER_DOUBLE - 2; i >= 0; i--) { rp[i] = manh >> (BITS_PER_ULONG - GMP_NUMB_BITS); manh = ((manh << GMP_NUMB_BITS) | (manl >> (BITS_PER_ULONG - GMP_NUMB_BITS))); manl = manl << GMP_NUMB_BITS; } } #endif return exp; } gmp-6.1.0/ylwrap000755 001756 001756 00000015312 12572636756 014734 0ustar00bodratobodrato000000 000000 #! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2013-01-12.17; # UTC # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . get_dirname () { case $1 in */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';; # Otherwise, we want the empty string (not "."). esac } # guard FILE # ---------- # The CPP macro used to guard inclusion of FILE. guard () { printf '%s\n' "$1" \ | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \ -e 's/__*/_/g' } # quote_for_sed [STRING] # ---------------------- # Return STRING (or stdin) quoted to be used as a sed pattern. quote_for_sed () { case $# in 0) cat;; 1) printf '%s\n' "$1";; esac \ | sed -e 's|[][\\.*]|\\&|g' } case "$1" in '') echo "$0: No files given. Try '$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input=$1 shift # We'll later need for a correct munging of "#line" directives. input_sub_rx=`get_dirname "$input" | quote_for_sed` case $input in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input=`pwd`/$input ;; esac input_rx=`get_dirname "$input" | quote_for_sed` # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot=false if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot=true fi # The parser itself, the first file, is the destination of the .y.c # rule in the Makefile. parser=$1 # A sed program to s/FROM/TO/g for all the FROM/TO so that, for # instance, we rename #include "y.tab.h" into #include "parse.h" # during the conversion from y.tab.c to parse.c. sed_fix_filenames= # Also rename header guards, as Bison 2.7 for instance uses its header # guard in its implementation file. sed_fix_header_guards= while test $# -ne 0; do if test x"$1" = x"--"; then shift break fi from=$1 # Handle y_tab.c and y_tab.h output by DOS if $y_tab_nodot; then case $from in "y.tab.c") from=y_tab.c;; "y.tab.h") from=y_tab.h;; esac fi shift to=$1 shift sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;" sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;" done # The program to run. prog=$1 shift # Make any relative path in $prog absolute. case $prog in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog=`pwd`/$prog ;; esac dirname=ylwrap$$ do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then for from in * do to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"` if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend '../'. case $to in [\\/]* | ?:[\\/]*) target=$to;; *) target=../$to;; esac # Do not overwrite unchanged header files to avoid useless # recompilations. Always update the parser itself: it is the # destination of the .y.c rule in the Makefile. Divert the # output of all other files to a temporary file so we can # compare them to existing versions. if test $from != $parser; then realtarget=$target target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'` fi # Munge "#line" or "#" directives. Don't let the resulting # debug information point at an absolute srcdir. Use the real # output file name, not yy.lex.c for instance. Adjust the # include guards too. sed -e "/^#/!b" \ -e "s|$input_rx|$input_sub_rx|" \ -e "$sed_fix_filenames" \ -e "$sed_fix_header_guards" \ "$from" >"$target" || ret=$? # Check whether files must be updated. if test "$from" != "$parser"; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$to is unchanged" rm -f "$target" else echo "updating $to" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the parser. This is a # blatant hack to let us support using "yacc -d". If -d is not # specified, don't fail when the header file is "missing". if test "$from" = "$parser"; then ret=1 fi fi done fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: gmp-6.1.0/mpf/000755 001756 001756 00000000000 12615426652 014236 5ustar00bodratobodrato000000 000000 gmp-6.1.0/printf/000755 001756 001756 00000000000 12615426652 014756 5ustar00bodratobodrato000000 000000 gmp-6.1.0/nextprime.c000664 001756 001756 00000010262 12615426624 015635 0ustar00bodratobodrato000000 000000 /* gmp_nextprime -- generate small primes reasonably efficiently for internal GMP needs. Contributed to the GNU project by Torbjorn Granlund. Miscellaneous improvements by Martin Boij. THE FUNCTIONS IN THIS FILE ARE INTERNAL WITH MUTABLE INTERFACES. IT IS ONLY SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. Copyright 2009 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ /* Optimisation ideas: 1. Unroll the sieving loops. Should reach 1 write/cycle. That would be a 2x improvement. 2. Separate sieving with primes p < SIEVESIZE and p >= SIEVESIZE. The latter will need at most one write, and thus not need any inner loop. 3. For primes p >= SIEVESIZE, i.e., typically the majority of primes, we perform more than one division per sieving write. That might dominate the entire run time for the nextprime function. A incrementally initialised remainder table of Pi(65536) = 6542 16-bit entries could replace that division. */ #include "gmp.h" #include "gmp-impl.h" #include /* for memset */ unsigned long int gmp_nextprime (gmp_primesieve_t *ps) { unsigned long p, d, pi; unsigned char *sp; static unsigned char addtab[] = { 2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4, 2,4,6,2,6,4,2,4,2,10,2,10 }; unsigned char *addp = addtab; unsigned long ai; /* Look for already sieved primes. A sentinel at the end of the sieving area allows us to use a very simple loop here. */ d = ps->d; sp = ps->s + d; while (*sp != 0) sp++; if (sp != ps->s + SIEVESIZE) { d = sp - ps->s; ps->d = d + 1; return ps->s0 + 2 * d; } /* Handle the number 2 separately. */ if (ps->s0 < 3) { ps->s0 = 3 - 2 * SIEVESIZE; /* Tricky */ return 2; } /* Exhausted computed primes. Resieve, then call ourselves recursively. */ #if 0 for (sp = ps->s; sp < ps->s + SIEVESIZE; sp++) *sp = 0; #else memset (ps->s, 0, SIEVESIZE); #endif ps->s0 += 2 * SIEVESIZE; /* Update sqrt_s0 as needed. */ while ((ps->sqrt_s0 + 1) * (ps->sqrt_s0 + 1) <= ps->s0 + 2 * SIEVESIZE - 1) ps->sqrt_s0++; pi = ((ps->s0 + 3) / 2) % 3; if (pi > 0) pi = 3 - pi; if (ps->s0 + 2 * pi <= 3) pi += 3; sp = ps->s + pi; while (sp < ps->s + SIEVESIZE) { *sp = 1, sp += 3; } pi = ((ps->s0 + 5) / 2) % 5; if (pi > 0) pi = 5 - pi; if (ps->s0 + 2 * pi <= 5) pi += 5; sp = ps->s + pi; while (sp < ps->s + SIEVESIZE) { *sp = 1, sp += 5; } pi = ((ps->s0 + 7) / 2) % 7; if (pi > 0) pi = 7 - pi; if (ps->s0 + 2 * pi <= 7) pi += 7; sp = ps->s + pi; while (sp < ps->s + SIEVESIZE) { *sp = 1, sp += 7; } p = 11; ai = 0; while (p <= ps->sqrt_s0) { pi = ((ps->s0 + p) / 2) % p; if (pi > 0) pi = p - pi; if (ps->s0 + 2 * pi <= p) pi += p; sp = ps->s + pi; while (sp < ps->s + SIEVESIZE) { *sp = 1, sp += p; } p += addp[ai]; ai = (ai + 1) % 48; } ps->d = 0; return gmp_nextprime (ps); } void gmp_init_primesieve (gmp_primesieve_t *ps) { ps->s0 = 0; ps->sqrt_s0 = 0; ps->d = SIEVESIZE; ps->s[SIEVESIZE] = 0; /* sentinel */ } gmp-6.1.0/acinclude.m4000664 001756 001756 00000364404 12615426624 015661 0ustar00bodratobodrato000000 000000 dnl GMP specific autoconf macros dnl Copyright 2000-2006, 2009, 2011, 2013-2015 Free Software Foundation, Inc. dnl dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. dnl Some tests use, or must delete, the default compiler output. The dnl possible filenames are based on what autoconf looks for, namely dnl dnl a.out - normal unix style dnl b.out - i960 systems, including gcc there dnl a.exe - djgpp dnl a_out.exe - OpenVMS DEC C called via GNV wrapper (gnv.sourceforge.net) dnl conftest.exe - various DOS compilers define(IA64_PATTERN, [[ia64*-*-* | itanium-*-* | itanium2-*-*]]) dnl Need to be careful not to match m6811, m6812, m68hc11 and m68hc12, all dnl of which config.sub accepts. (Though none of which are likely to work dnl with GMP.) dnl define(M68K_PATTERN, [[m68k-*-* | m68[0-9][0-9][0-9]-*-*]]) define(POWERPC64_PATTERN, [[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-* | powerpc970-*-* | power[3-9]-*-*]]) define(S390_PATTERN, [[s390-*-* | z900esa-*-* | z990esa-*-* | z9esa-*-* | z10esa-*-* | z196esa-*-*]]) define(S390X_PATTERN, [[s390x-*-* | z900-*-* | z990-*-* | z9-*-* | z10-*-* | z196-*-*]]) define(X86_PATTERN, [[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]]) define(X86_64_PATTERN, [[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | jaguar*-*-* | bulldozer*-*-* | piledriver*-*-* | steamroller*-*-* | excavator*-*-* | pentium4-*-* | atom-*-* | silvermont-*-* | goldmont-*-* | core2-*-* | corei*-*-* | x86_64-*-* | nano-*-* | nehalem*-*-* | westmere*-*-* | sandybridge*-*-* | ivybridge*-*-* | haswell*-*-* | broadwell*-*-* | skylake*-*-* | cabylake*-*-*]]) dnl GMP_FAT_SUFFIX(DSTVAR, DIRECTORY) dnl --------------------------------- dnl Emit code to set shell variable DSTVAR to the suffix for a fat binary dnl routine from DIRECTORY. DIRECTORY can be a shell expression like $foo dnl etc. dnl dnl The suffix is directory separators / or \ changed to underscores, and dnl if there's more than one directory part, then the first is dropped. dnl dnl For instance, dnl dnl x86 -> x86 dnl x86/k6 -> k6 dnl x86/k6/mmx -> k6_mmx define(GMP_FAT_SUFFIX, [[$1=`echo $2 | sed -e '/\//s:^[^/]*/::' -e 's:[\\/]:_:g'`]]) dnl GMP_REMOVE_FROM_LIST(listvar,item) dnl ---------------------------------- dnl Emit code to remove any occurrence of ITEM from $LISTVAR. ITEM can be a dnl shell expression like $foo if desired. define(GMP_REMOVE_FROM_LIST, [remove_from_list_tmp= for remove_from_list_i in $[][$1]; do if test $remove_from_list_i = [$2]; then :; else remove_from_list_tmp="$remove_from_list_tmp $remove_from_list_i" fi done [$1]=$remove_from_list_tmp ]) dnl GMP_STRIP_PATH(subdir) dnl ---------------------- dnl Strip entries */subdir from $path and $fat_path. define(GMP_STRIP_PATH, [GMP_STRIP_PATH_VAR(path, [$1]) GMP_STRIP_PATH_VAR(fat_path, [$1]) ]) define(GMP_STRIP_PATH_VAR, [tmp_path= for i in $[][$1]; do case $i in */[$2]) ;; *) tmp_path="$tmp_path $i" ;; esac done [$1]="$tmp_path" ]) dnl GMP_INCLUDE_GMP_H dnl ----------------- dnl Expand to the right way to #include gmp-h.in. This must be used dnl instead of gmp.h, since that file isn't generated until the end of the dnl configure. dnl dnl Dummy value for GMP_LIMB_BITS is enough dnl for all current configure-time uses of gmp.h. define(GMP_INCLUDE_GMP_H, [[#define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ #define GMP_NAIL_BITS $GMP_NAIL_BITS #define GMP_LIMB_BITS 123 $DEFN_LONG_LONG_LIMB #include "$srcdir/gmp-h.in"] ]) dnl GMP_HEADER_GETVAL(NAME,FILE) dnl ---------------------------- dnl Expand at autoconf time to the value of a "#define NAME" from the given dnl FILE. The regexps here aren't very rugged, but are enough for gmp. dnl /dev/null as a parameter prevents a hang if $2 is accidentally omitted. define(GMP_HEADER_GETVAL, [patsubst(patsubst( esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]), [^.*$1[ ]+],[]), [[ ]*$],[])]) dnl GMP_VERSION dnl ----------- dnl The gmp version number, extracted from the #defines in gmp-h.in at dnl autoconf time. Two digits like 3.0 if patchlevel <= 0, or three digits dnl like 3.0.1 if patchlevel > 0. define(GMP_VERSION, [GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp-h.in)[]dnl .GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp-h.in)[]dnl .GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in)]) dnl GMP_SUBST_CHECK_FUNCS(func,...) dnl ------------------------------ dnl Setup an AC_SUBST of HAVE_FUNC_01 for each argument. AC_DEFUN([GMP_SUBST_CHECK_FUNCS], [m4_if([$1],,, [_GMP_SUBST_CHECK_FUNCS(ac_cv_func_[$1],HAVE_[]m4_translit([$1],[a-z],[A-Z])_01) GMP_SUBST_CHECK_FUNCS(m4_shift($@))])]) dnl Called: _GMP_SUBST_CHECK_FUNCS(cachevar,substvar) AC_DEFUN([_GMP_SUBST_CHECK_FUNCS], [case $[$1] in yes) AC_SUBST([$2],1) ;; no) [$2]=0 ;; esac ]) dnl GMP_SUBST_CHECK_HEADERS(foo.h,...) dnl ---------------------------------- dnl Setup an AC_SUBST of HAVE_FOO_H_01 for each argument. AC_DEFUN([GMP_SUBST_CHECK_HEADERS], [m4_if([$1],,, [_GMP_SUBST_CHECK_HEADERS(ac_cv_header_[]m4_translit([$1],[./],[__]), HAVE_[]m4_translit([$1],[a-z./],[A-Z__])_01) GMP_SUBST_CHECK_HEADERS(m4_shift($@))])]) dnl Called: _GMP_SUBST_CHECK_HEADERS(cachevar,substvar) AC_DEFUN([_GMP_SUBST_CHECK_HEADERS], [case $[$1] in yes) AC_SUBST([$2],1) ;; no) [$2]=0 ;; esac ]) dnl GMP_COMPARE_GE(A1,B1, A2,B2, ...) dnl --------------------------------- dnl Compare two version numbers A1.A2.etc and B1.B2.etc. Set dnl $gmp_compare_ge to yes or no according to the result. The A parts dnl should be variables, the B parts fixed numbers. As many parts as dnl desired can be included. An empty string in an A part is taken to be dnl zero, the B parts should be non-empty and non-zero. dnl dnl For example, dnl dnl GMP_COMPARE($major,10, $minor,3, $subminor,1) dnl dnl would test whether $major.$minor.$subminor is greater than or equal to dnl 10.3.1. AC_DEFUN([GMP_COMPARE_GE], [gmp_compare_ge=no GMP_COMPARE_GE_INTERNAL($@) ]) AC_DEFUN([GMP_COMPARE_GE_INTERNAL], [ifelse(len([$3]),0, [if test -n "$1" && test "$1" -ge $2; then gmp_compare_ge=yes fi], [if test -n "$1"; then if test "$1" -gt $2; then gmp_compare_ge=yes else if test "$1" -eq $2; then GMP_COMPARE_GE_INTERNAL(m4_shift(m4_shift($@))) fi fi fi]) ]) dnl GMP_PROG_AR dnl ----------- dnl GMP additions to $AR. dnl dnl A cross-"ar" may be necessary when cross-compiling since the build dnl system "ar" might try to interpret the object files to build a symbol dnl table index, hence the use of AC_CHECK_TOOL. dnl dnl A user-selected $AR is always left unchanged. AC_CHECK_TOOL is still dnl run to get the "checking" message printed though. dnl dnl If extra flags are added to AR, then ac_cv_prog_AR and dnl ac_cv_prog_ac_ct_AR are set too, since libtool (cvs 2003-03-31 at dnl least) will do an AC_CHECK_TOOL and that will AR from one of those two dnl cached variables. (ac_cv_prog_AR is used if there's an ac_tool_prefix, dnl or ac_cv_prog_ac_ct_AR is used otherwise.) FIXME: This is highly dnl dependent on autoconf internals, perhaps it'd work to put our extra dnl flags into AR_FLAGS instead. dnl dnl $AR_FLAGS is set to "cq" rather than leaving it to libtool "cru". The dnl latter fails when libtool goes into piecewise mode and is unlucky dnl enough to have two same-named objects in separate pieces, as happens dnl for instance to random.o (and others) on vax-dec-ultrix4.5. Naturally dnl a user-selected $AR_FLAGS is left unchanged. dnl dnl For reference, $ARFLAGS is used by automake (1.8) for its ".a" archive dnl file rules. This doesn't get used by the piecewise linking, so we dnl leave it at the default "cru". dnl dnl FIXME: Libtool 1.5.2 has its own arrangements for "cq", but that version dnl is broken in other ways. When we can upgrade, remove the forcible dnl AR_FLAGS=cq. AC_DEFUN([GMP_PROG_AR], [dnl Want to establish $AR before libtool initialization. AC_BEFORE([$0],[AC_PROG_LIBTOOL]) gmp_user_AR=$AR AC_CHECK_TOOL(AR, ar, ar) if test -z "$gmp_user_AR"; then eval arflags=\"\$ar${abi1}_flags\" test -n "$arflags" || eval arflags=\"\$ar${abi2}_flags\" if test -n "$arflags"; then AC_MSG_CHECKING([for extra ar flags]) AR="$AR $arflags" ac_cv_prog_AR="$AR $arflags" ac_cv_prog_ac_ct_AR="$AR $arflags" AC_MSG_RESULT([$arflags]) fi fi if test -z "$AR_FLAGS"; then AR_FLAGS=cq fi ]) dnl GMP_PROG_M4 dnl ----------- dnl Find a working m4, either in $PATH or likely locations, and setup $M4 dnl and an AC_SUBST accordingly. If $M4 is already set then it's a user dnl choice and is accepted with no checks. GMP_PROG_M4 is like dnl AC_PATH_PROG or AC_CHECK_PROG, but tests each m4 found to see if it's dnl good enough. dnl dnl See mpn/asm-defs.m4 for details on the known bad m4s. AC_DEFUN([GMP_PROG_M4], [AC_ARG_VAR(M4,[m4 macro processor]) AC_CACHE_CHECK([for suitable m4], gmp_cv_prog_m4, [if test -n "$M4"; then gmp_cv_prog_m4="$M4" else cat >conftest.m4 <<\EOF dnl Must protect this against being expanded during autoconf m4! dnl Dont put "dnl"s in this as autoconf will flag an error for unexpanded dnl macros. [define(dollarhash,``$][#'')ifelse(dollarhash(x),1,`define(t1,Y)', ``bad: $][# not supported (SunOS /usr/bin/m4) '')ifelse(eval(89),89,`define(t2,Y)', `bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4) ')ifelse(eval(9,9),10,`define(t3,Y)', `bad: eval() doesnt support radix in eval (FreeBSD 8.x,9.0,9.1,9.2 m4) ')ifelse(t1`'t2`'t3,YYY,`good ')] EOF dnl ' <- balance the quotes for emacs sh-mode echo "trying m4" >&AC_FD_CC gmp_tmp_val=`(m4 conftest.m4) 2>&AC_FD_CC` echo "$gmp_tmp_val" >&AC_FD_CC if test "$gmp_tmp_val" = good; then gmp_cv_prog_m4="m4" else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="$PATH:/usr/5bin" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. echo "trying $ac_dir/m4" >&AC_FD_CC gmp_tmp_val=`($ac_dir/m4 conftest.m4) 2>&AC_FD_CC` echo "$gmp_tmp_val" >&AC_FD_CC if test "$gmp_tmp_val" = good; then gmp_cv_prog_m4="$ac_dir/m4" break fi done IFS="$ac_save_ifs" if test -z "$gmp_cv_prog_m4"; then AC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).]) fi fi rm -f conftest.m4 fi]) M4="$gmp_cv_prog_m4" AC_SUBST(M4) ]) dnl GMP_M4_M4WRAP_SPURIOUS dnl ---------------------- dnl Check for spurious output from m4wrap(), as described in mpn/asm-defs.m4. dnl dnl The following systems have been seen with the problem. dnl dnl - Unicos alpha, but its assembler doesn't seem to mind. dnl - MacOS X Darwin, its assembler fails. dnl - NetBSD 1.4.1 m68k, and gas 1.92.3 there gives a warning and ignores dnl the bad last line since it doesn't have a newline. dnl - NetBSD 1.4.2 alpha, but its assembler doesn't seem to mind. dnl - HP-UX ia64. dnl dnl Enhancement: Maybe this could be in GMP_PROG_M4, and attempt to prefer dnl an m4 with a working m4wrap, if it can be found. AC_DEFUN([GMP_M4_M4WRAP_SPURIOUS], [AC_REQUIRE([GMP_PROG_M4]) AC_CACHE_CHECK([if m4wrap produces spurious output], gmp_cv_m4_m4wrap_spurious, [# hide the d-n-l from autoconf's error checking tmp_d_n_l=d""nl cat >conftest.m4 <&AC_FD_CC cat conftest.m4 >&AC_FD_CC tmp_chars=`$M4 conftest.m4 | wc -c` echo produces $tmp_chars chars output >&AC_FD_CC rm -f conftest.m4 if test $tmp_chars = 0; then gmp_cv_m4_m4wrap_spurious=no else gmp_cv_m4_m4wrap_spurious=yes fi ]) GMP_DEFINE_RAW(["define(,<$gmp_cv_m4_m4wrap_spurious>)"]) ]) dnl GMP_PROG_NM dnl ----------- dnl GMP additions to libtool AC_PROG_NM. dnl dnl Note that if AC_PROG_NM can't find a working nm it still leaves dnl $NM set to "nm", so $NM can't be assumed to actually work. dnl dnl A user-selected $NM is always left unchanged. AC_PROG_NM is still run dnl to get the "checking" message printed though. dnl dnl Perhaps it'd be worthwhile checking that nm works, by running it on an dnl actual object file. For instance on sparcv9 solaris old versions of dnl GNU nm don't recognise 64-bit objects. Checking would give a better dnl error message than just a failure in later tests like GMP_ASM_W32 etc. dnl dnl On the other hand it's not really normal autoconf practice to take too dnl much trouble over detecting a broken set of tools. And libtool doesn't dnl do anything at all for say ranlib or strip. So for now we're inclined dnl to just demand that the user provides a coherent environment. AC_DEFUN([GMP_PROG_NM], [dnl Make sure we're the first to call AC_PROG_NM, so our extra flags are dnl used by everyone. AC_BEFORE([$0],[AC_PROG_NM]) gmp_user_NM=$NM AC_PROG_NM # FIXME: When cross compiling (ie. $ac_tool_prefix not empty), libtool # defaults to plain "nm" if a "${ac_tool_prefix}nm" is not found. In this # case run it again to try the native "nm", firstly so that likely locations # are searched, secondly so that -B or -p are added if necessary for BSD # format. This is necessary for instance on OSF with "./configure # --build=alphaev5-dec-osf --host=alphaev6-dec-osf". # if test -z "$gmp_user_NM" && test -n "$ac_tool_prefix" && test "$NM" = nm; then $as_unset lt_cv_path_NM gmp_save_ac_tool_prefix=$ac_tool_prefix ac_tool_prefix= NM= AC_PROG_NM ac_tool_prefix=$gmp_save_ac_tool_prefix fi if test -z "$gmp_user_NM"; then eval nmflags=\"\$nm${abi1}_flags\" test -n "$nmflags" || eval nmflags=\"\$nm${abi2}_flags\" if test -n "$nmflags"; then AC_MSG_CHECKING([for extra nm flags]) NM="$NM $nmflags" AC_MSG_RESULT([$nmflags]) fi fi ]) dnl GMP_PROG_CC_WORKS(cc+cflags,[ACTION-IF-WORKS][,ACTION-IF-NOT-WORKS]) dnl -------------------------------------------------------------------- dnl Check if cc+cflags can compile and link. dnl dnl This test is designed to be run repeatedly with different cc+cflags dnl selections, so the result is not cached. dnl dnl For a native build, meaning $cross_compiling == no, we require that the dnl generated program will run. This is the same as AC_PROG_CC does in dnl _AC_COMPILER_EXEEXT_WORKS, and checking here will ensure we don't pass dnl a CC/CFLAGS combination that it rejects. dnl dnl sparc-*-solaris2.7 can compile ABI=64 but won't run it if the kernel dnl was booted in 32-bit mode. The effect of requiring the compiler output dnl will run is that a plain native "./configure" falls back on ABI=32, but dnl ABI=64 is still available as a cross-compile. dnl dnl The various specific problems we try to detect are done in separate dnl compiles. Although this is probably a bit slower than one test dnl program, it makes it easy to indicate the problem in AC_MSG_RESULT, dnl hence giving the user a clue about why we rejected the compiler. AC_DEFUN([GMP_PROG_CC_WORKS], [AC_MSG_CHECKING([compiler $1]) gmp_prog_cc_works=yes # first see a simple "main()" works, then go on to other checks GMP_PROG_CC_WORKS_PART([$1], []) GMP_PROG_CC_WORKS_PART([$1], [function pointer return], [/* The following provokes an internal error from gcc 2.95.2 -mpowerpc64 (without -maix64), hence detecting an unusable compiler */ void *g() { return (void *) 0; } void *f() { return g(); } ]) GMP_PROG_CC_WORKS_PART([$1], [cmov instruction], [/* The following provokes an invalid instruction syntax from i386 gcc -march=pentiumpro on Solaris 2.8. The native sun assembler requires a non-standard syntax for cmov which gcc (as of 2.95.2 at least) doesn't know. */ int n; int cmov () { return (n >= 0 ? n : 0); } ]) GMP_PROG_CC_WORKS_PART([$1], [double -> ulong conversion], [/* The following provokes a linker invocation problem with gcc 3.0.3 on AIX 4.3 under "-maix64 -mpowerpc64 -mcpu=630". The -mcpu=630 option causes gcc to incorrectly select the 32-bit libgcc.a, not the 64-bit one, and consequently it misses out on the __fixunsdfdi helper (double -> uint64 conversion). */ double d; unsigned long gcc303 () { return (unsigned long) d; } ]) GMP_PROG_CC_WORKS_PART([$1], [double negation], [/* The following provokes an error from hppa gcc 2.95 under -mpa-risc-2-0 if the assembler doesn't know hppa 2.0 instructions. fneg is a 2.0 instruction, and a negation like this comes out using it. */ double fneg_data; unsigned long fneg () { return -fneg_data; } ]) GMP_PROG_CC_WORKS_PART([$1], [double -> float conversion], [/* The following makes gcc 3.3 -march=pentium4 generate an SSE2 xmm insn (cvtsd2ss) which will provoke an error if the assembler doesn't recognise those instructions. Not sure how much of the gmp code will come out wanting sse2, but it's easiest to reject an option we know is bad. */ double ftod_data; float ftod () { return (float) ftod_data; } ]) GMP_PROG_CC_WORKS_PART([$1], [gnupro alpha ev6 char spilling], [/* The following provokes an internal compiler error from gcc version "2.9-gnupro-99r1" under "-O2 -mcpu=ev6", apparently relating to char values being spilled into floating point registers. The problem doesn't show up all the time, but has occurred enough in GMP for us to reject this compiler+flags. */ #include /* for memcpy */ struct try_t { char dst[2]; char size; long d0, d1, d2, d3, d4, d5, d6; char overlap; }; struct try_t param[6]; int param_init () { struct try_t *p; memcpy (p, ¶m[ 2 ], sizeof (*p)); memcpy (p, ¶m[ 2 ], sizeof (*p)); p->size = 2; memcpy (p, ¶m[ 1 ], sizeof (*p)); p->dst[0] = 1; p->overlap = 2; memcpy (p, ¶m[ 3 ], sizeof (*p)); p->dst[0] = 1; p->overlap = 8; memcpy (p, ¶m[ 4 ], sizeof (*p)); memcpy (p, ¶m[ 4 ], sizeof (*p)); p->overlap = 8; memcpy (p, ¶m[ 5 ], sizeof (*p)); memcpy (p, ¶m[ 5 ], sizeof (*p)); memcpy (p, ¶m[ 5 ], sizeof (*p)); return 0; } ]) # __builtin_alloca is not available everywhere, check it exists before # seeing that it works GMP_PROG_CC_WORKS_PART_TEST([$1],[__builtin_alloca availability], [int k; int foo () { __builtin_alloca (k); }], [GMP_PROG_CC_WORKS_PART([$1], [alloca array], [/* The following provokes an internal compiler error from Itanium HP-UX cc under +O2 or higher. We use this sort of code in mpn/generic/mul_fft.c. */ int k; int foo () { int i, **a; a = __builtin_alloca (k); for (i = 0; i <= k; i++) a[i] = __builtin_alloca (1 << i); } ])]) GMP_PROG_CC_WORKS_PART([$1], [abs int -> double conversion], [/* The following provokes an internal error from the assembler on power2-ibm-aix4.3.1.0. gcc -mrios2 compiles to nabs+fcirz, and this results in "Internal error related to the source program domain". For reference it seems to be the combination of nabs+fcirz which is bad, not either alone. This sort of thing occurs in mpz/get_str.c with the way double chars_per_bit_exactly is applied in MPN_SIZEINBASE. Perhaps if that code changes to a scaled-integer style then we won't need this test. */ double fp[1]; int x; int f () { int a; a = (x >= 0 ? x : -x); return a * fp[0]; } ]) GMP_PROG_CC_WORKS_PART([$1], [long long reliability test 1], [/* The following provokes a segfault in the compiler on powerpc-apple-darwin. Extracted from tests/mpn/t-iord_u.c. Causes Apple's gcc 3.3 build 1640 and 1666 to segfault with e.g., -O2 -mpowerpc64. */ #if defined (__GNUC__) && ! defined (__cplusplus) typedef unsigned long long t1;typedef t1*t2; void g(){} void h(){} static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0) {t1 c,x,r;int i;if(v0){c=1;for(i=1;i> tnc; high_limb = low_limb << cnt; for (i = n - 1; i != 0; i--) { low_limb = *up++; *rp++ = ~(high_limb | (low_limb >> tnc)); high_limb = low_limb << cnt; } return retval; } int main () { unsigned long cy, rp[2], up[2]; up[0] = ~ 0L; up[1] = 0; cy = lshift_com (rp, up, 2L, 1); if (cy != 1L) return 1; return 0; } #else int main () { return 0; } #endif ]) GMP_PROG_CC_WORKS_PART_MAIN([$1], [mpn_lshift_com optimization 2], [/* The following is mis-compiled by Intel ia-64 icc version 1.8 under "icc -O3", After several calls, the function writes partial garbage to the result vector. Perhaps relates to the chk.a.nc insn. This code needs to be run to show the problem, but that's fine, the offending cc is a native-only compiler so we don't have to worry about cross compiling. */ #if ! defined (__cplusplus) #include void lshift_com (rp, up, n, cnt) unsigned long *rp; unsigned long *up; long n; unsigned cnt; { unsigned long high_limb, low_limb; unsigned tnc; long i; up += n; rp += n; tnc = 8 * sizeof (unsigned long) - cnt; low_limb = *--up; high_limb = low_limb << cnt; for (i = n - 1; i != 0; i--) { low_limb = *--up; *--rp = ~(high_limb | (low_limb >> tnc)); high_limb = low_limb << cnt; } *--rp = ~high_limb; } int main () { unsigned long *r, *r2; unsigned long a[88 + 1]; long i; for (i = 0; i < 88 + 1; i++) a[i] = ~0L; r = malloc (10000 * sizeof (unsigned long)); r2 = r; for (i = 0; i < 528; i += 22) { lshift_com (r2, a, i / (8 * sizeof (unsigned long)) + 1, i % (8 * sizeof (unsigned long))); r2 += 88 + 1; } if (r[2048] != 0 || r[2049] != 0 || r[2050] != 0 || r[2051] != 0 || r[2052] != 0 || r[2053] != 0 || r[2054] != 0) abort (); return 0; } #else int main () { return 0; } #endif ]) # A certain _GLOBAL_OFFSET_TABLE_ problem in past versions of gas, tickled # by recent versions of gcc. # if test "$gmp_prog_cc_works" = yes; then case $host in X86_PATTERN) # this problem only arises in PIC code, so don't need to test when # --disable-shared. We don't necessarily have $enable_shared set to # yes at this point, it will still be unset for the default (which is # yes); hence the use of "!= no". if test "$enable_shared" != no; then GMP_PROG_CC_X86_GOT_EAX_EMITTED([$1], [GMP_ASM_X86_GOT_EAX_OK([$1],, [gmp_prog_cc_works="no, bad gas GOT with eax"])]) fi ;; esac fi AC_MSG_RESULT($gmp_prog_cc_works) case $gmp_prog_cc_works in yes) [$2] ;; *) [$3] ;; esac ]) dnl Called: GMP_PROG_CC_WORKS_PART(CC+CFLAGS,FAIL-MESSAGE [,CODE]) dnl A dummy main() is appended to the CODE given. dnl AC_DEFUN([GMP_PROG_CC_WORKS_PART], [GMP_PROG_CC_WORKS_PART_MAIN([$1],[$2], [$3] [int main () { return 0; }]) ]) dnl Called: GMP_PROG_CC_WORKS_PART_MAIN(CC+CFLAGS,FAIL-MESSAGE,CODE) dnl CODE must include a main(). dnl AC_DEFUN([GMP_PROG_CC_WORKS_PART_MAIN], [GMP_PROG_CC_WORKS_PART_TEST([$1],[$2],[$3], [], gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2]", gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2][[, program does not run]]") ]) dnl Called: GMP_PROG_CC_WORKS_PART_TEST(CC+CFLAGS,TITLE,[CODE], dnl [ACTION-GOOD],[ACTION-BAD][ACTION-NORUN]) dnl AC_DEFUN([GMP_PROG_CC_WORKS_PART_TEST], [if test "$gmp_prog_cc_works" = yes; then # remove anything that might look like compiler output to our "||" expression rm -f conftest* a.out b.out a.exe a_out.exe cat >conftest.c <&AC_FD_CC gmp_compile="$1 conftest.c >&AC_FD_CC" if AC_TRY_EVAL(gmp_compile); then cc_works_part=yes if test "$cross_compiling" = no; then if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :; else cc_works_part=norun fi fi else cc_works_part=no fi if test "$cc_works_part" != yes; then echo "failed program was:" >&AC_FD_CC cat conftest.c >&AC_FD_CC fi rm -f conftest* a.out b.out a.exe a_out.exe case $cc_works_part in yes) $4 ;; no) $5 ;; norun) $6 ;; esac fi ]) dnl GMP_PROG_CC_WORKS_LONGLONG(cc+cflags,[ACTION-YES][,ACTION-NO]) dnl -------------------------------------------------------------- dnl Check that cc+cflags accepts "long long". dnl dnl This test is designed to be run repeatedly with different cc+cflags dnl selections, so the result is not cached. AC_DEFUN([GMP_PROG_CC_WORKS_LONGLONG], [AC_MSG_CHECKING([compiler $1 has long long]) cat >conftest.c <&AC_FD_CC cat conftest.c >&AC_FD_CC fi rm -f conftest* a.out b.out a.exe a_out.exe AC_MSG_RESULT($gmp_prog_cc_works) if test $gmp_prog_cc_works = yes; then ifelse([$2],,:,[$2]) else ifelse([$3],,:,[$3]) fi ]) dnl GMP_C_TEST_SIZEOF(cc/cflags,test,[ACTION-GOOD][,ACTION-BAD]) dnl ------------------------------------------------------------ dnl The given cc/cflags compiler is run to check the size of a type dnl specified by the "test" argument. "test" can either be a string, or a dnl variable like $foo. The value should be for instance "sizeof-long-4", dnl to test that sizeof(long)==4. dnl dnl This test is designed to be run for different compiler and/or flags dnl combinations, so the result is not cached. dnl dnl The idea for making an array that has a negative size if the desired dnl condition test is false comes from autoconf AC_CHECK_SIZEOF. The cast dnl to "long" in the array dimension also follows autoconf, apparently it's dnl a workaround for a HP compiler bug. AC_DEFUN([GMP_C_TEST_SIZEOF], [echo "configure: testlist $2" >&AC_FD_CC [gmp_sizeof_type=`echo "$2" | sed 's/sizeof-\([a-z]*\).*/\1/'`] [gmp_sizeof_want=`echo "$2" | sed 's/sizeof-[a-z]*-\([0-9]*\).*/\1/'`] AC_MSG_CHECKING([compiler $1 has sizeof($gmp_sizeof_type)==$gmp_sizeof_want]) cat >conftest.c <conftest.c <