platformio_pre.py
This commit is contained in:
@@ -124,6 +124,7 @@
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <atomic>
|
||||
|
||||
#ifdef WINDOWS
|
||||
# ifdef CC_VC
|
||||
@@ -277,7 +278,7 @@
|
||||
} _PIP_ADD_COUNTER(_pip_initializer_);
|
||||
|
||||
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
# define PIP_MIN_MSLEEP 10.
|
||||
#else
|
||||
# define PIP_MIN_MSLEEP 1.
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "pivector2d.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
# define _TYPENAME_(T) "?"
|
||||
#else
|
||||
# define _TYPENAME_(T) typeid(T).name()
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
#ifdef PIP_STD_IOSTREAM
|
||||
# include <iostream>
|
||||
#endif
|
||||
#ifndef PIP_MICRO
|
||||
# include <atomic>
|
||||
#endif
|
||||
|
||||
class PIMutex;
|
||||
class PIMutexLocker;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "pisysteminfo.h"
|
||||
#include "piresourcesstorage.h"
|
||||
#include "pidir.h"
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
# include "piprocess.h"
|
||||
#endif
|
||||
#ifdef ESP_PLATFORM
|
||||
@@ -49,7 +49,7 @@ void __PISetTimerResolution() {
|
||||
}
|
||||
#else
|
||||
# include <pwd.h>
|
||||
# ifndef FREERTOS
|
||||
# ifndef MICRO_PIP
|
||||
# include <sys/utsname.h>
|
||||
# endif
|
||||
# include <pthread.h>
|
||||
@@ -84,7 +84,7 @@ ULONG prev_res;
|
||||
bool delete_locs;
|
||||
PRIVATE_DEFINITION_END(PIInit)
|
||||
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
void __sighandler__(PISignals::Signal s) {
|
||||
//piCout << Hex << int(s);
|
||||
if (s == PISignals::StopTTYInput || s == PISignals::StopTTYOutput)
|
||||
@@ -106,12 +106,12 @@ PIInit::PIInit() {
|
||||
file_charset = 0;
|
||||
PISystemInfo * sinfo = PISystemInfo::instance();
|
||||
sinfo->execDateTime = PIDateTime::current();
|
||||
#ifndef MICRO_PIP
|
||||
setFileCharset("UTF-8");
|
||||
#ifndef FREERTOS
|
||||
#ifndef ANDROID
|
||||
# ifndef ANDROID
|
||||
PISignals::setSlot(__sighandler__);
|
||||
PISignals::grabSignals(PISignals::UserDefined1);
|
||||
# ifndef WINDOWS
|
||||
# ifndef WINDOWS
|
||||
PISignals::grabSignals(PISignals::StopTTYInput | PISignals::StopTTYOutput);
|
||||
sigset_t ss;
|
||||
sigemptyset(&ss);
|
||||
@@ -128,7 +128,7 @@ PIInit::PIInit() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
# else
|
||||
# else //WINDOWS
|
||||
// OS version
|
||||
DWORD dwVersion = GetVersion();
|
||||
DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
@@ -154,33 +154,33 @@ PIInit::PIInit() {
|
||||
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
|
||||
__PISetTimerResolution();
|
||||
}
|
||||
# endif
|
||||
# ifdef HAS_LOCALE
|
||||
# endif //WINDOWS
|
||||
# ifdef HAS_LOCALE
|
||||
//cout << "has locale" << endl;
|
||||
if (currentLocale_t != 0) {
|
||||
freelocale(currentLocale_t);
|
||||
currentLocale_t = 0;
|
||||
}
|
||||
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, ""), 0);
|
||||
# else
|
||||
# else //HAS_LOCALE
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
# endif
|
||||
#else
|
||||
# endif //HAS_LOCALE
|
||||
# else //ANDROID
|
||||
struct sigaction actions;
|
||||
memset(&actions, 0, sizeof(actions));
|
||||
sigemptyset(&actions.sa_mask);
|
||||
actions.sa_flags = 0;
|
||||
actions.sa_handler = android_thread_exit_handler;
|
||||
sigaction(SIGTERM, &actions, 0);
|
||||
#endif
|
||||
# endif //ANDROID
|
||||
PRIVATE->delete_locs = false;
|
||||
__syslocname__ = __sysoemname__ = 0;
|
||||
__utf8name__ = const_cast<char*>("UTF-8");
|
||||
#ifdef PIP_ICU
|
||||
# ifdef PIP_ICU
|
||||
UErrorCode e((UErrorCode)0);
|
||||
u_init(&e);
|
||||
# ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
PRIVATE->delete_locs = true;
|
||||
CPINFOEX cpinfo;
|
||||
int l = 0;
|
||||
@@ -192,30 +192,30 @@ PIInit::PIInit() {
|
||||
memset(__sysoemname__, 0, 256);
|
||||
memcpy(__sysoemname__, "ibm-", 4);
|
||||
memcpy(&(__sysoemname__[4]), cpinfo.CodePageName, l);
|
||||
# else
|
||||
# else
|
||||
/*PIString en(getenv("LANG"));
|
||||
if (!en.isEmpty())
|
||||
en = en.mid(en.find(".") + 1);
|
||||
PIByteArray enba = en.toByteArray();
|
||||
memcpy(__syslocname__, enba.data(), enba.size_s());*/
|
||||
# endif
|
||||
# endif
|
||||
//piCout << __syslocname__;
|
||||
//piCout << __sysoemname__;
|
||||
#else
|
||||
# ifdef WINDOWS
|
||||
# else //PIP_ICU
|
||||
# ifdef WINDOWS
|
||||
__syslocname__ = (char *)CP_ACP;
|
||||
__sysoemname__ = (char *)CP_OEMCP;
|
||||
__utf8name__ = (char *)CP_UTF8;
|
||||
# endif
|
||||
#endif
|
||||
#ifdef MAC_OS
|
||||
# endif
|
||||
# endif //PIP_ICU
|
||||
# ifdef MAC_OS
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &__pi_mac_clock);
|
||||
#endif
|
||||
# endif
|
||||
char cbuff[1024];
|
||||
memset(cbuff, 0, 1024);
|
||||
if (gethostname(cbuff, 1023) == 0)
|
||||
sinfo->hostname = cbuff;
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
|
||||
@@ -236,7 +236,7 @@ PIInit::PIInit() {
|
||||
ulong unlen = 1023;
|
||||
if (GetUserName(cbuff, &unlen) != 0)
|
||||
sinfo->user = cbuff;
|
||||
#else
|
||||
# else //WINDOWS
|
||||
sinfo->processorsCount = piMaxi(1, int(sysconf(_SC_NPROCESSORS_ONLN)));
|
||||
passwd * ps = getpwuid(getuid());
|
||||
if (ps)
|
||||
@@ -252,8 +252,9 @@ PIInit::PIInit() {
|
||||
sinfo->OS_version = uns.release;
|
||||
sinfo->architecture = uns.machine;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
# endif //WINDOWS
|
||||
#endif // MICRO_PIP
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
@@ -265,19 +266,21 @@ PIInit::PIInit() {
|
||||
sinfo->OS_name =
|
||||
#ifdef WINDOWS
|
||||
PIStringAscii("Windows");
|
||||
#elif defined(QNX)
|
||||
# elif defined(QNX)
|
||||
PIStringAscii("QNX");
|
||||
#elif defined(MAC_OS)
|
||||
# elif defined(MAC_OS)
|
||||
PIStringAscii("MacOS");
|
||||
#elif defined(ANDROID)
|
||||
# elif defined(ANDROID)
|
||||
PIStringAscii("Android");
|
||||
#elif defined(FREE_BSD)
|
||||
# elif defined(FREE_BSD)
|
||||
PIStringAscii("FreeBSD");
|
||||
#elif defined(FREERTOS)
|
||||
# elif defined(FREERTOS)
|
||||
PIStringAscii("FreeRTOS");
|
||||
#else
|
||||
# elif defined(MICRO_PIP)
|
||||
PIStringAscii("MicroPIP");
|
||||
# else
|
||||
uns.sysname;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "pisysteminfo.h"
|
||||
#include "pithread.h"
|
||||
#include "piconditionvar.h"
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
# include "pifile.h"
|
||||
#endif
|
||||
|
||||
@@ -355,7 +355,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig) {
|
||||
src->connections.remove(i);
|
||||
i--;
|
||||
if (dest) {
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(FREERTOS)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
PIMutexLocker _mld(dest->mutex_connect, src != dest);
|
||||
#endif
|
||||
dest->updateConnectors();
|
||||
@@ -373,7 +373,7 @@ void PIObject::piDisconnectAll() {
|
||||
// piCout << "disconnect"<< src << o;
|
||||
if (!o || (o == this)) continue;
|
||||
if (!o->isPIObject()) continue;
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(FREERTOS)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
PIMutexLocker _mld(o->mutex_connect, this != o);
|
||||
#endif
|
||||
PIVector<Connection> & oc(o->connections);
|
||||
@@ -615,7 +615,7 @@ void dumpApplication() {
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREERTOS
|
||||
#ifndef MICRO_PIP
|
||||
bool dumpApplicationToFile(const PIString & path) {
|
||||
PIFile f(path + "_tmp");
|
||||
f.setName("__S__DumpFile");
|
||||
|
||||
@@ -192,9 +192,9 @@ public:
|
||||
static PIObject::Connection piConnect(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, void * ev_h, void * e_h, int args, const char * loc);
|
||||
static PIObject::Connection piConnectU(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, const PIString & hname, const char * loc, PIObject * performer = 0);
|
||||
static PIObject::Connection piConnectLS(PIObject * src, const PIString & sig, std::function<void()> * f, const char * loc);
|
||||
template <typename INPUT, typename... TYPES>
|
||||
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,TYPES...), INPUT functor) {
|
||||
return (std::function<void()>*)(new std::function<void(TYPES...)>(functor));
|
||||
template <typename PIINPUT, typename... PITYPES>
|
||||
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,PITYPES...), PIINPUT functor) {
|
||||
return (std::function<void()>*)(new std::function<void(PITYPES...)>(functor));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
# include "freertos/FreeRTOS.h"
|
||||
# include "freertos/task.h"
|
||||
#endif
|
||||
#ifdef MICRO_PIP
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/*! \class PISystemTime
|
||||
* @brief System time
|
||||
@@ -252,12 +255,10 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
||||
ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);
|
||||
return PISystemTime(lt / 10000000U, (lt % 10000000U) * 100U);
|
||||
}
|
||||
#else
|
||||
# ifdef MAC_OS
|
||||
#elif defined(MAC_OS)
|
||||
mach_timespec_t t_cur;
|
||||
clock_get_time(__pi_mac_clock, &t_cur);
|
||||
# else
|
||||
# ifdef FREERTOS
|
||||
#elif defined(MICRO_PIP)
|
||||
timespec t_cur;
|
||||
timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
@@ -265,11 +266,11 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
||||
gettimeofday(&tv, NULL);
|
||||
t_cur.tv_sec = tv.tv_sec;
|
||||
t_cur.tv_nsec = tv.tv_usec * 1000;
|
||||
# else
|
||||
#else
|
||||
timespec t_cur;
|
||||
clock_gettime(precise_but_not_system ? CLOCK_MONOTONIC : 0, &t_cur);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef WINDOWS
|
||||
return PISystemTime(t_cur.tv_sec, t_cur.tv_nsec);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "pistring.h"
|
||||
#include <typeinfo>
|
||||
#ifdef PIP_FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
#include "pivariant.h"
|
||||
#endif
|
||||
|
||||
@@ -48,10 +48,10 @@ template<typename T>
|
||||
class __VariantFunctions__: public __VariantFunctionsBase__ {
|
||||
public:
|
||||
__VariantFunctionsBase__ * instance() final {static __VariantFunctions__<T> ret; return &ret;}
|
||||
#ifdef PIP_FREERTOS
|
||||
#ifdef MICRO_PIP
|
||||
PIString typeName() const final {static PIString ret(PIVariant(T()).typeName()); return ret;}
|
||||
#else
|
||||
PIString typeName() const final {static PIString ret(typeid(T).name()); return ret;}
|
||||
PIString typeName() const final {static PIString ret(_TYPENAME_(T)); return ret;}
|
||||
#endif
|
||||
uint hash() const final {static uint ret = typeName().hash(); return ret;}
|
||||
void newT(void *& ptr, const void * value) final {ptr = (void*)(new T(*(const T*)value));}
|
||||
|
||||
Reference in New Issue
Block a user