2 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Joerg Sonnenberger <joerg@bec.de>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/i386/include/Attic/gencount.h,v 1.1 2004/12/08 23:19:51 joerg Exp $
37 #ifndef _MACHINE_GENCOUNT_H
38 #define _MACHINE_GENCOUNT_H
41 #error "no user-servicable parts inside"
44 #include <sys/types.h>
45 #include <sys/thread2.h>
51 /* not interrupt-safe */
53 gencount_init(gencount_t *gencnt)
61 gencount_inc(gencount_t *gencnt)
64 if (++gencnt->high == 0)
70 static __inline gencount_t
71 gencount_get(gencount_t *gencnt)
73 volatile gencount_t *vgencnt;
77 ret.low = vgencnt->low;
78 ret.high = vgencnt->high;
79 if (ret.low != vgencnt->low) {
81 * Choose an arbitrary time between when we started
82 * and when we finished. Since blocking can occur
83 * at any time, this has to be save.
92 /* not interrupt-safe */
94 gencount_cmp(gencount_t *gencnt1, gencount_t *gencnt2)
96 if (gencnt1->low > gencnt2->low)
98 else if (gencnt1->low < gencnt1->low)
100 else if (gencnt1->high > gencnt2->high)
102 else if (gencnt1->high < gencnt2->high)