Eliminated the huge bugs caused by replacing thingy[0] with thingy[1]. Replaced small_data_start with an inline function SmallDataStart() that knows how to pacify mwcc. Should have negligible to no impact on x86 performance.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5286 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
55e3d98707
commit
f929e15217
@ -302,7 +302,7 @@ Inode::MakeSpaceForSmallData(Transaction *transaction, const char *name, int32 b
|
||||
ASSERT(fSmallDataLock.IsLocked());
|
||||
|
||||
while (bytes > 0) {
|
||||
small_data *item = Node()->small_data_start, *max = NULL;
|
||||
small_data *item = Node()->SmallDataStart(), *max = NULL;
|
||||
int32 index = 0, maxIndex = 0;
|
||||
for (; !item->IsLast(Node()); item = item->Next(), index++) {
|
||||
// should not remove those
|
||||
@ -408,7 +408,7 @@ Inode::RemoveSmallData(Transaction *transaction, const char *name)
|
||||
|
||||
// search for the small_data item
|
||||
|
||||
small_data *item = Node()->small_data_start;
|
||||
small_data *item = Node()->SmallDataStart();
|
||||
int32 index = 0;
|
||||
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
||||
item = item->Next();
|
||||
@ -449,7 +449,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type,
|
||||
|
||||
SimpleLocker locker(fSmallDataLock);
|
||||
|
||||
small_data *item = Node()->small_data_start;
|
||||
small_data *item = Node()->SmallDataStart();
|
||||
int32 index = 0;
|
||||
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
||||
item = item->Next();
|
||||
@ -480,7 +480,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type,
|
||||
return B_ERROR;
|
||||
|
||||
// reset our pointers
|
||||
item = Node()->small_data_start;
|
||||
item = Node()->SmallDataStart();
|
||||
index = 0;
|
||||
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
||||
item = item->Next();
|
||||
@ -531,7 +531,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type,
|
||||
return B_ERROR;
|
||||
|
||||
// get new last item!
|
||||
item = Node()->small_data_start;
|
||||
item = Node()->SmallDataStart();
|
||||
index = 0;
|
||||
while (!item->IsLast(Node())) {
|
||||
item = item->Next();
|
||||
@ -584,7 +584,7 @@ Inode::GetNextSmallData(small_data **_smallData) const
|
||||
|
||||
// begin from the start?
|
||||
if (data == NULL)
|
||||
data = Node()->small_data_start;
|
||||
data = Node()->SmallDataStart();
|
||||
else
|
||||
data = data->Next();
|
||||
|
||||
@ -2091,7 +2091,7 @@ AttributeIterator::GetNext(char *name, size_t *_length, uint32 *_type, vnode_id
|
||||
// read attributes out of the small data section
|
||||
|
||||
if (fCurrentSmallData >= 0) {
|
||||
small_data *item = fInode->Node()->small_data_start;
|
||||
small_data *item = fInode->Node()->SmallDataStart();
|
||||
|
||||
fInode->SmallDataLock().Lock();
|
||||
|
||||
|
@ -133,11 +133,8 @@ struct small_data {
|
||||
uint32 type;
|
||||
uint16 name_size;
|
||||
uint16 data_size;
|
||||
|
||||
#if __MWERKS__
|
||||
char name[1]; // name_size long, followed by data
|
||||
// ToDo: this is bad and breaks the code
|
||||
#else
|
||||
|
||||
#if !__MWERKS__ //-- mwcc doesn't support thingy[0], so we patch Name() instead
|
||||
char name[0]; // name_size long, followed by data
|
||||
#endif
|
||||
|
||||
@ -186,13 +183,18 @@ struct bfs_inode {
|
||||
};
|
||||
int32 pad[4];
|
||||
|
||||
#if __MWERKS__
|
||||
small_data small_data_start[1];
|
||||
// ToDo: this reduces the space you have in an inode for attributes
|
||||
#else
|
||||
#if !__MWERKS__
|
||||
small_data small_data_start[0];
|
||||
#endif
|
||||
|
||||
|
||||
inline small_data *SmallDataStart() const {
|
||||
#if __MWERKS__
|
||||
return (small_data *)(&pad[4] /* last item in pad + sizeof(int32) */);
|
||||
#else
|
||||
return small_data_start;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 Magic1() const { return BFS_ENDIAN_TO_HOST_INT32(magic1); }
|
||||
int32 UserID() const { return BFS_ENDIAN_TO_HOST_INT32(uid); }
|
||||
int32 GroupID() const { return BFS_ENDIAN_TO_HOST_INT32(gid); }
|
||||
@ -341,14 +343,18 @@ block_run::Run(int32 group, uint16 start, uint16 length)
|
||||
inline char *
|
||||
small_data::Name() const
|
||||
{
|
||||
#if __MWERKS__
|
||||
return (char *)(uint32(&data_size)+uint32(sizeof(data_size)));
|
||||
#else
|
||||
return const_cast<char *>(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline uint8 *
|
||||
small_data::Data() const
|
||||
{
|
||||
return (uint8 *)name + NameSize() + 3;
|
||||
return (uint8 *)Name() + NameSize() + 3;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user