git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/6] bswap: add 64 bit endianness helper get_be64

From
Ben Peart <peartben@gmail.com>
Date
May 25, 2017, 18:36 UTC
Message-ID
<20170525183612.3128-2-benpeart@microsoft.com>
In-Reply-To
<20170525183612.3128-1-benpeart@microsoft.com>

Add a new get_be64 macro to enable 64 bit endian conversions on memory that may or may not be aligned.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
---
 compat/bswap.h | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/compat/bswap.h b/compat/bswap.h
index d47c003544..f89fe7f4b5 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -158,6 +158,7 @@ static inline uint64_t git_bswap64(uint64_t x)
 
 #define get_be16(p)	ntohs(*(unsigned short *)(p))
 #define get_be32(p)	ntohl(*(unsigned int *)(p))
+#define get_be64(p)	ntohll(*(uint64_t *)(p))
 #define put_be32(p, v)	do { *(unsigned int *)(p) = htonl(v); } while (0)
 
 #else
@@ -170,6 +171,9 @@ static inline uint64_t git_bswap64(uint64_t x)
 	(*((unsigned char *)(p) + 1) << 16) | \
 	(*((unsigned char *)(p) + 2) <<  8) | \
 	(*((unsigned char *)(p) + 3) <<  0) )
+#define get_be64(p)	( \
+	((uint64_t)get_be32((unsigned char *)(p) + 0) << 32) | \
+	((uint64_t)get_be32((unsigned char *)(p) + 4) <<  0)
 #define put_be32(p, v)	do { \
 	unsigned int __v = (v); \
 	*((unsigned char *)(p) + 0) = __v >> 24; \
-- 
2.13.0.windows.1.9.gc201c67b71
Previous: Ben PeartNext: Ben Peart
Message 2 of 14 in “Fast git status via a file system watcher”
  1. 0/6 Fast git status via a file system watcherBen Peart, May 25, 2017
  2. 1/6 bswap: add 64 bit endianness helper get_be64Ben Peart, May 25, 2017
  3. 6/6 fsmonitor: add a sample query-fsmonitor hook script for WatchmanBen Peart, May 25, 2017
  4. Christian CouderMay 31, 2017
  5. 3/6 fsmonitor: teach git to optionally utilize a file system monitor to speed up detecting new or changed files.Ben Peart, May 25, 2017
  6. 5/6 fsmonitor: add documentation for the fsmonitor extension.Ben Peart, May 25, 2017
  7. 2/6 dir: make lookup_untracked() available outside of dir.cBen Peart, May 25, 2017
  8. 4/6 fsmonitor: add test cases for fsmonitor extensionBen Peart, May 25, 2017
  9. Christian CouderMay 30, 2017
  10. Ben PeartMay 30, 2017
  11. Junio C HamanoMay 30, 2017
  12. Ben PeartMay 31, 2017
  13. Christian CouderMay 31, 2017
  14. Ben PeartMay 31, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.