Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

How can you work when the system's so crowded?


devel / comp.unix.programmer / Why 8 bit exit status codes?

SubjectAuthor
* Why 8 bit exit status codes?Andreas Kempe
+* Re: Why 8 bit exit status codes?Scott Lurndal
|`* Re: Why 8 bit exit status codes?Andreas Kempe
| `* Re: Why 8 bit exit status codes?Scott Lurndal
|  `* Re: Why 8 bit exit status codes?Andreas Kempe
|   +- Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|   `* Re: Why 8 bit exit status codes?Keith Thompson
|    +* Re: Why 8 bit exit status codes?Andreas Kempe
|    |+- Re: Why 8 bit exit status codes?Janis Papanagnou
|    |+- Re: Why 8 bit exit status codes?Scott Lurndal
|    |+- Re: Why 8 bit exit status codes?Keith Thompson
|    |+- Re: Why 8 bit exit status codes?Rainer Weikusat
|    |`- Re: Why 8 bit exit status codes?Andreas Kempe
|    `* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|     `* Re: Why 8 bit exit status codes?Joe Pfeiffer
|      +* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|      |`- Re: Why 8 bit exit status codes?Scott Lurndal
|      +- Re: Why 8 bit exit status codes?Richard Kettlewell
|      `* Re: Why 8 bit exit status codes?Kees Nuyt
|       `* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|        `* Re: Why 8 bit exit status codes?Keith Thompson
|         +- Re: Why 8 bit exit status codes?Scott Lurndal
|         `* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|          `* Re: Why 8 bit exit status codes?Keith Thompson
|           `* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|            `* Re: Why 8 bit exit status codes?Keith Thompson
|             `* Re: Why 8 bit exit status codes?Richard Kettlewell
|              +* Re: Why 8 bit exit status codes?Rainer Weikusat
|              |+* Re: Why 8 bit exit status codes?Kaz Kylheku
|              ||`* Re: Why 8 bit exit status codes?Rainer Weikusat
|              || +* Re: Why 8 bit exit status codes?Kaz Kylheku
|              || |`* Re: Why 8 bit exit status codes?Rainer Weikusat
|              || | `* Re: Why 8 bit exit status codes?Kaz Kylheku
|              || |  `- Re: Why 8 bit exit status codes?Rainer Weikusat
|              || `* Re: Why 8 bit exit status codes?Lew Pitcher
|              ||  `- Re: Why 8 bit exit status codes?Rainer Weikusat
|              |`- Re: Why 8 bit exit status codes?Keith Thompson
|              `* Re: Why 8 bit exit status codes?Keith Thompson
|               +* Re: Why 8 bit exit status codes?Andreas Kempe
|               |`* Re: Why 8 bit exit status codes?Scott Lurndal
|               | `* Re: Why 8 bit exit status codes?Andreas Kempe
|               |  `* Re: Why 8 bit exit status codes?Scott Lurndal
|               |   `* Re: Why 8 bit exit status codes?Andreas Kempe
|               |    `- Re: Why 8 bit exit status codes?Scott Lurndal
|               `* Re: Why 8 bit exit status codes?Richard Kettlewell
|                `* Re: Why 8 bit exit status codes?Rainer Weikusat
|                 `* Re: Why 8 bit exit status codes?Richard Kettlewell
|                  +* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|                  |`- Re: Why 8 bit exit status codes?Richard Kettlewell
|                  `* Re: Why 8 bit exit status codes?Rainer Weikusat
|                   `* Re: Why 8 bit exit status codes?Keith Thompson
|                    `* Re: Why 8 bit exit status codes?Rainer Weikusat
|                     +* Re: Why 8 bit exit status codes?Keith Thompson
|                     |`* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|                     | +* Re: Why 8 bit exit status codes?Scott Lurndal
|                     | |`- Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
|                     | `- Re: Why 8 bit exit status codes?Keith Thompson
|                     `- Re: Why 8 bit exit status codes?Kaz Kylheku
`* Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
 `* Re: Why 8 bit exit status codes?Keith Thompson
  +- Re: Why 8 bit exit status codes?Lawrence D'Oliveiro
  `- Re: Why 8 bit exit status codes?Rainer Weikusat

Pages:123
Re: Why 8 bit exit status codes?

<YTewN.46668$mMj7.4380@fx01.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11230&group=comp.unix.programmer#11230

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx01.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Why 8 bit exit status codes?
Newsgroups: comp.unix.programmer
References: <upj3rq$da8$1@nyheter.lysator.liu.se> <EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se> <w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se> <87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net> <qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl> <upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
Lines: 29
Message-ID: <YTewN.46668$mMj7.4380@fx01.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 06 Feb 2024 00:16:56 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 06 Feb 2024 00:16:56 GMT
X-Received-Bytes: 2113
 by: Scott Lurndal - Tue, 6 Feb 2024 00:16 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>> On Mon, 05 Feb 2024 18:22:59 +0100, Kees Nuyt wrote:
>>> On Sat, 3 Feb 2024 21:37:55 -0000 (UTC), Lawrence D'Oliveiro wrote:
>>> Signed characters make no sense.
>>>
>>> Nor did 6 bit characters, but in the 1980s we had them:
>>> 3 characters in a 24 bit word.
>>
>> I see your sixbit and raise you Radix-50, which packed 3 characters into a
>> 16-bit word.
>>
>> None of these used signed character codes, by the way. So my point still
>> stands.
>
>My understanding is that on the PDP-11, making plain char signed made
>code that stored character values in int objects more efficient.
>Sign-extension was more efficient than zero-filling or something like
>that. I don't remember the details, but I'm sure it wouldn't be
>difficult to find out.

The PDP-11 had two move instructions:

MOV (r1)+,r2
MOVB (r2)+,r3

MOV moved source to destination. MOVB always sign-extended the byte
to the destination register size (16-bit).

Re: Why 8 bit exit status codes?

<ups07m$h6mt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11231&group=comp.unix.programmer#11231

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 6 Feb 2024 00:58:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ups07m$h6mt$1@dont-email.me>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me>
<1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 6 Feb 2024 00:58:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="06aca01f94cf0cf48b148884bafbedb9";
logging-data="563933"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hvEw4fTgwSz/vxlIw2zO0"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:D/SuF0RzFfsRY/TcHIoRShn1aRk=
 by: Lawrence D'Oliv - Tue, 6 Feb 2024 00:58 UTC

On Mon, 05 Feb 2024 15:51:37 -0800, Keith Thompson wrote:

> My understanding is that on the PDP-11, making plain char signed made
> code that stored character values in int objects more efficient.
> Sign-extension was more efficient than zero-filling or something like
> that.

The move-byte instruction did sign-extension when loading into a register,
not storing into memory.

There was no convert-byte-to-word instruction as such.

Re: Why 8 bit exit status codes?

<878r3yjpbr.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11232&group=comp.unix.programmer#11232

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Mon, 05 Feb 2024 18:31:36 -0800
Organization: None to speak of
Lines: 34
Message-ID: <878r3yjpbr.fsf@nosuchdomain.example.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4718b0a0ab2e3c1c2260eb363d68ae7d";
logging-data="587468"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cJHl+XoQ2HIJiDlUsutu9"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:pAXSigteH3F97SEjIS6qwr+BK/k=
sha1:YMI4lTBGFYvTjsMFXEuNZVVuRtk=
 by: Keith Thompson - Tue, 6 Feb 2024 02:31 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Mon, 05 Feb 2024 15:51:37 -0800, Keith Thompson wrote:
>> My understanding is that on the PDP-11, making plain char signed made
>> code that stored character values in int objects more efficient.
>> Sign-extension was more efficient than zero-filling or something like
>> that.
>
> The move-byte instruction did sign-extension when loading into a register,
> not storing into memory.
>
> There was no convert-byte-to-word instruction as such.

Right, so if you wanted to copy an 8-bit value into a 16-bit register
with sign-extension, you do it in one instruction, whereas zeroing the
top 8 bits would require at least one additional instruction, probably a
BIC (bit-clear) following the MOVB. You'd probably need more
instruction space to store the mask value of 0xff00 -- pardon me,
0177400. And I expect that copying a character into a register would
have been a common operation.

Given those constraints, I'd say it made sense *at the time* for char to
be signed on the PDP-11, especially since it was pretty much assumed
that text would be plain ASCII that would never have the high bit set.

If the PDP-11 had had an alternative MOVB instruction that did
zero-extension, we might not be having this discussion.

Question: Do any more modern CPUs have similar characteristics that make
either signed or unsigned char more efficient?

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why 8 bit exit status codes?

<ups7vs$i2ic$5@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11233&group=comp.unix.programmer#11233

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 6 Feb 2024 03:10:52 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ups7vs$i2ic$5@dont-email.me>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me>
<1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 6 Feb 2024 03:10:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="06aca01f94cf0cf48b148884bafbedb9";
logging-data="592460"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fdWIwfDt53yUabI/cxfZw"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:ql4Ja0h2TEltqZO5haUiVbJuY8M=
 by: Lawrence D'Oliv - Tue, 6 Feb 2024 03:10 UTC

On Mon, 05 Feb 2024 18:31:36 -0800, Keith Thompson wrote:

> If the PDP-11 had had an alternative MOVB instruction that did
> zero-extension, we might not be having this discussion.

Which is effectively what I said:

On Fri, 02 Feb 2024 18:17:52 -0800, Keith Thompson wrote:

> The signedness of plain char is implementation-defined.

Why? Because the PDP-11 on which C and Unix were originally developed did
sign extension when loading a byte quantity into a (word-length) register.

Signed characters make no sense.

Re: Why 8 bit exit status codes?

<87zfwei6n2.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11234&group=comp.unix.programmer#11234

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Mon, 05 Feb 2024 20:00:33 -0800
Organization: None to speak of
Lines: 26
Message-ID: <87zfwei6n2.fsf@nosuchdomain.example.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4718b0a0ab2e3c1c2260eb363d68ae7d";
logging-data="733642"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187nBe25XTmMvyquupC9EZl"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:nsungi8hWynieHdXFzEGZNVYD/Q=
sha1:PzLTHYbiKMTasK2dveVet4uJBpc=
 by: Keith Thompson - Tue, 6 Feb 2024 04:00 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Mon, 05 Feb 2024 18:31:36 -0800, Keith Thompson wrote:
>
>> If the PDP-11 had had an alternative MOVB instruction that did
>> zero-extension, we might not be having this discussion.
>
> Which is effectively what I said:
>
> On Fri, 02 Feb 2024 18:17:52 -0800, Keith Thompson wrote:
>
> > The signedness of plain char is implementation-defined.
>
> Why? Because the PDP-11 on which C and Unix were originally developed did
> sign extension when loading a byte quantity into a (word-length) register.
>
> Signed characters make no sense.

You wrote that "Signed characters make no sense". I was talking about a
context in which they did make sense. How is that effectively what you
said? (I was agreeing with and expanding on your statement about the
PDP-11.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why 8 bit exit status codes?

<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11250&group=comp.unix.programmer#11250

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.nntp4.net!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: inva...@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 17:00:25 +0000
Organization: terraraq NNTP server
Message-ID: <wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="35556"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:W6WT9bfXbLRzBfScsG8Sz3j2ays=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Tue, 6 Feb 2024 17:00 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Lawrence D'Oliveiro <ldo@nz.invalid> writes:

>> Signed characters make no sense.
>
> You wrote that "Signed characters make no sense". I was talking about a
> context in which they did make sense. How is that effectively what you
> said? (I was agreeing with and expanding on your statement about the
> PDP-11.)

I still don’t see any explanation for signed characters as such making
sense.

I think the situation is more accurately interpreted as letting a
PDP-11-specific optimization influence the language design, and
(temporarily) getting away with it because the character values they
cared about at the time happened to lie within a small enough range that
negative values didn’t arise.

--
https://www.greenend.org.uk/rjk/

Re: Why 8 bit exit status codes?

<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11251&group=comp.unix.programmer#11251

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweiku...@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 17:35:01 +0000
Lines: 25
Message-ID: <87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net swJ46/u715S7pR0liMmYlAq2aeXGoGb8cKimheFIlG74A619k=
Cancel-Lock: sha1:rlE3l5w2TDEQVaholGhRL9F0mOE= sha1:GKMbiiTc3J4k/Z9ySDn8hM7F03M= sha256:TJK1V8PUDEuFNvK1VK81KPmYpOM0Ax/TcL2JuyJVg58=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Rainer Weikusat - Tue, 6 Feb 2024 17:35 UTC

Richard Kettlewell <invalid@invalid.invalid> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>
>>> Signed characters make no sense.
>>
>> You wrote that "Signed characters make no sense". I was talking about a
>> context in which they did make sense. How is that effectively what you
>> said? (I was agreeing with and expanding on your statement about the
>> PDP-11.)
>
> I still don’t see any explanation for signed characters as such making
> sense.
>
> I think the situation is more accurately interpreted as letting a
> PDP-11-specific optimization influence the language design, and
> (temporarily) getting away with it because the character values they
> cared about at the time happened to lie within a small enough range that
> negative values didn’t arise.

I think that's just a (probably traditional) misnomer. A C char isn't a
character, it's an integer type and it's a signed integer type because
all other original C integer types (int and short) were signed as
well. Unsigned integer types, as something that's different from
pointer, were a later addition.

Re: Why 8 bit exit status codes?

<20240206095046.803@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11252&group=comp.unix.programmer#11252

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 6 Feb 2024 18:04:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 75
Message-ID: <20240206095046.803@kylheku.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me>
<1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 6 Feb 2024 18:04:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a112f49d5e72d19646dc68722a58d18c";
logging-data="1059183"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fBiaRZiCuNAWNVgD+MvxH4UqGBmgW8r0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:tWjqs5v/fGtdyKgfcZwxpvELhGA=
 by: Kaz Kylheku - Tue, 6 Feb 2024 18:04 UTC

On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
> Richard Kettlewell <invalid@invalid.invalid> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>
>>>> Signed characters make no sense.
>>>
>>> You wrote that "Signed characters make no sense". I was talking about a
>>> context in which they did make sense. How is that effectively what you
>>> said? (I was agreeing with and expanding on your statement about the
>>> PDP-11.)
>>
>> I still don’t see any explanation for signed characters as such making
>> sense.
>>
>> I think the situation is more accurately interpreted as letting a
>> PDP-11-specific optimization influence the language design, and
>> (temporarily) getting away with it because the character values they
>> cared about at the time happened to lie within a small enough range that
>> negative values didn’t arise.
>
> I think that's just a (probably traditional) misnomer. A C char isn't a
> character, it's an integer type and it's a signed integer type because
> all other original C integer types (int and short) were signed as
> well. Unsigned integer types, as something that's different from
> pointer, were a later addition.

Sure, except for the part where "abcd" denotes an object that is a
null-terminated array of these *char* integers, that entity being formally
called a "string" in ISO C, and used for representing text. (Or else "abcd" is
initializer syntax for a four element (or larger) array of *char*).

If *char* is signed (and CHAR_BIT is 8), then '\xff` produces a negative value,
even though the constant has type *int*, and "\xff"[0] does likewise.

This has been connected to needless bugs in C programs. An expression like
table[str[i]] may result in table[] being negatively indexed.

The <ctype.h> function require an argument that is either EOF
or a value in the range of 0 to UCHAR_MAX, and so are incompatible
with string elements.

All this crap could have been avoided if *char* had been unsigned.
*unsigned char* never needed to exist except as a synonym for plain
*char*.

Speaking of synonyms, *char* is a distinct type, and not a synonym for either
*signed char* or *unsigned char*. It has to be that way, given the way it is
defined, but it's just another complication that need not have existed:

#include <stdio.h>

int main(void)
{ char *cp = 0;
unsigned char *ucp = 0;
signed char *scp = 0;
printf("%d %d %d\n", cp == ucp, cp == scp, ucp == scp);
printf("%d\n", '\xff');
}

char.c: In function ‘main’:
char.c:8:27: warning: comparison of distinct pointer types lacks a cast
printf("%d %d %d\n", cp == ucp, cp == scp, ucp == scp);
^~
char.c:8:38: warning: comparison of distinct pointer types lacks a cast
printf("%d %d %d\n", cp == ucp, cp == scp, ucp == scp);
^~
char.c:8:50: warning: comparison of distinct pointer types lacks a cast
printf("%d %d %d\n", cp == ucp, cp == scp, ucp == scp);

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Why 8 bit exit status codes?

<87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11253&group=comp.unix.programmer#11253

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweiku...@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 18:30:46 +0000
Lines: 56
Message-ID: <87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
<20240206095046.803@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net tRVU7/B6gBGzFyT1s7sZ7wRYP8IrEBdCmLCPnJJuszxXdwqJU=
Cancel-Lock: sha1:u74w5YvN0CO1t56j2WPhQ6IJnvQ= sha1:AmqUN7JqvuSgtdaTUtRM3870eNo= sha256:CJQXdjl7dZwcUfKMVAy2Btqcreb36/e0/SKEIjSapmE=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Rainer Weikusat - Tue, 6 Feb 2024 18:30 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>> Richard Kettlewell <invalid@invalid.invalid> writes:

[...]

>>> I still don’t see any explanation for signed characters as such making
>>> sense.
>>>
>>> I think the situation is more accurately interpreted as letting a
>>> PDP-11-specific optimization influence the language design, and
>>> (temporarily) getting away with it because the character values they
>>> cared about at the time happened to lie within a small enough range that
>>> negative values didn’t arise.
>>
>> I think that's just a (probably traditional) misnomer. A C char isn't a
>> character, it's an integer type and it's a signed integer type because
>> all other original C integer types (int and short) were signed as
>> well. Unsigned integer types, as something that's different from
>> pointer, were a later addition.
>
> Sure, except for the part where "abcd" denotes an object that is a
> null-terminated array of these *char* integers, that entity being formally
> called a "string" in ISO C, and used for representing text. (Or else "abcd" is
> initializer syntax for a four element (or larger) array of *char*).
>
> If *char* is signed (and CHAR_BIT is 8), then '\xff` produces a negative value,
> even though the constant has type *int*, and "\xff"[0] does likewise.
>
> This has been connected to needless bugs in C programs. An expression like
> table[str[i]] may result in table[] being negatively indexed.
>
> The <ctype.h> function require an argument that is either EOF
> or a value in the range of 0 to UCHAR_MAX, and so are incompatible
> with string elements.
>
> All this crap could have been avoided if *char* had been unsigned.
> *unsigned char* never needed to exist except as a synonym for plain
> *char*.

All of this may be true¹ but it's all besides the point. The original C
language had three integer types, char, short and int, which were all
signed types. It further supported declaring pointers to some type and
pointers were basically unsigned integer indices into a linear memory
array. Char couldn't have been an unsigned integer type, regardless if
this would have made more sense², because unsigned integer types didn't
exist in the language.

¹ My personal theory of human fallibility is that humans tend to fuck up
everything they possibly can. Hence, so-called C pitfalls expose human
traits (fallibility) and not language traits. Had they been avoided,
human ingenuity would have found something else to fuck up.

² Being wise in hindsight is always easy. But that's not an option for
people who need to create something which doesn't yet exist and not be
wisely critical of something that does.

Re: Why 8 bit exit status codes?

<20240206103531.140@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11254&group=comp.unix.programmer#11254

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 6 Feb 2024 18:38:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20240206103531.140@kylheku.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me>
<1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
<20240206095046.803@kylheku.com>
<87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 6 Feb 2024 18:38:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a112f49d5e72d19646dc68722a58d18c";
logging-data="1070139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dNdoPo5UGKj6bhiQUCF8I0LHQfW3FdHk="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:hRTpyRZKyjGopjzmtTwZICHQSlQ=
 by: Kaz Kylheku - Tue, 6 Feb 2024 18:38 UTC

On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
> ¹ My personal theory of human fallibility is that humans tend to fuck up
> everything they possibly can. Hence, so-called C pitfalls expose human
> traits (fallibility) and not language traits.

Does that work for all safety devices? Isolation transformers, steel
toed boots, helmets, seat belts, roll bars, third outlet prongs, ...

A fractured skull reveals a human trait (accident proneness, weak bone)
rather than the workplace trait of not enforcing helmet use.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Why 8 bit exit status codes?

<87h6il76xj.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11255&group=comp.unix.programmer#11255

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweiku...@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 19:02:00 +0000
Lines: 12
Message-ID: <87h6il76xj.fsf@doppelsaurus.mobileactivedefense.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
<20240206095046.803@kylheku.com>
<87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>
<20240206103531.140@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net xtMd3iOKsrmj0NCkX8Z00w8YMpjSIqL7ogyxg9Zz43Tm0CseU=
Cancel-Lock: sha1:Yu4olPvDbYGIyw+dCljdqPRJVQQ= sha1:OjSktc1gQMSg7IDYhM5DkQY34QM= sha256:qh5o0dsLssLAM2Gcx7k3Lw5ENW0yAG3URwzyEGkRAfQ=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Rainer Weikusat - Tue, 6 Feb 2024 19:02 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>> ¹ My personal theory of human fallibility is that humans tend to fuck up
>> everything they possibly can. Hence, so-called C pitfalls expose human
>> traits (fallibility) and not language traits.
>
> Does that work for all safety devices? Isolation transformers, steel
> toed boots, helmets, seat belts, roll bars, third outlet prongs, ...

I wrote about C types and somewhat more generally, programming language
features, and not "safety devices" supposed to protect human bodies from
physical injury.

Re: Why 8 bit exit status codes?

<87sf25if5u.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11256&group=comp.unix.programmer#11256

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 11:08:45 -0800
Organization: None to speak of
Lines: 38
Message-ID: <87sf25if5u.fsf@nosuchdomain.example.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="4718b0a0ab2e3c1c2260eb363d68ae7d";
logging-data="1081706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18juocaRzA23ybh/Gc7B1Vn"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:wvVDDWv0tOq0DQIfN3lbekcz9OU=
sha1:ym7sTBFhtcWe+awHNwZR5a8t2n4=
 by: Keith Thompson - Tue, 6 Feb 2024 19:08 UTC

Richard Kettlewell <invalid@invalid.invalid> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>> Signed characters make no sense.
>>
>> You wrote that "Signed characters make no sense". I was talking about a
>> context in which they did make sense. How is that effectively what you
>> said? (I was agreeing with and expanding on your statement about the
>> PDP-11.)
>
> I still don’t see any explanation for signed characters as such making
> sense.
>
> I think the situation is more accurately interpreted as letting a
> PDP-11-specific optimization influence the language design, and
> (temporarily) getting away with it because the character values they
> cared about at the time happened to lie within a small enough range that
> negative values didn’t arise.

I think we're mostly in agreement, perhaps with different understandings
of "making sense". What I'm saying is that the decision to make char a
signed type made sense for PDP-11 implementation, purely because of
performance issues.

I just did a quick test on x86_64, x86, and ARM. It appears that
assigning either an unsigned char or a signed char to an int object
takes a single instruction. (My test didn't distinguish between
register or memory target.) I suspect there's no longer any performance
justification on most modern platforms for making plain char signed.
But there's like to be (bad or at least non-portable) code that depends
on plain char being signed. As it happens, plain char is unsigned in
gcc for ARM. And gcc has "-fsigned-char" and "-funsigned-char" options
to override the default.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why 8 bit exit status codes?

<87o7ctiev2.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11257&group=comp.unix.programmer#11257

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 11:15:13 -0800
Organization: None to speak of
Lines: 56
Message-ID: <87o7ctiev2.fsf@nosuchdomain.example.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="4718b0a0ab2e3c1c2260eb363d68ae7d";
logging-data="1081706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19o/xBHIFuinL2RbWNHQhM/"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:gF62AP8IE1vOiOi3PScOv2ekcGM=
sha1:VrQqcrH/Jay4VjQuKmaYWi+zUhw=
 by: Keith Thompson - Tue, 6 Feb 2024 19:15 UTC

Rainer Weikusat <rweikusat@talktalk.net> writes:
> Richard Kettlewell <invalid@invalid.invalid> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>
>>>> Signed characters make no sense.
>>>
>>> You wrote that "Signed characters make no sense". I was talking about a
>>> context in which they did make sense. How is that effectively what you
>>> said? (I was agreeing with and expanding on your statement about the
>>> PDP-11.)
>>
>> I still don’t see any explanation for signed characters as such making
>> sense.
>>
>> I think the situation is more accurately interpreted as letting a
>> PDP-11-specific optimization influence the language design, and
>> (temporarily) getting away with it because the character values they
>> cared about at the time happened to lie within a small enough range that
>> negative values didn’t arise.
>
> I think that's just a (probably traditional) misnomer. A C char isn't a
> character, it's an integer type and it's a signed integer type because
> all other original C integer types (int and short) were signed as
> well. Unsigned integer types, as something that's different from
> pointer, were a later addition.

Here's a quote from the 1974 and 1975 C reference manuals:

A char object may be used anywhere an int may be. In all cases the
char is converted to an int by propagating its sign through the
upper 8 bits of the resultant integer. This is consistent with the
two’s complement representation used for both characters and
integers. (However, the sign-propagation feature disappears in other
implementations.)

In more modern terms, that last sentence suggests that plain char was
unsigned in some implementations

K&R1, 1978, is more explicit:

There is one subtle point about the conversion of characters
to integers. The language does not specify whether variables
of type char are signed or unsigned quantities. When a
char is converted to an int, can it ever produce a negative
integer? Unfortunately, this varies from machine to machine,
reflecting differences in architecture. On some machines
(PDP-11, for instance), a char whose leftmost bit is 1 will be
converted to a negative integer ("sign extension"). On others,
a char is promoted to an int by adding zeros at the left end,
and thus is always positive.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why 8 bit exit status codes?

<upu136$vc7e$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11259&group=comp.unix.programmer#11259

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 6 Feb 2024 19:25:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 76
Message-ID: <upu136$vc7e$1@dont-email.me>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me>
<1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
<20240206095046.803@kylheku.com>
<87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 6 Feb 2024 19:25:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e6a07a32e0c2f15274a42ec89675d32e";
logging-data="1028334"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LvsvOaM6PRnnC2VzqdLZ27Gz79+iCgV8="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:ss+ArMqG/su/aQ8G5hfJv66xDjM=
 by: Lew Pitcher - Tue, 6 Feb 2024 19:25 UTC

On Tue, 06 Feb 2024 18:30:46 +0000, Rainer Weikusat wrote:

> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>> On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>> Richard Kettlewell <invalid@invalid.invalid> writes:
>
> [...]
>
>>>> I still don’t see any explanation for signed characters as such making
>>>> sense.
>>>>
>>>> I think the situation is more accurately interpreted as letting a
>>>> PDP-11-specific optimization influence the language design, and
>>>> (temporarily) getting away with it because the character values they
>>>> cared about at the time happened to lie within a small enough range that
>>>> negative values didn’t arise.
>>>
>>> I think that's just a (probably traditional) misnomer. A C char isn't a
>>> character, it's an integer type and it's a signed integer type because
>>> all other original C integer types (int and short) were signed as
>>> well. Unsigned integer types, as something that's different from
>>> pointer, were a later addition.
>>
>> Sure, except for the part where "abcd" denotes an object that is a
>> null-terminated array of these *char* integers, that entity being formally
>> called a "string" in ISO C, and used for representing text. (Or else "abcd" is
>> initializer syntax for a four element (or larger) array of *char*).
>>
>> If *char* is signed (and CHAR_BIT is 8), then '\xff` produces a negative value,
>> even though the constant has type *int*, and "\xff"[0] does likewise.
>>
>> This has been connected to needless bugs in C programs. An expression like
>> table[str[i]] may result in table[] being negatively indexed.
>>
>> The <ctype.h> function require an argument that is either EOF
>> or a value in the range of 0 to UCHAR_MAX, and so are incompatible
>> with string elements.
>>
>> All this crap could have been avoided if *char* had been unsigned.
>> *unsigned char* never needed to exist except as a synonym for plain
>> *char*.
>
> All of this may be true¹ but it's all besides the point. The original C
> language had three integer types, char, short and int, which were all
> signed types.

This view ignores the early implementation of (K&R) C on IBM 370 systems,
where a char was 8 bits of EBCDIC. In EBCDIC, all alphabetic and numeric
characters have their high bit set (alphabetics range from 0x80 through
0xe9, while numerics range from 0xf0 through 0xf9). A char in this
implementation, by necessity, was unsigned, as C "guarantees that any
character in the machine's standard character set will never be negative"
(K&R "The C Programming Language", p40)

> It further supported declaring pointers to some type and
> pointers were basically unsigned integer indices into a linear memory
> array. Char couldn't have been an unsigned integer type, regardless if
> this would have made more sense², because unsigned integer types didn't
> exist in the language.
>
> ¹ My personal theory of human fallibility is that humans tend to fuck up
> everything they possibly can. Hence, so-called C pitfalls expose human
> traits (fallibility) and not language traits. Had they been avoided,
> human ingenuity would have found something else to fuck up.
>
> ² Being wise in hindsight is always easy. But that's not an option for
> people who need to create something which doesn't yet exist and not be
> wisely critical of something that does.

--
Lew Pitcher
"In Skills We Trust"

Re: Why 8 bit exit status codes?

<87cyt97460.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11260&group=comp.unix.programmer#11260

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweiku...@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 20:01:43 +0000
Lines: 18
Message-ID: <87cyt97460.fsf@doppelsaurus.mobileactivedefense.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
<20240206095046.803@kylheku.com>
<87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>
<upu136$vc7e$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net tG50cbnvC9+BMqhQ58hrjQHTrYhdJuLazHl2ejkRupR26mJPI=
Cancel-Lock: sha1:xROCOsYaXksCp22SWBeQ4ROvzZY= sha1:Nf9+KeNzqBbXHL8ectwPud8s4XI= sha256:fBRB+xAXI2A1+Rmbpa6Tg0DQtmmaLiApr0fOtQdbDwU=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Rainer Weikusat - Tue, 6 Feb 2024 20:01 UTC

Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> On Tue, 06 Feb 2024 18:30:46 +0000, Rainer Weikusat wrote:

[Why-oh-why is char not unsigned?!?]

>> All of this may be true¹ but it's all besides the point. The original C
>> language had three integer types, char, short and int, which were all
>> signed types.
>
> This view ignores the early implementation of (K&R) C on IBM 370 systems,
> where a char was 8 bits of EBCDIC. In EBCDIC, all alphabetic and numeric
> characters have their high bit set (alphabetics range from 0x80 through
> 0xe9, while numerics range from 0xf0 through 0xf9).

Indeed. It refers to the C lanuage as it existed/ was created when UNIX
was brought over to the PDP-11. This language didn't have any unsigned
integer types as the concept didn't yet exist.

Re: Why 8 bit exit status codes?

<20240206131924.235@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11267&group=comp.unix.programmer#11267

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 6 Feb 2024 21:22:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20240206131924.235@kylheku.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me>
<1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
<20240206095046.803@kylheku.com>
<87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>
<20240206103531.140@kylheku.com>
<87h6il76xj.fsf@doppelsaurus.mobileactivedefense.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 6 Feb 2024 21:22:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a112f49d5e72d19646dc68722a58d18c";
logging-data="1125698"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pLQQd/IskRuzJ4P5vcsOlOBIKhpzprgw="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:W30WJflaV7zv8rS7+lnP5cU6DrA=
 by: Kaz Kylheku - Tue, 6 Feb 2024 21:22 UTC

On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>> On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>> ¹ My personal theory of human fallibility is that humans tend to fuck up
>>> everything they possibly can. Hence, so-called C pitfalls expose human
>>> traits (fallibility) and not language traits.
>>
>> Does that work for all safety devices? Isolation transformers, steel
>> toed boots, helmets, seat belts, roll bars, third outlet prongs, ...
>
> I wrote about C types and somewhat more generally, programming language
> features, and not "safety devices" supposed to protect human bodies from
> physical injury.

Type systems are safety devices. That's why we have terms like "type
safe" and "unsafe code".

Type safety helps prevent misbehavior, which results in problems like
incorrect results and data loss, which can have real economic harm.

In a safety-critical embedded system, a connection between type safety
and physical safety is readily identifiable.

"Type safety" it's not just some fanciful metaphor like "debugging";
there is a literal interpretation which is true.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Why 8 bit exit status codes?

<878r3x6zpt.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11269&group=comp.unix.programmer#11269

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweiku...@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 06 Feb 2024 21:37:50 +0000
Lines: 26
Message-ID: <878r3x6zpt.fsf@doppelsaurus.mobileactivedefense.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87plx97ayi.fsf@doppelsaurus.mobileactivedefense.com>
<20240206095046.803@kylheku.com>
<87le7x78dl.fsf@doppelsaurus.mobileactivedefense.com>
<20240206103531.140@kylheku.com>
<87h6il76xj.fsf@doppelsaurus.mobileactivedefense.com>
<20240206131924.235@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net FUwPLkmm/zhRWGlCkby5OgSjXtvDlOpIFZaon88Vd+uFac6QM=
Cancel-Lock: sha1:utbDk0ROejQJeyUULZhlxAlAjqE= sha1:syDusxCXHlUn4Qjzhanzl6L2jtM= sha256:RJthjTCtKTesKfLE8xuhGzc7+7zB5OVr0wZOyog0tBQ=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Rainer Weikusat - Tue, 6 Feb 2024 21:37 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>> On 2024-02-06, Rainer Weikusat <rweikusat@talktalk.net> wrote:
>>>> ¹ My personal theory of human fallibility is that humans tend to fuck up
>>>> everything they possibly can. Hence, so-called C pitfalls expose human
>>>> traits (fallibility) and not language traits.
>>>
>>> Does that work for all safety devices? Isolation transformers, steel
>>> toed boots, helmets, seat belts, roll bars, third outlet prongs, ...
>>
>> I wrote about C types and somewhat more generally, programming language
>> features, and not "safety devices" supposed to protect human bodies from
>> physical injury.
>
> Type systems are safety devices. That's why we have terms like "type
> safe" and "unsafe code".

They're not, at least not when safety device is supposed to mean
something like hard hats. That's just an inappropriate analogy some
people like to employ. This is, however, completely besides the point of
my original text which was about providing an explanation why char is
signed in C despite all kinds of smart alecs with fifty years of
hindsight Ritchie didn't have in 1972 are extremely concvinced that this
was an extremely bad idea.

Re: Why 8 bit exit status codes?

<upueeh$psf$1@nyheter.lysator.liu.se>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11271&group=comp.unix.programmer#11271

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!nyheter.lysator.liu.se!.POSTED!not-for-mail
From: kem...@lysator.liu.se (Andreas Kempe)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Tue, 6 Feb 2024 23:13:21 -0000 (UTC)
Organization: Lysator ACS
Message-ID: <upueeh$psf$1@nyheter.lysator.liu.se>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad> <upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad> <upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com> <upmbnj$39vft$2@dont-email.me>
<1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87sf25if5u.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 6 Feb 2024 23:13:21 -0000 (UTC)
Injection-Info: nyheter.lysator.liu.se; posting-account="kempe";
logging-data="26511"; mail-complaints-to="newsmaster@lysator.liu.se"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Andreas Kempe - Tue, 6 Feb 2024 23:13 UTC

Den 2024-02-06 skrev Keith Thompson <Keith.S.Thompson+u@gmail.com>:
> Richard Kettlewell <invalid@invalid.invalid> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>>> Signed characters make no sense.
>>>
>>> You wrote that "Signed characters make no sense". I was talking about a
>>> context in which they did make sense. How is that effectively what you
>>> said? (I was agreeing with and expanding on your statement about the
>>> PDP-11.)
>>
>> I still don’t see any explanation for signed characters as such making
>> sense.
>>
>> I think the situation is more accurately interpreted as letting a
>> PDP-11-specific optimization influence the language design, and
>> (temporarily) getting away with it because the character values they
>> cared about at the time happened to lie within a small enough range that
>> negative values didn’t arise.
>
> I think we're mostly in agreement, perhaps with different understandings
> of "making sense". What I'm saying is that the decision to make char a
> signed type made sense for PDP-11 implementation, purely because of
> performance issues.
>
> I just did a quick test on x86_64, x86, and ARM. It appears that
> assigning either an unsigned char or a signed char to an int object
> takes a single instruction. (My test didn't distinguish between
> register or memory target.) I suspect there's no longer any performance
> justification on most modern platforms for making plain char signed.
> But there's like to be (bad or at least non-portable) code that depends
> on plain char being signed. As it happens, plain char is unsigned in
> gcc for ARM. And gcc has "-fsigned-char" and "-funsigned-char" options
> to override the default.
>

I wouldn't expect any difference on a modern CPU. I did a microbench
on my laptop with an Intel i5-8350U. clang on my FreeBSD uses movzbl
and movsbl to move char to int so that's what I benched.

The bench was done by moving a byte from the stack to eax using a loop
of 10 movzbl/movsbl running 10M times. Both instructions gave on
average about 0.7 cycles per instruction measured using rdtsc. The
highest bit in the byte being set or unset made no difference.

Re: Why 8 bit exit status codes?

<vfzwN.269008$Ama9.259970@fx12.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11272&group=comp.unix.programmer#11272

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx12.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Why 8 bit exit status codes?
Newsgroups: comp.unix.programmer
References: <upj3rq$da8$1@nyheter.lysator.liu.se> <upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net> <qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl> <upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com> <ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com> <ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com> <wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk> <87sf25if5u.fsf@nosuchdomain.example.com> <upueeh$psf$1@nyheter.lysator.liu.se>
Lines: 29
Message-ID: <vfzwN.269008$Ama9.259970@fx12.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 06 Feb 2024 23:27:23 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 06 Feb 2024 23:27:23 GMT
X-Received-Bytes: 2456
 by: Scott Lurndal - Tue, 6 Feb 2024 23:27 UTC

Andreas Kempe <kempe@lysator.liu.se> writes:
>Den 2024-02-06 skrev Keith Thompson <Keith.S.Thompson+u@gmail.com>:
>> Richard Kettlewell <invalid@invalid.invalid> writes:

>>
>> I think we're mostly in agreement, perhaps with different understandings
>> of "making sense". What I'm saying is that the decision to make char a
>> signed type made sense for PDP-11 implementation, purely because of
>> performance issues.
>>
>> I just did a quick test on x86_64, x86, and ARM. It appears that
>> assigning either an unsigned char or a signed char to an int object
>> takes a single instruction. (My test didn't distinguish between
>> register or memory target.) I suspect there's no longer any performance
>> justification on most modern platforms for making plain char signed.
>> But there's like to be (bad or at least non-portable) code that depends
>> on plain char being signed. As it happens, plain char is unsigned in
>> gcc for ARM. And gcc has "-fsigned-char" and "-funsigned-char" options
>> to override the default.
>>
>
>I wouldn't expect any difference on a modern CPU. I did a microbench
>on my laptop with an Intel i5-8350U. clang on my FreeBSD uses movzbl
>and movsbl to move char to int so that's what I benched.

A move from register to register isn't even executed on most modern
processor designs. It is detected at fetch and the register is
just renamed in the pipeline.

Re: Why 8 bit exit status codes?

<upuin0$psf$2@nyheter.lysator.liu.se>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11274&group=comp.unix.programmer#11274

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!nyheter.lysator.liu.se!.POSTED!not-for-mail
From: kem...@lysator.liu.se (Andreas Kempe)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Wed, 7 Feb 2024 00:26:08 -0000 (UTC)
Organization: Lysator ACS
Message-ID: <upuin0$psf$2@nyheter.lysator.liu.se>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87sf25if5u.fsf@nosuchdomain.example.com>
<upueeh$psf$1@nyheter.lysator.liu.se> <vfzwN.269008$Ama9.259970@fx12.iad>
Injection-Date: Wed, 7 Feb 2024 00:26:08 -0000 (UTC)
Injection-Info: nyheter.lysator.liu.se; posting-account="kempe";
logging-data="26511"; mail-complaints-to="newsmaster@lysator.liu.se"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Andreas Kempe - Wed, 7 Feb 2024 00:26 UTC

Den 2024-02-06 skrev Scott Lurndal <scott@slp53.sl.home>:
> Andreas Kempe <kempe@lysator.liu.se> writes:
>>Den 2024-02-06 skrev Keith Thompson <Keith.S.Thompson+u@gmail.com>:
>>> Richard Kettlewell <invalid@invalid.invalid> writes:
>
>>>
>>> I think we're mostly in agreement, perhaps with different understandings
>>> of "making sense". What I'm saying is that the decision to make char a
>>> signed type made sense for PDP-11 implementation, purely because of
>>> performance issues.
>>>
>>> I just did a quick test on x86_64, x86, and ARM. It appears that
>>> assigning either an unsigned char or a signed char to an int object
>>> takes a single instruction. (My test didn't distinguish between
>>> register or memory target.) I suspect there's no longer any performance
>>> justification on most modern platforms for making plain char signed.
>>> But there's like to be (bad or at least non-portable) code that depends
>>> on plain char being signed. As it happens, plain char is unsigned in
>>> gcc for ARM. And gcc has "-fsigned-char" and "-funsigned-char" options
>>> to override the default.
>>>
>>
>>I wouldn't expect any difference on a modern CPU. I did a microbench
>>on my laptop with an Intel i5-8350U. clang on my FreeBSD uses movzbl
>>and movsbl to move char to int so that's what I benched.
>
> A move from register to register isn't even executed on most modern
> processor designs. It is detected at fetch and the register is
> just renamed in the pipeline.
>

Yeah. I tried some different variations and by adding some data
dependencies by incrementing the value and moving it around, I could
get some difference between the two, approx 10 to 30 %, but I'm not
sure how much is due to the instruction itself or other effects of
manipulating the data.

Funnily enough, the zero extend was the more performant in these tests
making unsigned char possibly more performant.

My intention wasn't really to claim they're exactly the same, but that
that I don't think there is any real performance benefit to be had by
switching char to unsigned. Even if the 10-30 % are a real thing, I
wonder how much software is actually using char types in a way where
it would make a difference?

Re: Why 8 bit exit status codes?

<tpAwN.44331$9cLc.25205@fx02.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11275&group=comp.unix.programmer#11275

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx02.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Why 8 bit exit status codes?
Newsgroups: comp.unix.programmer
References: <upj3rq$da8$1@nyheter.lysator.liu.se> <upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com> <ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com> <ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com> <wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk> <87sf25if5u.fsf@nosuchdomain.example.com> <upueeh$psf$1@nyheter.lysator.liu.se> <vfzwN.269008$Ama9.259970@fx12.iad> <upuin0$psf$2@nyheter.lysator.liu.se>
Lines: 65
Message-ID: <tpAwN.44331$9cLc.25205@fx02.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 07 Feb 2024 00:46:17 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 07 Feb 2024 00:46:17 GMT
X-Received-Bytes: 4055
 by: Scott Lurndal - Wed, 7 Feb 2024 00:46 UTC

Andreas Kempe <kempe@lysator.liu.se> writes:
>Den 2024-02-06 skrev Scott Lurndal <scott@slp53.sl.home>:
>> Andreas Kempe <kempe@lysator.liu.se> writes:
>>>Den 2024-02-06 skrev Keith Thompson <Keith.S.Thompson+u@gmail.com>:
>>>> Richard Kettlewell <invalid@invalid.invalid> writes:
>>
>>>>
>>>> I think we're mostly in agreement, perhaps with different understandings
>>>> of "making sense". What I'm saying is that the decision to make char a
>>>> signed type made sense for PDP-11 implementation, purely because of
>>>> performance issues.
>>>>
>>>> I just did a quick test on x86_64, x86, and ARM. It appears that
>>>> assigning either an unsigned char or a signed char to an int object
>>>> takes a single instruction. (My test didn't distinguish between
>>>> register or memory target.) I suspect there's no longer any performance
>>>> justification on most modern platforms for making plain char signed.
>>>> But there's like to be (bad or at least non-portable) code that depends
>>>> on plain char being signed. As it happens, plain char is unsigned in
>>>> gcc for ARM. And gcc has "-fsigned-char" and "-funsigned-char" options
>>>> to override the default.
>>>>
>>>
>>>I wouldn't expect any difference on a modern CPU. I did a microbench
>>>on my laptop with an Intel i5-8350U. clang on my FreeBSD uses movzbl
>>>and movsbl to move char to int so that's what I benched.
>>
>> A move from register to register isn't even executed on most modern
>> processor designs. It is detected at fetch and the register is
>> just renamed in the pipeline.
>>
>
>Yeah. I tried some different variations and by adding some data
>dependencies by incrementing the value and moving it around, I could
>get some difference between the two, approx 10 to 30 %, but I'm not
>sure how much is due to the instruction itself or other effects of
>manipulating the data.
>

The logic for sign extension (MOVSX) isn't complex, the added gate delay
wouldn't affect the instruction timing. Fan the sign bit out
to the higher bits through a couple of gates to either select the
sign bit or the high order bits when storing into the new register.

Sign extension on load (MOV from memory) will happen in the load unit before
it hits the register file, most likely.

The x86 MOVBE instruction is a slight more complex example.

>Funnily enough, the zero extend was the more performant in these tests
>making unsigned char possibly more performant.

Within what margin of measurement error?

>
>My intention wasn't really to claim they're exactly the same, but that
>that I don't think there is any real performance benefit to be had by
>switching char to unsigned. Even if the 10-30 % are a real thing, I
>wonder how much software is actually using char types in a way where
>it would make a difference?

We use uint8_t extensively because the data is unsigned in the range 0-255.

And generally want wrapping behavior modulo 2^8.

Re: Why 8 bit exit status codes?

<upuose$u2f$1@nyheter.lysator.liu.se>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11276&group=comp.unix.programmer#11276

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!nyheter.lysator.liu.se!.POSTED!not-for-mail
From: kem...@lysator.liu.se (Andreas Kempe)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Wed, 7 Feb 2024 02:11:26 -0000 (UTC)
Organization: Lysator ACS
Message-ID: <upuose$u2f$1@nyheter.lysator.liu.se>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<upro72$g01t$2@dont-email.me> <87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87sf25if5u.fsf@nosuchdomain.example.com>
<upueeh$psf$1@nyheter.lysator.liu.se> <vfzwN.269008$Ama9.259970@fx12.iad>
<upuin0$psf$2@nyheter.lysator.liu.se> <tpAwN.44331$9cLc.25205@fx02.iad>
Injection-Date: Wed, 7 Feb 2024 02:11:26 -0000 (UTC)
Injection-Info: nyheter.lysator.liu.se; posting-account="kempe";
logging-data="30799"; mail-complaints-to="newsmaster@lysator.liu.se"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Andreas Kempe - Wed, 7 Feb 2024 02:11 UTC

Den 2024-02-07 skrev Scott Lurndal <scott@slp53.sl.home>:
> Andreas Kempe <kempe@lysator.liu.se> writes:
>>Den 2024-02-06 skrev Scott Lurndal <scott@slp53.sl.home>:
>>> Andreas Kempe <kempe@lysator.liu.se> writes:
>>>>
>>>>I wouldn't expect any difference on a modern CPU. I did a microbench
>>>>on my laptop with an Intel i5-8350U. clang on my FreeBSD uses movzbl
>>>>and movsbl to move char to int so that's what I benched.
>>>
>>> A move from register to register isn't even executed on most modern
>>> processor designs. It is detected at fetch and the register is
>>> just renamed in the pipeline.
>>>
>>
>>Yeah. I tried some different variations and by adding some data
>>dependencies by incrementing the value and moving it around, I could
>>get some difference between the two, approx 10 to 30 %, but I'm not
>>sure how much is due to the instruction itself or other effects of
>>manipulating the data.
>>
>
> The logic for sign extension (MOVSX) isn't complex, the added gate delay
> wouldn't affect the instruction timing. Fan the sign bit out
> to the higher bits through a couple of gates to either select the
> sign bit or the high order bits when storing into the new register.
>
> Sign extension on load (MOV from memory) will happen in the load unit before
> it hits the register file, most likely.
>
> The x86 MOVBE instruction is a slight more complex example.
>
>
>>Funnily enough, the zero extend was the more performant in these tests
>>making unsigned char possibly more performant.
>
> Within what margin of measurement error?
>

Here's an example of a test I played around with. The body of my loop
does this 10M times for this test. movzbl is switched for movsbl when
testing the other configuration.

movzbl -24(%rsp), %eax
movb %al, -25(%rsp)
movzbl -25(%rsp), %eax
movb %al, -26(%rsp)
movzbl -26(%rsp), %eax
movb %al, -27(%rsp)
movzbl -27(%rsp), %eax
movb %al, -28(%rsp)
movzbl -28(%rsp), %eax
incl %eax
movb %al, -24(%rsp)

This is the data, unit is total cycles for a run, from 2000 runs of
10M each for the two different instructions:

movzbl:
mean = 1.24E+08
variance = 3.95E+12

movsbl:
mean = 1.38E+08
variance = 3.44E+12

ratio movsbl/movzbl = 1.11

Performing a two-tail student t-test gives

p-value: 0.00E+00

Something is causing these two test runs to give different performance
results. I will not pretend I know enough about the inner workings of
Intel's magic box to explain why.

>>
>>My intention wasn't really to claim they're exactly the same, but that
>>that I don't think there is any real performance benefit to be had by
>>switching char to unsigned. Even if the 10-30 % are a real thing, I
>>wonder how much software is actually using char types in a way where
>>it would make a difference?
>
> We use uint8_t extensively because the data is unsigned in the range 0-255.
>
> And generally want wrapping behavior modulo 2^8.

Sure, but if you are using uint8_t, you have sidestepped the whole
issues of char being signed or unsigned so a change wouldn't really
affect you.

Re: Why 8 bit exit status codes?

<wwvplx8y3bt.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11285&group=comp.unix.programmer#11285

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: inva...@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Wed, 07 Feb 2024 10:29:58 +0000
Organization: terraraq NNTP server
Message-ID: <wwvplx8y3bt.fsf@LkoBDZeT.terraraq.uk>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87sf25if5u.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="50626"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:pGgLbwchVjsWoI9C4GvAOq6eiGk=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Wed, 7 Feb 2024 10:29 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Richard Kettlewell <invalid@invalid.invalid> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>>> Signed characters make no sense.
>>>
>>> You wrote that "Signed characters make no sense". I was talking about a
>>> context in which they did make sense. How is that effectively what you
>>> said? (I was agreeing with and expanding on your statement about the
>>> PDP-11.)
>>
>> I still don’t see any explanation for signed characters as such making
>> sense.
>>
>> I think the situation is more accurately interpreted as letting a
>> PDP-11-specific optimization influence the language design, and
>> (temporarily) getting away with it because the character values they
>> cared about at the time happened to lie within a small enough range that
>> negative values didn’t arise.
>
> I think we're mostly in agreement, perhaps with different understandings
> of "making sense". What I'm saying is that the decision to make char a
> signed type made sense for PDP-11 implementation, purely because of
> performance issues.

Having a basic 8-bit integer type be signed type makes sense (in
context) for performance reasons and perhaps for usability reasons too.

But that’s really not the same as “signed characters make sense”. For
signed characters to make sense there has to be encoding where some
signs (or control codes, etc) are encoded to negative values. I’ve never
heard of one.

“char” isn’t just a random string of symbols. It’s obvious both from the
name and the way it’s used in the language that it’s intended to
represent characters, not just small integer values. If the purpose was
purely the latter it would have been called ‘short short int’ or
something like that.

> I just did a quick test on x86_64, x86, and ARM. It appears that
> assigning either an unsigned char or a signed char to an int object
> takes a single instruction. (My test didn't distinguish between
> register or memory target.) I suspect there's no longer any performance
> justification on most modern platforms for making plain char signed.
> But there's like to be (bad or at least non-portable) code that depends
> on plain char being signed. As it happens, plain char is unsigned in
> gcc for ARM. And gcc has "-fsigned-char" and "-funsigned-char" options
> to override the default.

i.e. we’re still suffering the locked-in side-effects of an ancient
decision even though the original justification has become irrelevant.
It might or might not have been a reasonable trade-off at the time,
disregarding what were then hypotheticals about the future, but (indeed
with hindsight) I think from today’s point of view it was clearly the
wrong decision.

--
https://www.greenend.org.uk/rjk/

Re: Why 8 bit exit status codes?

<weNwN.343222$xHn7.84170@fx14.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11297&group=comp.unix.programmer#11297

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Why 8 bit exit status codes?
Newsgroups: comp.unix.programmer
References: <upj3rq$da8$1@nyheter.lysator.liu.se> <87cytajwqe.fsf@nosuchdomain.example.com> <ups07m$h6mt$1@dont-email.me> <878r3yjpbr.fsf@nosuchdomain.example.com> <ups7vs$i2ic$5@dont-email.me> <87zfwei6n2.fsf@nosuchdomain.example.com> <wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk> <87sf25if5u.fsf@nosuchdomain.example.com> <upueeh$psf$1@nyheter.lysator.liu.se> <vfzwN.269008$Ama9.259970@fx12.iad> <upuin0$psf$2@nyheter.lysator.liu.se> <tpAwN.44331$9cLc.25205@fx02.iad> <upuose$u2f$1@nyheter.lysator.liu.se>
Lines: 53
Message-ID: <weNwN.343222$xHn7.84170@fx14.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 07 Feb 2024 15:22:04 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 07 Feb 2024 15:22:04 GMT
X-Received-Bytes: 2640
 by: Scott Lurndal - Wed, 7 Feb 2024 15:22 UTC

Andreas Kempe <kempe@lysator.liu.se> writes:
>Den 2024-02-07 skrev Scott Lurndal <scott@slp53.sl.home>:
>> Andreas Kempe <kempe@lysator.liu.se> writes:

>>>Funnily enough, the zero extend was the more performant in these tests
>>>making unsigned char possibly more performant.
>>
>> Within what margin of measurement error?
>>
>
>Here's an example of a test I played around with. The body of my loop
>does this 10M times for this test. movzbl is switched for movsbl when
>testing the other configuration.
>
>movzbl -24(%rsp), %eax
>movb %al, -25(%rsp)
>movzbl -25(%rsp), %eax
>movb %al, -26(%rsp)
>movzbl -26(%rsp), %eax
>movb %al, -27(%rsp)
>movzbl -27(%rsp), %eax
>movb %al, -28(%rsp)
>movzbl -28(%rsp), %eax
>incl %eax
>movb %al, -24(%rsp)
>
>This is the data, unit is total cycles for a run, from 2000 runs of
>10M each for the two different instructions:
>
>movzbl:
> mean = 1.24E+08
> variance = 3.95E+12
>
>movsbl:
> mean = 1.38E+08
> variance = 3.44E+12
>
>ratio movsbl/movzbl = 1.11

Sehr interresant. Ich weiss nicht, warum es ist.

>> We use uint8_t extensively because the data is unsigned in the range 0-255.
>>
>> And generally want wrapping behavior modulo 2^8.
>
>Sure, but if you are using uint8_t, you have sidestepped the whole
>issues of char being signed or unsigned so a change wouldn't really
>affect you.

While most C compilers have a compile-time option to select the signed-ness of
char, using uint8_t sidesteps the issue completely.

Re: Why 8 bit exit status codes?

<87r0hoqokw.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=11301&group=comp.unix.programmer#11301

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweiku...@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: Why 8 bit exit status codes?
Date: Wed, 07 Feb 2024 15:30:23 +0000
Lines: 28
Message-ID: <87r0hoqokw.fsf@doppelsaurus.mobileactivedefense.com>
References: <upj3rq$da8$1@nyheter.lysator.liu.se>
<EP8vN.39265$Wbff.38272@fx37.iad>
<upjho8$hek$1@nyheter.lysator.liu.se>
<w3cvN.322279$c3Ea.250268@fx10.iad>
<upjmam$hek$2@nyheter.lysator.liu.se>
<87cytenve7.fsf@nosuchdomain.example.com>
<upmbnj$39vft$2@dont-email.me> <1bwmrkaoow.fsf@pfeifferfamily.net>
<qv52si5cvkajlf7fdcidur6elhism0u2su@dim53.demon.nl>
<upro72$g01t$2@dont-email.me>
<87cytajwqe.fsf@nosuchdomain.example.com>
<ups07m$h6mt$1@dont-email.me>
<878r3yjpbr.fsf@nosuchdomain.example.com>
<ups7vs$i2ic$5@dont-email.me>
<87zfwei6n2.fsf@nosuchdomain.example.com>
<wwvttmlv87q.fsf@LkoBDZeT.terraraq.uk>
<87sf25if5u.fsf@nosuchdomain.example.com>
<wwvplx8y3bt.fsf@LkoBDZeT.terraraq.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net L4FqG5ZfUcbXFs58EhShyAJuNCVMDOfiHD8IEYbThRUYuHujE=
Cancel-Lock: sha1:dnkNF6tMF/WL9Q5kT73yXrk3hI4= sha1:ypb6bu4zfcwJG5pPW7nhwozatiw= sha256:Bbg4dwICBgnAHqwaxsx9tbMOJS7SPdJp/Wheqfmj4ps=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Rainer Weikusat - Wed, 7 Feb 2024 15:30 UTC

Richard Kettlewell <invalid@invalid.invalid> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

[...]

>> I think we're mostly in agreement, perhaps with different understandings
>> of "making sense". What I'm saying is that the decision to make char a
>> signed type made sense for PDP-11 implementation, purely because of
>> performance issues.
>
> Having a basic 8-bit integer type be signed type makes sense (in
> context) for performance reasons and perhaps for usability reasons too.
>
> But that’s really not the same as “signed characters make sense”. For
> signed characters to make sense there has to be encoding where some
> signs (or control codes, etc) are encoded to negative values. I’ve never
> heard of one.
>
> “char” isn’t just a random string of symbols. It’s obvious both from the
> name and the way it’s used in the language that it’s intended to
> represent characters, not just small integer values.

Computers have absolutely no idea of "characters". They handle numbers,
integer numbers in this case, and humans then interpret them as
characters based on some convention for encoding characters as
integers. Hence, a data type suitable for holding an encoded character
(ie, an integer value from 0 - 127 for the case in question) is not the
same as a character.


devel / comp.unix.programmer / Why 8 bit exit status codes?

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor