[ox] Replace __attribute__((packed)) with OX_PACKED

This commit is contained in:
Gary Talent 2019-12-19 23:38:17 -06:00
parent 1499f42361
commit 8c576ef9c5
8 changed files with 20 additions and 11 deletions

View File

@ -23,7 +23,7 @@ struct StatInfo {
};
template<typename size_t>
struct __attribute__((packed)) FileStoreItem: public ptrarith::Item<size_t> {
struct OX_PACKED FileStoreItem: public ptrarith::Item<size_t> {
ox::LittleEndian<size_t> id = 0;
ox::LittleEndian<uint8_t> fileType = 0;
ox::LittleEndian<size_t> links = 0;
@ -64,7 +64,7 @@ class FileStoreTemplate {
static constexpr InodeId_t ReservedInodeEnd = 100;
static constexpr auto MaxInode = MaxValue<size_t> / 2;
struct __attribute__((packed)) FileStoreData {
struct OX_PACKED FileStoreData {
ox::LittleEndian<size_t> rootNode = 0;
ox::Random random;
};

View File

@ -16,10 +16,10 @@
namespace ox {
template<typename InodeId_t>
struct __attribute__((packed)) DirectoryEntry {
struct OX_PACKED DirectoryEntry {
public:
struct __attribute__((packed)) DirectoryEntryData {
struct OX_PACKED DirectoryEntryData {
// DirectoryEntry fields
LittleEndian<InodeId_t> inode = 0;
char name[MaxFileNameLength];

View File

@ -89,7 +89,7 @@ class FileSystemTemplate: public FileSystem {
private:
static constexpr auto InodeFsData = 2;
struct __attribute__((packed)) FileSystemData {
struct OX_PACKED FileSystemData {
LittleEndian<typename FileStore::InodeId_t> rootDirInode;
};

View File

@ -8,6 +8,7 @@
#pragma once
#include <ox/std/stddef.hpp>
#include <ox/std/trace.hpp>
#include "ptr.hpp"
@ -15,10 +16,10 @@
namespace ox::ptrarith {
template<typename size_t, typename Item>
class __attribute__((packed)) NodeBuffer {
class OX_PACKED NodeBuffer {
public:
struct __attribute__((packed)) Header {
struct OX_PACKED Header {
ox::LittleEndian<size_t> size = sizeof(Header); // capacity
ox::LittleEndian<size_t> bytesUsed = sizeof(Header);
ox::LittleEndian<size_t> firstItem = 0;
@ -433,7 +434,7 @@ uint8_t *NodeBuffer<size_t, Item>::data() {
template<typename size_t>
struct __attribute__((packed)) Item {
struct OX_PACKED Item {
public:
ox::LittleEndian<size_t> prev = 0;
ox::LittleEndian<size_t> next = 0;

View File

@ -26,7 +26,7 @@ using namespace std;
using namespace ox;
template<typename T>
struct __attribute__((packed)) NodeType: public ox::ptrarith::Item<T> {
struct OX_PACKED NodeType: public ox::ptrarith::Item<T> {
public:
size_t fullSize() const {
return this->size() + sizeof(*this);

View File

@ -9,6 +9,7 @@
#pragma once
#include "defines.hpp"
#include "stddef.hpp"
#include "types.hpp"
#include "typetraits.hpp"
@ -58,7 +59,7 @@ template<typename T, bool byteSwap>
}
template<typename T, bool byteSwap>
class __attribute__((packed)) ByteSwapInteger {
class OX_PACKED ByteSwapInteger {
private:
T m_value;

View File

@ -8,13 +8,14 @@
#pragma once
#include "stddef.hpp"
#include "types.hpp"
namespace ox {
using RandomSeed = uint64_t[2];
class __attribute__((packed)) Random {
class OX_PACKED Random {
private:
RandomSeed m_seed;

View File

@ -13,3 +13,9 @@
#else
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif
#ifdef _MSC_VER
#define OX_PACKED
#else
#define OX_PACKED __attribute__((packed))
#endif