summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2021-11-04 10:17:23 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2021-11-04 10:17:23 +0100
commit8fa1746685a86b8ddda454e2e2746d535e2b6d89 (patch)
treef4db150c3f5f5f136eefd2b503e85b7bdeaa9d76
parent0e15b4890a1d84f2aa800b745fdb0642d2ee966d (diff)
downloadpsutil-8fa1746685a86b8ddda454e2e2746d535e2b6d89.tar.gz
c / win: get rid of psutil_load_globals() and move it into psutil_setup() fun
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r--psutil/_psutil_common.c47
-rw-r--r--psutil/_psutil_common.h1
-rw-r--r--psutil/_psutil_windows.c2
3 files changed, 19 insertions, 31 deletions
diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c
index 6ed14658..94aa997b 100644
--- a/psutil/_psutil_common.c
+++ b/psutil/_psutil_common.c
@@ -129,11 +129,6 @@ AccessDenied(const char *syscall) {
}
-// ====================================================================
-// --- Global utils
-// ====================================================================
-
-
// Enable or disable PSUTIL_DEBUG messages.
PyObject *
psutil_set_debug(PyObject *self, PyObject *args) {
@@ -156,17 +151,6 @@ psutil_set_debug(PyObject *self, PyObject *args) {
}
-/*
- * Called on module import on all platforms.
- */
-int
-psutil_setup(void) {
- if (getenv("PSUTIL_DEBUG") != NULL)
- PSUTIL_DEBUG = 1;
- return 0;
-}
-
-
// ============================================================================
// Utility functions (BSD)
// ============================================================================
@@ -369,18 +353,6 @@ psutil_set_winver() {
}
-int
-psutil_load_globals() {
- if (psutil_loadlibs() != 0)
- return 1;
- if (psutil_set_winver() != 0)
- return 1;
- GetSystemInfo(&PSUTIL_SYSTEM_INFO);
- InitializeCriticalSection(&PSUTIL_CRITICAL_SECTION);
- return 0;
-}
-
-
/*
* Convert the hi and lo parts of a FILETIME structure or a LARGE_INTEGER
* to a UNIX time.
@@ -416,3 +388,22 @@ psutil_LargeIntegerToUnixTime(LARGE_INTEGER li) {
(ULONGLONG)li.LowPart);
}
#endif // PSUTIL_WINDOWS
+
+
+// Called on module import on all platforms.
+int
+psutil_setup(void) {
+ if (getenv("PSUTIL_DEBUG") != NULL)
+ PSUTIL_DEBUG = 1;
+
+#ifdef PSUTIL_WINDOWS
+ if (psutil_loadlibs() != 0)
+ return 1;
+ if (psutil_set_winver() != 0)
+ return 1;
+ GetSystemInfo(&PSUTIL_SYSTEM_INFO);
+ InitializeCriticalSection(&PSUTIL_CRITICAL_SECTION);
+#endif
+
+ return 0;
+}
diff --git a/psutil/_psutil_common.h b/psutil/_psutil_common.h
index 6cf19d65..6aa7da6d 100644
--- a/psutil/_psutil_common.h
+++ b/psutil/_psutil_common.h
@@ -157,7 +157,6 @@ void convert_kvm_err(const char *syscall, char *errbuf);
#define AF_INET6 23
#endif
- int psutil_load_globals();
PVOID psutil_GetProcAddress(LPCSTR libname, LPCSTR procname);
PVOID psutil_GetProcAddressFromLib(LPCSTR libname, LPCSTR procname);
PVOID psutil_SetFromNTStatusErr(NTSTATUS Status, const char *syscall);
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
index 596aa5c0..f9ec2376 100644
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -1736,8 +1736,6 @@ void init_psutil_windows(void)
if (psutil_setup() != 0)
INITERROR;
- if (psutil_load_globals() != 0)
- INITERROR;
if (psutil_set_se_debug() != 0)
INITERROR;