1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Basic library routines.
25 #ifndef __LIBCFS_DARWIN_XNU_TYPES_H__
26 #define __LIBCFS_DARWIN_XNU_TYPES_H__
28 #ifndef __LIBCFS_LIBCFS_H__
29 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
32 #include <mach/mach_types.h>
33 #include <sys/types.h>
35 typedef u_int8_t __u8;
36 typedef u_int16_t __u16;
37 typedef u_int32_t __u32;
38 typedef u_int64_t __u64;
42 #include <kern/kern_types.h>
45 typedef __signed__ int __s32;
48 typedef __signed__ long long __s64;
51 typedef struct { int e; } event_chan_t;
57 #include <libkern/OSAtomic.h>
59 typedef struct { volatile uint32_t counter; } atomic_t;
61 #define ATOMIC_INIT(i) { (i) }
62 #define atomic_read(a) ((a)->counter)
63 #define atomic_set(a, v) (((a)->counter) = (v))
64 #define atomic_add(v, a) hw_atomic_add((uint32_t *)&((a)->counter), v)
65 #define atomic_sub(v, a) hw_atomic_sub((uint32_t *)&((a)->counter), v)
66 #define atomic_inc(a) atomic_add(1, a)
67 #define atomic_dec(a) atomic_sub(1, a)
68 #define atomic_sub_and_test(v, a) ( atomic_sub(v, a) == 0 )
69 #define atomic_dec_and_test(a) ( atomic_dec(a) == 0 )
71 #include <libsa/mach/mach.h>
72 typedef uint64_t loff_t;
74 #else /* !__KERNEL__ */
78 typedef uint64_t loff_t;
80 #endif /* __KERNEL END */
82 #endif /* __XNU_CFS_TYPES_H__ */