[nginx] Introduced the NGX_COMPAT macro.

Ruslan Ermilov ru at nginx.com
Mon Oct 3 13:00:15 UTC 2016


details:   http://hg.nginx.org/nginx/rev/d200a0fd00b7
branches:  
changeset: 6715:d200a0fd00b7
user:      Ruslan Ermilov <ru at nginx.com>
date:      Thu Sep 29 15:28:24 2016 +0300
description:
Introduced the NGX_COMPAT macro.

When enabled, some structures are padded to be size compatible
with their NGINX Plus versions.

diffstat:

 src/core/ngx_config.h                        |  13 +++++++++++++
 src/core/ngx_module.h                        |   8 +++++++-
 src/event/ngx_event_connect.h                |   3 +++
 src/http/ngx_http_upstream.h                 |   9 +++++++++
 src/http/ngx_http_upstream_round_robin.h     |   3 +++
 src/stream/ngx_stream_upstream.h             |   3 +++
 src/stream/ngx_stream_upstream_round_robin.h |   3 +++
 7 files changed, 41 insertions(+), 1 deletions(-)

diffs (131 lines):

diff -r c3e3de6d2672 -r d200a0fd00b7 src/core/ngx_config.h
--- a/src/core/ngx_config.h	Thu Sep 29 19:40:47 2016 +0300
+++ b/src/core/ngx_config.h	Thu Sep 29 15:28:24 2016 +0300
@@ -129,4 +129,17 @@ typedef intptr_t        ngx_flag_t;
 #define NGX_MAX_INT32_VALUE   (uint32_t) 0x7fffffff
 
 
+#if (NGX_COMPAT)
+
+#define NGX_COMPAT_BEGIN(slots)  uint64_t spare[slots];
+#define NGX_COMPAT_END
+
+#else
+
+#define NGX_COMPAT_BEGIN(slots)
+#define NGX_COMPAT_END
+
+#endif
+
+
 #endif /* _NGX_CONFIG_H_INCLUDED_ */
diff -r c3e3de6d2672 -r d200a0fd00b7 src/core/ngx_module.h
--- a/src/core/ngx_module.h	Thu Sep 29 19:40:47 2016 +0300
+++ b/src/core/ngx_module.h	Thu Sep 29 15:28:24 2016 +0300
@@ -212,6 +212,12 @@
 #define NGX_MODULE_SIGNATURE_33  "0"
 #endif
 
+#if (NGX_COMPAT)
+#define NGX_MODULE_SIGNATURE_34  "1"
+#else
+#define NGX_MODULE_SIGNATURE_34  "0"
+#endif
+
 #define NGX_MODULE_SIGNATURE                                                  \
     NGX_MODULE_SIGNATURE_0 NGX_MODULE_SIGNATURE_1 NGX_MODULE_SIGNATURE_2      \
     NGX_MODULE_SIGNATURE_3 NGX_MODULE_SIGNATURE_4 NGX_MODULE_SIGNATURE_5      \
@@ -224,7 +230,7 @@
     NGX_MODULE_SIGNATURE_24 NGX_MODULE_SIGNATURE_25 NGX_MODULE_SIGNATURE_26   \
     NGX_MODULE_SIGNATURE_27 NGX_MODULE_SIGNATURE_28 NGX_MODULE_SIGNATURE_29   \
     NGX_MODULE_SIGNATURE_30 NGX_MODULE_SIGNATURE_31 NGX_MODULE_SIGNATURE_32   \
-    NGX_MODULE_SIGNATURE_33
+    NGX_MODULE_SIGNATURE_33 NGX_MODULE_SIGNATURE_34
 
 
 #define NGX_MODULE_V1                                                         \
diff -r c3e3de6d2672 -r d200a0fd00b7 src/event/ngx_event_connect.h
--- a/src/event/ngx_event_connect.h	Thu Sep 29 19:40:47 2016 +0300
+++ b/src/event/ngx_event_connect.h	Thu Sep 29 15:28:24 2016 +0300
@@ -68,6 +68,9 @@ struct ngx_peer_connection_s {
 
                                      /* ngx_connection_log_error_e */
     unsigned                         log_error:2;
+
+    NGX_COMPAT_BEGIN(2)
+    NGX_COMPAT_END
 };
 
 
diff -r c3e3de6d2672 -r d200a0fd00b7 src/http/ngx_http_upstream.h
--- a/src/http/ngx_http_upstream.h	Thu Sep 29 19:40:47 2016 +0300
+++ b/src/http/ngx_http_upstream.h	Thu Sep 29 15:28:24 2016 +0300
@@ -102,6 +102,9 @@ typedef struct {
 
     unsigned                         down:1;
     unsigned                         backup:1;
+
+    NGX_COMPAT_BEGIN(6)
+    NGX_COMPAT_END
 } ngx_http_upstream_server_t;
 
 
@@ -229,6 +232,9 @@ typedef struct {
 #endif
 
     ngx_str_t                        module;
+
+    NGX_COMPAT_BEGIN(2)
+    NGX_COMPAT_END
 } ngx_http_upstream_conf_t;
 
 
@@ -382,6 +388,9 @@ struct ngx_http_upstream_s {
     unsigned                         request_sent:1;
     unsigned                         request_body_sent:1;
     unsigned                         header_sent:1;
+
+    NGX_COMPAT_BEGIN(1)
+    NGX_COMPAT_END
 };
 
 
diff -r c3e3de6d2672 -r d200a0fd00b7 src/http/ngx_http_upstream_round_robin.h
--- a/src/http/ngx_http_upstream_round_robin.h	Thu Sep 29 19:40:47 2016 +0300
+++ b/src/http/ngx_http_upstream_round_robin.h	Thu Sep 29 15:28:24 2016 +0300
@@ -50,6 +50,9 @@ struct ngx_http_upstream_rr_peer_s {
 #endif
 
     ngx_http_upstream_rr_peer_t    *next;
+
+    NGX_COMPAT_BEGIN(32)
+    NGX_COMPAT_END
 };
 
 
diff -r c3e3de6d2672 -r d200a0fd00b7 src/stream/ngx_stream_upstream.h
--- a/src/stream/ngx_stream_upstream.h	Thu Sep 29 19:40:47 2016 +0300
+++ b/src/stream/ngx_stream_upstream.h	Thu Sep 29 15:28:24 2016 +0300
@@ -58,6 +58,9 @@ typedef struct {
 
     unsigned                           down:1;
     unsigned                           backup:1;
+
+    NGX_COMPAT_BEGIN(4)
+    NGX_COMPAT_END
 } ngx_stream_upstream_server_t;
 
 
diff -r c3e3de6d2672 -r d200a0fd00b7 src/stream/ngx_stream_upstream_round_robin.h
--- a/src/stream/ngx_stream_upstream_round_robin.h	Thu Sep 29 19:40:47 2016 +0300
+++ b/src/stream/ngx_stream_upstream_round_robin.h	Thu Sep 29 15:28:24 2016 +0300
@@ -50,6 +50,9 @@ struct ngx_stream_upstream_rr_peer_s {
 #endif
 
     ngx_stream_upstream_rr_peer_t   *next;
+
+    NGX_COMPAT_BEGIN(25)
+    NGX_COMPAT_END
 };
 
 



More information about the nginx-devel mailing list