Skip to content

Commit 8582bcb

Browse files
committed
Support MacOS for running MMTk Ruby binding
1 parent 1f4c40d commit 8582bcb

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

mmtk_support.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ rb_mmtk_system_physical_memory(void)
214214
rb_bug("failed to get system physical memory size");
215215
}
216216
return (size_t) physical_pages * (size_t) page_size;
217+
#elif __APPLE__
218+
#include <sys/sysctl.h>
219+
int mib[2];
220+
mib[0] = CTL_HW;
221+
mib[1] = HW_MEMSIZE; // total physical memory
222+
int64_t physical_memory;
223+
size_t length = sizeof(int64_t);
224+
if (sysctl(mib, 2, &physical_memory, &length, NULL, 0) == -1)
225+
{
226+
rb_bug("failed to get system physical memory size");
227+
}
228+
return (size_t) physical_memory;
217229
#else
218230
#error no implementation of rb_mmtk_system_physical_memory on this platform
219231
#endif

string.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ rb_str_make_embedded(VALUE str)
419419
TERM_FILL(RSTRING(str)->as.embed.ary + len, TERM_LEN(str));
420420
}
421421

422+
void
422423
rb_debug_rstring_null_ptr(const char *func)
423424
{
424425
fprintf(stderr, "%s is returning NULL!! "

tool/m4/mmtk_ruby.m4

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ dnl -*- Autoconf -*-
22
AC_DEFUN([MMTK_RUBY], [
33
44
[MMTK_RUBY_SO_NAME=libmmtk_ruby.so]
5+
[MMTK_RUBY_DYLIB_NAME=libmmtk_ruby.dylib]
56
67
AC_ARG_WITH(mmtk-ruby,
78
AS_HELP_STRING([--with-mmtk-ruby=DIR],
@@ -28,10 +29,10 @@ AS_IF([test -n "$with_mmtk_ruby"], [
2829
AC_MSG_RESULT([yes])
2930
3031
AS_IF([test -n "$with_mmtk_ruby_so"], [
31-
AC_MSG_NOTICE([User specified the path to $MMTK_RUBY_SO_NAME: $with_mmtk_ruby_so])
32+
AC_MSG_NOTICE([User specified the path to $MMTK_RUBY_SO_NAME or $MMTK_RUBY_DYLIB_NAME: $with_mmtk_ruby_so])
3233
mmtk_ruby_so_basename=$(basename $with_mmtk_ruby_so)
33-
AS_IF([test "x$mmtk_ruby_so_basename" != "x$MMTK_RUBY_SO_NAME"],[
34-
AC_MSG_ERROR([The base name must be $MMTK_RUBY_SO_NAME Found: $mmtk_ruby_so_basename])
34+
AS_IF([test "x$mmtk_ruby_so_basename" != "x$MMTK_RUBY_SO_NAME" -a "x$mmtk_ruby_so_basename" != "x$MMTK_RUBY_DYLIB_NAME"],[
35+
AC_MSG_ERROR([The base name must be $MMTK_RUBY_SO_NAME or $MMTK_RUBY_DYLIB_NAME. Found: $mmtk_ruby_so_basename])
3536
])
3637
mmtk_ruby_so_path="$with_mmtk_ruby_so"
3738
mmtk_ruby_build_suggestion="Please build it first"

0 commit comments

Comments
 (0)