]> git.sur5r.net Git - openldap/blobdiff - libraries/liblmdb/mdb_stat.c
Use proper printf format on Windows
[openldap] / libraries / liblmdb / mdb_stat.c
index aaad2d75a3d22715de338f673c58624119c0983c..aeb573a4951f136ac198bfa46cf7cde18a1f31a9 100644 (file)
 #include <unistd.h>
 #include "lmdb.h"
 
+#ifdef _WIN32
+#define        Z       "I"
+#else
+#define        Z       "z"
+#endif
+
 static void prstat(MDB_stat *ms)
 {
 #if 0
        printf("  Page size: %u\n", ms->ms_psize);
 #endif
        printf("  Tree depth: %u\n", ms->ms_depth);
-       printf("  Branch pages: %zu\n", ms->ms_branch_pages);
-       printf("  Leaf pages: %zu\n", ms->ms_leaf_pages);
-       printf("  Overflow pages: %zu\n", ms->ms_overflow_pages);
-       printf("  Entries: %zu\n", ms->ms_entries);
+       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);
 }
 
 static void usage(char *prog)
@@ -110,11 +116,11 @@ int main(int argc, char *argv[])
                rc = mdb_env_info(env, &mei);
                printf("Environment Info\n");
                printf("  Map address: %p\n", mei.me_mapaddr);
-               printf("  Map size: %zu\n", mei.me_mapsize);
+               printf("  Map size: %"Z"u\n", mei.me_mapsize);
                printf("  Page size: %u\n", mst.ms_psize);
-               printf("  Max pages: %zu\n", mei.me_mapsize / mst.ms_psize);
-               printf("  Number of pages used: %zu\n", mei.me_last_pgno+1);
-               printf("  Last transaction ID: %zu\n", mei.me_last_txnid);
+               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 readers: %u\n", mei.me_maxreaders);
                printf("  Number of readers used: %u\n", mei.me_numreaders);
        }
@@ -172,20 +178,20 @@ int main(int argc, char *argv[])
                                        pg += span;
                                        for (; i >= span && iptr[i-span] == pg; span++, pg++) ;
                                }
-                               printf("    Transaction %zu, %zd pages, maxspan %zd%s\n",
+                               printf("    Transaction %"Z"u, %"Z"d pages, maxspan %"Z"d%s\n",
                                        *(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 ? "     %9zu[%zd]\n" : "     %9zu\n",
+                                               printf(span>1 ? "     %9"Z"u[%"Z"d]\n" : "     %9"Z"u\n",
                                                        pg, span);
                                        }
                                }
                        }
                }
                mdb_cursor_close(cursor);
-               printf("  Free pages: %zu\n", pages);
+               printf("  Free pages: %"Z"u\n", pages);
        }
 
        rc = mdb_open(txn, subname, 0, &dbi);