www.pudn.com > usbold11.rar > compat.h


/* for 2.2-kernels */
 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)

static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
{
	__list_add(new, head->prev, head);
}
#define LIST_HEAD_INIT(name) { &(name), &(name) }

typedef struct wait_queue wait_queue_t;

typedef struct wait_queue *wait_queue_head_t;
#define DECLARE_WAITQUEUE(wait, current) \
	struct wait_queue wait = { current, NULL }
#define DECLARE_WAIT_QUEUE_HEAD(wait)\
	wait_queue_head_t wait

#define init_waitqueue_head(x) *x=NULL
#define init_MUTEX(x) *(x)=MUTEX
#define DECLARE_MUTEX(name) struct semaphore name=MUTEX
#define DECLARE_MUTEX_LOCKED(name) struct semaphore name=MUTEX_LOCKED


#define __set_current_state(state_value)                        \
	do { current->state = state_value; } while (0)
#ifdef __SMP__
#define set_current_state(state_value)          \
	set_mb(current->state, state_value)
#else
#define set_current_state(state_value)          \
	__set_current_state(state_value)
#endif

#ifdef __alpha
extern long __kernel_thread(unsigned long, int (*)(void *), void *);
static inline long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
	return __kernel_thread(flags | CLONE_VM, fn, arg);
}
#undef CONFIG_APM
#endif

#define __init 
#define __exit

#endif // 2.2.x

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,34)
static void daemonize(void)
{
	struct fs_struct *fs;


	/*
	 * If we were started as result of loading a module, close all of the
	 * user space pages.  We don't need them, and if we didn't close them
	 * they would be locked into memory.
	 */
	exit_mm(current);

	current->session = 1;
	current->pgrp = 1;

	/* Become as one with the init task */

	exit_fs(current);	/* current->fs->count--; */
	fs = init_task.fs;
	current->fs = fs;
	atomic_inc(&fs->count);
}
#endif