|
35 | 35 | #include <nuttx/init.h> |
36 | 36 | #include <nuttx/kmalloc.h> |
37 | 37 | #include <nuttx/fs/fs.h> |
| 38 | +#include <nuttx/nuttx.h> |
38 | 39 | #include <nuttx/spinlock.h> |
39 | 40 |
|
40 | 41 | /**************************************************************************** |
|
112 | 113 |
|
113 | 114 | #define MAXARCS (1 << 20) |
114 | 115 |
|
115 | | -/* General rounding functions. */ |
116 | | - |
117 | | -#define ROUNDDOWN(x, y) (((x) / (y)) * (y)) |
118 | | -#define ROUNDUP(x, y) ((((x) + (y) - 1) / (y)) * (y)) |
119 | | - |
120 | 116 | /* See profil(2) where this is described (incorrectly) */ |
121 | 117 |
|
122 | 118 | #define SCALE_1_TO_1 0x10000 |
@@ -288,13 +284,13 @@ void moncontrol(int mode) |
288 | 284 |
|
289 | 285 | if (mode) |
290 | 286 | { |
291 | | - uintptr_t lowpc = ROUNDDOWN((uintptr_t)&_stext, |
| 287 | + uintptr_t lowpc = ALIGN_DOWN((uintptr_t)&_stext, |
292 | 288 | HISTFRACTION * sizeof(HISTCOUNTER)); |
293 | | - uintptr_t highpc = ROUNDUP((uintptr_t)&_etext, |
294 | | - HISTFRACTION * sizeof(HISTCOUNTER)); |
| 289 | + uintptr_t highpc = ALIGN_UP((uintptr_t)&_etext, |
| 290 | + HISTFRACTION * sizeof(HISTCOUNTER)); |
295 | 291 | size_t textsize = highpc - lowpc; |
296 | | - size_t kcountsize = ROUNDUP(textsize / HISTFRACTION, |
297 | | - sizeof(*p->kcount)); |
| 292 | + size_t kcountsize = ALIGN_UP(textsize / HISTFRACTION, |
| 293 | + sizeof(*p->kcount)); |
298 | 294 | int scale = kcountsize >= textsize ? SCALE_1_TO_1 : |
299 | 295 | (float)kcountsize / textsize * SCALE_1_TO_1; |
300 | 296 | FAR unsigned short *kcount = kmm_zalloc(kcountsize); |
@@ -370,10 +366,10 @@ void monstartup(unsigned long lowpc, unsigned long highpc) |
370 | 366 | * so the rest of the scaling (here and in gprof) stays in ints. |
371 | 367 | */ |
372 | 368 |
|
373 | | - lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER)); |
374 | | - highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER)); |
| 369 | + lowpc = ALIGN_DOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER)); |
| 370 | + highpc = ALIGN_UP(highpc, HISTFRACTION * sizeof(HISTCOUNTER)); |
375 | 371 | textsize = highpc - lowpc; |
376 | | - fromssize = ROUNDUP(textsize / HASHFRACTION, sizeof(*p->froms)); |
| 372 | + fromssize = ALIGN_UP(textsize / HASHFRACTION, sizeof(*p->froms)); |
377 | 373 | tolimit = textsize * ARCDENSITY / 100; |
378 | 374 |
|
379 | 375 | if (tolimit < MINARCS) |
|
0 commit comments