groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 13/19: [libgroff]: Make allocator replacement optional.


From: G. Branden Robinson
Subject: [groff] 13/19: [libgroff]: Make allocator replacement optional.
Date: Mon, 8 Nov 2021 18:56:02 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 5151526cfd1aec0222ec2b03ddc725ac9eb803d0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Nov 9 08:36:19 2021 +1100

    [libgroff]: Make allocator replacement optional.
    
    Switch it off by default, relying on C++ runtime new/delete support.
    
    * configure.ac: Call new `GROFF_USE_GROFF_ALLOCATOR` m4 macro.  Use
      `AM_CONDITIONAL` to set Automake variable `USE_GROFF_ALLOCATOR` if
      appropriate.  Report whether the allocator is used in configure script
      output summary.
    
    * m4/groff.m4 (GROFF_USE_GROFF_ALLOCATOR): Define new macro to collect
      user preference.  The default is off.
    
    * src/libs/libgroff/libgroff.am (libgroff_a_SOURCES): Build and link
      new.cpp only if `USE_GROFF_ALLOCATOR`.
    
    * NEWS: Add item.
---
 ChangeLog                     | 16 ++++++++++++++++
 NEWS                          |  9 +++++++++
 configure.ac                  | 11 +++++++++++
 m4/groff.m4                   |  8 ++++++++
 src/libs/libgroff/libgroff.am |  5 ++++-
 5 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 12bdfa9..05a4867 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2021-11-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       [libgroff]: Make allocator replacement optional.  Switch it
+       off by default, relying on C++ runtime new/delete support.
+
+       * configure.ac: Call new `GROFF_USE_GROFF_ALLOCATOR` m4 macro.
+       Use `AM_CONDITIONAL` to set Automake variable
+       `USE_GROFF_ALLOCATOR` if appropriate.  Report whether the
+       allocator is used in configure script output summary.
+       * m4/groff.m4 (GROFF_USE_GROFF_ALLOCATOR): Define new macro to
+       collect user preference.  The default is off.
+       * src/libs/libgroff/libgroff.am (libgroff_a_SOURCES): Build and
+       link new.cpp only if `USE_GROFF_ALLOCATOR`.
+
+       * NEWS: Add item.
+
+2021-11-09  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        * m4/groff.m4 (GROFF_TMAC): Report a human-readable message if
        no system tmac prefix is found, instead of leaving the ellipsis
        hanging.
diff --git a/NEWS b/NEWS
index 41f7448..d61c34f 100644
--- a/NEWS
+++ b/NEWS
@@ -304,6 +304,15 @@ o On the Latin-1 output device ("groff -T latin1") the 
special character
 Miscellaneous
 -------------
 
+o New 'configure' options --{en,dis}able-groff-allocator control whether
+  groff uses its own malloc/free-wrapping allocator to implement all C++
+  new/delete operations.  groff has used this allocator for over 30
+  years; C++ implementations are more mature now.  The default is now to
+  rely on C++ language runtime support for new/delete.  When building
+  groff, use
+    configure --enable-groff-allocator
+  to re-enable groff's traditional allocator.
+
 o Italian language input documents are now supported, including
   hyphenation patterns from the hyph-utf8 project and localized strings
   for the ms, me, mm, and mom packages.  Thanks to Edmond Orignac.
diff --git a/configure.ac b/configure.ac
index f9963a9..cdc425b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,6 +152,9 @@ GROFF_WCOREFLAG
 # URW fonts extra dir
 GROFF_URW_FONTS_PATH
 
+# use groff's own malloc-based allocator for C++ new/delete operators
+GROFF_USE_GROFF_ALLOCATOR
+
 # other random stuff
 GROFF_BROKEN_SPOOLER_FLAGS
 GROFF_PAGE
@@ -199,6 +202,7 @@ AM_CONDITIONAL([BUILD_PDFDOC], [test -n "$make_pdfdoc"])
 AM_CONDITIONAL([BUILD_PDFEXAMPLES], [test -n "$make_pdfexamples"])
 AM_CONDITIONAL([BUILD_OTHERDOC], [test -n "$make_otherdoc"])
 AM_CONDITIONAL([BUILD_EXAMPLES], [test -n "$make_examples"])
+AM_CONDITIONAL([USE_GROFF_ALLOCATOR], [test "x$use_groff_allocator" = "xyes"])
 AM_CONDITIONAL([INSTALL_SHIPPED_HTML], [test -n 
"$make_install_shipped_htmldoc"])
 AM_CONDITIONAL([HAVE_PDFTOOLS], [test "x$groff_have_pdftools" = "xyes" ])
 AM_CONDITIONAL([HAVE_TEXI2DVI], [test "x$groff_have_texi2dvi" = "xyes" ])
@@ -212,6 +216,13 @@ ${PACKAGE_NAME} version ${PACKAGE_VERSION}
 ----------------------------------------------------------------------
  Prefix                          : ${prefix}
  Compiler                        : ${CC} ${CFLAGS} ${CPPFLAGS}"
+if test "x$use_groff_allocator" = "xyes"; then
+echo "\
+ Use groff allocator             : yes"
+else
+echo "\
+ Use groff allocator             : no"
+fi
 if test "x$groff_no_x" = "xyes"; then
 echo "\
  X11 support                     : no"
diff --git a/m4/groff.m4 b/m4/groff.m4
index d7b9ab4..e73a217 100644
--- a/m4/groff.m4
+++ b/m4/groff.m4
@@ -1767,3 +1767,11 @@ AC_DEFUN([GROFF_PDFTOOLS],
       groff_have_pdftools=no;
    fi
    ])
+
+AC_DEFUN([GROFF_USE_GROFF_ALLOCATOR],
+  [AC_ARG_ENABLE([groff-allocator],
+   [AS_HELP_STRING([--enable-groff-allocator], [enable groff's own \
+allocator for C++ new/delete])],
+   [test "x$enableval" = "xyes" && use_groff_allocator=yes],
+   [use_groff_allocator=]
+)])
diff --git a/src/libs/libgroff/libgroff.am b/src/libs/libgroff/libgroff.am
index bd6c7d8..be6d9e2 100644
--- a/src/libs/libgroff/libgroff.am
+++ b/src/libs/libgroff/libgroff.am
@@ -56,7 +56,6 @@ libgroff_a_SOURCES = \
   src/libs/libgroff/maxpathname.cpp \
   src/libs/libgroff/mksdir.cpp \
   src/libs/libgroff/nametoindex.cpp \
-  src/libs/libgroff/new.cpp \
   src/libs/libgroff/paper.cpp \
   src/libs/libgroff/prime.cpp \
   src/libs/libgroff/progname.c \
@@ -74,6 +73,10 @@ libgroff_a_SOURCES = \
   src/libs/libgroff/uniglyph.cpp \
   src/libs/libgroff/uniuni.cpp \
   src/libs/libgroff/relocatable.h
+if USE_GROFF_ALLOCATOR
+libgroff_a_SOURCES += \
+  src/libs/libgroff/new.cpp
+endif
 nodist_libgroff_a_SOURCES = src/libs/libgroff/version.cpp
 
 # TODO: these .c files could be removed (use gnulib instead).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]