From bc197380a53a2a3ef10300a48c1482cfc9c1faf7 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sun, 12 Apr 2009 14:25:07 +0800 Subject: [PATCH] Put lwkt_serialize_array_{enter,try,exit}() into its own header file; name it sys/serialize2.h according to our convention. --- sys/dev/netif/emx/if_emx.c | 1 + sys/sys/serialize.h | 44 ------------------------------------- sys/sys/serialize2.h | 52 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 sys/sys/serialize2.h diff --git a/sys/dev/netif/emx/if_emx.c b/sys/dev/netif/emx/if_emx.c index ea2aaed..728b8e1 100644 --- a/sys/dev/netif/emx/if_emx.c +++ b/sys/dev/netif/emx/if_emx.c @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/sys/serialize.h b/sys/sys/serialize.h index 073258c..b179de2 100644 --- a/sys/sys/serialize.h +++ b/sys/sys/serialize.h @@ -14,18 +14,6 @@ #ifndef _SYS_SERIALIZE_H_ #define _SYS_SERIALIZE_H_ -#ifndef _KERNEL -#error "kernel only header file" -#endif - -#ifndef _SYS_PARAM_H_ -#include -#endif - -#ifndef _SYS_SYSTM_H_ -#include -#endif - #ifndef _MACHINE_STDINT_H_ #include #endif @@ -66,36 +54,4 @@ void lwkt_serialize_handler_enable(lwkt_serialize_t); void lwkt_serialize_handler_call(lwkt_serialize_t, void (*)(void *, void *), void *, void *); int lwkt_serialize_handler_try(lwkt_serialize_t, void (*)(void *, void *), void *, void *); -static __inline void -lwkt_serialize_array_enter(lwkt_serialize_t *_arr, int _arrcnt, int _s) -{ - KASSERT(_s < _arrcnt, ("nothing to be serialized\n")); - while (_s < _arrcnt) - lwkt_serialize_enter(_arr[_s++]); -} - -static __inline int -lwkt_serialize_array_try(lwkt_serialize_t *_arr, int _arrcnt, int _s) -{ - int _i; - - KASSERT(_s < _arrcnt, ("nothing to be serialized\n")); - for (_i = _s; _i < _arrcnt; ++_i) { - if (!lwkt_serialize_try(_arr[_i])) { - while (--_i >= _s) - lwkt_serialize_exit(_arr[_i]); - return 0; - } - } - return 1; -} - -static __inline void -lwkt_serialize_array_exit(lwkt_serialize_t *_arr, int _arrcnt, int _s) -{ - KASSERT(_arrcnt > _s, ("nothing to be deserialized\n")); - while (--_arrcnt >= _s) - lwkt_serialize_exit(_arr[_arrcnt]); -} - #endif /* !_SYS_SERIALIZE_H_ */ diff --git a/sys/sys/serialize2.h b/sys/sys/serialize2.h new file mode 100644 index 0000000..fb839c9 --- /dev/null +++ b/sys/sys/serialize2.h @@ -0,0 +1,52 @@ +#ifndef _SYS_SERIALIZE2_H_ +#define _SYS_SERIALIZE2_H_ + +#ifndef _KERNEL +#error "kernel only header file" +#endif + +#ifndef _SYS_PARAM_H_ +#include +#endif + +#ifndef _SYS_SYSTM_H_ +#include +#endif + +#ifndef _SYS_SERIALIZE_H_ +#include +#endif + +static __inline void +lwkt_serialize_array_enter(lwkt_serialize_t *_arr, int _arrcnt, int _s) +{ + KASSERT(_s < _arrcnt, ("nothing to be serialized\n")); + while (_s < _arrcnt) + lwkt_serialize_enter(_arr[_s++]); +} + +static __inline int +lwkt_serialize_array_try(lwkt_serialize_t *_arr, int _arrcnt, int _s) +{ + int _i; + + KASSERT(_s < _arrcnt, ("nothing to be serialized\n")); + for (_i = _s; _i < _arrcnt; ++_i) { + if (!lwkt_serialize_try(_arr[_i])) { + while (--_i >= _s) + lwkt_serialize_exit(_arr[_i]); + return 0; + } + } + return 1; +} + +static __inline void +lwkt_serialize_array_exit(lwkt_serialize_t *_arr, int _arrcnt, int _s) +{ + KASSERT(_arrcnt > _s, ("nothing to be deserialized\n")); + while (--_arrcnt >= _s) + lwkt_serialize_exit(_arr[_arrcnt]); +} + +#endif /* !_SYS_SERIALIZE2_H_ */ -- 1.7.7.2