]> git.saurik.com Git - apple/system_cmds.git/blobdiff - vm_stat.tproj/vm_stat.c
system_cmds-735.50.6.tar.gz
[apple/system_cmds.git] / vm_stat.tproj / vm_stat.c
index 4177284f03d1b6b3cf45a1ddcab65fb05befa0c6..7bedc319e50137e31e6573193264273347ca50b1 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1999-2009 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- * 
+ *
  * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
  * Reserved.  This file contains Original Code and/or Modifications of
  * Original Code as defined in and that are subject to the Apple Public
@@ -10,7 +10,7 @@
  * except in compliance with the License.  Please obtain a copy of the
  * License at http://www.apple.com/publicsource and read it before using
  * this file.
- * 
+ *
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
@@ -18,7 +18,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  * License for the specific language governing rights and limitations
  * under the License."
- * 
+ *
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
@@ -37,9 +37,9 @@
  *
  *  25-mar-99  A.Ramesh at Apple
  *             Ported to MacOS X
- *  
+ *
  *  22-Jan-09  R.Branche at Apple
- *             Changed some fields to 64-bit to alleviate overflows
+ *             Changed some fields to 64-bit to alleviate overflows
  ************************************************************************
  */
 
 #include <stdio.h>
 
 #include <mach/mach.h>
+#include <mach/vm_page_size.h>
 
 vm_statistics64_data_t vm_stat, last;
 char   *pgmname;
 mach_port_t myHost;
-vm_size_t pageSize = 4096;     /* set to 4k default */
 
 void usage(void);
 void snapshot(void);
@@ -68,7 +68,6 @@ void pstat(uint64_t n, int width);
 int
 main(int argc, char *argv[])
 {
-
        double delay = 0.0;
        int count = 0;
 
@@ -104,11 +103,6 @@ main(int argc, char *argv[])
 
        myHost = mach_host_self();
 
-       if(host_page_size(mach_host_self(), &pageSize) != KERN_SUCCESS) {
-               fprintf(stderr, "%s: failed to get pagesize; defaulting to 4K.\n", pgmname);
-               pageSize = 4096;
-       }       
-
        if (delay == 0.0) {
                snapshot();
        } else {
@@ -131,10 +125,8 @@ usage(void)
 void
 snapshot(void)
 {
-
        get_stats(&vm_stat);
-       printf("Mach Virtual Memory Statistics: (page size of %d bytes)\n",
-                               (int) (pageSize));
+       printf("Mach Virtual Memory Statistics: (page size of %llu bytes)\n", (mach_vm_size_t)vm_kernel_page_size);
 
        sspstat("Pages free:", (uint64_t) (vm_stat.free_count - vm_stat.speculative_count));
        sspstat("Pages active:", (uint64_t) (vm_stat.active_count));
@@ -171,8 +163,7 @@ banner(void)
 {
        get_stats(&vm_stat);
        printf("Mach Virtual Memory Statistics: ");
-       printf("(page size of %d bytes)\n",
-                               (int) (pageSize));
+       printf("(page size of %llu bytes)\n", (mach_vm_size_t)vm_kernel_page_size);
        printf("%8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %11s %9s %8s %8s %8s %8s %8s %8s %8s %8s\n",
               "free",
               "active",