[libgtop/wip/lantw/Check-if-sbrk-is-available: 3/3] Check if sbrk is available



commit 4229d1ea2018ccd7be94858f4d06013ce59f03cf
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Mon Dec 2 21:46:50 2019 +0800

    Check if sbrk is available
    
    The only use of sbrk in libgtop is in an example which always calls it
    with 0. Since the use of sbrk provides no functionality, just skip these
    calls when sbrk is not available.
    
    This problem was first reported on FreeBSD Bugzilla because FreeBSD
    decides not to support sbrk on ARM64 and RISC-V:
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221751
    
    Fix https://gitlab.gnome.org/GNOME/libgtop/issues/46

 configure.ac         | 2 +-
 examples/mountlist.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/configure.ac b/configure.ac
index 712b787c..d7215bf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -213,7 +213,7 @@ AC_FUNC_ALLOCA
 AC_FUNC_MMAP
 AC_TYPE_SIGNAL
 AC_FUNC_STRFTIME
-AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv strdup strtoul uname)
+AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv sbrk strdup strtoul uname)
 
 # FIXME: Remove AM_GNU_GETTEXT_VERSION once autoreconf supports REQUIRE_VERSION
 AM_GNU_GETTEXT_VERSION([0.19.6])
diff --git a/examples/mountlist.c b/examples/mountlist.c
index bbb005fc..6feacf91 100644
--- a/examples/mountlist.c
+++ b/examples/mountlist.c
@@ -71,7 +71,9 @@ main (int argc, char *argv [])
 
        printf ("Host = '%s' - %u\n\n", buffer, port);
 
+#ifdef HAVE_SBRK
        printf ("sbrk (0) = %p\n\n", sbrk (0));
+#endif
 
        for (c = 0; c < PROFILE_COUNT; c++) {
                mount_entries = glibtop_get_mountlist (&mount_list, 1);
@@ -79,7 +81,9 @@ main (int argc, char *argv [])
                g_free (mount_entries);
        }
 
+#ifdef HAVE_SBRK
        printf ("sbrk (0) = %p\n\n", sbrk (0));
+#endif
 
        mount_entries = glibtop_get_mountlist (&mount_list, 1);
 
@@ -108,7 +112,9 @@ main (int argc, char *argv [])
 
        g_free (mount_entries);
 
+#ifdef HAVE_SBRK
        printf ("\nsbrk (0) = %p\n\n", sbrk (0));
+#endif
 
        glibtop_close ();
 


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