; missing on line 16, the return type of main (int argc, char *argv[]) should be int. Besides that, lets try simple ...

$ cat test2.c
#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 + B +YTE_BITS) #define BYTES_PER_SLOT __UINT64_C (1) << BYTE_BITS #define TRACKING_SLOTS 8192 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; } /* check_new */ int main (int argc, char *argv[]) { uintptr_t p; for (p = __UINT64_C (123456); p < (__UINT64_C (1) << 34); p += (__ +UINT64_C (+1) << 29)) check_new (p); return (1); } /* main */
$ gcc -dumpversion 4.2.4 $ gcc -o test2 test2.c test2.c: In function 'main': test2.c:29: warning: left shift count >= width of type ld: Unsatisfied symbol "__UINT64_C" in file /tmp/ccAAXIbg.o 1 errors. $ gcc -mlp64 -fno-strict-aliasing -pipe -fPIC -o test2 test2.c test2.c: In function 'main': test2.c:29: warning: left shift count >= width of type ld: Unsatisfied symbol "__UINT64_C" in file /tmp/ccvHbmFn.o 1 errors.

Did you actually try this yourself, and with what version of gcc? If this is gcc-only code I could try on my various platforms, but I'm sure that that would work just as on any 32bit capable 64bit platform.

Older versions of gcc do not know about stdint.h

$ gcc -dumpversion 3.4.6 $ gcc -fno-strict-aliasing -pipe -fPIC -o test2 test2.c test2.c:3:20: stdint.h: No such file or directory test2.c: In function `main': test2.c:29: warning: left shift count >= width of type $

Above won't compile with HP C-ANSI-C for example.

$ cc -Ae -z +Z +w +DD64 -o test2 test2.c "test2.c", line 15: warning #2223-D: function "__UINT64_C" declared im +plicitly ptrdiff_t slot = ( p >> (BYTE_BITS + BIT_BITS + ALIGN_BITS)); ^ "test2.c", line 15: remark #4242-D: no prototype or definition in scop +e for call to "__UINT64_C" ptrdiff_t slot = ( p >> (BYTE_BITS + BIT_BITS + ALIGN_BITS)); ^ "test2.c", line 21: warning #2181-D: argument is incompatible with corresponding format string conversion p, slot, byte, bit, nop); ^ "test2.c", line 21: warning #2181-D: argument is incompatible with corresponding format string conversion p, slot, byte, bit, nop); ^ "test2.c", line 21: warning #2181-D: argument is incompatible with corresponding format string conversion p, slot, byte, bit, nop); ^ "test2.c", line 21: warning #2181-D: argument is incompatible with corresponding format string conversion p, slot, byte, bit, nop); ^ "test2.c", line 21: warning #2181-D: argument is incompatible with corresponding format string conversion p, slot, byte, bit, nop); ^ "test2.c", line 25: warning #2951-D: return type of function "main" mu +st be "int" void main (int argc, char *argv[]) ^ "test2.c", line 29: warning #2223-D: function "__UINT64_C" declared im +plicitly for (p = __UINT64_C (123456); p < (__UINT64_C (1) << 34); p += ( +__UINT64_C (+1) << 29)) { ^ "test2.c", line 29: remark #4272-D: conversion from "int" to "uintptr_ +t" may lose sign for (p = __UINT64_C (123456); p < (__UINT64_C (1) << 34); p += ( +__UINT64_C (+1) << 29)) { ^ "test2.c", line 29: warning #2063-D: shift count is too large for (p = __UINT64_C (123456); p < (__UINT64_C (1) << 34); p += ( +__UINT64_C (+1) << 29)) { ^ "test2.c", line 29: remark #4248-D: comparison of unsigned integer wit +h a signed integer for (p = __UINT64_C (123456); p < (__UINT64_C (1) << 34); p += ( +__UINT64_C (+1) << 29)) { ^ "test2.c", line 15: remark #4298-D: addition result could be truncated + before cast to bigger sized type ptrdiff_t slot = ( p >> (BYTE_BITS + BIT_BITS + ALIGN_BITS)); ^ "test2.c", line 29: remark #4249-D: value could be truncated before ca +st to bigger sized type for (p = __UINT64_C (123456); p < (__UINT64_C (1) << 34); p += ( +__UINT64_C (+1) << 29)) { ^ "test2.c", line 29: remark #4249-D: value could be truncated before ca +st to bigger sized type for (p = __UINT64_C (123456); p < (__UINT64_C (1) << 34); p += ( +__UINT64_C (+1) << 29)) { + ^ ld: Unsatisfied symbol "__UINT64_C" in file test2.o

Enjoy, Have FUN! H.Merijn

In reply to Re^9: 64-bit *nix/gcc expertise required by Tux
in thread 64-bit *nix/gcc expertise required (THIS IS NOT OFF TOPIC!) by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.