Is there another way to do that? At the moment I do:
Code: Select all
if((*p & 0xfff) != 0)
//code
Code: Select all
if((*p & 0xfff) != 0)
//code
Code: Select all
if((a == b) && (b == c))
{
...
}
Code: Select all
if((*p && 0xfff) != 0))
Code: Select all
if((p != 0) && (0xfff != 0))
{
...
}
Code: Select all
if(((*p) & 0xfff) != 0)
Code: Select all
if (((uintptr_t)p & 0xFFF) != 0)
Code: Select all
struct test_t
{
void *base;
};
struct test_t *p;
if((p->base & 0xfff) != 0)
//code
Code: Select all
uint32_t temp;
temp= p->base;
if((temp &0xfff) != 0)
//code
Are you trying to find out if the address of 'p' is page aligned, or if the address pointed to by 'base' is page-aligned?Code: Select all
struct test_t { void *base; }; struct test_t *p; if((p->base & 0xfff) != 0) //code
Depends on your Compiler and on the architecture you are targeting. The only requirements of an uintptr_t are thatFlashBurn wrote:Yeah, but how do you define uintptr_t?
Actually, no. You define uintptr_t like this:bluecode wrote:Depends on your Compiler and on the architecture you are targeting.FlashBurn wrote:Yeah, but how do you define uintptr_t?
Code: Select all
#include <stdint.h>
Solar wrote:Actually, no. You define uintptr_t like this:Well, at least if you're working in a C99 environment.Code: Select all
#include <stdint.h>
As he posted to "General Programming"... besides, it's hard to remember how much of an environment everyone's OS provides. For him, the solution was to typedef uint32_t... had I suggested that, it would have sounded a bit silly if he didn't have an uint32_t, right?bluecode wrote:Actually I was thinking he is using this in his OS and does not have a full C99 environment and has to provide his own C99 environment.