From c5268dd3aa47124a151346cb5aae5bd9ce41aeb8 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 23 Apr 1996 18:00:25 +0000 Subject: (swab_disk): New variable. (swab_short, swab_long): New functions. (read_disk_entry, write_disk_entry): New macros. --- ufs/ufs.h | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/ufs/ufs.h b/ufs/ufs.h index ba778e1d..dba7acd9 100644 --- a/ufs/ufs.h +++ b/ufs/ufs.h @@ -187,19 +187,32 @@ swab_long (long arg) | ((arg & 0xff000000) >> 24)); } -/* Return *ENTRYP, after byteswapping it if necessary */ -#define read_disk_entry(entryp) \ +/* Return ENTRY, after byteswapping it if necessary */ +#define read_disk_entry(entry) \ ({ \ - if (!swab_disk || sizeof (*entryp) == 1) \ - *entryp; \ - else if (sizeof (*entryp) == 2) \ - swab_short (*entryp); \ - else if (sizeof (*entry) == 4) \ - swab_long (*entryp); \ + if (!swab_disk || sizeof (entry) == 1) \ + (entry); \ + else if (sizeof (entry) == 2) \ + swab_short (entry); \ + else if (sizeof (entry) == 4) \ + swab_long (entry); \ else \ - abort; \ + abort (); \ }) +/* Execute A = B, but byteswap it along the way if necessary */ +#define write_disk_entry(a,b) \ +({ \ + if (!swab_disk || sizeof (a) == 1) \ + ((a) = (b)); \ + else if (sizeof (a) == 2) \ + ((a) = (swab_short (b))); \ + else if (sizeof (a) == 4) \ + ((a) = (swab_long (b))); \ + else \ + abort (); \ +}) + -- cgit v1.2.3