From 3d207f8600adbc8fad6f5a5daaa66bf3961d9bdd Mon Sep 17 00:00:00 2001
From: Tim Hentenaar <tim@hentenaar.com>
Date: Mon, 26 Jan 2026 12:01:07 -0500
Subject: [PATCH] Fix compilation on 32-bit targets

Fixes #3

Thanks to @jengelh

Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxmu/-/merge_requests/20>
---
 include/X11/Xmu/EditresP.h | 8 ++------
 src/EditresCom.c           | 2 +-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/include/X11/Xmu/EditresP.h b/include/X11/Xmu/EditresP.h
index 1591e0f..3530345 100644
--- a/include/X11/Xmu/EditresP.h
+++ b/include/X11/Xmu/EditresP.h
@@ -265,6 +265,7 @@ in this Software without prior written authorization from The Open Group.
 
 ************************************************************/
 
+#include <stdint.h>
 #include <X11/Intrinsic.h>
 #include <X11/Xfuncproto.h>
 #include <X11/Xmd.h>
@@ -291,12 +292,7 @@ in this Software without prior written authorization from The Open Group.
 #define EDITRES_COMM_ATOM    "EditresComm"
 #define EDITRES_CLIENT_VALUE "EditresClientVal"
 #define EDITRES_PROTOCOL_ATOM "EditresProtocol"
-
-#ifdef LONG64
-#define ID2WIDGET(X) ((Widget)(void *)((X)))
-#else
-#define ID2WIDGET(X) ((Widget)(void *)((X) & 0xffffffff))
-#endif
+#define ID2WIDGET(X) ((Widget)(void *)(uintptr_t)((X)))
 
 typedef enum {
   SendWidgetTree = 0,
diff --git a/src/EditresCom.c b/src/EditresCom.c
index 07b7bfd..b085acf 100644
--- a/src/EditresCom.c
+++ b/src/EditresCom.c
@@ -1631,7 +1631,7 @@ InsertWidget(ProtocolStream *stream, Widget w)
      * make sure that they are inserted in the list from parent -> child
      */
     for (i--, temp = w; temp != NULL; temp = XtParent(temp), i--)
-    widget_list[i] = (CARD64)temp;
+    widget_list[i] = (CARD64)(uintptr_t)temp;
 
     _XEditResPut16(stream, num_widgets);	/* insert number of widgets */
     for (i = 0; i < num_widgets; i++)		/* insert Widgets themselves */
-- 
GitLab

