]> git.sur5r.net Git - openldap/blobdiff - libraries/liblmdb/mdb_stat.c
MDB_VL32: Switch to mdb_size_t formats PRIu64 & co
[openldap] / libraries / liblmdb / mdb_stat.c
index 6f4b3ee4f361817615b3fc8761d6fc311dcb2258..0343a6537d4d71a7003ab620f7447bf766fee959 100644 (file)
@@ -1,6 +1,6 @@
 /* mdb_stat.c - memory-mapped database status tool */
 /*
- * Copyright 2011-2015 Howard Chu, Symas Corp.
+ * Copyright 2011-2016 Howard Chu, Symas Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <unistd.h>
 #include "lmdb.h"
 
-#ifdef _WIN32
-#define        Z       "I"
-#else
-#define        Z       "z"
-#endif
+#define Z      MDB_FMT_Z
+#define Yu     MDB_PRIy(u)
 
 static void prstat(MDB_stat *ms)
 {
@@ -29,10 +26,10 @@ static void prstat(MDB_stat *ms)
        printf("  Page size: %u\n", ms->ms_psize);
 #endif
        printf("  Tree depth: %u\n", ms->ms_depth);
-       printf("  Branch pages: %"Z"u\n", ms->ms_branch_pages);
-       printf("  Leaf pages: %"Z"u\n", ms->ms_leaf_pages);
-       printf("  Overflow pages: %"Z"u\n", ms->ms_overflow_pages);
-       printf("  Entries: %"Z"u\n", ms->ms_entries);
+       printf("  Branch pages: %"Yu"\n",   ms->ms_branch_pages);
+       printf("  Leaf pages: %"Yu"\n",     ms->ms_leaf_pages);
+       printf("  Overflow pages: %"Yu"\n", ms->ms_overflow_pages);
+       printf("  Entries: %"Yu"\n",        ms->ms_entries);
 }
 
 static void usage(char *prog)
@@ -125,11 +122,11 @@ int main(int argc, char *argv[])
                (void)mdb_env_info(env, &mei);
                printf("Environment Info\n");
                printf("  Map address: %p\n", mei.me_mapaddr);
-               printf("  Map size: %"Z"u\n", mei.me_mapsize);
+               printf("  Map size: %"Yu"\n", mei.me_mapsize);
                printf("  Page size: %u\n", mst.ms_psize);
-               printf("  Max pages: %"Z"u\n", mei.me_mapsize / mst.ms_psize);
-               printf("  Number of pages used: %"Z"u\n", mei.me_last_pgno+1);
-               printf("  Last transaction ID: %"Z"u\n", mei.me_last_txnid);
+               printf("  Max pages: %"Yu"\n", mei.me_mapsize / mst.ms_psize);
+               printf("  Number of pages used: %"Yu"\n", mei.me_last_pgno+1);
+               printf("  Last transaction ID: %"Yu"\n", mei.me_last_txnid);
                printf("  Max readers: %u\n", mei.me_maxreaders);
                printf("  Number of readers used: %u\n", mei.me_numreaders);
        }
@@ -156,7 +153,7 @@ int main(int argc, char *argv[])
        if (freinfo) {
                MDB_cursor *cursor;
                MDB_val key, data;
-               size_t pages = 0, *iptr;
+               mdb_size_t pages = 0, *iptr;
 
                printf("Freelist Status\n");
                dbi = 0;
@@ -176,7 +173,7 @@ int main(int argc, char *argv[])
                        pages += *iptr;
                        if (freinfo > 1) {
                                char *bad = "";
-                               size_t pg, prev;
+                               mdb_size_t pg, prev;
                                ssize_t i, j, span = 0;
                                j = *iptr++;
                                for (i = j, prev = 1; --i >= 0; ) {
@@ -187,20 +184,20 @@ int main(int argc, char *argv[])
                                        pg += span;
                                        for (; i >= span && iptr[i-span] == pg; span++, pg++) ;
                                }
-                               printf("    Transaction %"Z"u, %"Z"d pages, maxspan %"Z"d%s\n",
-                                       *(size_t *)key.mv_data, j, span, bad);
+                               printf("    Transaction %"Yu", %"Z"d pages, maxspan %"Z"d%s\n",
+                                       *(mdb_size_t *)key.mv_data, j, span, bad);
                                if (freinfo > 2) {
                                        for (--j; j >= 0; ) {
                                                pg = iptr[j];
                                                for (span=1; --j >= 0 && iptr[j] == pg+span; span++) ;
-                                               printf(span>1 ? "     %9"Z"u[%"Z"d]\n" : "     %9"Z"u\n",
+                                               printf(span>1 ? "     %9"Yu"[%"Z"d]\n" : "     %9"Yu"\n",
                                                        pg, span);
                                        }
                                }
                        }
                }
                mdb_cursor_close(cursor);
-               printf("  Free pages: %"Z"u\n", pages);
+               printf("  Free pages: %"Yu"\n", pages);
        }
 
        rc = mdb_open(txn, subname, 0, &dbi);