[svn:parrot] r49619 - in trunk: . config/gen/platform/darwin

cotto at svn.parrot.org cotto at svn.parrot.org
Thu Oct 21 03:43:12 UTC 2010


Author: cotto
Date: Thu Oct 21 03:43:11 2010
New Revision: 49619
URL: https://trac.parrot.org/parrot/changeset/49619

Log:
[gc] first attempt to detect available memory on darwin

Added:
   trunk/config/gen/platform/darwin/sysmem.c   (contents, props changed)
Modified:
   trunk/MANIFEST

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Thu Oct 21 01:13:55 2010	(r49618)
+++ trunk/MANIFEST	Thu Oct 21 03:43:11 2010	(r49619)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Oct 20 10:26:51 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Thu Oct 21 03:36:17 2010 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -286,6 +286,7 @@
 config/gen/platform/cygwin/math.c                           []
 config/gen/platform/darwin/begin.c                          []
 config/gen/platform/darwin/hires_timer.c                    []
+config/gen/platform/darwin/sysmem.c                         []
 config/gen/platform/generic/dl.c                            []
 config/gen/platform/generic/dl.h                            []
 config/gen/platform/generic/env.c                           []

Added: trunk/config/gen/platform/darwin/sysmem.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/config/gen/platform/darwin/sysmem.c	Thu Oct 21 03:43:11 2010	(r49619)
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ * Copyright (C) 2010, Parrot Foundation.
+ */
+
+/*
+
+=head1 NAME
+
+config/gen/platform/darwin/sysmem.c
+
+=head1 DESCRIPTION
+
+Get system memory information.
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+#include <sys/sysctl.h>
+#include <stdio.h>
+
+/*
+
+=item C<size_t Parrot_sysmem_amount(PARROT_INTERP)>
+
+Get information about available physycal memory.
+
+=cut
+
+*/
+
+size_t
+Parrot_sysmem_amount(PARROT_INTERP)
+{
+    int           err = 0 ;
+    size_t        memsize = 0 ;
+    char         *err_msg;
+    unsigned long length = sizeof(memsize) ;
+
+    int selection[2] = { CTL_HW, HW_MEMSIZE} ;
+
+    err = sysctl(selection, 2, &memsize, &length, NULL, 0) ;
+
+    if (err) {
+        err_msg = strerror(err);
+        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
+                "sysctl failed: %s", err_msg);
+    }
+
+    return memsize;
+}
+
+/*
+
+=back
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */


More information about the parrot-commits mailing list