Skip to content

Commit

Permalink
leak mingw32
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Jul 18, 2024
1 parent 60c43f1 commit 619913d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <emscripten/threading.h>
#endif

#if defined _WIN32 && !(defined __MINGW32__)
#if defined _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <powerbase.h>
Expand Down Expand Up @@ -747,7 +747,7 @@ static int get_cpucount()
count = emscripten_num_logical_cores();
else
count = 1;
#elif (defined _WIN32 && !(defined __MINGW32__))
#elif defined _WIN32
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
count = system_info.dwNumberOfProcessors;
Expand Down Expand Up @@ -814,7 +814,7 @@ static int get_thread_siblings(int cpuid)
static int get_physical_cpucount()
{
int count = 0;
#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
typedef BOOL(WINAPI * LPFN_GLPI)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
LPFN_GLPI glpi = (LPFN_GLPI)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation");
if (glpi == NULL)
Expand Down Expand Up @@ -1052,7 +1052,7 @@ static int get_big_cpu_data_cache_size(int level)
static int get_cpu_level2_cachesize()
{
int size = 0;
#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
typedef BOOL(WINAPI * LPFN_GLPI)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
LPFN_GLPI glpi = (LPFN_GLPI)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation");
if (glpi != NULL)
Expand Down Expand Up @@ -1122,7 +1122,7 @@ static int get_cpu_level2_cachesize()
static int get_cpu_level3_cachesize()
{
int size = 0;
#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
typedef BOOL(WINAPI * LPFN_GLPI)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
LPFN_GLPI glpi = (LPFN_GLPI)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation");
if (glpi != NULL)
Expand Down Expand Up @@ -1169,7 +1169,7 @@ static int get_cpu_level3_cachesize()
return size;
}

#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
static ncnn::CpuSet get_smt_cpu_mask()
{
ncnn::CpuSet smt_cpu_mask;
Expand Down Expand Up @@ -1263,7 +1263,7 @@ static int set_sched_affinity(const ncnn::CpuSet& thread_affinity_mask)

return 0;
}
#endif // (defined _WIN32 && !(defined __MINGW32__))
#endif // defined _WIN32

#if defined __ANDROID__ || defined __linux__
static int get_max_freq_khz(int cpuid)
Expand Down Expand Up @@ -1437,7 +1437,7 @@ static void initialize_cpu_thread_affinity_mask(ncnn::CpuSet& mask_all, ncnn::Cp
mask_all.enable(i);
}

#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
// get max freq mhz for all cores
int max_freq_mhz_min = INT_MAX;
int max_freq_mhz_max = 0;
Expand Down Expand Up @@ -1946,7 +1946,7 @@ static inline void try_initialize_global_cpu_info()

namespace ncnn {

#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
CpuSet::CpuSet()
{
disable_all();
Expand Down Expand Up @@ -2687,7 +2687,7 @@ const CpuSet& get_cpu_thread_affinity_mask(int powersave)
int set_cpu_thread_affinity(const CpuSet& thread_affinity_mask)
{
try_initialize_global_cpu_info();
#if defined __ANDROID__ || defined __linux__ || (defined _WIN32 && !(defined __MINGW32__))
#if defined __ANDROID__ || defined __linux__ || defined _WIN32
#ifdef _OPENMP
int num_threads = thread_affinity_mask.num_enabled();

Expand Down
4 changes: 2 additions & 2 deletions src/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <stddef.h>

#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
Expand All @@ -40,7 +40,7 @@ class NCNN_EXPORT CpuSet
int num_enabled() const;

public:
#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
ULONG_PTR mask;
#endif
#if defined __ANDROID__ || defined __linux__
Expand Down
8 changes: 4 additions & 4 deletions src/platform.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#ifdef __cplusplus

#if NCNN_THREADS
#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
Expand All @@ -86,7 +86,7 @@
namespace ncnn {

#if NCNN_THREADS
#if (defined _WIN32 && !(defined __MINGW32__))
#if defined _WIN32
class NCNN_EXPORT Mutex
{
public:
Expand Down Expand Up @@ -141,7 +141,7 @@ public:
private:
DWORD key;
};
#else // (defined _WIN32 && !(defined __MINGW32__))
#else // defined _WIN32
class NCNN_EXPORT Mutex
{
public:
Expand Down Expand Up @@ -186,7 +186,7 @@ public:
private:
pthread_key_t key;
};
#endif // (defined _WIN32 && !(defined __MINGW32__))
#endif // defined _WIN32
#else // NCNN_THREADS
class NCNN_EXPORT Mutex
{
Expand Down

0 comments on commit 619913d

Please sign in to comment.