[PATCH] Use int64 and int32 types with GCC atomics
Alessandro Ghedini
alessandro at ghedini.me
Fri Sep 16 13:44:38 UTC 2016
# HG changeset patch
# User Alessandro Ghedini <alessandro at ghedini.me>
# Date 1474033303 -3600
# Fri Sep 16 14:41:43 2016 +0100
# Node ID 64afed0e819b9af65e7afa89baad3313f1db18d4
# Parent e83540f825cd8c936f4f7f1e0336279d66446606
Use int64 and int32 types with GCC atomics
It's not quite clear if this was done on purpose, but it seems a good
idea to use appropriately sized types when GCC atomics are used.
diff -r e83540f825cd -r 64afed0e819b src/os/unix/ngx_atomic.h
--- a/src/os/unix/ngx_atomic.h Thu Sep 15 15:36:02 2016 +0300
+++ b/src/os/unix/ngx_atomic.h Fri Sep 16 14:41:43 2016 +0100
@@ -94,13 +94,18 @@
#define NGX_HAVE_ATOMIC_OPS 1
-typedef long ngx_atomic_int_t;
-typedef unsigned long ngx_atomic_uint_t;
+#if (NGX_PTR_SIZE == 8)
-#if (NGX_PTR_SIZE == 8)
+typedef int64_t ngx_atomic_int_t;
+typedef uint64_t ngx_atomic_uint_t;
#define NGX_ATOMIC_T_LEN (sizeof("-9223372036854775808") - 1)
+
#else
+
+typedef int32_t ngx_atomic_int_t;
+typedef uint32_t ngx_atomic_uint_t;
#define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1)
+
#endif
typedef volatile ngx_atomic_uint_t ngx_atomic_t;
More information about the nginx-devel
mailing list