CompCert icon indicating copy to clipboard operation
CompCert copied to clipboard

__ILP32__ __LP64__ __LLP64__

Open monniaux opened this issue 1 year ago • 0 comments

Apparently, certain compilers define __ILP32__, __LP64__, __LLP64__ (and the same without trailing __) to imply certain sizes of integers and pointers.

#if defined(__LLP64__)
	if (sizeof(short) == 2
	    && sizeof(int) == 4
	    && sizeof(long int) == 4
	    && sizeof(long long int) == 8
	    && sizeof(void*) == 8) {
		(void)printf("Ok\n");
	} else {
		(void)printf("KO __LLP64__\n");
	}
#elif defined(__LP64__)
	if (sizeof(short) == 2
	    && sizeof(int) == 4
	    && sizeof(long int) == 8
	    && sizeof(long long int) == 8
	    && sizeof(void*) == 8) {
		(void)printf("Ok\n");
	} else {
		(void)printf("KO __LP64__\n");
	}
#elif defined(__ILP32__)
	if (sizeof(short) == 2
	    && sizeof(int) == 4
	    && sizeof(long int) == 4
	    && sizeof(void*) == 4) {
		(void)printf("Ok\n");
	} else {
		(void)printf("KO __ILP32__\n");
	}

Maybe CompCert should do likewise. Apparently it does on some platforms depending on which compiler is used as a preprocessor, but not on ARM32 for instance.

This is low priority in any case.

monniaux avatar Nov 05 '24 09:11 monniaux