Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1302306pxa; Sat, 15 Aug 2020 15:04:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc9ecpD1J3w0Sex/twtZhGoUScRP+KcqRaIxvZvAqiWCd3OGsG1h7Wckl1z+qVmAFt1Su2 X-Received: by 2002:a17:906:1911:: with SMTP id a17mr7978004eje.431.1597529085464; Sat, 15 Aug 2020 15:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597529085; cv=none; d=google.com; s=arc-20160816; b=Adi0OwPluOhR/iNGCOhJ9vzHUmeSumjDYEUARyBVqvk3U/Fq0+qywcmVLggwOnuSBC I51bVhf1gN4ApSz9PDKDW7eEM7ltz1yKoaElD3pU6Efga1blZU9Ncytedj3y0dsW5NNd huxw/qfNrDz5KlndbHhpm89FQBrg4SeXcCCeSESMPb/vbOAvfsunQkoWdXdRgD2jsChZ VwE3IlKsD2bI1T79gTuPYN/cNtKkAlAkNiiyofAM6dZiaT2QSb6OtBw6hWjGB0oGa3uG QApiXbdpekfoLGKz/RlKgxx0iITPy8cp63MYh3nggLFRZAf/kv2EJXYGyTczOFdlsyX5 4mGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=elMrilSLXI6b7aYlKVZpaKDCZnCipuhXfzdMESlljx4=; b=T7taEFSAwgPl3S6cyLIfIGG0JRbBNlPdMQbbN3i4E+eAooU78dzR1Mv+9Z8Sja2Q9n Kt3YG1Ul58KwNuJKQKAKWWvGJy9NWqdu4IW9OhGV5LdOF5Iv+jSOdgG+FIXFqBxHuwKW hreEqlrN3RpjDbgWdCeoa1gR12I7WdwFUr6FQ+yFKREWEXbNKgoSELmlWZMy/ave6in+ 6aB/UNQfNln20m9zUF3oiQKRir7LRURI4kYcp6cXZDSR7vy5Hhhr7Fn0gD22hwaeomk1 fjiGJOQHbSdHOc6LRr+N7mZ54zPw0yvJItcYROriakI8cRgiZ4+HgfYoR081+OPk8sXG nlLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PeLFqURv; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ov30si7700279ejb.181.2020.08.15.15.04.22; Sat, 15 Aug 2020 15:04:45 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=PeLFqURv; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729388AbgHOWBY (ORCPT + 99 others); Sat, 15 Aug 2020 18:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728798AbgHOVva (ORCPT ); Sat, 15 Aug 2020 17:51:30 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7835C061350 for ; Fri, 14 Aug 2020 19:00:35 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k13so4954243plk.13 for ; Fri, 14 Aug 2020 19:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=elMrilSLXI6b7aYlKVZpaKDCZnCipuhXfzdMESlljx4=; b=PeLFqURvd92pEiF6Mj5L1v1twm8KmHeCGT5FIUueuiePqXC/2SmG8X8wnJdCAvoIMF KBT1wvqHoqpL5j0WDX0ITEnjU+oLOV3CiB72ng3+Obta5Y7ld8+oYs4EO/mBUzjiyFvi z0uWLCjbBqWiMYG+AQi4Vw2rbLXCjmg86TOHvoZzdgZS2eHot7znULGD970HG2GgHWTS YHBgZCv60OtMpqCL+406elAO7tlZMekOZ3JwLSlD9NXsv9gftMbi/I41LKy7I7cZiloO iBZ3LenMuMHyqsmaKE3teY8bEw1j3TCBYD/bdFSe3gq1So0jmDCnm44iPKDgGjeqUfxb 3ecw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=elMrilSLXI6b7aYlKVZpaKDCZnCipuhXfzdMESlljx4=; b=UW0wRWvlfn0BquPXc4o30EgC+RhsUhIcdFz+Iy3F6EiltlnxaTfHz36CRfl/4Y+lO9 +ms6aBHsdNQnPenzESkX8lv9dDpZdDuTKhmpOqx7rVN2v4euRMjIqlPflQ/2uhwyVqxm QMMrSMp9Dv7Arzq9RHaU4o6ZyL2mnzNC0/GErq73joF0oI1jebpEZqX1rmOHB1yTf/Oh inGr9WXXWJ/3ygSspmGIVs+JpuBVWM9a+7K+IfyXu/ki/MV7e8AOHBxlOL8t+I84SDB4 qbT/vZbvOuBQckAvw36Rtj5ZANbKitLM+z56QF71TRSOoVxn1DIL7r6rhWx2oXJdnEZL ZMOw== X-Gm-Message-State: AOAM531b79BPgAEiATT2kG6i2oaqFzXM7Ea2w/UEds+N7XWToblfBhZk 5jZ133x+ZJhoB5QpPcBEGwfIYxE2gEg2Ubhy6pj2EQ== X-Received: by 2002:a17:902:8509:: with SMTP id bj9mr3855029plb.179.1597456834421; Fri, 14 Aug 2020 19:00:34 -0700 (PDT) MIME-Version: 1.0 References: <20200815002417.1512973-1-ndesaulniers@google.com> <562003af51ca0b08f2108147b8d6e75cec18f3fd.camel@perches.com> In-Reply-To: <562003af51ca0b08f2108147b8d6e75cec18f3fd.camel@perches.com> From: Nick Desaulniers Date: Fri, 14 Aug 2020 19:00:22 -0700 Message-ID: Subject: Re: [PATCH] lib/string.c: implement stpcpy To: Joe Perches Cc: Andrew Morton , =?UTF-8?B?RMOhdmlkIEJvbHZhbnNrw70=?= , Eli Friedman , "# 3.4.x" , Sami Tolvanen , Tony Luck , Yury Norov , Daniel Axtens , Arvind Sankar , Dan Williams , "Joel Fernandes (Google)" , Andy Shevchenko , Kees Cook , Alexandru Ardelean , LKML , clang-built-linux Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 14, 2020 at 5:52 PM Joe Perches wrote: > > On Fri, 2020-08-14 at 17:24 -0700, Nick Desaulniers wrote: > > LLVM implemented a recent "libcall optimization" that lowers calls to > > `sprintf(dest, "%s", str)` where the return value is used to > > `stpcpy(dest, str) - dest`. This generally avoids the machinery involved > > in parsing format strings. > [] > > diff --git a/include/linux/string.h b/include/linux/string.h > [] > > @@ -31,6 +31,9 @@ size_t strlcpy(char *, const char *, size_t); > > #ifndef __HAVE_ARCH_STRSCPY > > ssize_t strscpy(char *, const char *, size_t); > > #endif > > +#ifndef __HAVE_ARCH_STPCPY > > +extern char *stpcpy(char *__restrict, const char *__restrict__); > > Why use two different forms for __restrict and __restrict__? > Any real reason to use __restrict__ at all? Bah, sorry, I recently enabled some setting in my ~/.vimrc to help me find my cursor better: " highlight cursor set cursorline set cursorcolumn Turns out this makes it pretty difficult to see underscores, or the lack thereof. Will fix up. > > It's used nowhere else in the kernel. > > $ git grep -w -P '__restrict_{0,2}' > scripts/genksyms/keywords.c: // According to rth, c99 defines "_Bool", __restrict", __restrict__", "restrict". KAO > scripts/genksyms/keywords.c: { "__restrict__", RESTRICT_KEYW }, > > -- Thanks, ~Nick Desaulniers