[or-cvs] Throw out this UNALIGNED_INT_ACCESS_OK nonsense. Even wher...

Nick Mathewson nickm at seul.org
Tue May 23 08:23:05 UTC 2006


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv8674/src/common

Modified Files:
	compat.c compat.h 
Log Message:
Throw out this UNALIGNED_INT_ACCESS_OK nonsense.  Even where it works, it is often way way slower than doing the right thing. Backport candidate.

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -p -d -r1.85 -r1.86
--- compat.c	26 Mar 2006 06:47:08 -0000	1.85
+++ compat.c	23 May 2006 08:23:03 -0000	1.86
@@ -206,7 +206,6 @@ tor_fix_source_file(const char *fname)
 }
 #endif
 
-#ifndef UNALIGNED_INT_ACCESS_OK
 /**
  * Read a 16-bit value beginning at <b>cp</b>.  Equivalent to
  * *(uint16_t*)(cp), but will not cause segfaults on platforms that forbid
@@ -249,7 +248,6 @@ set_uint32(char *cp, uint32_t v)
 {
   memcpy(cp,&v,4);
 }
-#endif
 
 /**
  * Rename the file <b>from</b> to the file <b>to</b>.  On unix, this is

Index: compat.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -p -d -r1.44 -r1.45
--- compat.h	17 Mar 2006 04:43:37 -0000	1.44
+++ compat.h	23 May 2006 08:23:03 -0000	1.45
@@ -223,21 +223,10 @@ const char *tor_socket_strerror(int e);
 /* ===== OS compatibility */
 const char *get_uname(void);
 
-/* Some platforms segfault when you try to access a multi-byte type
- * that isn't aligned to a word boundary.  The macros and/or functions
- * below can be used to access unaligned data on any platform.
- */
-#ifdef UNALIGNED_INT_ACCESS_OK
-#define get_uint16(cp) (*(uint16_t*)(cp))
-#define get_uint32(cp) (*(uint32_t*)(cp))
-#define set_uint16(cp,v) do { *(uint16_t*)(cp) = (v); } while (0)
-#define set_uint32(cp,v) do { *(uint32_t*)(cp) = (v); } while (0)
-#else
 uint16_t get_uint16(const char *cp);
 uint32_t get_uint32(const char *cp);
 void set_uint16(char *cp, uint16_t v);
 void set_uint32(char *cp, uint32_t v);
-#endif
 
 int set_max_file_descriptors(unsigned long limit, unsigned long cap);
 int switch_id(char *user, char *group);



More information about the tor-commits mailing list