Page MenuHomePhabricator

[llvm] [Support] mallctl() is in malloc.h on NetBSD
AcceptedPublic

Authored by mgorny on Mar 12 2019, 6:23 AM.

Details

Summary

Fix the CMake check and Support code for mallctl() to account for
the function being added to malloc.h recently. In both cases,
the inconsistency between platforms is resolved by checking for
malloc_np.h first and falling back to malloc.h if it is not present.

Diff Detail

Event Timeline

mgorny created this revision.Mar 12 2019, 6:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2019, 6:23 AM
krytarowski added inline comments.Mar 12 2019, 10:31 AM
llvm/cmake/config-ix.cmake
32

Please add another check for malloc.h

llvm/lib/Support/Unix/Process.inc
39

I really prefer:

#if defined(HAVE_MALLOC_H)
#include <malloc.h>
#endif
#if defined(HAVE_MALLOC_NP_H)
#include <malloc_np.h>
#endif

And use conditionals for MALLINFO/MALLCTL in code using the APIs.

mgorny updated this revision to Diff 190313.Mar 12 2019, 12:54 PM

Updated to use dedicated header checks, as requested by @krytarowski

mgorny marked 2 inline comments as done.Mar 12 2019, 12:54 PM
krytarowski accepted this revision.Mar 12 2019, 1:57 PM

Looks good, but I would hold on a little bit until the situation will stabilize. We might want to add additional scenario of jemalloc.h and MALLCTL interfaces in -ljemalloc. But either way this patch is an improvement.

This revision is now accepted and ready to land.Mar 12 2019, 1:57 PM