Skip to content

Commit

Permalink
MINOR: [C++] io_util.cc: fix for macOS without MACH_TASK_BASIC_INFO (#…
Browse files Browse the repository at this point in the history
…35046)

Earlier macOS have no `MACH_TASK_BASIC_INFO`, but they have an equivalent `TASK_BASIC_INFO`. Use the latter as a fall back on Apple when the former is undefined. Fixes the build on earlier systems. Tested on macOS 10.6 (fixes the build), tested on the latest macOS (i.e. the patch does not break anything and works as supposed to).

We use a similar patch for `folly` and elsewhere: https://github.com/macports/macports-ports/blob/eaa29a4816054657e65d001562d7f77ba5157e40/devel/folly/files/patch-older-systems.diff#L232-L251

Lead-authored-by: Sergey Fedorov <[email protected]>
Co-authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
  • Loading branch information
barracuda156 and pitrou authored May 22, 2023
1 parent 6ceb12f commit 41ba4fe
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cpp/src/arrow/util/io_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2138,14 +2138,24 @@ int64_t GetCurrentRSS() {
return static_cast<int64_t>(info.WorkingSetSize);

#elif defined(__APPLE__)
// OSX ------------------------------------------------------
// OSX ------------------------------------------------------
#ifdef MACH_TASK_BASIC_INFO
struct mach_task_basic_info info;
mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info, &infoCount) !=
KERN_SUCCESS) {
ARROW_LOG(WARNING) << "Can't resolve RSS value";
return 0;
}
#else
struct task_basic_info info;
mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT;
if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &infoCount) !=
KERN_SUCCESS) {
ARROW_LOG(WARNING) << "Can't resolve RSS value";
return 0;
}
#endif
return static_cast<int64_t>(info.resident_size);

#elif defined(__linux__)
Expand Down

0 comments on commit 41ba4fe

Please sign in to comment.