diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c
index 2cca7ba3ee1729081fc02b24f8053122e28b12e4..bc076deadd3fd74e8c69025bacee8ce1cb0a6919 100644
--- a/lib/core/libwebsockets.c
+++ b/lib/core/libwebsockets.c
@@ -1530,7 +1530,7 @@ lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path,
 		pf = fops->next;
 		while (pf) {
 			n = 0;
-			while (n < (int)ARRAY_SIZE(pf->fi) && pf->fi[n].sig) {
+			while (n < (int)LWS_ARRAY_SIZE(pf->fi) && pf->fi[n].sig) {
 				if (p >= vfs_path + pf->fi[n].len)
 					if (!strncmp(p - (pf->fi[n].len - 1),
 						    pf->fi[n].sig,
@@ -2023,14 +2023,14 @@ LWS_VISIBLE void lwsl_emit_stderr(int level, const char *line)
 {
 	char buf[50];
 	static char tty = 3;
-	int n, m = ARRAY_SIZE(colours) - 1;
+	int n, m = LWS_ARRAY_SIZE(colours) - 1;
 
 	if (!tty)
 		tty = isatty(2) | 2;
 	lwsl_timestamp(level, buf, sizeof(buf));
 
 	if (tty == 3) {
-		n = 1 << (ARRAY_SIZE(colours) - 1);
+		n = 1 << (LWS_ARRAY_SIZE(colours) - 1);
 		while (n) {
 			if (level & n)
 				break;
diff --git a/lib/core/private.h b/lib/core/private.h
index 84b4a949a77758636a6aff03a49649f1f17eebb3..839c3a292fb2402019e69c774109ad78ee784ada 100644
--- a/lib/core/private.h
+++ b/lib/core/private.h
@@ -136,6 +136,20 @@
 
 #include "tls/private.h"
 
+#if defined(WIN32) || defined(_WIN32)
+	 // Visual studio older than 2015 and WIN_CE has only _stricmp
+	#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE)
+	#define strcasecmp _stricmp
+	#elif !defined(__MINGW32__)
+	#define strcasecmp stricmp
+	#endif
+	#define getdtablesize() 30000
+#endif
+
+#ifndef LWS_ARRAY_SIZE
+#define LWS_ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/lib/event-libs/libuv/libuv.c b/lib/event-libs/libuv/libuv.c
index ec37e09e8568fb57e829721fd058e0953dd90417..ddcbc4adb47f3d0430fdba9e0824496a1fbf65f7 100644
--- a/lib/event-libs/libuv/libuv.c
+++ b/lib/event-libs/libuv/libuv.c
@@ -722,7 +722,7 @@ elops_destroy_pt_uv(struct lws_context *context, int tsi)
 	if (!pt->event_loop_foreign) {
 		uv_signal_stop(&pt->w_sigint.uv.watcher);
 
-		ns = ARRAY_SIZE(sigs);
+		ns = LWS_ARRAY_SIZE(sigs);
 		if (lws_check_opt(context->options,
 				  LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN))
 			ns = 2;
@@ -783,13 +783,13 @@ elops_init_pt_uv(struct lws_context *context, void *_loop, int tsi)
 		LWS_UV_REFCOUNT_STATIC_HANDLE_NEW(&pt->uv.idle, context);
 
 
-		ns = ARRAY_SIZE(sigs);
+		ns = LWS_ARRAY_SIZE(sigs);
 		if (lws_check_opt(context->options,
 				  LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN))
 			ns = 2;
 
 		if (!pt->event_loop_foreign) {
-			assert(ns <= (int)ARRAY_SIZE(pt->uv.signals));
+			assert(ns <= (int)LWS_ARRAY_SIZE(pt->uv.signals));
 			for (n = 0; n < ns; n++) {
 				uv_signal_init(loop, &pt->uv.signals[n]);
 				LWS_UV_REFCOUNT_STATIC_HANDLE_NEW(&pt->uv.signals[n],
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index 4857850cee53d67f5b1f6bba71444550aa23271a..ddf92f99390611848f6b417b16bf6ae7f6914ae5 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -66,14 +66,6 @@ typedef unsigned long long lws_intptr_t;
 #define O_RDONLY	_O_RDONLY
 #endif
 
-// Visual studio older than 2015 and WIN_CE has only _stricmp
-#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE)
-#define strcasecmp _stricmp
-#elif !defined(__MINGW32__)
-#define strcasecmp stricmp
-#endif
-#define getdtablesize() 30000
-
 #define LWS_INLINE __inline
 #define LWS_VISIBLE
 #define LWS_WARN_UNUSED_RESULT
@@ -462,9 +454,6 @@ lwsl_visible(int level);
 #endif
 
 struct lws;
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-#endif
 
 typedef int64_t lws_usec_t;
 
@@ -7097,10 +7086,9 @@ lws_email_destroy(struct lws_email *email);
 //@{
 struct lejp_ctx;
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0]))
-#endif
+#if !defined(LWS_ARRAY_SIZE)
 #define LWS_ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0]))
+#endif
 #define LEJP_FLAG_WS_KEEP 64
 #define LEJP_FLAG_WS_COMMENTLINE 32
 
diff --git a/lib/misc/jws/jwk.c b/lib/misc/jws/jwk.c
index 2337d5e8cfe0c54017db5f3f5ae612075b2624af..3a346906c9e8d96cbbf3a87723e2acca41aebe6c 100644
--- a/lib/misc/jws/jwk.c
+++ b/lib/misc/jws/jwk.c
@@ -135,7 +135,7 @@ lws_jwk_import(struct lws_jwk *s, const char *in, size_t len)
 	cbs.b64 = b64;
 	cbs.b64max = b64max;
 	cbs.pos = 0;
-	lejp_construct(&jctx, cb_jwk, &cbs, jwk_tok, ARRAY_SIZE(jwk_tok));
+	lejp_construct(&jctx, cb_jwk, &cbs, jwk_tok, LWS_ARRAY_SIZE(jwk_tok));
 	m = (int)(signed char)lejp_parse(&jctx, (uint8_t *)in, len);
 	lejp_destruct(&jctx);
 
diff --git a/lib/misc/jws/jws.c b/lib/misc/jws/jws.c
index 23a863ca5268d26e59333930207c4106e0f60b59..72cfc98069034f1fd5d47c9160790547e1c2b7ce 100644
--- a/lib/misc/jws/jws.c
+++ b/lib/misc/jws/jws.c
@@ -273,7 +273,7 @@ lws_jws_confirm_sig(const char *in, size_t len, struct lws_jwk *jwk)
 
 	args.alg[0] = '\0';
 	args.is_rsa = 0;
-	lejp_construct(&jctx, cb_hdr, &args, jhdr_tok, ARRAY_SIZE(jhdr_tok));
+	lejp_construct(&jctx, cb_hdr, &args, jhdr_tok, LWS_ARRAY_SIZE(jhdr_tok));
 	m = (int)(signed char)lejp_parse(&jctx, (uint8_t *)buf, n);
 	lejp_destruct(&jctx);
 	if (m < 0) {
diff --git a/lib/misc/lejp.c b/lib/misc/lejp.c
index f945d09ae1fb62dc46ea9156bea70a2ed40133da..99142b9553e61c3d76fb5498b204c36c45979ad2 100644
--- a/lib/misc/lejp.c
+++ b/lib/misc/lejp.c
@@ -20,6 +20,7 @@
  */
 
 #include <libwebsockets.h>
+#include "core/private.h"
 #include <string.h>
 #include <stdio.h>
 
@@ -30,7 +31,7 @@
  * \param callback:	your user callback which will received parsed tokens
  * \param user:	optional user data pointer untouched by lejp
  * \param paths:	your array of name elements you are interested in
- * \param count_paths:	ARRAY_SIZE() of @paths
+ * \param count_paths:	LWS_ARRAY_SIZE() of @paths
  *
  * Prepares your context struct for use with lejp
  */
@@ -417,7 +418,7 @@ lejp_parse(struct lejp_ctx *ctx, const unsigned char *json, int len)
 					goto reject;
 				}
 				ctx->i[ctx->ipos++] = 0;
-				if (ctx->ipos > ARRAY_SIZE(ctx->i)) {
+				if (ctx->ipos > LWS_ARRAY_SIZE(ctx->i)) {
 					ret = LEJP_REJECT_MP_DELIM_ISTACK;
 					goto reject;
 				}
@@ -722,7 +723,7 @@ add_stack_level:
 
 		ctx->st[ctx->sp].p = ctx->ppos;
 		ctx->st[ctx->sp].i = ctx->ipos;
-		if (++ctx->sp == ARRAY_SIZE(ctx->st)) {
+		if (++ctx->sp == LWS_ARRAY_SIZE(ctx->st)) {
 			ret = LEJP_REJECT_STACK_OVERFLOW;
 			goto reject;
 		}
diff --git a/lib/plat/esp32/esp32-helpers.c b/lib/plat/esp32/esp32-helpers.c
index b624651f36659e282da2791e7a3ddc69770f5ae4..cf60784e507448703e49bfbc9cf0cf42d22cd9ac 100644
--- a/lib/plat/esp32/esp32-helpers.c
+++ b/lib/plat/esp32/esp32-helpers.c
@@ -412,7 +412,7 @@ end_scan()
 	uint16_t count_ap_records;
 	int n, m;
 
-	count_ap_records = ARRAY_SIZE(ap_records);
+	count_ap_records = LWS_ARRAY_SIZE(ap_records);
 	if (esp_wifi_scan_get_ap_records(&count_ap_records, ap_records)) {
 		lwsl_err("%s: failed\n", __func__);
 		return;
@@ -636,7 +636,7 @@ esp_err_t lws_esp32_event_passthru(void *ctx, system_event_t *event)
 
 			mdns_service_add(lws_esp32.group,
 					 "_lwsgrmem", "_tcp", 443, txta,
-					 ARRAY_SIZE(txta));
+					 LWS_ARRAY_SIZE(txta));
 
 			mem = lws_esp32.first;
 			while (mem) {
diff --git a/lib/plat/windows/windows-file.c b/lib/plat/windows/windows-file.c
index ee9dc7418e4d8273fdada5d06b08ee9a9f25a2e9..6516b70b0864cd3ab6f905b561e76a95ee2f9584 100644
--- a/lib/plat/windows/windows-file.c
+++ b/lib/plat/windows/windows-file.c
@@ -38,7 +38,7 @@ _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,
 	lws_fop_fd_t fop_fd;
 	LARGE_INTEGER llFileSize = {0};
 
-	MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, ARRAY_SIZE(buf));
+	MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, LWS_ARRAY_SIZE(buf));
 	if (((*flags) & 7) == _O_RDONLY) {
 		ret = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ,
 			  NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
diff --git a/lib/roles/cgi/cgi-server.c b/lib/roles/cgi/cgi-server.c
index 5c4b10c2775329eaafeeb0aace3ac5fe1c5b3705..cb80fc5a50537ffa0ee5fb48453a735c05173707 100644
--- a/lib/roles/cgi/cgi-server.c
+++ b/lib/roles/cgi/cgi-server.c
@@ -228,7 +228,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
 		};
 
 		if (script_uri_path_len >= 0)
-			for (m = 0; m < (int)ARRAY_SIZE(meths); m++)
+			for (m = 0; m < (int)LWS_ARRAY_SIZE(meths); m++)
 				if (lws_hdr_total_length(wsi, meths[m]) >=
 						script_uri_path_len) {
 					uritok = meths[m];
diff --git a/lib/roles/h2/hpack.c b/lib/roles/h2/hpack.c
index d25849d0a1d9534ea83d2b0b0558af4c1d3dbc3e..b59ce9f9e1b4aa8d1b83fdbfabec9bd481fcf612 100644
--- a/lib/roles/h2/hpack.c
+++ b/lib/roles/h2/hpack.c
@@ -219,7 +219,7 @@ static int lws_frag_start(struct lws *wsi, int hdr_token_idx)
 		return 1;
 	}
 
-	if (ah->nfrag >= ARRAY_SIZE(ah->frag_index)) {
+	if (ah->nfrag >= LWS_ARRAY_SIZE(ah->frag_index)) {
 		lwsl_err("%s: frag index %d too big\n", __func__, ah->nfrag);
 		return 1;
 	}
@@ -375,8 +375,8 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len,
 	if (index < 0)
 		return -1;
 
-	if (index < (int)ARRAY_SIZE(static_token)) {
-		if (arg && index < (int)ARRAY_SIZE(http2_canned)) {
+	if (index < (int)LWS_ARRAY_SIZE(static_token)) {
+		if (arg && index < (int)LWS_ARRAY_SIZE(http2_canned)) {
 			*arg = http2_canned[index];
 			*len = (int)strlen(http2_canned[index]);
 		}
@@ -391,8 +391,8 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len,
 		return -1;
 	}
 
-	if (index < (int)ARRAY_SIZE(static_token) ||
-	    index >= (int)ARRAY_SIZE(static_token) + dyn->used_entries) {
+	if (index < (int)LWS_ARRAY_SIZE(static_token) ||
+	    index >= (int)LWS_ARRAY_SIZE(static_token) + dyn->used_entries) {
 		lwsl_info("  %s: adjusted index %d >= %d\n", __func__, index,
 			    dyn->used_entries);
 		lws_h2_goaway(wsi, H2_ERR_COMPRESSION_ERROR,
@@ -400,7 +400,7 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len,
 		return -1;
 	}
 
-	index -= (int)ARRAY_SIZE(static_token);
+	index -= (int)LWS_ARRAY_SIZE(static_token);
 	index = (dyn->pos - 1 - index) % dyn->num_entries;
 	if (index < 0)
 		index += dyn->num_entries;
@@ -435,7 +435,7 @@ lws_h2_dynamic_table_dump(struct lws *wsi)
 	lwsl_header("Dump dyn table for nwsi %p (%d / %d members, pos = %d, "
 		    "start index %d, virt used %d / %d)\n", nwsi,
 		    dyn->used_entries, dyn->num_entries, dyn->pos,
-		    (uint32_t)ARRAY_SIZE(static_token),
+		    (uint32_t)LWS_ARRAY_SIZE(static_token),
 		    dyn->virtual_payload_usage, dyn->virtual_payload_max);
 
 	for (n = 0; n < dyn->used_entries; n++) {
@@ -448,7 +448,7 @@ lws_h2_dynamic_table_dump(struct lws *wsi)
 		else
 			p = "(ignored)";
 		lwsl_header("   %3d: tok %s: (len %d) val '%s'\n",
-			    (int)(n + ARRAY_SIZE(static_token)), p,
+			    (int)(n + LWS_ARRAY_SIZE(static_token)), p,
 			    dyn->entries[m].hdr_len, dyn->entries[m].value ?
 			    dyn->entries[m].value : "null");
 	}
@@ -552,7 +552,7 @@ lws_dynamic_token_insert(struct lws *wsi, int hdr_len,
 	dyn->virtual_payload_usage += hdr_len + len;
 
 	lwsl_info("%s: index %ld: lws_hdr_index 0x%x, hdr len %d, '%s' len %d\n",
-		  __func__, (long)ARRAY_SIZE(static_token),
+		  __func__, (long)LWS_ARRAY_SIZE(static_token),
 		  lws_hdr_index, hdr_len, dyn->entries[new_index].value ?
 				 dyn->entries[new_index].value : "null", len);
 
@@ -726,7 +726,7 @@ lws_hpack_use_idx_hdr(struct lws *wsi, int idx, int known_token)
 	if (arg)
 		p = arg;
 
-	if (idx < (int)ARRAY_SIZE(http2_canned))
+	if (idx < (int)LWS_ARRAY_SIZE(http2_canned))
 		p = http2_canned[idx];
 
 	if (lws_frag_start(wsi, tok))
diff --git a/lib/roles/h2/minihuf.c b/lib/roles/h2/minihuf.c
index eaf84e5d8cbf69dd948afd33a81e632c28a75824..ee19e378ea7016593392535d08bd8206c28a99c4 100644
--- a/lib/roles/h2/minihuf.c
+++ b/lib/roles/h2/minihuf.c
@@ -16,7 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0]))
+#define LWS_ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0]))
 
 struct huf {
 	unsigned int code;
@@ -340,7 +340,7 @@ int main(void)
 	int fails = 0;
 
 	m = 0;
-	while (m < ARRAY_SIZE(state)) {
+	while (m < LWS_ARRAY_SIZE(state)) {
 		for (j = 0; j < PARALLEL; j++) {
 			state[m].state[j] = 0xffff;
 			state[m].terminal = 0;
@@ -348,7 +348,7 @@ int main(void)
 		m++;
 	}
 
-	while (n < ARRAY_SIZE(huf_literal)) {
+	while (n < LWS_ARRAY_SIZE(huf_literal)) {
 
 		m = 0;
 		walk = 0;
@@ -474,7 +474,7 @@ again:
 	 * Try to parse every legal input string
 	 */
 
-	for (n = 0; n < ARRAY_SIZE(huf_literal); n++) {
+	for (n = 0; n < LWS_ARRAY_SIZE(huf_literal); n++) {
 		walk = 0;
 		m = 0;
 		y = -1;
diff --git a/lib/roles/http/header.c b/lib/roles/http/header.c
index 2f020f153a9d7b81ff9bcbd9fb255b3a2220af89..ca2e6dad3274798e14836a3268d9ae7745584a3d 100644
--- a/lib/roles/http/header.c
+++ b/lib/roles/http/header.c
@@ -26,7 +26,7 @@
 const unsigned char *
 lws_token_to_string(enum lws_token_indexes token)
 {
-	if ((unsigned int)token >= ARRAY_SIZE(set))
+	if ((unsigned int)token >= LWS_ARRAY_SIZE(set))
 		return NULL;
 
 	return (unsigned char *)set[token];
@@ -215,9 +215,9 @@ lws_add_http_header_status(struct lws *wsi, unsigned int _code,
 	if (lwsi_role_h2(wsi) || lwsi_role_h2_ENCAPSULATION(wsi))
 		return lws_add_http2_header_status(wsi, code, p, end);
 #endif
-	if (code >= 400 && code < (400 + ARRAY_SIZE(err400)))
+	if (code >= 400 && code < (400 + LWS_ARRAY_SIZE(err400)))
 		description = err400[code - 400];
-	if (code >= 500 && code < (500 + ARRAY_SIZE(err500)))
+	if (code >= 500 && code < (500 + LWS_ARRAY_SIZE(err500)))
 		description = err500[code - 500];
 
 	if (code == 100)
@@ -230,7 +230,7 @@ lws_add_http_header_status(struct lws *wsi, unsigned int _code,
 		if (code >= 300 && code < 400)
 			description = "Redirect";
 
-	if (wsi->http.request_version < ARRAY_SIZE(hver))
+	if (wsi->http.request_version < LWS_ARRAY_SIZE(hver))
 		p1 = hver[wsi->http.request_version];
 	else
 		p1 = hver[0];
diff --git a/lib/roles/http/server/lejp-conf.c b/lib/roles/http/server/lejp-conf.c
index dc49bf61ffb6f3208af117ddb714ca74ed00d5bc..94912439d39d393a38be729367b18b45c8ab72a6 100644
--- a/lib/roles/http/server/lejp-conf.c
+++ b/lib/roles/http/server/lejp-conf.c
@@ -225,7 +225,7 @@ arg_to_bool(const char *s)
 	if (n)
 		return 1;
 
-	for (n = 0; n < (int)ARRAY_SIZE(on); n++)
+	for (n = 0; n < (int)LWS_ARRAY_SIZE(on); n++)
 		if (!strcasecmp(s, on[n]))
 			return 1;
 
@@ -503,7 +503,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
 		if (a->last)
 			a->last->mount_next = m;
 
-		for (n = 0; n < (int)ARRAY_SIZE(mount_protocols); n++)
+		for (n = 0; n < (int)LWS_ARRAY_SIZE(mount_protocols); n++)
 			if (!strncmp(a->m.origin, mount_protocols[n],
 			     strlen(mount_protocols[n]))) {
 				lwsl_info("----%s\n", a->m.origin);
@@ -513,7 +513,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
 				break;
 			}
 
-		if (n == (int)ARRAY_SIZE(mount_protocols)) {
+		if (n == (int)LWS_ARRAY_SIZE(mount_protocols)) {
 			lwsl_err("unsupported protocol:// %s\n", a->m.origin);
 			return 1;
 		}
@@ -928,11 +928,11 @@ lwsws_get_config_globals(struct lws_context_creation_info *info, const char *d,
 
 	lws_snprintf(dd, sizeof(dd) - 1, "%s/conf", d);
 	if (lwsws_get_config(&a, dd, paths_global,
-			     ARRAY_SIZE(paths_global), lejp_globals_cb) > 1)
+			     LWS_ARRAY_SIZE(paths_global), lejp_globals_cb) > 1)
 		return 1;
 	lws_snprintf(dd, sizeof(dd) - 1, "%s/conf.d", d);
 	if (lwsws_get_config_d(&a, dd, paths_global,
-			       ARRAY_SIZE(paths_global), lejp_globals_cb) > 1)
+			       LWS_ARRAY_SIZE(paths_global), lejp_globals_cb) > 1)
 		return 1;
 
 	a.plugin_dirs[a.count_plugin_dirs] = NULL;
@@ -963,11 +963,11 @@ lwsws_get_config_vhosts(struct lws_context *context,
 
 	lws_snprintf(dd, sizeof(dd) - 1, "%s/conf", d);
 	if (lwsws_get_config(&a, dd, paths_vhosts,
-			     ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1)
+			     LWS_ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1)
 		return 1;
 	lws_snprintf(dd, sizeof(dd) - 1, "%s/conf.d", d);
 	if (lwsws_get_config_d(&a, dd, paths_vhosts,
-			       ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1)
+			       LWS_ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) > 1)
 		return 1;
 
 	*cs = a.p;
diff --git a/lib/roles/http/server/lws-spa.c b/lib/roles/http/server/lws-spa.c
index 916254c0a40217eca90135f0d277b632f3d10792..a67bd9fee90f0222fe549a9fff44092be430b756 100644
--- a/lib/roles/http/server/lws-spa.c
+++ b/lib/roles/http/server/lws-spa.c
@@ -263,7 +263,7 @@ retry_as_first:
 			c =*in;
 			if (c >= 'A' && c <= 'Z')
 				c += 'a' - 'A';
-			for (n = 0; n < (int)ARRAY_SIZE(mp_hdr); n++)
+			for (n = 0; n < (int)LWS_ARRAY_SIZE(mp_hdr); n++)
 				if (c == mp_hdr[n][s->mp]) {
 					m++;
 					hit = n;
diff --git a/lib/roles/http/server/parsers.c b/lib/roles/http/server/parsers.c
index 62778b8a04f3a6c4b38ffc2f8392ce596ad0d438..1c0f6564eb7999eadccee5ad9c73a93bdd2dbcaa 100644
--- a/lib/roles/http/server/parsers.c
+++ b/lib/roles/http/server/parsers.c
@@ -563,7 +563,7 @@ int LWS_WARN_UNUSED_RESULT
 lws_hdr_simple_create(struct lws *wsi, enum lws_token_indexes h, const char *s)
 {
 	wsi->http.ah->nfrag++;
-	if (wsi->http.ah->nfrag == ARRAY_SIZE(wsi->http.ah->frags)) {
+	if (wsi->http.ah->nfrag == LWS_ARRAY_SIZE(wsi->http.ah->frags)) {
 		lwsl_warn("More hdr frags than we can deal with, dropping\n");
 		return -1;
 	}
@@ -683,7 +683,7 @@ lws_parse_urldecode(struct lws *wsi, uint8_t *_c)
 			/* link to next fragment */
 			ah->frags[ah->nfrag].nfrag = ah->nfrag + 1;
 			ah->nfrag++;
-			if (ah->nfrag >= ARRAY_SIZE(ah->frags))
+			if (ah->nfrag >= LWS_ARRAY_SIZE(ah->frags))
 				goto excessive;
 			/* start next fragment after the & */
 			ah->post_literal_equal = 0;
@@ -786,7 +786,7 @@ lws_parse_urldecode(struct lws *wsi, uint8_t *_c)
 
 		/* move to using WSI_TOKEN_HTTP_URI_ARGS */
 		ah->nfrag++;
-		if (ah->nfrag >= ARRAY_SIZE(ah->frags))
+		if (ah->nfrag >= LWS_ARRAY_SIZE(ah->frags))
 			goto excessive;
 		ah->frags[ah->nfrag].offset = ++ah->pos;
 		ah->frags[ah->nfrag].len = 0;
@@ -851,10 +851,10 @@ lws_parse(struct lws *wsi, unsigned char *buf, int *len)
 			    c == ' ')
 				break;
 
-			for (m = 0; m < ARRAY_SIZE(methods); m++)
+			for (m = 0; m < LWS_ARRAY_SIZE(methods); m++)
 				if (ah->parser_state == methods[m])
 					break;
-			if (m == ARRAY_SIZE(methods))
+			if (m == LWS_ARRAY_SIZE(methods))
 				/* it was not any of the methods */
 				goto check_eol;
 
@@ -982,7 +982,7 @@ nope:
 			if (ah->lextable_pos < 0 && lwsi_role_h1(wsi) &&
 			    lwsi_role_server(wsi)) {
 				/* this is not a header we know about */
-				for (m = 0; m < ARRAY_SIZE(methods); m++)
+				for (m = 0; m < LWS_ARRAY_SIZE(methods); m++)
 					if (ah->frag_index[methods[m]]) {
 						/*
 						 * already had the method, no idea what
@@ -995,7 +995,7 @@ nope:
 				 * hm it's an unknown http method from a client in fact,
 				 * it cannot be valid http
 				 */
-				if (m == ARRAY_SIZE(methods)) {
+				if (m == LWS_ARRAY_SIZE(methods)) {
 					/*
 					 * are we set up to accept raw in these cases?
 					 */
@@ -1024,7 +1024,7 @@ nope:
 						lextable[ah->lextable_pos + 1];
 
 				lwsl_parser("known hdr %d\n", n);
-				for (m = 0; m < ARRAY_SIZE(methods); m++)
+				for (m = 0; m < LWS_ARRAY_SIZE(methods); m++)
 					if (n == methods[m] &&
 					    ah->frag_index[methods[m]]) {
 						lwsl_warn("Duplicated method\n");
@@ -1060,7 +1060,7 @@ nope:
 start_fragment:
 			ah->nfrag++;
 excessive:
-			if (ah->nfrag == ARRAY_SIZE(ah->frags)) {
+			if (ah->nfrag == LWS_ARRAY_SIZE(ah->frags)) {
 				lwsl_warn("More hdr frags than we can deal with\n");
 				return -1;
 			}
diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index d948fa2989b86f569563e907210229765f1781b7..44b84a234380bb0d937eea0c41ebec1c57851bcb 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -855,7 +855,7 @@ lws_http_get_uri_and_method(struct lws *wsi, char **puri_ptr, int *puri_len)
 {
 	int n, count = 0;
 
-	for (n = 0; n < (int)ARRAY_SIZE(methods); n++)
+	for (n = 0; n < (int)LWS_ARRAY_SIZE(methods); n++)
 		if (lws_hdr_total_length(wsi, methods[n]))
 			count++;
 	if (!count) {
@@ -870,7 +870,7 @@ lws_http_get_uri_and_method(struct lws *wsi, char **puri_ptr, int *puri_len)
 		return -1;
 	}
 
-	for (n = 0; n < (int)ARRAY_SIZE(methods); n++)
+	for (n = 0; n < (int)LWS_ARRAY_SIZE(methods); n++)
 		if (lws_hdr_total_length(wsi, methods[n])) {
 			*puri_ptr = lws_hdr_simple_ptr(wsi, methods[n]);
 			*puri_len = lws_hdr_total_length(wsi, methods[n]);
@@ -900,7 +900,7 @@ lws_http_action(struct lws *wsi)
 	};
 
 	meth = lws_http_get_uri_and_method(wsi, &uri_ptr, &uri_len);
-	if (meth < 0 || meth >= (int)ARRAY_SIZE(method_names))
+	if (meth < 0 || meth >= (int)LWS_ARRAY_SIZE(method_names))
 		goto bail_nuke_ah;
 
 	/* we insist on absolute paths */
diff --git a/lib/roles/ws/ext/extension-permessage-deflate.c b/lib/roles/ws/ext/extension-permessage-deflate.c
index 3998003cc91244c92efae18a9bbdf144916d32ac..405c2329890eb699204bbfbd4859ae4f716b50d1 100644
--- a/lib/roles/ws/ext/extension-permessage-deflate.c
+++ b/lib/roles/ws/ext/extension-permessage-deflate.c
@@ -83,12 +83,12 @@ lws_extension_callback_pm_deflate(struct lws_context *context,
 		if (!oa->option_name)
 			break;
 		lwsl_ext("%s: named option set: %s\n", __func__, oa->option_name);
-		for (n = 0; n < (int)ARRAY_SIZE(lws_ext_pm_deflate_options); n++)
+		for (n = 0; n < (int)LWS_ARRAY_SIZE(lws_ext_pm_deflate_options); n++)
 			if (!strcmp(lws_ext_pm_deflate_options[n].name,
 				    oa->option_name))
 				break;
 
-		if (n == (int)ARRAY_SIZE(lws_ext_pm_deflate_options))
+		if (n == (int)LWS_ARRAY_SIZE(lws_ext_pm_deflate_options))
 			break;
 		oa->option_index = n;
 
diff --git a/lib/tls/mbedtls/mbedtls-server.c b/lib/tls/mbedtls/mbedtls-server.c
index 2de6d422e37c3fafb1ba4dbee5edcdd7299376e3..f17c7e5494f3614dd9238b4da16082f0bec5594e 100644
--- a/lib/tls/mbedtls/mbedtls-server.c
+++ b/lib/tls/mbedtls/mbedtls-server.c
@@ -631,7 +631,7 @@ lws_tls_acme_sni_csr_create(struct lws_context *context, const char *elements[],
 
 	/* subject must be formatted like "C=TW,O=warmcat,CN=myserver" */
 
-	for (n = 0; n < (int)ARRAY_SIZE(x5); n++) {
+	for (n = 0; n < (int)LWS_ARRAY_SIZE(x5); n++) {
 		if (p != subject)
 			*p++ = ',';
 		if (elements[n])
diff --git a/lwsws/main.c b/lwsws/main.c
index 2055d774b70273f6e2fe13c9ff428dae38af2870..ecfd948b00e1ad8af9d55fef0c453dba2897d9cf 100644
--- a/lwsws/main.c
+++ b/lwsws/main.c
@@ -183,7 +183,7 @@ reload_handler(int signum)
 		fprintf(stderr, "root process receives reload\n");
 		if (!do_reload) {
 			fprintf(stderr, "passing HUP to child processes\n");
-			for (m = 0; m < (int)ARRAY_SIZE(pids); m++)
+			for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++)
 				if (pids[m])
 					kill(pids[m], SIGHUP);
 			sleep(1);
@@ -196,7 +196,7 @@ reload_handler(int signum)
 		fprintf(stderr, "master process waiting 2s...\n");
 		sleep(2); /* give children a chance to deal with the signal */
 		fprintf(stderr, "killing service processes\n");
-		for (m = 0; m < (int)ARRAY_SIZE(pids); m++)
+		for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++)
 			if (pids[m])
 				kill(pids[m], SIGTERM);
 		exit(0);
@@ -254,7 +254,7 @@ int main(int argc, char **argv)
 				break;
 			/* old */
 			if (n > 0)
-				for (m = 0; m < (int)ARRAY_SIZE(pids); m++)
+				for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++)
 					if (!pids[m]) {
 						// fprintf(stderr, "added child pid %d\n", n);
 						pids[m] = n;
@@ -266,7 +266,7 @@ int main(int argc, char **argv)
 
 		n = waitpid(-1, &status, WNOHANG);
 		if (n > 0)
-			for (m = 0; m < (int)ARRAY_SIZE(pids); m++)
+			for (m = 0; m < (int)LWS_ARRAY_SIZE(pids); m++)
 				if (pids[m] == n) {
 					// fprintf(stderr, "reaped child pid %d\n", pids[m]);
 					pids[m] = 0;
diff --git a/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c b/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c
index 7fb811eeefca8633c54017f7ecb59e0f8dd2d0b5..8e9a454d607ee2b349a6cf2072fb445b192c942b 100644
--- a/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c
+++ b/minimal-examples/client-server/minimal-ws-proxy/protocol_lws_minimal.c
@@ -264,7 +264,7 @@ init_protocol_minimal(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c
index 54f0f1188f8f9d87a45b583c599c71554d8811e6..ae2380ce99d01d8786daec3ffa5d32b95efceb54 100644
--- a/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c
+++ b/minimal-examples/http-server/minimal-http-server-form-get/minimal-http-server-form-get.c
@@ -43,7 +43,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
 
 		/* we just dump the decoded things to the log */
 
-		for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) {
+		for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) {
 			val = lws_get_urlarg_by_name(wsi, param_names[n],
 					(char *)buf, sizeof(buf));
 			if (!val)
diff --git a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c
index 486e9e643b088c673aacc78d3281753e0f51ea7b..d58d89202a9f11f339d7bfeb9cab675978bea718 100644
--- a/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c
+++ b/minimal-examples/http-server/minimal-http-server-form-post-file/minimal-http-server-form-post-file.c
@@ -125,7 +125,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
 
 		if (!pss->spa) {
 			pss->spa = lws_spa_create(wsi, param_names,
-					ARRAY_SIZE(param_names), 1024,
+					LWS_ARRAY_SIZE(param_names), 1024,
 					file_upload_cb, pss);
 			if (!pss->spa)
 				return -1;
@@ -145,7 +145,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
 
 		/* we just dump the decoded things to the log */
 
-		for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) {
+		for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) {
 			if (!lws_spa_get_string(pss->spa, n))
 				lwsl_user("%s: undefined\n", param_names[n]);
 			else
diff --git a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c
index 2f50863a047eed6a4b8c2e38062ec01780870342..d6cfc6b784709e5303e5cda70cb18a23d1eee5bb 100644
--- a/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c
+++ b/minimal-examples/http-server/minimal-http-server-form-post/minimal-http-server-form-post.c
@@ -69,7 +69,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
 
 		if (!pss->spa) {
 			pss->spa = lws_spa_create(wsi, param_names,
-					ARRAY_SIZE(param_names), 1024,
+					LWS_ARRAY_SIZE(param_names), 1024,
 					NULL, NULL); /* no file upload */
 			if (!pss->spa)
 				return -1;
@@ -89,7 +89,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
 
 		/* we just dump the decoded things to the log */
 
-		for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) {
+		for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) {
 			if (!lws_spa_get_string(pss->spa, n))
 				lwsl_user("%s: undefined\n", param_names[n]);
 			else
diff --git a/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c b/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c
index cdee75c4fc49278c3cbb0c70d5c5d144b10ff2e9..31149074b090a5e16ff2f53c442a9b66c6693220 100644
--- a/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c
+++ b/minimal-examples/ws-client/minimal-ws-client-echo/protocol_lws_minimal_client_echo.c
@@ -294,7 +294,7 @@ init_protocol_minimal_client_echo(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c
index e4c48c101b1be80cc8a41d973c3657d25e438f1c..a1bb7052fd31dacbc07cf04fc0f883346c3b46fd 100644
--- a/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c
+++ b/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c
@@ -304,7 +304,7 @@ init_protocol_minimal_pmd_bulk(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c
index b2efc6cbee66f53504bcb5b7da2ecfd8ed37aeb3..8fba881859e4b3ceac49cec791e5b85065058505 100644
--- a/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c
+++ b/minimal-examples/ws-server/minimal-ws-broker/protocol_lws_minimal.c
@@ -235,7 +235,7 @@ init_protocol_minimal(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c b/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c
index aa3a0440e2b7b213c30376384ce602e09b7ab2f1..fd108606f86cd43dfc5724010a74849180ccb80f 100644
--- a/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c
+++ b/minimal-examples/ws-server/minimal-ws-server-echo/protocol_lws_minimal_server_echo.c
@@ -243,7 +243,7 @@ init_protocol_minimal_server_echo(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c
index 58fe1604b220b4949c2d8f890b1c56c602f4bcf4..33d4eedc1a0856ed98e63055a56491988a66162e 100644
--- a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c
+++ b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/protocol_lws_minimal_pmd_bulk.c
@@ -241,7 +241,7 @@ init_protocol_minimal_pmd_bulk(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c
index b9ec3305f9a23f2a91780c4ac9128c4c98cca51a..441951e98e3b205ccb136f26c41d9810818eadc4 100644
--- a/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c
+++ b/minimal-examples/ws-server/minimal-ws-server-pmd/protocol_lws_minimal.c
@@ -178,7 +178,7 @@ init_protocol_minimal(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c
index bd88f029568ff604d617942b9535fd2922f17ec0..0da2ff4245c8548035bc468e61818574d16548c4 100644
--- a/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c
+++ b/minimal-examples/ws-server/minimal-ws-server-ring/protocol_lws_minimal.c
@@ -299,7 +299,7 @@ init_protocol_minimal(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c
index 121296291a6b2190934edc94237c479d7cea6f7a..ab9b88d6e37acce45fd788125754244abbf01e3c 100644
--- a/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c
+++ b/minimal-examples/ws-server/minimal-ws-server-threads/protocol_lws_minimal.c
@@ -303,7 +303,7 @@ init_protocol_minimal(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c b/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c
index 26f20c2f8eafcdf45ca02350a9f824c64db37832..2d41257b322660e7a12d2b523b14a5166e547a4a 100644
--- a/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c
+++ b/minimal-examples/ws-server/minimal-ws-server/protocol_lws_minimal.c
@@ -172,7 +172,7 @@ init_protocol_minimal(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugin-standalone/protocol_example_standalone.c b/plugin-standalone/protocol_example_standalone.c
index 36172d43b32e4878cdc34d31f37aaed6272bbaae..19a5a435e81af229496d0a92941a7ccb564d88fc 100644
--- a/plugin-standalone/protocol_example_standalone.c
+++ b/plugin-standalone/protocol_example_standalone.c
@@ -138,7 +138,7 @@ init_protocol_example_standalone(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/acme-client/protocol_lws_acme_client.c b/plugins/acme-client/protocol_lws_acme_client.c
index 828ef95bf3e0a5315c5df5de14320371c3ed86b7..9ccd8945e70419941edd618ce54c757084bee9d5 100644
--- a/plugins/acme-client/protocol_lws_acme_client.c
+++ b/plugins/acme-client/protocol_lws_acme_client.c
@@ -585,7 +585,7 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason,
 			memcpy(start, pvo->value, n);
 			p += n;
 
-			for (m = 0; m < (int)ARRAY_SIZE(pvo_names); m++)
+			for (m = 0; m < (int)LWS_ARRAY_SIZE(pvo_names); m++)
 				if (!strcmp(pvo->name, pvo_names[m]))
 					vhd->pvop[m] = start;
 
@@ -593,7 +593,7 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason,
 		}
 
 		n = 0;
-		for (m = 0; m < (int)ARRAY_SIZE(pvo_names); m++)
+		for (m = 0; m < (int)LWS_ARRAY_SIZE(pvo_names); m++)
 			if (!vhd->pvop[m] && m >= LWS_TLS_REQ_ELEMENT_COMMON_NAME) {
 				lwsl_notice("%s: require pvo '%s'\n", __func__,
 						pvo_names[m]);
@@ -669,7 +669,7 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason,
 		if (vhd->vhost != caa->vh)
 			return 1;
 
-		for (n = 0; n < (int)ARRAY_SIZE(vhd->pvop);n++)
+		for (n = 0; n < (int)LWS_ARRAY_SIZE(vhd->pvop);n++)
 			if (caa->element_overrides[n])
 				vhd->pvop_active[n] = caa->element_overrides[n];
 			else
@@ -720,19 +720,19 @@ callback_acme_client(struct lws *wsi, enum lws_callback_reasons reason,
 		switch (ac->state) {
 		case ACME_STATE_DIRECTORY:
 			lejp_construct(&ac->jctx, cb_dir, vhd, jdir_tok,
-				       ARRAY_SIZE(jdir_tok));
+				       LWS_ARRAY_SIZE(jdir_tok));
 			break;
 		case ACME_STATE_NEW_REG:
 			break;
 		case ACME_STATE_NEW_AUTH:
 			lejp_construct(&ac->jctx, cb_authz, ac, jauthz_tok,
-				       ARRAY_SIZE(jauthz_tok));
+					LWS_ARRAY_SIZE(jauthz_tok));
 			break;
 
 		case ACME_STATE_POLLING:
 		case ACME_STATE_ACCEPT_CHALL:
 			lejp_construct(&ac->jctx, cb_chac, ac, jchac_tok,
-				       ARRAY_SIZE(jchac_tok));
+					LWS_ARRAY_SIZE(jchac_tok));
 			break;
 
 		case ACME_STATE_POLLING_CSR:
@@ -1598,7 +1598,7 @@ init_protocol_lws_acme_client(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/generic-sessions/protocol_generic_sessions.c b/plugins/generic-sessions/protocol_generic_sessions.c
index eb2ab6759f5a04db8c2267dcdbed967196aaa5ce..975659daf6f550ab5fc91cb16e4c94cb749fee1a 100644
--- a/plugins/generic-sessions/protocol_generic_sessions.c
+++ b/plugins/generic-sessions/protocol_generic_sessions.c
@@ -553,7 +553,7 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason,
 			a.wsi = wsi;
 
 			pss->phs.vars = vars;
-			pss->phs.count_vars = ARRAY_SIZE(vars);
+			pss->phs.count_vars = LWS_ARRAY_SIZE(vars);
 			pss->phs.replace = lwsgs_subst;
 			pss->phs.data = &a;
 
@@ -568,7 +568,7 @@ callback_generic_sessions(struct lws *wsi, enum lws_callback_reasons reason,
 
 		if (!pss->spa) {
 			pss->spa = lws_spa_create(wsi, param_names,
-						ARRAY_SIZE(param_names), 1024,
+					LWS_ARRAY_SIZE(param_names), 1024,
 						NULL, NULL);
 			if (!pss->spa)
 				return -1;
@@ -901,7 +901,7 @@ init_protocol_generic_sessions(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/generic-sessions/protocol_lws_messageboard.c b/plugins/generic-sessions/protocol_lws_messageboard.c
index de65ad702baef7201a9ea80d5d8d2bd8b39c5b7a..45ad1f5cbb11d92d3a17e040677362a733ce3d84 100644
--- a/plugins/generic-sessions/protocol_lws_messageboard.c
+++ b/plugins/generic-sessions/protocol_lws_messageboard.c
@@ -294,7 +294,7 @@ callback_messageboard(struct lws *wsi, enum lws_callback_reasons reason,
 			break;
 		if (!pss->spa) {
 			pss->spa = lws_spa_create(wsi, param_names,
-						ARRAY_SIZE(param_names),
+					LWS_ARRAY_SIZE(param_names),
 						MAX_MSG_LEN + 1024, NULL, NULL);
 			if (!pss->spa)
 				return -1;
@@ -408,7 +408,7 @@ init_protocol_lws_messageboard(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/generic-table/protocol_table_dirlisting.c b/plugins/generic-table/protocol_table_dirlisting.c
index 9cbb2155901e51c95247469c64ee1b6dccd96f67..ed184f6e1a93adbaac574305afbd4e02cea9cf13 100644
--- a/plugins/generic-table/protocol_table_dirlisting.c
+++ b/plugins/generic-table/protocol_table_dirlisting.c
@@ -380,7 +380,7 @@ init_protocol_lws_table_dirlisting(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_client_loopback_test.c b/plugins/protocol_client_loopback_test.c
index 5ec33f6f27819301f5427ec1f54a8a681ba146ea..5ae15ddc1759d71f4a4ab0cd6884a869de5dfe6a 100644
--- a/plugins/protocol_client_loopback_test.c
+++ b/plugins/protocol_client_loopback_test.c
@@ -184,7 +184,7 @@ init_protocol_client_loopback_test(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_dumb_increment.c b/plugins/protocol_dumb_increment.c
index 47b293c0700d79387ee2ba5ab04d29c62cba3079..7f6b5cac3e09764c3bf7b6e5d09a18f8864fa782 100644
--- a/plugins/protocol_dumb_increment.c
+++ b/plugins/protocol_dumb_increment.c
@@ -132,7 +132,7 @@ init_protocol_dumb_increment(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_esp32_lws_ota.c b/plugins/protocol_esp32_lws_ota.c
index 5eeee7f41a0df14126a03c17978366f887243882..74f2493971ade6f3775bbc4147dfc6f1a5fb92d6 100644
--- a/plugins/protocol_esp32_lws_ota.c
+++ b/plugins/protocol_esp32_lws_ota.c
@@ -200,7 +200,7 @@ callback_esplws_ota(struct lws *wsi, enum lws_callback_reasons reason,
 		lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT, 30);
 		if (!pss->spa) {
 			pss->spa = lws_spa_create(wsi, ota_param_names,
-					ARRAY_SIZE(ota_param_names), 4096,
+					LWS_ARRAY_SIZE(ota_param_names), 4096,
 					ota_file_upload_cb, pss);
 			if (!pss->spa)
 				return -1;
diff --git a/plugins/protocol_esp32_lws_scan.c b/plugins/protocol_esp32_lws_scan.c
index 4dcc1b2ac114e11a349647ac82f911e3c0207860..80ac55861db9e8601bbe673b4c15f22cf366d842 100644
--- a/plugins/protocol_esp32_lws_scan.c
+++ b/plugins/protocol_esp32_lws_scan.c
@@ -347,10 +347,10 @@ scan_finished(uint16_t count, wifi_ap_record_t *recs, void *v)
 
 	vhd->scan_ongoing = 0;
 
-	if (count < ARRAY_SIZE(vhd->ap_records))
+	if (count < LWS_ARRAY_SIZE(vhd->ap_records))
 		vhd->count_ap_records = count;
 	else
-		vhd->count_ap_records = ARRAY_SIZE(vhd->ap_records);
+		vhd->count_ap_records = LWS_ARRAY_SIZE(vhd->ap_records);
 
 	memcpy(vhd->ap_records, recs, vhd->count_ap_records * sizeof(*recs));
 	
@@ -826,7 +826,7 @@ issue:
 
 			lwsl_notice("si %d\n", si);
 
-			for (n = 0; n < ARRAY_SIZE(store_json); n++) {
+			for (n = 0; n < LWS_ARRAY_SIZE(store_json); n++) {
 				if (esplws_simple_arg(p, sizeof(p), in, store_json[n].j))
 					continue;
 
@@ -1020,7 +1020,7 @@ start_le:
 		/* create the POST argument parser if not already existing */
 		if (!pss->spa) {
 			pss->spa = lws_spa_create(wsi, param_names,
-					ARRAY_SIZE(param_names), 1024,
+					LWS_ARRAY_SIZE(param_names), 1024,
 					file_upload_cb, pss);
 			if (!pss->spa)
 				return -1;
@@ -1039,7 +1039,7 @@ start_le:
 		/* call to inform no more payload data coming */
 		lws_spa_finalize(pss->spa);
 
-		for (n = 0; n < ARRAY_SIZE(param_names); n++)
+		for (n = 0; n < LWS_ARRAY_SIZE(param_names); n++)
 			if (lws_spa_get_string(pss->spa, n))
 				lwsl_notice(" Param %s: %s\n", param_names[n],
 					    lws_spa_get_string(pss->spa, n));
diff --git a/plugins/protocol_lws_mirror.c b/plugins/protocol_lws_mirror.c
index f6e2dd498940f75148e80c7821699e472e8f7183..32340d014b169ed544aef7b884df8fcc279bafb8 100644
--- a/plugins/protocol_lws_mirror.c
+++ b/plugins/protocol_lws_mirror.c
@@ -482,7 +482,7 @@ init_protocol_lws_mirror(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_lws_raw_test.c b/plugins/protocol_lws_raw_test.c
index abef4ca664481d63c623bf9a720a0fcbece6bf6d..502a1245fb355f33583259d9155d983aacc01b05 100644
--- a/plugins/protocol_lws_raw_test.c
+++ b/plugins/protocol_lws_raw_test.c
@@ -280,7 +280,7 @@ init_protocol_lws_raw_test(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_lws_server_status.c b/plugins/protocol_lws_server_status.c
index c37f05c3f896880da36e1b8e06c0af693bf15c33..ceef610494c5505f2e726f87552332c9c11af4a3 100644
--- a/plugins/protocol_lws_server_status.c
+++ b/plugins/protocol_lws_server_status.c
@@ -224,7 +224,7 @@ init_protocol_lws_server_status(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_lws_sshd_demo.c b/plugins/protocol_lws_sshd_demo.c
index bca536bb8a41e9dd919fed7079643496c76b0e7d..0143ce8f90dc0635d7a6125217908d32ecc1830a 100644
--- a/plugins/protocol_lws_sshd_demo.c
+++ b/plugins/protocol_lws_sshd_demo.c
@@ -465,7 +465,7 @@ init_protocol_lws_sshd_demo(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_lws_status.c b/plugins/protocol_lws_status.c
index ab91b6067c00cbb62760d49dafdd4700f8a70af7..3df1748866946aa5733ae34ad1981926a38a663a 100644
--- a/plugins/protocol_lws_status.c
+++ b/plugins/protocol_lws_status.c
@@ -255,7 +255,7 @@ init_protocol_lws_status(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/protocol_post_demo.c b/plugins/protocol_post_demo.c
index 8b209273be77a3aaa3a445fcc8ea5352933a0c1f..c5ad9c2d7953dab2dae5968418226c78a5ab3def 100644
--- a/plugins/protocol_post_demo.c
+++ b/plugins/protocol_post_demo.c
@@ -130,7 +130,7 @@ format_result(struct per_session_data__post_demo *pss)
 		"<html><body><h1>Form results (after urldecoding)</h1>"
 		"<table><tr><td>Name</td><td>Length</td><td>Value</td></tr>");
 
-	for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) {
+	for (n = 0; n < (int)LWS_ARRAY_SIZE(param_names); n++) {
 		if (!lws_spa_get_string(pss->spa, n))
 			p += lws_snprintf((char *)p, end - p,
 			    "<tr><td><b>%s</b></td><td>0"
@@ -169,7 +169,7 @@ callback_post_demo(struct lws *wsi, enum lws_callback_reasons reason,
 		/* create the POST argument parser if not already existing */
 		if (!pss->spa) {
 			pss->spa = lws_spa_create(wsi, param_names,
-					ARRAY_SIZE(param_names), 1024,
+					LWS_ARRAY_SIZE(param_names), 1024,
 					file_upload_cb, pss);
 			if (!pss->spa)
 				return -1;
@@ -295,7 +295,7 @@ init_protocol_post_demo(struct lws_context *context,
 	}
 
 	c->protocols = protocols;
-	c->count_protocols = ARRAY_SIZE(protocols);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/plugins/ssh-base/sshd.c b/plugins/ssh-base/sshd.c
index e532a36885cbeca2288b425819e91fdfe736955f..980e4eb3d8c20b7fd7f62b54975f3432e5ad8472 100644
--- a/plugins/ssh-base/sshd.c
+++ b/plugins/ssh-base/sshd.c
@@ -2588,7 +2588,7 @@ init_protocol_lws_ssh_base(struct lws_context *context,
 	}
 
 	c->protocols = protocols_sshd;
-	c->count_protocols = ARRAY_SIZE(protocols_sshd);
+	c->count_protocols = LWS_ARRAY_SIZE(protocols_sshd);
 	c->extensions = NULL;
 	c->count_extensions = 0;
 
diff --git a/test-apps/test-client.c b/test-apps/test-client.c
index 690564081cc1c3d27a39b025b096e112f953dd5c..d05e347e39d5e68b5fa09d0c595e83bb96d3abb5 100644
--- a/test-apps/test-client.c
+++ b/test-apps/test-client.c
@@ -151,7 +151,7 @@ callback_dumb_increment(struct lws *wsi, enum lws_callback_reasons reason,
 			wsi_mirror = NULL;
 		}
 
-		for (n = 0; n < (int)ARRAY_SIZE(wsi_multi); n++)
+		for (n = 0; n < (int)LWS_ARRAY_SIZE(wsi_multi); n++)
 			if (wsi == wsi_multi[n]) {
 				sprintf(which_wsi, "multi %d", n);
 				which = which_wsi;
@@ -786,7 +786,7 @@ int main(int argc, char **argv)
 	while (!force_exit) {
 
 		if (do_multi) {
-			for (n = 0; n < (int)ARRAY_SIZE(wsi_multi); n++) {
+			for (n = 0; n < (int)LWS_ARRAY_SIZE(wsi_multi); n++) {
 				if (!wsi_multi[n] && ratelimit_connects(&rl_multi[n], 2u)) {
 					lwsl_notice("dumb %d: connecting\n", n);
 					i.protocol = protocols[PROTOCOL_DUMB_INCREMENT].name;
diff --git a/test-apps/test-lejp.c b/test-apps/test-lejp.c
index b31770df76e911f32ad900cf60be4d36a7f38988..c5fcdbc22bb9258812839650b70fba6e48f70f82 100644
--- a/test-apps/test-lejp.c
+++ b/test-apps/test-lejp.c
@@ -94,7 +94,7 @@ main(int argc, char *argv[])
 	lwsl_notice("libwebsockets-test-lejp  (C) 2017 - 2018 andy@warmcat.com\n");
 	lwsl_notice("  usage: cat my.json | libwebsockets-test-lejp\n\n");
 
-	lejp_construct(&ctx, cb, NULL, tok, ARRAY_SIZE(tok));
+	lejp_construct(&ctx, cb, NULL, tok, LWS_ARRAY_SIZE(tok));
 
 	fd = 0;