Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp264541pxy; Wed, 5 May 2021 01:25:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF5GzrfEZ3US/2G52EJ6Yr2GvK67C1H9plu6byM9mx9J1w/BPECA5x/2FTzUfOBOW+Si5N X-Received: by 2002:a65:6256:: with SMTP id q22mr10574781pgv.391.1620203101322; Wed, 05 May 2021 01:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620203101; cv=none; d=google.com; s=arc-20160816; b=QsQ16/kcRM0eV/Dhcpf28i7OPDHm4uzFHre+9/s5hinz2Pgx11Sv96I5zRkvjd1vk6 axzMzCpvnrPALTYuANDb/QFgY+DfARCy3u+q/rq/wafiKyS8nSOJKlHDwbaK+Pap+ckJ N0dRu96G787WtymqeO5g9+Ffcg5tHkSzql03ZTSdkqbC15bH1obD3RsUi0nQ4Lb5QwbY 6YPyZ7gPsbOaDHDYldgN8PDuJ4GFH8l9Pq9nFay+EqmYw+HXrNHqjEQkyqlY2UC6uDQI nNsAJxeoimOAFl9R2dtUWacx8AmYnORfQxuYrzzzZtY3+ErwwtBVrOurPAzdLh/YtMzV 0EBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=Wldo9Sr5q+daZetciMYO7FGx7QOjRICxzm3izwlVP1E=; b=nUCXKdFYms3Mt3jepD+HxmqFE8MRM/JjthNnfr0GQsMN8IKFL0EcnJDwishgHEJO61 Jh5c2CiJwxuUAbmakxc+6rnawiL3OOBewarKVO5IGWqlGs6ky8DkrIyb7Bf+8hwC2s+d cen92rY3U3vJ6KDMdAaacvUP/EPJYu9aqBRQP7f0zSyPHEuxYGuhou5ASMP/xU2XUDfg vaA9p8HpACF2hd99bjT7rvngzpGFeu8b517zWU8I1vr2Iw5qji+kkBY4PEaD6r2HdH7m 8N/XwC/bXD9UYNb3hxxPdGb17UGPYbTowLBYk4hiEig3Ppt3wBdz+p3iZyy164T15/QZ H/4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si6033141plg.367.2021.05.05.01.24.48; Wed, 05 May 2021 01:25:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbhEEIZA convert rfc822-to-8bit (ORCPT + 99 others); Wed, 5 May 2021 04:25:00 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]:57394 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbhEEIY6 (ORCPT ); Wed, 5 May 2021 04:24:58 -0400 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-246-t31SIAGZMKGhnCVP98Zw3A-1; Wed, 05 May 2021 09:23:55 +0100 X-MC-Unique: t31SIAGZMKGhnCVP98Zw3A-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 May 2021 09:23:55 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.015; Wed, 5 May 2021 09:23:55 +0100 From: David Laight To: 'Florian Weimer' , "Alejandro Colomar (man-pages)" CC: Zack Weinberg , Greg KH , Daniel Borkmann , Alexei Starovoitov , "Michael Kerrisk (man-pages)" , linux-man , LKML , glibc , GCC , bpf , Joseph Myers Subject: RE: [RFC v2] bpf.2: Use standard types and attributes Thread-Topic: [RFC v2] bpf.2: Use standard types and attributes Thread-Index: AQHXQR4JneAG95ru70e6btooWxCDq6rUiRug Date: Wed, 5 May 2021 08:23:55 +0000 Message-ID: References: <20210423230609.13519-1-alx.manpages@gmail.com> <20210504110519.16097-1-alx.manpages@gmail.com> <69fb22e0-84bd-47fb-35b5-537a7d39c692@gmail.com> <6740a229-842e-b368-86eb-defc786b3658@gmail.com> <87r1imgu5g.fsf@oldenburg.str.redhat.com> In-Reply-To: <87r1imgu5g.fsf@oldenburg.str.redhat.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Weimer > Sent: 04 May 2021 20:46 > > * Alejandro Colomar: > > > The thing is, in all of those threads, the only reasons to avoid > > types in the kernel (at least, the only explicitly > > mentioned ones) are (a bit simplified, but this is the general idea of > > those threads): > > > > * Possibly breaking something in such a big automated change. > > * Namespace collision with userspace (the C standard allows defining > > uint32_t for nefarious purposes as long as you don't include > > . POSIX prohibits that, though) > > * Uglier > > __u64 can't be formatted with %llu on all architectures. That's not > true for uint64_t, where you have to use %lu on some architectures to > avoid compiler warnings (and technically undefined behavior). There are > preprocessor macros to get the expected format specifiers, but they are > clunky. I don't know if the problem applies to uint32_t. It does > happen with size_t and ptrdiff_t on 32-bit targets (both vary between > int and long). uint32_t can be 'randomly' either int or long on typical 32bit architectures. The correct way to print it is with eg "xxx %5.4" PRI_u32 " yyy". Typed like ptrdiff_t and size_t exist because of things like the x86 segmented model. Pointers are 32bit (segment and offset), size_t is (probably) 16 bit (nothing can be any bigger), but ptrdiff_t has to be 32bit to contain [-65535 .. 65535]. Kernel code has used u8, u16 and u32 since well before the standards body even thought about fixed width types (and well before Linux). ISTR they were considered as the standard names, but rejected and the current definitions approved. They were probably too worried about code already using u32 for a variable. (Shame they never fixed math.h) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)