This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 'master'
Release 1.0.0 See merge request ii887522/nitro!22
- Loading branch information
Showing
30 changed files
with
1,507 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
docker run --rm --name nitro_bundler -w C:\nitro -v %CD%:C:\nitro mcr.microsoft.com/windows/servercore:20H2 cmd /c mkdir libs && cd libs && mkdir nitro && cd nitro && mkdir include && cd include && xcopy ..\..\..\nitro\src\main\ .\ /s && cd .. && mkdir lib && cd lib && mkdir x86 && cd x86 && mkdir Debug && cd Debug && copy ..\..\..\..\..\nitro\Debug\nitro.lib .\ && cd .. && mkdir Release && cd Release && copy ..\..\..\..\..\nitro\Release\nitro.lib .\ && cd .. && cd .. && mkdir x64 && cd x64 && mkdir Debug && cd Debug && copy ..\..\..\..\..\nitro\x64\Debug\nitro.lib .\ && cd .. && mkdir Release && cd Release && copy ..\..\..\..\..\nitro\x64\Release\nitro.lib .\ && cd .. && cd .. && cd .. && cd .. && cd .. | ||
docker run --rm --name nitro_zipper -w C:\nitro\libs -v %CD%\libs:C:\nitro\libs kiazhi/nanoserver.7-zip:1709-18.05 7z a nitro.zip nitro\ | ||
docker run --rm --name nitro_publisher -v %CD%\libs:C:\nitro\libs stefanscherer/curl-windows:7.58.0 --header "PRIVATE-TOKEN: %1" --upload-file C:\nitro\libs\nitro.zip https://gitlab.com/api/v4/projects/23530641/packages/generic/nitro/1.0.0/nitro.zip | ||
docker run --rm --name nitro_cleaner -w C:\nitro -v %CD%:C:\nitro mcr.microsoft.com/windows/servercore:20H2 cmd /c rmdir libs /s /q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
docker run --rm --name nitro_bundler -w C:/nitro -v $PWD:C:/nitro mcr.microsoft.com/windows/servercore:20H2 cmd /c mkdir libs && cd libs && mkdir nitro && cd nitro && mkdir include && cd include && xcopy ..\..\..\nitro\src\main\ .\ /s && cd .. && mkdir lib && cd lib && mkdir x86 && cd x86 && mkdir Debug && cd Debug && copy ..\..\..\..\..\nitro\Debug\nitro.lib .\ && cd .. && mkdir Release && cd Release && copy ..\..\..\..\..\nitro\Release\nitro.lib .\ && cd .. && cd .. && mkdir x64 && cd x64 && mkdir Debug && cd Debug && copy ..\..\..\..\..\nitro\x64\Debug\nitro.lib .\ && cd .. && mkdir Release && cd Release && copy ..\..\..\..\..\nitro\x64\Release\nitro.lib .\ && cd .. && cd .. && cd .. && cd .. && cd .. | ||
docker run --rm --name nitro_zipper -w C:/nitro/libs -v $PWD/libs:C:/nitro/libs kiazhi/nanoserver.7-zip:1709-18.05 7z a nitro.zip nitro\ | ||
docker run --rm --name nitro_publisher -v $PWD/libs:C:/nitro/libs stefanscherer/curl-windows:7.58.0 --header "PRIVATE-TOKEN: %1" --upload-file C:\nitro\libs\nitro.zip https://gitlab.com/api/v4/projects/23530641/packages/generic/nitro/1.0.0/nitro.zip | ||
docker run --rm --name nitro_cleaner -w C:/nitro -v $PWD:C:/nitro mcr.microsoft.com/windows/servercore:20H2 cmd /c rmdir libs /s /q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#ifdef LINEAR_ALLOCATOR | ||
|
||
#ifndef II887522_NITRO_LINEAR_ALLOCATOR_H | ||
#define II887522_NITRO_LINEAR_ALLOCATOR_H | ||
|
||
#include "../Functions/math_ext.h" | ||
#include <new> | ||
|
||
using ii887522::nitro::min; | ||
using std::bad_alloc; | ||
|
||
#ifdef _DEBUG | ||
#include <iostream> | ||
|
||
using std::cout; | ||
#endif | ||
|
||
namespace ii887522::nitro | ||
{ | ||
enum class Term : unsigned int | ||
{ | ||
LONG, SHORT | ||
}; | ||
|
||
static char longTermData[LONG_TERM_ALLOCATOR_SIZE]; | ||
static size_t longTermDataSize{ 0u }; | ||
#ifdef SHORT_TERM_ALLOCATOR_SIZE | ||
static char shortTermData[SHORT_TERM_ALLOCATOR_SIZE]; | ||
static size_t shortTermDataSize{ 0u }; | ||
#endif | ||
static Term term{ Term::LONG }; | ||
|
||
constexpr static size_t getAlignedDataSize(const size_t dataSize, const size_t size) | ||
{ | ||
const auto alignmentRequirement{ min(size, alignof(max_align_t)) }; | ||
return (dataSize / alignmentRequirement + 1u) * alignmentRequirement; | ||
} | ||
|
||
// Not Thread Safe | ||
static void* longTermAlloc(const size_t size) | ||
{ | ||
longTermDataSize = getAlignedDataSize(longTermDataSize, size); | ||
const auto result{ longTermData + longTermDataSize }; | ||
longTermDataSize += size; | ||
#ifdef _DEBUG | ||
cout << "Long term data usage: " << longTermDataSize << " bytes\n"; | ||
#endif | ||
return result; | ||
} | ||
|
||
|
||
// Not Thread Safe | ||
static void* shortTermAlloc(const size_t size) | ||
{ | ||
#ifdef SHORT_TERM_ALLOCATOR_SIZE | ||
shortTermDataSize = getAlignedDataSize(shortTermDataSize, size); | ||
const auto result{ shortTermData + shortTermDataSize }; | ||
shortTermDataSize += size; | ||
#ifdef _DEBUG | ||
cout << "Short term data usage: " << shortTermDataSize << " bytes\n"; | ||
#endif | ||
return result; | ||
#else | ||
size; | ||
return nullptr; | ||
#endif | ||
} | ||
|
||
#ifdef SHORT_TERM_ALLOCATOR_SIZE | ||
constexpr void beginShortTermAlloc() | ||
{ | ||
term = Term::SHORT; | ||
} | ||
|
||
constexpr void endShortTermAlloc() | ||
{ | ||
shortTermDataSize = 0u; | ||
term = Term::LONG; | ||
} | ||
#endif | ||
} | ||
|
||
using ii887522::nitro::Term; | ||
using ii887522::nitro::term; | ||
using ii887522::nitro::longTermAlloc; | ||
using ii887522::nitro::shortTermAlloc; | ||
|
||
// Not Thread Safe | ||
void* operator new(const size_t size) | ||
{ | ||
switch (term) | ||
{ | ||
case Term::LONG: return longTermAlloc(size); | ||
case Term::SHORT: return shortTermAlloc(size); | ||
} | ||
throw bad_alloc{ }; | ||
} | ||
|
||
// Not Thread Safe | ||
void operator delete(void*const) { } | ||
|
||
#endif | ||
#endif |
Oops, something went wrong.