This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Move __sanitizer_mallinfo to separate header
ClosedPublic

Authored by leonardchan on Mar 28 2023, 3:12 PM.

Details

Summary

mallinfo is platform-specific and not specified by either posix or the C standard, but the hwasan interface unconditionally exposes __sanitizer_mallinfo which returns a struct __sanitizer_struct_mallinfo which is defined in sanitizer_platform_limits_posix.h, so this should also be available for fuchsia to provide __sanitizer_mallinfo. Fuchsia doesn't need the rest of what's in sanitizer_platform_limits_posix.h so we can just move it to its own header.

Exposing this and not forcing it to hide behind SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO fixes the test failures found after landing D145718.

Diff Detail

Event Timeline

leonardchan created this revision.Mar 28 2023, 3:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 3:12 PM
leonardchan requested review of this revision.Mar 28 2023, 3:12 PM

I'm not a big fan of this change since Fuchsia is not POSIX and most of this files isn't useful on Fuchsia. mallinfo is also not specified by neither POSIX nor C standard. Would it be possible to move the definition of __sanitizer_struct_mallinfo to a separate header file?

leonardchan retitled this revision from [compiler-rt][Fuchsia] Allow fuchsia to use sanitizer_platform_limits_posix.h to [compiler-rt] Move __sanitizer_mallinfo to separate header.
leonardchan edited the summary of this revision. (Show Details)

I'm not a big fan of this change since Fuchsia is not POSIX and most of this files isn't useful on Fuchsia. mallinfo is also not specified by neither POSIX nor C standard. Would it be possible to move the definition of __sanitizer_struct_mallinfo to a separate header file?

Something like this?

mcgrathr accepted this revision.Mar 29 2023, 9:27 AM

I agree that isolating things away from an #if-ridden grab-bag is the cleanest approach here.

compiler-rt/lib/sanitizer_common/sanitizer_mallinfo.h
20

It's usually a good idea to put blank lines around the # directive lines.

This revision is now accepted and ready to land.Mar 29 2023, 9:27 AM
This revision was landed with ongoing or failed builds.Mar 29 2023, 10:09 AM
This revision was automatically updated to reflect the committed changes.
leonardchan marked an inline comment as done.