ia64/linux-2.6.18-xen.hg

view fs/jffs2/pushpull.h @ 524:7f8b544237bf

netfront: Allow netfront in domain 0.

This is useful if your physical network device is in a utility domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 15 15:18:58 2008 +0100 (2008-04-15)
parents 831230e53067
children
line source
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
4 * Copyright (C) 2001, 2002 Red Hat, Inc.
5 *
6 * Created by David Woodhouse <dwmw2@infradead.org>
7 *
8 * For licensing information, see the file 'LICENCE' in this directory.
9 *
10 * $Id: pushpull.h,v 1.10 2004/11/16 20:36:11 dwmw2 Exp $
11 *
12 */
14 #ifndef __PUSHPULL_H__
15 #define __PUSHPULL_H__
17 #include <linux/errno.h>
19 struct pushpull {
20 unsigned char *buf;
21 unsigned int buflen;
22 unsigned int ofs;
23 unsigned int reserve;
24 };
27 static inline void init_pushpull(struct pushpull *pp, char *buf, unsigned buflen, unsigned ofs, unsigned reserve)
28 {
29 pp->buf = buf;
30 pp->buflen = buflen;
31 pp->ofs = ofs;
32 pp->reserve = reserve;
33 }
35 static inline int pushbit(struct pushpull *pp, int bit, int use_reserved)
36 {
37 if (pp->ofs >= pp->buflen - (use_reserved?0:pp->reserve)) {
38 return -ENOSPC;
39 }
41 if (bit) {
42 pp->buf[pp->ofs >> 3] |= (1<<(7-(pp->ofs &7)));
43 }
44 else {
45 pp->buf[pp->ofs >> 3] &= ~(1<<(7-(pp->ofs &7)));
46 }
47 pp->ofs++;
49 return 0;
50 }
52 static inline int pushedbits(struct pushpull *pp)
53 {
54 return pp->ofs;
55 }
57 static inline int pullbit(struct pushpull *pp)
58 {
59 int bit;
61 bit = (pp->buf[pp->ofs >> 3] >> (7-(pp->ofs & 7))) & 1;
63 pp->ofs++;
64 return bit;
65 }
67 static inline int pulledbits(struct pushpull *pp)
68 {
69 return pp->ofs;
70 }
72 #endif /* __PUSHPULL_H__ */