summarylogtreecommitdiffstats
path: root/0010-MINGW-build-in-windows-modules-winreg.patch
blob: c91d837697a39f80edf97f9317653910998887be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From 08880ce168fbb08e6476a246fd80e141ebf2eed7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
 <alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:51:20 +0530
Subject: [PATCH 010/N] MINGW build in windows modules winreg
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Алексей <alexey.pawlow@gmail.com>
Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>
---
 Modules/Setup.config.in |  3 +++
 PC/winreg.c             | 19 +++++++++++++++++++
 configure.ac            |  7 +++++++
 3 files changed, 29 insertions(+)

diff --git a/Modules/Setup.config.in b/Modules/Setup.config.in
index 9b364fe..612cabd 100644
--- a/Modules/Setup.config.in
+++ b/Modules/Setup.config.in
@@ -6,3 +6,6 @@
 # init system calls(posix/nt/...) for INITFUNC (used by makesetup)
 @INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c
 
+# build-in modules for windows platform:
+@USE_WIN32_MODULE@winreg ../PC/winreg.c
+
diff --git a/PC/winreg.c b/PC/winreg.c
index fd1ccb7..b6f1a8f 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -17,6 +17,25 @@
 #include "structmember.h"         // PyMemberDef
 #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
+
 static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK);
 static BOOL clinic_HKEY_converter(PyObject *ob, void *p);
 static PyObject *PyHKEY_FromHKEY(HKEY h);
diff --git a/configure.ac b/configure.ac
index ba8736b..59f3edc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3326,6 +3326,13 @@ else
 fi])
 AC_MSG_RESULT($with_dbmliborder)
 
+# Determine if windows modules should be used.
+AC_SUBST(USE_WIN32_MODULE)
+USE_WIN32_MODULE='#'
+case $host in
+  *-*-mingw*) USE_WIN32_MODULE=;;
+esac
+
 # Templates for things AC_DEFINEd more than once.
 # For a single AC_DEFINE, no template is needed.
 AH_TEMPLATE(_REENTRANT,
-- 
2.33.0