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

Configurator: support both negative numbers and expressions in C imports #1731

Closed
wants to merge 5 commits into from

Conversation

emillon
Copy link
Collaborator

@emillon emillon commented Jan 2, 2019

Rather than using the preprocessor to determine the sign of a value, we store both x and -x. One of them has an all-digit representation.

For example, 1234 is stored as "0000001234000000/.-," and -5678 is stored as "000000+*)(0000005678".

We might be able to do better if we could encode the sign and absolute value in the preprocessor, but it seems tricky to do so in a portable way.

(cc @Chris00 @avsm)

@Chris00
Copy link
Member

Chris00 commented Jan 2, 2019

Well, #1726 does not use the sign-detection by the preprocessor, just compile time evaluation of constant expressions.

@emillon
Copy link
Collaborator Author

emillon commented Jan 2, 2019

Indeed! But this requires the constant to be evaluable by cpp, which is a stronger requirement than what it used to be.

Signed-off-by: Etienne Millon <me@emillon.org>
Signed-off-by: Etienne Millon <me@emillon.org>
This reverts commit 606f25b.

Signed-off-by: Etienne Millon <me@emillon.org>
Rather than using the preprocessor to determine the sign of a value, we
store both `x` and `-x`. One of them has an all-digit representation.

Closes ocaml#1720

Signed-off-by: Etienne Millon <me@emillon.org>
Signed-off-by: Etienne Millon <me@emillon.org>
@Chris00
Copy link
Member

Chris00 commented Jan 2, 2019

Are you sure the evaluation is by cpp? I would rather think the compiler does them.

@emillon
Copy link
Collaborator Author

emillon commented Jan 2, 2019

You can see #1720 for a description of the problem, but yes the idea is that #if ... expressions are evaluated only by the C preprocessor. It has access to macros and constant evaluation, but does not have access to C features such as sizeof. You can find the relevant bits in the GCC documentation or in the C18 document in 6.10.1, "conditional inclusion".

@Chris00
Copy link
Member

Chris00 commented Jan 2, 2019

Please see #1726 (the PR I was referring to in my earlier post), there are no #if anymore.

@emillon
Copy link
Collaborator Author

emillon commented Jan 2, 2019

Ah! My bad, I didn't see this one. I'll merge it and close this one. Sorry about the confusion!

@emillon emillon closed this Jan 2, 2019
@emillon emillon deleted the configurator-1720 branch January 7, 2019 07:42
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

Successfully merging this pull request may close these issues.

2 participants