Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Release 1.0.0

See merge request ii887522/nitro!22
  • Loading branch information
ii887522 committed Jan 9, 2021
2 parents 7011cdf + 15d3363 commit 6802710
Show file tree
Hide file tree
Showing 30 changed files with 1,507 additions and 30 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ It is a general purpose C++ library that can help developers create various kind
Please go to https://gitlab.com/ii887522/nitro to start contributing instead.

## Prerequisites
- Windows 10
- [Docker Desktop](https://www.docker.com/products/docker-desktop) using Windows containers
- [Visual Studio Code](https://code.visualstudio.com/)
- Docker
Expand All @@ -33,23 +32,23 @@ Please go to https://gitlab.com/ii887522/nitro to start contributing instead.

## Update .NET Framework SDK version used by ms-build-tools to match your OS
1. Left click on the start button at the bottom left corner of your desktop.

<img src="docs/start-button.png" alt="Start button" width="770" /><br /><br />

2. Left click on the settings button at the left side of the start menu.

<img src="docs/settings.png" alt="Settings" width="770" /><br /><br />

3. Left click on the system button at the top left corner of settings window.

<img src="docs/system.png" alt="System" width="770" /><br /><br />

4. Left click on the about button at the bottom left corner of settings window.

<img src="docs/about.png" alt="About" width="770" /><br /><br />

5. Take note of the version shown in the settings window. You will need it to search for appropriate tags later.

<img src="docs/version.png" alt="Version" width="770" /><br /><br />

6. Go to https://hub.docker.com/_/microsoft-dotnet-framework-sdk/ and find Full Tag Listing section.
Expand Down Expand Up @@ -81,3 +80,8 @@ install
```sh
build
```

### Deploy project
```sh
deploy <access-token>
```
4 changes: 4 additions & 0 deletions deploy.cmd
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
4 changes: 4 additions & 0 deletions deploy.sh
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
35 changes: 30 additions & 5 deletions nitro/nitro.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\main\Any\AnimatedAny.h" />
<ClInclude Include="src\main\Any\Reactive.h" />
<ClInclude Include="src\main\Functions\math_ext.h" />
<ClInclude Include="src\main\Functions\queue_ext.h" />
<ClInclude Include="src\main\Reactive\BinaryReactive.h" />
<ClInclude Include="src\main\Reactive\UnaryReactive.h" />
<ClInclude Include="src\main\Struct\Range.h" />
<ClInclude Include="src\main\Struct\Vector.h" />
<ClInclude Include="src\test\Any\AnimatedAny.test.h" />
<ClInclude Include="src\test\Any\Reactive.test.h" />
<ClInclude Include="src\test\Functions\math_ext.test.h" />
<ClInclude Include="src\test\Functions\queue_ext.test.h" />
<ClInclude Include="src\test\Reactive\BinaryReactive.test.h" />
<ClInclude Include="src\test\Reactive\UnaryReactive.test.h" />
<ClInclude Include="src\test\Struct\Vector.test.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main\Allocator\linear_allocator.h" />
<ClCompile Include="src\test\Any\AnimatedAny.test.cpp" />
<ClCompile Include="src\test\Any\Reactive.test.cpp" />
<ClCompile Include="src\test\Functions\math_ext.test.cpp" />
<ClCompile Include="src\test\Functions\queue_ext.test.cpp" />
<ClCompile Include="src\test\Functions\test.cpp" />
<ClCompile Include="src\test\Reactive\BinaryReactive.test.cpp" />
<ClCompile Include="src\test\Reactive\UnaryReactive.test.cpp" />
<ClCompile Include="src\test\Struct\Vector.test.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
Expand Down Expand Up @@ -134,7 +162,7 @@
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>TEST;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TEST;LINEAR_ALLOCATOR;LONG_TERM_ALLOCATOR_SIZE=5304u;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
Expand Down Expand Up @@ -187,7 +215,7 @@
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>TEST;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TEST;LINEAR_ALLOCATOR;LONG_TERM_ALLOCATOR_SIZE=8168u;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
Expand Down Expand Up @@ -220,9 +248,6 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\test\test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
114 changes: 112 additions & 2 deletions nitro/nitro.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,120 @@
<Filter Include="Test Source Files">
<UniqueIdentifier>{b6579c0e-bfe8-4b51-a187-60404b74ee71}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Any">
<UniqueIdentifier>{f0392f57-51f8-4dc9-97a3-b81564a6f838}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Functions">
<UniqueIdentifier>{a72974c4-fac4-4d9d-b801-d13def8aac60}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Reactive">
<UniqueIdentifier>{179e3bd4-fe02-4d7f-b2c3-639b6eb8d1b2}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Struct">
<UniqueIdentifier>{8784fcff-f52c-416a-b6f4-8a214819be53}</UniqueIdentifier>
</Filter>
<Filter Include="Test Header Files\Any">
<UniqueIdentifier>{a853a5d0-5bcd-465b-82a6-3dffb5baa298}</UniqueIdentifier>
</Filter>
<Filter Include="Test Header Files\Functions">
<UniqueIdentifier>{72b06555-60e9-4409-a99e-73b6d6a528d2}</UniqueIdentifier>
</Filter>
<Filter Include="Test Header Files\Reactive">
<UniqueIdentifier>{3d0bbcbf-74bb-4101-ac26-4038e54e4683}</UniqueIdentifier>
</Filter>
<Filter Include="Test Header Files\Struct">
<UniqueIdentifier>{19558d27-8bc0-4ec7-9c03-6af01d816423}</UniqueIdentifier>
</Filter>
<Filter Include="Test Source Files\Any">
<UniqueIdentifier>{82739f87-9db2-42b4-b145-3e1617770a1d}</UniqueIdentifier>
</Filter>
<Filter Include="Test Source Files\Functions">
<UniqueIdentifier>{3e1422de-17a3-4af0-b792-303b91900ac7}</UniqueIdentifier>
</Filter>
<Filter Include="Test Source Files\Struct">
<UniqueIdentifier>{3bed952f-5fd6-4645-8fb4-13f0598a4dbe}</UniqueIdentifier>
</Filter>
<Filter Include="Test Source Files\Reactive">
<UniqueIdentifier>{89423a92-d04d-44fb-b078-e3c3909887d4}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Allocator">
<UniqueIdentifier>{32fab255-14c2-421b-b489-35537f8e9d5e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\main\Any\AnimatedAny.h">
<Filter>Header Files\Any</Filter>
</ClInclude>
<ClInclude Include="src\main\Any\Reactive.h">
<Filter>Header Files\Any</Filter>
</ClInclude>
<ClInclude Include="src\main\Functions\math_ext.h">
<Filter>Header Files\Functions</Filter>
</ClInclude>
<ClInclude Include="src\main\Functions\queue_ext.h">
<Filter>Header Files\Functions</Filter>
</ClInclude>
<ClInclude Include="src\main\Struct\Range.h">
<Filter>Header Files\Struct</Filter>
</ClInclude>
<ClInclude Include="src\main\Struct\Vector.h">
<Filter>Header Files\Struct</Filter>
</ClInclude>
<ClInclude Include="src\main\Reactive\BinaryReactive.h">
<Filter>Header Files\Reactive</Filter>
</ClInclude>
<ClInclude Include="src\main\Reactive\UnaryReactive.h">
<Filter>Header Files\Reactive</Filter>
</ClInclude>
<ClInclude Include="src\test\Any\AnimatedAny.test.h">
<Filter>Test Header Files\Any</Filter>
</ClInclude>
<ClInclude Include="src\test\Any\Reactive.test.h">
<Filter>Test Header Files\Any</Filter>
</ClInclude>
<ClInclude Include="src\test\Functions\math_ext.test.h">
<Filter>Test Header Files\Functions</Filter>
</ClInclude>
<ClInclude Include="src\test\Functions\queue_ext.test.h">
<Filter>Test Header Files\Functions</Filter>
</ClInclude>
<ClInclude Include="src\test\Struct\Vector.test.h">
<Filter>Test Header Files\Struct</Filter>
</ClInclude>
<ClInclude Include="src\test\Reactive\BinaryReactive.test.h">
<Filter>Test Header Files\Reactive</Filter>
</ClInclude>
<ClInclude Include="src\test\Reactive\UnaryReactive.test.h">
<Filter>Test Header Files\Reactive</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\test\test.cpp">
<Filter>Test Source Files</Filter>
<ClCompile Include="src\test\Functions\math_ext.test.cpp">
<Filter>Test Source Files\Functions</Filter>
</ClCompile>
<ClCompile Include="src\test\Functions\queue_ext.test.cpp">
<Filter>Test Source Files\Functions</Filter>
</ClCompile>
<ClCompile Include="src\test\Functions\test.cpp">
<Filter>Test Source Files\Functions</Filter>
</ClCompile>
<ClCompile Include="src\test\Struct\Vector.test.cpp">
<Filter>Test Source Files\Struct</Filter>
</ClCompile>
<ClCompile Include="src\test\Reactive\BinaryReactive.test.cpp">
<Filter>Test Source Files\Reactive</Filter>
</ClCompile>
<ClCompile Include="src\test\Reactive\UnaryReactive.test.cpp">
<Filter>Test Source Files\Reactive</Filter>
</ClCompile>
<ClCompile Include="src\test\Any\AnimatedAny.test.cpp">
<Filter>Test Source Files\Any</Filter>
</ClCompile>
<ClCompile Include="src\test\Any\Reactive.test.cpp">
<Filter>Test Source Files\Any</Filter>
</ClCompile>
<ClCompile Include="src\main\Allocator\linear_allocator.h">
<Filter>Header Files\Allocator</Filter>
</ClCompile>
</ItemGroup>
</Project>
103 changes: 103 additions & 0 deletions nitro/src/main/Allocator/linear_allocator.h
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
Loading

0 comments on commit 6802710

Please sign in to comment.