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

📄 queue.h

📁 7号信令功能代码,为开源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*                               -*- Mode: C -*-  * queue.h --- streams queue handling * Author          : Graham Wheeler * Created On      : Tue May 31 22:25:19 1994 * Last Modified By: David Grothe * RCS Id          : queue.h,v 1.1.1.4 2003/12/27 21:12:52 brian Exp * Purpose         : here you have utilites to handle str queues. * ----------------______________________________________________ * *   Copyright (C) 1995  Graham Wheeler, Francisco J. Ballesteros *   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 us by email to any of *    gram@aztec.co.za, nemo@ordago.uc3m.es */#ifndef _QUEUE_H#define _QUEUE_H 1#ident "@(#) LiS queue.h 2.17 12/27/03 15:12:52 "/*  -------------------------------------------------------------------  *//*				 Dependencies                            */#ifndef _LIS_CONFIG_H#include <sys/strconfig.h>	/* config definitions */#endif#ifndef _MSG_H#include <sys/LiS/msg.h>	/* streams messages*/#endif#ifndef _STRPORT_H#include <sys/strport.h>	/* machine-dependent porting constructs */#endif#ifndef SYS_LISLOCKS_H#include <sys/lislocks.h>#endif/*  -------------------------------------------------------------------  *//*				   Symbols                               *//* Max # of bands -- hard limit since we use char to store band ids */#define LIS_MAX_BAND	255/* STREAMS queue flags (q_flag) mask values */#define QENAB           0x000001 /* queue enabled */#define QWANTR          0x000002 /* usr wants to read */#define QWANTW          0x000004 /* usr wants to write */#define QFULL           0x000008 /* queue is full */#define QREADR          0x000010 /* it's the reader */#define QUSE            0x000020 /* not a free queue */#define QNOENB          0x000040 /* don't enable with putq() */#define QBACK           0x000080 /* a back-enabled queue */#define QRETRY		0x000100 /* retry timer's set */#define QSCAN		0x000200 /* queue in the scan list */#define	QCLOSING	0x000400 /* strm hd wants to close this queue */#define QWASFULL	0x000800 /* QFULL was set, still above low water */#define QCLOSEWT	0x001000 /* strm hd waiting for queue to drain */#define	QPROCSOFF	0x002000 /* don't call Q put/svc routines */#define QRUNNING	0x004000 /* svc proc is actually running */#define	QWAITING	0x008000 /* qdetach is waiting for wakeup */#define	QREADING	0x010000 /* read/getpmsg running on queue *//*  -------------------------------------------------------------------  *//* STREAMS queue's qband flags */#define QB_FULL         0x000001 /* band is full */#define QB_WANTW        0x000002 #define QB_BACK         0x000004 #define	QB_WASFULL	0x000008/* flushq() flags */#define FLUSHDATA 0		/* do not flush cntl msgs */#define FLUSHALL  1		/* flush every msg *//* what to qtrqget/set */#define QHIWAT		0#define QLOWAT		1#define QMAXPSZ		2#define QMINPSZ		3#define QCOUNT		4#define QFIRST		5#define QLAST		6#define QFLAG		7/*  -------------------------------------------------------------------  *//*				    Types                                */typedef int qfields_t;/* *  The STREAMS queue structure. Each module has a queue upstream and * another one downstream. */typedefstruct queue{  EXPORT        struct  qinit   *q_qinfo;       /* procs and limits for queue [I]*/        struct  msgb    *q_first;       /* first data block [Z]*/        struct  msgb    *q_last;        /* last data block [Z]*/        struct  queue   *q_next;        /* next Q of stream [Z]*/        struct  queue   *q_link;        /* to next Q for the scan list [Z]*/        void            *q_ptr;         /* module private data for free */        ulong           q_count;        /* number of bytes on Q [Z]*/        volatile ulong  q_flag;         /* queue state [Z]*/  SHARE        long            q_minpsz;       /* min packet size accepted [I]*/        long            q_maxpsz;       /* max packet size accepted [I]*/        ulong           q_hiwat;        /* queue high water mark [I]*/        ulong           q_lowat;        /* queue low water mark [I]*/  PRIVATE        struct qband    *q_bandp;       /* separate flow information */        struct queue    *q_other;       /* for RD()/WR()/OTHER() */        void            *q_str;         /* pointer to stream's stdata */        struct  queue   *q_scnxt;       /* next q in the scan list */	ulong		 q_magic;	/* magic number */	lis_spin_lock_t	 q_lock;	/* for put, srv, open, close */	lis_spin_lock_t	 q_isr_lock;	/* for ISR protection */	lis_semaphore_t *q_wakeup_sem ;	/* helps sync closes */} queue_t;#define	Q_MAGIC		((ulong) (0x93390000L | sizeof(queue_t)) )int     lis_check_q_magic(queue_t *q, char *filename, int linenr) ;#define LIS_QMAGIC(q,f,l) \	(((q) && ((q)->q_magic == Q_MAGIC)) || lis_check_q_magic((q),(f),(l)))#define	LIS_CHECK_Q_MAGIC(q)	LIS_QMAGIC((q),__FILE__,__LINE__)/* * Queue isr locking macro.  To be used ONLY internally by LiS. */#define	LIS_QISRLOCK(qp,flgsp)			\			lis_spin_lock_irqsave(&(qp)->q_isr_lock,(flgsp))#define	LIS_QISRUNLOCK(qp,flgsp)		\			lis_spin_unlock_irqrestore(&(qp)->q_isr_lock,(flgsp))/* *  The qinit structure. It's used to hold the queue routines and info. * *  The SVR4 DKI contains contradictory information about the types *  of the put and srv procedures.  In the D2DK section, it says that *  that they are void type.  In the D4DK section on qinit, it says *  that they are int type. * *  After using the "void" form for some years, we are converting to the *  "int" form.  It seems that all the other Unix streams.h files use "int". *  Use "return(0)" in the functions.  The return value is ignored by LiS. */typedefstruct  qinit {#if defined(USE_VOID_PUT_PROC)        void    (*qi_putp)(queue_t*, mblk_t*);  /* put procedure */        void    (*qi_srvp)(queue_t*);           /* service procedure */#else        int     (*qi_putp)(queue_t*, mblk_t*);  /* put procedure */        int     (*qi_srvp)(queue_t*);           /* service procedure */#endif        int     (*qi_qopen)(queue_t *, dev_t *, int, int, cred_t *);   /* open procedure */        int     (*qi_qclose)(queue_t *, int,cred_t *);   /* close procedure */        int     (*qi_qadmin)(void);         /* debugging */        struct lis_module_info *qi_minfo;   /* module information structure */        struct module_stat *qi_mstat;   /* module statistics structure */} qinit_t;/* * This structure hold a queue's priority band information. */typedefstruct qband {  SHARE        struct qband    *qb_next;       /* next band's info */        ulong           qb_count;       /* number of bytes in band */        struct msgb     *qb_first;      /* beginning of band's data */        struct msgb     *qb_last;       /* end of band's data */        ulong           qb_hiwat;       /* high water mark for band */        ulong           qb_lowat;       /* low water mark for band */        ulong           qb_flag;        /* see above */} qband_t;/*  -------------------------------------------------------------------  *//*				 Glob. Vars.                             *//*  -------------------------------------------------------------------  *//*			Exported functions & macros                      *//* Queues are allocated always in queue pairs, the pointer to the queue pair * may be a pointer to any of the two queues (usually the pointer to * RD(q). Flags are initialized by allocq in such a way RD(q) and WR(q) will * always work regardless the given queue. * The pointer given by allocq is actually a pointer to RD(q). */#ifdef __KERNEL__#if (defined(LINUX) && defined(USE_LINUX_KMEM_CACHE))extern void lis_init_queues(void);extern void lis_terminate_queues(void);#endif/* Allocate a new queue pair * return NULL on failure  * */extern queue_t * lis_allocq( const char *name );/* Deallocate a new queue pair * return NULL on failure * */extern void lis_freeq( queue_t *q );#endif /* __KERNEL__ *//* backq - Return the queue which feeds this one. * get ptr to the queue behind q. That queue with q_next == q. * returns NULL if no such queue * */#ifdef __KERNEL__extern queue_t * lis_backq_fcn(queue_t *q, char *f,int l);extern queue_t * lis_backq(queue_t *q);#endif				/* __KERNEL__ *//* lis_getq - get message from head of queue * */

⌨️ 快捷键说明

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