9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: adr <adr@SDF.ORG>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] ntohl, htonl, &c
Date: Fri, 13 May 2022 15:51:27 +0000 (UTC)	[thread overview]
Message-ID: <55a533b9-5b8f-a89-5c80-bf55b7d9031@SDF.ORG> (raw)
In-Reply-To: <7528AA612E26746F7C665AA5D5472930@eigenstate.org>

On Fri, 13 May 2022, ori@eigenstate.org wrote:

> Date: Fri, 13 May 2022 10:22:13 -0400
> From: ori@eigenstate.org
> Reply-To: 9fans <9fans@9fans.net>
> To: 9fans@9fans.net
> Subject: Re: [9fans] ntohl, htonl, &c
> 
> Quoth Alex Musolino <alex@musolino.id.au>:
>>> I'm getting rid of ape but I need the functions at
>>> /sys/src/ape/lib/bsd/ntohl.c to port some software.  These functions
>>> just change endianness.  Is there some native similar functions
>>> somebody is aware of?  lookman is not helping me here.  I don't want
>>> to add code if a similar functionality is already in the system.
>>
>> No. Those functions are mental.  The Plan 9 way is so simple that
>> there's no library, everyone just brings their own macros/functions.
>> The trick is: if you care about the order of bytes then you should be
>> dealing with a byte array, not a native integral type.
>
> see also:
>
> https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html

Oh, I agree with that and I think this was a key in the design of
9p. I wasn't asking for the existence of those functions elsewhere,
but for some common code to change endianness of some data structure,
stream, etc. Not because is hard to do, just to not repeat the same
code again and again. Every format of image, audio, etc store
data in a determinded endianness, so I imagined that some functions
or macros could be defined already somewhere.

Regards,
adr.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tbf58310b561cd180-Mf37677730df2f6e32e400995
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

  reply	other threads:[~2022-05-13 15:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13 11:50 adr
2022-05-13 13:11 ` Alex Musolino
2022-05-13 14:22   ` ori
2022-05-13 15:51     ` adr [this message]
2022-05-13 16:42       ` adr
2022-05-13 21:23       ` ori
2022-05-13 22:29         ` Steve Simon
2022-05-13 22:37           ` ori
2022-05-14 10:45         ` adr

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=55a533b9-5b8f-a89-5c80-bf55b7d9031@SDF.ORG \
    --to=adr@sdf.org \
    --cc=9fans@9fans.net \
    /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).