From simonm@dcs.gla.ac.uk  Fri Feb 27 02:17:26 1998
Received: from vanuata (vanuata.dcs.gla.ac.uk [130.209.240.50])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA00624
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 27 Feb 1998 02:16:57 -0800 (PST)
          (envelope-from simonm@dcs.gla.ac.uk)
Received: from solander.dcs.gla.ac.uk (actually host solander) by vanuata 
          with SMTP (MMTA) with ESMTP; Fri, 27 Feb 1998 10:16:15 +0000
Received: (from simonm@localhost)	by solander.dcs.gla.ac.uk (8.8.7/8.8.7) 
          id KAA07921;	Fri, 27 Feb 1998 10:16:11 GMT
Message-Id: <199802271016.KAA07921@solander.dcs.gla.ac.uk>
Date: Fri, 27 Feb 1998 10:16:11 GMT
From: Simon Marlow <simonm@dcs.gla.ac.uk>
Reply-To: Simon Marlow <simonm@dcs.gla.ac.uk>
To: FreeBSD-gnats-submit@freebsd.org
Subject: /usr/include/sys/time.h and _POSIX_SOURCE don't mix
X-Send-Pr-Version: 3.2

>Number:         5866
>Category:       bin
>Synopsis:       can't include <sys/time.h> with _POSIX_SOURCE defined
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bde
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 27 02:20:01 PST 1998
>Closed-Date:    Tue Apr 7 04:59:25 PDT 1998
>Last-Modified:  Tue Apr  7 05:02:07 PDT 1998
>Originator:     Simon Marlow
>Release:        FreeBSD 3.0-CURRENT (25 Feb)
>Organization:
University of Glasgow
>Environment:

3.0-CURRENT only, stable doesn't have this problem.

>Description:

<sys/time.h> uses some types from <sys/types.h> which aren't defined
under _POSIX_SOURCE, and doesn't protect the relevant sections with
#ifndef _POSIX_SOURCE.

>How-To-Repeat:

$ cat >test.c
#define _POSIX_SOURCE
#include <sys/time.h>
^D
$ gcc test.c
In file included from test.c:2:
/usr/include/sys/time.h:120: parse error before `timecounter_get_t'
/usr/include/sys/time.h:120: warning: data definition has no type or storage class
/usr/include/sys/time.h:125: parse error before `timecounter_get_t'
/usr/include/sys/time.h:125: warning: no semicolon at end of struct or union
/usr/include/sys/time.h:142: parse error before `}'

>Fix:

I don't have access to the POSIX spec, so I have no idea what the
right thing to do is.  Here's a guess:

*** time.h~	Wed Feb 25 16:47:38 1998
--- time.h	Fri Feb 27 10:02:46 1998
***************
*** 116,121 ****
--- 116,123 ----
   *     called attoseconds, it comes from "atten" for 18 in Danish/Swedish.
   */
  
+ #ifndef _POSIX_SOURCE
+ 
  struct timecounter;
  typedef u_int timecounter_get_t __P((struct timecounter *));
  typedef	u_int64_t timecounter_delta_t __P((void));
***************
*** 140,145 ****
--- 142,148 ----
  	struct timecounter	*other;
  	struct timecounter	*tweak;
  };
+ #endif /* !_POSIX_SOURCE */
  
  /* Operations on timevals. */
  #define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: jkh 
Responsible-Changed-When: Fri Feb 27 02:57:41 PST 1998 
Responsible-Changed-Why:  
bde was probably the last person in here. 

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@freebsd.org, simonm@dcs.gla.ac.uk
Cc:  Subject: Re: bin/5866: /usr/include/sys/time.h and _POSIX_SOURCE don't mix
Date: Sat, 28 Feb 1998 12:28:56 +1100

 >>Description:
 >
 ><sys/time.h> uses some types from <sys/types.h> which aren't defined
 >under _POSIX_SOURCE, and doesn't protect the relevant sections with
 >#ifndef _POSIX_SOURCE.
 >
 >>How-To-Repeat:
 >
 >$ cat >test.c
 >#define _POSIX_SOURCE
 >#include <sys/time.h>
 
 >>Fix:
 >
 >I don't have access to the POSIX spec, so I have no idea what the
 >right thing to do is.  Here's a guess:
 
 The right thing is to not define _POSIX_SOURCE in your application.
 <sys/types.h> is not a POSIX header, so source code that includes it
 is not POSIX conformant.  Including it just happened to not cause
 any problems.
 
 Other important application headers that break for the same reason
 when included with _POSIX_SOURCE defined: <sys/socket.h>,
 <sys/sysctl.h>.
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: bde 
State-Changed-When: Tue Apr 7 04:59:25 PDT 1998 
State-Changed-Why:  
Bug for bug compatibility was restored in rev.1.21 of sys/time.h. 
>Unformatted:
