Browse Source

Added include guard and moved in includes.

David Piuva 1 year ago
parent
commit
070d84388b
2 changed files with 12 additions and 10 deletions
  1. 2 0
      Source/DFPSR/base/virtualStack.cpp
  2. 10 10
      Source/DFPSR/base/virtualStack.h

+ 2 - 0
Source/DFPSR/base/virtualStack.cpp

@@ -22,6 +22,8 @@
 //    distribution.
 
 #include "virtualStack.h"
+#include <thread>
+#include "../api/stringAPI.h"
 
 namespace dsr {
 	// A structure that is placed in front of each stack allocation while allocating backwards along decreasing addresses to allow aligning memory quickly using bit masking.

+ 10 - 10
Source/DFPSR/base/virtualStack.h

@@ -21,21 +21,19 @@
 //    3. This notice may not be removed or altered from any source
 //    distribution.
 
-#include "SafePointer.h"
-#include "../api/stringAPI.h"
 
-#include <mutex>
-#include <thread>
+#ifndef DFPSR_VIRTUAL_STACK
+#define DFPSR_VIRTUAL_STACK
 
-namespace dsr {
-	// TODO: Make overloaded versions for signed and unsigned integer types.
-	constexpr uint64_t roundUp(uint64_t size, uint64_t alignment) {
-		return size + (alignment - 1) - ((size - 1) % alignment);
-	}
+#include "SafePointer.h"
 
+namespace dsr {
 	template <typename T>
 	constexpr uint64_t memory_getPaddedSize() {
-		return roundUp((uint64_t)sizeof(T), (uint64_t)alignof(T));
+		uint64_t size = (uint64_t)sizeof(T);
+		uint64_t alignment = (uint64_t)alignof(T);
+		// Round up with unsigned integers.
+		return size + (alignment - 1) - ((size - 1) % alignment);
 	}
 
 	// Pre-condition:
@@ -86,3 +84,5 @@ namespace dsr {
 		}
 	};
 }
+
+#endif