[OpenBIOS] r549 - trunk/openbios-devel/fs
svn at openbios.org
svn at openbios.org
Tue Aug 11 22:31:50 CEST 2009
Author: laurent
Date: 2009-08-11 22:31:50 +0200 (Tue, 11 Aug 2009)
New Revision: 549
Modified:
trunk/openbios-devel/fs/hfs_mdb.h
Log:
Author: Pavel Roskin <proski at gnu.org>
Rewrite hfs_get_ushort() and hfs_get_uint() as inline functions so that
their arguments are checked. Use __be16_to_cpu and __be32_to_cpu to
byte-swap the result as needed.
Modified: trunk/openbios-devel/fs/hfs_mdb.h
===================================================================
--- trunk/openbios-devel/fs/hfs_mdb.h 2009-08-11 20:27:17 UTC (rev 548)
+++ trunk/openbios-devel/fs/hfs_mdb.h 2009-08-11 20:31:50 UTC (rev 549)
@@ -15,13 +15,22 @@
#ifndef _H_HFS_MDB
#define _H_HFS_MDB
+#include "libc/byteorder.h"
+
typedef unsigned char hfs_char_t;
typedef unsigned char hfs_ushort_t[2];
typedef unsigned char hfs_uint_t[4];
-#define hfs_get_ushort(addr) (*((unsigned short*)(addr)))
-#define hfs_get_uint(addr) (*((unsigned int*)(addr)))
+static inline unsigned short hfs_get_ushort(hfs_ushort_t addr)
+{
+ return __be16_to_cpu(*((unsigned short *)(addr)));
+}
+static inline unsigned int hfs_get_uint(hfs_uint_t addr)
+{
+ return __be32_to_cpu(*((unsigned int *)(addr)));
+}
+
/*
* The HFS Master Directory Block (MDB).
*
More information about the OpenBIOS
mailing list