From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RDNS_NONE,T_SCC_BODY_TEXT_LINE, URIBL_CSS autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 25002 invoked from network); 13 May 2022 13:12:37 -0000 Received: from unknown (HELO tb-ob1.topicbox.com) (64.147.108.173) by inbox.vuxu.org with ESMTPUTF8; 13 May 2022 13:12:37 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob1.topicbox.com (Postfix) with ESMTP id 24BBA1CE0D for ; Fri, 13 May 2022 09:12:22 -0400 (EDT) (envelope-from bounce.mM0b8f2ed4b88270bf7dd090ab.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 21C6423C95E9; Fri, 13 May 2022 09:12:22 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=musolino.id.au; spf=pass smtp.mailfrom=alex@musolino.id.au smtp.helo=vultr.musolino.id.au; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=message-id:to:subject:from:date:in-reply-to :mime-version:content-type:content-transfer-encoding:list-help :list-id:list-post:list-subscribe:reply-to:list-unsubscribe; s= sysmsg-1; t=1652447542; bh=wrfxaZkDxTWGEfoXlh2uWLNJlCsmitZw0nXz2 LeIS4E=; b=GITN+M8UdJvxgmtwRE1YEoc1z2anbytAYyQFGBUdtZbSVwHq8vDeB wTTQbVfqxPoviBrEDiPd5Fh9hehr39TUPYjSFmYPQfLHEsIJMzmGc60YLaIcSmty ddQZH9PZ79ctzRtZB+Zse9lBoXkzIcT5pYUTCCJSas/NQDDNfd4BHU= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1652447542; b=gKMecsM6wDo81owdrPbDAiztBABSuVtgviSJTnr7SS5girt9ok oEKfCMc5/vV2qTUEff5VxrzCDOkM6qNeJ93B//VFnn+OwhJ/T+ptC+JaN7uqtZLX G6l1naXdf4hjeK6MzbzmguUsz5qTwP0q53toOPD3lRiHOZDf9KvCU2EDg= Authentication-Results: topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=musolino.id.au; spf=pass smtp.mailfrom=alex@musolino.id.au smtp.helo=vultr.musolino.id.au; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=musolino.id.au; iprev=pass smtp.remote-ip=45.76.123.158 (vultr.musolino.id.au); spf=pass smtp.mailfrom=alex@musolino.id.au smtp.helo=vultr.musolino.id.au; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=vultr.musolino.id.au policy.ptr=vultr.musolino.id.au; x-return-mx=pass header.domain=musolino.id.au policy.is_org=yes (MX Records found: musolino.id.au); x-return-mx=pass smtp.domain=musolino.id.au policy.is_org=yes (MX Records found: musolino.id.au); x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=message-id :to:subject:from:date:in-reply-to:mime-version:content-type :content-transfer-encoding:list-help:list-id:list-post :list-subscribe:reply-to:list-unsubscribe; s=dkim-1; bh=K1ER4oIa Uy5Ty+/JoYzeH/5ZiVe8V4V8DE2/5O+AqR8=; b=SsMMrW5lojIL4TdZo5ARq4R3 +Wq0RLvvAmfN5LNPpSpnLiNR7posUwizUHKoFViEbMVICwCNDxRBx4JXQGZa7c7x 372pYlKBfu/tRGBCFc3qVWwoAnmf8QiaS/vJA2fVY7wwRmxFmsyq6ZxU4Mfn9fJm iy7ZB3JFFaIPp80Vykk= Received: from tb-mx0.topicbox.com (localhost.local [127.0.0.1]) by tb-mx0.topicbox.com (Postfix) with ESMTP id 3865E23C8CD8 for <9fans@9fans.net>; Fri, 13 May 2022 09:12:08 -0400 (EDT) (envelope-from alex@musolino.id.au) Received: from tb-mx0.topicbox.com (localhost [127.0.0.1]) by tb-mx0.topicbox.com (Authentication Milter) with ESMTP id 7388942F037; Fri, 13 May 2022 09:12:08 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1652447528; b=PuT9nfgzMcsN7N72viNSS61kis+sDABS+Hw9ozyN8iNk1Ui1y+ zbkxYX/rj2P5ipacDvy/gIwfQgduru1rPvj/eRvHoFJ6Jb1uQa604wta0R83PujI byUyFDCf5jLtH4TaFC/1VsN+6np285Zw4VCkQeavfZ3sgjM8nphYm+9OAUffbyNm QzIWuoHd9MJEjJ81g4NzFbbqXd+PTGXRFiSV5YLlVwhlRS8Ge8QoVNS/UHb/WqMA g3buqLplo7i/STA4ZAXgiMZKBCiPOprxk1ZdHcbZ/bAMQlDwLU1C9TzTxdm8Dkbh NVc30FoTcFXmFXyZZ20nd8YT1Tu402oS6KMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=message-id:to:subject:from:date:in-reply-to :mime-version:content-type:content-transfer-encoding; s=arcseal; t=1652447528; bh=DBEpd0Se69x+VP3cP3UdaZ0rpG+NGgOWgoBSMnDWrDo=; b= Vzmb2fhG/54MMeIQoSpXg1AobPxj79enOU+z5S1SplaptIKYZQyB06RmBCkCCWLt AGyPE8NP71aM22ThWmLGdRnJ0LBlEJ66tJaUZYhaGRWRH3C49CGD+40WpNDuHBJ2 oAAdr9nMlKfuXRba8mgDqhrQNGgtIc+E+hz3OsCWkrJ0o9b8L0iKFzCnmFoF3jh/ ctb9UgtF9siO/HZEG1YqEtq4xBDtcc09qD7Xi9k/EE1XZ8E3ZSY1AcDkTirB+/Rz R+YdkWSpsQjKsM37eBsMnHwsaf4hYGhezfARxFII+ufZ/xiLlJhAwLEKehmhAX6a lbnHUoc92lngfeipIWniAg== ARC-Authentication-Results: i=1; tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=musolino.id.au; iprev=pass smtp.remote-ip=45.76.123.158 (vultr.musolino.id.au); spf=pass smtp.mailfrom=alex@musolino.id.au smtp.helo=vultr.musolino.id.au; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=vultr.musolino.id.au policy.ptr=vultr.musolino.id.au; x-return-mx=pass header.domain=musolino.id.au policy.is_org=yes (MX Records found: musolino.id.au); x-return-mx=pass smtp.domain=musolino.id.au policy.is_org=yes (MX Records found: musolino.id.au); x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvfedrgeelgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkffvuffhff gjgggtgfesthejjedttddtvdenucfhrhhomheptehlvgigucfouhhsohhlihhnohcuoegr lhgvgiesmhhushholhhinhhordhiugdrrghuqeenucggtffrrghtthgvrhhnpeejheeltd evhefhkeeuudfhueevvddvfeekgeelhfffheevjeekgfffudehgefhgfenucfkphepgeeh rdejiedruddvfedrudehkedpudektddrudehtddrudduvddrudeikeenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeghedrjeeirdduvdefrdduheekpdhh vghlohepvhhulhhtrhdrmhhushholhhinhhordhiugdrrghupdhmrghilhhfrhhomhepoe grlhgvgiesmhhushholhhinhhordhiugdrrghuqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (musolino.id.au: 45.76.123.158 is authorized to use 'alex@musolino.id.au' in 'mfrom' identity (mechanism 'ip4:45.76.123.158' matched)) receiver=tb-mx0.topicbox.com; identity=mailfrom; envelope-from="alex@musolino.id.au"; helo=vultr.musolino.id.au; client-ip=45.76.123.158 Received: from vultr.musolino.id.au (vultr.musolino.id.au [45.76.123.158]) by tb-mx0.topicbox.com (Postfix) with ESMTP for <9fans@9fans.net>; Fri, 13 May 2022 09:12:06 -0400 (EDT) (envelope-from alex@musolino.id.au) Received: from 180.150.112.168 ([180.150.112.168]) by vultr; Fri May 13 23:11:48 +1000 2022 Message-ID: <13F82633F6415657513741E64A249C22@musolino.id.au> To: 9fans@9fans.net Subject: Re: [9fans] ntohl, htonl, &c From: Alex Musolino Date: Fri, 13 May 2022 22:41:47 +0930 In-Reply-To: <929c3e53-53bf-29c1-d9ef-83d6949d7f57@SDF.ORG> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 4e13f056-d2be-11ec-92da-bc0f4c2254cb Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UYmY1ODMxMGI1NjFjZDE4MC1NMGI4ZjJlZDRiODgyNzBiZjdkZDA5?= =?UTF-8?B?MGFiPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:M0b8f2ed4b88270bf7dd090ab:1:06TnL013E30LIbw9-qgTQ9jCZklxWqxcOq9-ZePLQNk > 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. These are from Ori's git implementation though there are other, similar implementations around the place (e.g. lib9p, venti). They do the job perfectly well. #define GETBE32(b) \ ((((b)[0] & 0xFFul) << 24) | \ (((b)[1] & 0xFFul) << 16) | \ (((b)[2] & 0xFFul) << 8) | \ (((b)[3] & 0xFFul) << 0)) #define PUTBE32(b, n)\ do{ \ (b)[0] =3D (n) >> 24; \ (b)[1] =3D (n) >> 16; \ (b)[2] =3D (n) >> 8; \ (b)[3] =3D (n) >> 0; \ } while(0) Little endian versions proceed similarly: #define GETLE32(b) \ ((((b)[0] & 0xFFul) << 0) | \ (((b)[1] & 0xFFul) << 8) | \ (((b)[2] & 0xFFul) << 16) | \ (((b)[3] & 0xFFul) << 24)) #define PUTLE32(b, n)\ do{ \ (b)[0] =3D (n) >> 0; \ (b)[1] =3D (n) >> 8; \ (b)[2] =3D (n) >> 16; \ (b)[3] =3D (n) >> 24; \ } while(0) The 16-bit and 64-bit versions should be obvious. For porting I'd just use APE, or copy the bits and pieces you need. ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tbf58310b561cd180-M0b8f2= ed4b88270bf7dd090ab Delivery options: https://9fans.topicbox.com/groups/9fans/subscription