Skip to content

Commit 0eeed0c

Browse files
committed
Remove specializations for vector_storage that add fields (x, y, z, w) since this is not supported on all compilers
1 parent fcfd9c1 commit 0eeed0c

File tree

2 files changed

+22
-190
lines changed

2 files changed

+22
-190
lines changed

include/kernel_float/base.h

+10-94
Original file line numberDiff line numberDiff line change
@@ -21,126 +21,42 @@ struct alignas(Alignment) aligned_array {
2121
T items_[N] = {};
2222
};
2323

24-
template<typename T, size_t Alignment>
25-
struct aligned_array<T, 0, Alignment> {
26-
KERNEL_FLOAT_INLINE
27-
T* data() {
28-
while (true)
29-
;
30-
}
31-
32-
KERNEL_FLOAT_INLINE
33-
const T* data() const {
34-
while (true)
35-
;
36-
}
37-
};
38-
3924
template<typename T, size_t Alignment>
4025
struct alignas(Alignment) aligned_array<T, 1, Alignment> {
4126
KERNEL_FLOAT_INLINE
42-
aligned_array(T value = {}) : x(value) {}
27+
aligned_array(T item = {}) : item_(item) {}
4328

4429
KERNEL_FLOAT_INLINE
4530
operator T() const {
46-
return x;
47-
}
48-
49-
KERNEL_FLOAT_INLINE
50-
T* data() {
51-
return &x;
52-
}
53-
54-
KERNEL_FLOAT_INLINE
55-
const T* data() const {
56-
return &x;
57-
}
58-
59-
T x;
60-
};
61-
62-
template<typename T, size_t Alignment>
63-
struct alignas(Alignment) aligned_array<T, 2, Alignment> {
64-
KERNEL_FLOAT_INLINE
65-
aligned_array(T x, T y) : x(x), y(y) {}
66-
67-
KERNEL_FLOAT_INLINE
68-
aligned_array() : aligned_array(T {}, T {}) {}
69-
70-
KERNEL_FLOAT_INLINE
71-
T* data() {
72-
return items;
31+
return item_;
7332
}
7433

75-
KERNEL_FLOAT_INLINE
76-
const T* data() const {
77-
return items;
78-
}
79-
80-
union {
81-
T items[2];
82-
struct {
83-
T x;
84-
T y;
85-
};
86-
};
87-
};
88-
89-
template<typename T, size_t Alignment>
90-
struct alignas(Alignment) aligned_array<T, 3, Alignment> {
91-
KERNEL_FLOAT_INLINE
92-
aligned_array(T x, T y, T z) : x(x), y(y), z(z) {}
93-
94-
KERNEL_FLOAT_INLINE
95-
aligned_array() : aligned_array(T {}, T {}, T {}) {}
96-
9734
KERNEL_FLOAT_INLINE
9835
T* data() {
99-
return items;
36+
return &item_;
10037
}
10138

10239
KERNEL_FLOAT_INLINE
10340
const T* data() const {
104-
return items;
41+
return &item_;
10542
}
10643

107-
union {
108-
T items[3];
109-
struct {
110-
T x;
111-
T y;
112-
T z;
113-
};
114-
};
44+
T item_ = {};
11545
};
11646

11747
template<typename T, size_t Alignment>
118-
struct alignas(Alignment) aligned_array<T, 4, Alignment> {
119-
KERNEL_FLOAT_INLINE
120-
aligned_array(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}
121-
122-
KERNEL_FLOAT_INLINE
123-
aligned_array() : aligned_array(T {}, T {}, T {}, T {}) {}
124-
48+
struct aligned_array<T, 0, Alignment> {
12549
KERNEL_FLOAT_INLINE
12650
T* data() {
127-
return items;
51+
while (true)
52+
;
12853
}
12954

13055
KERNEL_FLOAT_INLINE
13156
const T* data() const {
132-
return items;
57+
while (true)
58+
;
13359
}
134-
135-
union {
136-
T items[4];
137-
struct {
138-
T x;
139-
T y;
140-
T z;
141-
T w;
142-
};
143-
};
14460
};
14561

14662
KERNEL_FLOAT_INLINE

single_include/kernel_float.h

+12-96
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
//================================================================================
1818
// this file has been auto-generated, do not modify its contents!
19-
// date: 2023-09-28 12:12:55.542179
20-
// git hash: 0ae5853b782118d9842541588429b4aec7ff186a
19+
// date: 2023-10-06 16:02:20.461619
20+
// git hash: d578b7a87ead79baf78e181e8fbe14c03ea3f9a6
2121
//================================================================================
2222

2323
#ifndef KERNEL_FLOAT_MACROS_H
@@ -365,126 +365,42 @@ struct alignas(Alignment) aligned_array {
365365
T items_[N] = {};
366366
};
367367

368-
template<typename T, size_t Alignment>
369-
struct aligned_array<T, 0, Alignment> {
370-
KERNEL_FLOAT_INLINE
371-
T* data() {
372-
while (true)
373-
;
374-
}
375-
376-
KERNEL_FLOAT_INLINE
377-
const T* data() const {
378-
while (true)
379-
;
380-
}
381-
};
382-
383368
template<typename T, size_t Alignment>
384369
struct alignas(Alignment) aligned_array<T, 1, Alignment> {
385370
KERNEL_FLOAT_INLINE
386-
aligned_array(T value = {}) : x(value) {}
371+
aligned_array(T item = {}) : item_(item) {}
387372

388373
KERNEL_FLOAT_INLINE
389374
operator T() const {
390-
return x;
375+
return item_;
391376
}
392377

393378
KERNEL_FLOAT_INLINE
394379
T* data() {
395-
return &x;
380+
return &item_;
396381
}
397382

398383
KERNEL_FLOAT_INLINE
399384
const T* data() const {
400-
return &x;
385+
return &item_;
401386
}
402387

403-
T x;
388+
T item_ = {};
404389
};
405390

406391
template<typename T, size_t Alignment>
407-
struct alignas(Alignment) aligned_array<T, 2, Alignment> {
408-
KERNEL_FLOAT_INLINE
409-
aligned_array(T x, T y) : x(x), y(y) {}
410-
411-
KERNEL_FLOAT_INLINE
412-
aligned_array() : aligned_array(T {}, T {}) {}
413-
414-
KERNEL_FLOAT_INLINE
415-
T* data() {
416-
return items;
417-
}
418-
419-
KERNEL_FLOAT_INLINE
420-
const T* data() const {
421-
return items;
422-
}
423-
424-
union {
425-
T items[2];
426-
struct {
427-
T x;
428-
T y;
429-
};
430-
};
431-
};
432-
433-
template<typename T, size_t Alignment>
434-
struct alignas(Alignment) aligned_array<T, 3, Alignment> {
435-
KERNEL_FLOAT_INLINE
436-
aligned_array(T x, T y, T z) : x(x), y(y), z(z) {}
437-
438-
KERNEL_FLOAT_INLINE
439-
aligned_array() : aligned_array(T {}, T {}, T {}) {}
440-
441-
KERNEL_FLOAT_INLINE
442-
T* data() {
443-
return items;
444-
}
445-
446-
KERNEL_FLOAT_INLINE
447-
const T* data() const {
448-
return items;
449-
}
450-
451-
union {
452-
T items[3];
453-
struct {
454-
T x;
455-
T y;
456-
T z;
457-
};
458-
};
459-
};
460-
461-
template<typename T, size_t Alignment>
462-
struct alignas(Alignment) aligned_array<T, 4, Alignment> {
463-
KERNEL_FLOAT_INLINE
464-
aligned_array(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}
465-
466-
KERNEL_FLOAT_INLINE
467-
aligned_array() : aligned_array(T {}, T {}, T {}, T {}) {}
468-
392+
struct aligned_array<T, 0, Alignment> {
469393
KERNEL_FLOAT_INLINE
470394
T* data() {
471-
return items;
395+
while (true)
396+
;
472397
}
473398

474399
KERNEL_FLOAT_INLINE
475400
const T* data() const {
476-
return items;
401+
while (true)
402+
;
477403
}
478-
479-
union {
480-
T items[4];
481-
struct {
482-
T x;
483-
T y;
484-
T z;
485-
T w;
486-
};
487-
};
488404
};
489405

490406
KERNEL_FLOAT_INLINE

0 commit comments

Comments
 (0)