X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Ftypes.h;h=8f6283b57bdd8878a8c4b5dfddfb6e45568f6f17;hp=a8753c5f149115c539e2e39d3eeb07256344f172;hb=a94748ec6da9bdc6e25a7f73bbea723b8b55fa33;hpb=f0ce88b3af9a6090ac986160950d66317de5087e diff --git a/src/helper/types.h b/src/helper/types.h index a8753c5f14..8f6283b57b 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -73,6 +73,15 @@ typedef bool _Bool; (type *)( (char *)__mptr - offsetof(type,member) );}) +/** + * Rounds @c m up to the nearest multiple of @c n using division. + * @params m The value to round up to @c n. + * @params n Round @c m up to a multiple of this number. + * @returns The rounded integer value. + */ +#define DIV_ROUND_UP(m, n) (((m) + (n) - 1) / (n)) + + /* DANGER!!!! here be dragons! * * Leave these fn's as byte accesses because it is safe