Blame SOURCES/0001-Ticket-49305-Need-to-wrap-atomic-calls.patch

058656
From 76e8c99e00f776fdab6cf834923d19f911f06fb9 Mon Sep 17 00:00:00 2001
058656
From: Mark Reynolds <mreynolds@redhat.com>
058656
Date: Thu, 28 Sep 2017 10:38:20 -0400
058656
Subject: [PATCH] Ticket 49305 - Need to wrap atomic calls
058656
058656
Bug Description:  Some RHEL 7.5 platforms (ppc 32bit) still do not support
058656
                  all the gcc built-in atomics.  This breaks the downstream
058656
                  builds.
058656
058656
Fix Description:  Use wrapper functions for the atomic's using #define's
058656
                  to detect if builtin atomics are supported, otherwise
058656
                  use the generic nspr atomic functions.
058656
058656
https://pagure.io/389-ds-base/issue/49305
058656
058656
Reviewed by: tbordaz, lkrispen, and wibrown(Thanks!!!)
058656
058656
(cherry picked from commit 93a29584ddae52497b898b451c2c810244627acb)
058656
---
058656
 ldap/servers/slapd/attrsyntax.c        |   8 +-
058656
 ldap/servers/slapd/back-ldbm/dblayer.c |   8 +-
058656
 ldap/servers/slapd/entry.c             |   8 +-
058656
 ldap/servers/slapd/libglobs.c          | 154 ++++++++++++++++-----------------
058656
 ldap/servers/slapd/log.c               |   9 +-
058656
 ldap/servers/slapd/mapping_tree.c      |  28 +++---
058656
 ldap/servers/slapd/object.c            |   7 +-
058656
 ldap/servers/slapd/psearch.c           |   7 +-
058656
 ldap/servers/slapd/slapi-plugin.h      |  65 ++++++++++----
058656
 ldap/servers/slapd/slapi_counter.c     | 113 +++++++++++++-----------
058656
 10 files changed, 223 insertions(+), 184 deletions(-)
058656
058656
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
058656
index a0a60c4..1a9efef 100644
058656
--- a/ldap/servers/slapd/attrsyntax.c
058656
+++ b/ldap/servers/slapd/attrsyntax.c
058656
@@ -274,7 +274,7 @@ attr_syntax_get_by_oid_locking_optional(const char *oid, PRBool use_lock, PRUint
058656
         }
058656
         asi = (struct asyntaxinfo *)PL_HashTableLookup_const(ht, oid);
058656
         if (asi) {
058656
-            slapi_atomic_incr(&(asi->asi_refcnt), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+            slapi_atomic_incr_64(&(asi->asi_refcnt), __ATOMIC_RELEASE);
058656
         }
058656
         if (use_lock) {
058656
             AS_UNLOCK_READ(oid2asi_lock);
058656
@@ -371,7 +371,7 @@ attr_syntax_get_by_name_locking_optional(const char *name, PRBool use_lock, PRUi
058656
         }
058656
         asi = (struct asyntaxinfo *)PL_HashTableLookup_const(ht, name);
058656
         if (NULL != asi) {
058656
-            slapi_atomic_incr(&(asi->asi_refcnt), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+            slapi_atomic_incr_64(&(asi->asi_refcnt), __ATOMIC_RELEASE);
058656
         }
058656
         if (use_lock) {
058656
             AS_UNLOCK_READ(name2asi_lock);
058656
@@ -406,7 +406,7 @@ attr_syntax_return_locking_optional(struct asyntaxinfo *asi, PRBool use_lock)
058656
     }
058656
     if (NULL != asi) {
058656
         PRBool delete_it = PR_FALSE;
058656
-        if (0 == slapi_atomic_decr(&(asi->asi_refcnt), __ATOMIC_ACQ_REL, ATOMIC_LONG)) {
058656
+        if (0 == slapi_atomic_decr_64(&(asi->asi_refcnt), __ATOMIC_ACQ_REL)) {
058656
             delete_it = asi->asi_marked_for_delete;
058656
         }
058656
 
058656
@@ -540,7 +540,7 @@ attr_syntax_delete_no_lock(struct asyntaxinfo *asi,
058656
                 PL_HashTableRemove(ht, asi->asi_aliases[i]);
058656
             }
058656
         }
058656
-        if (slapi_atomic_load(&(asi->asi_refcnt), __ATOMIC_ACQUIRE, ATOMIC_LONG) > 0) {
058656
+        if (slapi_atomic_load_64(&(asi->asi_refcnt), __ATOMIC_ACQUIRE) > 0) {
058656
             asi->asi_marked_for_delete = PR_TRUE;
058656
         } else {
058656
             /* This is ok, but the correct thing is to call delete first,
058656
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
058656
index c4c4959..9e557a2 100644
058656
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
058656
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
058656
@@ -2880,7 +2880,7 @@ dblayer_get_index_file(backend *be, struct attrinfo *a, DB **ppDB, int open_flag
058656
     /* it's like a semaphore -- when count > 0, any file handle that's in
058656
      * the attrinfo will remain valid from here on.
058656
      */
058656
-    slapi_atomic_incr(&(a->ai_dblayer_count), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_incr_64(&(a->ai_dblayer_count), __ATOMIC_RELEASE);
058656
 
058656
     if (a->ai_dblayer && ((dblayer_handle *)(a->ai_dblayer))->dblayer_dbp) {
058656
         /* This means that the pointer is valid, so we should return it. */
058656
@@ -2938,7 +2938,7 @@ dblayer_get_index_file(backend *be, struct attrinfo *a, DB **ppDB, int open_flag
058656
         /* some sort of error -- we didn't open a handle at all.
058656
          * decrement the refcount back to where it was.
058656
          */
058656
-        slapi_atomic_decr(&(a->ai_dblayer_count), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+        slapi_atomic_decr_64(&(a->ai_dblayer_count), __ATOMIC_RELEASE);
058656
     }
058656
 
058656
     return return_value;
058656
@@ -2950,7 +2950,7 @@ dblayer_get_index_file(backend *be, struct attrinfo *a, DB **ppDB, int open_flag
058656
 int
058656
 dblayer_release_index_file(backend *be __attribute__((unused)), struct attrinfo *a, DB *pDB __attribute__((unused)))
058656
 {
058656
-    slapi_atomic_decr(&(a->ai_dblayer_count), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_decr_64(&(a->ai_dblayer_count), __ATOMIC_RELEASE);
058656
     return 0;
058656
 }
058656
 
058656
@@ -3057,7 +3057,7 @@ dblayer_erase_index_file_ex(backend *be, struct attrinfo *a, PRBool use_lock, in
058656
 
058656
             dblayer_release_index_file(be, a, db);
058656
 
058656
-            while (slapi_atomic_load(&(a->ai_dblayer_count), __ATOMIC_ACQUIRE, ATOMIC_LONG) > 0) {
058656
+            while (slapi_atomic_load_64(&(a->ai_dblayer_count), __ATOMIC_ACQUIRE) > 0) {
058656
                 /* someone is using this index file */
058656
                 /* ASSUMPTION: you have already set the INDEX_OFFLINE flag, because
058656
                  * you intend to mess with this index.  therefore no new requests
058656
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
058656
index 289a149..fbbc8fa 100644
058656
--- a/ldap/servers/slapd/entry.c
058656
+++ b/ldap/servers/slapd/entry.c
058656
@@ -2249,14 +2249,14 @@ static int32_t g_virtual_watermark = 0; /* good enough to init */
058656
 int
058656
 slapi_entry_vattrcache_watermark_isvalid(const Slapi_Entry *e)
058656
 {
058656
-    return e->e_virtual_watermark == slapi_atomic_load(&g_virtual_watermark, __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return e->e_virtual_watermark == slapi_atomic_load_32(&g_virtual_watermark, __ATOMIC_ACQUIRE);
058656
 
058656
 }
058656
 
058656
 void
058656
 slapi_entry_vattrcache_watermark_set(Slapi_Entry *e)
058656
 {
058656
-    e->e_virtual_watermark = slapi_atomic_load(&g_virtual_watermark, __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    e->e_virtual_watermark = slapi_atomic_load_32(&g_virtual_watermark, __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 void
058656
@@ -2269,8 +2269,8 @@ void
058656
 slapi_entrycache_vattrcache_watermark_invalidate()
058656
 {
058656
     /* Make sure the value is never 0 */
058656
-    if (slapi_atomic_incr(&g_virtual_watermark, __ATOMIC_RELEASE, ATOMIC_INT) == 0) {
058656
-        slapi_atomic_incr(&g_virtual_watermark, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    if (slapi_atomic_incr_32(&g_virtual_watermark, __ATOMIC_RELEASE) == 0) {
058656
+        slapi_atomic_incr_32(&g_virtual_watermark, __ATOMIC_RELEASE);
058656
     }
058656
 }
058656
 
058656
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
058656
index 4c54cf7..1ba3000 100644
058656
--- a/ldap/servers/slapd/libglobs.c
058656
+++ b/ldap/servers/slapd/libglobs.c
058656
@@ -1335,19 +1335,19 @@ static uint64_t active_threads = 0;
058656
 void
058656
 g_incr_active_threadcnt(void)
058656
 {
058656
-    slapi_atomic_incr(&active_threads, __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_incr_64(&active_threads, __ATOMIC_RELEASE);
058656
 }
058656
 
058656
 void
058656
 g_decr_active_threadcnt(void)
058656
 {
058656
-    slapi_atomic_decr(&active_threads, __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_decr_64(&active_threads, __ATOMIC_RELEASE);
058656
 }
058656
 
058656
 uint64_t
058656
 g_get_active_threadcnt(void)
058656
 {
058656
-    return slapi_atomic_load(&active_threads, __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    return slapi_atomic_load_64(&active_threads, __ATOMIC_RELEASE);
058656
 }
058656
 
058656
 /*
058656
@@ -1936,7 +1936,7 @@ config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf,
058656
         size = NDN_DEFAULT_SIZE;
058656
     }
058656
     if (apply) {
058656
-        slapi_atomic_store(&(slapdFrontendConfig->ndn_cache_max_size), &size, __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+        slapi_atomic_store_64(&(slapdFrontendConfig->ndn_cache_max_size), size, __ATOMIC_RELEASE);
058656
     }
058656
 
058656
     return retVal;
058656
@@ -3476,7 +3476,7 @@ int32_t
058656
 config_get_dynamic_plugins(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->dynamic_plugins), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->dynamic_plugins), __ATOMIC_ACQUIRE);
058656
 
058656
 }
058656
 
058656
@@ -3499,7 +3499,7 @@ int32_t
058656
 config_get_cn_uses_dn_syntax_in_dns()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->cn_uses_dn_syntax_in_dns), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->cn_uses_dn_syntax_in_dns), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
@@ -3544,7 +3544,7 @@ config_set_onoff(const char *attrname, char *value, int32_t *configvalue, char *
058656
         newval = LDAP_OFF;
058656
     }
058656
 
058656
-    slapi_atomic_store(configvalue, &newval, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(configvalue, newval, __ATOMIC_RELEASE);
058656
 
058656
     return retVal;
058656
 }
058656
@@ -3916,7 +3916,7 @@ config_set_threadnumber(const char *attrname, char *value, char *errorbuf, int a
058656
         retVal = LDAP_OPERATIONS_ERROR;
058656
     }
058656
     if (apply) {
058656
-        slapi_atomic_store(&(slapdFrontendConfig->threadnumber), &threadnum, __ATOMIC_RELAXED, ATOMIC_INT);
058656
+        slapi_atomic_store_32(&(slapdFrontendConfig->threadnumber), threadnum, __ATOMIC_RELAXED);
058656
     }
058656
     return retVal;
058656
 }
058656
@@ -3925,7 +3925,7 @@ int
058656
 config_set_maxthreadsperconn(const char *attrname, char *value, char *errorbuf, int apply)
058656
 {
058656
     int retVal = LDAP_SUCCESS;
058656
-    long maxthreadnum = 0;
058656
+    int32_t maxthreadnum = 0;
058656
     char *endp = NULL;
058656
 
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
@@ -3935,7 +3935,7 @@ config_set_maxthreadsperconn(const char *attrname, char *value, char *errorbuf,
058656
     }
058656
 
058656
     errno = 0;
058656
-    maxthreadnum = strtol(value, &endp, 10);
058656
+    maxthreadnum = (int32_t)strtol(value, &endp, 10);
058656
 
058656
     if (*endp != '\0' || errno == ERANGE || maxthreadnum < 1 || maxthreadnum > 65535) {
058656
         slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
058656
@@ -3945,7 +3945,7 @@ config_set_maxthreadsperconn(const char *attrname, char *value, char *errorbuf,
058656
     }
058656
 
058656
     if (apply) {
058656
-        slapi_atomic_store(&(slapdFrontendConfig->maxthreadsperconn), &maxthreadnum, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+        slapi_atomic_store_32(&(slapdFrontendConfig->maxthreadsperconn), maxthreadnum, __ATOMIC_RELEASE);
058656
     }
058656
     return retVal;
058656
 }
058656
@@ -4083,7 +4083,7 @@ int
058656
 config_set_ioblocktimeout(const char *attrname, char *value, char *errorbuf, int apply)
058656
 {
058656
     int retVal = LDAP_SUCCESS;
058656
-    long nValue = 0;
058656
+    int32_t nValue = 0;
058656
     char *endp = NULL;
058656
 
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
@@ -4093,7 +4093,7 @@ config_set_ioblocktimeout(const char *attrname, char *value, char *errorbuf, int
058656
     }
058656
 
058656
     errno = 0;
058656
-    nValue = strtol(value, &endp, 10);
058656
+    nValue = (int32_t)strtol(value, &endp, 10);
058656
 
058656
     if (*endp != '\0' || errno == ERANGE || nValue < 0) {
058656
         slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %lld",
058656
@@ -4103,7 +4103,7 @@ config_set_ioblocktimeout(const char *attrname, char *value, char *errorbuf, int
058656
     }
058656
 
058656
     if (apply) {
058656
-        slapi_atomic_store(&(slapdFrontendConfig->ioblocktimeout), &nValue, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+        slapi_atomic_store_32(&(slapdFrontendConfig->ioblocktimeout), nValue, __ATOMIC_RELEASE);
058656
     }
058656
     return retVal;
058656
 }
058656
@@ -4607,7 +4607,7 @@ int32_t
058656
 config_get_sasl_mapping_fallback()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->sasl_mapping_fallback), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->sasl_mapping_fallback), __ATOMIC_ACQUIRE);
058656
 
058656
 }
058656
 
058656
@@ -4615,14 +4615,14 @@ int32_t
058656
 config_get_disk_monitoring()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->disk_monitoring), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->disk_monitoring), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_disk_logging_critical()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->disk_logging_critical), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->disk_logging_critical), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int
058656
@@ -4669,14 +4669,14 @@ int32_t
058656
 config_get_ldapi_switch()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ldapi_switch), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->ldapi_switch), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_ldapi_bind_switch()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ldapi_bind_switch), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->ldapi_bind_switch), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 char *
058656
@@ -4695,7 +4695,7 @@ int
058656
 config_get_ldapi_map_entries()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ldapi_map_entries), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->ldapi_map_entries), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 char *
058656
@@ -4765,7 +4765,7 @@ int32_t
058656
 config_get_slapi_counters()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->slapi_counters), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->slapi_counters), __ATOMIC_ACQUIRE);
058656
 
058656
 }
058656
 
058656
@@ -4948,7 +4948,7 @@ int32_t
058656
 config_get_pw_change(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_change), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_change), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 
058656
@@ -4956,7 +4956,7 @@ int32_t
058656
 config_get_pw_history(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_history), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_history), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 
058656
@@ -4964,21 +4964,21 @@ int32_t
058656
 config_get_pw_must_change(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_must_change), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_must_change), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_allow_hashed_pw(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->allow_hashed_pw), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->allow_hashed_pw), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_pw_syntax(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_syntax), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_syntax), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 
058656
@@ -5167,21 +5167,21 @@ int32_t
058656
 config_get_pw_is_global_policy(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_is_global_policy), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_is_global_policy), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_pw_is_legacy_policy(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_is_legacy), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_is_legacy), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_pw_exp(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_exp), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_exp), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 
058656
@@ -5189,14 +5189,14 @@ int32_t
058656
 config_get_pw_unlock(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_unlock), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_unlock), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_pw_lockout()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->pw_policy.pw_lockout), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->pw_policy.pw_lockout), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int
058656
@@ -5216,112 +5216,112 @@ int32_t
058656
 config_get_lastmod()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->lastmod), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->lastmod), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_enquote_sup_oc()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->enquote_sup_oc), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->enquote_sup_oc), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_nagle(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->nagle), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->nagle), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_accesscontrol(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->accesscontrol), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->accesscontrol), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_return_exact_case(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->return_exact_case), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->return_exact_case), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_result_tweak(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->result_tweak), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->result_tweak), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_moddn_aci(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->moddn_aci), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->moddn_aci), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_security(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->security), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->security), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 slapi_config_get_readonly(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->readonly), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->readonly), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_schemacheck(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->schemacheck), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->schemacheck), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_schemamod(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->schemamod), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->schemamod), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_syntaxcheck(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->syntaxcheck), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->syntaxcheck), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_syntaxlogging(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->syntaxlogging), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->syntaxlogging), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_dn_validate_strict(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->dn_validate_strict), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->dn_validate_strict), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_ds4_compatible_schema(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ds4_compatible_schema), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->ds4_compatible_schema), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_schema_ignore_trailing_spaces(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->schema_ignore_trailing_spaces), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->schema_ignore_trailing_spaces), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 char *
058656
@@ -5405,7 +5405,7 @@ config_get_threadnumber(void)
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
     int32_t retVal;
058656
 
058656
-    retVal = slapi_atomic_load(&(slapdFrontendConfig->threadnumber), __ATOMIC_RELAXED, ATOMIC_INT);
058656
+    retVal = slapi_atomic_load_32(&(slapdFrontendConfig->threadnumber), __ATOMIC_RELAXED);
058656
 
058656
     if (retVal <= 0) {
058656
         retVal = util_get_hardware_threads();
058656
@@ -5423,7 +5423,7 @@ int32_t
058656
 config_get_maxthreadsperconn()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->maxthreadsperconn), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->maxthreadsperconn), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int
058656
@@ -5455,7 +5455,7 @@ int32_t
058656
 config_get_ioblocktimeout()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ioblocktimeout), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->ioblocktimeout), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int
058656
@@ -5772,21 +5772,21 @@ int32_t
058656
 config_get_unauth_binds_switch(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->allow_unauth_binds), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->allow_unauth_binds), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_require_secure_binds(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->require_secure_binds), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->require_secure_binds), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_anon_access_switch(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->allow_anon_access), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->allow_anon_access), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int
058656
@@ -6028,7 +6028,7 @@ int32_t
058656
 config_get_minssf_exclude_rootdse()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->minssf_exclude_rootdse), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->minssf_exclude_rootdse), __ATOMIC_ACQUIRE);
058656
 
058656
 }
058656
 
058656
@@ -6057,7 +6057,7 @@ config_set_max_filter_nest_level(const char *attrname, char *value, char *errorb
058656
         return retVal;
058656
     }
058656
 
058656
-    slapi_atomic_store(&(slapdFrontendConfig->max_filter_nest_level), &level, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->max_filter_nest_level), level, __ATOMIC_RELEASE);
058656
     return retVal;
058656
 }
058656
 
058656
@@ -6065,28 +6065,28 @@ int32_t
058656
 config_get_max_filter_nest_level()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->max_filter_nest_level), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->max_filter_nest_level), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 uint64_t
058656
 config_get_ndn_cache_size()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ndn_cache_max_size), __ATOMIC_ACQUIRE, ATOMIC_LONG);
058656
+    return slapi_atomic_load_64(&(slapdFrontendConfig->ndn_cache_max_size), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_ndn_cache_enabled()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ndn_cache_enabled), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->ndn_cache_enabled), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_return_orig_type_switch()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->return_orig_type), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->return_orig_type), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 char *
058656
@@ -6788,7 +6788,7 @@ int32_t
058656
 config_get_force_sasl_external(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->force_sasl_external), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->force_sasl_external), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
@@ -6810,7 +6810,7 @@ int32_t
058656
 config_get_entryusn_global(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->entryusn_global), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->entryusn_global), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
@@ -7048,21 +7048,21 @@ int32_t
058656
 config_get_enable_turbo_mode(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->enable_turbo_mode), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->enable_turbo_mode), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_connection_nocanon(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->connection_nocanon), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->connection_nocanon), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_plugin_logging(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->plugin_logging), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->plugin_logging), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
@@ -7075,21 +7075,21 @@ int32_t
058656
 config_get_unhashed_pw_switch()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->unhashed_pw_switch), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->unhashed_pw_switch), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_ignore_time_skew(void)
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->ignore_time_skew), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->ignore_time_skew), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
 config_get_global_backend_lock()
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    return slapi_atomic_load(&(slapdFrontendConfig->global_backend_lock), __ATOMIC_ACQUIRE, ATOMIC_INT);
058656
+    return slapi_atomic_load_32(&(slapdFrontendConfig->global_backend_lock), __ATOMIC_ACQUIRE);
058656
 }
058656
 
058656
 int32_t
058656
@@ -7185,7 +7185,7 @@ config_set_connection_buffer(const char *attrname, char *value, char *errorbuf,
058656
     }
058656
 
058656
     val = atoi(value);
058656
-    slapi_atomic_store(&(slapdFrontendConfig->connection_buffer), &val, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->connection_buffer), val, __ATOMIC_RELEASE);
058656
 
058656
     return retVal;
058656
 }
058656
@@ -7209,7 +7209,7 @@ config_set_listen_backlog_size(const char *attrname, char *value, char *errorbuf
058656
     }
058656
 
058656
     if (apply) {
058656
-        slapi_atomic_store(&(slapdFrontendConfig->listen_backlog_size), &size, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+        slapi_atomic_store_32(&(slapdFrontendConfig->listen_backlog_size), size, __ATOMIC_RELEASE);
058656
     }
058656
     return LDAP_SUCCESS;
058656
 }
058656
@@ -7622,7 +7622,7 @@ config_set_accesslog_enabled(int value)
058656
     char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
058656
     errorbuf[0] = '\0';
058656
 
058656
-    slapi_atomic_store(&(slapdFrontendConfig->accesslog_logging_enabled), &value, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->accesslog_logging_enabled), value, __ATOMIC_RELEASE);
058656
     if (value) {
058656
         log_set_logging(CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_ACCESS_LOG, errorbuf, CONFIG_APPLY);
058656
     } else {
058656
@@ -7640,7 +7640,7 @@ config_set_auditlog_enabled(int value)
058656
     char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
058656
     errorbuf[0] = '\0';
058656
 
058656
-    slapi_atomic_store(&(slapdFrontendConfig->auditlog_logging_enabled), &value, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->auditlog_logging_enabled), value, __ATOMIC_RELEASE);
058656
     if (value) {
058656
         log_set_logging(CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_AUDIT_LOG, errorbuf, CONFIG_APPLY);
058656
     } else {
058656
@@ -7658,7 +7658,7 @@ config_set_auditfaillog_enabled(int value)
058656
     char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
058656
     errorbuf[0] = '\0';
058656
 
058656
-    slapi_atomic_store(&(slapdFrontendConfig->auditfaillog_logging_enabled), &value, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->auditfaillog_logging_enabled), value, __ATOMIC_RELEASE);
058656
     if (value) {
058656
         log_set_logging(CONFIG_AUDITFAILLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_AUDITFAIL_LOG, errorbuf, CONFIG_APPLY);
058656
     } else {
058656
@@ -7736,7 +7736,7 @@ config_set_malloc_mxfast(const char *attrname, char *value, char *errorbuf, int
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
     int max = 80 * (sizeof(size_t) / 4);
058656
-    int mxfast;
058656
+    int32_t mxfast;
058656
     char *endp = NULL;
058656
 
058656
     if (config_value_is_null(attrname, value, errorbuf, 0)) {
058656
@@ -7749,7 +7749,7 @@ config_set_malloc_mxfast(const char *attrname, char *value, char *errorbuf, int
058656
                               value, CONFIG_MALLOC_MXFAST, max);
058656
         return LDAP_OPERATIONS_ERROR;
058656
     }
058656
-    slapi_atomic_store(&(slapdFrontendConfig->malloc_mxfast), &mxfast, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->malloc_mxfast), mxfast, __ATOMIC_RELEASE);
058656
 
058656
     if ((mxfast >= 0) && (mxfast <= max)) {
058656
         mallopt(M_MXFAST, mxfast);
058656
@@ -7775,7 +7775,7 @@ int
058656
 config_set_malloc_trim_threshold(const char *attrname, char *value, char *errorbuf, int apply __attribute__((unused)))
058656
 {
058656
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
058656
-    int trim_threshold;
058656
+    int32_t trim_threshold;
058656
     char *endp = NULL;
058656
 
058656
     if (config_value_is_null(attrname, value, errorbuf, 0)) {
058656
@@ -7789,7 +7789,7 @@ config_set_malloc_trim_threshold(const char *attrname, char *value, char *errorb
058656
         return LDAP_OPERATIONS_ERROR;
058656
     }
058656
 
058656
-    slapi_atomic_store(&(slapdFrontendConfig->malloc_trim_threshold), &trim_threshold, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->malloc_trim_threshold), trim_threshold, __ATOMIC_RELEASE);
058656
 
058656
     if (trim_threshold >= -1) {
058656
         mallopt(M_TRIM_THRESHOLD, trim_threshold);
058656
@@ -7836,7 +7836,7 @@ config_set_malloc_mmap_threshold(const char *attrname, char *value, char *errorb
058656
         return LDAP_OPERATIONS_ERROR;
058656
     }
058656
 
058656
-    slapi_atomic_store(&(slapdFrontendConfig->malloc_mmap_threshold), &mmap_threshold, __ATOMIC_RELEASE, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&(slapdFrontendConfig->malloc_mmap_threshold), mmap_threshold, __ATOMIC_RELEASE);
058656
 
058656
     if ((mmap_threshold >= 0) && (mmap_threshold <= max)) {
058656
         mallopt(M_MMAP_THRESHOLD, mmap_threshold);
058656
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
058656
index 4d44c87..e16d89c 100644
058656
--- a/ldap/servers/slapd/log.c
058656
+++ b/ldap/servers/slapd/log.c
058656
@@ -4942,13 +4942,12 @@ static LogBufferInfo *
058656
 log_create_buffer(size_t sz)
058656
 {
058656
     LogBufferInfo *lbi;
058656
-    uint64_t init_val = 0;
058656
 
058656
     lbi = (LogBufferInfo *)slapi_ch_malloc(sizeof(LogBufferInfo));
058656
     lbi->top = (char *)slapi_ch_malloc(sz);
058656
     lbi->current = lbi->top;
058656
     lbi->maxsize = sz;
058656
-    slapi_atomic_store(&(lbi->refcount), &init_val, __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_store_64(&(lbi->refcount), 0, __ATOMIC_RELEASE);
058656
     return lbi;
058656
 }
058656
 
058656
@@ -5010,7 +5009,7 @@ log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, cha
058656
     insert_point = lbi->current;
058656
     lbi->current += size;
058656
     /* Increment the copy refcount */
058656
-    slapi_atomic_incr(&(lbi->refcount), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_incr_64(&(lbi->refcount), __ATOMIC_RELEASE);
058656
     PR_Unlock(lbi->lock);
058656
 
058656
     /* Now we can copy without holding the lock */
058656
@@ -5018,7 +5017,7 @@ log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_t size1, cha
058656
     memcpy(insert_point + size1, msg2, size2);
058656
 
058656
     /* Decrement the copy refcount */
058656
-    slapi_atomic_decr(&(lbi->refcount), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_decr_64(&(lbi->refcount), __ATOMIC_RELEASE);
058656
 
058656
     /* If we are asked to sync to disk immediately, do so */
058656
     if (!slapdFrontendConfig->accesslogbuffering) {
058656
@@ -5038,7 +5037,7 @@ log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
058656
     if (type == SLAPD_ACCESS_LOG) {
058656
 
058656
         /* It is only safe to flush once any other threads which are copying are finished */
058656
-        while (slapi_atomic_load(&(lbi->refcount), __ATOMIC_ACQUIRE, ATOMIC_LONG) > 0) {
058656
+        while (slapi_atomic_load_64(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) {
058656
             /* It's ok to sleep for a while because we only flush every second or so */
058656
             DS_Sleep(PR_MillisecondsToInterval(1));
058656
         }
058656
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
058656
index 6621ceb..8cc5318 100644
058656
--- a/ldap/servers/slapd/mapping_tree.c
058656
+++ b/ldap/servers/slapd/mapping_tree.c
058656
@@ -1647,7 +1647,7 @@ mapping_tree_init()
058656
 
058656
     /* we call this function from a single thread, so it should be ok */
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown has been detected */
058656
         return 0;
058656
     }
058656
@@ -1759,8 +1759,6 @@ mtn_free_node(mapping_tree_node **node)
058656
 void
058656
 mapping_tree_free()
058656
 {
058656
-    int init_val = 1;
058656
-
058656
     /* unregister dse callbacks */
058656
     slapi_config_remove_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP, MAPPING_TREE_BASE_DN, LDAP_SCOPE_BASE, "(objectclass=*)", mapping_tree_entry_modify_callback);
058656
     slapi_config_remove_callback(SLAPI_OPERATION_ADD, DSE_FLAG_PREOP, MAPPING_TREE_BASE_DN, LDAP_SCOPE_BASE, "(objectclass=*)", mapping_tree_entry_add_callback);
058656
@@ -1773,7 +1771,7 @@ mapping_tree_free()
058656
     slapi_unregister_backend_state_change_all();
058656
     /* recursively free tree nodes */
058656
     mtn_free_node(&mapping_tree_root);
058656
-    slapi_atomic_store(&mapping_tree_freed, &init_val, __ATOMIC_RELAXED, ATOMIC_INT);
058656
+    slapi_atomic_store_32(&mapping_tree_freed, 1, __ATOMIC_RELAXED);
058656
 }
058656
 
058656
 /* This function returns the first node to parse when a search is done
058656
@@ -2024,7 +2022,7 @@ slapi_dn_write_needs_referral(Slapi_DN *target_sdn, Slapi_Entry **referral)
058656
     mapping_tree_node *target_node = NULL;
058656
     int ret = 0;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         goto done;
058656
     }
058656
@@ -2095,7 +2093,7 @@ slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry **re
058656
     int fixup = 0;
058656
 
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         return LDAP_OPERATIONS_ERROR;
058656
     }
058656
@@ -2200,7 +2198,7 @@ slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list, Slapi_E
058656
     int flag_partial_result = 0;
058656
     int op_type;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         return LDAP_OPERATIONS_ERROR;
058656
     }
058656
 
058656
@@ -2360,7 +2358,7 @@ slapi_mapping_tree_select_and_check(Slapi_PBlock *pb, char *newdn, Slapi_Backend
058656
     int ret;
058656
     int need_unlock = 0;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         return LDAP_OPERATIONS_ERROR;
058656
     }
058656
 
058656
@@ -2526,7 +2524,7 @@ mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb, Slapi_Backend **be,
058656
     int flag_stop = 0;
058656
     struct slapi_componentid *cid = NULL;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shut down detected */
058656
         return LDAP_OPERATIONS_ERROR;
058656
     }
058656
@@ -2714,7 +2712,7 @@ best_matching_child(mapping_tree_node *parent,
058656
     mapping_tree_node *highest_match_node = NULL;
058656
     mapping_tree_node *current;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         return NULL;
058656
     }
058656
@@ -2741,7 +2739,7 @@ mtn_get_mapping_tree_node_by_entry(mapping_tree_node *node, const Slapi_DN *dn)
058656
 {
058656
     mapping_tree_node *found_node = NULL;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         return NULL;
058656
     }
058656
@@ -2784,7 +2782,7 @@ slapi_get_mapping_tree_node_by_dn(const Slapi_DN *dn)
058656
     mapping_tree_node *current_best_match = mapping_tree_root;
058656
     mapping_tree_node *next_best_match = mapping_tree_root;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         return NULL;
058656
     }
058656
@@ -2818,7 +2816,7 @@ get_mapping_tree_node_by_name(mapping_tree_node *node, char *be_name)
058656
     int i;
058656
     mapping_tree_node *found_node = NULL;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         return NULL;
058656
     }
058656
@@ -2865,7 +2863,7 @@ slapi_get_mapping_tree_node_configdn(const Slapi_DN *root)
058656
 {
058656
     char *dn = NULL;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         return NULL;
058656
     }
058656
@@ -2892,7 +2890,7 @@ slapi_get_mapping_tree_node_configsdn(const Slapi_DN *root)
058656
     char *dn = NULL;
058656
     Slapi_DN *sdn = NULL;
058656
 
058656
-    if (slapi_atomic_load(&mapping_tree_freed, __ATOMIC_RELAXED, ATOMIC_INT)) {
058656
+    if (slapi_atomic_load_32(&mapping_tree_freed, __ATOMIC_RELAXED)) {
058656
         /* shutdown detected */
058656
         return NULL;
058656
     }
058656
diff --git a/ldap/servers/slapd/object.c b/ldap/servers/slapd/object.c
058656
index 6a1a9a5..8e55a16 100644
058656
--- a/ldap/servers/slapd/object.c
058656
+++ b/ldap/servers/slapd/object.c
058656
@@ -43,12 +43,11 @@ Object *
058656
 object_new(void *user_data, FNFree destructor)
058656
 {
058656
     Object *o;
058656
-    uint64_t init_val = 1;
058656
 
058656
     o = (object *)slapi_ch_malloc(sizeof(object));
058656
     o->destructor = destructor;
058656
     o->data = user_data;
058656
-    slapi_atomic_store(&(o->refcnt), &init_val, __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_store_64(&(o->refcnt), 1, __ATOMIC_RELEASE);
058656
     return o;
058656
 }
058656
 
058656
@@ -62,7 +61,7 @@ void
058656
 object_acquire(Object *o)
058656
 {
058656
     PR_ASSERT(NULL != o);
058656
-    slapi_atomic_incr(&(o->refcnt), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_incr_64(&(o->refcnt), __ATOMIC_RELEASE);
058656
 }
058656
 
058656
 
058656
@@ -77,7 +76,7 @@ object_release(Object *o)
058656
     PRInt32 refcnt_after_release;
058656
 
058656
     PR_ASSERT(NULL != o);
058656
-    refcnt_after_release = slapi_atomic_decr(&(o->refcnt), __ATOMIC_ACQ_REL, ATOMIC_LONG);
058656
+    refcnt_after_release = slapi_atomic_decr_64(&(o->refcnt), __ATOMIC_ACQ_REL);
058656
     if (refcnt_after_release == 0) {
058656
         /* Object can be destroyed */
058656
         if (o->destructor)
058656
diff --git a/ldap/servers/slapd/psearch.c b/ldap/servers/slapd/psearch.c
058656
index 70c530b..e0dd2bf 100644
058656
--- a/ldap/servers/slapd/psearch.c
058656
+++ b/ldap/servers/slapd/psearch.c
058656
@@ -134,7 +134,7 @@ ps_stop_psearch_system()
058656
     if (PS_IS_INITIALIZED()) {
058656
         PSL_LOCK_WRITE();
058656
         for (ps = psearch_list->pl_head; NULL != ps; ps = ps->ps_next) {
058656
-            slapi_atomic_incr(&(ps->ps_complete), __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+            slapi_atomic_incr_64(&(ps->ps_complete), __ATOMIC_RELEASE);
058656
         }
058656
         PSL_UNLOCK_WRITE();
058656
         ps_wakeup_all();
058656
@@ -285,7 +285,7 @@ ps_send_results(void *arg)
058656
 
058656
     PR_Lock(psearch_list->pl_cvarlock);
058656
 
058656
-    while ((conn_acq_flag == 0) && slapi_atomic_load(&(ps->ps_complete), __ATOMIC_ACQUIRE, ATOMIC_LONG) == 0) {
058656
+    while ((conn_acq_flag == 0) && slapi_atomic_load_64(&(ps->ps_complete), __ATOMIC_ACQUIRE) == 0) {
058656
         /* Check for an abandoned operation */
058656
         if (pb_op == NULL || slapi_op_abandoned(ps->ps_pblock)) {
058656
             slapi_log_err(SLAPI_LOG_CONNS, "ps_send_results",
058656
@@ -427,7 +427,6 @@ static PSearch *
058656
 psearch_alloc(void)
058656
 {
058656
     PSearch *ps;
058656
-    uint64_t init_val = 0;
058656
 
058656
     ps = (PSearch *)slapi_ch_calloc(1, sizeof(PSearch));
058656
 
058656
@@ -438,7 +437,7 @@ psearch_alloc(void)
058656
         slapi_ch_free((void **)&ps);
058656
         return (NULL);
058656
     }
058656
-    slapi_atomic_store(&(ps->ps_complete), &init_val, __ATOMIC_RELEASE, ATOMIC_LONG);
058656
+    slapi_atomic_store_64(&(ps->ps_complete), 0, __ATOMIC_RELEASE);
058656
     ps->ps_eq_head = ps->ps_eq_tail = (PSEQNode *)NULL;
058656
     ps->ps_lasttime = (time_t)0L;
058656
     ps->ps_next = NULL;
058656
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
058656
index c434add..4566202 100644
058656
--- a/ldap/servers/slapd/slapi-plugin.h
058656
+++ b/ldap/servers/slapd/slapi-plugin.h
058656
@@ -8202,56 +8202,87 @@ void slapi_operation_time_initiated(Slapi_Operation *o, struct timespec *initiat
058656
  */
058656
 #endif
058656
 
058656
-/* See: https://gcc.gnu.org/ml/gcc/2016-11/txt6ZlA_JS27i.txt */
058656
-#define ATOMIC_GENERIC  0
058656
-#define ATOMIC_INT      4
058656
-#define ATOMIC_LONG     8
058656
-#define ATOMIC_INT128  16  /* Future */
058656
+/**
058656
+ * Store a 32bit integral value atomicly
058656
+ *
058656
+ * \param ptr - integral pointer
058656
+ * \param val - pointer to integral value (use integral type int32_t with ATOMIC_INT, or uint64_t
058656
+ * with ATOMIC_LONG & ATOMIC_GENERIC)
058656
+ * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
+ * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
+ */
058656
+void slapi_atomic_store_32(int32_t *ptr, int32_t val, int memorder);
058656
 
058656
 /**
058656
- * Store an integral value atomicly
058656
+ * Store a 64bit integral value atomicly
058656
  *
058656
  * \param ptr - integral pointer
058656
  * \param val - pointer to integral value (use integral type int32_t with ATOMIC_INT, or uint64_t
058656
  * with ATOMIC_LONG & ATOMIC_GENERIC)
058656
  * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
  * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
- * \param type - "ptr" type: ATOMIC_GENERIC, ATOMIC_INT, or ATOMIC_LONG
058656
  */
058656
-void slapi_atomic_store(void *ptr, void *val, int memorder, int type);
058656
+void slapi_atomic_store_64(uint64_t *ptr, uint64_t val, int memorder);
058656
 
058656
 /**
058656
- * Get an integral value atomicly
058656
+ * Get a 32bit integral value atomicly
058656
  *
058656
  * \param ptr - integral pointer
058656
  * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
  * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
- * \param type - "ptr" type: ATOMIC_GENERIC, ATOMIC_INT, or ATOMIC_LONG
058656
  * \return -
058656
  */
058656
-uint64_t slapi_atomic_load(void *ptr, int memorder, int type);
058656
+int32_t slapi_atomic_load_32(int32_t *ptr, int memorder);
058656
 
058656
 /**
058656
- * Increment integral atomicly
058656
+ * Get a 64bit integral value atomicly
058656
+ *
058656
+ * \param ptr - integral pointer
058656
+ * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
+ * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
+ * \return ptr value
058656
+ */
058656
+uint64_t slapi_atomic_load_64(uint64_t *ptr, int memorder);
058656
+
058656
+/**
058656
+ * Increment a 32bit integral atomicly
058656
  *
058656
  * \param ptr - pointer to integral to increment
058656
  * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
  * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
- * \param type - "ptr" type: ATOMIC_GENERIC, ATOMIC_INT, or ATOMIC_LONG
058656
  * \return - new value of ptr
058656
  */
058656
-uint64_t slapi_atomic_incr(void *ptr, int memorder, int type);
058656
+int32_t slapi_atomic_incr_32(int32_t *ptr, int memorder);
058656
+
058656
+/**
058656
+ * Increment a 64bitintegral atomicly
058656
+ *
058656
+ * \param ptr - pointer to integral to increment
058656
+ * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
+ * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
+ * \return - new value of ptr
058656
+ */
058656
+uint64_t slapi_atomic_incr_64(uint64_t *ptr, int memorder);
058656
+
058656
+/**
058656
+ * Decrement a 32bit integral atomicly
058656
+ *
058656
+ * \param ptr - pointer to integral to decrement
058656
+ * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
+ * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
+ * \return - new value of ptr
058656
+ */
058656
+int32_t slapi_atomic_decr_32(int32_t *ptr, int memorder);
058656
 
058656
 /**
058656
- * Decrement integral atomicly
058656
+ * Decrement a 64bitintegral atomicly
058656
  *
058656
  * \param ptr - pointer to integral to decrement
058656
  * \param memorder - __ATOMIC_RELAXED, __ATOMIC_CONSUME, __ATOMIC_ACQUIRE,
058656
  * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, __ATOMIC_SEQ_CST
058656
- * \param type - "ptr" type: ATOMIC_GENERIC, ATOMIC_INT, or ATOMIC_LONG
058656
  * \return - new value of ptr
058656
  */
058656
-uint64_t slapi_atomic_decr(void *ptr, int memorder, int type);
058656
+uint64_t slapi_atomic_decr_64(uint64_t *ptr, int memorder);
058656
 
058656
 
058656
 #ifdef __cplusplus
058656
diff --git a/ldap/servers/slapd/slapi_counter.c b/ldap/servers/slapd/slapi_counter.c
058656
index 9e705b3..c5cae27 100644
058656
--- a/ldap/servers/slapd/slapi_counter.c
058656
+++ b/ldap/servers/slapd/slapi_counter.c
058656
@@ -295,53 +295,41 @@ slapi_counter_get_value(Slapi_Counter *counter)
058656
  * __ATOMIC_RELEASE, __ATOMIC_ACQ_REL, or __ATOMIC_SEQ_CST
058656
  *
058656
  *     See: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/_005f_005fatomic-Builtins.html
058656
- *
058656
- * type_size - ATOMIC_GENERIC, ATOMIC_INT, or ATOMIC_LONG, see slapi-plugin.h for more info
058656
- *
058656
- * Future:
058656
- *    If we need to support ATOMIC_INT128 (not available on 32bit systems):
058656
- *         __atomic_store_16((uint64_t *)&ptr, val, memorder);
058656
- *         __atomic_load_16((uint64_t *)&ptr, memorder);
058656
- *         __atomic_add_fetch_16((uint64_t *)&ptr, 1, memorder);
058656
- *         __atomic_sub_fetch_16((uint64_t *)&ptr, 1, memorder);
058656
  */
058656
 
058656
 /*
058656
- * "val" must be either int32_t or uint64_t
058656
+ * atomic store functions (32bit and 64bit)
058656
  */
058656
 void
058656
-slapi_atomic_store(void *ptr, void *val, int memorder, int type_size)
058656
+slapi_atomic_store_32(int32_t *ptr, int32_t val, int memorder)
058656
 {
058656
 #ifdef ATOMIC_64BIT_OPERATIONS
058656
-    if (type_size == ATOMIC_INT) {
058656
-        __atomic_store_4((int32_t *)ptr, *(int32_t *)val, memorder);
058656
-    } else if (type_size == ATOMIC_LONG) {
058656
-        __atomic_store_8((uint64_t *)ptr, *(uint64_t *)val, memorder);
058656
-    } else {
058656
-        /* ATOMIC_GENERIC or unknown size */
058656
-        __atomic_store((uint64_t *)&ptr, (uint64_t *)val, memorder);
058656
-    }
058656
+    __atomic_store_4(ptr, val, memorder);
058656
 #else
058656
     PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
-    PR_AtomicSet(pr_ptr, *(PRInt32 *)val);
058656
+    PR_AtomicSet(pr_ptr, (PRInt32)val);
058656
 #endif
058656
 }
058656
 
058656
-uint64_t
058656
-slapi_atomic_load(void *ptr, int memorder, int type_size)
058656
+void
058656
+slapi_atomic_store_64(uint64_t *ptr, uint64_t val, int memorder)
058656
 {
058656
 #ifdef ATOMIC_64BIT_OPERATIONS
058656
-    uint64_t ret;
058656
+    __atomic_store_8(ptr, val, memorder);
058656
+#else
058656
+    PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
+    PR_AtomicSet(pr_ptr, (PRInt32)val);
058656
+#endif
058656
+}
058656
 
058656
-    if (type_size == ATOMIC_INT) {
058656
-        return __atomic_load_4((int32_t *)ptr, memorder);
058656
-    } else if (type_size == ATOMIC_LONG) {
058656
-        return __atomic_load_8((uint64_t *)ptr, memorder);
058656
-    } else {
058656
-        /* ATOMIC_GENERIC or unknown size */
058656
-        __atomic_load((uint64_t *)ptr, &ret, memorder);
058656
-        return ret;
058656
-    }
058656
+/*
058656
+ * atomic load functions (32bit and 64bit)
058656
+ */
058656
+int32_t
058656
+slapi_atomic_load_32(int32_t *ptr, int memorder)
058656
+{
058656
+#ifdef ATOMIC_64BIT_OPERATIONS
058656
+    return __atomic_load_4(ptr, memorder);
058656
 #else
058656
     PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
     return PR_AtomicAdd(pr_ptr, 0);
058656
@@ -349,17 +337,24 @@ slapi_atomic_load(void *ptr, int memorder, int type_size)
058656
 }
058656
 
058656
 uint64_t
058656
-slapi_atomic_incr(void *ptr, int memorder, int type_size)
058656
+slapi_atomic_load_64(uint64_t *ptr, int memorder)
058656
 {
058656
 #ifdef ATOMIC_64BIT_OPERATIONS
058656
-    if (type_size == ATOMIC_INT) {
058656
-        return __atomic_add_fetch_4((int32_t *)ptr, 1, memorder);
058656
-    } else if (type_size == ATOMIC_LONG) {
058656
-        return __atomic_add_fetch_8((uint64_t *)ptr, 1, memorder);
058656
-    } else {
058656
-        /* ATOMIC_GENERIC or unknown size */
058656
-        return __atomic_add_fetch((uint64_t *)ptr, 1, memorder);
058656
-    }
058656
+    return __atomic_load_8(ptr, memorder);
058656
+#else
058656
+    PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
+    return PR_AtomicAdd(pr_ptr, 0);
058656
+#endif
058656
+}
058656
+
058656
+/*
058656
+ * atomic increment functions (32bit and 64bit)
058656
+ */
058656
+int32_t
058656
+slapi_atomic_incr_32(int32_t *ptr, int memorder)
058656
+{
058656
+#ifdef ATOMIC_64BIT_OPERATIONS
058656
+    return __atomic_add_fetch_4(ptr, 1, memorder);
058656
 #else
058656
     PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
     return PR_AtomicIncrement(pr_ptr);
058656
@@ -367,17 +362,35 @@ slapi_atomic_incr(void *ptr, int memorder, int type_size)
058656
 }
058656
 
058656
 uint64_t
058656
-slapi_atomic_decr(void *ptr, int memorder, int type_size)
058656
+slapi_atomic_incr_64(uint64_t *ptr, int memorder)
058656
 {
058656
 #ifdef ATOMIC_64BIT_OPERATIONS
058656
-    if (type_size == ATOMIC_INT) {
058656
-        return __atomic_sub_fetch_4((int32_t *)ptr, 1, memorder);
058656
-    } else if (type_size == ATOMIC_LONG) {
058656
-        return __atomic_sub_fetch_8((uint64_t *)ptr, 1, memorder);
058656
-    } else {
058656
-        /* ATOMIC_GENERIC or unknown size */
058656
-        return __atomic_sub_fetch((uint64_t *)ptr, 1, memorder);
058656
-    }
058656
+    return __atomic_add_fetch_8(ptr, 1, memorder);
058656
+#else
058656
+    PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
+    return PR_AtomicIncrement(pr_ptr);
058656
+#endif
058656
+}
058656
+
058656
+/*
058656
+ * atomic decrement functions (32bit and 64bit)
058656
+ */
058656
+int32_t
058656
+slapi_atomic_decr_32(int32_t *ptr, int memorder)
058656
+{
058656
+#ifdef ATOMIC_64BIT_OPERATIONS
058656
+    return __atomic_sub_fetch_4(ptr, 1, memorder);
058656
+#else
058656
+    PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
+    return PR_AtomicDecrement(pr_ptr);
058656
+#endif
058656
+}
058656
+
058656
+uint64_t
058656
+slapi_atomic_decr_64(uint64_t *ptr, int memorder)
058656
+{
058656
+#ifdef ATOMIC_64BIT_OPERATIONS
058656
+    return __atomic_sub_fetch_8(ptr, 1, memorder);
058656
 #else
058656
     PRInt32 *pr_ptr = (PRInt32 *)ptr;
058656
     return PR_AtomicDecrement(pr_ptr);
058656
-- 
058656
2.9.5
058656