From owner-svn-src-head@freebsd.org Thu Aug 3 08:24:44 2017 Return-Path: Delivered-To: svn-src-head@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 9BC24DD08D7; Thu, 3 Aug 2017 08:24:44 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 63FB86D099; Thu, 3 Aug 2017 08:24:44 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 3DE7842A7FA; Thu, 3 Aug 2017 17:53:45 +1000 (AEST) Date: Thu, 3 Aug 2017 17:53:43 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ngie Cooper cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321969 - in head/sys/boot: arm/at91/libat91 arm/ixp425/boot2 i386/boot2 In-Reply-To: <201708030527.v735R5dg041043@repo.freebsd.org> Message-ID: <20170803173421.C2203@besplex.bde.org> References: <201708030527.v735R5dg041043@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=KeqiiUQD c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=WiSNjSlbGeYnkCD5ExAA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 03 Aug 2017 08:24:44 -0000 On Thu, 3 Aug 2017, Ngie Cooper wrote: > Log: > Fix the return types for printf and putchar to match their libc and > POSIX equivalents > > Both printf and putchar return int, not void. > > This will allow code that leverages the libcalls and checks/rely on the > return type to interchangeably between loader code and non-loader > code. > > MFC after: 1 month > > Modified: > head/sys/boot/arm/at91/libat91/lib.h > head/sys/boot/arm/at91/libat91/printf.c > head/sys/boot/arm/at91/libat91/putchar.c > head/sys/boot/arm/ixp425/boot2/ixp425_board.c > head/sys/boot/arm/ixp425/boot2/lib.h > head/sys/boot/i386/boot2/boot2.c This is wrong for at least i386/boot2. It isn't part of the loader, and saves space by not returning unused values. > Modified: head/sys/boot/i386/boot2/boot2.c > ============================================================================== > --- head/sys/boot/i386/boot2/boot2.c Thu Aug 3 03:45:48 2017 (r321968) > +++ head/sys/boot/i386/boot2/boot2.c Thu Aug 3 05:27:05 2017 (r321969) > @@ -114,8 +114,8 @@ void exit(int); > static void load(void); > static int parse(void); > static int dskread(void *, unsigned, unsigned); > -static void printf(const char *,...); > -static void putchar(int); > +static int printf(const char *,...); > +static int putchar(int); These are freestanding static functions, so they have nothing to do with library functions except their name is a hint that they are similar. Since they are static, -funit-at-a-time might allow the unused return values to be optimized away. Then returning unused values would be just an obfuscation. This file still has a static memcpy() which is quite different from the libc version. It doesn't return an unused value, and its arg types are all different (no newfangled size_t or newerfangled restrict). Freestanding versions (static and otherwise) cause problems with builtins. -ffreestanding turns off all builtins. The static memcpy used to be ifdefed so as to use __builtin_memcpy instead of the static one if the compiler is gcc. That apparently broke with gcc-4.2, since the builtin will call libc memcpy() in some cases, although memcpy() is unavailable in the freestanding case. Bruce