Skip to content

Commit

Permalink
common/MemoryModel: Alpine is a linux variant but does not implement …
Browse files Browse the repository at this point in the history
…mallinfo(). Added explicit feature check.

Signed-off-by: John Coyle <dx9err@gmail.com>
  • Loading branch information
dx9 committed Oct 19, 2015
1 parent e7b49f5 commit e138e78
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -32,6 +32,7 @@ CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE)
CHECK_FUNCTION_EXISTS(posix_fallocate HAVE_POSIX_FALLOCATE)
CHECK_FUNCTION_EXISTS(syncfs HAVE_SYS_SYNCFS)
CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE)
CHECK_FUNCTION_EXISTS(mallinfo HAVE_MALLINFO)
CHECK_INCLUDE_FILES("arpa/inet.h" HAVE_ARPA_INET_H)
CHECK_INCLUDE_FILES("boost/random/discrete_distribution.hpp" HAVE_BOOST_RANDOM_DISCRETE_DISTRIBUTION)
CHECK_INCLUDE_FILES("dirent.h" HAVE_DIRENT_H)
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Expand Up @@ -964,6 +964,10 @@ AC_CHECK_FUNC([fallocate],
[AC_DEFINE([CEPH_HAVE_FALLOCATE], [], [fallocate(2) is supported])],
[])

# mallinfo
AC_CHECK_FUNC([mallinfo],
[AC_DEFINE(HAVE_MALLINFO, 1, [Define if you have mallinfo])])

# getgrouplist
AC_CHECK_FUNCS([getgrouplist])

Expand Down
3 changes: 2 additions & 1 deletion src/common/MemoryModel.cc
@@ -1,4 +1,5 @@

#include "acconfig.h"
#include "include/types.h"
#include "MemoryModel.h"
#include "common/config.h"
Expand Down Expand Up @@ -92,7 +93,7 @@ void MemoryModel::_sample(snap *psnap)
psnap->heap = heap >> 10;

// ...
#if defined(__linux__)
#if defined(HAVE_MALLINFO)
struct mallinfo mi = mallinfo();

psnap->malloc = mi.uordblks >> 10;
Expand Down
3 changes: 3 additions & 0 deletions src/include/config-h.in.cmake
Expand Up @@ -6,6 +6,9 @@
/* fallocate(2) is supported */
#cmakedefine CEPH_HAVE_FALLOCATE

/* mallinfo(3) is supported */
#cmakedefine HAVE_MALLINFO

/* posix_fadvise is supported */
#cmakedefine HAVE_POSIX_FADVISE

Expand Down

0 comments on commit e138e78

Please sign in to comment.