Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > why does symbol & in #define QO_PTR(q_node, q_type, q_ptr) needed?

Reply
Thread Tools

why does symbol & in #define QO_PTR(q_node, q_type, q_ptr) needed?

 
 
ooze
Guest
Posts: n/a
 
      06-08-2004
typedef unsigned long PARAM;

typedef PARAM SAP;

typedef struct qnode
{
struct qnode *next;
struct qnode *prev;
}
QNODE;

typedef struct qhead
{
struct qnode *head;
struct qnode *tail;
}
QHEAD;

typedef struct
{
QHEAD qhead;
int (*srv_req) (SAP sys_sap);
SAP sys_sap;
}
SSRV_S;



typedef struct sig_s
{
struct sig_s *next;
struct sig_s *prev;
int waiting;
SAP ssrv_sap;
SIG_FUNC func;
SAP user_sap;
PARAM ident;
}
SIG_S;
/************************************************** **********************
* slib_init
************************************************** ***********************
*
*/
PUBLIC int slib_init
(
int (*func) (SAP SysSap),
SAP sys_sap,
SAP *ssrv_sap
)
{
SSRV_S *ssrv;

/* Self initialize, if needed.
*/
if (! s_initialized)
s_init ();

/* Try to allocate a sap
*/
#if MAX_SIG_SRV
for (ssrv = ssrv_pool; ssrv < ssrv_pool + MAX_SIG_SRV; ++ssrv)
if (ssrv->srv_req == NULL)
break;
if (ssrv >= ssrv_pool + MAX_SIG_SRV)
return -1;
#else
ssrv = (SSRV_S *) MEM_ALLOC (sizeof (SSRV_S));
if (ssrv == NULL)
return -1;
#endif

/* Initialize it.
*/
Q_INIT (&ssrv->qhead);
ssrv->srv_req = func;
ssrv->sys_sap = sys_sap;

/* Tell the caller the address of the SSRV_S and return success.
*/
*ssrv_sap = (SAP) ssrv;
return 0;
}


/************************************************** **********************
* slib_serv
************************************************** ***********************
*
*/
PUBLIC void slib_serv
(
SAP ssrv_sap
)
{
SSRV_S *ssrv = (SSRV_S *) ssrv_sap;
SIG_S *sig;
IPL_VALUE level;
int limit = SIG_SERV_LIMIT;

/* Call the functions for each signaled event.
*/
while (((sig = (SIG_S *) ssrv->qhead.head) != NULL) && (limit-- > 0))
{
level = IPL_SET_NORMAL ();
QO_REMOVE (sig, &ssrv->qhead, SIG_S, next);
sig->waiting = 0;
IPL_RESTORE (level);
(*sig->func) (sig->user_sap, sig->ident);
}
}




#define QO_REMOVE(q_node, q_head, q_type, q_ptr) { \
register QNODE * node = (QNODE *) (void *) q_node; \
register QHEAD * head = (QHEAD *) (void *) q_head; \
if (QO_PTR(node, q_type, q_ptr)->prev == NULL) \
head->head = QO_PTR(node, q_type, q_ptr)->next; \
else \
QO_PTR(QO_PTR(node, q_type, q_ptr)->prev, q_type, q_ptr)->next = \
QO_PTR(node, q_type, q_ptr)->next; \
if (QO_PTR(node, q_type, q_ptr)->next == NULL) \
head->tail = QO_PTR(node, q_type, q_ptr)->prev; \
else \
QO_PTR(QO_PTR(node, q_type, q_ptr)->next, q_type, q_ptr)->prev = \
QO_PTR(node, q_type, q_ptr)->prev; \
QO_PTR(node, q_type, q_ptr)->next = NULL; \
QO_PTR(node, q_type, q_ptr)->prev = NULL; \
}



#define QO_PTR(q_node, q_type, q_ptr) \
((QNODE *) (void *) (&((q_type *) (void *) q_node)->q_ptr))
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(Encryption Package) error: cannot find symbol symbol: class BaseNCode clusardi2k@aol.com Java 6 08-29-2012 08:33 PM
Why ":symbol" failed but 'symbol' successed with JRuby 1.0.3? Song Ma Ruby 2 07-20-2008 04:08 AM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
what's differnece between #ifdef symbol and #if defined(symbol) baumann@pan C Programming 1 04-15-2005 08:25 AM



Advertisments