📄 compatmac.h
字号:
static inline int try_inc_mod_count(struct module *mod){#ifdef CONFIG_MODULES if (mod) __MOD_INC_USE_COUNT(mod);#endif return 1;}#endif/* Yes, I'm aware that it's a fairly ugly hack. Until the __constant_* macros appear in Linus' own kernels, this is the way it has to be done. DW 19/1/00 */#include <asm/byteorder.h>#ifndef __constant_cpu_to_le16#ifdef __BIG_ENDIAN#define __constant_cpu_to_le64(x) ___swab64((x))#define __constant_le64_to_cpu(x) ___swab64((x))#define __constant_cpu_to_le32(x) ___swab32((x))#define __constant_le32_to_cpu(x) ___swab32((x))#define __constant_cpu_to_le16(x) ___swab16((x))#define __constant_le16_to_cpu(x) ___swab16((x))#define __constant_cpu_to_be64(x) ((__u64)(x))#define __constant_be64_to_cpu(x) ((__u64)(x))#define __constant_cpu_to_be32(x) ((__u32)(x))#define __constant_be32_to_cpu(x) ((__u32)(x))#define __constant_cpu_to_be16(x) ((__u16)(x))#define __constant_be16_to_cpu(x) ((__u16)(x))#else#ifdef __LITTLE_ENDIAN#define __constant_cpu_to_le64(x) ((__u64)(x))#define __constant_le64_to_cpu(x) ((__u64)(x))#define __constant_cpu_to_le32(x) ((__u32)(x))#define __constant_le32_to_cpu(x) ((__u32)(x))#define __constant_cpu_to_le16(x) ((__u16)(x))#define __constant_le16_to_cpu(x) ((__u16)(x))#define __constant_cpu_to_be64(x) ___swab64((x))#define __constant_be64_to_cpu(x) ___swab64((x))#define __constant_cpu_to_be32(x) ___swab32((x))#define __constant_be32_to_cpu(x) ___swab32((x))#define __constant_cpu_to_be16(x) ___swab16((x))#define __constant_be16_to_cpu(x) ___swab16((x))#else#error No (recognised) endianness defined (unless it,s PDP)#endif /* __LITTLE_ENDIAN */#endif /* __BIG_ENDIAN */#endif /* ifndef __constant_cpu_to_le16 */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) #define mod_init_t int __init #define mod_exit_t void #else #define mod_init_t static int __init #define mod_exit_t static void __exit#endif#ifndef THIS_MODULE#ifdef MODULE#define THIS_MODULE (&__this_module)#else#define THIS_MODULE (NULL)#endif#endif#if LINUX_VERSION_CODE < 0x20300#include <linux/interrupt.h>#define spin_lock_bh(lock) do {start_bh_atomic();spin_lock(lock);}while(0)#define spin_unlock_bh(lock) do {spin_unlock(lock);end_bh_atomic();}while(0)#else#include <asm/softirq.h>#include <linux/spinlock.h>#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)#define set_current_state(state_value) \ do { current->state = (state_value); } while (0)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0) static inline int invalidate_device(kdev_t dev, int do_sync) { if (do_sync) fsync_dev(dev); invalidate_buffers(dev); return 0;}#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5)static inline int invalidate_device(kdev_t dev, int do_sync) { struct super_block *sb = get_super(dev); int res = 0; if (do_sync) fsync_dev(dev); if (sb) res = invalidate_inodes(sb); invalidate_buffers(dev); return res;}#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)#undef min#undef max#undef min_t#undef max_t/* * min()/max() macros that also do * strict type-checking.. See the * "unnecessary" pointer comparison. */#define min(x,y) ({ \ const typeof(x) _x = (x); \ const typeof(y) _y = (y); \ (void) (&_x == &_y); \ _x < _y ? _x : _y; })#define max(x,y) ({ \ const typeof(x) _x = (x); \ const typeof(y) _y = (y); \ (void) (&_x == &_y); \ _x > _y ? _x : _y; })/* * ..and if you can't take the strict * types, you can specify one yourself. * * Or not use min/max at all, of course. */#define min_t(type,x,y) \ ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })#define max_t(type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,7)struct completion { struct semaphore s;};#define complete(c) up(&(c)->s)#define wait_for_completion(c) down(&(c)->s)#define init_completion(c) init_MUTEX_LOCKED(&(c)->s);#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9)/* This came later */#define complete_and_exit(c, r) do { complete(c); do_exit(r); } while(0)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9) || \ (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) && !defined(__rh_config_h__))#include <linux/genhd.h>static inline void add_gendisk(struct gendisk *gp){ gp->next = gendisk_head; gendisk_head = gp;}static inline void del_gendisk(struct gendisk *gp){ struct gendisk *gd, **gdp; for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next)) if (*gdp == gp) { gd = *gdp; *gdp = gd->next; break; }}#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18) && defined(MODULE)#define module_init(func) \mod_init_t init_module(void) { \ return func(); \}#define module_exit(func) \mod_exit_t cleanup_module(void) { \ return func(); \}#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9) || \ (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) && !defined(__rh_config_h__))#define MODULE_LICENSE(x) /* */#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,5)#include <linux/sched.h>static inline void __recalc_sigpending(void){ recalc_sigpending(current);}#define recalc_sigpending() __recalc_sigpending ()#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,5)#define parent_ino(d) ((d)->d_parent->d_inode->i_ino)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,3)#define need_resched() (current->need_resched)#define cond_resched() do { if need_resched() schedule(); } while(0)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)#define yield() do { current->policy |= SCHED_YIELD; schedule(); } while(0)#ifndef major#define major(d) (MAJOR(to_kdev_t(d)))#endif#ifndef minor#define minor(d) (MINOR(to_kdev_t(d)))#endif#define mk_kdev(ma,mi) MKDEV(ma,mi)#define kdev_t_to_nr(x) (x)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) /* Is this right? */#define set_user_nice(tsk, n) do { (tsk)->priority = 20-(n); } while(0) #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)#define set_user_nice(tsk, n) do { (tsk)->nice = n; } while(0)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)#define rq_data_dir(x) ((x)->cmd)#define IS_REQ_CMD(req) (1)#define QUEUE_LOCK(q) (&io_request_lock)#define BLK_INIT_QUEUE(q, req, lock) blk_init_queue((q), (req)) #else /* > 2.5.0 */#define IS_REQ_CMD(req) ((req)->flags & REQ_CMD)#define QUEUE_LOCK(q) ((q)->queue_lock)#define BLK_INIT_QUEUE(q, req, lock) blk_init_queue((q), (req), (lock)) #endif/* Removed cos it broke stuff. Where is this required anyway? * #ifndef QUEUE_EMPTY * #define QUEUE_EMPTY (!CURRENT) * #endif */#if LINUX_VERSION_CODE < 0x20300#define QUEUE_PLUGGED (blk_dev[MAJOR_NR].plug_tq.sync)#elif LINUX_VERSION_CODE < 0x20500 //FIXME (Si)#define QUEUE_PLUGGED (blk_dev[MAJOR_NR].request_queue.plugged)#else#define QUEUE_PLUGGED (blk_queue_plugged(QUEUE))#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,14)#define BLK_INC_USE_COUNT MOD_INC_USE_COUNT#define BLK_DEC_USE_COUNT MOD_DEC_USE_COUNT#else#define BLK_INC_USE_COUNT do {} while(0)#define BLK_DEC_USE_COUNT do {} while(0)#endif#endif /* __LINUX_MTD_COMPATMAC_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -