Skip to content

Support MacOS for running MMTk Ruby binding #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions mmtk_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "vm_sync.h"
#include "stdatomic.h"

#ifdef __APPLE__
#include <sys/sysctl.h>
#endif

#ifdef __GNUC__
#define PREFETCH(addr, write_p) __builtin_prefetch(addr, write_p)
#define EXPECT(expr, val) __builtin_expect(expr, val)
Expand Down Expand Up @@ -218,6 +222,17 @@ rb_mmtk_system_physical_memory(void)
rb_bug("failed to get system physical memory size");
}
return (size_t) physical_pages * (size_t) page_size;
#elif defined(__APPLE__)
int mib[2];
mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE; // total physical memory
int64_t physical_memory;
size_t length = sizeof(int64_t);
if (sysctl(mib, 2, &physical_memory, &length, NULL, 0) == -1)
{
rb_bug("failed to get system physical memory size");
}
return (size_t) physical_memory;
#else
#error no implementation of rb_mmtk_system_physical_memory on this platform
#endif
Expand Down
4 changes: 2 additions & 2 deletions tool/m4/mmtk_ruby.m4
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl -*- Autoconf -*-
AC_DEFUN([MMTK_RUBY], [

[MMTK_RUBY_SO_NAME=libmmtk_ruby.so]
[MMTK_RUBY_SO_NAME=libmmtk_ruby.$SOEXT]

AC_ARG_WITH(mmtk-ruby,
AS_HELP_STRING([--with-mmtk-ruby=DIR],
Expand Down Expand Up @@ -31,7 +31,7 @@ AS_IF([test -n "$with_mmtk_ruby"], [
AC_MSG_NOTICE([User specified the path to $MMTK_RUBY_SO_NAME: $with_mmtk_ruby_so])
mmtk_ruby_so_basename=$(basename $with_mmtk_ruby_so)
AS_IF([test "x$mmtk_ruby_so_basename" != "x$MMTK_RUBY_SO_NAME"],[
AC_MSG_ERROR([The base name must be $MMTK_RUBY_SO_NAME Found: $mmtk_ruby_so_basename])
AC_MSG_ERROR([The base name must be $MMTK_RUBY_SO_NAME. Found: $mmtk_ruby_so_basename])
])
mmtk_ruby_so_path="$with_mmtk_ruby_so"
mmtk_ruby_build_suggestion="Please build it first"
Expand Down