473,325 Members | 2,860 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,325 software developers and data experts.

Qustion: sigset_t operation.

Hi All,

In Richard's book AUEP, one example as below.

But I compile with gcc in Soalris 9. It will report error.
gcc -I/usr/include -I/opt/exp/include -I/opt/exp/gnu/include -Wall -Dsun -c
setops.c
setops.c: In function `sigaddset':
setops.c:12: error: invalid operands to binary |
*** Error code 1
make: Fatal error: Command failed for target `setops.o'
Could you tell me the reason and how to fix it.

Thanks.

Franklin
************************************************** *********
#define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG)
/* <signal.h> usually defines NSIG to include signal number 0 */

int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set |= (1 << (signo - 1)); /* turn bit on */
return(0);
}

int
sigdelset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set &= ~(1 << (signo - 1)); /* turn bit off */
return(0);
}

int
sigismember(const sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

return( (*set & (1 << (signo - 1))) != 0 );
return(0);
}

************************************************** ********
Nov 14 '05 #1
4 2832
In article <cp********@netnews.proxy.lucent.com>
Franklin Li <pe*******@hotmai.com> wrote:
In Richard's book AUEP, one example as below.
Which Richard, and what does "AUEP" stand for? (I can guess,
but you should not force me to guess -- and my guess is that
you mean "W. Richard Stevens", and a book that would be better
abbreviated "APUE" or "APitUE", and to shorten his name to a single
word, one would normally use "Stevens", not "Richard", so perhaps
my guess is not such a good one.)

In any case:
setops.c:12: error: invalid operands to binary |
where line 12 is apparently the "|=" line in:
int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set |= (1 << (signo - 1)); /* turn bit on */
return(0);
}


What type does "sigset_t" have? The only thing that is fairly
obvious is that it must not be an integral type. Since sigset_t
is not a basic C type, you will have to tell us more about it
before we can answer this as a C question.

Although it is off topic here, I will also note that sigaddset(),
sigdelset(), and sigismember() are standard POSIX functions, and
questions about them therefore belong in comp.unix.programmer.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #2


Franklin Li wrote:
Hi All,

In Richard's book AUEP, one example as below.

But I compile with gcc in Soalris 9. It will report error.
gcc -I/usr/include -I/opt/exp/include -I/opt/exp/gnu/include -Wall -Dsun -c
setops.c
setops.c: In function `sigaddset':
setops.c:12: error: invalid operands to binary |
*** Error code 1
make: Fatal error: Command failed for target `setops.o'
Could you tell me the reason and how to fix it.

Thanks.

Franklin
************************************************** *********
#define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG)
/* <signal.h> usually defines NSIG to include signal number 0 */

int
sigaddset(sigset_t *set, int signo)

^^^^^^^^^^

What is 'sigset_t' ? Its not a standard data type.
So i guess its off-topic here and you need to seek in a solaris/sun
group.

Nov 14 '05 #3
Chris Torek wrote:
Franklin Li <pe*******@hotmai.com> wrote:
In Richard's book AUEP, one example as below.
Which Richard, and what does "AUEP" stand for? (I can guess,
but you should not force me to guess -- and my guess is that
you mean "W. Richard Stevens", and a book that would be better
abbreviated "APUE" or "APitUE", and to shorten his name to a
single word, one would normally use "Stevens", not "Richard",
so perhaps my guess is not such a good one.)


I always wonder why people assume we are mind readers.

In any case:
setops.c:12: error: invalid operands to binary |
where line 12 is apparently the "|=" line in:
int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set |= (1 << (signo - 1)); /* turn bit on */
return(0);
}


What type does "sigset_t" have? The only thing that is fairly
obvious is that it must not be an integral type. Since sigset_t
is not a basic C type, you will have to tell us more about it
before we can answer this as a C question.


Surely you jest. To use the |= operator it should be an integral
type, with a heavy preference for an unsigned type.

I wonder if he pasted or typed the code. If the prototype used a
stray 'const' it could explain the problem. Another function in
his original posting did so, but didn't modify the set. The error
return of -1 is another source of problems.

Although it is off topic here, I will also note that sigaddset(),
sigdelset(), and sigismember() are standard POSIX functions, and
questions about them therefore belong in comp.unix.programmer.


Yet those names are firmly in the users namespace, so there is no
reason not to use them. Thus questions that include their source
are valid here.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #4
[various snippage]
Franklin Li <pe*******@hotmai.com> wrote:
int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set |= (1 << (signo - 1)); /* turn bit on */
return(0);
}
Chris Torek wrote:
What type does "sigset_t" have? The only thing that is fairly
obvious is that it must not be an integral type. Since sigset_t
is not a basic C type, you will have to tell us more about it
before we can answer this as a C question.

In article <41***************@yahoo.com>
CBFalconer <cb********@worldnet.att.net> wrote:Surely you jest. To use the |= operator it should be an integral
type, with a heavy preference for an unsigned type.


You misunderstand: the compiler is complaining that the "|" is
invalid, therefore I conclude that sigset_t is in fact not (i.e.,
"must not be") an integral type. The error lies in trying to
manipulate the bits of this non-integral type.

The fix is not "define sigset_t as an integral type", because the
sigset_t type is pre-defined as part of the (POSIX) implementation --
for the programmer to change it is like an attempt by the programmer
to re-#define RAND_MAX in an attempt to influence the numbers coming
out of rand(). It simply does not work.
Although it is off topic here, I will also note that sigaddset(),
sigdelset(), and sigismember() are standard POSIX functions, and
questions about them therefore belong in comp.unix.programmer.


Yet those names are firmly in the users namespace, so there is no
reason not to use them. Thus questions that include their source
are valid here.


Again, these things are actually supplied by the implementation.

Just for completeness, here is the actual definition of sigset_t on
his system, with some of the names and/or types changed to protect
the guilty :-) :

typedef struct { unsigned char bits[SOME_CONSTANT]; } sigset_t;

The reason the compiler gripes about the assignment to *set is now
clear. The code should read something like:

set->bits[signo / SOME_DIVISOR] |= 1 << (signo % SOME_MODULUS);

but his system already provides these routines, so he should not
write them at all!
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #5

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

Similar topics

3
by: Marcus | last post by:
Hi I have a very complex sql query and a explain plan. I found there is a full table scan in ID=9 9 8 TABLE ACCESS (FULL) OF 'F_LOTTXNHIST' (Cost=84573 Card=185892...
5
by: Jade Fox | last post by:
Can anybody tell me what is wrong with the following code? It compiles ok with 'gcc file.c', but not 'gcc -ansi file.c' or 'gcc -std=c99 file.c'. It complains that 'sigset_t' is undeclared. What...
4
by: Hardy Wang | last post by:
Hi, I have a win form application, when a button is clicked, a lengthy operation will be triggered. During the time program is still running, this application seems not to be able to response to...
0
by: John Jenkins | last post by:
Hi, any help on this would be greatly apprciated. I have been given a wsdl file from a customer generated by Oracle 10g Web Services tools. When I use wsdl.exe to attempt to produce proxy classes I...
0
by: relaxedrob | last post by:
Hi All, I have a portType such as this: <portType name="CMLeJobSoapGetEmpBrand"> <operation name="EJobGetEmpBrand"> <input message="tns:EJobEmpBrdReq" name="EJobEmpBrdReq"/> <output...
6
by: Cerebrus99 | last post by:
Hi all, I'm making a Windows application that does some lengthy retrieval operations from a database and possibly from a internet resource. I want to show that the operation is going on, by...
2
by: Robinson | last post by:
I can start an Asynchronous operation against a data source with SQLCommand.BeginExecuteReader, allowing me to loop, checking for user cancellation before the operation has completed, but how then...
34
by: Alan Larsson | last post by:
Is there a way i can look at the php code that is runnig a site, without any ind of admin access to the server?
0
by: Default User | last post by:
I work on creating test cases for a SOAP-based set of servers, using soapUI. I received and updated set of WSDL and schema files, and when I made new tests and mock server operations, all of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.