From owner-freebsd-hackers@freebsd.org Wed Dec 27 06:35:43 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B24FEEA6D8C for ; Wed, 27 Dec 2017 06:35:43 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22d.google.com (mail-it0-x22d.google.com [IPv6:2607:f8b0:4001:c0b::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 748717A01C for ; Wed, 27 Dec 2017 06:35:43 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22d.google.com with SMTP id o130so26963466itg.0 for ; Tue, 26 Dec 2017 22:35:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ZDGUsUaW7+ALSUdU+kprYuCJHWKDTRmmggbhYhM/Ss0=; b=1mDV/t2iKuHNNxejIZUaf+z8zcf1UANKqXVWeQobbVrZAWnkkV5vSBBRH64a5FVy9e aU2t20ZXPZJzxVJMQ/JbVybhqnapKSkkwvs+YR8mh9agkl1FN85FBsF6SZS+tZ93hd1a 6HjpvPDmqmHE4EbvJ0IWaf87IYgn5M5Zi+7nJo903YDPTudGc7Y1t6ix9pVYbZA2680j /4WxnLCgk8CgAi5FuqilNxYZsKkTh2RiNOhtN088fKSTvk/6WtO4cbnnWp2b+ikDrHlj GuAp2GMeFx7XsS+qaXSI+pC0j5zGtRMHc4p+gjf/aB8GuJsK8TVUysCDD+heU2T6tUAE 3Byw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ZDGUsUaW7+ALSUdU+kprYuCJHWKDTRmmggbhYhM/Ss0=; b=syNtj2OGYc3s+Nl2EmrAlSX47t411eAnrVmFrZSBHqwaJz7sBRyP0oSbOh3p2Ac66j BieSYx9sCN6cELdAPtkddf7KsWhFSTkJx4RcJihd2kwIr3Z2ufujPLsDa+YplENxGriv In9tF2cuOG7sORwHeWnv41AdrGBce9aVHRPj/mRLbSfYreUonjrXJNnR+nFNMNLQkgAJ T+MyTiYYhcrRKrwvkParSMJ8B2Hk9Wk6ZlSZzQa+QxtLlP6uFHciDAjBDhhzFNrqfLKm LPROkuh4gOXfb08KlNirVZ3rTTXMObdnc3zJHczl6WS8hyPYhsHHCLgDF5tanxnviUxm xSNA== X-Gm-Message-State: AKGB3mJFvTVeRvvHpXCqF6nvceRhiUcowkM3X8+8haMK0VCpYAOeKj5n q5hRwNSj5YcGT/mli/8d4ourTmfbq7s9fxIMfSiPig== X-Google-Smtp-Source: ACJfBosMOXTDpIb7LKStwUFGR+X24eRJeYtzFtajlBlwvagyLWQ7MIy0ahrtbyLGcMG9tqg6ykg0VkQd9+SId+zdaeA= X-Received: by 10.36.131.200 with SMTP id d191mr35501702ite.97.1514356542608; Tue, 26 Dec 2017 22:35:42 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.108.204 with HTTP; Tue, 26 Dec 2017 22:35:41 -0800 (PST) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: References: From: Warner Losh Date: Tue, 26 Dec 2017 23:35:41 -0700 X-Google-Sender-Auth: b9RVjVil_yev473JDZ68BUIKqxE Message-ID: Subject: Re: Parsing a comment in stdlib.h To: Alan Somers Cc: Eitan Adler , FreeBSD Hackers , gwollman@freebsd.org, Benno Rice Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Dec 2017 06:35:43 -0000 I find the proposed comment less clear. In fact, I'd go so far as to say its brevity makes it misleadingly wrong. It turns out that __LONG_LONG_SUPPORTED is switchable via compiler flags (in both gcc and clang), hence the need to have these #ifdefs in a standard file. gcc -ansi accepts long long with a warning, but does define __STRICT_ANSI__ so you can create warning free code. All of this happens far away from stdlib.h in sys/cdefs.h: #if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 #define __LONG_LONG_SUPPORTED #endif clang defines __GNUC__ so that __LONG_LONG_SUPPORTED is identical to gcc in the brief testing I just did. One should really read "if the compiler supports 'long long'" as "if the compiler is invoked in a mode that supports long long without generating warnings" It's removal critically changes the meaning here, fatally so I'm afraid. The new text is of absolutely no help because in c89 mode, long long is supported and __LONG_LONG_SUPPORTED is defined. All this nuance is lost, and it's more than mere quibbles. I'd be tempted to leave it along because a full explanation would be quite verbose. Warner On Tue, Dec 26, 2017 at 9:05 PM, Alan Somers wrote: > I would say that your proposed change makes it less clear. For one thing, > it's not clear whether those three bullet points are meant to be ANDed or > ORed. For another, I'm not sure why you removed the part about "long > long". Finally, s/its/it's/. Frankly, I think the comment can just be > shortened to "C99 functions". GCC and Clang both support "long long". Are > there any external compilers that don't? > > On Tue, Dec 26, 2017 at 8:18 PM, Eitan Adler wrote: > > > Hi all, > > > > I'm trying to understand a visibility comment in stdlib.h. Is the > > following change technically correct? > > Can it be made more clear? > > > > Index: include/stdlib.h > > =================================================================== > > --- include/stdlib.h (revision 327228) > > +++ include/stdlib.h (working copy) > > @@ -120,8 +120,10 @@ int wctomb(char *, wchar_t); > > size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); > > > > /* > > - * Functions added in C99 which we make conditionally available in the > > - * BSD^C89 namespace if the compiler supports `long long'. > > + * Functions added in C99 which we make available if > > + * - its C99 > > + * - BSD visible and not C89 > > + * - its C++ > > * The #if test is more complicated than it ought to be because > > * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long' > > * is not supported in the compilation environment (which therefore > means > > > > > > -- > > Eitan Adler > > _______________________________________________ > > freebsd-hackers@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@ > freebsd.org" > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >