in reply to 64-bit *nix/gcc expertise required (THIS IS NOT OFF TOPIC!)

Does it matter what architecture? e.g. Itanium (ia64) vs PA-RISC (lp64) vs RISC (ppc5) vs Intel (x86_64)?


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: 64-bit *nix/gcc expertise required
by BrowserUk (Patriarch) on Dec 24, 2010 at 14:57 UTC

    Preferably all of them, but the latter would satisfy the majority of the target audience.

    Please note, there are no actually addresses involved. The problem lies in the types and constants required to make the math work correctly.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      On my x86_64 machine:

      #include <stdio.h> #define ALIGN_BITS (sizeof (void *) >> 1LL) #define BIT_BITS 3LL #define BYTE_BITS 14LL #define SLOT_BITS (sizeof (void *) * 8) - (ALIGN_BITS + BIT_BITS + + BYTE_BITS) #define BYTES_PER_SLOT 1LL << BYTE_BITS #define TRACKING_SLOTS 8192 int check_new (unsigned long long p) { unsigned long long slot = (p >> (BYTE_BITS + BIT_BITS + ALIGN_BIT +S)); unsigned long long byte = (p >> (ALIGN_BITS + BIT_BITS)) & 0x00003 +fffLL; unsigned long long bit = (p >> ALIGN_BITS) & 0x00000 +007LL; unsigned long long nop = p & 0x3LL; printf ("address: %012p slot: %012p byte: %4x bit: %4x nop: %x\n", p, slot, byte, bit, nop); return (1); } /* check_new */ int main (int argc, char *argv[]) { unsigned long long p; for (p = 123456LL; p < (1ULL << 34); p += (1ULL << 29)) check_new (p); } /* main */

      Yields

      ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6 +.4, dynamically linked (uses shared libs), not stripped address: 0x000001e240 slot: (nil) byte: 3c4 bit: 4 nop: 0 address: 0x002001e240 slot: 0x0000000100 byte: 3c4 bit: 4 nop: 0 address: 0x004001e240 slot: 0x0000000200 byte: 3c4 bit: 4 nop: 0 address: 0x006001e240 slot: 0x0000000300 byte: 3c4 bit: 4 nop: 0 address: 0x008001e240 slot: 0x0000000400 byte: 3c4 bit: 4 nop: 0 address: 0x00a001e240 slot: 0x0000000500 byte: 3c4 bit: 4 nop: 0 address: 0x00c001e240 slot: 0x0000000600 byte: 3c4 bit: 4 nop: 0 address: 0x00e001e240 slot: 0x0000000700 byte: 3c4 bit: 4 nop: 0 address: 0x010001e240 slot: 0x0000000800 byte: 3c4 bit: 4 nop: 0 address: 0x012001e240 slot: 0x0000000900 byte: 3c4 bit: 4 nop: 0 address: 0x014001e240 slot: 0x0000000a00 byte: 3c4 bit: 4 nop: 0 address: 0x016001e240 slot: 0x0000000b00 byte: 3c4 bit: 4 nop: 0 address: 0x018001e240 slot: 0x0000000c00 byte: 3c4 bit: 4 nop: 0 address: 0x01a001e240 slot: 0x0000000d00 byte: 3c4 bit: 4 nop: 0 address: 0x01c001e240 slot: 0x0000000e00 byte: 3c4 bit: 4 nop: 0 address: 0x01e001e240 slot: 0x0000000f00 byte: 3c4 bit: 4 nop: 0 address: 0x020001e240 slot: 0x0000001000 byte: 3c4 bit: 4 nop: 0 address: 0x022001e240 slot: 0x0000001100 byte: 3c4 bit: 4 nop: 0 address: 0x024001e240 slot: 0x0000001200 byte: 3c4 bit: 4 nop: 0 address: 0x026001e240 slot: 0x0000001300 byte: 3c4 bit: 4 nop: 0 address: 0x028001e240 slot: 0x0000001400 byte: 3c4 bit: 4 nop: 0 address: 0x02a001e240 slot: 0x0000001500 byte: 3c4 bit: 4 nop: 0 address: 0x02c001e240 slot: 0x0000001600 byte: 3c4 bit: 4 nop: 0 address: 0x02e001e240 slot: 0x0000001700 byte: 3c4 bit: 4 nop: 0 address: 0x030001e240 slot: 0x0000001800 byte: 3c4 bit: 4 nop: 0 address: 0x032001e240 slot: 0x0000001900 byte: 3c4 bit: 4 nop: 0 address: 0x034001e240 slot: 0x0000001a00 byte: 3c4 bit: 4 nop: 0 address: 0x036001e240 slot: 0x0000001b00 byte: 3c4 bit: 4 nop: 0 address: 0x038001e240 slot: 0x0000001c00 byte: 3c4 bit: 4 nop: 0 address: 0x03a001e240 slot: 0x0000001d00 byte: 3c4 bit: 4 nop: 0 address: 0x03c001e240 slot: 0x0000001e00 byte: 3c4 bit: 4 nop: 0 address: 0x03e001e240 slot: 0x0000001f00 byte: 3c4 bit: 4 nop: 0

      That was what you were looking for?


      Enjoy, Have FUN! H.Merijn

        I don't think that is not going to work, p in main, and the arg to check_new() must be pointers. That's what makes this a problem.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

      Same program on Itanium2 with HP's ANSI C compiler:

      ELF-64 executable object file - IA64 address: 000000000001e240 slot: 0000000000000000 byte: 3c4 bit: 4 +nop: 0 address: 000000002001e240 slot: 0000000000000100 byte: 3c4 bit: 4 +nop: 0 address: 000000004001e240 slot: 0000000000000200 byte: 3c4 bit: 4 +nop: 0 address: 000000006001e240 slot: 0000000000000300 byte: 3c4 bit: 4 +nop: 0 address: 000000008001e240 slot: 0000000000000400 byte: 3c4 bit: 4 +nop: 0 address: 00000000a001e240 slot: 0000000000000500 byte: 3c4 bit: 4 +nop: 0 address: 00000000c001e240 slot: 0000000000000600 byte: 3c4 bit: 4 +nop: 0 address: 00000000e001e240 slot: 0000000000000700 byte: 3c4 bit: 4 +nop: 0 address: 000000010001e240 slot: 0000000000000800 byte: 3c4 bit: 4 +nop: 0 address: 000000012001e240 slot: 0000000000000900 byte: 3c4 bit: 4 +nop: 0 address: 000000014001e240 slot: 0000000000000a00 byte: 3c4 bit: 4 +nop: 0 address: 000000016001e240 slot: 0000000000000b00 byte: 3c4 bit: 4 +nop: 0 address: 000000018001e240 slot: 0000000000000c00 byte: 3c4 bit: 4 +nop: 0 address: 00000001a001e240 slot: 0000000000000d00 byte: 3c4 bit: 4 +nop: 0 address: 00000001c001e240 slot: 0000000000000e00 byte: 3c4 bit: 4 +nop: 0 address: 00000001e001e240 slot: 0000000000000f00 byte: 3c4 bit: 4 +nop: 0 address: 000000020001e240 slot: 0000000000001000 byte: 3c4 bit: 4 +nop: 0 address: 000000022001e240 slot: 0000000000001100 byte: 3c4 bit: 4 +nop: 0 address: 000000024001e240 slot: 0000000000001200 byte: 3c4 bit: 4 +nop: 0 address: 000000026001e240 slot: 0000000000001300 byte: 3c4 bit: 4 +nop: 0 address: 000000028001e240 slot: 0000000000001400 byte: 3c4 bit: 4 +nop: 0 address: 00000002a001e240 slot: 0000000000001500 byte: 3c4 bit: 4 +nop: 0 address: 00000002c001e240 slot: 0000000000001600 byte: 3c4 bit: 4 +nop: 0 address: 00000002e001e240 slot: 0000000000001700 byte: 3c4 bit: 4 +nop: 0 address: 000000030001e240 slot: 0000000000001800 byte: 3c4 bit: 4 +nop: 0 address: 000000032001e240 slot: 0000000000001900 byte: 3c4 bit: 4 +nop: 0 address: 000000034001e240 slot: 0000000000001a00 byte: 3c4 bit: 4 +nop: 0 address: 000000036001e240 slot: 0000000000001b00 byte: 3c4 bit: 4 +nop: 0 address: 000000038001e240 slot: 0000000000001c00 byte: 3c4 bit: 4 +nop: 0 address: 00000003a001e240 slot: 0000000000001d00 byte: 3c4 bit: 4 +nop: 0 address: 00000003c001e240 slot: 0000000000001e00 byte: 3c4 bit: 4 +nop: 0 address: 00000003e001e240 slot: 0000000000001f00 byte: 3c4 bit: 4 +nop: 0

      Same program on PA-RISC2 with HP's ANSI C compiler:

      ELF-64 executable object file - PA-RISC 2.0 (LP64) address: 000000000001e240 slot: 0000000000000000 byte: 3c4 bit: 4 +nop: 0 address: 000000002001e240 slot: 0000000000000100 byte: 3c4 bit: 4 +nop: 0 address: 000000004001e240 slot: 0000000000000200 byte: 3c4 bit: 4 +nop: 0 address: 000000006001e240 slot: 0000000000000300 byte: 3c4 bit: 4 +nop: 0 address: 000000008001e240 slot: 0000000000000400 byte: 3c4 bit: 4 +nop: 0 address: 00000000a001e240 slot: 0000000000000500 byte: 3c4 bit: 4 +nop: 0 address: 00000000c001e240 slot: 0000000000000600 byte: 3c4 bit: 4 +nop: 0 address: 00000000e001e240 slot: 0000000000000700 byte: 3c4 bit: 4 +nop: 0 address: 000000010001e240 slot: 0000000000000800 byte: 3c4 bit: 4 +nop: 0 address: 000000012001e240 slot: 0000000000000900 byte: 3c4 bit: 4 +nop: 0 address: 000000014001e240 slot: 0000000000000a00 byte: 3c4 bit: 4 +nop: 0 address: 000000016001e240 slot: 0000000000000b00 byte: 3c4 bit: 4 +nop: 0 address: 000000018001e240 slot: 0000000000000c00 byte: 3c4 bit: 4 +nop: 0 address: 00000001a001e240 slot: 0000000000000d00 byte: 3c4 bit: 4 +nop: 0 address: 00000001c001e240 slot: 0000000000000e00 byte: 3c4 bit: 4 +nop: 0 address: 00000001e001e240 slot: 0000000000000f00 byte: 3c4 bit: 4 +nop: 0 address: 000000020001e240 slot: 0000000000001000 byte: 3c4 bit: 4 +nop: 0 address: 000000022001e240 slot: 0000000000001100 byte: 3c4 bit: 4 +nop: 0 address: 000000024001e240 slot: 0000000000001200 byte: 3c4 bit: 4 +nop: 0 address: 000000026001e240 slot: 0000000000001300 byte: 3c4 bit: 4 +nop: 0 address: 000000028001e240 slot: 0000000000001400 byte: 3c4 bit: 4 +nop: 0 address: 00000002a001e240 slot: 0000000000001500 byte: 3c4 bit: 4 +nop: 0 address: 00000002c001e240 slot: 0000000000001600 byte: 3c4 bit: 4 +nop: 0 address: 00000002e001e240 slot: 0000000000001700 byte: 3c4 bit: 4 +nop: 0 address: 000000030001e240 slot: 0000000000001800 byte: 3c4 bit: 4 +nop: 0 address: 000000032001e240 slot: 0000000000001900 byte: 3c4 bit: 4 +nop: 0 address: 000000034001e240 slot: 0000000000001a00 byte: 3c4 bit: 4 +nop: 0 address: 000000036001e240 slot: 0000000000001b00 byte: 3c4 bit: 4 +nop: 0 address: 000000038001e240 slot: 0000000000001c00 byte: 3c4 bit: 4 +nop: 0 address: 00000003a001e240 slot: 0000000000001d00 byte: 3c4 bit: 4 +nop: 0 address: 00000003c001e240 slot: 0000000000001e00 byte: 3c4 bit: 4 +nop: 0 address: 00000003e001e240 slot: 0000000000001f00 byte: 3c4 bit: 4 +nop: 0

      Same program on PowerPC5 with IBM's XLC compiler:

      64-bit XCOFF executable or object module address: 00000001e240 slot: 000000000000 byte: 3c4 bit: 4 nop: 0 address: 00002001e240 slot: 000000000100 byte: 3c4 bit: 4 nop: 0 address: 00004001e240 slot: 000000000200 byte: 3c4 bit: 4 nop: 0 address: 00006001e240 slot: 000000000300 byte: 3c4 bit: 4 nop: 0 address: 00008001e240 slot: 000000000400 byte: 3c4 bit: 4 nop: 0 address: 0000a001e240 slot: 000000000500 byte: 3c4 bit: 4 nop: 0 address: 0000c001e240 slot: 000000000600 byte: 3c4 bit: 4 nop: 0 address: 0000e001e240 slot: 000000000700 byte: 3c4 bit: 4 nop: 0 address: 00010001e240 slot: 000000000800 byte: 3c4 bit: 4 nop: 0 address: 00012001e240 slot: 000000000900 byte: 3c4 bit: 4 nop: 0 address: 00014001e240 slot: 000000000a00 byte: 3c4 bit: 4 nop: 0 address: 00016001e240 slot: 000000000b00 byte: 3c4 bit: 4 nop: 0 address: 00018001e240 slot: 000000000c00 byte: 3c4 bit: 4 nop: 0 address: 0001a001e240 slot: 000000000d00 byte: 3c4 bit: 4 nop: 0 address: 0001c001e240 slot: 000000000e00 byte: 3c4 bit: 4 nop: 0 address: 0001e001e240 slot: 000000000f00 byte: 3c4 bit: 4 nop: 0 address: 00020001e240 slot: 000000001000 byte: 3c4 bit: 4 nop: 0 address: 00022001e240 slot: 000000001100 byte: 3c4 bit: 4 nop: 0 address: 00024001e240 slot: 000000001200 byte: 3c4 bit: 4 nop: 0 address: 00026001e240 slot: 000000001300 byte: 3c4 bit: 4 nop: 0 address: 00028001e240 slot: 000000001400 byte: 3c4 bit: 4 nop: 0 address: 0002a001e240 slot: 000000001500 byte: 3c4 bit: 4 nop: 0 address: 0002c001e240 slot: 000000001600 byte: 3c4 bit: 4 nop: 0 address: 0002e001e240 slot: 000000001700 byte: 3c4 bit: 4 nop: 0 address: 00030001e240 slot: 000000001800 byte: 3c4 bit: 4 nop: 0 address: 00032001e240 slot: 000000001900 byte: 3c4 bit: 4 nop: 0 address: 00034001e240 slot: 000000001a00 byte: 3c4 bit: 4 nop: 0 address: 00036001e240 slot: 000000001b00 byte: 3c4 bit: 4 nop: 0 address: 00038001e240 slot: 000000001c00 byte: 3c4 bit: 4 nop: 0 address: 0003a001e240 slot: 000000001d00 byte: 3c4 bit: 4 nop: 0 address: 0003c001e240 slot: 000000001e00 byte: 3c4 bit: 4 nop: 0 address: 0003e001e240 slot: 000000001f00 byte: 3c4 bit: 4 nop: 0

      Enjoy, Have FUN! H.Merijn