[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] [PATCH] [1/5] Add ROUNDUP2 and ROUNDDOWN2 macros.



One of this macros is needed by the ALLOC_CACHE_ALIGN_BUFFER added by
a next patch.

Commit message:

Add ROUNDUP2 and ROUNDDOWN2 macros.
Contributed by David Galvez.
diff -r a02994a6acc1 -r 0c0a26a764a2 sys/mint/kcompiler.h
--- a/sys/mint/kcompiler.h	Thu Nov 13 14:01:08 2014 +0100
+++ b/sys/mint/kcompiler.h	Mon Nov 17 11:19:29 2014 +0100
@@ -116,5 +116,7 @@
 
 # define ROUNDUP(a,b)	((((a) + ((b) - 1)) / (b)) * (b))
 # define ROUNDDOWN(a,b)	(((a) / (b)) * (b))
+# define ROUNDUP2(a,b)		(((a) + (b) - 1) & ~((b) - 1))		/* if y is power of two */
+# define ROUNDDOWN2(a,b)	((a) & (~((b) - 1)))				/* if y is power of two */
 
 # endif /* _mint_misc_h */