linprocfs - Introduce /proc/mounts
[dragonfly.git] / sys / sys / serialize2.h
blobfb839c9727d25346e9bc881caf81523954fceec2
1 #ifndef _SYS_SERIALIZE2_H_
2 #define _SYS_SERIALIZE2_H_
4 #ifndef _KERNEL
5 #error "kernel only header file"
6 #endif
8 #ifndef _SYS_PARAM_H_
9 #include <sys/param.h>
10 #endif
12 #ifndef _SYS_SYSTM_H_
13 #include <sys/systm.h>
14 #endif
16 #ifndef _SYS_SERIALIZE_H_
17 #include <sys/serialize.h>
18 #endif
20 static __inline void
21 lwkt_serialize_array_enter(lwkt_serialize_t *_arr, int _arrcnt, int _s)
23 KASSERT(_s < _arrcnt, ("nothing to be serialized\n"));
24 while (_s < _arrcnt)
25 lwkt_serialize_enter(_arr[_s++]);
28 static __inline int
29 lwkt_serialize_array_try(lwkt_serialize_t *_arr, int _arrcnt, int _s)
31 int _i;
33 KASSERT(_s < _arrcnt, ("nothing to be serialized\n"));
34 for (_i = _s; _i < _arrcnt; ++_i) {
35 if (!lwkt_serialize_try(_arr[_i])) {
36 while (--_i >= _s)
37 lwkt_serialize_exit(_arr[_i]);
38 return 0;
41 return 1;
44 static __inline void
45 lwkt_serialize_array_exit(lwkt_serialize_t *_arr, int _arrcnt, int _s)
47 KASSERT(_arrcnt > _s, ("nothing to be deserialized\n"));
48 while (--_arrcnt >= _s)
49 lwkt_serialize_exit(_arr[_arrcnt]);
52 #endif /* !_SYS_SERIALIZE2_H_ */