From owner-svn-src-head@freebsd.org Mon Jun 11 09:22:42 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 568761005134; Mon, 11 Jun 2018 09:22:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C517378E36; Mon, 11 Jun 2018 09:22:41 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTP id w5B9MUJb001691; Mon, 11 Jun 2018 12:22:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w5B9MUJb001691 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w5B9MUQD001690; Mon, 11 Jun 2018 12:22:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 11 Jun 2018 12:22:30 +0300 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r334928 - head/lib/libc/stdlib Message-ID: <20180611092230.GB1939@kib.kiev.ua> References: <201806101754.w5AHsi4r061028@repo.freebsd.org> <20180611141715.W1182@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180611141715.W1182@besplex.bde.org> User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 09:22:42 -0000 On Mon, Jun 11, 2018 at 03:48:52PM +1000, Bruce Evans wrote: > Change TYPE to unsigned char[sizeof(old TYPE)] and use memcpy() to assign > the variables to fix this with small churn and without the pessimizations > in this commit. This gives portable code back to K&R1978 + memcpy(), and > is as efficient as the above when the above works. On x86, even gcc-3.3 > produces a load and store for memcpy(p, q, sizeof(register_t)) when p and > q are void *. > > Change TYPE to unsigned char[n] and use a single memcpy() without a loop > to assign the variables to fix this with larger churn and with different > (smaller?) pessimizations than in this commit. Setup and initialization > for this method is also simpler. This uses the newfangled VLA feature, > and since n is variable for qsort(), builtin memcpy() with length n > doesn't work so well. Either results in the unacceptable stack use. I can limit the char[es] and memcpy to some value of es, but I do not see a point. I will not object if somebody decides to do it.