kernel.h: Add a HOWMANY macro and make use of it.
This commit is contained in:
@@ -85,6 +85,7 @@ is_user_address_range(const void* addr, size_t size)
|
||||
|
||||
#define ROUNDDOWN(a, b) (((a) / (b)) * (b))
|
||||
#define ROUNDUP(a, b) ROUNDDOWN((a) + (b) - 1, b)
|
||||
#define HOWMANY(a, b) (((a) + ((b) - 1)) / (b))
|
||||
|
||||
|
||||
#define CHECK_BIT(a, b) ((a) & (1 << (b)))
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
|
||||
#include <boot/platform.h>
|
||||
#include <kernel/kernel.h>
|
||||
|
||||
#include "efi_platform.h"
|
||||
|
||||
@@ -12,7 +13,7 @@
|
||||
extern "C" ssize_t
|
||||
platform_allocate_heap_region(size_t _size, void** _base)
|
||||
{
|
||||
size_t pages = (_size + (B_PAGE_SIZE - 1)) / B_PAGE_SIZE;
|
||||
size_t pages = HOWMANY(_size, B_PAGE_SIZE);
|
||||
efi_physical_addr base;
|
||||
if (kBootServices->AllocatePages(AllocateAnyPages, EfiLoaderData, pages, &base) != EFI_SUCCESS)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -97,7 +97,7 @@ class SelectTraceEntry : public AbstractTraceEntry {
|
||||
int sets = (readSet != NULL ? 1 : 0) + (writeSet != NULL ? 1 : 0)
|
||||
+ (errorSet != NULL ? 1 : 0);
|
||||
if (sets > 0 && count > 0) {
|
||||
uint32 bytes = _howmany(count, NFDBITS) * sizeof(fd_mask);
|
||||
uint32 bytes = HOWMANY(count, NFDBITS) * sizeof(fd_mask);
|
||||
uint8* allocated = (uint8*)alloc_tracing_buffer(bytes * sets);
|
||||
if (allocated != NULL) {
|
||||
if (readSet != NULL) {
|
||||
@@ -356,7 +356,7 @@ static inline void
|
||||
fd_zero(fd_set *set, int numFDs)
|
||||
{
|
||||
if (set != NULL)
|
||||
memset(set, 0, _howmany(numFDs, NFDBITS) * sizeof(fd_mask));
|
||||
memset(set, 0, HOWMANY(numFDs, NFDBITS) * sizeof(fd_mask));
|
||||
}
|
||||
|
||||
|
||||
@@ -958,7 +958,7 @@ ssize_t
|
||||
_user_select(int numFDs, fd_set *userReadSet, fd_set *userWriteSet,
|
||||
fd_set *userErrorSet, bigtime_t timeout, const sigset_t *userSigMask)
|
||||
{
|
||||
uint32 bytes = _howmany(numFDs, NFDBITS) * sizeof(fd_mask);
|
||||
uint32 bytes = HOWMANY(numFDs, NFDBITS) * sizeof(fd_mask);
|
||||
int result;
|
||||
|
||||
if (timeout >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user