freebsd11_network: Add mtx_trylock() and curcpu.
These are needed for the "non-legacy" TX path in ipro1000. Also remove the "spinlock" member from struct mtx; struct mtx_spin is different (and not implemented by us presently.)
This commit is contained in:
parent
6f3f2e141c
commit
94064605f5
@ -41,6 +41,7 @@ KernelStaticLibrary libfreebsd11_network.a :
|
||||
mbuf.c
|
||||
mii.c
|
||||
mutex.c
|
||||
pcpu.cpp
|
||||
priv.cpp
|
||||
smp.c
|
||||
subr_autoconf.cpp
|
||||
|
@ -17,7 +17,6 @@ struct mtx {
|
||||
mutex lock;
|
||||
thread_id owner;
|
||||
} mutex;
|
||||
int32 spinlock;
|
||||
recursive_lock recursive;
|
||||
} u;
|
||||
};
|
||||
|
@ -54,6 +54,22 @@ mtx_lock(struct mtx* mutex)
|
||||
}
|
||||
|
||||
|
||||
static inline int
|
||||
mtx_trylock(struct mtx* mutex)
|
||||
{
|
||||
if (mutex->type == MTX_DEF) {
|
||||
if (mutex_trylock(&mutex->u.mutex.lock) != B_OK)
|
||||
return 0;
|
||||
mutex->u.mutex.owner = find_thread(NULL);
|
||||
return 1;
|
||||
} else if (mutex->type == MTX_RECURSE) {
|
||||
if (recursive_lock_trylock(&mutex->u.recursive) != B_OK)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
mtx_unlock(struct mtx* mutex)
|
||||
{
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
|
||||
struct thread;
|
||||
int get_curcpu();
|
||||
|
||||
#define curcpu (get_curcpu())
|
||||
#define curthread ((struct thread*)NULL)
|
||||
/* NOTE: Dereferencing curthread will crash, which is intentional. There is
|
||||
no FreeBSD compatible struct thread and Haiku's should not be used as it
|
||||
|
18
src/libs/compat/freebsd11_network/pcpu.cpp
Normal file
18
src/libs/compat/freebsd11_network/pcpu.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2018, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <OS.h>
|
||||
#include <smp.h>
|
||||
|
||||
extern "C" {
|
||||
#include <compat/sys/pcpu.h>
|
||||
};
|
||||
|
||||
|
||||
int32_t
|
||||
get_curcpu()
|
||||
{
|
||||
return smp_get_current_cpu();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user