Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__ILP32__ __LP64__ __LLP64__ #536

Open
monniaux opened this issue Nov 5, 2024 · 0 comments
Open

__ILP32__ __LP64__ __LLP64__ #536

monniaux opened this issue Nov 5, 2024 · 0 comments

Comments

@monniaux
Copy link
Contributor

monniaux commented Nov 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant