ide, uppsrc: Main config flags

This commit is contained in:
Mirek Fidler 2025-04-07 10:21:39 +02:00
parent 9a16396f90
commit 9c2102cb8e
19 changed files with 53 additions and 49 deletions

View file

@ -669,7 +669,7 @@ public:
} }
void shutdown_local() throw() { void shutdown_local() throw() {
#ifdef flagUSEMALLOC #ifdef flagUSEMALLOC // disable U++ allocator (MemoryAlloc is malloc, new/delete standard library)
tls_malloc.shutdown(); tls_malloc.shutdown();
#else #else
UPP::MemoryFreeThread(); UPP::MemoryFreeThread();

View file

@ -619,7 +619,7 @@ void AppExit__()
#endif #endif
} }
#ifdef flagTURTLE #ifdef flagTURTLE // Turtle web backend
void Turtle_PutLink(const String& link); void Turtle_PutLink(const String& link);

View file

@ -3,13 +3,9 @@
#define UPP_VERSION 0x20250200 #define UPP_VERSION 0x20250200
#ifndef flagMT
#define flagMT // MT is now always on
#endif
#define _MULTITHREADED #define _MULTITHREADED
#define MULTITHREADED #define MULTITHREADED
#ifdef flagDLL #ifdef flagDLL // Build .dll
#define flagUSEMALLOC #define flagUSEMALLOC
#define STD_NEWDELETE #define STD_NEWDELETE
#endif #endif
@ -18,7 +14,7 @@
#define _USRDLL #define _USRDLL
#endif #endif
#ifdef flagHEAPDBG #ifdef flagHEAPDBG // Activate heap debugging features even in release mode
#define HEAPDBG #define HEAPDBG
#endif #endif
@ -40,7 +36,7 @@
#include "config.h" #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 #define STD_NEWDELETE
#endif #endif
@ -278,7 +274,7 @@ namespace std {
namespace Upp { namespace Upp {
#ifndef flagNODEPRECATED #ifndef flagNODEPRECATED // Using deprecated features produces error
#define DEPRECATED #define DEPRECATED
#endif #endif
@ -290,7 +286,11 @@ class JsonIO;
#include "Ops.h" #include "Ops.h"
#include "Fn.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 #ifdef CPU_SSE2
#undef CPU_SSE2 #undef CPU_SSE2
#endif #endif
@ -441,8 +441,6 @@ typedef void *DLLHANDLE;
DLLHANDLE LoadDll__(UPP::String& fn, const char *const *names, void *const *procs); DLLHANDLE LoadDll__(UPP::String& fn, const char *const *names, void *const *procs);
void FreeDll__(DLLHANDLE dllhandle); void FreeDll__(DLLHANDLE dllhandle);
#ifndef flagNONAMESPACE
using Upp::byte; // Dirty solution to Windows.h typedef byte... using Upp::byte; // Dirty solution to Windows.h typedef byte...
#endif
#endif //CORE_H #endif //CORE_H

View file

@ -1,6 +1,6 @@
// #define MEMORY_SHRINK // #define MEMORY_SHRINK
#if !defined(flagUSEMALLOC) && !defined(flagSO) && !defined(flagHEAPOVERRIDE) #if !defined(flagUSEMALLOC) && !defined(flagSO)
#define UPP_HEAP #define UPP_HEAP
#endif #endif

View file

@ -133,8 +133,6 @@ void TinyFree(int size, void *ptr)
inline MemoryOptions::MemoryOptions() {} inline MemoryOptions::MemoryOptions() {}
inline MemoryOptions::~MemoryOptions() {} inline MemoryOptions::~MemoryOptions() {}
#ifndef flagHEAPOVERRIDE
inline void *MemoryAllocPermanent(size_t size) { return malloc(size); } inline void *MemoryAllocPermanent(size_t size) { return malloc(size); }
inline void *MemoryAlloc(size_t size) { return new byte[size]; } inline void *MemoryAlloc(size_t size) { return new byte[size]; }
inline void *MemoryAllocSz(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
#endif
dword MemoryGetCurrentSerial(); dword MemoryGetCurrentSerial();
void MemoryIgnoreNonMainLeaks(); void MemoryIgnoreNonMainLeaks();

View file

@ -77,7 +77,7 @@ private:
template <class Range> template <class Range>
void Insert_(int ii, const Range& r, bool def); 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; void Check(int blki, int offset) const;
#endif #endif
public: public:

View file

@ -308,7 +308,7 @@ void LogStream::_Put(const void *data, dword size)
sTh.Put(*q++); sTh.Put(*q++);
} }
#ifdef flagCHECKINIT #ifdef flagCHECKINIT // Adds heap check and additional logging INITBLOCKs
void InitBlockBegin__(const char *fn, int line) { void InitBlockBegin__(const char *fn, int line) {
RLOG(fn << " " << line << " init block"); RLOG(fn << " " << line << " init block");

View file

@ -496,7 +496,7 @@ void Thread::Sleep(int msec)
#endif #endif
} }
#ifdef flagPROFILEMT #ifdef flagPROFILEMT // Add code to gather Mutex locking/blocking statistics
MtInspector *MtInspector::Dumi() MtInspector *MtInspector::Dumi()
{ {
static MtInspector h(NULL); static MtInspector h(NULL);
@ -652,7 +652,6 @@ void ConditionVariable::Broadcast()
ConditionVariable::ConditionVariable() ConditionVariable::ConditionVariable()
{ {
#ifndef flagTESTXPCV
ONCELOCK { ONCELOCK {
if(IsWinVista()) { if(IsWinVista()) {
DllFn(InitializeConditionVariable, "kernel32", "InitializeConditionVariable"); DllFn(InitializeConditionVariable, "kernel32", "InitializeConditionVariable");
@ -661,7 +660,6 @@ ConditionVariable::ConditionVariable()
DllFn(SleepConditionVariableCS, "kernel32", "SleepConditionVariableCS"); DllFn(SleepConditionVariableCS, "kernel32", "SleepConditionVariableCS");
} }
} }
#endif
if(InitializeConditionVariable) if(InitializeConditionVariable)
InitializeConditionVariable(cv); InitializeConditionVariable(cv);
else else

View file

@ -4,10 +4,12 @@
# include <winnls.h> # include <winnls.h>
#endif #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 <execinfo.h> # include <execinfo.h>
# include <cxxabi.h> # include <cxxabi.h>
#endif #endif
#endif
namespace Upp { namespace Upp {

View file

@ -44,7 +44,7 @@ struct XmlError : public Exc
class XmlParser { class XmlParser {
enum { 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, MCHARS = 128,
CHUNK = 256 CHUNK = 256
#else #else

View file

@ -26,7 +26,7 @@
#undef WINVER #undef WINVER
#undef _WIN32_WINNT #undef _WIN32_WINNT
#ifdef flagWIN10 #ifdef flagWIN10 // Force _WIN32_WINNT and NTDDI_VERSION to Win10 values
#define _WIN32_WINNT _WIN32_WINNT_WIN10 #define _WIN32_WINNT _WIN32_WINNT_WIN10
#undef NTDDI_VERSION #undef NTDDI_VERSION
#define NTDDI_VERSION NTDDI_WIN10_19H1 #define NTDDI_VERSION NTDDI_WIN10_19H1
@ -52,7 +52,7 @@
#define PLATFORM_BSD 1 #define PLATFORM_BSD 1
#define PLATFORM_MACOS 1 #define PLATFORM_MACOS 1
#define PLATFORM_OSX 1 #define PLATFORM_OSX 1
#ifndef flagUSEMALLOC #ifndef flagUSEMALLOC // Completely disable U++ heap allocator
#define STD_NEWDELETE #define STD_NEWDELETE
#endif #endif
#else #else
@ -129,7 +129,7 @@
#endif #endif
#endif #endif
#ifdef flagFlatpak #ifdef flagFlatpak // Activates features for Flatpak compilation
#define FLATPAK 1 #define FLATPAK 1
#endif #endif
@ -170,11 +170,6 @@
#define CPU_UNALIGNED #define CPU_UNALIGNED
#endif #endif
#ifdef flagCLR
#define flagUSEMALLOC
#define STD_NEWDELETE
#endif
#if __cplusplus >= 201103 #if __cplusplus >= 201103
#define CPP_11 #define CPP_11
#endif #endif

View file

@ -269,7 +269,7 @@ String AsString(const MemoryProfile& mem)
return text; return text;
} }
#ifdef flagHEAPSTAT #ifdef flagHEAPSTAT // Produce U++ allocation heap histogram into log
int stat[65536]; int stat[65536];
int bigstat; int bigstat;

View file

@ -478,7 +478,7 @@ size_t GetMemoryBlockSize_(void *ptr)
#else #else
#ifdef flagHEAPLOG #ifdef flagHEAPLOG // log all heap allocations and deallocations
#undef AllocSz #undef AllocSz

View file

@ -1,5 +1,3 @@
#ifndef flagNOI18N
#ifndef _Core_lng_h_ #ifndef _Core_lng_h_
#define _Core_lng_h_ #define _Core_lng_h_
@ -303,5 +301,3 @@ INITBLOCK_(COMBINE3(LNG_MODULE, LNG_VERB, LNG_VERA))
#undef T_ #undef T_
#endif #endif
#endif

View file

@ -5,7 +5,7 @@
#include <Core/Core.h> #include <Core/Core.h>
#ifdef flagCFONTS #ifdef flagCFONTS // Activates custom font system in Draw (font routines in another package)
#define CUSTOM_FONTSYS #define CUSTOM_FONTSYS
#endif #endif

View file

@ -3,7 +3,9 @@
#define LLOG(x) // LOG(x) #define LLOG(x) // LOG(x)
#define LTIMING(x) // TIMING(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 Point NS_Point
#define Rect NS_Rect #define Rect NS_Rect
@ -357,4 +359,6 @@ void RenderCharacterSys(FontGlyphConsumer& sw, double x, double y, int chr, Font
}; };
#endif
#endif #endif

View file

@ -3,7 +3,7 @@
#include <Draw/Draw.h> #include <Draw/Draw.h>
#ifdef flagTIMING #ifdef flagPAINTER_TIMING // .Activate Painter benchmarking code
#define PAINTER_TIMING(x) RTIMING(x) #define PAINTER_TIMING(x) RTIMING(x)
#else #else
#define PAINTER_TIMING(x) // RTIMING(x) #define PAINTER_TIMING(x) // RTIMING(x)

View file

@ -35,19 +35,27 @@ void MainConfigDlg::FlagDlg()
PPInfo pp; PPInfo pp;
pp.SetIncludes(TheIde()->GetCurrentIncludePath() + ";" + GetClangInternalIncludes()); pp.SetIncludes(TheIde()->GetCurrentIncludePath() + ";" + GetClangInternalIncludes());
const Workspace& wspc = GetIdeWorkspace(); const Workspace& wspc = GetIdeWorkspace();
static Index<String> 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 for(int i = 0; i < wspc.GetCount(); i++) { // find package of included file
const Package& pk = wspc.GetPackage(i); const Package& pk = wspc.GetPackage(i);
String pk_name = wspc[i]; String pk_name = wspc[i];
for(int i = 0; i < pk.file.GetCount(); 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]))) { for(auto m : ~pp.GetFileFlags(SourcePath(pk_name, pk.file[i]))) {
String f = m.key; String f = m.key;
f.TrimStart("flag"); f.TrimStart("flag");
auto& fl = flags.GetAdd(f); if(ignore_flags.Find(f) < 0) {
fl.b.FindAdd(pk_name); auto& fl = flags.GetAdd(f);
if(m.value.GetCount() > fl.a.GetCount()) fl.b.FindAdd(pk_name);
fl.a = m.value; 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.ColumnWidths("29 140 458 117");
cfg.accepts.EvenRowColor(); cfg.accepts.EvenRowColor();
cfg.accepts.NoCursor(); cfg.accepts.NoCursor();
for(const auto& f : ~flags) for(int pass = 0; pass < 2; pass++) // second pass for "hidden" flags
cfg.accepts.Add(false, f.key, f.value.a, Join(f.value.b.GetKeys(), ", ")); 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.other.SetFilter(FlagFilterM);
cfg.gui <<= false; cfg.gui <<= false;

View file

@ -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) #if defined(flagWIN32) || defined(flagOSX) || defined(flagSTATIC_PNG)
#include <plugin/png/lib/png.h> #include <plugin/png/lib/png.h>
#else #else