diff --git a/bsd/porting/netport.h b/bsd/porting/netport.h index 57d9a04c93a4241ccd1b88099b64e072f753d43a..53d24482ea2fd786705ce7495fd955f10bc5c79e 100644 --- a/bsd/porting/netport.h +++ b/bsd/porting/netport.h @@ -130,12 +130,6 @@ extern int tick; #define ENOIOCTL (-3) /* ioctl not handled by this layer */ #define EDIRIOCTL (-4) /* do direct ioctl in GEOM */ -/* FIXME: TODO - Implement... */ -#define sx_slock(...) do{}while(0) -#define sx_sunlock(...) do{}while(0) -#define sx_xlock(...) do{}while(0) -#define sx_xunlock(...) do{}while(0) - /* FIXME: TODO - Implement... */ #ifndef time_uptime #define time_uptime (1) diff --git a/bsd/porting/sync_stub.c b/bsd/porting/sync_stub.c index 1ec73af3c3bd5c541305b60f5df6942894e45427..9f34a02f9b8ecab3c96888ec477e8d3aced2787a 100644 --- a/bsd/porting/sync_stub.c +++ b/bsd/porting/sync_stub.c @@ -1,4 +1,5 @@ #include <osv/mutex.h> +#include <osv/rwlock.h> #include <stdlib.h> #include <bsd/porting/sync_stub.h> @@ -40,3 +41,28 @@ void mtx_assert(struct mtx *mp, int flag) abort(); } } + +void sx_init(struct sx *s, const char *name) +{ + rwlock_init(&s->_rw); +} + +void sx_xlock(struct sx *s) +{ + rw_wlock(&s->_rw); +} + +void sx_xunlock(struct sx *s) +{ + rw_wunlock(&s->_rw); +} + +void sx_slock(struct sx *s) +{ + rw_wlock(&s->_rw); +} + +void sx_sunlock(struct sx *s) +{ + rw_runlock(&s->_rw); +} diff --git a/bsd/porting/sync_stub.h b/bsd/porting/sync_stub.h index 48c571337e568799407f00b9d1dc8c7ab59161c0..629be013984b2888f5b064a250f205d0f07c6629 100644 --- a/bsd/porting/sync_stub.h +++ b/bsd/porting/sync_stub.h @@ -22,6 +22,21 @@ void mtx_destroy(struct mtx *m); void mtx_lock(struct mtx *mp); void mtx_unlock(struct mtx *mp); void mtx_assert(struct mtx *mp, int flag); + +#ifndef __cplusplus +#include <osv/rwlock.h> +struct sx { + rwlock_t _rw; +}; + +void sx_init(struct sx *m, const char *name); +void sx_xlock(struct sx *mp); +void sx_xunlock(struct sx *mp); +void sx_slock(struct sx *mp); +void sx_sunlock(struct sx *mp); +#endif +#define sx_assert(...) do { } while (0) + __END_DECLS #define mtx_sleep(chan, mtx, pri, wmesg, timo) (void)0;