]> Savannah Git Hosting - gnulib.git/commitdiff
xalloc-die: Fix link error with Solaris cc (regression 2020-07-27).
authorBruno Haible <bruno@clisp.org>
Mon, 19 Oct 2020 23:12:51 +0000 (01:12 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 19 Oct 2020 23:12:51 +0000 (01:12 +0200)
* lib/xalloc.h (xalloc_die): Don't declare if GNULIB_XALLOC_DIE is 0.
(xmalloc, xzalloc, xcalloc, xrealloc, x2realloc, xmemdup, xstrdup,
XMALLOC, XNMALLOC, XZALLOC, XCALLOC, xnmalloc, xnrealloc, x2nrealloc,
xcharalloc): Don't declare/define if GNULIB_XALLOC is 0.
* modules/xalloc (configure.ac): Define GNULIB_XALLOC.
* modules/xalloc-die (configure.ac): Define GNULIB_XALLOC_DIE.

ChangeLog
lib/xalloc.h
modules/xalloc
modules/xalloc-die

index 4903d51e9ebb3542ce10dfc7da93d48bcf8fab69..e0e2a30b4137effa4177686a3a248b8ab03598cf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-10-19  Bruno Haible  <bruno@clisp.org>
+
+       xalloc-die: Fix link error with Solaris cc (regression 2020-07-27).
+       * lib/xalloc.h (xalloc_die): Don't declare if GNULIB_XALLOC_DIE is 0.
+       (xmalloc, xzalloc, xcalloc, xrealloc, x2realloc, xmemdup, xstrdup,
+       XMALLOC, XNMALLOC, XZALLOC, XCALLOC, xnmalloc, xnrealloc, x2nrealloc,
+       xcharalloc): Don't declare/define if GNULIB_XALLOC is 0.
+       * modules/xalloc (configure.ac): Define GNULIB_XALLOC.
+       * modules/xalloc-die (configure.ac): Define GNULIB_XALLOC_DIE.
+
 2020-10-18  Bruno Haible  <bruno@clisp.org>
 
        ssfmalloc: Add tests.
index 24273ffbe333b4fbbdfba2c11d247dc02ed33612..d4f96bfe0f5bd1b118356fb047bcc17546851141 100644 (file)
@@ -31,11 +31,14 @@ _GL_INLINE_HEADER_BEGIN
 # define XALLOC_INLINE _GL_INLINE
 #endif
 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
+#if GNULIB_XALLOC_DIE
+
 /* This function is always triggered when memory is exhausted.
    It must be defined by the application, either explicitly
    or by using gnulib's xalloc-die module.  This is the
@@ -43,6 +46,10 @@ extern "C" {
    memory allocation failure.  */
 /*extern*/ _Noreturn void xalloc_die (void);
 
+#endif /* GNULIB_XALLOC_DIE */
+
+#if GNULIB_XALLOC
+
 void *xmalloc (size_t s)
       _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 void *xzalloc (size_t s)
@@ -64,23 +71,23 @@ char *xstrdup (char const *str)
 
 /* Allocate an object of type T dynamically, with error checking.  */
 /* extern t *XMALLOC (typename t); */
-#define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
+# define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
 
 /* Allocate memory for N elements of type T, with error checking.  */
 /* extern t *XNMALLOC (size_t n, typename t); */
-#define XNMALLOC(n, t) \
-   ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
+# define XNMALLOC(n, t) \
+    ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
 
 /* Allocate an object of type T dynamically, with error checking,
    and zero it.  */
 /* extern t *XZALLOC (typename t); */
-#define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
+# define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
 
 /* Allocate memory for N elements of type T, with error checking,
    and zero it.  */
 /* extern t *XCALLOC (size_t n, typename t); */
-#define XCALLOC(n, t) \
-   ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
+# define XCALLOC(n, t) \
+    ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
 
 
 /* Allocate an array of N objects, each with S bytes of memory,
@@ -211,8 +218,15 @@ xcharalloc (size_t n)
   return XNMALLOC (n, char);
 }
 
+#endif /* GNULIB_XALLOC */
+
+
 #ifdef __cplusplus
 }
+#endif
+
+
+#if GNULIB_XALLOC && defined __cplusplus
 
 /* C++ does not allow conversions from void * to other pointer types
    without a cast.  Use templates to work around the problem when
@@ -248,7 +262,8 @@ xmemdup (T const *p, size_t s)
   return (T *) xmemdup ((void const *) p, s);
 }
 
-#endif
+#endif /* GNULIB_XALLOC && C++ */
+
 
 _GL_INLINE_HEADER_END
 
index c6e3cfd9debbddda01fda603f37e42459cdcb345..65007561b54b21a62cbf98a451ac5b4060815125 100644 (file)
@@ -15,6 +15,7 @@ xalloc-oversized
 
 configure.ac:
 gl_XALLOC
+gl_MODULE_INDICATOR([xalloc])
 
 Makefile.am:
 lib_SOURCES += xmalloc.c
index 23ade89e70bd8f6ca634e9eb8690f11d686afbc3..f53de5a5ac787d1b3f5d336b9bac1ceb566f97be 100644 (file)
@@ -14,6 +14,7 @@ stdint
 xalloc-oversized
 
 configure.ac:
+gl_MODULE_INDICATOR([xalloc-die])
 
 Makefile.am:
 lib_SOURCES += xalloc-die.c