summaryrefslogtreecommitdiff
path: root/libjava/classpath/native/jni/java-math
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/native/jni/java-math')
-rw-r--r--libjava/classpath/native/jni/java-math/Makefile.am11
-rw-r--r--libjava/classpath/native/jni/java-math/Makefile.in610
-rw-r--r--libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c1396
3 files changed, 2017 insertions, 0 deletions
diff --git a/libjava/classpath/native/jni/java-math/Makefile.am b/libjava/classpath/native/jni/java-math/Makefile.am
new file mode 100644
index 000000000..9bc756b6d
--- /dev/null
+++ b/libjava/classpath/native/jni/java-math/Makefile.am
@@ -0,0 +1,11 @@
+nativeexeclib_LTLIBRARIES = libjavamath.la
+
+libjavamath_la_SOURCES = gnu_java_math_GMP.c
+
+libjavamath_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+
+libjavamath_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
+
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GMP_LIBS@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ @GMP_CFLAGS@
diff --git a/libjava/classpath/native/jni/java-math/Makefile.in b/libjava/classpath/native/jni/java-math/Makefile.in
new file mode 100644
index 000000000..3b7072586
--- /dev/null
+++ b/libjava/classpath/native/jni/java-math/Makefile.in
@@ -0,0 +1,610 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@
+
+VPATH = @srcdir@
+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@
+target_triplet = @target@
+subdir = native/jni/java-math
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \
+ $(top_srcdir)/../../config/lead-dot.m4 \
+ $(top_srcdir)/../../config/lib-ld.m4 \
+ $(top_srcdir)/../../config/lib-link.m4 \
+ $(top_srcdir)/../../config/lib-prefix.m4 \
+ $(top_srcdir)/../../config/multi.m4 \
+ $(top_srcdir)/../../config/no-executables.m4 \
+ $(top_srcdir)/../../config/override.m4 \
+ $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/../../ltoptions.m4 \
+ $(top_srcdir)/../../ltsugar.m4 \
+ $(top_srcdir)/../../ltversion.m4 \
+ $(top_srcdir)/../../lt~obsolete.m4 \
+ $(top_srcdir)/m4/ac_prog_antlr.m4 \
+ $(top_srcdir)/m4/ac_prog_java.m4 \
+ $(top_srcdir)/m4/ac_prog_java_works.m4 \
+ $(top_srcdir)/m4/ac_prog_javac.m4 \
+ $(top_srcdir)/m4/ac_prog_javac_works.m4 \
+ $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
+ $(top_srcdir)/m4/acinclude.m4 \
+ $(top_srcdir)/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/m4/ax_func_which_gethostbyname_r.m4 \
+ $(top_srcdir)/m4/gcc_attribute.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+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__installdirs = "$(DESTDIR)$(nativeexeclibdir)"
+LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
+libjavamath_la_DEPENDENCIES = \
+ $(top_builddir)/native/jni/classpath/jcl.lo
+am_libjavamath_la_OBJECTS = gnu_java_math_GMP.lo
+libjavamath_la_OBJECTS = $(am_libjavamath_la_OBJECTS)
+libjavamath_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libjavamath_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/../../depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libjavamath_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+ANTLR = @ANTLR@
+ANTLR_JAR = @ANTLR_JAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLASSPATH_CONVENIENCE = @CLASSPATH_CONVENIENCE@
+CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
+CLASSPATH_MODULE = @CLASSPATH_MODULE@
+COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
+CP = @CP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ_JAR = @ECJ_JAR@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+EXTRA_CFLAGS = @EXTRA_CFLAGS@
+FGREP = @FGREP@
+FIND = @FIND@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
+GJDOC = @GJDOC@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GMP_CFLAGS = @GMP_CFLAGS@
+GMP_LIBS = @GMP_LIBS@
+GREP = @GREP@
+GSTREAMER_BASE_CFLAGS = @GSTREAMER_BASE_CFLAGS@
+GSTREAMER_BASE_LIBS = @GSTREAMER_BASE_LIBS@
+GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@
+GSTREAMER_FILE_READER = @GSTREAMER_FILE_READER@
+GSTREAMER_LIBS = @GSTREAMER_LIBS@
+GSTREAMER_MIXER_PROVIDER = @GSTREAMER_MIXER_PROVIDER@
+GSTREAMER_PLUGINS_BASE_CFLAGS = @GSTREAMER_PLUGINS_BASE_CFLAGS@
+GSTREAMER_PLUGINS_BASE_LIBS = @GSTREAMER_PLUGINS_BASE_LIBS@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAR = @JAR@
+JAVA = @JAVA@
+JAVAC = @JAVAC@
+JAVAC_IS_GCJ = @JAVAC_IS_GCJ@
+JAVAC_MEM_OPT = @JAVAC_MEM_OPT@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+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@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
+PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
+QT_CFLAGS = @QT_CFLAGS@
+QT_LIBS = @QT_LIBS@
+RANLIB = @RANLIB@
+REMOVE = @REMOVE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+TOOLSDIR = @TOOLSDIR@
+USER_JAVAH = @USER_JAVAH@
+VERSION = @VERSION@
+WANT_NATIVE_BIG_INTEGER = @WANT_NATIVE_BIG_INTEGER@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+XMKMF = @XMKMF@
+XML_CFLAGS = @XML_CFLAGS@
+XML_LIBS = @XML_LIBS@
+XSLT_CFLAGS = @XSLT_CFLAGS@
+XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZIP = @ZIP@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_ANTLR = @ac_ct_ANTLR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+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@
+default_toolkit = @default_toolkit@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+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@
+multi_basedir = @multi_basedir@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+uudecode = @uudecode@
+vm_classes = @vm_classes@
+nativeexeclib_LTLIBRARIES = libjavamath.la
+libjavamath_la_SOURCES = gnu_java_math_GMP.c
+libjavamath_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+libjavamath_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GMP_LIBS@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ @GMP_CFLAGS@
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu native/jni/java-math/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu native/jni/java-math/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-nativeexeclibLTLIBRARIES: $(nativeexeclib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(nativeexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(nativeexeclibdir)"
+ @list='$(nativeexeclib_LTLIBRARIES)'; test -n "$(nativeexeclibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(nativeexeclibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(nativeexeclibdir)"; \
+ }
+
+uninstall-nativeexeclibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nativeexeclib_LTLIBRARIES)'; test -n "$(nativeexeclibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(nativeexeclibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(nativeexeclibdir)/$$f"; \
+ done
+
+clean-nativeexeclibLTLIBRARIES:
+ -test -z "$(nativeexeclib_LTLIBRARIES)" || rm -f $(nativeexeclib_LTLIBRARIES)
+ @list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libjavamath.la: $(libjavamath_la_OBJECTS) $(libjavamath_la_DEPENDENCIES)
+ $(libjavamath_la_LINK) -rpath $(nativeexeclibdir) $(libjavamath_la_OBJECTS) $(libjavamath_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_math_GMP.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ 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
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ 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"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(nativeexeclibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+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)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-nativeexeclibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-nativeexeclibLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-nativeexeclibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-nativeexeclibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags dvi dvi-am html html-am info info-am install \
+ install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-nativeexeclibLTLIBRARIES install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-nativeexeclibLTLIBRARIES
+
+
+# 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:
diff --git a/libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c b/libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c
new file mode 100644
index 000000000..85c2e6b0f
--- /dev/null
+++ b/libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c
@@ -0,0 +1,1396 @@
+/* gnu_java_math_GMP.c -- Native MPI implemenetation over GNU MP
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath 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.
+
+GNU Classpath 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 GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gnu_java_math_GMP.h"
+#include <jcl.h>
+
+#if defined(HAVE_GMP_H)
+#include <gmp.h>
+#endif /* defined(HAVE_GMP_H) */
+
+#if defined(WITH_GNU_MP)
+#else
+#warning GNU MP not available or wanted!
+#warning Invocation of natXXX() methods will raise an exception
+#endif
+
+/*
+ * This is the implementation of the native BigInteger$NativeMPI methods which
+ * use the GNU MP (GMP) library.
+ *
+ * In all the Java non-statically declared native methods, the second argument,
+ * an instance of jobject, refers to the current NativeMPI instance; i.e.
+ * "this" in Java parlance. The corresponding allocated data structure
+ * representing the GMP's counter-part is pointed-to by the pointer stored in a
+ * transient java field named "native_ptr". The first thing these methods do is
+ * (a) access that field with a JNI GetObjectField() call to obtain the
+ * reference to the gnu.classpath.Pointer subclass instance, then (b) obtain
+ * the native GMP pointer (an mpz_ptr), in order to perform their job; e.g.
+ *
+ * JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr))
+ *
+ * For static methods the second argument, an instance of jclass, is almost
+ * always unused --except when initializing the library, which is the only time
+ * we get hold of the native pointer field.
+ *
+ * This code was written and tested with GNU MP version 4.1.2. More recent
+ * versions of that library offer more operations; e.g. in the implementation
+ * of the method Java_java_math_BigInteger_00024NativeMPI_natFlipBit, mpz_combit()
+ * should be used with GNU MP versions later than 4.2. As a consequence, this
+ * code should be reviewed, from time to time, to use newer features of the GNU
+ * MP library.
+ */
+
+static jfieldID native_ptr;
+
+#ifdef DEBUG
+#define TRACE(msg) fprintf (stderr, "%s(%s:%d) -- %s\n", __FUNCTION__, __FILE__, __LINE__, msg)
+#else
+#define TRACE(msg)
+#endif
+
+#define throw_config_exception(env) JCL_ThrowException (env, "java/lang/Error", "GNU MP was not specified/found by configure")
+
+/*
+ * Initialize the native library. Specifically this method:
+ *
+ * a. Pass NULLs to the mp_set_memory_functions implying that GMP should use
+ * malloc, realloc and free for memory allocation, and if they fail GMP
+ * will print a message to the standard error output and terminates the
+ * program.
+ * b. Find out and store the reference to the NativeMPI class's 'native_ptr'
+ * field. This is done so later in the method invocations we can access that
+ * field and acquire the native value associated with that Pointer instance.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natInitializeLibrary (JNIEnv *env,
+ jclass nativeMPI)
+{
+#if defined(WITH_GNU_MP)
+ TRACE("Loading GMP-based BigInteger native library");
+ mp_set_memory_functions (NULL, NULL, NULL);
+ native_ptr = (*env)->GetFieldID (env, nativeMPI, "native_ptr",
+ "Lgnu/classpath/Pointer;");
+ TRACE("Loaded GMP-based BigInteger native library");
+#else /* !defined(WITH_GNU_MP) */
+ (void) nativeMPI;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * Allocate and initialize the data structure for an instance of a NativeMPI.
+ *
+ * @param this an instance of NativeMPI.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natInitialize(JNIEnv *env, jobject this)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_malloc (env, sizeof (mpz_t));
+ /* initialize --GMP sets the value to zero. */
+ mpz_init (_this);
+ /* instantiate the Pointer instance for this NativeMPI. */
+ jobject native_ptr_fld = JCL_NewRawDataObject (env, _this);
+ /* ... and assign it to the native_ptr field. */
+ (*env)->SetObjectField (env, this, native_ptr, native_ptr_fld);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * Clear and free the data structure for an instance of a NativeMPI.
+ *
+ * @param this an instance of NativeMPI.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natFinalize(JNIEnv *env, jobject this)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ if (_this != NULL)
+ {
+ mpz_clear (_this);
+ free (_this);
+ _this = NULL;
+ }
+ else
+ {
+ TRACE("WARNING: Already cleared + freed");
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+
+/*
+ * @param this an instance of NativeMPI. On exit, this will have a value of n.
+ * @param n a Java long primitive value.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natFromLong(JNIEnv *env, jobject this,
+ jlong n)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ /* the size of jlong (64-bit) is either the same as a long, or that of a long long.
+ * if it's the former, we use as is. */
+ if (sizeof (jlong) == sizeof (long))
+ {
+ mpz_set_si (_this, (signed long)n);
+ }
+ else
+ {
+ /* ...otherwise, we operate on the two halves of the long long, each half
+ * being 32-bit wide. for simplicity, we work with positive
+ * values negating, if necessary, the final outcome.
+ */
+ const int isnegative = n < 0 ? 1 : 0;
+ if (isnegative)
+ {
+ n = -n;
+ }
+ mpz_set_ui (_this, (unsigned long)(((unsigned long long)n) >> 32));
+ mpz_mul_2exp (_this, _this, 32); /* shift left by 32 bits */
+ mpz_add_ui (_this, _this, (unsigned long)n);
+ if (isnegative)
+ {
+ mpz_neg (_this, _this);
+ }
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) n;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI. On exit, this will have the same
+ * value as x.
+ * @param x an instance of a NativeMPI's Pointer.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natFromBI(JNIEnv *env, jobject this,
+ jobject x)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this;
+ mpz_srcptr _x;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ mpz_set (_this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI. On exit, this will have the value
+ * represented by the v Java byte array (in 2's complement with most
+ * significant byte at index position 0). The sign is implied by the
+ * value of the most significant byte.
+ * @param v a Java byte array containing the byte representation, in 2's
+ * complement of the signed value to assign to this.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natFromByteArray(JNIEnv *env,
+ jobject this,
+ jbyteArray v)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this;
+ jbyte *_v;
+ unsigned long b;
+ int vlength, isnegative, i;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _v = (*env)->GetByteArrayElements (env, v, NULL);
+ vlength = (*env)->GetArrayLength (env, v);
+ b = (unsigned long)(_v[0] & 0xFF);
+ isnegative = (b > 0x7F) ? 1 : 0;
+ mpz_set_ui (_this, 0);
+ for (i = 0; i < vlength; i++)
+ {
+ mpz_mul_2exp (_this, _this, 8); /* shift left 8 positions. */
+ b = (unsigned long)(_v[i] & 0xFF);
+ b = (isnegative) ? ~b : b;
+ mpz_add_ui (_this, _this, (unsigned long)(b & 0xFF));
+ }
+ (*env)->ReleaseByteArrayElements (env, v, _v, JNI_ABORT);
+ if (isnegative)
+ {
+ mpz_add_ui (_this, _this, 1);
+ mpz_neg (_this, _this);
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) v;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI. On exit, this will have the value
+ * represented by the s Java string.
+ * @param s a Java string containing, a possibly signed, value to assign to
+ * this.
+ * @param rdx the base in which the symbols, in s, are represented.
+ * @return 0 if the entire string is a valid number in base rdx. Otherwise it
+ * returns -1.
+ *
+ * Implementation note:
+ * While the GMP library is more tolerant in what it accepts as parameter values
+ * for conversions from strings, the BigInteger code, which calls this method,
+ * ensures that the contract described in the RI's documentation is respected;
+ * e.g. no white spaces in the middle, limited valid radix values, etc...
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natFromString(JNIEnv *env,
+ jobject this, jstring s,
+ jint rdx)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this;
+ const char *_s;
+ int result;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _s = (*env)->GetStringUTFChars (env, s, NULL);
+ result = mpz_set_str (_this, _s, (int)rdx);
+ JCL_free_cstring (env, s, _s);
+ TRACE("end");
+ return (result);
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) s;
+ (void) rdx;
+ throw_config_exception(env);
+ return (-1);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI. On exit, this will have the value
+ * represented by the m Java byte array (most significant byte at
+ * index position 0). It will be positive, or negative, depending on
+ * the value of isnegative.
+ * @param m a Java byte array containing the byte representation of the
+ * absolute value (most significant byte being at index position 0)
+ * to assign to this.
+ * @param isnegative true if this should be negative and false if it should
+ * be positive.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natFromSignedMagnitude(JNIEnv *env,
+ jobject this,
+ jbyteArray m,
+ jboolean isnegative)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this;
+ jbyte *_m;
+ int mlength, i;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _m = (*env)->GetByteArrayElements (env, m, NULL);
+ mlength = (*env)->GetArrayLength (env, m);
+ mpz_set_ui (_this, 0);
+ for (i = 0; i < mlength; i++)
+ {
+ mpz_mul_2exp (_this, _this, 8);
+ mpz_add_ui (_this, _this, (unsigned long)(_m[i] & 0xFF));
+ }
+ (*env)->ReleaseByteArrayElements (env, m, _m, JNI_ABORT);
+ if (isnegative == JNI_TRUE)
+ {
+ mpz_neg (_this, _this);
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) m;
+ (void) isnegative;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n the base in which to represent this.
+ * @return the Java string representing the value of this in base n.
+ */
+JNIEXPORT jstring JNICALL
+Java_gnu_java_math_GMP_natToString(JNIEnv *env, jobject this,
+ jint n)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ char *cstr;
+ jstring result;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ cstr = mpz_get_str (NULL, (int)n, _this);
+ result = (*env)->NewStringUTF (env, cstr);
+ free (cstr);
+ TRACE("end");
+ return (result);
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ throw_config_exception(env);
+ return (NULL);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this a non-ZERO instance of NativeMPI.
+ *
+ * output:
+ * @param r a Java byte array which shall contain the byte representation of
+ * this.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natToByteArray(JNIEnv *env,
+ jobject this,
+ jbyteArray r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_t _w; /* a temporary work mpi */
+ jbyte *_r;
+ int rlength, sign, i;
+ unsigned long b;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (*env)->GetByteArrayElements (env, r, NULL);
+ rlength = (*env)->GetArrayLength (env, r);
+ mpz_init (_w);
+ /* if this is negative set w to its 2's complement otherwise use as is. */
+ sign = mpz_sgn (_this);
+ if (sign == 1)
+ {
+ mpz_set (_w, _this);
+ }
+ else
+ {
+ mpz_neg (_w, _this);
+ mpz_sub_ui (_w, _w, 1);
+ }
+ /* _w SHOULD be >= 0.
+ * start filling the array starting from the least significant byte. */
+ for (i = rlength; --i >= 0; )
+ {
+ b = mpz_tdiv_q_ui (_w, _w, 256);
+ b = (sign == -1) ? ~b : b;
+ _r[i] = (unsigned long)(b & 0xFF);
+ }
+ (*env)->ReleaseByteArrayElements (env, r, _r, JNI_COMMIT);
+ /* if _w > 0 the byte array was short. */
+ if (mpz_cmp_ui (_w, 0) > 0)
+ {
+ TRACE("WARNING: byte array is too short");
+ }
+ mpz_clear (_w);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @return the "int" value (least significant 32 bits) of the absolute value
+ * of this NativeMPI. The calling code MUST handle the sign. We do
+ * this so we can use the same method when computing the "long" value
+ * as well.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natAbsIntValue(JNIEnv *env,
+ jobject this)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ TRACE("end");
+ return ((jint)mpz_get_ui (_this));
+#else /* !defined(WITH_GNU_MP) */
+ (void) s;
+ throw_config_exception(env);
+ return (-1);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @return the, eventually truncated, double value of this NativeMPI.
+ */
+JNIEXPORT jdouble JNICALL
+Java_gnu_java_math_GMP_natDoubleValue(JNIEnv *env,
+ jobject this)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ TRACE("end");
+ return ((jdouble)mpz_get_d (_this));
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ throw_config_exception(env);
+ return (0.0);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this a NativeMPI instance.
+ * @param x an instance of NativeMPI's Pointer.
+ * @return -1, 0, +1 if x is respectively less than, equal to, or greater
+ * than y.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natCompare(JNIEnv *env, jobject this,
+ jobject x)
+{
+#if defined(WITH_GNU_MP)
+ mpz_ptr _this, _x;
+ int res;
+
+ TRACE("begin");
+ _this = (mpz_ptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_ptr)JCL_GetRawData (env, x);
+ res = mpz_cmp (_this, _x);
+ TRACE("end");
+ if (res == 0)
+ return ((jint)0);
+ else if (res < 0)
+ return ((jint)-1);
+ else
+ return ((jint)1);
+#else /* !defined(WITH_GNU_MP) */
+ (void) x;
+ (void) y;
+ throw_config_exception(env);
+ return (0);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this + x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natAdd(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_add (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this - x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natSubtract(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_sub (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this * x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natMultiply(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_mul (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this div x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natQuotient(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_tdiv_q (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this mod x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natRemainder(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_tdiv_r (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param q a NativeMPI's Pointer such that q = this div x.
+ * @param r a NativeMPI's Pointer such that r = this mod x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natQuotientAndRemainder(JNIEnv *env,
+ jobject this,
+ jobject x,
+ jobject q,
+ jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _q, _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _q = (mpz_ptr)JCL_GetRawData (env, q);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_tdiv_qr (_q, _r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) q;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this mod x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natModulo(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_mod (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n a non-negative number to raise this to.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this ** n.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natPow(JNIEnv *env, jobject this,
+ jint n, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_pow_ui (_r, _this, (unsigned long)n);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param e an instance of NativeMPI's Pointer.
+ * @param m another instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = (this**e) mod m.
+ *
+ * @throws java.lang.ArithmeticException if e is negative and (1 / this) mod m
+ * has no multiplicative inverse.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natModPow(JNIEnv *env, jobject this,
+ jobject e, jobject m,
+ jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _e, _m;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _e = (mpz_srcptr)JCL_GetRawData (env, e);
+ _m = (mpz_srcptr)JCL_GetRawData (env, m);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ /* the documentation of mpz_powm(rop, b, e, m) states that it: "Set rop to
+ * (b raised to e) modulo m. Negative e is supported if an inverse b^-1 mod m
+ * exists.... If an inverse doesn't exist then a divide by zero is raised."
+ * to work around this case we use the same code as in the pure java class;
+ * i.e.:
+ * if (e.isNegative())
+ * return this.modInverse(m).modPow(e.negate(), m); */
+ if (mpz_sgn (_e) == -1)
+ {
+ mpz_t _w; /* a temporary work mpi */
+ const int res = mpz_invert (_r, _this, _m);
+ if (res == 0)
+ {
+ JCL_ThrowException (env, "java/lang/ArithmeticException",
+ "No multiplicative inverse modulo the designated number exists");
+ }
+ mpz_init (_w);
+ mpz_neg (_w, _e);
+ mpz_powm (_r, _r, _w, _m);
+ mpz_clear (_w);
+ }
+ else
+ {
+ mpz_powm (_r, _this, _e, _m);
+ }
+
+ while (mpz_sgn (_r) == -1)
+ {
+ mpz_add (_r, _r, _m);
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) e;
+ (void) m;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param m an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = (1 / this) mod m.
+ * @throws java.lang.ArithmeticException if (1 / this) mod m has no
+ * multiplicative inverse.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natModInverse(JNIEnv *env,
+ jobject this,
+ jobject m, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _m;
+ mpz_ptr _r;
+ int res;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _m = (mpz_srcptr)JCL_GetRawData (env, m);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ res = mpz_invert (_r, _this, _m);
+ if (res == 0)
+ {
+ JCL_ThrowException (env, "java/lang/ArithmeticException",
+ "No multiplicative inverse modulo the designated number exists");
+ }
+
+ while (mpz_sgn (_r) == -1)
+ {
+ mpz_add (_r, _r, _m);
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r is the GCD of this and x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natGCD(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_gcd (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n number of Miller-Rabin tests to conduct.
+ * @return 2 if this is definitely prime. Returns 1 if this is probably prime
+ * (without being certain). Finally, returns 0 if this is definitely
+ * composite.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natTestPrimality(JNIEnv *env,
+ jobject this, jint n)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ TRACE("end");
+ return ((jint)mpz_probab_prime_p (_this, (int)n));
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ throw_config_exception(env);
+ return (0);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n the non-negative number of positions to shift right this by.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this * 2**n.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natShiftLeft(JNIEnv *env, jobject this,
+ jint n, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_mul_2exp (_r, _this, (unsigned long)n);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n the non-negative number of positions to shift left this by.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = floor(this / 2**n).
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natShiftRight(JNIEnv *env,
+ jobject this, jint n,
+ jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_fdiv_q_2exp (_r, _this, (unsigned long)n);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @return the 0-based index of the lowest significant bit set (to 1) in this.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natLowestSetBit(JNIEnv *env,
+ jobject this)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ TRACE("end");
+ return ((jint)mpz_scan1 (_this, 0));
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ throw_config_exception(env);
+ return (-1);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = abs(x).
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natAbs(JNIEnv *env, jobject this,
+ jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_abs (_r, _this);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = -x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natNegate(JNIEnv *env, jobject this,
+ jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_neg (_r, _this);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @return the number of bits needed to represent this.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natBitLength(JNIEnv *env, jobject this)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ TRACE("end");
+ return ((jint)mpz_sizeinbase (_this, 2));
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ throw_config_exception(env);
+ return (-1);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI. It MUST be >= ZERO.
+ * @return the number of bits set (to 1) in this.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natSetBitCount(JNIEnv *env,
+ jobject this)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _bi;
+ unsigned long res = 0;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ switch (mpz_sgn (_this))
+ {
+ case -1:
+ /* initialize --GMP sets the value to zero. */
+ _bi = (mpz_ptr)JCL_malloc (env, sizeof (mpz_t));
+ mpz_init (_bi);
+ mpz_neg (_bi, _this);
+ res = mpz_popcount (_bi);
+ mpz_clear (_bi);
+ free (_bi);
+ break;
+ case 0:
+ res = 0;
+ break;
+ case 1:
+ res = mpz_popcount (_this);
+ default:
+ JCL_ThrowException (env, "java/lang/Error",
+ "Unexpected sign value for a native MPI");
+ }
+ TRACE("end");
+ return ((jint)res);
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ throw_config_exception(env);
+ return (ULONG_MAX);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this ^ x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natXor(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_xor (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this | x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natOr(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_ior (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this & x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natAnd(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_and (_r, _this, _x);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param x an instance of NativeMPI's Pointer.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = this & ~x.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natAndNot(JNIEnv *env, jobject this,
+ jobject x, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this, _x;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _x = (mpz_srcptr)JCL_GetRawData (env, x);
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_com (_r, _x);
+ mpz_and (_r, _this, _r);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) x;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n the 0-based index position of the bit to flip in this. n MUST be
+ * greater than, or equal to 0.
+ *
+ * output:
+ * @param r a copy of this NativeMPI's Pointer with its n-th bit flipped.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natFlipBit(JNIEnv *env, jobject this,
+ jint n, jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_set (_r, _this);
+ /* GNU MP versions earlier than 4.2 do not define this method:
+ * mpz_combit (_r, (unsigned long)n); */
+ if (mpz_tstbit (_r, (unsigned long)n) == 1)
+ {
+ mpz_clrbit (_r, (unsigned long)n);
+ }
+ else
+ {
+ mpz_setbit (_r, (unsigned long)n);
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n the 0-based index position of the bit to test in this. n MUST be
+ * greater than, or equal to 0.
+ * @return +1, or -1 depending on whether the n-th bit in this is set or not
+ * respectively.
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_math_GMP_natTestBit(JNIEnv *env, jobject this,
+ jint n)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ TRACE("end");
+ return ((jint)mpz_tstbit (_this, (unsigned long)n));
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ throw_config_exception(env);
+ return (-1);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ * @param n the 0-based index position of the bit to set, or clear, in this.
+ * n MUST be greater than, or equal to 0.
+ * @param setIt if true, then the n-th bit in this will be set, otherwise it
+ * will be cleared.
+ *
+ * output:
+ * @param r a copy of this NativeMPI's Pointer with its n-th bit set or cleared
+ * as requested.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natSetBit(JNIEnv *env, jobject this,
+ jint n, jboolean setIt,
+ jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_set (_r, _this);
+ if (setIt == JNI_TRUE)
+ {
+ mpz_setbit (_r, (unsigned long)n);
+ }
+ else
+ {
+ mpz_clrbit (_r, (unsigned long)n);
+ }
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) n;
+ (void) setIt;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}
+
+/*
+ * @param this an instance of NativeMPI.
+ *
+ * output:
+ * @param r a NativeMPI's Pointer such that r = ~this.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_math_GMP_natNot(JNIEnv *env, jobject this,
+ jobject r)
+{
+#if defined(WITH_GNU_MP)
+ mpz_srcptr _this;
+ mpz_ptr _r;
+
+ TRACE("begin");
+ _this = (mpz_srcptr)JCL_GetRawData (env, (*env)->GetObjectField (env, this, native_ptr));
+ _r = (mpz_ptr)JCL_GetRawData (env, r);
+ mpz_com (_r, _this);
+ TRACE("end");
+#else /* !defined(WITH_GNU_MP) */
+ (void) this;
+ (void) r;
+ throw_config_exception(env);
+#endif /* defined(WITH_GNU_MP) */
+}