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

📄 q.h

📁 用于嵌入式系统的TCP/IP协议栈及若干服务
💻 H
字号:
/**            Copyright (c) 1998-2001 by NETsilicon Inc.**  This software is copyrighted by and is the sole property of*  NETsilicon.  All rights, title, ownership, or other interests*  in the software remain the property of NETsilicon.  This*  software may only be used in accordance with the corresponding*  license agreement.  Any unauthorized use, duplication, transmission,*  distribution, or disclosure of this software is expressly forbidden.**  This Copyright notice may not be removed or modified without prior*  written consent of NETsilicon.**  NETsilicon, reserves the right to modify this software*  without notice.**  NETsilicon*  411 Waverley Oaks Road                  USA 781.647.1234*  Suite 227                               http://www.netsilicon.com*  Waltham, MA 02452                       AmericaSales@netsilicon.com***************************************************************************  $Name: Fusion 6.52 Fusion 6.51 $*  $Date: 2001/09/20 10:19:23 $*  $Source: M:/psisrc/stack/incl/rcs/q.h $*  $Revision: 1.12 $***************************************************************************  File Description:  Definitions and Macros for dealing with `q', `gq'*                     structures**************************************************************************/#ifndef _Q_#define _Q_#include "config.h"#include "ccdep.h"#include "std.h"/* basic doubly linked list queue structure */typedef struct q_t {	struct q_t      * q_next;	struct q_t      * q_prev;} q_t;  /* queue type *//* Queue structure used all over the kernel */typedef struct  q {	struct  q       * q_next;       /* forward link */	struct  q       * q_prev;       /* backward link */	u16     q_flags;        /* used for locking, zapping etc. */	i16     q_parent;       /* offset (in bytes) to parent struct */        } q;/* flags for q.q_flags */#define F_Q_HEADER      0x0001  /* denotes a queue head */#define F_Q_LOCKED      0x0002  /* don't touch this right now */#define F_Q_ZAPPED      0x0004  /* this entry awaiting burial */#define F_Q_PRESERVE    0x0008  /* preserve across unlocks */#define F_Q_BYTE_QUEUE  0x0800  /* byte-style vs. packet-style queue */#define is_header(ptr)          bT1(((q *)(ptr))->q_flags,F_Q_HEADER)#define is_zapped(ptr)          bT1(((q *)(ptr))->q_flags,F_Q_ZAPPED)#define is_locked(ptr)          bT1(((q *)(ptr))->q_flags,F_Q_LOCKED)#define q_empty(qp)             (((q *)(qp))->q_next == (q *)(qp))#define gq_full(gqp)            ((gqp)->gq_cnt >= (gqp)->gq_max)#define gq_empty(gqp)           ((gqp)->gq_cnt == 0)#define gq_left(gqp) (((gqp)->gq_max > (gqp)->gq_cnt) ? ((gqp)->gq_max - (gqp)->gq_cnt) : 0)/* Guarded Queue 'gq' structure used all over the kernel */typedef struct gq {	q       gq_q;           /* head and tail links */    u32     gq_cnt;         /* how many elements are on this queue */	u32     gq_max;         /* how many elements can be on this queue */	i16     gq_sleeping;    /* how many procs are sleeping on this queue */	i16     gq_status;      /* status to be passed up when awakened */	boolean gq_inuse;		/* indcates whether the queue is presently in service							   or not */} gq;/* internal queue manipulation macros, to be used in critical section */#define _q_init(qp)     ((qp)->q_next=(qp),(qp)->q_prev=(qp))#define _q_intail(a,b)  q_in((b), (a))#define _q_rem(qp)      ((qp)->q_next->q_prev=(qp)->q_prev,(qp)->q_prev->q_next=(qp)->q_next)#define _q_parent(qp)   (&((char *)(qp))[(qp)->q_parent])#define _q_outhead(qp)  (q_empty((qp)) ? (char *)0 : q_outparent((qp)->q_next))/* macro to replace the function q_initparent (performance reasons) */#define q_initparent(qp,flags,pp) { \                                    (qp)->q_flags = flags;\                                    (qp)->q_parent = pp - (char *)(qp);\                                    _q_init((qp));}/* macro to replace the function q_init (performance reasons */#define q_init(qp,flags) { \                         	(qp)->q_flags = flags; \	                        _q_init(qp); }	                      #endif  /*_Q_*/

⌨️ 快捷键说明

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