From: Paul Cercueil <paul@crapouillou.net>
To: David Laight <David.Laight@ACULAB.COM>
Cc: "'Maciej W. Rozycki'" <macro@orcam.me.uk>,
"Jiri Slaby" <jslaby@suse.cz>,
"'Uwe Kleine-König'" <u.kleine-koenig@pengutronix.de>,
gregkh@linuxfoundation.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Mateusz Holenko" <mholenko@antmicro.com>,
"Neil Armstrong" <narmstrong@baylibre.com>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Baruch Siach" <baruch@tkos.co.il>,
linux-kernel@vger.kernel.org, "Paul Mackerras" <paulus@samba.org>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Michal Simek" <michal.simek@xilinx.com>,
"Karol Gugala" <kgugala@antmicro.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Peter Korsgaard" <peter@korsgaard.com>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Alexander Shiyan" <shc_work@mail.ru>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@canonical.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Fabio Estevam" <festevam@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"Ludovic Desroches" <ludovic.desroches@microchip.com>,
"Andy Gross" <agross@kernel.org>,
bcm-kernel-feedback-list@broadcom.com,
"NXP Linux Team" <linux-imx@nxp.com>,
linux-serial@vger.kernel.org, "Vineet Gupta" <vgupta@kernel.org>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Tobias Klauser" <tklauser@distanz.ch>,
"Patrice Chotard" <patrice.chotard@foss.st.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Takao Orito" <orito.takao@socionext.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Bjorn Andersson" <bjorn.andersson@linaro.org>,
"Sudeep Holla" <sudeep.holla@arm.com>,
"Richard Genoud" <richard.genoud@gmail.com>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"David S. Miller" <davem@davemloft.net>,
"Taichi Sugaya" <sugaya.taichi@socionext.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Kevin Hilman" <khilman@baylibre.com>,
"Baolin Wang" <baolin.wang7@gmail.com>,
"Shawn Guo" <shawnguo@kernel.org>,
"Andreas Färber" <afaerber@suse.de>
Subject: RE: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char
Date: Thu, 03 Mar 2022 12:27:37 +0000 [thread overview]
Message-ID: <1A568R.RVXRB53P9YYQ1@crapouillou.net> (raw)
In-Reply-To: <9fa84690ed244eba89f1efe4e6670f80@AcuMS.aculab.com>
Hi David,
Le jeu., mars 3 2022 at 11:44:42 +0000, David Laight
<David.Laight@ACULAB.COM> a écrit :
> From: Maciej W. Rozycki
>> Sent: 03 March 2022 11:31
> ..
>> It does, but, oh dear, it's a "solution" to a problem we have
>> created in
>> the first place. Why do we ever want to have signed characters in
>> the TTY
>> layer, and then to vary between platforms? It's asking for
>> portability
>> issues.
>
> C 'char' is signed because the pdp/11 byte load sign extended.
That's incorrect. The C standard does say that "the implementation
shall define char to have the same range, representation, and behavior
as either signed char or unsigned char".
C 'char' is signed on x86 (and MIPS and Sparc etc.). It is unsigned on
ARM, PowerPC and Risc-V among others.
> I guess some ABI use unsigned char to avoid issues with all
> the functions that take/return an int parameter that is
> either a 'char' cast to 'unsigned char' or EOF.
>
> EOF is usually (-1) - but doesn't have to be.
> But it needs to be different from any value obtained
> by casting a 'char' to 'unsigned char'.
> (But that may only need to be all characters, not all values of
> 'char'.)
Is the putchar() callback ever going to be called with EOF? I don't
think so.
> Then you get the requirement that:
> sizeof (int) >= sizeof (short) >= sizeof (char)
> which means that it is perfectly valid for all 3 to be the same size
> [1].
> In that case 'unsigned char' promotes to 'unsigned int'
> which probably breaks some code.
We're talking about Linux here. Ints are 32-bit.
Cheers,
-Paul
next prev parent reply other threads:[~2022-03-03 12:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 7:27 [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char Jiri Slaby
2022-03-02 17:52 ` Uwe Kleine-König
2022-03-02 23:57 ` David Laight
2022-03-03 7:06 ` Jiri Slaby
2022-03-03 9:55 ` Maciej W. Rozycki
2022-03-03 10:22 ` Paul Cercueil
2022-03-03 11:30 ` Maciej W. Rozycki
2022-03-03 11:35 ` Jiri Slaby
2022-03-03 11:44 ` David Laight
2022-03-03 12:27 ` Paul Cercueil [this message]
2022-03-03 10:23 ` David Laight
2022-03-31 22:59 ` Maciej W. Rozycki
2022-03-02 18:21 ` Vladimir Zapolskiy
2022-03-03 6:32 ` Jiri Slaby
2022-03-03 7:45 ` Greg KH
2022-03-03 7:49 ` Jiri Slaby
2022-03-03 8:07 ` Greg KH
2022-03-03 8:09 ` Jiri Slaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1A568R.RVXRB53P9YYQ1@crapouillou.net \
--to=paul@crapouillou.net \
--cc=David.Laight@ACULAB.COM \
--cc=afaerber@suse.de \
--cc=agross@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=aou@eecs.berkeley.edu \
--cc=baolin.wang7@gmail.com \
--cc=baruch@tkos.co.il \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=benh@kernel.crashing.org \
--cc=bjorn.andersson@linaro.org \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbrunet@baylibre.com \
--cc=jslaby@suse.cz \
--cc=kernel@pengutronix.de \
--cc=kgugala@antmicro.com \
--cc=khilman@baylibre.com \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=liviu.dudau@arm.com \
--cc=lorenzo.pieralisi@arm.com \
--cc=ludovic.desroches@microchip.com \
--cc=macro@orcam.me.uk \
--cc=mani@kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mholenko@antmicro.com \
--cc=michal.simek@xilinx.com \
--cc=mpe@ellerman.id.au \
--cc=narmstrong@baylibre.com \
--cc=nicolas.ferre@microchip.com \
--cc=orito.takao@socionext.com \
--cc=orsonzhai@gmail.com \
--cc=palmer@dabbelt.com \
--cc=patrice.chotard@foss.st.com \
--cc=paul.walmsley@sifive.com \
--cc=paulus@samba.org \
--cc=peter@korsgaard.com \
--cc=richard.genoud@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=shc_work@mail.ru \
--cc=sudeep.holla@arm.com \
--cc=sugaya.taichi@socionext.com \
--cc=tklauser@distanz.ch \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vgupta@kernel.org \
--cc=vz@mleia.com \
--cc=zhang.lyra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).