2 * support.h - Useful definitions and macros. Originated from the Linux-NTFS project.
4 * Copyright (c) 2000-2004 Anton Altaparmakov
6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program/include file is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (in the main directory of the NTFS-3G
18 * distribution in the file COPYING); if not, write to the Free Software
19 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _NTFS_SUPPORT_H
23 #define _NTFS_SUPPORT_H
34 * Our mailing list. Use this define to prevent typos in email address.
36 #define NTFS_DEV_LIST "ntfs-3g-devel@lists.sf.net"
39 * Generic macro to convert pointers to values for comparison purposes.
42 #define p2n(p) ((ptrdiff_t)((ptrdiff_t*)(p)))
46 * The classic min and max macros.
49 #define min(a,b) ((a) <= (b) ? (a) : (b))
53 #define max(a,b) ((a) >= (b) ? (a) : (b))
57 * Useful macro for determining the offset of a struct member.
60 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
64 * Simple bit operation macros. NOTE: These are NOT atomic.
66 #define test_bit(bit, var) ((var) & (1 << (bit)))
67 #define set_bit(bit, var) (var) |= 1 << (bit)
68 #define clear_bit(bit, var) (var) &= ~(1 << (bit))
70 #define test_and_set_bit(bit, var) \
72 const BOOL old_state = test_bit(bit, var); \
77 #define test_and_clear_bit(bit, var) \
79 const BOOL old_state = test_bit(bit, var); \
80 clear_bit(bit, var); \
84 #endif /* defined _NTFS_SUPPORT_H */