Blame SOURCES/0028-Ticket-48864-Add-cgroup-memory-limit-detection-to-38.patch

6f51e1
From 57b6e5afb6265363ede667ad450e267f8a803b9e Mon Sep 17 00:00:00 2001
6f51e1
From: Mark Reynolds <mreynolds@redhat.com>
6f51e1
Date: Wed, 19 Apr 2017 13:37:10 -0400
6f51e1
Subject: [PATCH] Ticket 48864 - Add cgroup memory limit detection to 389-ds
6f51e1
6f51e1
Bug Description:  Previously our memory limits only check hardware
6f51e1
    limits and shell resource limits. However, we may be in a container
6f51e1
    like docker or lxc, and unable to detect these limits. This can lead
6f51e1
    to crash conditions or worse, especially with autosizing
6f51e1
    on import we may have conditions where the server may not
6f51e1
    even be able to install.
6f51e1
6f51e1
Fix Description:  Add support for cgroup memory limit detection
6f51e1
    so that we can properly determine our resource availability regardless
6f51e1
    of lxc, docker, systemd or others.
6f51e1
6f51e1
https://pagure.io/389-ds-base/issue/48864
6f51e1
6f51e1
Author: wibrown
6f51e1
6f51e1
Review by: mreynolds (Thanks!)
6f51e1
---
6f51e1
 Makefile.am                                        |   7 +-
6f51e1
 ldap/servers/plugins/acl/acl.c                     |  18 +-
6f51e1
 ldap/servers/plugins/acl/acl.h                     |  16 -
6f51e1
 ldap/servers/plugins/acl/aclanom.c                 |   8 +-
6f51e1
 ldap/servers/plugins/dna/dna.c                     |  50 ++-
6f51e1
 ldap/servers/plugins/posix-winsync/posix-winsync.c |   4 +-
6f51e1
 ldap/servers/plugins/replication/repl.h            |  17 +-
6f51e1
 .../plugins/replication/repl5_inc_protocol.c       |   2 +-
6f51e1
 ldap/servers/plugins/replication/repl5_init.c      |   2 +-
6f51e1
 ldap/servers/plugins/replication/repl5_plugins.c   |   2 +-
6f51e1
 ldap/servers/plugins/replication/repl5_replica.c   |   8 +-
6f51e1
 ldap/servers/plugins/replication/repl5_total.c     |   4 +-
6f51e1
 ldap/servers/plugins/replication/repl_connext.c    |  20 +-
6f51e1
 ldap/servers/plugins/replication/repl_extop.c      |  26 +-
6f51e1
 ldap/servers/plugins/sync/sync_persist.c           |   6 +-
6f51e1
 ldap/servers/plugins/syntaxes/validate_task.c      |   6 +-
6f51e1
 ldap/servers/plugins/usn/usn.c                     |   8 +-
6f51e1
 ldap/servers/slapd/abandon.c                       |   8 +-
6f51e1
 ldap/servers/slapd/add.c                           |   4 +-
6f51e1
 ldap/servers/slapd/auth.c                          |  18 +-
6f51e1
 ldap/servers/slapd/back-ldbm/back-ldbm.h           |  23 +-
6f51e1
 ldap/servers/slapd/back-ldbm/cache.c               |  34 +-
6f51e1
 ldap/servers/slapd/back-ldbm/dblayer.c             |  72 ++--
6f51e1
 ldap/servers/slapd/back-ldbm/dblayer.h             |   8 -
6f51e1
 ldap/servers/slapd/back-ldbm/import-threads.c      |   2 +-
6f51e1
 ldap/servers/slapd/back-ldbm/import.c              |  12 +-
6f51e1
 ldap/servers/slapd/back-ldbm/ldbm_config.c         |  32 +-
6f51e1
 ldap/servers/slapd/back-ldbm/ldbm_delete.c         |   4 +-
6f51e1
 .../servers/slapd/back-ldbm/ldbm_instance_config.c |  20 +-
6f51e1
 ldap/servers/slapd/back-ldbm/ldbm_modrdn.c         |   4 +-
6f51e1
 ldap/servers/slapd/back-ldbm/ldbm_search.c         |   4 +-
6f51e1
 ldap/servers/slapd/back-ldbm/misc.c                |   2 +-
6f51e1
 ldap/servers/slapd/back-ldbm/monitor.c             |  10 +-
6f51e1
 ldap/servers/slapd/back-ldbm/perfctrs.h            |   2 +-
6f51e1
 ldap/servers/slapd/back-ldbm/start.c               | 113 +++----
6f51e1
 ldap/servers/slapd/bind.c                          |   8 +-
6f51e1
 ldap/servers/slapd/compare.c                       |   2 +-
6f51e1
 ldap/servers/slapd/connection.c                    |  72 ++--
6f51e1
 ldap/servers/slapd/conntable.c                     |   8 +-
6f51e1
 ldap/servers/slapd/control.c                       |   2 +-
6f51e1
 ldap/servers/slapd/daemon.c                        |  48 +--
6f51e1
 ldap/servers/slapd/delete.c                        |   2 +-
6f51e1
 ldap/servers/slapd/entry.c                         |   2 +-
6f51e1
 ldap/servers/slapd/extendop.c                      |   4 +-
6f51e1
 ldap/servers/slapd/log.c                           |  10 +-
6f51e1
 ldap/servers/slapd/modify.c                        |  12 +-
6f51e1
 ldap/servers/slapd/modrdn.c                        |   6 +-
6f51e1
 ldap/servers/slapd/monitor.c                       |   8 +-
6f51e1
 ldap/servers/slapd/operation.c                     |   6 +-
6f51e1
 ldap/servers/slapd/opshared.c                      |   4 +-
6f51e1
 ldap/servers/slapd/pagedresults.c                  |   2 +-
6f51e1
 ldap/servers/slapd/psearch.c                       |  10 +-
6f51e1
 ldap/servers/slapd/result.c                        |  12 +-
6f51e1
 ldap/servers/slapd/sasl_io.c                       |  52 +--
6f51e1
 ldap/servers/slapd/saslbind.c                      |   2 +-
6f51e1
 ldap/servers/slapd/search.c                        |   2 +-
6f51e1
 ldap/servers/slapd/slap.h                          |   9 +-
6f51e1
 ldap/servers/slapd/slapi-plugin.h                  |  14 +-
6f51e1
 ldap/servers/slapd/slapi-private.h                 |  38 ++-
6f51e1
 ldap/servers/slapd/slapi_pal.c                     | 311 +++++++++++++++++
6f51e1
 ldap/servers/slapd/slapi_pal.h                     |  62 ++++
6f51e1
 ldap/servers/slapd/snmp_collator.c                 |   2 +-
6f51e1
 ldap/servers/slapd/unbind.c                        |   6 +-
6f51e1
 ldap/servers/slapd/util.c                          | 376 +--------------------
6f51e1
 test/libslapd/spal/meminfo.c                       |  54 +++
6f51e1
 test/libslapd/test.c                               |   2 +
6f51e1
 test/test_slapd.h                                  |   5 +
6f51e1
 67 files changed, 870 insertions(+), 859 deletions(-)
6f51e1
 create mode 100644 ldap/servers/slapd/slapi_pal.c
6f51e1
 create mode 100644 ldap/servers/slapd/slapi_pal.h
6f51e1
 create mode 100644 test/libslapd/spal/meminfo.c
6f51e1
6f51e1
diff --git a/Makefile.am b/Makefile.am
6f51e1
index 485a460..429a345 100644
6f51e1
--- a/Makefile.am
6f51e1
+++ b/Makefile.am
6f51e1
@@ -481,6 +481,7 @@ dist_noinst_HEADERS = \
6f51e1
 	ldap/servers/slapd/pw_verify.h \
6f51e1
 	ldap/servers/slapd/secerrstrs.h \
6f51e1
 	ldap/servers/slapd/slap.h \
6f51e1
+	ldap/servers/slapd/slapi_pal.h \
6f51e1
 	ldap/servers/slapd/slapi-plugin-compat4.h \
6f51e1
 	ldap/servers/slapd/slapi-plugin.h \
6f51e1
 	ldap/servers/slapd/slapi-private.h \
6f51e1
@@ -850,6 +851,7 @@ pkgconfig_DATA = src/pkgconfig/dirsrv.pc \
6f51e1
 # header files
6f51e1
 #------------------------
6f51e1
 serverinc_HEADERS = ldap/servers/plugins/replication/repl-session-plugin.h \
6f51e1
+	ldap/servers/slapd/slapi_pal.h \
6f51e1
 	ldap/servers/slapd/slapi-plugin.h \
6f51e1
 	ldap/servers/plugins/replication/winsync-plugin.h \
6f51e1
 	src/nunc-stans/include/nunc-stans.h \
6f51e1
@@ -1219,6 +1221,7 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \
6f51e1
 	ldap/servers/slapd/value.c \
6f51e1
 	ldap/servers/slapd/valueset.c \
6f51e1
 	ldap/servers/slapd/vattr.c \
6f51e1
+	ldap/servers/slapd/slapi_pal.c \
6f51e1
 	$(libavl_a_SOURCES)
6f51e1
 
6f51e1
 libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) @db_inc@ $(SVRCORE_INCLUDES) @kerberos_inc@ @pcre_inc@
6f51e1
@@ -2004,7 +2007,9 @@ test_slapd_SOURCES = test/main.c \
6f51e1
 	test/libslapd/counters/atomic.c \
6f51e1
 	test/libslapd/pblock/analytics.c \
6f51e1
 	test/libslapd/pblock/v3_compat.c \
6f51e1
-	test/libslapd/operation/v3_compat.c
6f51e1
+	test/libslapd/operation/v3_compat.c \
6f51e1
+	test/libslapd/spal/meminfo.c
6f51e1
+
6f51e1
 test_slapd_LDADD = libslapd.la
6f51e1
 test_slapd_LDFLAGS = $(AM_CPPFLAGS) $(CMOCKA_LINKS)
6f51e1
 ### WARNING: Slap.h needs cert.h, which requires the -I/lib/ldaputil!!!
6f51e1
diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
6f51e1
index 48b8efc..561dd91 100644
6f51e1
--- a/ldap/servers/plugins/acl/acl.c
6f51e1
+++ b/ldap/servers/plugins/acl/acl.c
6f51e1
@@ -276,7 +276,7 @@ acl_access_allowed(
6f51e1
 
6f51e1
 		 if (  !privateBackend && (be_readonly ||  slapi_config_get_readonly () )){
6f51e1
 			slapi_log_err(loglevel, plugin_name,
6f51e1
-				"acl_access_allowed - conn=%" NSPRIu64 " op=%d (main): Deny %s on entry(%s)"
6f51e1
+				"acl_access_allowed - conn=%" PRIu64 " op=%d (main): Deny %s on entry(%s)"
6f51e1
 				": readonly backend\n", 
6f51e1
 				o_connid, o_opid,
6f51e1
 				acl_access2str(access),
6f51e1
@@ -289,7 +289,7 @@ acl_access_allowed(
6f51e1
 	TNF_PROBE_0_DEBUG(acl_skipaccess_start,"ACL","");
6f51e1
 	if (  acl_skip_access_check ( pb, e, access )) {
6f51e1
 		slapi_log_err(loglevel, plugin_name,
6f51e1
-				"acl_access_allowed - conn=%" NSPRIu64 " op=%d (main): Allow %s on entry(%s)"
6f51e1
+				"acl_access_allowed - conn=%" PRIu64 " op=%d (main): Allow %s on entry(%s)"
6f51e1
 				": root user\n", 
6f51e1
 				o_connid, o_opid,
6f51e1
 				acl_access2str(access),
6f51e1
@@ -448,7 +448,7 @@ acl_access_allowed(
6f51e1
 		TNF_PROBE_0_DEBUG(acl_entry_first_touch_start,"ACL","");
6f51e1
 
6f51e1
 		slapi_log_err(loglevel, plugin_name,
6f51e1
-			"acl_access_allowed - #### conn=%" NSPRIu64 " op=%d binddn=\"%s\"\n",
6f51e1
+			"acl_access_allowed - #### conn=%" PRIu64 " op=%d binddn=\"%s\"\n",
6f51e1
 			o_connid, o_opid, clientDn);
6f51e1
 		aclpb->aclpb_stat_total_entries++;
6f51e1
 
6f51e1
@@ -776,7 +776,7 @@ print_access_control_summary( char *source, int ret_val, char *clientDn,
6f51e1
                                 null_user);
6f51e1
                         if (strcasecmp(right, access_str_moddn) == 0) {
6f51e1
                                  slapi_log_err(loglevel, plugin_name, "print_access_control_summary - "                                            
6f51e1
-                                        "conn=%" NSPRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) [from %s] to proxy (%s)"
6f51e1
+                                        "conn=%" PRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) [from %s] to proxy (%s)"
6f51e1
                                          ": %s\n",
6f51e1
                                         o_connid, o_opid,
6f51e1
                                         source,
6f51e1
@@ -790,7 +790,7 @@ print_access_control_summary( char *source, int ret_val, char *clientDn,
6f51e1
 
6f51e1
                         } else {
6f51e1
                                 slapi_log_err(loglevel, plugin_name, 
6f51e1
-                                        "print_access_control_summary - conn=%" NSPRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) to proxy (%s)"
6f51e1
+                                        "print_access_control_summary - conn=%" PRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) to proxy (%s)"
6f51e1
                                          ": %s\n",
6f51e1
                                         o_connid, o_opid,
6f51e1
                                         source,
6f51e1
@@ -805,7 +805,7 @@ print_access_control_summary( char *source, int ret_val, char *clientDn,
6f51e1
                         proxy_user = null_user;
6f51e1
                         if (strcasecmp(right, access_str_moddn) == 0) {
6f51e1
                                 slapi_log_err(loglevel, plugin_name, 
6f51e1
-                                        "print_access_control_summary - conn=%" NSPRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) [from %s] to proxy (%s)"
6f51e1
+                                        "print_access_control_summary - conn=%" PRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) [from %s] to proxy (%s)"
6f51e1
                                         ": %s\n",
6f51e1
                                         o_connid, o_opid,
6f51e1
                                         source,
6f51e1
@@ -819,7 +819,7 @@ print_access_control_summary( char *source, int ret_val, char *clientDn,
6f51e1
                                 
6f51e1
                         } else {
6f51e1
                                 slapi_log_err(loglevel, plugin_name, 
6f51e1
-                                        "print_access_control_summary - conn=%" NSPRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) to proxy (%s)"
6f51e1
+                                        "print_access_control_summary - conn=%" PRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) to proxy (%s)"
6f51e1
                                         ": %s\n",
6f51e1
                                         o_connid, o_opid,
6f51e1
                                         source,
6f51e1
@@ -834,7 +834,7 @@ print_access_control_summary( char *source, int ret_val, char *clientDn,
6f51e1
 	} else {
6f51e1
                 if (strcasecmp(right, access_str_moddn) == 0) {
6f51e1
                         slapi_log_err(loglevel, plugin_name, 
6f51e1
-                                "print_access_control_summary - conn=%" NSPRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) [from %s] to %s"
6f51e1
+                                "print_access_control_summary - conn=%" PRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) [from %s] to %s"
6f51e1
                                 ": %s\n",
6f51e1
                                 o_connid, o_opid,
6f51e1
                                 source,
6f51e1
@@ -848,7 +848,7 @@ print_access_control_summary( char *source, int ret_val, char *clientDn,
6f51e1
                         
6f51e1
                 } else {
6f51e1
                         slapi_log_err(loglevel, plugin_name, 
6f51e1
-                                "print_access_control_summary - conn=%" NSPRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) to %s"
6f51e1
+                                "print_access_control_summary - conn=%" PRIu64 " op=%d (%s): %s %s on entry(%s).attr(%s) to %s"
6f51e1
                                 ": %s\n",
6f51e1
                                 o_connid, o_opid,
6f51e1
                                 source,
6f51e1
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
6f51e1
index 91f5071..8b3486c 100644
6f51e1
--- a/ldap/servers/plugins/acl/acl.h
6f51e1
+++ b/ldap/servers/plugins/acl/acl.h
6f51e1
@@ -20,22 +20,6 @@
6f51e1
 #ifndef _ACL_H_
6f51e1
 #define _ACL_H_
6f51e1
 
6f51e1
-/* Required to get portable printf/scanf format macros */
6f51e1
-#ifdef HAVE_INTTYPES_H
6f51e1
-#include <inttypes.h>
6f51e1
-
6f51e1
-/* NSPR uses the print macros a bit differently than ANSI C.  We
6f51e1
- * need to use ll for a 64-bit integer, even when a long is 64-bit.
6f51e1
- */
6f51e1
-#undef PRIu64
6f51e1
-#define PRIu64  "llu"
6f51e1
-#undef PRI64
6f51e1
-#define PRI64   "ll"
6f51e1
-
6f51e1
-#else
6f51e1
-#error Need to define portable format macros such as PRIu64
6f51e1
-#endif /* HAVE_INTTYPES_H */
6f51e1
-
6f51e1
 #include 	<stdio.h>
6f51e1
 #include 	<string.h>
6f51e1
 #include 	<sys types.h="">
6f51e1
diff --git a/ldap/servers/plugins/acl/aclanom.c b/ldap/servers/plugins/acl/aclanom.c
6f51e1
index 5462d87..96d0d9f 100644
6f51e1
--- a/ldap/servers/plugins/acl/aclanom.c
6f51e1
+++ b/ldap/servers/plugins/acl/aclanom.c
6f51e1
@@ -523,7 +523,7 @@ aclanom_match_profile (Slapi_PBlock *pb, struct acl_pblock *aclpb, Slapi_Entry *
6f51e1
 			aci_ndn = slapi_sdn_get_ndn (acl_anom_profile->anom_targetinfo[i].anom_target);
6f51e1
 			if (access & SLAPI_ACL_MODDN) {
6f51e1
 				slapi_log_err(loglevel, plugin_name, 
6f51e1
-					"aclanom_match_profile - conn=%" NSPRIu64 " op=%d: Allow access on entry(%s).attr(%s) (from %s) to anonymous: acidn=\"%s\"\n",
6f51e1
+					"aclanom_match_profile - conn=%" PRIu64 " op=%d: Allow access on entry(%s).attr(%s) (from %s) to anonymous: acidn=\"%s\"\n",
6f51e1
 					o_connid, o_opid,
6f51e1
 					ndn,
6f51e1
 					attr ? attr:"NULL",
6f51e1
@@ -532,7 +532,7 @@ aclanom_match_profile (Slapi_PBlock *pb, struct acl_pblock *aclpb, Slapi_Entry *
6f51e1
 				
6f51e1
 			} else {
6f51e1
 				slapi_log_err(loglevel, plugin_name, 
6f51e1
-					"aclanom_match_profile - conn=%" NSPRIu64 " op=%d: Allow access on entry(%s).attr(%s) to anonymous: acidn=\"%s\"\n",
6f51e1
+					"aclanom_match_profile - conn=%" PRIu64 " op=%d: Allow access on entry(%s).attr(%s) to anonymous: acidn=\"%s\"\n",
6f51e1
 					o_connid, o_opid,
6f51e1
 					ndn,
6f51e1
 					attr ? attr:"NULL",
6f51e1
@@ -541,13 +541,13 @@ aclanom_match_profile (Slapi_PBlock *pb, struct acl_pblock *aclpb, Slapi_Entry *
6f51e1
 		} else {
6f51e1
 			if (access & SLAPI_ACL_MODDN) {
6f51e1
 				slapi_log_err(loglevel, plugin_name,
6f51e1
-					"aclanom_match_profile - conn=%" NSPRIu64 " op=%d: Deny access on entry(%s).attr(%s) (from %s) to anonymous\n",
6f51e1
+					"aclanom_match_profile - conn=%" PRIu64 " op=%d: Deny access on entry(%s).attr(%s) (from %s) to anonymous\n",
6f51e1
 					o_connid, o_opid,
6f51e1
 					ndn, attr ? attr:"NULL" ,
6f51e1
 					aclpb->aclpb_moddn_source_sdn ? slapi_sdn_get_dn(aclpb->aclpb_moddn_source_sdn) : "NULL");
6f51e1
 			} else {
6f51e1
 				slapi_log_err(loglevel, plugin_name,
6f51e1
-					"aclanom_match_profile - conn=%" NSPRIu64 " op=%d: Deny access on entry(%s).attr(%s) to anonymous\n",
6f51e1
+					"aclanom_match_profile - conn=%" PRIu64 " op=%d: Deny access on entry(%s).attr(%s) to anonymous\n",
6f51e1
 					o_connid, o_opid,
6f51e1
 					ndn, attr ? attr:"NULL" );
6f51e1
 			}
6f51e1
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
6f51e1
index 34011b9..a085941 100644
6f51e1
--- a/ldap/servers/plugins/dna/dna.c
6f51e1
+++ b/ldap/servers/plugins/dna/dna.c
6f51e1
@@ -23,14 +23,6 @@
6f51e1
 #include "slapi-private.h"
6f51e1
 #include "prclist.h"
6f51e1
 
6f51e1
-/* Required to get portable printf/scanf format macros */
6f51e1
-#ifdef HAVE_INTTYPES_H
6f51e1
-#include <inttypes.h>
6f51e1
-
6f51e1
-#else
6f51e1
-#error Need to define portable format macros such as PRIu64
6f51e1
-#endif /* HAVE_INTTYPES_H */
6f51e1
-
6f51e1
 #include <sys stat.h="">
6f51e1
 
6f51e1
 #define DNA_PLUGIN_SUBSYSTEM "dna-plugin"
6f51e1
@@ -997,7 +989,7 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry * e, int apply)
6f51e1
     }
6f51e1
 
6f51e1
     slapi_log_err(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
6f51e1
-                    "dna_parse_config_entry - %s [%" NSPRIu64 "]\n", DNA_NEXTVAL,
6f51e1
+                    "dna_parse_config_entry - %s [%" PRIu64 "]\n", DNA_NEXTVAL,
6f51e1
                     entry->nextval);
6f51e1
 
6f51e1
     value = slapi_entry_attr_get_charptr(e, DNA_PREFIX);
6f51e1
@@ -1026,7 +1018,7 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry * e, int apply)
6f51e1
     }
6f51e1
 
6f51e1
     slapi_log_err(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
6f51e1
-                    "dna_parse_config_entry - %s [%" NSPRIu64 "]\n", DNA_INTERVAL, entry->interval);
6f51e1
+                    "dna_parse_config_entry - %s [%" PRIu64 "]\n", DNA_INTERVAL, entry->interval);
6f51e1
 #endif
6f51e1
 
6f51e1
     value = slapi_entry_attr_get_charptr(e, DNA_GENERATE);
6f51e1
@@ -1126,7 +1118,7 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry * e, int apply)
6f51e1
     }
6f51e1
 
6f51e1
     slapi_log_err(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
6f51e1
-                    "dna_parse_config_entry - %s [%" NSPRIu64 "]\n", DNA_MAXVAL,
6f51e1
+                    "dna_parse_config_entry - %s [%" PRIu64 "]\n", DNA_MAXVAL,
6f51e1
                     entry->maxval);
6f51e1
 
6f51e1
     /* get the global bind dn and password(if any) */
6f51e1
@@ -1256,7 +1248,7 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry * e, int apply)
6f51e1
     }
6f51e1
 
6f51e1
     slapi_log_err(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
6f51e1
-                    "dna_parse_config_entry - %s [%" NSPRIu64 "]\n", DNA_THRESHOLD,
6f51e1
+                    "dna_parse_config_entry - %s [%" PRIu64 "]\n", DNA_THRESHOLD,
6f51e1
                     entry->threshold);
6f51e1
 
6f51e1
     value = slapi_entry_attr_get_charptr(e, DNA_RANGE_REQUEST_TIMEOUT);
6f51e1
@@ -1268,7 +1260,7 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry * e, int apply)
6f51e1
     }
6f51e1
 
6f51e1
     slapi_log_err(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
6f51e1
-                    "dna_parse_config_entry - %s [%" NSPRIu64 "]\n", DNA_RANGE_REQUEST_TIMEOUT,
6f51e1
+                    "dna_parse_config_entry - %s [%" PRIu64 "]\n", DNA_RANGE_REQUEST_TIMEOUT,
6f51e1
                     entry->timeout);
6f51e1
 
6f51e1
     value = slapi_entry_attr_get_charptr(e, DNA_NEXT_RANGE);
6f51e1
@@ -2307,7 +2299,7 @@ dna_first_free_value(struct configEntry *config_entry,
6f51e1
             return LDAP_OPERATIONS_ERROR;
6f51e1
         }
6f51e1
 
6f51e1
-        filter = slapi_ch_smprintf("(&%s(&(%s>=%" NSPRIu64 ")(%s<=%" NSPRIu64 ")))",
6f51e1
+        filter = slapi_ch_smprintf("(&%s(&(%s>=%" PRIu64 ")(%s<=%" PRIu64 ")))",
6f51e1
                                    config_entry->filter,
6f51e1
                                    config_entry->types[0], tmpval,
6f51e1
                                    config_entry->types[0], config_entry->maxval);
6f51e1
@@ -2497,7 +2489,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
6f51e1
     if ((config_entry->maxval == -1) ||
6f51e1
         (nextval <= (config_entry->maxval + config_entry->interval))) {
6f51e1
         /* try to set the new next value in the config entry */
6f51e1
-        snprintf(next_value, sizeof(next_value),"%" NSPRIu64, nextval);
6f51e1
+        snprintf(next_value, sizeof(next_value),"%" PRIu64, nextval);
6f51e1
 
6f51e1
         /* set up our replace modify operation */
6f51e1
         replace_val[0] = next_value;
6f51e1
@@ -2524,7 +2516,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
6f51e1
 
6f51e1
     if (LDAP_SUCCESS == ret) {
6f51e1
         slapi_ch_free_string(next_value_ret);
6f51e1
-        *next_value_ret = slapi_ch_smprintf("%" NSPRIu64, setval);
6f51e1
+        *next_value_ret = slapi_ch_smprintf("%" PRIu64, setval);
6f51e1
         if (NULL == *next_value_ret) {
6f51e1
             ret = LDAP_OPERATIONS_ERROR;
6f51e1
             goto done;
6f51e1
@@ -2609,7 +2601,7 @@ dna_update_shared_config(struct configEntry *config_entry)
6f51e1
 
6f51e1
         /* We store the number of remaining assigned values
6f51e1
          * in the shared config entry. */
6f51e1
-        snprintf(remaining_vals, sizeof(remaining_vals),"%" NSPRIu64,
6f51e1
+        snprintf(remaining_vals, sizeof(remaining_vals),"%" PRIu64,
6f51e1
                 config_entry->remaining);
6f51e1
 
6f51e1
         /* set up our replace modify operation */
6f51e1
@@ -2709,7 +2701,7 @@ dna_update_next_range(struct configEntry *config_entry,
6f51e1
     int ret = 0;
6f51e1
 
6f51e1
     /* Try to set the new next range in the config entry. */
6f51e1
-    snprintf(nextrange_value, sizeof(nextrange_value), "%" NSPRIu64 "-%" NSPRIu64,
6f51e1
+    snprintf(nextrange_value, sizeof(nextrange_value), "%" PRIu64 "-%" PRIu64,
6f51e1
     		lower, upper);
6f51e1
 
6f51e1
     /* set up our replace modify operation */
6f51e1
@@ -2778,8 +2770,8 @@ dna_activate_next_range(struct configEntry *config_entry)
6f51e1
     int ret = 0;
6f51e1
 
6f51e1
     /* Setup the modify operation for the config entry */
6f51e1
-    snprintf(maxval_val, sizeof(maxval_val),"%" NSPRIu64, config_entry->next_range_upper);
6f51e1
-    snprintf(nextval_val, sizeof(nextval_val),"%" NSPRIu64, config_entry->next_range_lower);
6f51e1
+    snprintf(maxval_val, sizeof(maxval_val),"%" PRIu64, config_entry->next_range_upper);
6f51e1
+    snprintf(nextval_val, sizeof(nextval_val),"%" PRIu64, config_entry->next_range_lower);
6f51e1
 
6f51e1
     maxval_vals[0] = maxval_val;
6f51e1
     maxval_vals[1] = 0;
6f51e1
@@ -3319,7 +3311,7 @@ dna_create_valcheck_filter(struct configEntry *config_entry, PRUint64 value, cha
6f51e1
      * - the string length of the filter in the config
6f51e1
      * - the string length sum of all configured types
6f51e1
      * - 23 bytes for each type (20 for the max string
6f51e1
-     *   representation of a NSPRIu64, 3 for "(=)"
6f51e1
+     *   representation of a PRIu64, 3 for "(=)"
6f51e1
      * - 3 bytes for the beginning and end of the filter - "(&" and ")"
6f51e1
      * - 3 bytes to OR together multiple types (if present) - "(|" and ")"
6f51e1
      * - the string length of the prefix (if one is configured) for each type
6f51e1
@@ -3556,8 +3548,8 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
6f51e1
                     (config_entry->remaining <= config_entry->threshold)) {
6f51e1
                     slapi_log_err(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
6f51e1
                                     "_dna_pre_op_add - Passed threshold of %" 
6f51e1
-                                    NSPRIu64 " remaining values "
6f51e1
-                                    "for range %s. (%" NSPRIu64 " values remain)\n",
6f51e1
+                                    PRIu64 " remaining values "
6f51e1
+                                    "for range %s. (%" PRIu64 " values remain)\n",
6f51e1
                                     config_entry->threshold, config_entry->dn,
6f51e1
                                     config_entry->remaining);
6f51e1
                     dna_fix_maxval(config_entry, 0);
6f51e1
@@ -3828,8 +3820,8 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods, char **e
6f51e1
                     (config_entry->remaining <= config_entry->threshold)) {
6f51e1
                     slapi_log_err(SLAPI_LOG_ERR, DNA_PLUGIN_SUBSYSTEM,
6f51e1
                                     "_dna_pre_op_modify - Passed threshold of %" 
6f51e1
-                                    NSPRIu64 " remaining values "
6f51e1
-                                    "for range %s. (%" NSPRIu64 " values remain)\n",
6f51e1
+                                    PRIu64 " remaining values "
6f51e1
+                                    "for range %s. (%" PRIu64 " values remain)\n",
6f51e1
                                     config_entry->threshold, config_entry->dn,
6f51e1
                                     config_entry->remaining);
6f51e1
                     dna_fix_maxval(config_entry, 0);
6f51e1
@@ -4411,8 +4403,8 @@ static int dna_extend_exop(Slapi_PBlock *pb)
6f51e1
         char highstr[16];
6f51e1
 
6f51e1
         /* Create the exop response */
6f51e1
-        snprintf(lowstr, sizeof(lowstr), "%" NSPRIu64, lower);
6f51e1
-        snprintf(highstr, sizeof(highstr), "%" NSPRIu64, upper);
6f51e1
+        snprintf(lowstr, sizeof(lowstr), "%" PRIu64, lower);
6f51e1
+        snprintf(highstr, sizeof(highstr), "%" PRIu64, upper);
6f51e1
         range_low.bv_val = lowstr;
6f51e1
         range_low.bv_len = strlen(range_low.bv_val);
6f51e1
         range_high.bv_val = highstr;
6f51e1
@@ -4445,7 +4437,7 @@ static int dna_extend_exop(Slapi_PBlock *pb)
6f51e1
         ber_bvfree(respdata);
6f51e1
 
6f51e1
         slapi_log_err(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
6f51e1
-                        "dna_extend_exop - Released range %" NSPRIu64 "-%" NSPRIu64 ".\n",
6f51e1
+                        "dna_extend_exop - Released range %" PRIu64 "-%" PRIu64 ".\n",
6f51e1
                         lower, upper);
6f51e1
     }
6f51e1
 
6f51e1
@@ -4588,7 +4580,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
6f51e1
                 *lower = *upper - release + 1;
6f51e1
 
6f51e1
                 /* try to set the new maxval in the config entry */
6f51e1
-                snprintf(max_value, sizeof(max_value),"%" NSPRIu64, (*lower - 1));
6f51e1
+                snprintf(max_value, sizeof(max_value),"%" PRIu64, (*lower - 1));
6f51e1
 
6f51e1
                 /* set up our replace modify operation */
6f51e1
                 replace_val[0] = max_value;
6f51e1
diff --git a/ldap/servers/plugins/posix-winsync/posix-winsync.c b/ldap/servers/plugins/posix-winsync/posix-winsync.c
6f51e1
index 63444e5..21e4ad0 100644
6f51e1
--- a/ldap/servers/plugins/posix-winsync/posix-winsync.c
6f51e1
+++ b/ldap/servers/plugins/posix-winsync/posix-winsync.c
6f51e1
@@ -270,7 +270,7 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
6f51e1
         if (update_entry) {
6f51e1
             slapi_entry_attr_set_ulong(update_entry, "userAccountControl", adval);
6f51e1
             slapi_log_err(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
6f51e1
-                "<-- sync_acct_disable - %s AD account [%s] - new value is [%" NSPRIu64 "]\n",
6f51e1
+                "<-- sync_acct_disable - %s AD account [%s] - new value is [%" PRIu64 "]\n",
6f51e1
 				(ds_is_enabled) ? "enabled" : "disabled", slapi_entry_get_dn_const(update_entry), adval);
6f51e1
         } else {
6f51e1
             /* iterate through the mods - if there is already a mod
6f51e1
@@ -326,7 +326,7 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
6f51e1
                 mod_bval->bv_len = strlen(acctvalstr);
6f51e1
             }
6f51e1
             slapi_log_err(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
6f51e1
-                "<-- sync_acct_disable - %s AD account [%s] - new value is [%" NSPRIu64 "]\n",
6f51e1
+                "<-- sync_acct_disable - %s AD account [%s] - new value is [%" PRIu64 "]\n",
6f51e1
 				(ds_is_enabled) ? "enabled" : "disabled", slapi_entry_get_dn_const(ad_entry), adval);
6f51e1
         }
6f51e1
     }
6f51e1
diff --git a/ldap/servers/plugins/replication/repl.h b/ldap/servers/plugins/replication/repl.h
6f51e1
index 89ad481..9460ca9 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl.h
6f51e1
+++ b/ldap/servers/plugins/replication/repl.h
6f51e1
@@ -15,21 +15,8 @@
6f51e1
 #ifndef _REPL_H_
6f51e1
 #define _REPL_H_
6f51e1
 
6f51e1
-/* Required to get portable printf/scanf format macros */
6f51e1
-#ifdef HAVE_INTTYPES_H
6f51e1
-#include <inttypes.h>
6f51e1
-
6f51e1
-/* NSPR uses the print macros a bit differently than ANSI C.  We
6f51e1
- * need to use ll for a 64-bit integer, even when a long is 64-bit.
6f51e1
- */
6f51e1
-#undef PRIu64
6f51e1
-#define PRIu64  "llu"
6f51e1
-#undef PRI64
6f51e1
-#define PRI64   "ll"
6f51e1
-
6f51e1
-#else
6f51e1
-#error Need to define portable format macros such as PRIu64
6f51e1
-#endif /* HAVE_INTTYPES_H */
6f51e1
+/* Provides our int types and platform specific requirements. */
6f51e1
+#include <slapi_pal.h>
6f51e1
 
6f51e1
 #include <limits.h>
6f51e1
 #include <time.h>
6f51e1
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
6f51e1
index a5ae885..36c279e 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
6f51e1
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
6f51e1
@@ -2104,7 +2104,7 @@ repl5_inc_stop(Private_Repl_Protocol *prp)
6f51e1
 		/* Isn't listening. Do something drastic. */
6f51e1
 		return_value = -1;
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
-				"repl5_inc_stop - %s: Protocol does not stop after %" NSPRIu64 " seconds\n",
6f51e1
+				"repl5_inc_stop - %s: Protocol does not stop after %" PRIu64 " seconds\n",
6f51e1
 				agmt_get_long_name(prp->agmt), timeout);
6f51e1
 	}
6f51e1
 	else
6f51e1
diff --git a/ldap/servers/plugins/replication/repl5_init.c b/ldap/servers/plugins/replication/repl5_init.c
6f51e1
index 9549dcf..edffb84 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl5_init.c
6f51e1
+++ b/ldap/servers/plugins/replication/repl5_init.c
6f51e1
@@ -208,7 +208,7 @@ get_repl_session_id (Slapi_PBlock *pb, char *idstr, CSN **csn)
6f51e1
 		/* Avoid "Connection is NULL and hence cannot access SLAPI_CONN_ID" */
6f51e1
 		if (opid) {
6f51e1
 			slapi_pblock_get (pb, SLAPI_CONN_ID, &connid);
6f51e1
-			snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%" NSPRIu64 " op=%d",
6f51e1
+			snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%" PRIu64 " op=%d",
6f51e1
 					connid, opid);
6f51e1
 		}
6f51e1
 
6f51e1
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
6f51e1
index 357c093..ebcc230 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl5_plugins.c
6f51e1
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
6f51e1
@@ -1335,7 +1335,7 @@ process_postop (Slapi_PBlock *pb)
6f51e1
 			{
6f51e1
 				slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
6f51e1
 					"process_postop - Failed to apply update (%s) error (%d).  "
6f51e1
-					"Aborting replication session(conn=%" NSPRIu64 " op=%d)\n",
6f51e1
+					"Aborting replication session(conn=%" PRIu64 " op=%d)\n",
6f51e1
 					csn_as_string(opcsn, PR_FALSE, csn_str), retval,
6f51e1
 					connid, opid);
6f51e1
 				/*
6f51e1
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
6f51e1
index 5718a98..a106f8b 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl5_replica.c
6f51e1
+++ b/ldap/servers/plugins/replication/repl5_replica.c
6f51e1
@@ -596,7 +596,7 @@ replica_get_exclusive_access(Replica *r, PRBool *isInc, PRUint64 connid, int opi
6f51e1
 
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"replica_get_exclusive_access - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 				"Replica in use locking_purl=%s\n",
6f51e1
 				connid, opid,
6f51e1
 				slapi_sdn_get_dn(r->repl_root),
6f51e1
@@ -620,7 +620,7 @@ replica_get_exclusive_access(Replica *r, PRBool *isInc, PRUint64 connid, int opi
6f51e1
 	{
6f51e1
         slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
         		"replica_get_exclusive_access - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": Acquired replica\n",
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": Acquired replica\n",
6f51e1
 				connid, opid,
6f51e1
 				slapi_sdn_get_dn(r->repl_root));
6f51e1
 		r->repl_state_flags |= REPLICA_IN_USE;
6f51e1
@@ -664,13 +664,13 @@ replica_relinquish_exclusive_access(Replica *r, PRUint64 connid, int opid)
6f51e1
 	{
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"replica_relinquish_exclusive_access - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 				"Replica not in use\n",
6f51e1
 				connid, opid, slapi_sdn_get_dn(r->repl_root));
6f51e1
 	} else {
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"replica_relinquish_exclusive_access - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 				"Released replica held by locking_purl=%s\n",
6f51e1
 				connid, opid,
6f51e1
 				slapi_sdn_get_dn(r->repl_root),	r->locking_purl);
6f51e1
diff --git a/ldap/servers/plugins/replication/repl5_total.c b/ldap/servers/plugins/replication/repl5_total.c
6f51e1
index af570a8..064a099 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl5_total.c
6f51e1
+++ b/ldap/servers/plugins/replication/repl5_total.c
6f51e1
@@ -853,7 +853,7 @@ multimaster_extop_NSDS50ReplicationEntry(Slapi_PBlock  *pb)
6f51e1
            const char *dn = slapi_entry_get_dn_const(e);
6f51e1
            slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
                    "multimaster_extop_NSDS50ReplicationEntry - "
6f51e1
-                   "Error %d: could not import entry dn %s for total update operation conn=%" NSPRIu64 " op=%d\n",
6f51e1
+                   "Error %d: could not import entry dn %s for total update operation conn=%" PRIu64 " op=%d\n",
6f51e1
                    rc, dn, connid, opid);
6f51e1
 		   rc = -1;
6f51e1
 	   }
6f51e1
@@ -864,7 +864,7 @@ multimaster_extop_NSDS50ReplicationEntry(Slapi_PBlock  *pb)
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"multimaster_extop_NSDS50ReplicationEntry - "
6f51e1
 				"Error %d: could not decode the total update extop "
6f51e1
-				"for total update operation conn=%" NSPRIu64 " op=%d\n",
6f51e1
+				"for total update operation conn=%" PRIu64 " op=%d\n",
6f51e1
 				rc, connid, opid);
6f51e1
 	}
6f51e1
    
6f51e1
diff --git a/ldap/servers/plugins/replication/repl_connext.c b/ldap/servers/plugins/replication/repl_connext.c
6f51e1
index 29dc2a7..ba0fa15 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl_connext.c
6f51e1
+++ b/ldap/servers/plugins/replication/repl_connext.c
6f51e1
@@ -84,7 +84,7 @@ void consumer_connection_extension_destructor (void *ext, void *object, void *pa
6f51e1
 					slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 							"consumer_connection_extension_destructor - "
6f51e1
 							"Aborting total update in progress for replicated "
6f51e1
-							"area %s connid=%" NSPRIu64 "\n", slapi_sdn_get_dn(repl_root_sdn), connid);
6f51e1
+							"area %s connid=%" PRIu64 "\n", slapi_sdn_get_dn(repl_root_sdn), connid);
6f51e1
 					slapi_stop_bulk_import(pb);
6f51e1
 				}
6f51e1
 				else
6f51e1
@@ -156,7 +156,7 @@ consumer_connection_extension_acquire_exclusive_access(void* conn, PRUint64 conn
6f51e1
             ret = connext;
6f51e1
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
             		"consumer_connection_extension_acquire_exclusive_access - "
6f51e1
-                    "conn=%" NSPRIu64 " op=%d Acquired consumer connection extension\n",
6f51e1
+                    "conn=%" PRIu64 " op=%d Acquired consumer connection extension\n",
6f51e1
                     connid, opid);
6f51e1
         }
6f51e1
         else if (opid == connext->in_use_opid)
6f51e1
@@ -164,14 +164,14 @@ consumer_connection_extension_acquire_exclusive_access(void* conn, PRUint64 conn
6f51e1
             ret = connext;
6f51e1
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
             		"consumer_connection_extension_acquire_exclusive_access - "
6f51e1
-                    "conn=%" NSPRIu64 " op=%d Reacquired consumer connection extension\n",
6f51e1
+                    "conn=%" PRIu64 " op=%d Reacquired consumer connection extension\n",
6f51e1
                     connid, opid);
6f51e1
         }
6f51e1
         else
6f51e1
         {
6f51e1
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
             		"consumer_connection_extension_acquire_exclusive_access - "
6f51e1
-                    "conn=%" NSPRIu64 " op=%d Could not acquire consumer connection extension; it is in use by op=%d\n",
6f51e1
+                    "conn=%" PRIu64 " op=%d Could not acquire consumer connection extension; it is in use by op=%d\n",
6f51e1
                     connid, opid, connext->in_use_opid);
6f51e1
         }
6f51e1
 
6f51e1
@@ -182,7 +182,7 @@ consumer_connection_extension_acquire_exclusive_access(void* conn, PRUint64 conn
6f51e1
     {
6f51e1
         slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
         		"consumer_connection_extension_acquire_exclusive_access - "
6f51e1
-                "conn=%" NSPRIu64 " op=%d Could not acquire consumer extension, it is NULL!\n",
6f51e1
+                "conn=%" PRIu64 " op=%d Could not acquire consumer extension, it is NULL!\n",
6f51e1
                 connid, opid);
6f51e1
     }
6f51e1
     
6f51e1
@@ -221,7 +221,7 @@ consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 c
6f51e1
         {
6f51e1
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
             		"consumer_connection_extension_relinquish_exclusive_access - "
6f51e1
-                    "conn=%" NSPRIu64 " op=%d Consumer connection extension is not in use\n",
6f51e1
+                    "conn=%" PRIu64 " op=%d Consumer connection extension is not in use\n",
6f51e1
                     connid, opid);
6f51e1
             ret = 2;
6f51e1
         }
6f51e1
@@ -230,7 +230,7 @@ consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 c
6f51e1
             /* step 4, relinquish it (normal) */
6f51e1
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
             		"consumer_connection_extension_relinquish_exclusive_access - "
6f51e1
-                    "conn=%" NSPRIu64 " op=%d Relinquishing consumer connection extension\n",
6f51e1
+                    "conn=%" PRIu64 " op=%d Relinquishing consumer connection extension\n",
6f51e1
                     connid, opid);
6f51e1
             connext->in_use_opid = -1;
6f51e1
             ret = 1;
6f51e1
@@ -240,7 +240,7 @@ consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 c
6f51e1
             /* step 4, relinquish it (forced) */
6f51e1
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
             		"consumer_connection_extension_relinquish_exclusive_access - "
6f51e1
-                    "conn=%" NSPRIu64 " op=%d Forced to relinquish consumer connection extension held by op=%d\n",
6f51e1
+                    "conn=%" PRIu64 " op=%d Forced to relinquish consumer connection extension held by op=%d\n",
6f51e1
                     connid, opid, connext->in_use_opid);
6f51e1
             connext->in_use_opid = -1;
6f51e1
             ret = 1;
6f51e1
@@ -249,7 +249,7 @@ consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 c
6f51e1
         {
6f51e1
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
             		"consumer_connection_extension_relinquish_exclusive_access - "
6f51e1
-                    "conn=%" NSPRIu64 " op=%d Not relinquishing consumer connection extension, it is held by op=%d!\n",
6f51e1
+                    "conn=%" PRIu64 " op=%d Not relinquishing consumer connection extension, it is held by op=%d!\n",
6f51e1
                     connid, opid, connext->in_use_opid);
6f51e1
         }
6f51e1
         
6f51e1
@@ -260,7 +260,7 @@ consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 c
6f51e1
     {
6f51e1
         slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
         		"consumer_connection_extension_relinquish_exclusive_access - "
6f51e1
-                "conn=%" NSPRIu64 " op=%d Could not relinquish consumer extension, it is NULL!\n",
6f51e1
+                "conn=%" PRIu64 " op=%d Could not relinquish consumer extension, it is NULL!\n",
6f51e1
                 connid, opid);
6f51e1
     }
6f51e1
     
6f51e1
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
6f51e1
index 80580f9..412caec 100644
6f51e1
--- a/ldap/servers/plugins/replication/repl_extop.c
6f51e1
+++ b/ldap/servers/plugins/replication/repl_extop.c
6f51e1
@@ -668,7 +668,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 		connext->repl_protocol_version = REPL_PROTOCOL_50_INCREMENTAL;
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 			"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-			"conn=%" NSPRIu64 " op=%d repl=\"%s\": Begin incremental protocol\n",
6f51e1
+			"conn=%" PRIu64 " op=%d repl=\"%s\": Begin incremental protocol\n",
6f51e1
 			connid, opid, repl_root);
6f51e1
 		isInc = PR_TRUE;
6f51e1
 	}
6f51e1
@@ -695,7 +695,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 		}
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": Begin total protocol\n",
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": Begin total protocol\n",
6f51e1
 				connid, opid, repl_root);
6f51e1
 		isInc = PR_FALSE;
6f51e1
 	}
6f51e1
@@ -705,7 +705,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 		connext->repl_protocol_version = REPL_PROTOCOL_50_INCREMENTAL;
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 			"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-			"conn=%" NSPRIu64 " op=%d repl=\"%s\": Begin 7.1 incremental protocol\n",
6f51e1
+			"conn=%" PRIu64 " op=%d repl=\"%s\": Begin 7.1 incremental protocol\n",
6f51e1
 			connid, opid, repl_root);
6f51e1
 		isInc = PR_TRUE;
6f51e1
 	}
6f51e1
@@ -718,7 +718,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 		}
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": Begin 7.1 total protocol\n",
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": Begin 7.1 total protocol\n",
6f51e1
 				connid, opid, repl_root);
6f51e1
 		isInc = PR_FALSE;
6f51e1
 	}
6f51e1
@@ -741,7 +741,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 	{
6f51e1
         slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
         		"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d replica=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d replica=\"%s\": "
6f51e1
 				"Replica is being configured: try again later\n",
6f51e1
 				connid, opid, repl_root);
6f51e1
 		response = NSDS50_REPL_REPLICA_BUSY;
6f51e1
@@ -814,7 +814,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 				{
6f51e1
 					slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
6f51e1
 							"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-							"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+							"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 							"Excessive clock skew from supplier RUV\n",
6f51e1
 							connid, opid, repl_root);
6f51e1
 					response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
6f51e1
@@ -852,7 +852,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 	if (check_replica_id_uniqueness(replica, supplier_ruv) != 0){
6f51e1
         slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
         		"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 				"Replica has same replicaID %d as supplier\n",
6f51e1
 				connid, opid, repl_root, replica_get_rid(replica));
6f51e1
 		response = NSDS50_REPL_REPLICAID_ERROR;
6f51e1
@@ -865,7 +865,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 	 * the session's conn id and op id to identify the the supplier.
6f51e1
 	 */
6f51e1
 	/* junkrc = ruv_get_first_id_and_purl(supplier_ruv, &junkrid, &locking_purl); */
6f51e1
-	snprintf(locking_session, sizeof(locking_session), "conn=%" NSPRIu64 " id=%d",
6f51e1
+	snprintf(locking_session, sizeof(locking_session), "conn=%" PRIu64 " id=%d",
6f51e1
 			connid, opid);
6f51e1
 	locking_purl = &locking_session[0];
6f51e1
 	if (replica_get_exclusive_access(replica, &isInc, connid, opid,
6f51e1
@@ -892,7 +892,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 		int max = 480 * 5;
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 				"374 - Starting sleep: connext->repl_protocol_version == %d\n",
6f51e1
 				connid, opid, repl_root, connext->repl_protocol_version);
6f51e1
         
6f51e1
@@ -902,7 +902,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
         
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 				"374 - Finished sleep: connext->repl_protocol_version == %d\n",
6f51e1
 				connid, opid, repl_root, connext->repl_protocol_version);
6f51e1
 	}
6f51e1
@@ -997,7 +997,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
6f51e1
 		response = NSDS50_REPL_INTERNAL_ERROR;
6f51e1
 		slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 				"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-				"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+				"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 				"Unexpected update protocol received: %d.  "
6f51e1
 				"Expected incremental or total.\n",
6f51e1
 				connid, opid, repl_root, connext->repl_protocol_version);
6f51e1
@@ -1039,7 +1039,7 @@ send_response:
6f51e1
 		slapi_log_err (resp_log_level,
6f51e1
 			repl_plugin_name,
6f51e1
 			"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-			"conn=%" NSPRIu64 " op=%d replica=\"%s\": "
6f51e1
+			"conn=%" PRIu64 " op=%d replica=\"%s\": "
6f51e1
 			"Unable to acquire replica: error: %s%s\n",
6f51e1
 			connid, opid,
6f51e1
 			(replica ? slapi_sdn_get_dn(replica_get_root(replica)) : "unknown"),
6f51e1
@@ -1092,7 +1092,7 @@ send_response:
6f51e1
 	slapi_pblock_set(pb, SLAPI_EXT_OP_RET_VALUE, resp_bval);
6f51e1
 	slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
6f51e1
 			"multimaster_extop_StartNSDS50ReplicationRequest - "
6f51e1
-			"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
6f51e1
+			"conn=%" PRIu64 " op=%d repl=\"%s\": "
6f51e1
 			"%s: response=%d rc=%d\n",
6f51e1
 			connid, opid, repl_root,
6f51e1
 			is90 ? "StartNSDS90ReplicationRequest" :
6f51e1
diff --git a/ldap/servers/plugins/sync/sync_persist.c b/ldap/servers/plugins/sync/sync_persist.c
6f51e1
index 667a529..bd856cb 100644
6f51e1
--- a/ldap/servers/plugins/sync/sync_persist.c
6f51e1
+++ b/ldap/servers/plugins/sync/sync_persist.c
6f51e1
@@ -548,14 +548,14 @@ sync_send_results( void *arg )
6f51e1
 	slapi_pblock_get(req->req_pblock, SLAPI_CONNECTION, &conn);
6f51e1
 	if (NULL == conn) {
6f51e1
 		slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM,
6f51e1
-			"sync_send_results - conn=%" NSPRIu64 " op=%d Null connection - aborted\n",
6f51e1
+			"sync_send_results - conn=%" PRIu64 " op=%d Null connection - aborted\n",
6f51e1
 			connid, opid);
6f51e1
 		goto done;
6f51e1
 	}
6f51e1
 	conn_acq_flag = sync_acquire_connection (conn);
6f51e1
 	if (conn_acq_flag) {
6f51e1
 		slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM,
6f51e1
-			"sync_send_results - conn=%" NSPRIu64 " op=%d Could not acquire the connection - aborted\n",
6f51e1
+			"sync_send_results - conn=%" PRIu64 " op=%d Could not acquire the connection - aborted\n",
6f51e1
 			connid, opid);
6f51e1
 		goto done;
6f51e1
 	}
6f51e1
@@ -566,7 +566,7 @@ sync_send_results( void *arg )
6f51e1
 		/* Check for an abandoned operation */
6f51e1
 		if ( op == NULL || slapi_is_operation_abandoned( op ) ) {
6f51e1
 			slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM,
6f51e1
-						"sync_send_results - conn=%" NSPRIu64 " op=%d Operation no longer active - terminating\n",
6f51e1
+						"sync_send_results - conn=%" PRIu64 " op=%d Operation no longer active - terminating\n",
6f51e1
 						connid, opid);
6f51e1
 			break;
6f51e1
 		}
6f51e1
diff --git a/ldap/servers/plugins/syntaxes/validate_task.c b/ldap/servers/plugins/syntaxes/validate_task.c
6f51e1
index eae2d2a..c051573 100644
6f51e1
--- a/ldap/servers/plugins/syntaxes/validate_task.c
6f51e1
+++ b/ldap/servers/plugins/syntaxes/validate_task.c
6f51e1
@@ -201,12 +201,12 @@ syntax_validate_task_thread(void *arg)
6f51e1
 	slapi_pblock_destroy(search_pb);
6f51e1
 
6f51e1
 	/* Log finished message. */
6f51e1
-	slapi_task_log_notice(task, "Syntax validate task complete.  Found %" NSPRIu64
6f51e1
+	slapi_task_log_notice(task, "Syntax validate task complete.  Found %" PRIu64
6f51e1
 	                " invalid entries.\n", slapi_counter_get_value(td->invalid_entries));
6f51e1
-	slapi_task_log_status(task, "Syntax validate task complete.  Found %" NSPRIu64
6f51e1
+	slapi_task_log_status(task, "Syntax validate task complete.  Found %" PRIu64
6f51e1
 	                " invalid entries.\n", slapi_counter_get_value(td->invalid_entries));
6f51e1
 	slapi_log_err(SLAPI_LOG_ERR, SYNTAX_PLUGIN_SUBSYSTEM, "syntax_validate_task_thread - Complete."
6f51e1
-	                "  Found %" NSPRIu64 " invalid entries.\n",
6f51e1
+	                "  Found %" PRIu64 " invalid entries.\n",
6f51e1
 	                slapi_counter_get_value(td->invalid_entries));
6f51e1
 	slapi_task_inc_progress(task);
6f51e1
 
6f51e1
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
6f51e1
index 5e67e0a..54ebc31 100644
6f51e1
--- a/ldap/servers/plugins/usn/usn.c
6f51e1
+++ b/ldap/servers/plugins/usn/usn.c
6f51e1
@@ -320,7 +320,7 @@ _usn_add_next_usn(Slapi_Entry *e, Slapi_Backend *be)
6f51e1
                     "--> _usn_add_next_usn\n");
6f51e1
 
6f51e1
     /* add next USN to the entry; "be" contains the usn counter */
6f51e1
-    usn_berval.bv_val = slapi_ch_smprintf("%" NSPRIu64, 
6f51e1
+    usn_berval.bv_val = slapi_ch_smprintf("%" PRIu64, 
6f51e1
                                           slapi_counter_get_value(be->be_usn_counter));
6f51e1
     usn_berval.bv_len = strlen(usn_berval.bv_val);
6f51e1
     slapi_entry_attr_find(e, SLAPI_ATTR_ENTRYUSN, &attr);
6f51e1
@@ -360,7 +360,7 @@ _usn_mod_next_usn(LDAPMod ***mods, Slapi_Backend *be)
6f51e1
 
6f51e1
     /* add next USN to the mods; "be" contains the usn counter */
6f51e1
     usn_berval.bv_val = counter_buf;
6f51e1
-    snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
6f51e1
+    snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" PRIu64,
6f51e1
                 slapi_counter_get_value(be->be_usn_counter));
6f51e1
     usn_berval.bv_len = strlen(usn_berval.bv_val);
6f51e1
     bvals[0] = &usn_berval;
6f51e1
@@ -681,7 +681,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
6f51e1
             /* get a next USN counter from be_usn_counter; 
6f51e1
              * then minus 1 from it (except if be_usn_counter has value 0) */
6f51e1
             if (slapi_counter_get_value(be->be_usn_counter)) {
6f51e1
-                snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
6f51e1
+                snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" PRIu64,
6f51e1
                             slapi_counter_get_value(be->be_usn_counter)-1);
6f51e1
             } else {
6f51e1
                 snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
6f51e1
@@ -704,7 +704,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
6f51e1
             /* get a next USN counter from be_usn_counter; 
6f51e1
              * then minus 1 from it (except if be_usn_counter has value 0) */
6f51e1
             if (slapi_counter_get_value(be->be_usn_counter)) {
6f51e1
-                snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
6f51e1
+                snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" PRIu64,
6f51e1
                             slapi_counter_get_value(be->be_usn_counter)-1);
6f51e1
             } else {
6f51e1
                 snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
6f51e1
diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c
6f51e1
index 18ff8ce..0485006 100644
6f51e1
--- a/ldap/servers/slapd/abandon.c
6f51e1
+++ b/ldap/servers/slapd/abandon.c
6f51e1
@@ -119,19 +119,19 @@ do_abandon( Slapi_PBlock *pb )
6f51e1
 	}
6f51e1
 
6f51e1
 	if ( 0 == pagedresults_free_one_msgid_nolock(pb->pb_conn, id) ) {
6f51e1
-		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 
6f51e1
+		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 
6f51e1
 		    " op=%d ABANDON targetop=Simple Paged Results msgid=%d\n",
6f51e1
 		    pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
6f51e1
 	} else if ( NULL == o ) {
6f51e1
-		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON"
6f51e1
+		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d ABANDON"
6f51e1
 			" targetop=NOTFOUND msgid=%d\n",
6f51e1
 			pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
6f51e1
 	} else if ( suppressed_by_plugin ) {
6f51e1
-		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON"
6f51e1
+		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d ABANDON"
6f51e1
 			" targetop=SUPPRESSED-BY-PLUGIN msgid=%d\n",
6f51e1
 			pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
6f51e1
 	} else {
6f51e1
-		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ABANDON"
6f51e1
+		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d ABANDON"
6f51e1
 			" targetop=%d msgid=%d nentries=%d etime=%ld\n",
6f51e1
 			pb->pb_conn->c_connid, pb->pb_op->o_opid, o->o_opid, id,
6f51e1
 			o->o_results.r.r_search.nentries, current_time() - o->o_time );
6f51e1
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
6f51e1
index 1b994a0..9c4001e 100644
6f51e1
--- a/ldap/servers/slapd/add.c
6f51e1
+++ b/ldap/servers/slapd/add.c
6f51e1
@@ -168,7 +168,7 @@ do_add( Slapi_PBlock *pb )
6f51e1
 			if (( rc = slapi_entry_add_values( e, normtype, vals ))
6f51e1
 				!= LDAP_SUCCESS ) {
6f51e1
 				slapi_log_access( LDAP_DEBUG_STATS, 
6f51e1
-					"conn=%" NSPRIu64 " op=%d ADD dn=\"%s\", add values for type %s failed\n",
6f51e1
+					"conn=%" PRIu64 " op=%d ADD dn=\"%s\", add values for type %s failed\n",
6f51e1
 					pb->pb_conn->c_connid, operation->o_opid,
6f51e1
 					slapi_entry_get_dn_const(e), normtype );
6f51e1
 				send_ldap_result( pb, rc, NULL, NULL, 0, NULL );
6f51e1
@@ -460,7 +460,7 @@ static void op_shared_add (Slapi_PBlock *pb)
6f51e1
 
6f51e1
 		if ( !internal_op )
6f51e1
 		{
6f51e1
-			slapi_log_access(LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d ADD dn=\"%s\"%s\n",
6f51e1
+			slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d ADD dn=\"%s\"%s\n",
6f51e1
 							 pb->pb_conn->c_connid,
6f51e1
 							 operation->o_opid,
6f51e1
 							 slapi_entry_get_dn_const(e),
6f51e1
diff --git a/ldap/servers/slapd/auth.c b/ldap/servers/slapd/auth.c
6f51e1
index c787dd4..da1b586 100644
6f51e1
--- a/ldap/servers/slapd/auth.c
6f51e1
+++ b/ldap/servers/slapd/auth.c
6f51e1
@@ -366,7 +366,7 @@ handle_bad_certificate (void* clientData, PRFileDesc *prfd)
6f51e1
     char* subject = subject_of (clientCert);
6f51e1
     char* issuer  = issuer_of  (clientCert);
6f51e1
     slapi_log_access( LDAP_DEBUG_STATS,
6f51e1
-	       "conn=%" NSPRIu64 " " SLAPI_COMPONENT_NAME_NSPR " error %i (%s); unauthenticated client %s; issuer %s\n",
6f51e1
+	       "conn=%" PRIu64 " " SLAPI_COMPONENT_NAME_NSPR " error %i (%s); unauthenticated client %s; issuer %s\n",
6f51e1
 	       conn->c_connid, errorCode, slapd_pr_strerror(errorCode),
6f51e1
 	       subject ? escape_string( subject, sbuf ) : "NULL",
6f51e1
 	       issuer  ? escape_string( issuer,  ibuf ) : "NULL" );
6f51e1
@@ -402,7 +402,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
6f51e1
 	if ( (slapd_ssl_getChannelInfo (prfd, &channelInfo, sizeof(channelInfo))) != SECSuccess ) {
6f51e1
 		PRErrorCode errorCode = PR_GetError();
6f51e1
 		slapi_log_access (LDAP_DEBUG_STATS,
6f51e1
-			"conn=%" NSPRIu64 " SSL failed to obtain channel info; "
6f51e1
+			"conn=%" PRIu64 " SSL failed to obtain channel info; "
6f51e1
 			SLAPI_COMPONENT_NAME_NSPR " error %i (%s)\n",
6f51e1
 			conn->c_connid, errorCode, slapd_pr_strerror(errorCode));
6f51e1
 		goto done;
6f51e1
@@ -411,7 +411,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
6f51e1
 			!= SECSuccess) {
6f51e1
 		PRErrorCode errorCode = PR_GetError();
6f51e1
 		slapi_log_access (LDAP_DEBUG_STATS,
6f51e1
-			"conn=%" NSPRIu64 " SSL failed to obtain cipher info; "
6f51e1
+			"conn=%" PRIu64 " SSL failed to obtain cipher info; "
6f51e1
 			SLAPI_COMPONENT_NAME_NSPR " error %i (%s)\n",
6f51e1
 			conn->c_connid, errorCode, slapd_pr_strerror(errorCode));
6f51e1
 		goto done;
6f51e1
@@ -432,14 +432,14 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
6f51e1
 
6f51e1
     if (config_get_SSLclientAuth() == SLAPD_SSLCLIENTAUTH_OFF ) {
6f51e1
         (void) slapi_getSSLVersion_str(channelInfo.protocolVersion, sslversion, sizeof(sslversion));
6f51e1
-        slapi_log_access (LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " %s %i-bit %s\n",
6f51e1
+        slapi_log_access (LDAP_DEBUG_STATS, "conn=%" PRIu64 " %s %i-bit %s\n",
6f51e1
                 conn->c_connid, 
6f51e1
                 sslversion, keySize, cipher ? cipher : "NULL" );
6f51e1
         goto done;
6f51e1
     }
6f51e1
     if (clientCert == NULL) {
6f51e1
         (void) slapi_getSSLVersion_str(channelInfo.protocolVersion, sslversion, sizeof(sslversion));
6f51e1
-        slapi_log_access (LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " %s %i-bit %s\n",
6f51e1
+        slapi_log_access (LDAP_DEBUG_STATS, "conn=%" PRIu64 " %s %i-bit %s\n",
6f51e1
                 conn->c_connid, 
6f51e1
                 sslversion, keySize, cipher ? cipher : "NULL" );
6f51e1
     } else {
6f51e1
@@ -448,7 +448,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
6f51e1
             (void) slapi_getSSLVersion_str(channelInfo.protocolVersion,
6f51e1
                                                  sslversion, sizeof(sslversion));
6f51e1
             slapi_log_access( LDAP_DEBUG_STATS,
6f51e1
-                       "conn=%" NSPRIu64 " %s %i-bit %s; missing subject\n",
6f51e1
+                       "conn=%" PRIu64 " %s %i-bit %s; missing subject\n",
6f51e1
                        conn->c_connid, 
6f51e1
                        sslversion, keySize, cipher ? cipher : "NULL");
6f51e1
             goto done;
6f51e1
@@ -459,7 +459,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
6f51e1
             (void) slapi_getSSLVersion_str(channelInfo.protocolVersion,
6f51e1
                                                  sslversion, sizeof(sslversion));
6f51e1
             slapi_log_access( LDAP_DEBUG_STATS,
6f51e1
-                        "conn=%" NSPRIu64 " %s %i-bit %s; client %s; issuer %s\n",
6f51e1
+                        "conn=%" PRIu64 " %s %i-bit %s; client %s; issuer %s\n",
6f51e1
                         conn->c_connid,
6f51e1
                         sslversion, keySize, cipher ? cipher : "NULL",
6f51e1
                         subject ? escape_string( subject, sbuf ) : "NULL",
6f51e1
@@ -503,14 +503,14 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
6f51e1
         (void) slapi_getSSLVersion_str(channelInfo.protocolVersion,
6f51e1
                                              sslversion, sizeof(sslversion));
6f51e1
         slapi_log_access (LDAP_DEBUG_STATS, 
6f51e1
-                          "conn=%" NSPRIu64 " %s client bound as %s\n",
6f51e1
+                          "conn=%" PRIu64 " %s client bound as %s\n",
6f51e1
                           conn->c_connid,
6f51e1
                           sslversion, clientDN);
6f51e1
     } else if (clientCert != NULL) {
6f51e1
         (void) slapi_getSSLVersion_str(channelInfo.protocolVersion,
6f51e1
                                              sslversion, sizeof(sslversion));
6f51e1
         slapi_log_access (LDAP_DEBUG_STATS,
6f51e1
-                          "conn=%" NSPRIu64 " %s failed to map client "
6f51e1
+                          "conn=%" PRIu64 " %s failed to map client "
6f51e1
                           "certificate to LDAP DN (%s)\n",
6f51e1
                           conn->c_connid,
6f51e1
                           sslversion, extraErrorMsg);
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h
6f51e1
index a5fc540..0bb15e3 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
6f51e1
@@ -28,21 +28,8 @@
6f51e1
 #endif
6f51e1
 #endif
6f51e1
 
6f51e1
-/* Required to get portable printf/scanf format macros */
6f51e1
-#ifdef HAVE_INTTYPES_H
6f51e1
-#include <inttypes.h>
6f51e1
-
6f51e1
-/* NSPR uses the print macros a bit differently than ANSI C.  We
6f51e1
- * need to use ll for a 64-bit integer, even when a long is 64-bit.
6f51e1
- */
6f51e1
-#undef PRIu64
6f51e1
-#define PRIu64  "llu"
6f51e1
-#undef PRI64
6f51e1
-#define PRI64   "ll"
6f51e1
-
6f51e1
-#else
6f51e1
-#error Need to define portable format macros such as PRIu64
6f51e1
-#endif /* HAVE_INTTYPES_H */
6f51e1
+/* Provides our int types and platform specific requirements. */
6f51e1
+#include <slapi_pal.h>
6f51e1
 
6f51e1
 /* A bunch of random system headers taken from all the source files, no source file should #include
6f51e1
    any system headers now */
6f51e1
@@ -162,11 +149,11 @@ typedef unsigned short u_int16_t;
6f51e1
 #define    DBVERSION_FILENAME    "DBVERSION"
6f51e1
 /* 0 here means to let the autotuning reset the value on first run */
6f51e1
 /* cache can't get any smaller than this (in bytes) */
6f51e1
-#define MINCACHESIZE             (size_t)512000
6f51e1
-#define DEFAULT_CACHE_SIZE       (size_t)0
6f51e1
+#define MINCACHESIZE             (uint64_t)512000
6f51e1
+#define DEFAULT_CACHE_SIZE       (uint64_t)0
6f51e1
 #define DEFAULT_CACHE_SIZE_STR   "0"
6f51e1
 #define DEFAULT_CACHE_ENTRIES    -1        /* no limit */
6f51e1
-#define DEFAULT_DNCACHE_SIZE     (size_t)16777216
6f51e1
+#define DEFAULT_DNCACHE_SIZE     (uint64_t)16777216
6f51e1
 #define DEFAULT_DNCACHE_SIZE_STR "16777216"
6f51e1
 #define DEFAULT_DNCACHE_MAXCOUNT -1        /* no limit */
6f51e1
 #define DEFAULT_DBCACHE_SIZE     33554432
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
6f51e1
index ade2240..0f0cf3b 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/cache.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/cache.c
6f51e1
@@ -649,7 +649,7 @@ void cache_set_max_size(struct cache *cache, size_t bytes, int type)
6f51e1
     }
6f51e1
 }
6f51e1
 
6f51e1
-static void entrycache_set_max_size(struct cache *cache, size_t bytes)
6f51e1
+static void entrycache_set_max_size(struct cache *cache, uint64_t bytes)
6f51e1
 {
6f51e1
     struct backentry *eflush = NULL;
6f51e1
     struct backentry *eflushtemp = NULL;
6f51e1
@@ -659,16 +659,17 @@ static void entrycache_set_max_size(struct cache *cache, size_t bytes)
6f51e1
          * to happen. In that case, suppress this warning.
6f51e1
          */
6f51e1
         if (bytes > 0) {
6f51e1
-            slapi_log_err(SLAPI_LOG_WARNING, "entrycache_set_max_size", "Minimum cache size is %lu -- rounding up\n", MINCACHESIZE);
6f51e1
+            slapi_log_err(SLAPI_LOG_WARNING, "entrycache_set_max_size", "Minimum cache size is %"PRIu64" -- rounding up\n", MINCACHESIZE);
6f51e1
         }
6f51e1
         bytes = MINCACHESIZE;
6f51e1
     }
6f51e1
     cache_lock(cache);
6f51e1
     cache->c_maxsize = bytes;
6f51e1
-    LOG("entry cache size set to %lu\n", bytes);
6f51e1
+    LOG("entry cache size set to %"PRIu64"\n", bytes);
6f51e1
     /* check for full cache, and clear out if necessary */
6f51e1
-    if (CACHE_FULL(cache))
6f51e1
+    if (CACHE_FULL(cache)) {
6f51e1
        eflush = entrycache_flush(cache);
6f51e1
+    }
6f51e1
     while (eflush)
6f51e1
     {
6f51e1
         eflushtemp = BACK_LRU_NEXT(eflush, struct backentry *);
6f51e1
@@ -686,12 +687,11 @@ static void entrycache_set_max_size(struct cache *cache, size_t bytes)
6f51e1
     /* This may already have been called by one of the functions in
6f51e1
      * ldbm_instance_config
6f51e1
      */
6f51e1
-    if (! util_is_cachesize_sane(&bytes)) {
6f51e1
-       slapi_log_err(SLAPI_LOG_WARNING,
6f51e1
-                "entrycache_set_max_size", "Possible CONFIGURATION ERROR -- cachesize "
6f51e1
-                "(%lu) may be configured to use more than the available "
6f51e1
-                "physical memory.\n", bytes);
6f51e1
+    slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+    if (util_is_cachesize_sane(mi, &bytes) != UTIL_CACHESIZE_VALID) {
6f51e1
+       slapi_log_err(SLAPI_LOG_WARNING, "entrycache_set_max_size", "Cachesize (%"PRIu64") may use more than the available physical memory.\n", bytes);
6f51e1
     }
6f51e1
+    spal_meminfo_destroy(mi);
6f51e1
 }
6f51e1
 
6f51e1
 void cache_set_max_entries(struct cache *cache, long entries)
6f51e1
@@ -1597,7 +1597,7 @@ dn_same_id(const void *bdn, const void *k)
6f51e1
 }
6f51e1
 
6f51e1
 static void
6f51e1
-dncache_set_max_size(struct cache *cache, size_t bytes)
6f51e1
+dncache_set_max_size(struct cache *cache, uint64_t bytes)
6f51e1
 {
6f51e1
     struct backdn *dnflush = NULL;
6f51e1
     struct backdn *dnflushtemp = NULL;
6f51e1
@@ -1609,12 +1609,12 @@ dncache_set_max_size(struct cache *cache, size_t bytes)
6f51e1
     if (bytes < MINCACHESIZE) {
6f51e1
        bytes = MINCACHESIZE;
6f51e1
        slapi_log_err(SLAPI_LOG_WARNING,
6f51e1
-                "dncache_set_max_size", "Minimum cache size is %lu -- rounding up\n",
6f51e1
+                "dncache_set_max_size", "Minimum cache size is %"PRIu64" -- rounding up\n",
6f51e1
                 MINCACHESIZE);
6f51e1
     }
6f51e1
     cache_lock(cache);
6f51e1
     cache->c_maxsize = bytes;
6f51e1
-    LOG("entry cache size set to %lu\n", bytes);
6f51e1
+    LOG("entry cache size set to %"PRIu64"\n", bytes);
6f51e1
     /* check for full cache, and clear out if necessary */
6f51e1
     if (CACHE_FULL(cache)) {
6f51e1
        dnflush = dncache_flush(cache);
6f51e1
@@ -1636,12 +1636,12 @@ dncache_set_max_size(struct cache *cache, size_t bytes)
6f51e1
     /* This may already have been called by one of the functions in
6f51e1
      * ldbm_instance_config
6f51e1
      */
6f51e1
-    if (! util_is_cachesize_sane(&bytes)) {
6f51e1
-       slapi_log_err(SLAPI_LOG_WARNING,
6f51e1
-                "dncache_set_max_size", "Possible CONFIGURATION ERROR -- cachesize "
6f51e1
-                "(%lu) may be configured to use more than the available "
6f51e1
-                "physical memory.\n", bytes);
6f51e1
+
6f51e1
+    slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+    if (util_is_cachesize_sane(mi, &bytes) != UTIL_CACHESIZE_VALID) {
6f51e1
+       slapi_log_err(SLAPI_LOG_WARNING, "dncache_set_max_size", "Cachesize (%"PRIu64") may use more than the available physical memory.\n", bytes);
6f51e1
     }
6f51e1
+    spal_meminfo_destroy(mi);
6f51e1
 }
6f51e1
 
6f51e1
 /* remove a dn from the cache */
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
6f51e1
index 507a3cc..3c1fbb0 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
6f51e1
@@ -1386,14 +1386,16 @@ dblayer_start(struct ldbminfo *li, int dbmode)
6f51e1
 
6f51e1
     /* Sanity check on cache size on platforms which allow us to figure out
6f51e1
      * the available phys mem */
6f51e1
-    if (!util_is_cachesize_sane(&(priv->dblayer_cachesize))) {
6f51e1
+    slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+    if (!util_is_cachesize_sane(mi, &(priv->dblayer_cachesize))) {
6f51e1
         /* Oops---looks like the admin misconfigured, let's warn them */
6f51e1
         slapi_log_err(SLAPI_LOG_WARNING,"dblayer_start", "Likely CONFIGURATION ERROR -"
6f51e1
                   "dbcachesize is configured to use more than the available "
6f51e1
-                  "physical memory, decreased to the largest available size (%lu bytes).\n",
6f51e1
+                  "physical memory, decreased to the largest available size (%"PRIu64" bytes).\n",
6f51e1
                   priv->dblayer_cachesize);
6f51e1
         li->li_dbcachesize = priv->dblayer_cachesize;
6f51e1
     }
6f51e1
+    spal_meminfo_destroy(mi);
6f51e1
 
6f51e1
     /* fill in DB_ENV stuff from the common configuration */
6f51e1
     return_value = dblayer_make_env(&pEnv, li);
6f51e1
@@ -1690,9 +1692,6 @@ dblayer_start(struct ldbminfo *li, int dbmode)
6f51e1
  *    nsslapd-import-cache-autosize: 0
6f51e1
  * get the nsslapd-import-cachesize.
6f51e1
  * Calculate the memory size left after allocating the import cache size.
6f51e1
- * If the size is less than the hard limit, it issues an error and quit.
6f51e1
- * If the size is greater than the hard limit and less than the soft limit,
6f51e1
- * it issues a warning, but continues the import task.
6f51e1
  *
6f51e1
  * Note: this function is called only if the import is executed as a stand
6f51e1
  * alone command line (ldif2db).
6f51e1
@@ -1700,27 +1699,17 @@ dblayer_start(struct ldbminfo *li, int dbmode)
6f51e1
 int
6f51e1
 check_and_set_import_cache(struct ldbminfo *li)
6f51e1
 {
6f51e1
-    size_t import_pages = 0;
6f51e1
-    size_t pagesize, pages, procpages, availpages;
6f51e1
-    size_t soft_limit = 0;
6f51e1
-    size_t hard_limit = 0;
6f51e1
-    size_t page_delta = 0;
6f51e1
+    uint64_t import_cache = 0;
6f51e1
     char s[64];   /* big enough to hold %ld */
6f51e1
+    /* Get our platform memory values. */
6f51e1
+    slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
 
6f51e1
-    if (util_info_sys_pages(&pagesize, &pages, &procpages, &availpages) != 0 || 0 == pagesize || 0 == pages) {
6f51e1
-        slapi_log_err(SLAPI_LOG_ERR, "check_and_set_import_cache",
6f51e1
-                       "Failed to get pagesize: %ld or pages: %ld\n",
6f51e1
-                       pagesize, pages);
6f51e1
+    if (mi == NULL) {
6f51e1
+        slapi_log_err(SLAPI_LOG_ERR, "check_and_set_import_cache", "Failed to get system memory infomation\n");
6f51e1
         return ENOENT;
6f51e1
     }
6f51e1
-    slapi_log_err(SLAPI_LOG_INFO, "check_and_set_import_cache",
6f51e1
-                  "pagesize: %ld, pages: %ld, procpages: %ld\n",
6f51e1
-                  pagesize, pages, procpages);
6f51e1
+    slapi_log_err(SLAPI_LOG_INFO, "check_and_set_import_cache", "pagesize: %"PRIu64", available bytes %"PRIu64", process usage %"PRIu64" \n", mi->pagesize_bytes, mi->system_available_bytes, mi->process_consumed_bytes);
6f51e1
 
6f51e1
-    /* Soft limit: pages equivalent to 1GB (defined in dblayer.h) */
6f51e1
-    soft_limit = (DBLAYER_IMPORTCACHESIZE_SL*1024) / (pagesize/1024);
6f51e1
-    /* Hard limit: pages equivalent to 100MB (defined in dblayer.h) */
6f51e1
-    hard_limit = (DBLAYER_IMPORTCACHESIZE_HL*1024) / (pagesize/1024);
6f51e1
     /*
6f51e1
      * default behavior for ldif2db import cache,
6f51e1
      * nsslapd-import-cache-autosize==-1,
6f51e1
@@ -1741,48 +1730,29 @@ check_and_set_import_cache(struct ldbminfo *li)
6f51e1
 
6f51e1
     if (li->li_import_cache_autosize == 0) {
6f51e1
         /* user specified importCache */
6f51e1
-        import_pages = li->li_import_cachesize / pagesize;
6f51e1
+        import_cache = li->li_import_cachesize;
6f51e1
 
6f51e1
     } else {
6f51e1
         /* autosizing importCache */
6f51e1
         /* ./125 instead of ./100 is for adjusting the BDB overhead. */
6f51e1
-#ifdef LINUX
6f51e1
-        /* On linux, availpages is correct so we should use it! */
6f51e1
-        import_pages = (li->li_import_cache_autosize * availpages) / 125;
6f51e1
-#else
6f51e1
-        import_pages = (li->li_import_cache_autosize * pages) / 125;
6f51e1
-#endif
6f51e1
+        import_cache = (li->li_import_cache_autosize * mi->system_available_bytes) / 125;
6f51e1
     }
6f51e1
 
6f51e1
-    page_delta = pages - import_pages;
6f51e1
-    if (page_delta < hard_limit) {
6f51e1
-        slapi_log_err(SLAPI_LOG_ERR, 
6f51e1
-            "check_and_set_import_cache", "After allocating import cache %ldKB, "
6f51e1
-            "the available memory is %ldKB, "
6f51e1
-            "which is less than the hard limit %ldKB. "
6f51e1
-            "Please decrease the import cache size and rerun import.\n",
6f51e1
-            import_pages*(pagesize/1024), page_delta*(pagesize/1024),
6f51e1
-            hard_limit*(pagesize/1024));
6f51e1
+    if (util_is_cachesize_sane(mi, &import_cache) == UTIL_CACHESIZE_ERROR) {
6f51e1
+
6f51e1
+        slapi_log_err(SLAPI_LOG_INFO, "check_and_set_import_cache", "Import failed to run: unable to validate system memory limits.\n");
6f51e1
+        spal_meminfo_destroy(mi);
6f51e1
         return ENOMEM;
6f51e1
     }
6f51e1
-    if (page_delta < soft_limit) {
6f51e1
-        slapi_log_err(SLAPI_LOG_WARNING, 
6f51e1
-            "check_and_set_import_cache", "After allocating import cache %ldKB, "
6f51e1
-            "the available memory is %ldKB, "
6f51e1
-            "which is less than the soft limit %ldKB. "
6f51e1
-            "You may want to decrease the import cache size and "
6f51e1
-            "rerun import.\n",
6f51e1
-            import_pages*(pagesize/1024), page_delta*(pagesize/1024),
6f51e1
-            soft_limit*(pagesize/1024));
6f51e1
-    }
6f51e1
 
6f51e1
-    slapi_log_err(SLAPI_LOG_INFO, "check_and_set_import_cache", "Import allocates %ldKB import cache.\n", 
6f51e1
-                  import_pages*(pagesize/1024));
6f51e1
-    if (li->li_import_cache_autosize > 0) { /* import cache autosizing */
6f51e1
+    slapi_log_err(SLAPI_LOG_INFO, "check_and_set_import_cache", "Import allocates %"PRIu64"KB import cache.\n", import_cache / 1024);
6f51e1
+    if (li->li_import_cache_autosize > 0) {
6f51e1
+        /* import cache autosizing */
6f51e1
         /* set the calculated import cache size to the config */
6f51e1
-        sprintf(s, "%lu", (unsigned long)(import_pages * pagesize));
6f51e1
+        sprintf(s, "%"PRIu64, import_cache);
6f51e1
         ldbm_config_internal_set(li, CONFIG_IMPORT_CACHESIZE, s);
6f51e1
     }
6f51e1
+    spal_meminfo_destroy(mi);
6f51e1
     return 0;
6f51e1
 }
6f51e1
 
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.h b/ldap/servers/slapd/back-ldbm/dblayer.h
6f51e1
index e4307fc..816c943 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/dblayer.h
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/dblayer.h
6f51e1
@@ -68,14 +68,6 @@
6f51e1
 #define	DB_REGION_NAME	25		/* DB: named regions, no backing file. */
6f51e1
 #endif
6f51e1
 
6f51e1
-/* Used in check_and_set_import_cache */
6f51e1
-/* After allocating the import cache, free memory must be left more than
6f51e1
- * the hard limit to run import. */
6f51e1
-/* If the free memory size left is greater than hard limit and less than
6f51e1
- * soft limit, the import utility issues a warning, but it runs */
6f51e1
-#define DBLAYER_IMPORTCACHESIZE_HL 100  /* import cache hard limit 100MB */
6f51e1
-#define DBLAYER_IMPORTCACHESIZE_SL 1024 /* import cache soft limit 1GB */
6f51e1
-
6f51e1
 struct dblayer_private_env {
6f51e1
 	DB_ENV	*dblayer_DB_ENV;
6f51e1
 	Slapi_RWLock * dblayer_env_lock;
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
6f51e1
index 087103b..ab32e0a 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
6f51e1
@@ -3979,7 +3979,7 @@ _get_import_entryusn(ImportJob *job, Slapi_Value **usn_value)
6f51e1
              * Use the counter which stores the old DB's
6f51e1
              * next entryusn. */
6f51e1
             PR_snprintf(counter_buf, sizeof(counter_buf),
6f51e1
-                    "%" NSPRIu64, slapi_counter_get_value(be->be_usn_counter));
6f51e1
+                    "%" PRIu64, slapi_counter_get_value(be->be_usn_counter));
6f51e1
         } else {
6f51e1
             /* import_init value is digit.
6f51e1
              * Initialize the entryusn values with the digit */
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
6f51e1
index d0cef1a..7161bac 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/import.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/import.c
6f51e1
@@ -84,17 +84,19 @@ static int import_fifo_init(ImportJob *job)
6f51e1
 int import_fifo_validate_capacity_or_expand(ImportJob *job, size_t entrysize) {
6f51e1
     int result = 1;
6f51e1
     /* We shoot for four times as much to start with. */
6f51e1
-    size_t request = entrysize * 4;
6f51e1
-    int sane = 0;
6f51e1
+    uint64_t request = entrysize * 4;
6f51e1
+    util_cachesize_result sane;
6f51e1
 
6f51e1
     if (entrysize > job->fifo.bsize) {
6f51e1
         /* Check the amount of memory on the system */
6f51e1
-        sane = util_is_cachesize_sane(&request);
6f51e1
-        if (!sane && entrysize <= request) {
6f51e1
+        slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+        sane = util_is_cachesize_sane(mi, &request);
6f51e1
+        spal_meminfo_destroy(mi);
6f51e1
+        if (sane == UTIL_CACHESIZE_REDUCED && entrysize <= request) {
6f51e1
             /* Did the amount cachesize set still exceed entrysize? It'll do ... */
6f51e1
             job->fifo.bsize = request;
6f51e1
             result = 0;
6f51e1
-        } else if (!sane) {
6f51e1
+        } else if (sane != UTIL_CACHESIZE_VALID) {
6f51e1
             /* Can't allocate! No!!! */
6f51e1
             result = 1;
6f51e1
         } else {
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
6f51e1
index dfe7a13..d5120d3 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
6f51e1
@@ -403,8 +403,8 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
6f51e1
 {
6f51e1
     struct ldbminfo *li = (struct ldbminfo *) arg;
6f51e1
     int retval = LDAP_SUCCESS;
6f51e1
-    size_t val = (size_t)value;
6f51e1
-    size_t delta = (size_t)value;
6f51e1
+    uint64_t val = (size_t)value;
6f51e1
+    uint64_t delta = (size_t)value;
6f51e1
 
6f51e1
     /* There is an error here. We check the new val against our current mem-alloc 
6f51e1
      * Issue is that we already are using system pages, so while our value *might*
6f51e1
@@ -430,7 +430,13 @@ static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, i
6f51e1
             val = DBDEFMINSIZ;
6f51e1
         } else if (val > li->li_dbcachesize) {
6f51e1
             delta = val - li->li_dbcachesize;
6f51e1
-            if (!util_is_cachesize_sane(&delta)){
6f51e1
+
6f51e1
+            util_cachesize_result sane;
6f51e1
+            slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+            sane = util_is_cachesize_sane(mi, &delta);
6f51e1
+            spal_meminfo_destroy(mi);
6f51e1
+
6f51e1
+            if (sane != UTIL_CACHESIZE_VALID){
6f51e1
                 slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: nsslapd-dbcachesize value is too large.");
6f51e1
                 slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_dbcachesize_set",
6f51e1
                         "nsslapd-dbcachesize value is too large.\n");
6f51e1
@@ -1086,7 +1092,7 @@ static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int
6f51e1
     struct ldbminfo *li = (struct ldbminfo *) arg;
6f51e1
     int retval = LDAP_SUCCESS;
6f51e1
     int val = ((uintptr_t)value);
6f51e1
-    size_t delta = 0;
6f51e1
+    uint64_t delta = 0;
6f51e1
 
6f51e1
     /* There is an error here. We check the new val against our current mem-alloc 
6f51e1
      * Issue is that we already are using system pages, so while our value *might*
6f51e1
@@ -1101,7 +1107,13 @@ static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int
6f51e1
     if (apply) {
6f51e1
         if (val > li->li_dblayer_private->dblayer_cache_config) {
6f51e1
             delta = val - li->li_dblayer_private->dblayer_cache_config;
6f51e1
-            if (!util_is_cachesize_sane(&delta)){
6f51e1
+            util_cachesize_result sane;
6f51e1
+
6f51e1
+            slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+            sane = util_is_cachesize_sane(mi, &delta);
6f51e1
+            spal_meminfo_destroy(mi);
6f51e1
+
6f51e1
+            if (sane != UTIL_CACHESIZE_VALID){
6f51e1
                 slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: db cachesize value is too large");
6f51e1
                 slapi_log_err(SLAPI_LOG_ERR,"ldbm_config_db_cache_set", "db cachesize value is too large.\n");
6f51e1
                 return LDAP_UNWILLING_TO_PERFORM;
6f51e1
@@ -1219,7 +1231,7 @@ static int ldbm_config_import_cachesize_set(void *arg, void *value, char *errorb
6f51e1
 {
6f51e1
     struct ldbminfo *li = (struct ldbminfo *)arg;
6f51e1
     size_t val = (size_t)value;
6f51e1
-    size_t delta = (size_t)value;
6f51e1
+    uint64_t delta = (size_t)value;
6f51e1
     /* There is an error here. We check the new val against our current mem-alloc 
6f51e1
      * Issue is that we already are using system pages, so while our value *might*
6f51e1
      * be valid, we may reject it here due to the current procs page usage.
6f51e1
@@ -1232,7 +1244,13 @@ static int ldbm_config_import_cachesize_set(void *arg, void *value, char *errorb
6f51e1
     if (apply){
6f51e1
         if (val > li->li_import_cachesize) {
6f51e1
             delta = val - li->li_import_cachesize;
6f51e1
-            if (!util_is_cachesize_sane(&delta)){
6f51e1
+
6f51e1
+            util_cachesize_result sane;
6f51e1
+            slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+            sane = util_is_cachesize_sane(mi, &delta);
6f51e1
+            spal_meminfo_destroy(mi);
6f51e1
+
6f51e1
+            if (sane != UTIL_CACHESIZE_VALID){
6f51e1
                 slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: import cachesize value is too large.");
6f51e1
                 slapi_log_err(SLAPI_LOG_ERR,"ldbm_config_import_cachesize_set",
6f51e1
                         "Import cachesize value is too large.\n");
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
6f51e1
index 92d982e..0b0b37e 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
6f51e1
@@ -107,7 +107,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
6f51e1
 
6f51e1
 	if (pb->pb_conn)
6f51e1
 	{
6f51e1
-		slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_delete", "Enter conn=%" NSPRIu64 " op=%d\n",
6f51e1
+		slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_delete", "Enter conn=%" PRIu64 " op=%d\n",
6f51e1
 				pb->pb_conn->c_connid, operation->o_opid);
6f51e1
 	}
6f51e1
 
6f51e1
@@ -1493,7 +1493,7 @@ diskfull_return:
6f51e1
 	slapi_sdn_done(&parentsdn);
6f51e1
 	if (pb->pb_conn)
6f51e1
 	{
6f51e1
-		slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_delete", "leave conn=%" NSPRIu64 " op=%d\n",
6f51e1
+		slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_delete", "leave conn=%" PRIu64 " op=%d\n",
6f51e1
 				pb->pb_conn->c_connid, operation->o_opid);
6f51e1
 	}
6f51e1
 
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
6f51e1
index e03954d..62cdbc3 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
6f51e1
@@ -92,7 +92,7 @@ ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, in
6f51e1
     ldbm_instance *inst = (ldbm_instance *) arg;
6f51e1
     int retval = LDAP_SUCCESS;
6f51e1
     size_t val = (size_t) value;
6f51e1
-    size_t delta = 0;
6f51e1
+    uint64_t delta = 0;
6f51e1
 
6f51e1
     /* Do whatever we can to make sure the data is ok. */
6f51e1
     /* There is an error here. We check the new val against our current mem-alloc 
6f51e1
@@ -108,7 +108,13 @@ ldbm_instance_config_cachememsize_set(void *arg, void *value, char *errorbuf, in
6f51e1
     if (apply) {
6f51e1
         if (val > inst->inst_cache.c_maxsize) {
6f51e1
             delta = val - inst->inst_cache.c_maxsize;
6f51e1
-            if (!util_is_cachesize_sane(&delta)){
6f51e1
+
6f51e1
+            util_cachesize_result sane;
6f51e1
+            slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+            sane = util_is_cachesize_sane(mi, &delta);
6f51e1
+            spal_meminfo_destroy(mi);
6f51e1
+
6f51e1
+            if (sane != UTIL_CACHESIZE_VALID){
6f51e1
                 slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: cachememsize value is too large.");
6f51e1
                 slapi_log_err(SLAPI_LOG_ERR, "ldbm_instance_config_cachememsize_set", "cachememsize value is too large.\n");
6f51e1
                 return LDAP_UNWILLING_TO_PERFORM;
6f51e1
@@ -134,7 +140,7 @@ ldbm_instance_config_dncachememsize_set(void *arg, void *value, char *errorbuf,
6f51e1
     ldbm_instance *inst = (ldbm_instance *) arg;
6f51e1
     int retval = LDAP_SUCCESS;
6f51e1
     size_t val = (size_t)value;
6f51e1
-    size_t delta = 0;
6f51e1
+    uint64_t delta = 0;
6f51e1
 
6f51e1
     /* Do whatever we can to make sure the data is ok. */
6f51e1
     /* There is an error here. We check the new val against our current mem-alloc 
6f51e1
@@ -150,7 +156,13 @@ ldbm_instance_config_dncachememsize_set(void *arg, void *value, char *errorbuf,
6f51e1
     if (apply) {
6f51e1
         if (val > inst->inst_dncache.c_maxsize) {
6f51e1
             delta = val - inst->inst_dncache.c_maxsize;
6f51e1
-            if (!util_is_cachesize_sane(&delta)){
6f51e1
+
6f51e1
+            util_cachesize_result sane;
6f51e1
+            slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+            sane = util_is_cachesize_sane(mi, &delta);
6f51e1
+            spal_meminfo_destroy(mi);
6f51e1
+
6f51e1
+            if (sane != UTIL_CACHESIZE_VALID){
6f51e1
                 slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
6f51e1
                     "Error: dncachememsize value is too large.");
6f51e1
                 slapi_log_err(SLAPI_LOG_ERR,"ldbm_instance_config_dncachememsize_set",
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
6f51e1
index a78d850..533273b 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
6f51e1
@@ -142,7 +142,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
6f51e1
 
6f51e1
     if (pb->pb_conn)
6f51e1
     {
6f51e1
-        slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_modrdn", "enter conn=%" NSPRIu64 " op=%d\n",
6f51e1
+        slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_modrdn", "enter conn=%" PRIu64 " op=%d\n",
6f51e1
                 pb->pb_conn->c_connid, operation->o_opid);
6f51e1
     }
6f51e1
 
6f51e1
@@ -1539,7 +1539,7 @@ common_return:
6f51e1
     if (pb->pb_conn)
6f51e1
     {
6f51e1
         slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_modrdn",
6f51e1
-                "leave conn=%" NSPRIu64 " op=%d\n",
6f51e1
+                "leave conn=%" PRIu64 " op=%d\n",
6f51e1
                 pb->pb_conn->c_connid, operation->o_opid);
6f51e1
     }
6f51e1
     return retval;
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
6f51e1
index a6c3b74..cfb0d6b 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
6f51e1
@@ -407,7 +407,7 @@ ldbm_back_search( Slapi_PBlock *pb )
6f51e1
                     slapi_pblock_get(pb, SLAPI_OPERATION_ID, &op_id);
6f51e1
 
6f51e1
                     slapi_log_err(SLAPI_LOG_WARNING,
6f51e1
-                            "ldbm_back_search", "Sort control ignored for conn=%" NSPRIu64 " op=%d\n",
6f51e1
+                            "ldbm_back_search", "Sort control ignored for conn=%" PRIu64 " op=%d\n",
6f51e1
                             conn_id, op_id);                    
6f51e1
                 }
6f51e1
             } else {
6f51e1
@@ -442,7 +442,7 @@ ldbm_back_search( Slapi_PBlock *pb )
6f51e1
                         slapi_pblock_get(pb, SLAPI_OPERATION_ID, &op_id);
6f51e1
 
6f51e1
                         slapi_log_err(SLAPI_LOG_WARNING,
6f51e1
-                                "ldbm_back_search", "VLV control ignored for conn=%" NSPRIu64 " op=%d\n",
6f51e1
+                                "ldbm_back_search", "VLV control ignored for conn=%" PRIu64 " op=%d\n",
6f51e1
                                 conn_id, op_id);             
6f51e1
                     }
6f51e1
 
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/misc.c b/ldap/servers/slapd/back-ldbm/misc.c
6f51e1
index 5268087..7192b3a 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/misc.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/misc.c
6f51e1
@@ -54,7 +54,7 @@ void ldbm_log_access_message(Slapi_PBlock *pblock,char *string)
6f51e1
         return;
6f51e1
     }
6f51e1
     operation_id = operation->o_opid;
6f51e1
-    slapi_log_access(LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d %s\n",
6f51e1
+    slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d %s\n",
6f51e1
                      connection_id, operation_id, string);
6f51e1
 }
6f51e1
 
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
6f51e1
index 757792b..c58b069 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/monitor.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
6f51e1
@@ -101,9 +101,9 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
6f51e1
         /* fetch cache statistics */
6f51e1
         cache_get_stats(&(inst->inst_dncache), &hits, &tries, 
6f51e1
                         &nentries, &maxentries, &size, &maxsize);
6f51e1
-        sprintf(buf, "%" NSPRIu64, hits);
6f51e1
+        sprintf(buf, "%" PRIu64, hits);
6f51e1
         MSET("dnCacheHits");
6f51e1
-        sprintf(buf, "%" NSPRIu64, tries);
6f51e1
+        sprintf(buf, "%" PRIu64, tries);
6f51e1
         MSET("dnCacheTries");
6f51e1
         sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
6f51e1
         MSET("dnCacheHitRatio");
6f51e1
@@ -119,11 +119,11 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
6f51e1
     /* normalized dn cache stats */
6f51e1
     if(ndn_cache_started()){
6f51e1
         ndn_cache_get_stats(&hits, &tries, &size, &maxsize, &count);
6f51e1
-        sprintf(buf, "%" NSPRIu64, tries);
6f51e1
+        sprintf(buf, "%" PRIu64, tries);
6f51e1
         MSET("normalizedDnCacheTries");
6f51e1
-        sprintf(buf, "%" NSPRIu64, hits);
6f51e1
+        sprintf(buf, "%" PRIu64, hits);
6f51e1
         MSET("normalizedDnCacheHits");
6f51e1
-        sprintf(buf, "%" NSPRIu64, (tries - hits));
6f51e1
+        sprintf(buf, "%" PRIu64, (tries - hits));
6f51e1
         MSET("normalizedDnCacheMisses");
6f51e1
         sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
6f51e1
         MSET("normalizedDnCacheHitRatio");
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.h b/ldap/servers/slapd/back-ldbm/perfctrs.h
6f51e1
index 57be1d1..64c79e1 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/perfctrs.h
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/perfctrs.h
6f51e1
@@ -11,7 +11,7 @@
6f51e1
 #  include <config.h>
6f51e1
 #endif
6f51e1
 
6f51e1
-#include <inttypes.h>
6f51e1
+#include <slapi_pal.h>
6f51e1
 
6f51e1
 /* Structure definition for performance data */
6f51e1
 /* This stuff goes in shared memory, so make sure the packing is consistent */
6f51e1
diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c
6f51e1
index 1ae9858..a207bd8 100644
6f51e1
--- a/ldap/servers/slapd/back-ldbm/start.c
6f51e1
+++ b/ldap/servers/slapd/back-ldbm/start.c
6f51e1
@@ -32,34 +32,25 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
     Object *inst_obj = NULL;
6f51e1
     ldbm_instance *inst = NULL;
6f51e1
     /* size_t is a platform unsigned int, IE uint64_t */
6f51e1
-    size_t total_cache_size = 0;
6f51e1
-    size_t pagesize = 0;
6f51e1
-    size_t pages = 0;
6f51e1
-    size_t procpages __attribute__((unused)) = 0;
6f51e1
-    size_t availpages = 0;
6f51e1
-    size_t cache_size_to_configure = 0;
6f51e1
-    size_t zone_pages = 0;
6f51e1
-    size_t db_pages = 0;
6f51e1
-    size_t entry_pages = 0;
6f51e1
-    size_t import_pages = 0;
6f51e1
-    size_t zone_size = 0;
6f51e1
-    size_t import_size = 0;
6f51e1
-    size_t cache_size = 0;
6f51e1
-    size_t db_size = 0;
6f51e1
+    uint64_t total_cache_size = 0;
6f51e1
+    uint64_t entry_size = 0;
6f51e1
+    uint64_t zone_size = 0;
6f51e1
+    uint64_t import_size = 0;
6f51e1
+    uint64_t cache_size = 0;
6f51e1
+    uint64_t db_size = 0;
6f51e1
     /* For clamping the autotune value to a 64Mb boundary */
6f51e1
-    size_t clamp_pages = 0;
6f51e1
-    size_t clamp_div = 0;
6f51e1
-    size_t clamp_mod = 0;
6f51e1
+    uint64_t clamp_div = 0;
6f51e1
     /* Backend count */
6f51e1
-    size_t backend_count = 0;
6f51e1
+    uint64_t backend_count = 0;
6f51e1
 
6f51e1
     int_fast32_t autosize_percentage = 0;
6f51e1
     int_fast32_t autosize_db_percentage_split = 0;
6f51e1
     int_fast32_t import_percentage = 0;
6f51e1
-    int32_t issane = 0;
6f51e1
+    util_cachesize_result issane;
6f51e1
     char *msg = ""; /* This will be set by one of the two cache sizing paths below. */
6f51e1
     char size_to_str[32];    /* big enough to hold %ld */
6f51e1
 
6f51e1
+
6f51e1
     /* == Begin autotune == */
6f51e1
 
6f51e1
     /*
6f51e1
@@ -120,42 +111,34 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
         return SLAPI_FAIL_GENERAL;
6f51e1
     }
6f51e1
 
6f51e1
-    if (util_info_sys_pages(&pagesize, &pages, &procpages, &availpages) != 0) {
6f51e1
+    /* Get our platform memory values. */
6f51e1
+    slapi_pal_meminfo *mi = spal_meminfo_get();
6f51e1
+    if (mi == NULL) {
6f51e1
         slapi_log_err(SLAPI_LOG_CRIT, "ldbm_back_start", "Unable to determine system page limits\n");
6f51e1
         return SLAPI_FAIL_GENERAL;
6f51e1
     }
6f51e1
 
6f51e1
-    if (pagesize == 0) {
6f51e1
-        /* If this happens, we are in a very bad state indeed... */
6f51e1
-        slapi_log_err(SLAPI_LOG_CRIT, "ldbm_back_start", "Unable to determine system page size\n");
6f51e1
-        return SLAPI_FAIL_GENERAL;
6f51e1
-    }
6f51e1
-
6f51e1
     /* calculate the needed values */
6f51e1
-    zone_pages = (autosize_percentage * pages) / 100;
6f51e1
-    zone_size = zone_pages * pagesize;
6f51e1
+    zone_size = (autosize_percentage * mi->system_total_bytes) / 100;
6f51e1
     /* This is how much we "might" use, lets check it's sane. */
6f51e1
     /* In the case it is not, this will *reduce* the allocation */
6f51e1
-    issane = util_is_cachesize_sane(&zone_size);
6f51e1
-    if (!issane) {
6f51e1
+    issane = util_is_cachesize_sane(mi, &zone_size);
6f51e1
+    if (issane == UTIL_CACHESIZE_REDUCED) {
6f51e1
         slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "Your autosized cache values have been reduced. Likely your nsslapd-cache-autosize percentage is too high.\n");
6f51e1
         slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "%s", msg);
6f51e1
     }
6f51e1
     /* It's valid, lets divide it up and set according to user prefs */
6f51e1
-    zone_pages = zone_size / pagesize;
6f51e1
-    db_pages = (autosize_db_percentage_split * zone_pages) / 100;
6f51e1
+    db_size = (autosize_db_percentage_split * zone_size) / 100;
6f51e1
 
6f51e1
     /* Cap the DB size at 512MB, as this doesn't help perf much more (lkrispen's advice) */
6f51e1
-    if ((db_pages * pagesize) > (512 * MEGABYTE)) {
6f51e1
-        db_pages = (512 * MEGABYTE) / pagesize;
6f51e1
+    if (db_size > (512 * MEGABYTE)) {
6f51e1
+        db_size = (512 * MEGABYTE);
6f51e1
     }
6f51e1
 
6f51e1
     if (backend_count > 0 ) {
6f51e1
         /* Number of entry cache pages per backend. */
6f51e1
-        entry_pages = (zone_pages - db_pages) / backend_count;
6f51e1
+        entry_size = (zone_size - db_size) / backend_count;
6f51e1
         /* Now, clamp this value to a 64mb boundary. */
6f51e1
-        /* How many pages are in 64mb? */
6f51e1
-        clamp_pages = (64 * MEGABYTE) / pagesize;
6f51e1
         /* Now divide the entry pages by this, and also mod. If mod != 0, we need
6f51e1
          * to add 1 to the diveded number. This should give us:
6f51e1
          * 510 * 1024 * 1024 == 510MB
6f51e1
@@ -166,17 +149,15 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
          * 130560 % 16384 = 15872 which is != 0
6f51e1
          * therfore 7 + 1, aka 8 * 16384 = 131072 pages = 536870912 bytes = 512MB.
6f51e1
          */
6f51e1
-        clamp_div = entry_pages / clamp_pages;
6f51e1
-        clamp_mod = entry_pages % clamp_pages;
6f51e1
-        if (clamp_mod != 0) {
6f51e1
-            /* If we want to clamp down, remove this line. This would change the above from 510mb -> 448mb. */
6f51e1
-            clamp_div += 1;
6f51e1
-            entry_pages = clamp_div * clamp_pages;
6f51e1
+        if (entry_size % (64 * MEGABYTE) != 0) {
6f51e1
+            /* If we want to clamp down, remove the "+1". This would change the above from 510mb -> 448mb. */
6f51e1
+            clamp_div = (entry_size / (64 * MEGABYTE)) + 1;
6f51e1
+            entry_size = clamp_div * (64 * MEGABYTE);
6f51e1
         }
6f51e1
     }
6f51e1
 
6f51e1
-    slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk physical memory\n", pages*(pagesize/1024));
6f51e1
-    slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk avaliable\n", zone_pages*(pagesize/1024));
6f51e1
+    slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk physical memory\n", mi->system_total_bytes / 1024);
6f51e1
+    slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk avaliable\n", mi->system_available_bytes / 1024);
6f51e1
 
6f51e1
     /* We've now calculated the autotuning values. Do we need to apply it?
6f51e1
      * we use the logic of "if size is 0, or autosize is > 0. This way three
6f51e1
@@ -191,13 +172,12 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
 
6f51e1
     /* First, check the dbcache */
6f51e1
     if (li->li_dbcachesize == 0 || li->li_cache_autosize > 0) {
6f51e1
-        slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: db cache: %luk\n", db_pages*(pagesize/1024));
6f51e1
-        cache_size_to_configure = (unsigned long)(db_pages * pagesize);
6f51e1
-        if (cache_size_to_configure < (500 * MEGABYTE)) {
6f51e1
-            cache_size_to_configure = (unsigned long)((db_pages * pagesize) / 1.25);
6f51e1
+        slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: db cache: %luk\n", db_size / 1024);
6f51e1
+        if (db_size < (500 * MEGABYTE)) {
6f51e1
+            db_size = db_size / 1.25;
6f51e1
         }
6f51e1
         /* Have to set this value through text. */
6f51e1
-        sprintf(size_to_str, "%lu", cache_size_to_configure);
6f51e1
+        sprintf(size_to_str, "%" PRIu64 , db_size);
6f51e1
         ldbm_config_internal_set(li, CONFIG_DBCACHESIZE, size_to_str);
6f51e1
     }
6f51e1
     total_cache_size += li->li_dbcachesize;
6f51e1
@@ -205,7 +185,7 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
     /* For each backend */
6f51e1
     /*   apply the appropriate cache size if 0 */
6f51e1
     if (backend_count > 0 ) {
6f51e1
-        li->li_cache_autosize_ec = (unsigned long)entry_pages * pagesize;
6f51e1
+        li->li_cache_autosize_ec = entry_size;
6f51e1
     }
6f51e1
 
6f51e1
     for (inst_obj = objset_first_obj(li->li_instance_set); inst_obj;
6f51e1
@@ -220,7 +200,7 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
          * it's highly unlikely.
6f51e1
          */
6f51e1
         if (cache_size == 0 || cache_size == MINCACHESIZE || li->li_cache_autosize > 0) {
6f51e1
-            slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s entry cache (%lu total): %luk\n", inst->inst_name, backend_count, entry_pages*(pagesize/1024));
6f51e1
+            slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s entry cache (%lu total): %luk\n", inst->inst_name, backend_count, entry_size / 1024);
6f51e1
             cache_set_max_entries(&(inst->inst_cache), -1);
6f51e1
             cache_set_max_size(&(inst->inst_cache), li->li_cache_autosize_ec, CACHE_TYPE_ENTRY);
6f51e1
         }
6f51e1
@@ -229,8 +209,8 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
         db_size = dblayer_get_id2entry_size(inst);
6f51e1
         if (cache_size < db_size) {
6f51e1
             slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start",
6f51e1
-                  "%s: entry cache size %lu B is "
6f51e1
-                  "less than db size %lu B; "
6f51e1
+                  "%s: entry cache size %"PRIu64" B is "
6f51e1
+                  "less than db size %"PRIu64" B; "
6f51e1
                   "We recommend to increase the entry cache size "
6f51e1
                   "nsslapd-cachememsize.\n",
6f51e1
                   inst->inst_name, cache_size, db_size);
6f51e1
@@ -244,37 +224,36 @@ ldbm_back_start_autotune(struct ldbminfo *li) {
6f51e1
     /* autosizing importCache */
6f51e1
     if (li->li_import_cache_autosize > 0) {
6f51e1
         /* Use import percentage here, as it's been corrected for -1 behaviour */
6f51e1
-        import_pages = (import_percentage * pages) / 100;
6f51e1
-        import_size = import_pages * pagesize;
6f51e1
-        issane = util_is_cachesize_sane(&import_size);
6f51e1
-        if (!issane) {
6f51e1
+        import_size = (import_percentage * mi->system_total_bytes) / 100;
6f51e1
+        issane = util_is_cachesize_sane(mi, &import_size);
6f51e1
+        if (issane == UTIL_CACHESIZE_REDUCED) {
6f51e1
             slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "Your autosized import cache values have been reduced. Likely your nsslapd-import-cache-autosize percentage is too high.\n");
6f51e1
         }
6f51e1
         /* We just accept the reduced allocation here. */
6f51e1
-        import_pages = import_size / pagesize;
6f51e1
-        slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: import cache: %luk\n",
6f51e1
-        import_pages*(pagesize/1024));
6f51e1
+        slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: import cache: %"PRIu64"k\n", import_size / 1024);
6f51e1
 
6f51e1
-        sprintf(size_to_str, "%lu", (unsigned long)(import_pages * pagesize));
6f51e1
+        sprintf(size_to_str, "%"PRIu64, import_size);
6f51e1
         ldbm_config_internal_set(li, CONFIG_IMPORT_CACHESIZE, size_to_str);
6f51e1
     }
6f51e1
 
6f51e1
     /* Finally, lets check that the total result is sane. */
6f51e1
-    slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "total cache size: %lu B; \n", total_cache_size);
6f51e1
+    slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "total cache size: %"PRIu64" B; \n", total_cache_size);
6f51e1
 
6f51e1
-    issane = util_is_cachesize_sane(&total_cache_size);
6f51e1
-    if (!issane) {
6f51e1
+    issane = util_is_cachesize_sane(mi, &total_cache_size);
6f51e1
+    if (issane != UTIL_CACHESIZE_VALID) {
6f51e1
         /* Right, it's time to panic */
6f51e1
         slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "It is highly likely your memory configuration of all backends will EXCEED your systems memory.\n");
6f51e1
         slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "In a future release this WILL prevent server start up. You MUST alter your configuration.\n");
6f51e1
-        slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "Total entry cache size: %lu B; dbcache size: %lu B; available memory size: %lu B; \n",
6f51e1
-                  (PRUint64)total_cache_size, (PRUint64)li->li_dbcachesize, availpages * pagesize
6f51e1
+        slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "Total entry cache size: %"PRIu64" B; dbcache size: %"PRIu64" B; available memory size: %"PRIu64" B; \n",
6f51e1
+                    total_cache_size, (uint64_t)li->li_dbcachesize, mi->system_available_bytes
6f51e1
         );
6f51e1
         slapi_log_err(SLAPI_LOG_WARNING, "ldbm_back_start", "%s\n", msg);
6f51e1
         /* WB 2016 - This should be UNCOMMENTED in a future release */
6f51e1
         /* return SLAPI_FAIL_GENERAL; */
6f51e1
     }
6f51e1
 
6f51e1
+    spal_meminfo_destroy(mi);
6f51e1
+
6f51e1
     /* == End autotune == */
6f51e1
     return 0;
6f51e1
 }
6f51e1
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
6f51e1
index f83df7d..648a0f9 100644
6f51e1
--- a/ldap/servers/slapd/bind.c
6f51e1
+++ b/ldap/servers/slapd/bind.c
6f51e1
@@ -853,25 +853,25 @@ log_bind_access (
6f51e1
 {
6f51e1
     if (method == LDAP_AUTH_SASL && saslmech && msg) {
6f51e1
         slapi_log_access( LDAP_DEBUG_STATS, 
6f51e1
-                          "conn=%" NSPRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
+                          "conn=%" PRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
                           "method=sasl version=%d mech=%s, %s\n",
6f51e1
                           pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
6f51e1
                           version, saslmech, msg );
6f51e1
     } else if (method == LDAP_AUTH_SASL && saslmech) {
6f51e1
         slapi_log_access( LDAP_DEBUG_STATS, 
6f51e1
-                          "conn=%" NSPRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
+                          "conn=%" PRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
                           "method=sasl version=%d mech=%s\n",
6f51e1
                           pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
6f51e1
                           version, saslmech );
6f51e1
     } else if (msg) {
6f51e1
         slapi_log_access( LDAP_DEBUG_STATS, 
6f51e1
-                          "conn=%" NSPRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
+                          "conn=%" PRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
                           "method=%" BERTAG_T " version=%d, %s\n",
6f51e1
                           pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
6f51e1
                           method, version, msg );
6f51e1
     } else {
6f51e1
         slapi_log_access( LDAP_DEBUG_STATS, 
6f51e1
-                          "conn=%" NSPRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
+                          "conn=%" PRIu64 " op=%d BIND dn=\"%s\" "
6f51e1
                           "method=%" BERTAG_T " version=%d\n",
6f51e1
                           pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
6f51e1
                           method, version );
6f51e1
diff --git a/ldap/servers/slapd/compare.c b/ldap/servers/slapd/compare.c
6f51e1
index 07ded98..3c03053 100644
6f51e1
--- a/ldap/servers/slapd/compare.c
6f51e1
+++ b/ldap/servers/slapd/compare.c
6f51e1
@@ -111,7 +111,7 @@ do_compare( Slapi_PBlock *pb )
6f51e1
 	    rawdn, ava.ava_type, 0 );
6f51e1
 
6f51e1
 	slapi_log_access( LDAP_DEBUG_STATS,
6f51e1
-	    "conn=%" NSPRIu64 " op=%d CMP dn=\"%s\" attr=\"%s\"\n",
6f51e1
+	    "conn=%" PRIu64 " op=%d CMP dn=\"%s\" attr=\"%s\"\n",
6f51e1
 	    pb->pb_conn->c_connid, pb->pb_op->o_opid, dn, ava.ava_type );
6f51e1
 
6f51e1
 	/*
6f51e1
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
6f51e1
index 7c83c66..359b59a 100644
6f51e1
--- a/ldap/servers/slapd/connection.c
6f51e1
+++ b/ldap/servers/slapd/connection.c
6f51e1
@@ -411,7 +411,7 @@ connection_reset(Connection* conn, int ns, PRNetAddr * from, int fromLen, int is
6f51e1
 
6f51e1
     /* log useful stuff to our access log */
6f51e1
     slapi_log_access( LDAP_DEBUG_STATS,
6f51e1
-        "conn=%" NSPRIu64 " fd=%d slot=%d %sconnection from %s to %s\n",
6f51e1
+        "conn=%" PRIu64 " fd=%d slot=%d %sconnection from %s to %s\n",
6f51e1
         conn->c_connid, conn->c_sd, ns, pTmp, str_ip, str_destip );
6f51e1
 
6f51e1
     /* initialize the remaining connection fields */
6f51e1
@@ -511,7 +511,7 @@ connection_need_new_password(const Connection *conn, const Operation *op, Slapi_
6f51e1
 		op->o_tag != LDAP_REQ_ABANDON && op->o_tag != LDAP_REQ_EXTENDED)
6f51e1
 	{
6f51e1
 		slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);	
6f51e1
-		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" NSPRIu64 " op=%d %s\n",
6f51e1
+		slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d %s\n",
6f51e1
 			pb->pb_conn->c_connid, pb->pb_op->o_opid,
6f51e1
 			"UNPROCESSED OPERATION - need new password" );
6f51e1
 		send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, 
6f51e1
@@ -562,7 +562,7 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
6f51e1
 	    (op->o_tag != LDAP_REQ_EXTENDED) && (op->o_tag != LDAP_REQ_UNBIND) &&
6f51e1
 	    (op->o_tag != LDAP_REQ_ABANDON)) {
6f51e1
 		slapi_log_access( LDAP_DEBUG_STATS,
6f51e1
-			"conn=%" NSPRIu64 " op=%d UNPROCESSED OPERATION"
6f51e1
+			"conn=%" PRIu64 " op=%d UNPROCESSED OPERATION"
6f51e1
 			" - Insufficient SSF (local_ssf=%d sasl_ssf=%d ssl_ssf=%d)\n",
6f51e1
 			conn->c_connid, op->o_opid, conn->c_local_ssf,
6f51e1
 			conn->c_sasl_ssf, conn->c_ssl_ssf );
6f51e1
@@ -591,7 +591,7 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
6f51e1
 	    (op->o_tag != LDAP_REQ_ABANDON) && (op->o_tag != LDAP_REQ_SEARCH))))
6f51e1
 	{
6f51e1
 		slapi_log_access( LDAP_DEBUG_STATS,
6f51e1
-			"conn=%" NSPRIu64 " op=%d UNPROCESSED OPERATION"
6f51e1
+			"conn=%" PRIu64 " op=%d UNPROCESSED OPERATION"
6f51e1
 			" - Anonymous access not allowed\n",
6f51e1
 			conn->c_connid, op->o_opid );
6f51e1
 
6f51e1
@@ -650,7 +650,7 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
6f51e1
 			int ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
6f51e1
 			if (ret < 0) {
6f51e1
 				slapi_log_err(SLAPI_LOG_ERR, "connection_dispatch_operation",
6f51e1
-					"Failed to set TCP_CORK on connection %" NSPRIu64 "\n",conn->c_connid);
6f51e1
+					"Failed to set TCP_CORK on connection %" PRIu64 "\n",conn->c_connid);
6f51e1
 			}
6f51e1
 			pop_cork = 1;
6f51e1
 		}
6f51e1
@@ -664,7 +664,7 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
6f51e1
 			int ret = setsockopt(conn->c_sd,IPPROTO_TCP,TCP_CORK,&i,sizeof(i));
6f51e1
 			if (ret < 0) {
6f51e1
 				slapi_log_err(SLAPI_LOG_ERR, "connection_dispatch_operation",
6f51e1
-					"Failed to clear TCP_CORK on connection %" NSPRIu64 "\n",conn->c_connid);
6f51e1
+					"Failed to clear TCP_CORK on connection %" PRIu64 "\n",conn->c_connid);
6f51e1
 			}
6f51e1
 		}
6f51e1
 #endif
6f51e1
@@ -690,7 +690,7 @@ connection_dispatch_operation(Connection *conn, Operation *op, Slapi_PBlock *pb)
6f51e1
 
6f51e1
 	default:
6f51e1
 		slapi_log_err(SLAPI_LOG_ERR,
6f51e1
-		    "connection_dispatch_operation", "Ignoring unknown LDAP request (conn=%" NSPRIu64 ", tag=0x%lx)\n",
6f51e1
+		    "connection_dispatch_operation", "Ignoring unknown LDAP request (conn=%" PRIu64 ", tag=0x%lx)\n",
6f51e1
 		    conn->c_connid, op->o_tag);
6f51e1
 		break;
6f51e1
 	}
6f51e1
@@ -702,7 +702,7 @@ int connection_release_nolock_ext (Connection *conn, int release_only)
6f51e1
     if (conn->c_refcnt <= 0)
6f51e1
     {
6f51e1
         slapi_log_err(SLAPI_LOG_ERR, "connection_release_nolock_ext",
6f51e1
-		                "conn=%" NSPRIu64 " fd=%d Attempt to release connection that is not acquired\n",
6f51e1
+		                "conn=%" PRIu64 " fd=%d Attempt to release connection that is not acquired\n",
6f51e1
 		                conn->c_connid, conn->c_sd);
6f51e1
         PR_ASSERT (PR_FALSE);
6f51e1
         return -1;
6f51e1
@@ -734,7 +734,7 @@ int connection_acquire_nolock_ext (Connection *conn, int allow_when_closing)