From a70cddfc03d6f5b7d6d632dc97fa0324f552bc51 Mon Sep 17 00:00:00 2001
From: Alexey Pavlov <alexpux@gmail.com>
Date: Tue, 2 Sep 2025 22:42:04 +0300
Subject: [PATCH 145/N] winreg: Cleanup build module

---
 Modules/Setup.bootstrap.in |  2 +-
 PC/winreg.c                | 19 -------------------
 configure.ac               |  1 +
 3 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in
index 0b53035..b9f8fda 100644
--- a/Modules/Setup.bootstrap.in
+++ b/Modules/Setup.bootstrap.in
@@ -38,6 +38,6 @@ _symtable symtablemodule.c
 @MODULE_PWD_TRUE@pwd pwdmodule.c
 
 # build-in modules for windows platform:
-@USE_WIN32_MODULE@winreg ../PC/winreg.c
+@MODULE_WINREG_TRUE@winreg ../PC/winreg.c
 @MODULE_MSVCRT_TRUE@msvcrt -DPy_BUILD_CORE ../PC/msvcrtmodule.c
 @MODULE__WINAPI_TRUE@_winapi _winapi.c
diff --git a/PC/winreg.c b/PC/winreg.c
index 2cc175c..d4c152d 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -18,25 +18,6 @@
 
 #include <windows.h>
 
-#ifndef SIZEOF_HKEY
-/* used only here */
-#if defined(MS_WIN64)
-#  define SIZEOF_HKEY 8
-#elif defined(MS_WIN32)
-#  define SIZEOF_HKEY 4
-#else
-#  error "SIZEOF_HKEY is not defined"
-#endif
-#endif
-
-#ifndef REG_LEGAL_CHANGE_FILTER
-#define REG_LEGAL_CHANGE_FILTER        (\
-          REG_NOTIFY_CHANGE_NAME       |\
-          REG_NOTIFY_CHANGE_ATTRIBUTES |\
-          REG_NOTIFY_CHANGE_LAST_SET   |\
-          REG_NOTIFY_CHANGE_SECURITY   )
-#endif
-
 #if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES)
 
 typedef struct {
diff --git a/configure.ac b/configure.ac
index 5c35a58..d8564a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8389,6 +8389,7 @@ PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes],
   [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS])
 
 dnl windows specific modules
+PY_STDLIB_MOD([winreg], [test "$MACHDEP" = "win32"])
 PY_STDLIB_MOD([msvcrt], [test "$MACHDEP" = "win32"])
 PY_STDLIB_MOD([_winapi], [test "$MACHDEP" = "win32"])
 PY_STDLIB_MOD([winsound], [test "$MACHDEP" = "win32"], [], [],
