NetBSD Problem Report #57806

From www@netbsd.org  Mon Jan  1 19:25:56 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 428E21A9238
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  1 Jan 2024 19:25:56 +0000 (UTC)
Message-Id: <20240101192525.72E281A9239@mollari.NetBSD.org>
Date: Mon,  1 Jan 2024 19:25:25 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: #include <arpa/inet.h> fails to define htonl/htons/ntohl/ntohs under _POSIX_C_SOURCE=200809L
X-Send-Pr-Version: www-1.0

>Number:         57806
>Category:       standards
>Synopsis:       #include <arpa/inet.h> fails to define htonl/htons/ntohl/ntohs under _POSIX_C_SOURCE=200809L
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    standards-manager
>State:          needs-pullups
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 01 19:30:00 +0000 2024
>Closed-Date:    
>Last-Modified:  Mon Sep 09 15:25:01 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The <arpa/inet.h> Foundation
>Environment:
>Description:
POSIX and NetBSD both document htonl/htons/ntohl/ntohs as being provided by #include <arpa/inet.h>, but this doesn't provide them when _POSIX_C_SOURCE is defined to be 200809L.
>How-To-Repeat:
$ cat pr.c
#define	_POSIX_C_SOURCE	200809L
#include <arpa/inet.h>
int myntohl(int x) { return ntohl(x); }
$ make pr.o
cc -O2   -c pr.c
pr.c: In function ‘myntohl’:
pr.c:3:29: warning: implicit declaration of function ‘ntohl’; did you mean ‘myntohl’? [-Wimplicit-function-declaration]
 int myntohl(int x) { return ntohl(x); }
                             ^~~~~
                             myntohl
>Fix:
Yes, please!

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Mon, 09 Sep 2024 15:23:40 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-10 and pullup-9


From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57806 CVS commit: src/sys/sys
Date: Mon, 9 Sep 2024 15:22:50 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Mon Sep  9 15:22:50 UTC 2024

 Modified Files:
 	src/sys/sys: endian.h

 Log Message:
 arpa/inet.h: Define htonl &c. under _POSIX_C_SOURCE >= 200112L too.

 These do not require _XOPEN_SOURCE as of POSIX 2001:

 https://pubs.opengroup.org/onlinepubs/009696799/functions/htonl.html

 XXX Since this change is actually sys/endian.h, in principle it might
 bleed into header files than just arpa/inet.h.  But sys/endian.h is
 not used by anything that looks especially risky to me.

 PR standards/57806: #include <arpa/inet.h> fails to define
 htonl/htons/ntohl/ntohs under _POSIX_C_SOURCE=200809L


 To generate a diff of this commit:
 cvs rdiff -u -r1.32 -r1.33 src/sys/sys/endian.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.