Added dumb implementations for system_time() and TLS: system_time() currently
just returns the contents of the time base register, and the TLS implementation is only working correctly for single threaded applications. Enough for testing, at least. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3202 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,15 +2,14 @@ SubDir OBOS_TOP src kernel libroot os arch ppc ;
|
|||||||
|
|
||||||
KernelMergeObject os_arch_$(OBOS_ARCH).o :
|
KernelMergeObject os_arch_$(OBOS_ARCH).o :
|
||||||
<$(SOURCE_GRIST)>atomic.S
|
<$(SOURCE_GRIST)>atomic.S
|
||||||
# <$(SOURCE_GRIST)>cpuid.S
|
|
||||||
# <$(SOURCE_GRIST)>systeminfo.c
|
# <$(SOURCE_GRIST)>systeminfo.c
|
||||||
# <$(SOURCE_GRIST)>thread.c
|
<$(SOURCE_GRIST)>system_time.S
|
||||||
# <$(SOURCE_GRIST)>tls.c
|
<$(SOURCE_GRIST)>tls.c
|
||||||
:
|
:
|
||||||
-fPIC -DPIC
|
-fPIC -DPIC
|
||||||
;
|
;
|
||||||
|
|
||||||
MergeObjectFromObjects kernel_os_arch_$(OBOS_ARCH).o :
|
MergeObjectFromObjects kernel_os_arch_$(OBOS_ARCH).o :
|
||||||
<$(SOURCE_GRIST)>atomic.o
|
<$(SOURCE_GRIST)>atomic.o
|
||||||
#<$(SOURCE_GRIST)>cpuid.o
|
<$(SOURCE_GRIST)>system_time.S
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define FUNCTION(x) .global x; .type x,@function; x
|
||||||
|
|
||||||
|
.text
|
||||||
|
|
||||||
|
// ToDo: note, this function absolutely doesn't do what it should do.
|
||||||
|
// It only reads out the time base register, but it doesn't compute
|
||||||
|
// the real system time from its value.
|
||||||
|
// To do so, the kernel has to provide the appropriate system dependent
|
||||||
|
// conversion factors.
|
||||||
|
|
||||||
|
/* uint64 system_time(void)
|
||||||
|
* r3/r4
|
||||||
|
*/
|
||||||
|
FUNCTION(system_time):
|
||||||
|
carry: mftbu %r3
|
||||||
|
mftb %r4
|
||||||
|
mftbu %r5 // read the upper half again
|
||||||
|
cmpw %r3, %r5 // and check if the values have changed
|
||||||
|
bne carry // try again, if they had
|
||||||
|
blr
|
||||||
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ToDo: this is a dummy implementation - I've not yet gained enough knowledge
|
||||||
|
// to decide how this should be done, so it's just broken now (okay for single
|
||||||
|
// threaded apps, though).
|
||||||
|
|
||||||
|
// we don't want to have the inline assembly included here
|
||||||
|
#ifndef _NO_INLINE_ASM
|
||||||
|
# define _NO_INLINE_ASM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "support/TLS.h"
|
||||||
|
#include "tls.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int32 gNextSlot = TLS_FIRST_FREE_SLOT;
|
||||||
|
static void *gSlots[TLS_MAX_KEYS];
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
tls_allocate(void)
|
||||||
|
{
|
||||||
|
int32 next = atomic_add(&gNextSlot, 1);
|
||||||
|
if (next >= TLS_MAX_KEYS)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *
|
||||||
|
tls_get(int32 index)
|
||||||
|
{
|
||||||
|
return gSlots[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void **
|
||||||
|
tls_address(int32 index)
|
||||||
|
{
|
||||||
|
return &gSlots[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
tls_set(int32 index, void *value)
|
||||||
|
{
|
||||||
|
gSlots[index] = value;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user