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());
|
ASSERT(fSmallDataLock.IsLocked());
|
||||||
|
|
||||||
while (bytes > 0) {
|
while (bytes > 0) {
|
||||||
small_data *item = Node()->small_data_start, *max = NULL;
|
small_data *item = Node()->SmallDataStart(), *max = NULL;
|
||||||
int32 index = 0, maxIndex = 0;
|
int32 index = 0, maxIndex = 0;
|
||||||
for (; !item->IsLast(Node()); item = item->Next(), index++) {
|
for (; !item->IsLast(Node()); item = item->Next(), index++) {
|
||||||
// should not remove those
|
// should not remove those
|
||||||
@ -408,7 +408,7 @@ Inode::RemoveSmallData(Transaction *transaction, const char *name)
|
|||||||
|
|
||||||
// search for the small_data item
|
// search for the small_data item
|
||||||
|
|
||||||
small_data *item = Node()->small_data_start;
|
small_data *item = Node()->SmallDataStart();
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
||||||
item = item->Next();
|
item = item->Next();
|
||||||
@ -449,7 +449,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type,
|
|||||||
|
|
||||||
SimpleLocker locker(fSmallDataLock);
|
SimpleLocker locker(fSmallDataLock);
|
||||||
|
|
||||||
small_data *item = Node()->small_data_start;
|
small_data *item = Node()->SmallDataStart();
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
||||||
item = item->Next();
|
item = item->Next();
|
||||||
@ -480,7 +480,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type,
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// reset our pointers
|
// reset our pointers
|
||||||
item = Node()->small_data_start;
|
item = Node()->SmallDataStart();
|
||||||
index = 0;
|
index = 0;
|
||||||
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
while (!item->IsLast(Node()) && strcmp(item->Name(), name)) {
|
||||||
item = item->Next();
|
item = item->Next();
|
||||||
@ -531,7 +531,7 @@ Inode::AddSmallData(Transaction *transaction, const char *name, uint32 type,
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// get new last item!
|
// get new last item!
|
||||||
item = Node()->small_data_start;
|
item = Node()->SmallDataStart();
|
||||||
index = 0;
|
index = 0;
|
||||||
while (!item->IsLast(Node())) {
|
while (!item->IsLast(Node())) {
|
||||||
item = item->Next();
|
item = item->Next();
|
||||||
@ -584,7 +584,7 @@ Inode::GetNextSmallData(small_data **_smallData) const
|
|||||||
|
|
||||||
// begin from the start?
|
// begin from the start?
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
data = Node()->small_data_start;
|
data = Node()->SmallDataStart();
|
||||||
else
|
else
|
||||||
data = data->Next();
|
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
|
// read attributes out of the small data section
|
||||||
|
|
||||||
if (fCurrentSmallData >= 0) {
|
if (fCurrentSmallData >= 0) {
|
||||||
small_data *item = fInode->Node()->small_data_start;
|
small_data *item = fInode->Node()->SmallDataStart();
|
||||||
|
|
||||||
fInode->SmallDataLock().Lock();
|
fInode->SmallDataLock().Lock();
|
||||||
|
|
||||||
|
@ -133,11 +133,8 @@ struct small_data {
|
|||||||
uint32 type;
|
uint32 type;
|
||||||
uint16 name_size;
|
uint16 name_size;
|
||||||
uint16 data_size;
|
uint16 data_size;
|
||||||
|
|
||||||
#if __MWERKS__
|
#if !__MWERKS__ //-- mwcc doesn't support thingy[0], so we patch Name() instead
|
||||||
char name[1]; // name_size long, followed by data
|
|
||||||
// ToDo: this is bad and breaks the code
|
|
||||||
#else
|
|
||||||
char name[0]; // name_size long, followed by data
|
char name[0]; // name_size long, followed by data
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -186,13 +183,18 @@ struct bfs_inode {
|
|||||||
};
|
};
|
||||||
int32 pad[4];
|
int32 pad[4];
|
||||||
|
|
||||||
#if __MWERKS__
|
#if !__MWERKS__
|
||||||
small_data small_data_start[1];
|
|
||||||
// ToDo: this reduces the space you have in an inode for attributes
|
|
||||||
#else
|
|
||||||
small_data small_data_start[0];
|
small_data small_data_start[0];
|
||||||
#endif
|
#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 Magic1() const { return BFS_ENDIAN_TO_HOST_INT32(magic1); }
|
||||||
int32 UserID() const { return BFS_ENDIAN_TO_HOST_INT32(uid); }
|
int32 UserID() const { return BFS_ENDIAN_TO_HOST_INT32(uid); }
|
||||||
int32 GroupID() const { return BFS_ENDIAN_TO_HOST_INT32(gid); }
|
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 *
|
inline char *
|
||||||
small_data::Name() const
|
small_data::Name() const
|
||||||
{
|
{
|
||||||
|
#if __MWERKS__
|
||||||
|
return (char *)(uint32(&data_size)+uint32(sizeof(data_size)));
|
||||||
|
#else
|
||||||
return const_cast<char *>(name);
|
return const_cast<char *>(name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint8 *
|
inline uint8 *
|
||||||
small_data::Data() const
|
small_data::Data() const
|
||||||
{
|
{
|
||||||
return (uint8 *)name + NameSize() + 3;
|
return (uint8 *)Name() + NameSize() + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user