Report 1612 Actions
Problem Report Number |
1612 |
Submitter's Classification |
Specification problem |
State |
Resolved |
Resolution |
Permanent Interpretation (PIN) |
Problem Resolution ID |
PIN.X.0169 |
Raised |
1996-08-09 08:00 |
Updated |
2003-03-13 08:00 |
Published |
1996-09-11 08:00 |
Product Standard |
Internationalised System Calls and Libraries Extended (UNIX 95) |
Certification Program |
The Open Brand certification program |
Test Suite |
VSU version 4.1.0 |
Test Identification |
CAPI.hdr/misc/time-sys 29 31 33 |
Specification |
System Interfaces and Libraries Issue 4 Version 2 |
Location in Spec |
See Problem Text |
Problem Summary |
PIN4U.00035 This test may fail on implementations which evaluate the first argument to FD_SET, FD_CLR, or FD_ISSET more than once. |
Problem Text |
In our implementation, the first arguments of the macros FD_SET, FD_CLR, and FD_ISSET in <sys/time.h> are each evaluated more than once. XPG4, Version 2 specification while not explicitly disallowing this, references the ISO C standard which makes the following statement in section titled "Use of Library Functions":
Any invocation of a library function that is implemented as a macro shall expand to code that evaluates each of its arguments exactly once, fully protected by parentheses where necessary, so it is generally safe to use arbitrary expressions as arguments.
The tests are testing this requirement. The problem is that historically, these have been implemented as macros and these macros have always evaluated the first arguments more than once. Note that though the C standard makes a requirement with respect to argument evaluation for macros, there are exceptions within the C standard itself. The following statement is taken from the description for the putc function:
The putc function is equivalent to fputc except that if it is implemented as a macro, it may evaluate stream more than once...
A similar statement exists for the getc function.
Although the description for select() states that it is unspecified whether or not FD_CLR, FD_ISSET, FD_SET, or FD_ZERO are implemented as macros or functions, the description for <sys/time.h> states that each of these be defined as macros. Given historical practice and the fact that the C standard has made exceptions with regard to the evaluation of macro arguments, we believe that an exception is warranted in this case as well.
|
Test Output |
TEST CASE: sys/time.h
TEST PURPOSE #29 If the macro void FD_SET(int fd, fd_set *fdset) is defined in sys/time.h it shall evaluate each of its arguments exactly once, fully protected by parentheses where necessary, and return void. TEST: Argument evaluation ERROR: Argument 1 of FD_SET evaluated 2 times 29 FAIL
TEST PURPOSE #31 If the macro void FD_CLR(int fd, fd_set *fdset) is defined in sys/time.h it shall evaluate each of its arguments exactly once, fully protected by parentheses where necessary, and return void. TEST: Argument evaluation ERROR: Argument 1 of FD_CLR evaluated 2 times 31 FAIL
TEST PURPOSE #33 If the macro int FD_ISSET(int fd, fd_set *fdset) is defined in sys/time.h it shall evaluate each of its arguments exactly once, fully protected by parentheses where necessary, and return a value of the correct type. TEST: Argument evaluation ERROR: Argument 1 of FD_ISSET evaluated 2 times TEST: Return protection TEST: Return type 33 FAIL
|
Review Information
Review Type |
TSMA Review |
Start Date |
null |
Completed |
null |
Status |
Complete |
Review Recommendation |
No Resolution Given |
Review Response |
We recommend this request be refused.
PG4U.00032 and 1170 base resolution #33 have already addressed this issue.
BR# 1170/33 states
REQUEST:
Traditional implementations of the FD_SET, FD_CLR, FD_ISSET macros evaluate their first argument more than once.
In the absence of further information from the specification the test suite assumes that the macros should only evaluate their arguments once and flag existing inplementations as being non-compliant.
We belive the specification should be changed to allow existing practice.
X/OPEN RESOLUTION:
If macro versions of these functions are provided they must evaluate their arguments only once. This is an ISO C requirement.
The only additional information this request adds is that the C spec allows putc and getc to scan their second arguments more than once. We do not believe this adds any weight to the submitter's argument. The XSH spec also specifically allows these functions to scan these arguments more than once, but makes no such allowance for any arguments to the FD_* macros.
|
Review Type |
SA Review |
Start Date |
null |
Completed |
null |
Status |
Complete |
Review Resolution |
No Resolution Given |
Review Conclusion |
Traditionally these functions have been provided as macros only with no underlying functions. A waiver is grantd to permit traditional behaviour.
|
Review Type |
SA Review |
Start Date |
null |
Completed |
null |
Status |
Complete |
Review Resolution |
Permanent Interpretation (PIN) |
Review Conclusion |
A Permanent Interpretation is granted.
|
Problem Reporting System Options:
|