Skip to content
Permalink
Browse files

Fix #521, failed to build with libc without malloc_stats, malloc_trim

  • Loading branch information
klirichek committed Sep 28, 2018
1 parent 06ee6b5 commit 4f155712a0bccc1bd01cc191647bc8cff814888e
@@ -297,6 +297,12 @@ else ( WIN32 )
message ( STATUS "Checking for SO_REUSEPORT flag" )
include ( check_so_reuseport_availability )

message ( STATUS "Checking for malloc_trim availability" )
include ( check_malloc_trim_availability )

message ( STATUS "Checking for malloc_stats availability" )
include ( check_malloc_stats_availability )

message ( STATUS "Checking for PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP flag" )
include ( check_rwlock_prefer_writer )

@@ -0,0 +1,16 @@
#find if malloc_stats() is available
set ( _CHECK_MALLOC_STATS_PROG "
#include <malloc.h>
#ifdef __CLASSIC_C__
int main() {
int ac;
char*av[];
#else
int main(int ac, char*av[]){
#endif
malloc_stats();
return 0;
}" )

include ( CheckCXXSourceCompiles )
CHECK_CXX_SOURCE_COMPILES ( "${_CHECK_MALLOC_STATS_PROG}" HAVE_MALLOC_STATS )
@@ -0,0 +1,16 @@
#find if malloc_trim() is available
set ( _CHECK_MALLOC_TRIM_PROG "
#include <malloc.h>
#ifdef __CLASSIC_C__
int main() {
int ac;
char*av[];
#else
int main(int ac, char*av[]){
#endif
malloc_trim(0);
return 0;
}" )

include ( CheckCXXSourceCompiles )
CHECK_CXX_SOURCE_COMPILES ( "${_CHECK_MALLOC_TRIM_PROG}" HAVE_MALLOC_TRIM )
@@ -64,6 +64,12 @@
/* Define if your system supports flag SO_REUSEPORT */
#cmakedefine01 HAVE_SO_REUSEPORT

/* Define if your system libc has malloc_trim() */
#cmakedefine01 HAVE_MALLOC_TRIM

/* Define if your system libc has malloc_stats() */
#cmakedefine01 HAVE_MALLOC_STATS

/* Define if your system supports flag PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP */
#cmakedefine01 HAVE_RWLOCK_PREFER_WRITER

@@ -16332,7 +16332,7 @@ void HandleMysqlDebug ( SqlRowBuffer_c &tOut, const SqlStmt_t &tStmt, bool bVipC
tOut.HeadTuplet ( "command", "result" );
tOut.DataTuplet ( "debug token", sSha.cstr() );
}
#if HAVE_MALLOC_H
#if HAVE_MALLOC_STATS
else if ( sCommand=="malloc_stats" )
{
tOut.HeadTuplet ( "command", "result" );
@@ -16343,7 +16343,10 @@ void HandleMysqlDebug ( SqlRowBuffer_c &tOut, const SqlStmt_t &tStmt, bool bVipC
::dup2 ( iOldErr, STDERR_FILENO );
::close ( iOldErr );
tOut.DataTuplet ( "malloc_stats", g_sLogFile.cstr());
} else if ( sCommand=="malloc_trim" )
}
#endif
#if HAVE_MALLOC_TRIM
else if ( sCommand=="malloc_trim" )
{
tOut.HeadTuplet ( "command", "result" );
CSphString sResult;
@@ -16373,8 +16376,10 @@ void HandleMysqlDebug ( SqlRowBuffer_c &tOut, const SqlStmt_t &tStmt, bool bVipC
}
tOut.DataTuplet ( "flush logs", "emulate USR1 signal" );
tOut.DataTuplet ( "reload indexes", "emulate HUP signal" );
#if HAVE_MALLOC_H
#if HAVE_MALLOC_STATS
tOut.DataTuplet ( "malloc_stats", "perform 'malloc_stats', result in searchd.log" );
#endif
#if HAVE_MALLOC_TRIM
tOut.DataTuplet ( "malloc_trim", "pefrorm 'malloc_trim' call" );
#endif
tOut.DataTuplet ( "sleep Nsec", "sleep for N seconds" );

0 comments on commit 4f15571

Please sign in to comment.
You can’t perform that action at this time.