From adsharma@sharmas.dhs.org  Tue Sep  4 09:13:26 2001
Return-Path: <adsharma@sharmas.dhs.org>
Received: from snipe.mail.pas.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62])
	by hub.freebsd.org (Postfix) with ESMTP id 3064F37B40F
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  4 Sep 2001 09:13:26 -0700 (PDT)
Received: from sharmas.dhs.org (cpe-66-1-147-119.ca.sprintbbd.net [66.1.147.119])
	by snipe.mail.pas.earthlink.net (8.11.5/8.9.3) with ESMTP id f84GDPT16703
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 4 Sep 2001 09:13:25 -0700 (PDT)
Received: (from adsharma@localhost)
	by sharmas.dhs.org (8.11.5/8.11.3) id f84GC4O00694;
	Tue, 4 Sep 2001 09:12:04 -0700 (PDT)
	(envelope-from adsharma)
Message-Id: <200109041612.f84GC4O00694@sharmas.dhs.org>
Date: Tue, 4 Sep 2001 09:12:04 -0700 (PDT)
From: Arun Sharma <arun@sharmas.dhs.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Inability to compile programs defining _POSIX_SOURCE
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         30317
>Category:       bin
>Synopsis:       Inability to compile programs defining _POSIX_SOURCE
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 04 09:20:01 PDT 2001
>Closed-Date:    Wed Nov 21 21:43:27 PST 2001
>Last-Modified:  Sun Nov 25 02:50:00 PST 2001
>Originator:     Arun Sharma
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD astra.mirabella.net 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Sat Aug 11 01:55:44 PDT 2001 root@astra.mirabella.net:/usr.current/src/sys/i386/compile/astra i386


>Description:
	When a POSIX compliant program uses <sys/socket.h>, it gets 
 	compilation errors. The justification for this I've heard in the
	past is that POSIX doesn't include sockets. However, precluding
	all POSIX compliant programs from using sockets is not a good idea,
	in my opinion.

>How-To-Repeat:
	Compile this program:

	#include <sys/types.h>
	#include <sys/socket.h>
	main() {}

	with -D_POSIX_SOURCE
>Fix:

Apply the patch below.

$ diff -u /usr/include/sys/types.h- /usr/include/sys/types.h
--- /usr/include/sys/types.h-   Tue Sep  4 09:04:56 2001
+++ /usr/include/sys/types.h    Tue Sep  4 09:05:15 2001
@@ -48,14 +48,12 @@
 #include <sys/inttypes.h>              /* includes <machine/ansi.h> */
 #include <machine/types.h>
 
-#ifndef _POSIX_SOURCE
 typedef        unsigned char   u_char;
 typedef        unsigned short  u_short;
 typedef        unsigned int    u_int;
 typedef        unsigned long   u_long;
 typedef        unsigned short  ushort;         /* Sys V compatibility */
 typedef        unsigned int    uint;           /* Sys V compatibility */
-#endif
 
 typedef __uint8_t      u_int8_t;
 typedef __uint16_t     u_int16_t;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: dd 
Responsible-Changed-When: Thu Sep 6 01:35:11 PDT 2001 
Responsible-Changed-Why:  
misfiled 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30317 

From: <jkoshy@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/30317: nability to compile programs defining _POSIX_SOURCE
Date: Wed, 21 Nov 2001 21:36:07 -0800 (PST)

 If `_POSIX_SOURCE' is defined the system has to make visible the
 same namespace as permitted and required by IEEE Std 1003.1-1990,
 nothing more, nothing less.
 
 Your patch would make `u_char' .. `uint' visible to programs even
 if `_POSIX_SOURCE'  were defined, which would cause portable programs
 to break.
 
 If you need to use <sys/socket.h>, then by definition your code
 falls outside of the gambit defined by the POSIX standard, so you
 should not be defining `_POSIX_SOURCE'.
 
 Incidentally, the `_POSIX_SOURCE' feature test macro is deprecated;
 `_POSIX_C_SOURCE' is recommended and can be given a numeric value
 corresponding to revision of the POSIX standard desired.
 
 Regards,
 Koshy
 <jkoshy@freebsd.org>
State-Changed-From-To: open->closed 
State-Changed-By: jkoshy 
State-Changed-When: Wed Nov 21 21:43:27 PST 2001 
State-Changed-Why:  
Seems to be a misunderstanding on how defining 
`_POSIX_SOURCE' is required to change the behaviour of  
the C compilation system.   

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30317 

From: Bruce Evans <bde@zeta.org.au>
To: <jkoshy@FreeBSD.ORG>
Cc: <freebsd-gnats-submit@FreeBSD.ORG>
Subject: Re: bin/30317: nability to compile programs defining _POSIX_SOURCE
Date: Sun, 25 Nov 2001 21:46:39 +1100 (EST)

 On Wed, 21 Nov 2001 jkoshy@FreeBSD.ORG wrote:
 
 >  If you need to use <sys/socket.h>, then by definition your code
 >  falls outside of the gambit defined by the POSIX standard, so you
 >  should not be defining `_POSIX_SOURCE'.
 
 Correct for the 1990 standard.
 
 >  Incidentally, the `_POSIX_SOURCE' feature test macro is deprecated;
 >  `_POSIX_C_SOURCE' is recommended and can be given a numeric value
 >  corresponding to revision of the POSIX standard desired.
 
 POSIX.1-200x-draft7 has <sys/socket.h>, and for strict conformance,
 _POSIX_C_SOURCE has to be defined as 200xxxL before including any
 header.  So the PR mostly applies to POSIX.1-200x.
 
 Bruce
 
>Unformatted:
