473,626 Members | 3,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_nod e, 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(n ode, 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(n ode, 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 1349

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

Similar topics

2
6754
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 Python 2.3.1 and GCC 3.2.3 (both installed by default with Slackware) and SWIG 1.3.19, compiled from source code. I messed around a little on my own and couldn't get things to work right, so I copied the examples from the book, nearly verbatim but...
2
1402
by: ooze | last post by:
typedef unsigned long PARAM; typedef PARAM SAP; typedef struct qnode { struct qnode *next; struct qnode *prev; } QNODE;
9
2731
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
2433
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
2127
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; pCELL next_in_block; pCELL prev_in_column;
1
2170
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 <string>
14
3471
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="" id="eventImage0" class="eventImage"><img src="" id="eventImage1" class="eventImage"></div>
1
4191
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 aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? http://geekarama.co.uk/new_home.html here is the code for new_home.html and following that the CSS...
11
1879
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 problem not the actual code. pls help. static struct des_rbuf{ unsigned int ind; long long buf_adr;
0
8707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8641
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.