]> mj.ucw.cz Git - libucw.git/commitdiff
We should check the special case.
authorTomas Valla <tom@ucw.cz>
Tue, 18 Jan 2005 11:37:24 +0000 (11:37 +0000)
committerTomas Valla <tom@ucw.cz>
Tue, 18 Jan 2005 11:37:24 +0000 (11:37 +0000)
lib/lib.h

index 07c66e9e1df5dfd98e95db5ff756eb155066b2b0..15cad2108f83bc80f5316ec0467b68fe78fb47ba 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -2,6 +2,7 @@
  *     The UCW Library -- Miscellaneous Functions
  *
  *     (c) 1997--2004 Martin Mares <mj@ucw.cz>
+ *     (c) 2005 Tomas Valla <tom@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -22,7 +23,7 @@
 #define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i)
 #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
 #define ALIGN(s, a) (((s)+a-1)&~(a-1))
-#define ALIGN_PTR(p, s) ((typeof(p)) ((addr_int_t)(p) + (s) - (addr_int_t)(p) % (s)))
+#define ALIGN_PTR(p, s) ( (s)>1 ? ((typeof(p)) ((addr_int_t)(p) + (s) - (addr_int_t)(p) % (s))) : (p) )
 #define UNALIGNED_PART(ptr, type) (((long) (ptr)) % sizeof(type))
 
 /* Some other macros */