Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
New GDX release 7.11.6

See merge request devel/gdx!63
  • Loading branch information
0x17 committed Aug 9, 2024
2 parents aca8d41 + 2701a9c commit 79d9395
Show file tree
Hide file tree
Showing 16 changed files with 457 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ build-debug-leg:

build-deg:
stage: build
tags: [macos]
tags: [carla] # macOS x64
script:
- cp apifiles/* src/
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_CXX_COMPILER=clang++ CMakeLists.txt
Expand Down Expand Up @@ -224,7 +224,7 @@ test-leg:

test-deg:
stage: test
tags: [macos]
tags: [carla] # macOS x64
needs: [build-deg,install-gamsdist-deg]
script:
- GAMS_PATH=$HOME/cache/gams-installs/`cat gams_folder_deg.txt`
Expand Down
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,34 @@ set(gdx-core
${zlib-units}
)

set(test-deps
# runtime library
src/rtl/p3library.cpp
src/rtl/p3library.h
src/rtl/stdthread.cpp
src/rtl/stdthread.h

# global
src/global/gmslibname.cpp
src/global/gmslibname.h

# gdlib
src/gdlib/charmaps.cpp
src/gdlib/charmaps.h
src/gdlib/gmacro.cpp
src/gdlib/gmacro.h
src/gdlib/gmsheapnew.cpp
src/gdlib/gmsheapnew.h
src/gdlib/gmsonly.h
src/gdlib/gmsonly.cpp
src/gdlib/obfuscatestr.cpp
src/gdlib/obfuscatestr.h
src/gdlib/strhash.h
src/gdlib/strhash.cpp
src/gdlib/xcompress.cpp
src/gdlib/xcompress.h
)

set(tests
src/tests/doctestmain.cpp

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ Even more abstraction is offered by the GAMS Transfer libraries for

The GDX library is written in C++17 and built via [CMake](https://cmake.org/).

The fastest way to build the GDX library (static and dynamic) locally is by running the following spells:
```
git clone https://github.com/GAMS-dev/gdx.git
cd gdx
git clone https://github.com/madler/zlib zlib
cmake -DNO_TESTS=ON -DNO_EXAMPLES=ON .
cmake --build .
```
Running this on Linux creates the dynamic library `libgdxcclib64.so` and the static library `libgdx-static.a`.

This repository contains a GitLab CI YAML that describes a pipeline which

- builds GDX for all supported platforms (Windows, macOS, Linux) with Doxygen documentation, libraries, and examples,
Expand Down
3 changes: 2 additions & 1 deletion base-units.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(base-units
# also includes unused sources (modules and headers)
set(base-units-all
# runtime library
src/rtl/p3library.cpp
src/rtl/p3library.h
Expand Down
4 changes: 4 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- 7.11.6:
- Make building (so far) unused infrastructure classes in CMake project optional
- Added toggles to disable building tests and examples as part of CMake project (use -DNO_TESTS=ON or -DNO_EXAMPLES=ON)
- Extended README with short recipe for quickly building a minimal GDX library with CMake
- 7.11.5:
- Fixed gdxOpenAppend not indicating a problem (in the return code) when trying to append to a GDX file with format version before 7 (incompatible for appending).
- Fixed gdxDataReadMap crashing when record (user-mapped) UEL indices are out of bounds (index exceeds number of UELs).
Expand Down
18 changes: 18 additions & 0 deletions src/gdlib/datastorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ class TLinkedData final
return FCount * FTotalSize;
}

int* AllocIndex()
{
#ifdef USE_GMSHEAP
return static_cast<int*>(MyHeap.XGetMem( FKeySize ));
#else
return new int[FDimension];
#endif
}

void FreeIndex(int* p)
{
#ifdef USE_GMSHEAP
MyHeap.XFreeMem( p, FKeySize );
#else
delete[] p;
#endif
}

RecType *AddItem( const KeyType *AKey, const ValueType *AData )
{
#if defined( USE_GMSHEAP )
Expand Down
10 changes: 5 additions & 5 deletions src/gdlib/gmsgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ struct P3File;

namespace gdlib::gmsgen
{
using TAnsiCharArray = std::array<char, global::gmsspecs::BigIndex>;
using TAnsiCharArray = char[global::gmsspecs::BigIndex+1]; //std::array<char, global::gmsspecs::BigIndex>;
using PAnsiCharArray = TAnsiCharArray *;
using DoubleArray = std::array<double, global::gmsspecs::BigIndex>;
using DoubleArray = double[global::gmsspecs::BigIndex+1]; //std::array<double, global::gmsspecs::BigIndex>;
using PDoubleArray = DoubleArray *;
using PTextFile = rtl::p3io::P3File *;

using LongIntArray = std::array<int, global::gmsspecs::BigIndex>;
using LongIntArray = int[global::gmsspecs::BigIndex+1]; //std::array<int, global::gmsspecs::BigIndex>;
using PLongIntArray = LongIntArray *;

using TBooleanArray = std::array<bool, global::gmsspecs::BigIndex>;
using TBooleanArray = bool[global::gmsspecs::BigIndex+1]; // std::array<bool, global::gmsspecs::BigIndex>;
using PBooleanArray = TBooleanArray *;

using TByteDataArray = std::array<uint8_t, global::gmsspecs::BigIndex>;
using TByteDataArray = uint8_t[global::gmsspecs::BigIndex]; // std::array<uint8_t, global::gmsspecs::BigIndex>;
using PByteDataArray = TByteDataArray *;

enum tfileaction : uint8_t
Expand Down
51 changes: 38 additions & 13 deletions src/gdlib/statlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,30 @@ static gdlib::statlibobj::TGMSLogStream *GMSLogObj {};
static gdlib::statlibobj::TGMSStatusStream *GMSStatusObj {};
static std::string msg;

void registerWriteCallback( gdlib::stattypes::tgwrite *fptr, void *usermem );
void registerWriteCallback( stattypes::tgwrite *fptr, void *usermem );
void initialization();
void finalization();

bool statusFileOpen( const tfileaction AAction, std::string &msg )
{
return GMSStatusObj->StatusFileOpen( AAction, msg );
}

void statusClose()
{
GMSStatusObj->StatusClose();
}

void gcstat( const std::string &s )
{
GMSStatusObj->StatusWriteLn( s );
}

void gcstatPChar( const char *p )
{
GMSStatusObj->StatusWrite( p );
}

void registerWriteCallback( gdlib::stattypes::tgwrite *fptr, void *usermem )
{
GMSStatusObj->registerWriteCallback( fptr, usermem );
Expand All @@ -66,7 +81,7 @@ void gstatMessage( const std::string &s )
GMSLogObj->LogMessage( s );
}

void dumpfilename( const std::string &prfx, bool enabled, const std::string &what, const std::string &gs, tfileaction fa, int ioResOrNeg )
void dumpfilename( const std::string &prfx, const bool enabled, const std::string &what, const std::string &gs, const tfileaction fa, const int ioResOrNeg )
{
GMSLogObj->LogDumpFilename( prfx, enabled, what, gs, fa, ioResOrNeg );
}
Expand All @@ -91,12 +106,12 @@ void GcLog( const std::string &s )
GMSLogObj->LogWriteLn( s );
}

void gstatSetLogEnabled( bool enablelog )
void gstatSetLogEnabled( const bool enablelog )
{
GMSLogObj->setLogEnabled( enablelog );
}

void gstatSetShowOSMem( int showOSMemory )
void gstatSetShowOSMem( const int showOSMemory )
{
GMSLogObj->SetOSMemory( showOSMemory );
}
Expand All @@ -116,32 +131,32 @@ void GcStatWritePlain( const std::string &s )
GMSStatusObj->StatusWritePlain( s );
}

bool gstatOpen( int Astat, tfileaction AAction, const std::string &Afn )
bool gstatOpen( const int Astat, const tfileaction AAction, const std::string &Afn )
{
return GMSLogObj->LogOpen( Astat, AAction, Afn );
}

void gstatLineNr( int N )
void gstatLineNr( const int N )
{
GMSLogObj->LogLineNr( N );
}

void gstatTraceLevel( int N )
void gstatTraceLevel( const int N )
{
GMSLogObj->setTraceLevel( N );
}

void gstatFileAnchor( bool err, const std::string &fn, int line, int col )
void gstatFileAnchor( const bool err, const std::string &fn, const int line, const int col )
{
GMSLogObj->LogFileAnchor( err, fn, line, col );
}

void gstatAnchor( int N )
void gstatAnchor( const int N )
{
GMSLogObj->LogAnchor( N );
}

void gstatFileName( const std::string &fn, int Lev )
void gstatFileName( const std::string &fn, const int Lev )
{
GMSLogObj->LogFileName( fn, Lev );
}
Expand All @@ -151,7 +166,7 @@ int gstatGetTraceLevel()
return GMSLogObj->getTraceLevel();
}

void gstatSetIDErun( bool IDErun )
void gstatSetIDErun( const bool IDErun )
{
GMSLogObj->setIDErun( IDErun );
}
Expand All @@ -171,17 +186,27 @@ void gstatReOpen()
return GMSLogObj->LogReOpen();
}

void gstatMemory( double M )
void gstatMemory( const double M )
{
if(GMSLogObj)
GMSLogObj->LogMemory( M );
}

void gstatErrorCnt( int N )
void gstatErrorCnt( const int N )
{
return GMSLogObj->LogErrrorCnt( N );
}

void gstatFreshen()
{
GMSLogObj->freshen();
}

void gstatFreshenEx()
{
GMSLogObj->freshenEx();
}

bool gstatLogEnabled()
{
return GMSLogObj->getLogEnabled();
Expand Down
18 changes: 17 additions & 1 deletion src/gdlib/statlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,18 @@ bool statusErrorNextJac( int &row, int &col );
bool statusErrorDetail( int &cnt, std::string &msg );
void statusErrorFree();

// ...
void statusSetRowCol(int rowmax, int colmax);

bool statusFileOpen(gmsgen::tfileaction AAction, std::string &msg);
void statusClose();

void gcstat(const std::string &s);
void gcstatPChar(const char *p);

// ...

// you need to adjust gmoxxx\gmodoorg.pas

void registerWriteCallback( gdlib::stattypes::tgwrite fptr, void *usermem );


Expand All @@ -138,6 +146,14 @@ void gstatReOpen();
void gstatMemory(double M);
void gstatErrorCnt( int N );

// check if the log is "fresh enough", update if not
void gstatFreshen();
/*
*check if the log is "fresh enough", update if not:
called at regular time intervals, e.g. 200 ticks
*/
void gstatFreshenEx();

void dumpfilename( const std::string &prfx, bool enabled, const std::string &what, const std::string &gs, gmsgen::tfileaction fa, int ioResOrNeg );

bool gstatLogEnabled();
Expand Down
8 changes: 4 additions & 4 deletions src/rtl/stdthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int64_t nicksPerMin { 60 * NICKS_PER_SEC },
nicksPerHour { nicksPerMin * 60 },
nicksPerDay { nicksPerHour * 24 };

/*static int64_t nowCV()
int64_t nowCV()
{
#if defined( _WIN32 )
cvTime_t cvt {};
Expand All @@ -79,16 +79,16 @@ static int64_t nicksPerMin { 60 * NICKS_PER_SEC },
#endif
}

static void incCVTimeMillis( int64_t &cvt, const uint32_t ticks )
void incCVTimeMillis( int64_t &cvt, const uint32_t ticks )
{
cvt += ticks * NICKS_PER_MSEC;
}

static void decCVTimeMillis( int64_t &cvt, const uint32_t ticks )
void decCVTimeMillis( int64_t &cvt, const uint32_t ticks )
{
cvt -= ticks * NICKS_PER_MSEC;
if( cvt < 0 ) cvt = 0;
}*/
}

static std::chrono::time_point<std::chrono::steady_clock> absTimeTP( const int64_t aTimeCV )
{
Expand Down
4 changes: 4 additions & 0 deletions src/rtl/stdthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ class TStdCondVar
bool timedWaitAbs(std::mutex &mx, int64_t absTime ) const;
};

int64_t nowCV();
void incCVTimeMillis( int64_t &cvt, uint32_t ticks );
void decCVTimeMillis( int64_t &cvt, uint32_t ticks );

}
Loading

0 comments on commit 79d9395

Please sign in to comment.