]> Savannah Git Hosting - gnulib.git/commitdiff
libgmp-mpz: New module, renamed from libgmp.
authorBruno Haible <bruno@clisp.org>
Wed, 28 Aug 2024 12:16:08 +0000 (14:16 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 28 Aug 2024 12:16:08 +0000 (14:16 +0200)
* modules/libgmp-mpz: Renamed from modules/libgmp.
* modules/libgmp: New file.
* modules/libgmp-mpz-tests: Renamed from modules/libgmp-tests.
* tests/test-libgmp-mpz.c: Renamed from tests/test-libgmp.c.

ChangeLog
modules/libgmp
modules/libgmp-mpz [new file with mode: 0644]
modules/libgmp-mpz-tests [new file with mode: 0644]
modules/libgmp-tests [deleted file]
tests/test-libgmp-mpz.c [new file with mode: 0644]
tests/test-libgmp.c [deleted file]

index 8a7f812b67d48893969ddd0ddefc8538b4c73d23..0d9bf439662faee73ae6a058823f8704fef347a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-08-28  Bruno Haible  <bruno@clisp.org>
+
+       libgmp-mpz: New module, renamed from libgmp.
+       * modules/libgmp-mpz: Renamed from modules/libgmp.
+       * modules/libgmp: New file.
+       * modules/libgmp-mpz-tests: Renamed from modules/libgmp-tests.
+       * tests/test-libgmp-mpz.c: Renamed from tests/test-libgmp.c.
+
 2024-08-28  Bruno Haible  <bruno@clisp.org>
 
        doc: Add more details about O_EXEC and O_SEARCH.
index b8a7c0c32a24f44316ed863088572a4525b1770c..0668b6c3cb27e7ca24b204b42b375c2a66d1e695 100644 (file)
@@ -1,47 +1,15 @@
 Description:
-GNU Multiple Precision Arithmetic library, or its mini-gmp substitute
+GNU Multiple Precision Arithmetic library,
+or its mini-gmp + mini-mpq substitute
 
 Files:
-lib/mini-gmp-gnulib.c
-lib/mini-gmp.c
-lib/mini-gmp.h
-m4/libgmp.m4
 
 Depends-on:
+libgmp-mpz
 
 configure.ac:
-gl_LIBGMP
-gl_CONDITIONAL_HEADER([gmp.h])
-AC_PROG_MKDIR_P
-gl_CONDITIONAL([GL_COND_OBJ_MINI_GMP_GNULIB], [test $HAVE_LIBGMP != yes])
 
 Makefile.am:
-BUILT_SOURCES += $(GMP_H)
-
-if GL_GENERATE_GMP_H
-if GL_GENERATE_MINI_GMP_H
-# Build gmp.h as a wrapper for mini-gmp.h when using mini-gmp.
-gmp.h: $(top_builddir)/config.status
-@NMD@  $(MKDIR_P) '%reldir%'
-       echo '#include "mini-gmp.h"' > $@-t
-       mv $@-t $@
-endif
-if GL_GENERATE_GMP_GMP_H
-# Build gmp.h as a wrapper for gmp/gmp.h.
-gmp.h: $(top_builddir)/config.status
-@NMD@  $(MKDIR_P) '%reldir%'
-       echo '#include <gmp/gmp.h>' > $@-t
-       mv $@-t $@
-endif
-else
-gmp.h: $(top_builddir)/config.status
-       rm -f $@
-endif
-MOSTLYCLEANFILES += gmp.h gmp.h-t
-
-if GL_COND_OBJ_MINI_GMP_GNULIB
-lib_SOURCES += mini-gmp-gnulib.c
-endif
 
 Include:
 <gmp.h>
diff --git a/modules/libgmp-mpz b/modules/libgmp-mpz
new file mode 100644 (file)
index 0000000..4104e79
--- /dev/null
@@ -0,0 +1,57 @@
+Description:
+GNU Multiple Precision Arithmetic library (mpn_*, mpz_* part),
+or its mini-gmp substitute
+
+Files:
+lib/mini-gmp-gnulib.c
+lib/mini-gmp.c
+lib/mini-gmp.h
+m4/libgmp.m4
+
+Depends-on:
+
+configure.ac:
+gl_LIBGMP
+gl_CONDITIONAL_HEADER([gmp.h])
+AC_PROG_MKDIR_P
+gl_CONDITIONAL([GL_COND_OBJ_MINI_GMP_GNULIB], [test $HAVE_LIBGMP != yes])
+
+Makefile.am:
+BUILT_SOURCES += $(GMP_H)
+
+if GL_GENERATE_GMP_H
+if GL_GENERATE_MINI_GMP_H
+# Build gmp.h as a wrapper for mini-gmp.h when using mini-gmp.
+gmp.h: $(top_builddir)/config.status
+@NMD@  $(MKDIR_P) '%reldir%'
+       echo '#include "mini-gmp.h"' > $@-t
+       mv $@-t $@
+endif
+if GL_GENERATE_GMP_GMP_H
+# Build gmp.h as a wrapper for gmp/gmp.h.
+gmp.h: $(top_builddir)/config.status
+@NMD@  $(MKDIR_P) '%reldir%'
+       echo '#include <gmp/gmp.h>' > $@-t
+       mv $@-t $@
+endif
+else
+gmp.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES += gmp.h gmp.h-t
+
+if GL_COND_OBJ_MINI_GMP_GNULIB
+lib_SOURCES += mini-gmp-gnulib.c
+endif
+
+Include:
+<gmp.h>
+
+Link:
+$(LTLIBGMP) when linking with libtool, $(LIBGMP) otherwise
+
+License:
+LGPLv3+ or GPLv2+
+
+Maintainer:
+all
diff --git a/modules/libgmp-mpz-tests b/modules/libgmp-mpz-tests
new file mode 100644 (file)
index 0000000..d1af386
--- /dev/null
@@ -0,0 +1,14 @@
+Files:
+tests/macros.h
+tests/test-libgmp-mpz.c
+
+Depends-on:
+assert-h
+c99
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-libgmp-mpz
+check_PROGRAMS += test-libgmp-mpz
+test_libgmp_mpz_LDADD = $(LDADD) @LIBGMP@
diff --git a/modules/libgmp-tests b/modules/libgmp-tests
deleted file mode 100644 (file)
index b0cb73d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-Files:
-tests/macros.h
-tests/test-libgmp.c
-
-Depends-on:
-assert-h
-c99
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-libgmp
-check_PROGRAMS += test-libgmp
-test_libgmp_LDADD = $(LDADD) @LIBGMP@
diff --git a/tests/test-libgmp-mpz.c b/tests/test-libgmp-mpz.c
new file mode 100644 (file)
index 0000000..9d1e215
--- /dev/null
@@ -0,0 +1,74 @@
+/* Test of libgmp or its mini-gmp substitute.
+   Copyright (C) 2020-2024 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 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 <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <gmp.h>
+
+#include <limits.h>
+#include <string.h>
+
+#include "macros.h"
+
+#ifndef MINI_GMP_LIMB_TYPE
+/* Verify that the gmp.h header file was generated for the same
+   machine word size as we are using.  */
+static_assert (GMP_NUMB_BITS == sizeof (mp_limb_t) * CHAR_BIT);
+#endif
+
+int
+main ()
+{
+#ifndef MINI_GMP_LIMB_TYPE
+  /* Verify that the gmp.h header file and the libgmp library come from
+     the same GMP version.  */
+  {
+    char gmp_header_version[32];
+    sprintf (gmp_header_version, "%d.%d.%d", __GNU_MP_VERSION,
+             __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL);
+    if (strcmp (gmp_version, gmp_header_version) != 0)
+      {
+        char gmp_header_version2[32];
+        if (__GNU_MP_VERSION_PATCHLEVEL > 0
+            || (sprintf (gmp_header_version2, "%d.%d", __GNU_MP_VERSION,
+                         __GNU_MP_VERSION_MINOR),
+                strcmp (gmp_version, gmp_header_version2) != 0))
+          {
+            fprintf (stderr,
+                     "gmp header version (%s) does not match gmp library version (%s).\n",
+                     gmp_header_version, gmp_version);
+            exit (1);
+          }
+      }
+  }
+#endif
+
+  /* A simple sanity check that 2 + 2 = 4.  */
+  static mp_limb_t const twobody[] = { 2 };
+  static mpz_t const two = MPZ_ROINIT_N ((mp_limb_t *) twobody, 1);
+  ASSERT (mpz_fits_slong_p (two));
+  ASSERT (mpz_get_si (two) == 2);
+
+  mpz_t four;
+  mpz_init (four);
+  mpz_add (four, two, two);
+  ASSERT (mpz_fits_slong_p (four));
+  ASSERT (mpz_get_si (four) == 4);
+  mpz_clear (four);
+
+  return test_exit_status;
+}
diff --git a/tests/test-libgmp.c b/tests/test-libgmp.c
deleted file mode 100644 (file)
index 9d1e215..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Test of libgmp or its mini-gmp substitute.
-   Copyright (C) 2020-2024 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 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 <https://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* Specification.  */
-#include <gmp.h>
-
-#include <limits.h>
-#include <string.h>
-
-#include "macros.h"
-
-#ifndef MINI_GMP_LIMB_TYPE
-/* Verify that the gmp.h header file was generated for the same
-   machine word size as we are using.  */
-static_assert (GMP_NUMB_BITS == sizeof (mp_limb_t) * CHAR_BIT);
-#endif
-
-int
-main ()
-{
-#ifndef MINI_GMP_LIMB_TYPE
-  /* Verify that the gmp.h header file and the libgmp library come from
-     the same GMP version.  */
-  {
-    char gmp_header_version[32];
-    sprintf (gmp_header_version, "%d.%d.%d", __GNU_MP_VERSION,
-             __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL);
-    if (strcmp (gmp_version, gmp_header_version) != 0)
-      {
-        char gmp_header_version2[32];
-        if (__GNU_MP_VERSION_PATCHLEVEL > 0
-            || (sprintf (gmp_header_version2, "%d.%d", __GNU_MP_VERSION,
-                         __GNU_MP_VERSION_MINOR),
-                strcmp (gmp_version, gmp_header_version2) != 0))
-          {
-            fprintf (stderr,
-                     "gmp header version (%s) does not match gmp library version (%s).\n",
-                     gmp_header_version, gmp_version);
-            exit (1);
-          }
-      }
-  }
-#endif
-
-  /* A simple sanity check that 2 + 2 = 4.  */
-  static mp_limb_t const twobody[] = { 2 };
-  static mpz_t const two = MPZ_ROINIT_N ((mp_limb_t *) twobody, 1);
-  ASSERT (mpz_fits_slong_p (two));
-  ASSERT (mpz_get_si (two) == 2);
-
-  mpz_t four;
-  mpz_init (four);
-  mpz_add (four, two, two);
-  ASSERT (mpz_fits_slong_p (four));
-  ASSERT (mpz_get_si (four) == 4);
-  mpz_clear (four);
-
-  return test_exit_status;
-}