diff --git a/UnitTests/macros.h b/UnitTests/macros.h
index 4c375df75..4f927489d 100644
--- a/UnitTests/macros.h
+++ b/UnitTests/macros.h
@@ -22,4 +22,13 @@ bool UnitTestsFuncs::UT_##B##N()
#define UNIT_TEST_BATCH General_
+#define DO_2X(EX) EX; EX
+#define DO_4X(EX) DO_2X(EX); DO_2X(EX)
+#define DO_8X(EX) DO_4X(EX); DO_4X(EX)
+#define DO_16X(EX) DO_8X(EX); DO_8X(EX)
+#define DO_32X(EX) DO_16X(EX); DO_16X(EX)
+#define DO_64X(EX) DO_32X(EX); DO_32X(EX)
+#define DO_128X(EX) DO_64X(EX); DO_64X(EX)
+#define DO_256X(EX) DO_128X(EX); DO_128X(EX)
+
#endif // macros_h__
diff --git a/Vorb.vcxproj b/Vorb.vcxproj
index 807ee93cf..408a392e9 100644
--- a/Vorb.vcxproj
+++ b/Vorb.vcxproj
@@ -508,6 +508,7 @@
+
diff --git a/Vorb.vcxproj.filters b/Vorb.vcxproj.filters
index 7ed1087c6..008431514 100644
--- a/Vorb.vcxproj.filters
+++ b/Vorb.vcxproj.filters
@@ -855,6 +855,9 @@
Utils
+
+ Utils
+
Core
diff --git a/include/Bitfields.inl b/include/Bitfields.inl
new file mode 100644
index 000000000..753e4148e
--- /dev/null
+++ b/include/Bitfields.inl
@@ -0,0 +1,88 @@
+/*! \file typesArray.inl
+ * @brief Bitfield implementation for different access methodologies.
+ */
+
+#define VORB_BITS_PER_BYTE 8
+
+namespace vorb {
+ /*! @brief
+ */
+ template
+ class UncheckedBitfield {
+ static_assert(std::is_integral::value, "Bitfield may only represent integral types");
+ static_assert(BITOFF < sizeof(T) * VORB_BITS_PER_BYTE, "Starting offset must be contained within the type");
+ static_assert((BITOFF + BITSIZE) <= sizeof(T) * VORB_BITS_PER_BYTE, "Bitfield must be contained within the type");
+ public:
+ UncheckedBitfield& operator = (T v) {
+ // Reduced by an extra masking operation for overflowss
+ value = (value & ~(((1 << BITSIZE) - 1) << BITOFF)) | (v << BITOFF);
+ return *this;
+ }
+
+ UncheckedBitfield& operator += (T v) {
+ // Allows for overflows
+ value += (v << BITOFF);
+ return *this;
+ }
+ UncheckedBitfield& operator -= (T v) {
+ // Allows for overflows
+ value -= (v << BITOFF);
+ return *this;
+ }
+ UncheckedBitfield& operator *= (T v) {
+ field *= v;
+ return *this;
+ }
+ UncheckedBitfield& operator /= (T v) {
+ field /= v;
+ return *this;
+ }
+ UncheckedBitfield& operator |= (T v) {
+ value |= (v << BITOFF);
+ return *this;
+ }
+ UncheckedBitfield& operator &= (T v) {
+ value &= (v << BITOFF) | ~(((1 << BITSIZE) - 1) << BITOFF);
+ return *this;
+ }
+ UncheckedBitfield& operator ^= (T v) {
+ value ^= (v << BITOFF);
+ return *this;
+ }
+
+ T operator + (T v) {
+ return field + v;
+ }
+ T operator - (T v) {
+ return field - v;
+ }
+ T operator * (T v) {
+ return field * v;
+ }
+ T operator / (T v) {
+ return field / v;
+ }
+ T operator | (T v) {
+ return field | v;
+ }
+ T operator & (T v) {
+ return field & v;
+ }
+ T operator ^ (T v) {
+ return field ^ v;
+ }
+
+ operator T() const {
+ return field;
+ }
+
+ union {
+ T value;
+ struct {
+ T : BITOFF;
+ T field : BITSIZE;
+ T : ((sizeof(T) * VORB_BITS_PER_BYTE) - (BITOFF + BITSIZE));
+ };
+ };
+ };
+}