1 #ifndef __XFS_COMPAT_H__
2 #define __XFS_COMPAT_H__
5 #include <sys/libkern.h>
6 #include <sys/limits.h>
11 #include <sys/ioccom.h>
12 #include <sys/fcntl.h>
13 #include <sys/dirent.h>
23 #define MAJOR(x) major(x)
24 #define MINOR(x) minor(x)
27 * SYSV compatibility types missing in FreeBSD.
29 typedef unsigned long ulong;
30 typedef unsigned int uint;
31 typedef unsigned short ushort;
34 * Additional type declarations for XFS.
36 typedef signed char __s8;
37 typedef unsigned char __u8;
38 typedef signed short int __s16;
39 typedef unsigned short int __u16;
40 typedef signed int __s32;
41 typedef unsigned int __u32;
42 typedef signed long long int __s64;
43 typedef unsigned long long int __u64;
45 /* linus now has sparse which expects big endian or little endian */
51 * Linux types with direct FreeBSD conterparts
54 typedef struct timespec timespec_t;
55 typedef struct uuid uuid_t;
56 typedef struct fid fid_t;
57 typedef dev_t os_dev_t;
60 * Linux block devices are device vnodes in FreeBSD.
62 #define block_device vnode
65 * Get the current CPU ID.
67 #define smp_processor_id() PCPU_GET(cpuid)
70 * FreeBSD does not have BITS_PER_LONG defined.
73 #define BITS_PER_LONG LONG_BIT
74 #elif defined(__i386__)
75 #define BITS_PER_LONG 32
78 #define rol32(x, y) (((x)<<(y))|((x)>>(32-(y))))
80 * boolean_t is enum on Linux, int on FreeBSD.
81 * Provide value defines.
87 * GCC 3.x static branch prediction hints
90 #define __builtin_expect(x, expected_value) (x)
94 #define likely(x) __builtin_expect((x), 1)
98 #define unlikely(x) __builtin_expect((x), 0)
102 * ANSI and GCC extension keywords compatibity
105 #define inline __inline__
113 #define typeof __typeof
117 * Miscellaneous limit constants
119 #define MAX_LFS_FILESIZE 0x7fffffffffffffffLL
122 * Map simple functions to their FreeBSD kernel equivalents
125 #define copy_to_user(dst, src, len) copyout((src), (dst), (len))
128 #ifndef copy_from_user
129 #define copy_from_user(dst, src, len) copyin((src), (dst), (len))
133 * Map simple global vairables to FreeBSD kernel equivalents
135 #if !defined(xfs_physmem)
136 #define xfs_physmem physmem
144 * These should be implemented properly for all architectures
145 * we want to support.
147 #define get_unaligned(ptr) (*(ptr))
148 #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
151 * Linux type-safe min/max macros.
153 #define min_t(type,x,y) MIN((x),(y))
154 #define max_t(type,x,y) MAX((x),(y))
157 typedef struct mtx xfs_mutex_t;
159 * Cedentials manipulation.
161 #define current_fsuid(credp) (credp)->cr_uid
162 #define current_fsgid(credp) (credp)->cr_groups[0]
164 #define PAGE_CACHE_SIZE PAGE_SIZE
166 #define IS_ERR(err) (err)
168 static inline unsigned long ffz(unsigned long val)
173 #endif /* __XFS_COMPAT_H__ */