BIG deep clean

This commit is contained in:
2020-06-10 13:14:16 +03:00
parent f579718e0b
commit c59579d5d5
222 changed files with 2392 additions and 11600 deletions

View File

@@ -1,20 +1,20 @@
/*
PIP - Platform Independent Primitives
Initialization
PIP - Platform Independent Primitives
Initialization
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "piincludes_p.h"
@@ -33,20 +33,20 @@
#endif
#ifdef WINDOWS
# include <winsock2.h>
extern FILETIME __pi_ftjan1970;
extern PINtQueryTimerResolution getTimerResolutionAddr;
extern PINtSetTimerResolution setTimerResolutionAddr;
void __PISetTimerResolution() {
if (setTimerResolutionAddr == NULL || getTimerResolutionAddr == NULL)
return;
ULONG _max(0), _min(0), _cur(0);
//printf("getTimerResolution ...\n");
LONG q = getTimerResolutionAddr(&_max, &_min, &_cur);
//printf("getTimerResolution %d %lu %lu %lu\n", q, _min, _max, _cur);
if (q == 0)
setTimerResolutionAddr(_min, TRUE, &_cur);
//printf("setTimerResolution %lu\n", cur);
}
extern FILETIME __pi_ftjan1970;
extern PINtQueryTimerResolution getTimerResolutionAddr;
extern PINtSetTimerResolution setTimerResolutionAddr;
void __PISetTimerResolution() {
if (setTimerResolutionAddr == NULL || getTimerResolutionAddr == NULL)
return;
ULONG _max(0), _min(0), _cur(0);
//printf("getTimerResolution ...\n");
LONG q = getTimerResolutionAddr(&_max, &_min, &_cur);
//printf("getTimerResolution %d %lu %lu %lu\n", q, _min, _max, _cur);
if (q == 0)
setTimerResolutionAddr(_min, TRUE, &_cur);
//printf("setTimerResolution %lu\n", cur);
}
#else
# include <pwd.h>
# ifndef FREERTOS
@@ -64,24 +64,13 @@
# include <mach/mach.h>
# include <mach/clock.h>
//# include <crt_externs.h>
extern clock_serv_t __pi_mac_clock;
extern clock_serv_t __pi_mac_clock;
#endif
#ifdef PIP_ICU
# define U_NOEXCEPT
# include <unicode/uclean.h>
# include <unicode/ucnv.h>
#endif
/*
#ifdef WINDOWS
# include <conio.h>
# include <io.h>
# include <windows.h>
# include <wincon.h>
#else
# include <fcntl.h>
# include <sys/ioctl.h>
# include <pthread.h>
#endif*/
#ifdef HAS_LOCALE
@@ -90,10 +79,10 @@ static locale_t currentLocale_t = 0;
PRIVATE_DEFINITION_START(PIInit)
#ifdef WINDOWS
HMODULE ntlib;
ULONG prev_res;
HMODULE ntlib;
ULONG prev_res;
#endif
bool delete_locs;
bool delete_locs;
PRIVATE_DEFINITION_END(PIInit)
#ifndef FREERTOS
@@ -133,12 +122,12 @@ PIInit::PIInit() {
signal(SIGPIPE, SIG_IGN);
PIStringList ifpathes;
ifpathes << PIStringAscii("/bin/ifconfig") << PIStringAscii("/sbin/ifconfig")
<< PIStringAscii("/usr/bin/ifconfig") << PIStringAscii("/usr/sbin/ifconfig");
<< PIStringAscii("/usr/bin/ifconfig") << PIStringAscii("/usr/sbin/ifconfig");
piForeachC (PIString & i, ifpathes)
if (fileExists(i)) {
sinfo->ifconfigPath = i;
piBreak;
}
if (fileExists(i)) {
sinfo->ifconfigPath = i;
piBreak;
}
# else
// OS version
DWORD dwVersion = GetVersion();
@@ -165,9 +154,7 @@ PIInit::PIInit() {
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
__PISetTimerResolution();
}
/*if (setTimerResolution) setTimerResolutionAddr(1, TRUE, &(PRIVATE->prev_res));*/
# endif
//piDebug = true;
# ifdef HAS_LOCALE
//cout << "has locale" << endl;
if (currentLocale_t != 0) {
@@ -241,12 +228,12 @@ PIInit::PIInit() {
GetSystemInfo(&sysinfo);
sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
switch (sysinfo.wProcessorArchitecture) {
case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break;
case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break;
case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break;
case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break;
case PROCESSOR_ARCHITECTURE_UNKNOWN:
default: sinfo->architecture = PIStringAscii("unknown"); break;
case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break;
case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break;
case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break;
case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break;
case PROCESSOR_ARCHITECTURE_UNKNOWN:
default: sinfo->architecture = PIStringAscii("unknown"); break;
}
int argc_(0);
wchar_t ** argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_);
@@ -284,25 +271,25 @@ PIInit::PIInit() {
sinfo->OS_version = esp_get_idf_version();
#endif
sinfo->OS_name =
#ifdef WINDOWS
PIStringAscii("Windows");
#ifdef WINDOWS
PIStringAscii("Windows");
#else
# ifdef QNX
PIStringAscii("QNX");
# ifdef QNX
PIStringAscii("QNX");
# else
# ifdef MAC_OS
PIStringAscii("MacOS");
# ifdef MAC_OS
PIStringAscii("MacOS");
# else
# ifdef ANDROID
PIStringAscii("Android");
# ifdef ANDROID
PIStringAscii("Android");
# else
# ifdef FREE_BSD
PIStringAscii("FreeBSD");
# ifdef FREE_BSD
PIStringAscii("FreeBSD");
# else
# ifdef FREERTOS
PIStringAscii("FreeRTOS");
# ifdef FREERTOS
PIStringAscii("FreeRTOS");
# else
uns.sysname;
uns.sysname;
# endif
# endif
# endif
@@ -318,7 +305,6 @@ PIInit::~PIInit() {
PIResourcesStorage::instance()->clear();
#ifdef WINDOWS
WSACleanup();
//if (setTimerResolution) setTimerResolutionAddr(PRIVATE->prev_res, TRUE, &(PRIVATE->prev_res));
if (PRIVATE->ntlib) FreeLibrary(PRIVATE->ntlib);
PRIVATE->ntlib = 0;
#endif
@@ -332,67 +318,66 @@ PIInit::~PIInit() {
#ifdef PIP_ICU
u_cleanup();
#endif
//if (currentLocale_t != 0) freelocale(currentLocale_t);
}
bool PIInit::isBuildOptionEnabled(PIInit::BuildOption o) {
switch (o) {
case ICU: return
#ifdef PIP_ICU
case ICU: return
#ifdef PIP_ICU
true;
#else
false;
#endif
case USB: return
#ifdef PIP_USB
case USB: return
#ifdef PIP_USB
true;
#else
false;
#endif
case STL: return
#ifdef PIP_CONTAINERS_STL
case STL: return
#ifdef PIP_CONTAINERS_STL
true;
#else
false;
#endif
case Crypt: return
#ifdef PIP_CRYPT
case Crypt: return
#ifdef PIP_CRYPT
true;
#else
false;
#endif
case Introspection: return
#ifdef PIP_INTROSPECTION
case Introspection: return
#ifdef PIP_INTROSPECTION
true;
#else
false;
#endif
case FFTW: return
#ifdef PIP_FFTW
case FFTW: return
#ifdef PIP_FFTW
true;
#else
false;
#endif
case Compress: return
#ifdef PIP_COMPRESS
case Compress: return
#ifdef PIP_COMPRESS
true;
#else
false;
#endif
case OpenCL: return
#ifdef PIP_OPENCL
case OpenCL: return
#ifdef PIP_OPENCL
true;
#else
false;
#endif
case Cloud: return
#ifdef PIP_CLOUD
true;
case Cloud: return
#ifdef PIP_CLOUD
true;
#else
false;
false;
#endif
default: return false;
default: return false;
}
return false;
}