View Issue Details

IDProjectCategoryView StatusLast Update
00005921003.1(2008)/Issue 7Base Definitions and Headerspublic2024-06-11 08:52
Reportereblake Assigned Toajosey  
PrioritynormalSeverityObjectionTypeOmission
Status ClosedResolutionAccepted 
NameEric Blake
OrganizationRed Hat
User Referenceebb.timespec
Sectiontrace.h, others
Page Number426
Line Number14305
Interp Status---
Final Accepted Text
Summary0000592: consistent use of struct timespec
DescriptionMost headers that use struct timespec require that it be defined as in <time.h> (<aio.h> line 7210, <mqueue.h> line 9846, <pthread.h> line 10543, <sched.h> line 10756, <signal.h> line 10967, <sys/select.h> line 12650, <sys/stat.h> line 13044).

However, while <semaphore.h> permits the inclusion of <time.h> (line 10892), it does not require it and does not mandate that a forward reference to struct timespec be in place before the declaration of sem_timedwait(), which means that the declaration could be inadvertently declaring a pointer to a unique type if the headers are included in the wrong order. Worse, <trace.h> directly uses struct timespec (line 14264), but does not require either the type to exist nor the use of <time.h>. Both of these go against the goal of Issue 7 in making more headers self-contained.

Finally, a number of functions list the inclusion of <time.h> in their SYNOPSIS section, supposedly to guarantee the correct struct timespec, although this is redundant as demonstrated by the requirements listed above.
Desired ActionAfter line 10877 (XBD <semaphore.h> DESCRIPTION), add a paragraph:

The <semaphore.h> header shall define the struct timespec structure as described in <time.h>.

After line 14305 (XBD <trace.h> DESCRIPTION), add a paragraph:

The <trace.h> header shall define the struct timespec structure as described in <time.h>.

At line 14390 (XBD <trace.h> SEE ALSO), add a link to <time.h>.

Delete lines 43751-43752 (XSH mq_receive SYNOPSIS):
#include <mqueue.h>
#include <time.h>

Delete this sentence at line 43785 (XSH mq_receive DESCRIPTION):
The timespec argument is defined in the <time.h> header.

Delete lines 43849-43850 (XSH mq_send SYNOPSIS).
#include <mqueue.h>
#include <time.h>

Delete this sentence at line 43883 (XSH mq_send DESCRIPTION):
The timespec argument is defined in the <time.h> header.

Delete line 43979 (XSH mq_timedreceive SYNOPSIS):
#include <time.h>

Delete line 43989 (XSH mq_timedsend SYNOPSIS):
#include <time.h>

Delete line 47520 (XSH posix_trace_attr_getclockres SYNOPSIS):
#include <time.h>

Delete this sentence at line 48642 (XSH posix_trace_getnext_event DESCRIPTION):
The timespec data type is defined in the <time.h> header.

Delete line 52844 (XSH pthread_mutex_timedlock SYNOPSIS):
#include <time.h>

Delete this sentence at line 52857 (XSH pthread_mutex_timedlock DESCRIPTION):
The timespec data type is defined in the <time.h> header.

Delete line 53864 (XSH pthread_rwlock_timedrdlock SYNOPSIS):
#include <time.h>

Delete this sentence at line 53876 (XSH pthread_rwlock_timedrdlock DESCRIPTION):
The timespec data type is defined in the <time.h> header.

Delete line 53927 (XSH pthread_rwlock_timedwrlock SYNOPSIS):
#include <time.h>

Delete this sentence at line 53939 (XSH pthread_rwlock_timedwrlock DESCRIPTION):
The timespec data type is defined in the <time.h> header.

Delete line 58251 (XSH sem_timedwait SYNOPSIS):
#include <time.h>

Delete this sentence at line 58264 (XSH sem_timedwait DESCRIPTION):
The timespec data type is defined as a structure in the <time.h> header.
Tagsissue8

Activities

jim_pugsley

2013-05-30 14:09

manager   bugnote:0001627

According to comments in our version of semaphore.h:

 * Inclusion of <time.h> breaks X/Open and POSIX namespace.
 * The timespec structure while allowed in XPG6 and POSIX.1003d-1999,
 * is not permitted in prior POSIX or X/Open specifications even
 * though functions beginning with sem_* are allowed.

Issue History

Date Modified Username Field Change
2012-07-13 01:48 eblake New Issue
2012-07-13 01:48 eblake Status New => Under Review
2012-07-13 01:48 eblake Assigned To => ajosey
2012-07-13 01:48 eblake Name => Eric Blake
2012-07-13 01:48 eblake Organization => Red Hat
2012-07-13 01:48 eblake User Reference => ebb.timespec
2012-07-13 01:48 eblake Section => trace.h, others
2012-07-13 01:48 eblake Page Number => 426
2012-07-13 01:48 eblake Line Number => 14305
2012-07-13 01:48 eblake Interp Status => ---
2013-05-30 14:09 jim_pugsley Note Added: 0001627
2013-08-01 15:19 jim_pugsley Status Under Review => Resolved
2013-08-01 15:19 jim_pugsley Resolution Open => Accepted
2013-08-01 15:23 Don Cragun Tag Attached: issue8
2020-03-20 09:38 geoffclare Status Resolved => Applied
2024-06-11 08:52 agadmin Status Applied => Closed