unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Oscar Najera <hi@oscarnajera.com>
To: emacs-devel@gnu.org
Subject: [PATCH] Complete bindat.el package for 64-bit unsigned int
Date: Tue, 29 Nov 2022 19:10:02 +0100	[thread overview]
Message-ID: <87ilixbpj9.fsf@oscarnajera.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 158 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Complete-bindat.el-package-for-64-bit-unsigned-int.patch --]
[-- Type: text/x-patch, Size: 2347 bytes --]

From a63577cce6b0b47f2962cabfe35f1ca020b17057 Mon Sep 17 00:00:00 2001
From: Oscar Najera <hi@oscarnajera.com>
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


             reply	other threads:[~2022-11-29 18:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 18:10 Oscar Najera [this message]
2022-11-29 20:06 ` [PATCH] Complete bindat.el package for 64-bit unsigned int Stefan Monnier
2022-11-30  1:17   ` Oscar Najera
2022-11-30  2:44     ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilixbpj9.fsf@oscarnajera.com \
    --to=hi@oscarnajera.com \
    --cc=emacs-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).