hi Robert,

  Vitaly proposed a patch to fix mkfs.reiser4 on sparc64. unfortunately
i've no time to apply and test it right now. feel free to test it on
your own.

cheers
domenico

----- Forwarded message from Vitaly Fertman <[EMAIL PROTECTED]> -----

Date: Mon, 17 Jan 2005 01:27:12 +0300
From: Vitaly Fertman <[EMAIL PROTECTED]>
Subject: Re: Bug#289747: reiser4progs: mkfs.reiser4 is broken on sparc64

On Friday 14 January 2005 17:17, Domenico Andreoli wrote:
> On Fri, Jan 14, 2005 at 04:52:18PM +0300, Vitaly Fertman wrote:
> > On Friday 14 January 2005 12:05, Domenico Andreoli wrote:
> >
> > my ip is 195.131.124.64.
> > I would like to start this evening/tomorrow morning,
> > if you don't mind.
>
> the tunnel is already up. start whenever you want. it is a ADSL link
> so it might be slow if you want to transfer tens of megabytes.

the attached patches fixed the unaligned access in reiser4progs for me.
mkfs, fsck, debugfs worked fine. would you double test patches and 
email me about the result please.

-- 
Thanks,
Vitaly Fertman

diff -rup reiser4progs-1.0.3/plugin/item/cde40/cde40.h 
reiser4progs-1.0.3-1/plugin/item/cde40/cde40.h
--- reiser4progs-1.0.3/plugin/item/cde40/cde40.h        2004-06-30 
01:42:33.000000000 +0200
+++ reiser4progs-1.0.3-1/plugin/item/cde40/cde40.h      2005-01-16 
22:57:58.000000000 +0100
@@ -33,6 +33,7 @@ struct objid3 {
 
 typedef struct objid3 objid3_t;
 
+
 struct hash3 {
        d8_t objectid[8];
        d8_t offset[8];
@@ -130,71 +131,76 @@ extern uint32_t cde40_cut(reiser4_place_
 extern uint16_t cde40_overhead();
 
 #if defined(ENABLE_SHORT_KEYS) && defined(ENABLE_LARGE_KEYS)
+
+/* objidN_t macroses. */
+#define ob_loc(ob, pol)                                                        
\
+       ((pol == 3) ?                                                   \
+        ((objid3_t *)(ob))->locality :                                 \
+        ((objid4_t *)(ob))->locality)
+ 
 #define ob_get_locality(ob, pol)                                       \
-        ((pol == 3) ?                                                  \
-        LE64_TO_CPU(*((d64_t *)((objid3_t *)(ob))->locality)) :        \
-        LE64_TO_CPU(*((d64_t *)((objid4_t *)(ob))->locality)))
+       LE64_TO_CPU(get_unaligned((d64_t *)ob_loc(ob, pol)))
 
 #define ob_set_locality(ob, val, pol)                                  \
-        ((pol == 3) ?                                                  \
-        (*(d64_t *)((objid3_t *)(ob))->locality) = CPU_TO_LE64(val) :  \
-        (*(d64_t *)((objid4_t *)(ob))->locality) = CPU_TO_LE64(val))
+       put_unaligned((d64_t *)ob_loc(ob, pol), CPU_TO_LE64(val))
+
+#define ob_oid(ob, pol)                                                        
\
+       ((pol == 3) ?                                                   \
+        ((objid3_t *)(ob))->objectid :                                 \
+        ((objid4_t *)(ob))->objectid)
 
 #define ob_get_objectid(ob, pol)                                       \
-        ((pol == 3) ?                                                  \
-        LE64_TO_CPU(*((d64_t *)((objid3_t *)(ob))->objectid)) :        \
-        LE64_TO_CPU(*((d64_t *)((objid4_t *)(ob))->objectid)))
+       LE64_TO_CPU(get_unaligned((d64_t *)ob_oid(ob, pol)))
 
 #define ob_set_objectid(ob, val, pol)                                  \
-        ({if (pol == 3)                                                        
\
-        (*(d64_t *)((objid3_t *)(ob))->objectid) = CPU_TO_LE64(val);   \
-         else                                                          \
-        (*(d64_t *)((objid4_t *)(ob))->objectid) = CPU_TO_LE64(val);})
+       put_unaligned((d64_t *)ob_oid(ob, pol), CPU_TO_LE64(val))
+
+#define ob_ord(ob, pol) ((pol == 3) ? 0 : ((objid4_t *)(ob))->ordering)
 
 #define ob_get_ordering(ob, pol)                                       \
-        ((pol == 3) ? 0 :                                              \
-        LE64_TO_CPU(*((d64_t *)((objid4_t *)(ob))->ordering)))
+       LE64_TO_CPU(get_unaligned((d64_t *)ob_ord(ob, pol)))
 
 #define ob_set_ordering(ob, val, pol)                                  \
-        ({if (pol == 3) do {} while(0); else                           \
-        (*(d64_t *)((objid4_t *)(ob))->ordering) = CPU_TO_LE64(val);})
+       ({if (pol == 3) do {} while(0); else                            \
+        put_unaligned((d64_t *)ob_ord(ob, pol), CPU_TO_LE64(val));})
 
-#define ob_size(pol)                                                   \
-        ((pol == 3) ? sizeof(objid3_t) : sizeof(objid4_t))
+#define ob_size(pol) ((pol == 3) ? sizeof(objid3_t) : sizeof(objid4_t))
+
+/* hashN_t macroses.  */
+#define ha_oid(ha, pol)                                                        
\
+       ((pol == 3) ?                                                   \
+        ((hash3_t *)(ha))->objectid :                                  \
+        ((hash4_t *)(ha))->objectid)
 
 #define ha_get_objectid(ha, pol)                                       \
-        ((pol == 3) ?                                                  \
-        LE64_TO_CPU(*((d64_t *)((hash3_t *)(ha))->objectid)) :         \
-        LE64_TO_CPU(*((d64_t *)((hash4_t *)(ha))->objectid)))
+       LE64_TO_CPU(get_unaligned((d64_t *)ha_oid(ha, pol)))
 
 #define ha_set_objectid(ha, val, pol)                                  \
-        ({if (pol == 3)                                                        
\
-         (*(d64_t *)((hash3_t *)(ha))->objectid) = CPU_TO_LE64(val);   \
-        else                                                           \
-        (*(d64_t *)((hash4_t *)(ha))->objectid) = CPU_TO_LE64(val);})
+       put_unaligned((d64_t *)ha_oid(ha, pol),  CPU_TO_LE64(val))
+
+#define ha_off(ha, pol)                                                        
\
+       ((pol == 3) ?                                                   \
+        ((hash3_t *)(ha))->offset :                                    \
+        ((hash4_t *)(ha))->offset)
 
 #define ha_get_offset(ha, pol)                                         \
-        ((pol == 3) ?                                                  \
-         LE64_TO_CPU(*((d64_t *)((hash3_t *)(ha))->offset)) :          \
-        LE64_TO_CPU(*((d64_t *)((hash4_t *)(ha))->offset)))
-        
+       LE64_TO_CPU(get_unaligned((d64_t *)ha_off(ha, pol)))
+
 #define ha_set_offset(ha, val, pol)                                    \
-        ({if (pol == 3)                                                        
\
-        (*(d64_t *)((hash3_t *)(ha))->offset) = CPU_TO_LE64(val);      \
-        else                                                           \
-        (*(d64_t *)((hash4_t *)(ha))->offset) = CPU_TO_LE64(val);})
+       put_unaligned((d64_t *)ha_off(ha, pol), CPU_TO_LE64(val))
+
+#define ha_ord(ha, pol) ((pol == 3) ? 0 : ((hash4_t *)(ha))->ordering)
 
 #define ha_get_ordering(ha, pol)                                       \
-        ((pol == 3) ? 0 :                                              \
-        LE64_TO_CPU(*((d64_t *)((hash4_t *)(ha))->ordering)))
-        
+       LE64_TO_CPU(get_unaligned((d64_t *)ha_ord(ha, pol)))
+
 #define ha_set_ordering(ha, val, pol)                                  \
-        ({if (pol == 3) do {} while(0); else                           \
-        (*(d64_t *)((hash4_t *)(ha))->ordering) = CPU_TO_LE64(val);})
+       ({if (pol == 3) do {} while(0); else                            \
+        put_unaligned((d64_t *)ha_ord(ha, pol), CPU_TO_LE64(val));})
 
-#define ha_size(pol)                                                   \
-        ((pol == 3) ? sizeof(hash3_t) : sizeof(hash4_t))
+#define ha_size(pol) ((pol == 3) ? sizeof(hash3_t) : sizeof(hash4_t))
 
+/* entryN_t macroses */
 #define en_get_offset(en, pol)                                         \
         ((pol == 3) ?                                                  \
         aal_get_le16(((entry3_t *)(en)), offset) :                     \
@@ -214,97 +220,108 @@ extern uint16_t cde40_overhead();
         (void *)(&((cde403_t *)(pl)->body)->entry[pos]) :              \
         (void *)(&((cde404_t *)(pl)->body)->entry[pos]))
 
-#else
-#if defined(ENABLE_SHORT_KEYS)
+#elif defined(ENABLE_SHORT_KEYS)
+
+/* objidN_t macroses.  */
 #define ob_get_locality(ob, pol)                                       \
-        LE64_TO_CPU(*((d64_t *)((objid3_t *)(ob))->locality))
+       LE64_TO_CPU(get_unaligned((d64_t *)((objid3_t *)(ob))->locality))
 
 #define ob_set_locality(ob, val, pol)                                  \
-        (*(d64_t *)((objid3_t *)(ob))->locality) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((objid3_t *)(ob))->locality,            \
+                     CPU_TO_LE64(val))
 
 #define ob_get_objectid(ob, pol)                                       \
-        LE64_TO_CPU(*((d64_t *)((objid3_t *)(ob))->objectid))
+       LE64_TO_CPU(get_unaligned((d64_t *)((objid3_t *)(ob))->objectid))
 
 #define ob_set_objectid(ob, val, pol)                                  \
-        (*(d64_t *)((objid3_t *)(ob))->objectid) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((objid3_t *)(ob))->objectid,            \
+                     CPU_TO_LE64(val))
 
 #define ob_get_ordering(ob, pol) (0)
 #define ob_set_ordering(ob, val, pol) do {} while(0)
 
-#define ob_size(pol)                                                   \
-        (sizeof(objid3_t))
+#define ob_size(pol) (sizeof(objid3_t))
 
+/* hashN_t macroses.  */
 #define ha_get_objectid(ha, pol)                                       \
-        LE64_TO_CPU(*((d64_t *)((hash3_t *)(ha))->objectid))
+       LE64_TO_CPU(get_unaligned((d64_t *)((hash3_t *)(ha))->objectid))
 
 #define ha_set_objectid(ha, val, pol)                                  \
-         (*(d64_t *)((hash3_t *)(ha))->objectid) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((hash3_t *)(ha))->objectid,             \
+                     CPU_TO_LE64(val))
 
 #define ha_get_offset(ha, pol)                                         \
-         LE64_TO_CPU(*((d64_t *)((hash3_t *)(ha))->offset))
-        
+       LE64_TO_CPU(get_unaligned((d64_t *)((hash3_t *)(ha))->offset))
+
 #define ha_set_offset(ha, val, pol)                                    \
-        (*(d64_t *)((hash3_t *)(ha))->offset) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((hash3_t *)(ha))->offset,               \
+                     CPU_TO_LE64(val))
 
 #define ha_get_ordering(ha, pol) (0)
 #define ha_set_ordering(ha, val, pol) do {} while (0)
 
-#define ha_size(pol)                                                   \
-        (sizeof(hash3_t))
+#define ha_size(pol) (sizeof(hash3_t))
 
+/* entryN_t macroses */
 #define en_get_offset(en, pol)                                         \
         aal_get_le16(((entry3_t *)(en)), offset)
 
 #define en_set_offset(en, val, pol)                                    \
          aal_set_le16(((entry3_t *)(en)), offset, val)
 
-#define en_size(pol)                                                   \
-        (sizeof(entry3_t))
+#define en_size(pol) (sizeof(entry3_t))
 
 #define cde_get_entry(pl, pos, pol)                                    \
         ((void *)(&((cde403_t *)pl->body)->entry[pos]))
-#else
+
+#elif defined(ENABLE_LARGE_KEYS)
+/* objidN_t macroses. */
 #define ob_get_locality(ob, pol)                                       \
-        LE64_TO_CPU(*((d64_t *)((objid4_t *)(ob))->locality))
+       LE64_TO_CPU(get_unaligned((d64_t *)((objid4_t *)(ob))->locality))
 
 #define ob_set_locality(ob, val, pol)                                  \
-        (*(d64_t *)((objid4_t *)(ob))->locality) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((objid4_t *)(ob))->locality,            \
+                     CPU_TO_LE64(val))
 
 #define ob_get_objectid(ob, pol)                                       \
-        LE64_TO_CPU(*((d64_t *)((objid4_t *)(ob))->objectid))
+       LE64_TO_CPU(get_unaligned((d64_t *)((objid4_t *)(ob))->objectid))
 
 #define ob_set_objectid(ob, val, pol)                                  \
-        (*(d64_t *)((objid4_t *)(ob))->objectid) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((objid4_t *)(ob))->objectid,            \
+                     CPU_TO_LE64(val))
 
 #define ob_get_ordering(ob, pol)                                       \
-        LE64_TO_CPU(*((d64_t *)((objid4_t *)(ob))->ordering))
+       LE64_TO_CPU(get_unaligned((d64_t *)((objid4_t *)(ob))->ordering))
 
 #define ob_set_ordering(ob, val, pol)                                  \
-        (*(d64_t *)((objid4_t *)(ob))->ordering) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((objid4_t *)(ob))->ordering,            \
+                     CPU_TO_LE64(val))
 
-#define ob_size(pol)                                                   \
-        (sizeof(objid4_t))
+#define ob_size(pol) (sizeof(objid4_t))
 
+/* hashN_t macroses.  */
 #define ha_get_objectid(ha, pol)                                       \
-        LE64_TO_CPU(*((d64_t *)((hash4_t *)(ha))->objectid))
+       LE64_TO_CPU(get_unaligned((d64_t *)((hash4_t *)(ha))->objectid))
 
 #define ha_set_objectid(ha, val, pol)                                  \
-         (*(d64_t *)((hash4_t *)(ha))->objectid) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((hash4_t *)(ha))->objectid,             \
+                     CPU_TO_LE64(val))
 
 #define ha_get_offset(ha, pol)                                         \
-         LE64_TO_CPU(*((d64_t *)((hash4_t *)(ha))->offset))
+       LE64_TO_CPU(get_unaligned((d64_t *)((hash4_t *)(ha))->offset))
         
 #define ha_set_offset(ha, val, pol)                                    \
-        (*(d64_t *)((hash4_t *)(ha))->offset) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((hash4_t *)(ha))->offset,               \
+                     CPU_TO_LE64(val))
 
 #define ha_get_ordering(ha, pol)                                       \
-         LE64_TO_CPU(*((d64_t *)((hash4_t *)(ha))->ordering))
+       LE64_TO_CPU(get_unaligned((d64_t *)((hash4_t *)(ha))->ordering))
 
 #define ha_set_ordering(ha, val, pol)                                  \
-        (*(d64_t *)((hash4_t *)(ha))->ordering) = CPU_TO_LE64(val)
+       put_unaligned((d64_t *)((hash4_t *)(ha))->ordering,             \
+                     CPU_TO_LE64(val))
 
-#define ha_size(pol)                                                   \
-        (sizeof(hash4_t))
+#define ha_size(pol) (sizeof(hash4_t))
 
 #define en_get_offset(en, pol)                                         \
         aal_get_le16(((entry4_t *)(en)), offset)
@@ -312,13 +329,11 @@ extern uint16_t cde40_overhead();
 #define en_set_offset(en, val, pol)                                    \
          aal_set_le16(((entry4_t *)(en)), offset, val)
 
-#define en_size(pol)                                                   \
-        (sizeof(entry4_t))
+#define en_size(pol) (sizeof(entry4_t))
 
 #define cde_get_entry(pl, pos, pol)                                    \
         ((void *)(&((cde404_t *)pl->body)->entry[pos]))
 #endif
-#endif
 
 #define cde_get_units(pl)                                              \
         aal_get_le16(((cde40_t *)pl->body), units)
diff -rup reiser4progs-1.0.3/plugin/key/key_large/key_large.h 
reiser4progs-1.0.3-1/plugin/key/key_large/key_large.h
--- reiser4progs-1.0.3/plugin/key/key_large/key_large.h 2004-09-22 
14:35:47.000000000 +0200
+++ reiser4progs-1.0.3-1/plugin/key/key_large/key_large.h       2005-01-16 
22:57:58.000000000 +0100
@@ -120,14 +120,14 @@ extern uint64_t key_large_get_fobjectid(
 static inline uint64_t kl_get_el(const key_large_t *key,
                                 key_large_field_t off)
 {
-       return LE64_TO_CPU(key->el[off]);
+       return LE64_TO_CPU(get_unaligned(key->el + off));
 }
 
 static inline void kl_set_el(key_large_t *key,
                             key_large_field_t off,
                             uint64_t value)
 {
-       key->el[off] = CPU_TO_LE64(value);
+       put_unaligned(key->el + off, CPU_TO_LE64(value));
 }
 
 static inline int kl_comp_el(void *k1, void *k2, int off) {
diff -rup reiser4progs-1.0.3/plugin/key/key_short/key_short.h 
reiser4progs-1.0.3-1/plugin/key/key_short/key_short.h
--- reiser4progs-1.0.3/plugin/key/key_short/key_short.h 2004-09-22 
14:35:54.000000000 +0200
+++ reiser4progs-1.0.3-1/plugin/key/key_short/key_short.h       2005-01-16 
22:57:58.000000000 +0100
@@ -108,14 +108,14 @@ extern uint64_t key_short_get_fobjectid(
 static inline uint64_t ks_get_el(const key_short_t *key,
                                 key_short_field_t off)
 {
-       return LE64_TO_CPU(key->el[off]);
+       return LE64_TO_CPU(get_unaligned(key->el + off));
 }
 
 static inline void ks_set_el(key_short_t *key,
                             key_short_field_t off,
                             uint64_t value)
 {
-       key->el[off] = CPU_TO_LE64(value);
+       put_unaligned(key->el + off, CPU_TO_LE64(value));
 }
 
 static inline int ks_comp_el(void *k1, void *k2, int off) {
diff -rup reiser4progs-1.0.3/plugin/sdext/sdext_plug/sdext_plug.h 
reiser4progs-1.0.3-1/plugin/sdext/sdext_plug/sdext_plug.h
--- reiser4progs-1.0.3/plugin/sdext/sdext_plug/sdext_plug.h     2004-06-03 
22:00:12.000000000 +0200
+++ reiser4progs-1.0.3-1/plugin/sdext/sdext_plug/sdext_plug.h   2005-01-16 
22:57:58.000000000 +0100
@@ -27,14 +27,14 @@ typedef struct sdext_plug sdext_plug_t;
 
 extern reiser4_core_t *sdext_plug_core;
 
-#define sdext_plug_get_count(ext)              aal_get_le16(ext, count)
-#define sdext_plug_set_count(ext, val)         aal_set_le16(ext, count, val)
+#define sdext_plug_get_count(ext)              aal_get_le16((ext), count)
+#define sdext_plug_set_count(ext, val)         aal_set_le16((ext), count, 
(val))
 
-#define sdext_plug_get_member(ext, n)          aal_get_le16(&(ext->slot[n]), 
member)
-#define sdext_plug_set_member(ext, n, val)     aal_set_le16(&(ext->slot[n]), 
member, val)
+#define sdext_plug_get_member(ext, n)          aal_get_le16(&((ext)->slot[n]), 
member)
+#define sdext_plug_set_member(ext, n, val)     aal_set_le16(&((ext)->slot[n]), 
member, (val))
 
-#define sdext_plug_get_pid(ext, n)             aal_get_le16(&(ext->slot[n]), 
plug)
-#define sdext_plug_set_pid(ext, n, val)                
aal_set_le16(&(ext->slot[n]), plug, val)
+#define sdext_plug_get_pid(ext, n)             aal_get_le16(&((ext)->slot[n]), 
plug)
+#define sdext_plug_set_pid(ext, n, val)                
aal_set_le16(&((ext)->slot[n]), plug, (val))
 
 extern uint32_t sdext_plug_length(stat_entity_t *stat, void *hint);
 

diff -rup libaal-1.0.3/include/aal/Makefile.am 
libaal-1.0.3-1/include/aal/Makefile.am
--- libaal-1.0.3/include/aal/Makefile.am        2004-01-08 15:49:40.000000000 
+0100
+++ libaal-1.0.3-1/include/aal/Makefile.am      2005-01-16 22:18:51.000000000 
+0100
@@ -2,4 +2,4 @@ aalincludedir           = $(includedir)/aal
 
 aalinclude_HEADERS     = libaal.h device.h file.h exception.h list.h malloc.h \
                          print.h string.h math.h endian.h debug.h bitops.h \
-                          gauge.h block.h ui.h stream.h hash.h types.h
+                          gauge.h block.h ui.h stream.h hash.h types.h 
unaligned.h
diff -rup libaal-1.0.3/include/aal/Makefile.in 
libaal-1.0.3-1/include/aal/Makefile.in
--- libaal-1.0.3/include/aal/Makefile.in        2004-12-06 19:04:14.000000000 
+0100
+++ libaal-1.0.3-1/include/aal/Makefile.in      2005-01-16 15:24:49.000000000 
+0100
@@ -146,7 +146,7 @@ aalincludedir = $(includedir)/aal
 
 aalinclude_HEADERS = libaal.h device.h file.h exception.h list.h malloc.h \
                          print.h string.h math.h endian.h debug.h bitops.h \
-                          gauge.h block.h ui.h stream.h hash.h types.h
+                          gauge.h block.h ui.h stream.h hash.h types.h 
unaligned.h
 
 subdir = include/aal
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
diff -rup libaal-1.0.3/include/aal/endian.h libaal-1.0.3-1/include/aal/endian.h
--- libaal-1.0.3/include/aal/endian.h   2003-07-27 10:55:29.000000000 +0200
+++ libaal-1.0.3-1/include/aal/endian.h 2005-01-16 22:29:19.000000000 +0100
@@ -75,8 +75,8 @@
 
 #endif
 
-#define aal_get_leXX(xx, p, field)     (LE##xx##_TO_CPU ((p)->field))
-#define aal_set_leXX(xx, p, field, val)        ((p)->field = 
CPU_TO_LE##xx(val))
+#define aal_get_leXX(xx, p, field)     (LE##xx##_TO_CPU 
(get_unaligned(&(p)->field)))
+#define aal_set_leXX(xx, p, field, val)        put_unaligned(&(p)->field, 
CPU_TO_LE##xx(val))
 
 #define aal_get_le16(p, field)                 aal_get_leXX(16, p, field)
 #define aal_set_le16(p, field, val)    aal_set_leXX(16, p, field, val)
diff -rup libaal-1.0.3/include/aal/libaal.h libaal-1.0.3-1/include/aal/libaal.h
--- libaal-1.0.3/include/aal/libaal.h   2004-09-22 14:27:23.000000000 +0200
+++ libaal-1.0.3-1/include/aal/libaal.h 2005-01-16 22:18:51.000000000 +0100
@@ -26,6 +26,7 @@ extern "C" {
 #include "math.h"
 #include "bitops.h"
 #include "endian.h"
+#include "unaligned.h"
 #include "debug.h"
 #include "gauge.h"
 #include "block.h"
diff -rup libaal-1.0.3/include/aal/unaligned.h 
libaal-1.0.3-1/include/aal/unaligned.h
--- libaal-1.0.3/include/aal/unaligned.h        2005-01-16 23:09:05.000000000 
+0100
+++ libaal-1.0.3-1/include/aal/unaligned.h      2005-01-16 22:18:51.000000000 
+0100
@@ -0,0 +1,26 @@
+/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by 
libaal/COPYING.
+         
+   unaligned.h -- libaal unalignment declaration. */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#ifndef AAL_UNALIGNED_H
+#define AAL_UNALIGNED_H
+
+#define get_unaligned(ptr)                             \
+({                                                     \
+       __typeof__(*(ptr)) __tmp;                       \
+       aal_memcpy(&__tmp, (ptr), sizeof(*(ptr)));      \
+       __tmp;                                          \
+})
+
+#define put_unaligned(ptr, val)                                \
+({                                                     \
+       __typeof__(*(ptr)) __tmp = (val);               \
+       aal_memcpy((ptr), &__tmp, sizeof(*(ptr)));      \
+       (void)0;                                        \
+})
+
+#endif


----- End forwarded message -----


-----[ Domenico Andreoli, aka cavok
 --[ http://people.debian.org/~cavok/gpgkey.asc
   ---[ 3A0F 2F80 F79C 678A 8936  4FEE 0677 9033 A20E BC50


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to