Please help

Sebastian Strollo seb@REDACTED
Tue Dec 15 10:21:44 CET 1998


Hello out there!

Erlang uses tagged pointers in it's memory management. This usually
works fine, but for some architectures the top bits (which we use) in
the pointers are sometimes set (as in Irix, which some of you
noted). We are trying to write a test to dynamically figure this
out.

It would be great if you who have any other machines than we have
tried it on (see below) could compile and run the program included
below and send the output of the program, along with the output of
"uname -a", directly back to me.

We have tried it on Intel (Solaris, FreeBSD 2.2.X, Linux (red hat))
Sparc (Solaris, SunOS 4).

Thank you in advance!

-- Sebastian


----------------------------------------------------------------------
/*
** C program to find out sizes and sign of basic C data types
** also tries to find out the "magic" EXTRA_POINTER_BITS
**
*/
#include <stdio.h>
#include <stdlib.h>

#define UNSAFE_MASK  0xf0000000 /* Mask for bits that must be constant */

void extra_pointer_bits()
{
    int i;
    int n;
    void* ptr;
    unsigned long ptr_val;

    ptr_val = ((unsigned long) malloc(1)) & UNSAFE_MASK;
    n = 2;

    /* allocate some Meg */
    for (i = 1; i < 20; i++) {
	ptr = (void*) malloc(n);
	if ((((unsigned long) ptr) & UNSAFE_MASK) != ptr_val) {
	    fprintf(stderr, "POINTER HAS VARIABLE BITS IN BITS 31-28!\n");
	    exit(1);
	}
	n *= 2;
    }
    if (ptr_val == 0)
	fprintf(stdout, "#define EXTRA_POINTER_BITS 0\n");
    else
	fprintf(stdout, "#define EXTRA_POINTER_BITS 0x%8x\n", ptr_val);
}

main()
{
    extra_pointer_bits();
    exit(0);
}



More information about the erlang-questions mailing list