Bunches of changes to make mwcc like the code. I also coded an _atomic_set() and _atomic_test_and_set() for PowerPC. Of course, there's already one in the kernel tree, but mine's better. :P Now builds (and works, after a fashion) on R5 PowerPC.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5280 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Nathan Whitehorn 2003-11-08 04:39:58 +00:00
parent 36c3931c38
commit 1a49a0986b
14 changed files with 110 additions and 26 deletions

View File

@ -1690,7 +1690,11 @@ TreeIterator::Goto(int8 to)
nodeOffset = nextOffset;
}
FATAL(("%s fails\n",__PRETTY_FUNCTION__));
#if __MWERKS__
FATAL(("TreeIterator::Goto(int8 to) fails\n"));
#else
FATAL(("%s fails\n",__PRETTY_FUNCTION__));
#endif
RETURN_ERROR(B_ERROR);
}

View File

@ -14,6 +14,8 @@
#include "Journal.h"
#include "Chain.h"
#include <string.h>
//****************** on-disk structures ********************

View File

@ -14,6 +14,8 @@
#include "Stack.h"
#include "bfs_control.h"
#include <malloc.h>
#ifdef USER
# define spawn_kernel_thread spawn_thread
#endif

View File

@ -239,4 +239,3 @@ dump_bplustree_node(bplustree_node *node,bplustree_header *header,Volume *volume
}
}
}

View File

@ -297,7 +297,7 @@ CachedBlock::CachedBlock(Volume *volume)
inline
CachedBlock::CachedBlock(Volume *volume, off_t block, bool empty = false)
CachedBlock::CachedBlock(Volume *volume, off_t block, bool empty)
:
fVolume(volume),
fBlock(NULL)
@ -307,7 +307,7 @@ CachedBlock::CachedBlock(Volume *volume, off_t block, bool empty = false)
inline
CachedBlock::CachedBlock(Volume *volume, block_run run, bool empty = false)
CachedBlock::CachedBlock(Volume *volume, block_run run, bool empty)
:
fVolume(volume),
fBlock(NULL)
@ -350,7 +350,7 @@ CachedBlock::Unset()
inline uint8 *
CachedBlock::SetTo(off_t block, bool empty = false)
CachedBlock::SetTo(off_t block, bool empty)
{
Unset();
fBlockNumber = block;
@ -360,7 +360,7 @@ CachedBlock::SetTo(off_t block, bool empty = false)
inline uint8 *
CachedBlock::SetTo(block_run run, bool empty = false)
CachedBlock::SetTo(block_run run, bool empty)
{
return SetTo(fVolume->ToBlock(run), empty);
}

View File

@ -5,10 +5,10 @@
*/
#include "cpp.h"
#include "Journal.h"
#include "Inode.h"
#include "Debug.h"
#include "cpp.h"
Journal::Journal(Volume *volume)

View File

@ -10,6 +10,7 @@
#include <KernelExport.h>
#include <stdio.h>
#include "Utility.h"
#include "Debug.h"
@ -157,8 +158,15 @@ class RecursiveLock {
status_t Unlock()
{
thread_id thread = find_thread(NULL);
if (thread != fOwner)
panic("RecursiveLock unlocked by %ld, owned by %ld\n", thread, fOwner);
if (thread != fOwner) {
#if __MWERKS__ && !USER //--- The R5 PowerPC kernel doesn't have panic()
char blip[255];
sprintf(blip,"RecursiveLock unlocked by %ld, owned by %ld\n", thread, fOwner);
kernel_debugger(blip);
#else
panic("RecursiveLock unlocked by %ld, owned by %ld\n", thread, fOwner);
#endif
}
if (--fOwnerCount == 0) {
fOwner = -1;
@ -457,10 +465,17 @@ class SimpleLock {
{
int32 thisThread = find_thread(NULL);
int32 current;
while ((current = _atomic_test_and_set(&fHolder, thisThread, -1)) != -1) {
while (1) {
/*if (fHolder == -1) {
current = fHolder;
fHolder = thisThread;
}*/
current = _atomic_test_and_set(&fHolder, thisThread, -1);
if (current == -1)
break;
if (current == thisThread)
break;
snooze(time);
}

View File

@ -1321,13 +1321,13 @@ Expression::ParseEquation(char **expr)
{
skipWhitespace(expr);
bool not = false;
bool _not = false;
if (**expr == '!') {
skipWhitespace(expr, 1);
if (**expr != '(')
return NULL;
not = true;
_not = true;
}
if (**expr == ')') {
@ -1347,7 +1347,7 @@ Expression::ParseEquation(char **expr)
// If the term is negated, we just complement the tree, to get
// rid of the not, a.k.a. DeMorgan's Law.
if (not)
if (_not)
term->Complement();
skipWhitespace(expr, 1);

View File

@ -77,7 +77,7 @@ Uncached::Uncached(Volume *volume)
}
Uncached::Uncached(Volume *volume,off_t block, bool empty = false)
Uncached::Uncached(Volume *volume,off_t block, bool empty)
:
fVolume(volume),
fBlock(NULL)
@ -86,7 +86,7 @@ Uncached::Uncached(Volume *volume,off_t block, bool empty = false)
}
Uncached::Uncached(Volume *volume,block_run run,bool empty = false)
Uncached::Uncached(Volume *volume,block_run run,bool empty)
:
fVolume(volume),
fBlock(NULL)
@ -110,7 +110,7 @@ Uncached::Unset()
uint8 *
Uncached::SetTo(off_t block, bool empty = false)
Uncached::SetTo(off_t block, bool empty)
{
Unset();
fBlockNumber = block;
@ -127,7 +127,7 @@ Uncached::SetTo(off_t block, bool empty = false)
uint8 *
Uncached::SetTo(block_run run, bool empty = false)
Uncached::SetTo(block_run run, bool empty)
{
return SetTo(fVolume->ToBlock(run), empty);
}
@ -166,13 +166,13 @@ Cached::Cached(Volume *volume)
}
Cached::Cached(Volume *volume,off_t block,bool empty = false)
Cached::Cached(Volume *volume,off_t block,bool empty)
: CachedBlock(volume, block, empty)
{
}
Cached::Cached(Volume *volume,block_run run,bool empty = false)
Cached::Cached(Volume *volume,block_run run,bool empty)
: CachedBlock(volume, run, empty)
{
}
@ -211,13 +211,13 @@ Logged::Logged(Volume *volume)
}
Logged::Logged(Volume *volume, off_t block, bool empty = false)
Logged::Logged(Volume *volume, off_t block, bool empty)
: CachedBlock(volume, block, empty)
{
}
Logged::Logged(Volume *volume, block_run run, bool empty = false)
Logged::Logged(Volume *volume, block_run run, bool empty)
: CachedBlock(volume, run, empty)
{
}

View File

@ -16,7 +16,12 @@
struct sorted_array {
public:
off_t count;
off_t values[0];
#if __MWERKS__
off_t values[1];
#else
off_t values[0];
#endif
inline int32 Find(off_t value) const;
void Insert(off_t value);
@ -149,6 +154,42 @@ template<class Node> struct list {
asm volatile("lock; xchg %%eax, (%%edx)"
: : "a" (newValue), "d" (value));
}
#elif __POWERPC__ && __MWERKS__ /* GCC has different assembler syntax */
inline asm int32
_atomic_set(volatile int32 *value, int32)
{
loop:
dcbf r0, r3;
lwarx r0, 0, r3;
stwcx. r4, 0, r3;
bc 5, 2, loop
mr r3,r5;
isync;
blr;
}
inline asm int32
_atomic_test_and_set(volatile int32 *value, int32 newValue, int32 testAgainst)
{
loop:
dcbf r0, r3;
lwarx r0, 0, r3;
cmpw r5, r0;
bne no_dice;
stwcx. r4, 0, r3;
bc 5, 2, loop
mr r3,r0;
isync;
blr;
no_dice:
stwcx. r0, 0, r3;
mr r3,r0;
isync;
blr;
}
#else
# error The macros _atomic_set(), and _atomic_test_and_set() are not defined for the target processor
#endif

View File

@ -20,7 +20,6 @@
#include <string.h>
#include <ctype.h>
Volume::Volume(nspace_id id)
:
fID(id),

View File

@ -133,7 +133,12 @@ struct small_data {
uint32 type;
uint16 name_size;
uint16 data_size;
char name[0]; // name_size long, followed by data
#if __MWERKS__
char name[1]; // name_size long, followed by data
#else
char name[0]; // name_size long, followed by data
#endif
uint32 Type() const { return BFS_ENDIAN_TO_HOST_INT32(type); }
uint16 NameSize() const { return BFS_ENDIAN_TO_HOST_INT16(name_size); }
@ -179,7 +184,7 @@ struct bfs_inode {
char short_symlink[SHORT_SYMLINK_NAME_LENGTH];
};
int32 pad[4];
small_data small_data_start[0];
small_data small_data_start[1];
int32 Magic1() const { return BFS_ENDIAN_TO_HOST_INT32(magic1); }
int32 UserID() const { return BFS_ENDIAN_TO_HOST_INT32(uid); }

View File

@ -14,3 +14,16 @@ __pure_virtual()
//printf("pure virtual function call");
}
#if __MWERKS__
//--- These functions are supposed to throw exceptions. Obviously, we don't want them to.
extern "C" void __destroy_new_array( void *, int) {
//printf("__destroy_new_array called");
}
extern "C" void __construct_new_array( void *, int) {
//printf("__construct_new_array called");
}
#endif

View File

@ -30,6 +30,10 @@ struct mlock {
extern _IMPEXP_KERNEL int new_lock(lock *l, const char *name);
extern _IMPEXP_KERNEL int free_lock(lock *l);
#ifdef LOCK
#undef LOCK
#endif
#define LOCK(l) if (atomic_add(&l.c, -1) <= 0) acquire_sem(l.s);
#define UNLOCK(l) if (atomic_add(&l.c, 1) < 0) release_sem(l.s);