From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Oscar Najera Newsgroups: gmane.emacs.devel Subject: [PATCH] Complete bindat.el package for 64-bit unsigned int Date: Tue, 29 Nov 2022 19:10:02 +0100 Message-ID: <87ilixbpj9.fsf@oscarnajera.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17071"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 29 19:23:45 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p05Gi-0004DM-3C for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Nov 2022 19:23:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p05GC-00009j-9g; Tue, 29 Nov 2022 13:23:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p053q-0003jf-OP for emacs-devel@gnu.org; Tue, 29 Nov 2022 13:10:27 -0500 Original-Received: from vmd57947.contaboserver.net ([95.111.247.99] helo=mail.oscarnajera.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p053p-0005qm-5n for emacs-devel@gnu.org; Tue, 29 Nov 2022 13:10:26 -0500 Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.oscarnajera.com (Postfix) with ESMTPSA id 0C65840264 for ; Tue, 29 Nov 2022 18:10:14 +0000 (UTC) Received-SPF: pass client-ip=95.111.247.99; envelope-from=hi@oscarnajera.com; helo=mail.oscarnajera.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 29 Nov 2022 13:23:10 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300719 Archived-At: --=-=-= Content-Type: text/plain Hello, I needed to read 64-bit unsigned ints. It is a small change, looking forward for any feedback. It is the first time I submit a patch. Cheers, Oscar --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Complete-bindat.el-package-for-64-bit-unsigned-int.patch >From a63577cce6b0b47f2962cabfe35f1ca020b17057 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Tue, 29 Nov 2022 18:35:44 +0100 Subject: [PATCH] Complete bindat.el package for 64-bit unsigned int --- lisp/emacs-lisp/bindat.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el index 82d3c53..8946743 100644 --- a/lisp/emacs-lisp/bindat.el +++ b/lisp/emacs-lisp/bindat.el @@ -150,6 +150,9 @@ (defun bindat--unpack-u32 () (logior (ash (bindat--unpack-u16) 16) (bindat--unpack-u16))) +(defun bindat--unpack-u64 () + (logior (ash (bindat--unpack-u32) 32) (bindat--unpack-u32))) + (defun bindat--unpack-u16r () (logior (bindat--unpack-u8) (ash (bindat--unpack-u8) 8))) @@ -159,6 +162,9 @@ (defun bindat--unpack-u32r () (logior (bindat--unpack-u16r) (ash (bindat--unpack-u16r) 16))) +(defun bindat--unpack-u64r () + (logior (bindat--unpack-u32r) (ash (bindat--unpack-u32r) 32))) + (defun bindat--unpack-str (len) (let ((s (substring bindat-raw bindat-idx (+ bindat-idx len)))) (setq bindat-idx (+ bindat-idx len)) @@ -197,9 +203,11 @@ ((or 'u16 'word 'short) (bindat--unpack-u16)) ('u24 (bindat--unpack-u24)) ((or 'u32 'dword 'long) (bindat--unpack-u32)) + ('u64 (bindat--unpack-u64)) ('u16r (bindat--unpack-u16r)) ('u24r (bindat--unpack-u24r)) ('u32r (bindat--unpack-u32r)) + ('u64r (bindat--unpack-u64r)) ('bits (bindat--unpack-bits len)) ('str (bindat--unpack-str len)) ('strz (bindat--unpack-strz len)) @@ -317,6 +325,7 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..." (u16 . 2) (u16r . 2) (word . 2) (short . 2) (u24 . 3) (u24r . 3) (u32 . 4) (u32r . 4) (dword . 4) (long . 4) + (u64 . 8) (u64r . 8) (ip . 4))) (defun bindat--length-group (struct spec) @@ -486,9 +495,11 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..." ((or 'u16 'word 'short) (bindat--pack-u16 v)) ('u24 (bindat--pack-u24 v)) ((or 'u32 'dword 'long) (bindat--pack-u32 v)) + ('u64 (bindat--pack-u64 v)) ('u16r (bindat--pack-u16r v)) ('u24r (bindat--pack-u24r v)) ('u32r (bindat--pack-u32r v)) + ('u64r (bindat--pack-u64r v)) ('bits (bindat--pack-bits len v)) ('str (bindat--pack-str len v)) ('strz (bindat--pack-strz len v)) -- 2.38.1 --=-=-=--