⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux-mdep.h

📁 7号信令功能代码,为开源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*                               -*- Mode: C -*-  * mdep.h --- machine (actually kernel) dependencies. * Author          : Francisco J. Ballesteros * Created On      : Tue May 31 21:40:37 1994 * Last Modified By: David Grothe * RCS Id          : linux-mdep.h,v 1.1.1.6.4.1 2004/01/12 23:32:45 brian Exp * Purpose         : provide kernel independence as much as possible *                 : This could be also considered to be en embryo for *                 : dki stuff,i.e. linux-dki * ----------------______________________________________________ * *    Copyright (C) 1995  Francisco J. Ballesteros, Denis Froschauer *    Copyright (C) 1997  David Grothe, Gcom, Inc <dave@gcom.com> * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. *  * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, * MA 02139, USA. *  * *    You can reach su by email to any of *    nemo@ordago.uc3m.es, 100741.1151@compuserve.com *    dave@gcom.com */#ifndef _LIS_M_DEP_H#define _LIS_M_DEP_H 1#ident "@(#) LiS linux-mdep.h 2.57 01/12/04 10:50:27 "#ifdef __KERNEL__#include <linux/config.h>#include <linux/version.h>#ifdef CONFIG_MODVERSIONS#include <linux/modversions.h>#endif#include <linux/module.h>#endif/* Here follows complete drivel: *//*  -------------------------------------------------------------------  *//*				 Dependencies                            *//* * types.h will include <linux/config.h>.  If we have generated our own * autoconf.h file then we need to include it prior to anything else. * We set the include marker that prevents the <linux/config.h> from * including its own autoconf.h. */#ifdef __KERNEL__#ifdef LISAUTOCONF#include <sys/autoconf.h>           /* /usr/src/LiS/include/sys */#define _LINUX_CONFIG_H 1	    /* prevent <linux/config.h> */#endif#if !defined(NOKSRC)		/* have kernel source */#ifndef _SYS_TYPES_H#include <linux/types.h>#define _SYS_TYPES_H	1	/* pretend included */#endif#else#include <sys/types.h>#endif#endif/* kernel includes go here */#ifdef __KERNEL__/* * The IRDA driver's use of queue_t interferes with ours.  Later versions * of the kernel source do not have this problem, but this is safe for all * versions. */#define queue_t	irda_queue_t#ifdef MODVERSIONS# ifdef LISMODVERS# include <sys/modversions.h>           /* /usr/src/LiS/include/sys */# else# include <linux/modversions.h># endif#endif#include <linux/version.h>#ifndef KERNEL_VERSION#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)#define	KERNEL_2_0#else# define	KERNEL_2_1	/* 2.1.x and 2.2.x kernel */# if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)# define	KERNEL_2_3	/* 2.3.x and 2.4.x kernel */#  if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)#  define	KERNEL_2_4_7	/* 2.4.7+ redefines dentry structure */#  endif#  if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)#  define	KERNEL_2_5	/* 2.5.x and 2.6.x kernel */#  endif# endif#endif#if defined(NOKSRC)#include <linux/types.h>        /* common system types */#include <linux/spinlock.h>#define	__need_sigset_t	1#include <signal.h>#define timespec time_h_timespec#include <linux/time.h>#undef timespec#else#if !defined(_LINUX_TYPES_H)#include <linux/types.h>        /* common system types */#endif#endif#include <linux/kdev_t.h>	/* 1.3.xx needs this */#include <linux/sched.h>	/* sleep,wake,... */#include <linux/wait.h>#include <linux/kernel.h>	/* suser,...*/#include <linux/interrupt.h>#include <linux/major.h>#include <linux/fs.h>		/* inodes,... */#include <linux/fcntl.h>	/* inodes,... */#include <linux/string.h>	/* memcpy,... */#include <linux/timer.h>	/* timers */#include <linux/mm.h>		/* memory manager, pages,... */#include <linux/slab.h>		/* memory manager, pages,... */#include <linux/stat.h>		/* S_ISCHR */#include <asm/segment.h>	/* memcpy_{to,from}_fs */#include <asm/system.h>		/* sti,cli */#include <linux/errno.h>	      /* for errno */#include <linux/signal.h>	      /* for signal numbers */#if defined(KERNEL_2_1)		/* 2.1 kernel or later */#include <sys/poll.h>		/* ends up being linux/poll.h */#include <linux/file.h>#include <asm/uaccess.h>#endif#include <sys/LiS/genconf.h>	/* generated configs from installation */#include <sys/LiS/config.h>/* #include <sys/lislocks.h>	needs lis_atomic_t, below *//* * Kernel loadable module support */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)#ifdef CONFIG_KERNELD#include <linux/kerneld.h>#define LIS_LOADABLE_SUPPORT 1#endif#else#ifdef CONFIG_KMOD#include <linux/kmod.h>#define LIS_LOADABLE_SUPPORT 1#endif#endif#undef queue_t			/* allow visibility for LiS */#endif /* __KERNEL__ *//*  -------------------------------------------------------------------  *//*  -------------------------------------------------------------------  *//* * 2.1/2.2 kernels define this, earlier ones don't * OSH: In 2.2.1 and later this is an inline function, not a macro *      and we only need this in the kernel. */#if 0#ifndef signal_pending#define	signal_pending(tsk)	(tsk->signal & ~tsk->blocked)#endif#else#ifdef __KERNEL__#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,1)#ifndef signal_pending#define	signal_pending(tsk)	(tsk->signal & ~tsk->blocked)#endif#ifndef sigismember#define sigismember(sig_msk_addr,signo) ( *(sig_msk_addr) & (1 << (signo)) )#endif#ifndef sigaddset#define sigaddset(sig_msk_addr,signo) ( *(sig_msk_addr) |= (1 << (signo)) )#endif#endif#endif#endif/*  -------------------------------------------------------------------  */#if defined(__KERNEL__) && defined(KERNEL_2_0)# ifndef MODULE_AUTHOR# define MODULE_AUTHOR(str)	 static const char module_author[] = str# endif# ifndef MODULE_DESCRIPTION# define MODULE_DESCRIPTION(str) static const char module_description[] = str# endif#endif/* some missing symbols */#ifdef __KERNEL__			/* seconds to system tmout time units */#define SECS_TO(t)	lis_milli_to_ticks(1000*(t))extern long lis_time_till(long target_time);extern long lis_target_time(long milli_sec);extern long lis_milli_to_ticks(long milli_sec) ;#endif				/* __KERNEL__ *//* some missing generic types  */#undef uid #undef gidtypedef int     o_uid_t;typedef int     o_gid_t;typedef unsigned   char uchar;typedef struct cred {	uid_t	cr_uid;			/* effective user id */	gid_t	cr_gid;			/* effective group id */	uid_t	cr_ruid;		/* real user id */	gid_t	cr_rgid;		/* real group id */} cred_t;#ifdef __KERNEL__#if defined(KERNEL_2_5)#define lis_suser(fp)	capable(CAP_SYS_ADMIN)#else#define lis_suser(fp)	suser()#endif#endif				/* __KERNEL__ *//*  -------------------------------------------------------------------  */#ifdef __KERNEL__#define lis_free_page(cp) free_page((unsigned long)(cp))#define PRINTK		printk/* *  The ASSERT macro. */extern void lis_assert_fail(const char *expr, const char *objname,			    const char *file, unsigned int line);#ifdef ASSERT#undef ASSERT			/* we want our own version */#endif#ifdef LIS_OBJNAME#define ___ASSERT_XSTR(s) ___ASSERT_STR(s)#define ___ASSERT_STR(s) #s#define ASSERT(expr)							   \	((void)((expr) ? 0 : lis_assert_fail(#expr,			   \					      ___ASSERT_XSTR(LIS_OBJNAME), \					     __FILE__, __LINE__)))#else#define ASSERT(expr)							   \	((void)((expr) ? 0 : lis_assert_fail(#expr, "streams",		   \					     __FILE__, __LINE__)))#endif/* disable/enable interrupts */#define SPLSTR(x)	x = lis_splstr()#define SPLX(x)		lis_splx(x)/* * Atomic functions * * Usage is: lis_atomic_t	av ; *           lis_atomic_set(&av, 1) ; * * Use the lis_ versions of these for portability across kernel versions. * You can use the direct kernel versions for speed at the risk of needing a * recompile of your driver code with each new kernel version. * * The "long" type is intended to be an opaque type to the user.  The routines * cast the pointer to lis_atomic_t to a pointer to atomic_t (kernel struct) * for operational purposes.  By keeping the kernel's atomic_t type invisible * from STREAMS drivers we help insulate them from kernel changes. */typedef	volatile long		lis_atomic_t ;/* * Bad idea.  LDL foolishes exposes this to user space with a ioctl structure * in ldl_gstats_ioctl.  Therefore, long can be 64 bits or 32 bits or 31 bits * depending on the architecture.  Give up using ldl on non-32 bit * architectures. --bb */#define lis_atomic_t lis_atomic_tvoid	lis_atomic_set(lis_atomic_t *atomic_addr, int valu) ;int	lis_atomic_read(lis_atomic_t *atomic_addr) ;void	lis_atomic_add(lis_atomic_t *atomic_addr, int amt) ;void	lis_atomic_sub(lis_atomic_t *atomic_addr, int amt) ;void	lis_atomic_inc(lis_atomic_t *atomic_addr) ;void	lis_atomic_dec(lis_atomic_t *atomic_addr) ;int	lis_atomic_dec_and_test(lis_atomic_t *atomic_addr) ;/* * Now include lislocks.h */#include <sys/lislocks.h>/* *  lis_gettimeofday -  used by lis_hitime and similar functions */void lis_gettimeofday(struct timeval *tv);/* lock inodes... * * Must use kernel semaphore routine directly since the inode semaphore is a * kernel semaphore and not an LiS semaphore. */int lis_kernel_down(struct semaphore *sem);void lis_kernel_up(struct semaphore *sem);#if 0			/* don't need to hold inode semaphore for I/O oprns */#define	LOCK_INO(i)	lis_kernel_down(&((i)->i_sem))#define	ULOCK_INO(i)	lis_kernel_up(&((i)->i_sem))#else#define	LOCK_INO(i)	do {;} while (0)#define	ULOCK_INO(i)	do {;} while (0)#endif/* *  inode/stdata access */struct inode  *lis_file_inode(struct file *f);char          *lis_file_name(struct file *f);struct stdata *lis_file_str(struct file *f);void           lis_set_file_str(struct file *f, struct stdata *s);struct stdata *lis_inode_str(struct inode *i);void           lis_set_inode_str(struct inode *i, struct stdata *s);struct inode  *lis_set_up_inode(struct file *f, struct inode *inode) ;#define FILE_INODE(f)   lis_file_inode(f)#define FILE_NAME(f)    lis_file_name(f)#define FILE_STR(f)     lis_file_str(f)#define SET_FILE_STR(f,s) lis_set_file_str(f,s)#define INODE_STR(i)    lis_inode_str(i)#define SET_INODE_STR(i,s)  lis_set_inode_str(i,s)#if   defined(KERNEL_2_3)			/* linux > 2.3.0 */#define	I_COUNT(i)	( (i) ? atomic_read(&((i)->i_count)) : -1 )#define F_COUNT(f)	( (f) ? atomic_read(&((f)->f_count)) : -1 )#else#define	I_COUNT(i)	( (i) ? ((i)->i_count) : -1 )#define	F_COUNT(f)	( (f) ? ((f)->f_count) : -1 )#endifstruct dentry *lis_d_alloc_root(struct inode *i, int m);void           lis_dput(struct dentry *d);struct dentry *lis_dget(struct dentry *d);/* * mode (m) parameter values for lis_d_alloc_root */#define LIS_D_ALLOC_ROOT_NORMAL   0#define LIS_D_ALLOC_ROOT_MOUNT    1/* *  clone support */extern struct inode *lis_grab_inode(struct inode *ino);extern void          lis_put_inode(struct inode *ino);extern struct inode *lis_new_inode(struct file *,dev_t);extern struct inode *lis_old_inode(struct file *,struct inode *);extern int           lis_new_file_name(struct file *, const char *);extern void          lis_new_stream_name(struct stdata *, struct file *);#if defined(KERNEL_2_1)extern void          lis_cleanup_file_opening(struct file *,					      struct stdata *, int,					      struct dentry *,  int,					      struct vfsmount *, int);#elseextern void          lis_cleanup_file_opening(struct file *,					      struct stdata *, int);#endifextern void          lis_cleanup_file_closing(struct file *, struct stdata *);extern int lis_major;/* * Device node support */int     lis_mknod(char *name, int mode, dev_t dev) ;int     lis_unlink(char *name) ;/* *  FIFO/pipe support */extern int lis_get_fifo(struct file **);extern int lis_get_pipe(struct file **, struct file **);extern int lis_pipe( unsigned int * );extern int  lis_fifo_open_sync(struct inode *, struct file *);extern void lis_fifo_close_sync(struct inode *, struct file *);extern int  lis_fifo_write_sync(struct inode *, int);/* *  syscall interface */extern asmlinkage int lis_sys_pipe(unsigned int *);/* *  ioctl interface */extern int lis_ioc_pipe(unsigned int *);/* *  fattach()/fdetach() support */extern int lis_fattach(struct file *, const char *);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -