Signed-off-by: Michael Stefaniuc mstefani@winehq.org --- By popular request a generic ARRAY_SIZE(). The one in test.h is kept (with guard) for a standalone compilation.
There is no proper wine only header for this. As ARRAY_SIZE() fits in well with CONTAINING_RECORD() and FIELD_OFFSET() I have added it to winnt.h.
Let the controversy begin!
dlls/advapi32/advapi32_misc.h | 2 -- dlls/appwiz.cpl/appwiz.h | 2 -- dlls/avifil32/avifile_private.h | 2 -- dlls/comctl32/comctl32.h | 2 -- dlls/comdlg32/cdlg.h | 2 -- dlls/crypt32/crypt32_private.h | 2 -- dlls/d2d1/d2d1_private.h | 4 ---- dlls/d3d11/d3d11_private.h | 4 ---- dlls/d3d12/d3d12_main.c | 2 -- dlls/d3d9/d3d9_private.h | 2 -- dlls/d3drm/d3drm_private.h | 4 ---- dlls/d3dx9_36/d3dx9_private.h | 2 -- dlls/ddraw/ddraw_private.h | 2 -- dlls/dmloader/dmloader_private.h | 1 - dlls/dwrite/dwrite_private.h | 2 -- dlls/dxgi/dxgi_private.h | 2 -- dlls/gdiplus/gdiplus_private.h | 2 -- dlls/msi/tokenize.c | 2 -- dlls/msxml3/msxml_private.h | 2 -- dlls/scrrun/scrrun_private.h | 2 -- dlls/shell32/shell32_main.h | 2 -- dlls/user32/user_private.h | 2 -- dlls/usp10/usp10_internal.h | 4 ---- dlls/wined3d/wined3d_private.h | 4 ---- dlls/winevulkan/vulkan_private.h | 4 ---- dlls/wshom.ocx/wshom_private.h | 2 -- dlls/xmllite/xmllite_private.h | 2 -- include/wine/test.h | 4 +++- include/winnt.h | 4 ++++ programs/notepad/main.h | 2 -- programs/reg/reg.h | 1 - programs/regedit/main.h | 2 -- programs/regedit/regproc.c | 2 -- programs/winecfg/winecfg.h | 2 -- programs/winedbg/debugger.h | 2 -- tools/make_xftmpl.c | 2 -- 36 files changed, 7 insertions(+), 79 deletions(-)
diff --git a/dlls/advapi32/advapi32_misc.h b/dlls/advapi32/advapi32_misc.h index be3873a4b4..4ced1e8a64 100644 --- a/dlls/advapi32/advapi32_misc.h +++ b/dlls/advapi32/advapi32_misc.h @@ -25,8 +25,6 @@ #include "winnls.h" #include "wine/heap.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - const char * debugstr_sid(PSID sid) DECLSPEC_HIDDEN; BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName) DECLSPEC_HIDDEN; BOOL ADVAPI_GetComputerSid(PSID sid) DECLSPEC_HIDDEN; diff --git a/dlls/appwiz.cpl/appwiz.h b/dlls/appwiz.cpl/appwiz.h index d18d93aa5f..2165ce11b1 100644 --- a/dlls/appwiz.cpl/appwiz.h +++ b/dlls/appwiz.cpl/appwiz.h @@ -19,8 +19,6 @@ #include "wine/heap.h" #include "wine/unicode.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - typedef enum { ADDON_GECKO, ADDON_MONO diff --git a/dlls/avifil32/avifile_private.h b/dlls/avifil32/avifile_private.h index 83e87ea989..4bf11f42a8 100644 --- a/dlls/avifil32/avifile_private.h +++ b/dlls/avifil32/avifile_private.h @@ -22,8 +22,6 @@ #include <windef.h> #include <winuser.h>
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - #ifndef MAX_AVISTREAMS #define MAX_AVISTREAMS 8 #endif diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index e2367aa60b..eef2072e18 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -38,8 +38,6 @@ extern HMODULE COMCTL32_hModule DECLSPEC_HIDDEN; extern HBRUSH COMCTL32_hPattern55AABrush DECLSPEC_HIDDEN;
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - /* Property sheet / Wizard */ #define IDD_PROPSHEET 1006 #define IDD_WIZARD 1020 diff --git a/dlls/comdlg32/cdlg.h b/dlls/comdlg32/cdlg.h index eebf1a9b2b..28bb7e7526 100644 --- a/dlls/comdlg32/cdlg.h +++ b/dlls/comdlg32/cdlg.h @@ -23,8 +23,6 @@
#include "dlgs.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - /* Common dialogs implementation globals */ #define COMDLG32_Atom MAKEINTATOM(0xa000) /* MS uses this one to identify props */
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 95ee67c6cb..e58db989b7 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -21,8 +21,6 @@
#include "wine/list.h"
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - /* a few asn.1 tags we need */ #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index d754e85d34..925fcf48ce 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -31,10 +31,6 @@ #endif #include "dwrite_2.h"
-#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#endif - enum d2d_brush_type { D2D_BRUSH_TYPE_SOLID, diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index fdbb5414cd..6ec413139c 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -38,10 +38,6 @@ #include "wine/winedxgi.h" #include "wine/rbtree.h"
-#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#endif - #define MAKE_TAG(ch0, ch1, ch2, ch3) \ ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \ ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 )) diff --git a/dlls/d3d12/d3d12_main.c b/dlls/d3d12/d3d12_main.c index be0bd7acdf..324ad3cc4e 100644 --- a/dlls/d3d12/d3d12_main.c +++ b/dlls/d3d12/d3d12_main.c @@ -34,8 +34,6 @@
#include <vkd3d.h>
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - WINE_DEFAULT_DEBUG_CHANNEL(d3d12); WINE_DECLARE_DEBUG_CHANNEL(winediag);
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 08ea73ccdd..fc6e4af650 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -47,8 +47,6 @@
#define D3D9_TEXTURE_MIPMAP_DIRTY 0x1
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - extern const struct wined3d_parent_ops d3d9_null_wined3d_parent_ops DECLSPEC_HIDDEN;
HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index 0f24f80d24..858911f350 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -33,10 +33,6 @@ #include "wine/heap.h" #include "wine/list.h"
-#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) -#endif - struct d3drm_object { LONG ref; diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 6cc1126c80..930fce3ddf 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -32,8 +32,6 @@
#define ULONG64_MAX (~(ULONG64)0)
-#define ARRAY_SIZE(array) (sizeof(array)/sizeof(*array)) - struct vec4 { float x, y, z, w; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index b8552af287..495cb8be68 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -39,8 +39,6 @@ #include "wine/list.h" #include "wine/wined3d.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN; extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
diff --git a/dlls/dmloader/dmloader_private.h b/dlls/dmloader/dmloader_private.h index ecda299fb8..36e2bd885d 100644 --- a/dlls/dmloader/dmloader_private.h +++ b/dlls/dmloader/dmloader_private.h @@ -42,7 +42,6 @@ #include "dmusicf.h" #include "dmusics.h"
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
/* dmloader.dll global (for DllCanUnloadNow) */ diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index c16c401ad1..31b977a159 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -24,8 +24,6 @@ #include "wine/list.h" #include "wine/unicode.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - static const DWRITE_MATRIX identity = { 1.0f, 0.0f, diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index c05a0e81e7..4967bd425f 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -40,8 +40,6 @@ #include "wine/wined3d.h" #include "wine/winedxgi.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - enum dxgi_frame_latency { DXGI_FRAME_LATENCY_MAX = 16, diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 25b269ba35..b2e4f1e93f 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -35,8 +35,6 @@
#include "gdiplus.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER) #define MAX_ARC_PTS (13) #define MAX_DASHLEN (16) /* this is a limitation of gdi */ diff --git a/dlls/msi/tokenize.c b/dlls/msi/tokenize.c index 1656fd8c3d..d1c2da9743 100644 --- a/dlls/msi/tokenize.c +++ b/dlls/msi/tokenize.c @@ -77,8 +77,6 @@ static const WCHAR updateW[] = {'U','P','D','A','T','E'}; static const WCHAR valuesW[] = {'V','A','L','U','E','S'}; static const WCHAR whereW[] = {'W','H','E','R','E'};
-#define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) - /* ** These are the keywords ** They MUST be in alphabetical order diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index d7039275ce..94ef66b23d 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -31,8 +31,6 @@ # error You must include config.h to use this header #endif
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - typedef enum { MSXML_DEFAULT = 0, MSXML2 = 20, diff --git a/dlls/scrrun/scrrun_private.h b/dlls/scrrun/scrrun_private.h index d9ff2416a5..5083d30a8e 100644 --- a/dlls/scrrun/scrrun_private.h +++ b/dlls/scrrun/scrrun_private.h @@ -18,8 +18,6 @@ #ifndef _SCRRUN_PRIVATE_H_ #define _SCRRUN_PRIVATE_H_
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - extern HRESULT WINAPI FileSystem_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN; extern HRESULT WINAPI Dictionary_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h index d1b0e01cf1..11a96309e8 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h @@ -39,8 +39,6 @@ #include "wine/unicode.h" #include "wine/list.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - /******************************************* * global SHELL32.DLL variables */ diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 9699297b68..7a70ae9c43 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -32,8 +32,6 @@ #define GET_WORD(ptr) (*(const WORD *)(ptr)) #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - #define WM_SYSTIMER 0x0118 #define WM_POPUPSYSTEMMENU 0x0313
diff --git a/dlls/usp10/usp10_internal.h b/dlls/usp10/usp10_internal.h index 369a66dd58..bd55d8694f 100644 --- a/dlls/usp10/usp10_internal.h +++ b/dlls/usp10/usp10_internal.h @@ -27,10 +27,6 @@ ( (ULONG)_x2 << 8 ) | \ (ULONG)_x1 )
-#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#endif - enum usp10_script { Script_Undefined = 0x00, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9aa70817f5..a25c296616 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -58,10 +58,6 @@ #include "wine/rbtree.h" #include "wine/wgl_driver.h"
-#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#endif - #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
/* Driver quirks */ diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 582fb78229..353f7af36c 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -36,10 +36,6 @@ /* Magic value defined by Vulkan ICD / Loader spec */ #define VULKAN_ICD_MAGIC_VALUE 0x01CDC0DE
-#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#endif - #define WINEVULKAN_QUIRK_GET_DEVICE_PROC_ADDR 0x00000001
struct vulkan_func diff --git a/dlls/wshom.ocx/wshom_private.h b/dlls/wshom.ocx/wshom_private.h index 3d5eb1b8c1..a10cf2683a 100644 --- a/dlls/wshom.ocx/wshom_private.h +++ b/dlls/wshom.ocx/wshom_private.h @@ -25,8 +25,6 @@ #include "ole2.h" #include "olectl.h"
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - /* typelibs */ typedef enum tid_t { NULL_tid, diff --git a/dlls/xmllite/xmllite_private.h b/dlls/xmllite/xmllite_private.h index 381dec496c..7884e27453 100644 --- a/dlls/xmllite/xmllite_private.h +++ b/dlls/xmllite/xmllite_private.h @@ -23,8 +23,6 @@
#include "wine/heap.h"
-#define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) - static inline void *m_alloc(IMalloc *imalloc, size_t len) { if (imalloc) diff --git a/include/wine/test.h b/include/wine/test.h index e73f40d575..22ba7e8b40 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -137,7 +137,9 @@ extern void __winetest_cdecl winetest_trace( const char *msg, ... ) WINETEST_PRI #define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine"))
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif
#ifdef NONAMELESSUNION # define U(x) (x).u diff --git a/include/winnt.h b/include/winnt.h index 80a2fc33d5..7f822c4aec 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -759,6 +759,10 @@ typedef struct _MEMORY_BASIC_INFORMATION #define CONTAINING_RECORD(address, type, field) \ ((type *)((PCHAR)(address) - offsetof(type, field)))
+#ifdef __WINESRC__ +# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + /* Types */
typedef struct _LIST_ENTRY { diff --git a/programs/notepad/main.h b/programs/notepad/main.h index b672be66f5..e0efef0c08 100644 --- a/programs/notepad/main.h +++ b/programs/notepad/main.h @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#define ARRAY_SIZE(a) sizeof(a)/sizeof((a)[0]) - #include "notepad_res.h"
#define MAX_STRING_LEN 255 diff --git a/programs/reg/reg.h b/programs/reg/reg.h index dbce738ecd..a27399d06a 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -21,7 +21,6 @@
#include "resource.h"
-#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A)) #define MAX_SUBKEY_LEN 257
/* reg.c */ diff --git a/programs/regedit/main.h b/programs/regedit/main.h index 55317be338..edcc90154b 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -30,8 +30,6 @@
#define SPLIT_WIDTH 5
-#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A)) - #define MAX_NEW_KEY_LEN 128 #define KEY_MAX_LEN 1024
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index 2dbbd102c6..b938b61687 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -43,8 +43,6 @@ static HKEY reg_class_keys[] = { HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA };
-#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A)) - void *heap_xalloc(size_t size) { void *buf = heap_alloc(size); diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h index f2c24a2012..110856a536 100644 --- a/programs/winecfg/winecfg.h +++ b/programs/winecfg/winecfg.h @@ -38,8 +38,6 @@ #define IS_OPTION_FALSE(ch) \ ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
-#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - extern WCHAR* current_app; /* NULL means editing global settings */
/* Use get_reg_key and set_reg_key to alter registry settings. The changes made through diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 3fc8daa804..490bd06a0c 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -39,8 +39,6 @@ #include "oaidl.h" #include <wine/list.h>
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - #define ADDRSIZE (dbg_curr_process->be_cpu->pointer_size) #define ADDRWIDTH (ADDRSIZE * 2)
diff --git a/tools/make_xftmpl.c b/tools/make_xftmpl.c index 6a22fefc5d..49a1273bad 100644 --- a/tools/make_xftmpl.c +++ b/tools/make_xftmpl.c @@ -35,8 +35,6 @@ #include "windef.h" #include "guiddef.h"
-#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0])) - #define TOKEN_NAME 1 #define TOKEN_STRING 2 #define TOKEN_INTEGER 3