From 9c2102cb8e6f5fa36481ac42e14fd1d2f7778251 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Mon, 7 Apr 2025 10:21:39 +0200 Subject: [PATCH] ide, uppsrc: Main config flags --- benchmarks/AllocMT/Chris.cpp | 2 +- uppsrc/Core/App.cpp | 2 +- uppsrc/Core/Core.h | 20 +++++++++----------- uppsrc/Core/Defs.h | 2 +- uppsrc/Core/Heap.h | 4 ---- uppsrc/Core/InVector.h | 2 +- uppsrc/Core/Log.cpp | 2 +- uppsrc/Core/Mt.cpp | 4 +--- uppsrc/Core/Util.cpp | 4 +++- uppsrc/Core/XML.h | 2 +- uppsrc/Core/config.h | 11 +++-------- uppsrc/Core/heaputil.cpp | 2 +- uppsrc/Core/sheap.cpp | 2 +- uppsrc/Core/t.h | 4 ---- uppsrc/Draw/Draw.h | 2 +- uppsrc/Draw/FontCoco.mm | 6 +++++- uppsrc/Painter/Painter.h | 2 +- uppsrc/ide/MainConfig.cpp | 26 +++++++++++++++++++------- uppsrc/plugin/png/pngupp.cpp | 3 +++ 19 files changed, 53 insertions(+), 49 deletions(-) diff --git a/benchmarks/AllocMT/Chris.cpp b/benchmarks/AllocMT/Chris.cpp index e0a089678..2f5a2bfd2 100644 --- a/benchmarks/AllocMT/Chris.cpp +++ b/benchmarks/AllocMT/Chris.cpp @@ -669,7 +669,7 @@ public: } void shutdown_local() throw() { -#ifdef flagUSEMALLOC +#ifdef flagUSEMALLOC // disable U++ allocator (MemoryAlloc is malloc, new/delete standard library) tls_malloc.shutdown(); #else UPP::MemoryFreeThread(); diff --git a/uppsrc/Core/App.cpp b/uppsrc/Core/App.cpp index d8a18f627..f283497c5 100644 --- a/uppsrc/Core/App.cpp +++ b/uppsrc/Core/App.cpp @@ -619,7 +619,7 @@ void AppExit__() #endif } -#ifdef flagTURTLE +#ifdef flagTURTLE // Turtle web backend void Turtle_PutLink(const String& link); diff --git a/uppsrc/Core/Core.h b/uppsrc/Core/Core.h index 5b3055c66..e7c6e404d 100644 --- a/uppsrc/Core/Core.h +++ b/uppsrc/Core/Core.h @@ -3,13 +3,9 @@ #define UPP_VERSION 0x20250200 -#ifndef flagMT -#define flagMT // MT is now always on -#endif - #define _MULTITHREADED #define MULTITHREADED -#ifdef flagDLL +#ifdef flagDLL // Build .dll #define flagUSEMALLOC #define STD_NEWDELETE #endif @@ -18,7 +14,7 @@ #define _USRDLL #endif -#ifdef flagHEAPDBG +#ifdef flagHEAPDBG // Activate heap debugging features even in release mode #define HEAPDBG #endif @@ -40,7 +36,7 @@ #include "config.h" -#if defined(flagSTD_NEWDELETE) && !defined(STD_NEWDELETE) +#if defined(flagSTD_NEWDELETE) && !defined(STD_NEWDELETE) // Do not use U++ heap for new/delete #define STD_NEWDELETE #endif @@ -278,7 +274,7 @@ namespace std { namespace Upp { -#ifndef flagNODEPRECATED +#ifndef flagNODEPRECATED // Using deprecated features produces error #define DEPRECATED #endif @@ -290,7 +286,11 @@ class JsonIO; #include "Ops.h" #include "Fn.h" -#if defined(flagNOSIMD) || defined(flagLEGACY_CPU) +#ifdef flagLEGACY_CPU +#define flagNOSIMD +#endif + +#if defined(flagNOSIMD) // Disable SIMD (e.g. SSE2, ARM NEON) #ifdef CPU_SSE2 #undef CPU_SSE2 #endif @@ -441,8 +441,6 @@ typedef void *DLLHANDLE; DLLHANDLE LoadDll__(UPP::String& fn, const char *const *names, void *const *procs); void FreeDll__(DLLHANDLE dllhandle); -#ifndef flagNONAMESPACE using Upp::byte; // Dirty solution to Windows.h typedef byte... -#endif #endif //CORE_H diff --git a/uppsrc/Core/Defs.h b/uppsrc/Core/Defs.h index 42bfe7a3c..982c0bb68 100644 --- a/uppsrc/Core/Defs.h +++ b/uppsrc/Core/Defs.h @@ -1,6 +1,6 @@ // #define MEMORY_SHRINK -#if !defined(flagUSEMALLOC) && !defined(flagSO) && !defined(flagHEAPOVERRIDE) +#if !defined(flagUSEMALLOC) && !defined(flagSO) #define UPP_HEAP #endif diff --git a/uppsrc/Core/Heap.h b/uppsrc/Core/Heap.h index 8a818f08c..6eb80bb1d 100644 --- a/uppsrc/Core/Heap.h +++ b/uppsrc/Core/Heap.h @@ -133,8 +133,6 @@ void TinyFree(int size, void *ptr) inline MemoryOptions::MemoryOptions() {} inline MemoryOptions::~MemoryOptions() {} -#ifndef flagHEAPOVERRIDE - inline void *MemoryAllocPermanent(size_t size) { return malloc(size); } inline void *MemoryAlloc(size_t size) { return new byte[size]; } inline void *MemoryAllocSz(size_t &size) { return new byte[size]; } @@ -168,8 +166,6 @@ inline void TinyFree(int, void *ptr) { return MemoryFree(ptr); } #endif -#endif - dword MemoryGetCurrentSerial(); void MemoryIgnoreNonMainLeaks(); diff --git a/uppsrc/Core/InVector.h b/uppsrc/Core/InVector.h index bffa06db2..0bdf1e1bf 100644 --- a/uppsrc/Core/InVector.h +++ b/uppsrc/Core/InVector.h @@ -77,7 +77,7 @@ private: template void Insert_(int ii, const Range& r, bool def); -#ifdef flagIVTEST +#ifdef flagIVTEST // .activate additional diagnostics code for InVector void Check(int blki, int offset) const; #endif public: diff --git a/uppsrc/Core/Log.cpp b/uppsrc/Core/Log.cpp index c906baf70..8ccca7e2a 100644 --- a/uppsrc/Core/Log.cpp +++ b/uppsrc/Core/Log.cpp @@ -308,7 +308,7 @@ void LogStream::_Put(const void *data, dword size) sTh.Put(*q++); } -#ifdef flagCHECKINIT +#ifdef flagCHECKINIT // Adds heap check and additional logging INITBLOCKs void InitBlockBegin__(const char *fn, int line) { RLOG(fn << " " << line << " init block"); diff --git a/uppsrc/Core/Mt.cpp b/uppsrc/Core/Mt.cpp index 33b5f3d41..ca8ca81af 100644 --- a/uppsrc/Core/Mt.cpp +++ b/uppsrc/Core/Mt.cpp @@ -496,7 +496,7 @@ void Thread::Sleep(int msec) #endif } -#ifdef flagPROFILEMT +#ifdef flagPROFILEMT // Add code to gather Mutex locking/blocking statistics MtInspector *MtInspector::Dumi() { static MtInspector h(NULL); @@ -652,7 +652,6 @@ void ConditionVariable::Broadcast() ConditionVariable::ConditionVariable() { -#ifndef flagTESTXPCV ONCELOCK { if(IsWinVista()) { DllFn(InitializeConditionVariable, "kernel32", "InitializeConditionVariable"); @@ -661,7 +660,6 @@ ConditionVariable::ConditionVariable() DllFn(SleepConditionVariableCS, "kernel32", "SleepConditionVariableCS"); } } -#endif if(InitializeConditionVariable) InitializeConditionVariable(cv); else diff --git a/uppsrc/Core/Util.cpp b/uppsrc/Core/Util.cpp index 2f2eefcc0..f975b3ca6 100644 --- a/uppsrc/Core/Util.cpp +++ b/uppsrc/Core/Util.cpp @@ -4,10 +4,12 @@ # include #endif -#if defined(PLATFORM_POSIX) && defined(COMPILER_GCC) && !defined(PLATFORM_ANDROID) && defined(flagSTACKTRACE) +#ifdef flagSTACKTRACE // On Panic (e.g. failed ASSERT) try to print stack back-trace +#if defined(PLATFORM_POSIX) && defined(COMPILER_GCC) && !defined(PLATFORM_ANDROID) # include # include #endif +#endif namespace Upp { diff --git a/uppsrc/Core/XML.h b/uppsrc/Core/XML.h index 37d3d68ba..a5b3846e2 100644 --- a/uppsrc/Core/XML.h +++ b/uppsrc/Core/XML.h @@ -44,7 +44,7 @@ struct XmlError : public Exc class XmlParser { enum { -#ifdef flagTEST_XML // This is for testing purposes only to increase boundary condition frequency +#ifdef flagTEST_XML // .This is for testing purposes only to increase boundary condition frequency MCHARS = 128, CHUNK = 256 #else diff --git a/uppsrc/Core/config.h b/uppsrc/Core/config.h index b9244bd93..cf7d0f4e5 100644 --- a/uppsrc/Core/config.h +++ b/uppsrc/Core/config.h @@ -26,7 +26,7 @@ #undef WINVER #undef _WIN32_WINNT - #ifdef flagWIN10 + #ifdef flagWIN10 // Force _WIN32_WINNT and NTDDI_VERSION to Win10 values #define _WIN32_WINNT _WIN32_WINNT_WIN10 #undef NTDDI_VERSION #define NTDDI_VERSION NTDDI_WIN10_19H1 @@ -52,7 +52,7 @@ #define PLATFORM_BSD 1 #define PLATFORM_MACOS 1 #define PLATFORM_OSX 1 - #ifndef flagUSEMALLOC + #ifndef flagUSEMALLOC // Completely disable U++ heap allocator #define STD_NEWDELETE #endif #else @@ -129,7 +129,7 @@ #endif #endif -#ifdef flagFlatpak +#ifdef flagFlatpak // Activates features for Flatpak compilation #define FLATPAK 1 #endif @@ -170,11 +170,6 @@ #define CPU_UNALIGNED #endif -#ifdef flagCLR -#define flagUSEMALLOC -#define STD_NEWDELETE -#endif - #if __cplusplus >= 201103 #define CPP_11 #endif diff --git a/uppsrc/Core/heaputil.cpp b/uppsrc/Core/heaputil.cpp index e7ce1e6d9..99eaa48ac 100644 --- a/uppsrc/Core/heaputil.cpp +++ b/uppsrc/Core/heaputil.cpp @@ -269,7 +269,7 @@ String AsString(const MemoryProfile& mem) return text; } -#ifdef flagHEAPSTAT +#ifdef flagHEAPSTAT // Produce U++ allocation heap histogram into log int stat[65536]; int bigstat; diff --git a/uppsrc/Core/sheap.cpp b/uppsrc/Core/sheap.cpp index bc41c6aae..9756962d0 100644 --- a/uppsrc/Core/sheap.cpp +++ b/uppsrc/Core/sheap.cpp @@ -478,7 +478,7 @@ size_t GetMemoryBlockSize_(void *ptr) #else -#ifdef flagHEAPLOG +#ifdef flagHEAPLOG // log all heap allocations and deallocations #undef AllocSz diff --git a/uppsrc/Core/t.h b/uppsrc/Core/t.h index 81e6815c5..3ccafb3d7 100644 --- a/uppsrc/Core/t.h +++ b/uppsrc/Core/t.h @@ -1,5 +1,3 @@ -#ifndef flagNOI18N - #ifndef _Core_lng_h_ #define _Core_lng_h_ @@ -303,5 +301,3 @@ INITBLOCK_(COMBINE3(LNG_MODULE, LNG_VERB, LNG_VERA)) #undef T_ #endif - -#endif diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index 4f7d6ee35..2f6c04924 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -5,7 +5,7 @@ #include -#ifdef flagCFONTS +#ifdef flagCFONTS // Activates custom font system in Draw (font routines in another package) #define CUSTOM_FONTSYS #endif diff --git a/uppsrc/Draw/FontCoco.mm b/uppsrc/Draw/FontCoco.mm index a5fe82b41..4d7cb0ac8 100644 --- a/uppsrc/Draw/FontCoco.mm +++ b/uppsrc/Draw/FontCoco.mm @@ -3,7 +3,9 @@ #define LLOG(x) // LOG(x) #define LTIMING(x) // TIMING(x) -#if !defined(CUSTOM_FONTSYS) && defined(PLATFORM_COCOA) && !defined(flagNOMM) +#if !defined(CUSTOM_FONTSYS) && defined(PLATFORM_COCOA) + +#ifndef flagNOMM // Removes ObjectiveC and AppKit dependence in Draw (but disables Fonts) #define Point NS_Point #define Rect NS_Rect @@ -357,4 +359,6 @@ void RenderCharacterSys(FontGlyphConsumer& sw, double x, double y, int chr, Font }; +#endif + #endif \ No newline at end of file diff --git a/uppsrc/Painter/Painter.h b/uppsrc/Painter/Painter.h index 88fd43400..d8a327702 100644 --- a/uppsrc/Painter/Painter.h +++ b/uppsrc/Painter/Painter.h @@ -3,7 +3,7 @@ #include -#ifdef flagTIMING +#ifdef flagPAINTER_TIMING // .Activate Painter benchmarking code #define PAINTER_TIMING(x) RTIMING(x) #else #define PAINTER_TIMING(x) // RTIMING(x) diff --git a/uppsrc/ide/MainConfig.cpp b/uppsrc/ide/MainConfig.cpp index 5e5fc18e6..2a7c782dc 100644 --- a/uppsrc/ide/MainConfig.cpp +++ b/uppsrc/ide/MainConfig.cpp @@ -35,19 +35,27 @@ void MainConfigDlg::FlagDlg() PPInfo pp; pp.SetIncludes(TheIde()->GetCurrentIncludePath() + ";" + GetClangInternalIncludes()); const Workspace& wspc = GetIdeWorkspace(); + + static Index ignore_flags = { + "DEBUG", "WIN32", "GUI", "DEBUGCODE", "GCC", "GCC32", "CLANG", + "ANDROID", "WIN32", "POSIX", "OSX", "SO", + }; for(int i = 0; i < wspc.GetCount(); i++) { // find package of included file const Package& pk = wspc.GetPackage(i); String pk_name = wspc[i]; for(int i = 0; i < pk.file.GetCount(); i++) - if(!pk.file[i].separator || 1) + if(!pk.file[i].separator) for(auto m : ~pp.GetFileFlags(SourcePath(pk_name, pk.file[i]))) { String f = m.key; f.TrimStart("flag"); - auto& fl = flags.GetAdd(f); - fl.b.FindAdd(pk_name); - if(m.value.GetCount() > fl.a.GetCount()) - fl.a = m.value; + if(ignore_flags.Find(f) < 0) { + auto& fl = flags.GetAdd(f); + fl.b.FindAdd(pk_name); + String comment = m.value; + if(comment.GetCount() > fl.a.GetCount()) + fl.a = comment; + } } } @@ -68,8 +76,12 @@ void MainConfigDlg::FlagDlg() cfg.accepts.ColumnWidths("29 140 458 117"); cfg.accepts.EvenRowColor(); cfg.accepts.NoCursor(); - for(const auto& f : ~flags) - cfg.accepts.Add(false, f.key, f.value.a, Join(f.value.b.GetKeys(), ", ")); + for(int pass = 0; pass < 2; pass++) // second pass for "hidden" flags + for(const auto& f : ~flags) + if((*f.value.a == '.') == pass) { + f.value.a.TrimStart("."); + cfg.accepts.Add(false, f.key, AttrText(f.value.a).Italic(pass), Join(f.value.b.GetKeys(), ", ")); + } cfg.other.SetFilter(FlagFilterM); cfg.gui <<= false; diff --git a/uppsrc/plugin/png/pngupp.cpp b/uppsrc/plugin/png/pngupp.cpp index 8358257e9..e83d70bf6 100644 --- a/uppsrc/plugin/png/pngupp.cpp +++ b/uppsrc/plugin/png/pngupp.cpp @@ -1,3 +1,6 @@ +#ifdef flagSTATIC_PNG // Forces the use of internal PNG code even if host has libpng.so +#endif // just for mainconfig info + #if defined(flagWIN32) || defined(flagOSX) || defined(flagSTATIC_PNG) #include #else