From 93c16c8431478e4ca33a524c8ccfab7db8854bc4 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Mon, 21 Oct 2024 09:00:00 +0100 Subject: [PATCH] TCL9: magic.h ClientData type change helper macros Now a (void *) but previously an integer. These macros resolve the codebase allowing it to be built against both tcl8 (8.5, 8.6) and tcl9 (9.0). tar -zxvf tcl9.0.0-src.tar.gz cd tcl9.0.0/unix ./configure --enable-symbols --prefix=/opt/tktcl9 make install tar -zxvf tk9.0.0-src.tar.gz cd tk9.0.0/unix ./configure --enable-symbols --prefix=/opt/tktcl9 --with-tcl=/opt/tktcl9/lib make install cd magic ./configure --with-tk=/opt/tktcl9/lib --with-tcl=/opt/tktcl9/lib --- utils/magic.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/magic.h b/utils/magic.h index 77fd57ad..0e3ec1e0 100644 --- a/utils/magic.h +++ b/utils/magic.h @@ -63,6 +63,16 @@ typedef int64_t dlong; typedef pointertype ClientData; #endif +/* this is not the (int) C type, but the conceptual difference between + * a pointer and an integer. The integer width uses same size as pointer + * width, so integer width truncations need to be applied at usage site. + */ +#define CD2PTR(cd) ((void*)(cd)) +#define CD2INT(cd) ((pointertype)(cd)) + +#define PTR2CD(data) ((ClientData)(data)) +#define INT2CD(data) ((ClientData)(pointertype)(data)) + /* --------------------------- Booleans ------------------------------- */ typedef unsigned char bool;