Files
MINGW-packages/mingw-w64-python-psutil/0002-msys-Fixes-for-msys2.patch
2019-07-12 19:23:58 +03:00

114 lines
3.2 KiB
Diff

From 221ae3655cdbbd49f288299bbd09996d930a5ce4 Mon Sep 17 00:00:00 2001
From: Manuel Naranjo <naranjo.manuel@gmail.com>
Date: Thu, 23 Jun 2016 18:15:39 -0300
Subject: [PATCH 2/2] [msys] Fixes for msys2
Fixes for building the lib in an msys environment with mingw32
mingw64 should work as well.
---
psutil/_psutil_windows.c | 65 +++++++----------------------------
psutil/arch/windows/glpi.h | 7 ++--
psutil/arch/windows/ntextapi.h | 16 ++++++---
psutil/arch/windows/process_handles.h | 2 ++
psutil/arch/windows/services.c | 12 +++++++
5 files changed, 41 insertions(+), 61 deletions(-)
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
index ebc4368..98c01df 100644
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -33,12 +33,16 @@
// Link with Iphlpapi.lib
#pragma comment(lib, "IPHLPAPI.lib")
+#ifndef __MINGW32__
#include "arch/windows/ntextapi.h"
+#endif
#include "arch/windows/global.h"
#include "arch/windows/security.h"
#include "arch/windows/process_info.h"
#include "arch/windows/process_handles.h"
+#ifndef __MINGW32__
#include "arch/windows/inet_ntop.h"
+#endif
#include "arch/windows/services.h"
#include "arch/windows/wmi.h"
#include "_psutil_common.h"
@@ -63,7 +63,7 @@
PIP_ADAPTER_ADDRESSES
psutil_get_nic_addresses() {
// allocate a 15 KB buffer to start with
- int outBufLen = 15000;
+ ULONG outBufLen = 15000;
DWORD dwRetVal = 0;
ULONG attempts = 0;
PIP_ADAPTER_ADDRESSES pAddresses = NULL;
diff --git a/psutil/arch/windows/ntextapi.h b/psutil/arch/windows/ntextapi.h
index 74adce2..df1f436 100644
--- a/psutil/arch/windows/ntextapi.h
+++ b/psutil/arch/windows/ntextapi.h
@@ -290,6 +291,7 @@
* ================================================================
*/
+#ifndef __MINGW32__
typedef enum _PROCESSINFOCLASS2 {
_ProcessBasicInformation,
ProcessQuotaLimits,
@@ -72,6 +72,14 @@
#define ProcessImageFileName _ProcessImageFileName
#define ProcessBreakOnTermination _ProcessBreakOnTermination
+#else
+// values from https://msdn.microsoft.com/en-us/library/windows/desktop/ms684280(v=vs.85).aspx
+#define ProcessBasicInformation 0
+#define ProcessWow64Information 26
+#define ProcessDebugPort 7
+#define ProcessImageFileName 27
+#endif
+
/*
* ================================================================
* Structs.
@@ -189,6 +189,7 @@
MaximumThreadState
} KTHREAD_STATE, *PKTHREAD_STATE;
+#ifndef __MINGW32__
typedef enum _KWAIT_REASON {
Executive,
FreePage,
@@ -238,6 +238,7 @@
WrDeferredPreempt,
MaximumWaitReason
} KWAIT_REASON, *PKWAIT_REASON;
+#endif
typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX {
PVOID Object;
diff --git a/psutil/arch/windows/services.c b/psutil/arch/windows/services.c
index ddfe30e..8c279f0 100644
--- a/psutil/arch/windows/services.c
+++ b/psutil/arch/windows/services.c
@@ -10,6 +10,18 @@
#include "services.h"
+#ifdef __MINGW32__
+#if !defined(_UNICODE) && !defined(_MBCS)
+#define _tcslen(x) strlen(x)
+#elif defined(_UNICODE)
+#define _tclsen(x) wcslen(x)
+#elif defined(_MBCS)
+#define _tclsen(x) strlen(x)
+#else
+#error "Invalid value"
+#endif
+#endif //__MINGW32__
+
// ==================================================================
// utils
--
2.7.2