473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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))
Nov 14 '05 #1
0 1333

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Hodapp | last post by:
I have seen messages posted about this before, and there is a clear reference to it in the manual, but I have been unable to find a solution. I'm on Slackware 9.1, kernel 2.6.0-test11, using...
2
by: ooze | last post by:
typedef unsigned long PARAM; typedef PARAM SAP; typedef struct qnode { struct qnode *next; struct qnode *prev; } QNODE;
9
by: Felix Kater | last post by:
Hi, if I link my code to other o-files: Does the linker include the whole o-file or does it use the needed functions from that only? Felix
28
by: Martin Jørgensen | last post by:
Hi, I have a "funny" question, which I think is pretty "healthy" to examine... This program is being investigated: - - - - - - - #include <iostream> using namespace std; #define DAYS 7
8
by: Ben | last post by:
Hi, I am having trouble debugging a segmentation fault...here's my data structure: typedef struct CELL *pCELL; /* Pointers to cells */ struct CELL { SYMBOL symbol; pCELL prev_in_block;...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
14
by: webEater | last post by:
I have a problem, it's not browser specific, and I don't get a solution. I have an (X)HTML document, I show you a part of it: .... <!--<div class="pad">--> <div id="eventImages"><img src=""...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
11
by: A.C. | last post by:
hi i m declaring a structure globally & there is func1 & main. i m assigning the value to variable(this is a pointer) of structure in fun1 & want to print it in main. this is same kind of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.