in reply to Re^7: 64-bit *nix/gcc expertise required
in thread 64-bit *nix/gcc expertise required (THIS IS NOT OFF TOPIC!)
Tux Many thanks for your assistance. Up for a bit more?
In theory, based on my reading the gcc headers, this should compile clean under 32/64-bit. It probably won't, but once you recover from your seasonal revelries, I'd appreciated seeing the warnings/errors produced on your various platforms.
#include <stdio.h> #define __STDC_LIMIT_MACROS #include <stdint.h> #include <stddef.h> #define ALIGN_BITS ( sizeof(void*) >> __UINT64_C( 1 ) ) #define BIT_BITS __UINT64_C( 3 ) #define BYTE_BITS __UINT64_C( 14 ) #define SLOT_BITS ( sizeof( void*) * 8 ) - ( ALIGN_BITS + BIT_BITS + + BYTE_BITS ) #define BYTES_PER_SLOT __UINT64_C( 1 ) << BYTE_BITS #define TRACKING_SLOTS 8192 // max. 8192 for 4GB/32-bit machine int check_new( uintptr_t p ) { ptrdiff_t slot = ( p >> (BYTE_BITS + BIT_BITS + ALIGN_BITS) ); ptrdiff_t byte = ( p >> (ALIGN_BITS + BIT_BITS)) & __UINT64_C( 0x0 +0003fff ) ptrdiff_t bit = ( p >> ALIGN_BITS) & __UINT64_C( 0x0 +0000007 ); ptrdiff_t nop = p & __UINT64_C( 0x3 + ); printf( "address: %p slot: %p byte: %4x bit: %4x nop:%x\n", p, slot, byte, bit, nop ); return 1; } void main( void ) { uintptr_t p; for( p = __UINT64_C( 123456 ); p < ( __UINT64_C( 1 ) << 34 ); p += + ( __UINT64_C( 1 ) << 29 ) ) { check_new( p ); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: 64-bit *nix/gcc expertise required
by Tux (Canon) on Dec 26, 2010 at 09:06 UTC | |
by BrowserUk (Patriarch) on Dec 26, 2010 at 16:32 UTC | |
by BrowserUk (Patriarch) on Dec 26, 2010 at 11:06 UTC |