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

Add support for Visual Studio 2015+ #45

Closed
wants to merge 7 commits into from
Closed

Add support for Visual Studio 2015+ #45

wants to merge 7 commits into from

Conversation

ladnir
Copy link
Contributor

@ladnir ladnir commented May 9, 2017

In this pull require I propose adding support for the Visual Studio compiler. In total, the changes can be summarized as:

  • Replace the use of "variable-length automatic array" with malloc(...)/free(...). This is required because VS only supports C90 and Variable-length automatic arrays were added in C99.
  • Setting the WORD size to be 32 bits as opposed to 64 to ensure that the gcc extension uint128_t type is note used. This change has been made to the cmake files when cmake is targeting visual studio.
  • Using WCGR instead of UDEV as the source of random numbers when cmake detects that visual studio is being targeted.
  • Added the EXPAND(...) macro to help Visual Studio expand __VA_ARGS__. This is a known bug/workaround in visual studio.
  • Small fix with windows header and the pre-processor definition of FIXED. See src/rand/relic_rand_core.c
  • Add visual studio (Intel) equivalent of __builtin_clz(...).

This change has been tested both on x64 windows 10 and x64 Linux (CentOS). If addition changes are required, I would be happy to assist.

Thanks,
Peter Rindal

@ladnir
Copy link
Contributor Author

ladnir commented Jul 5, 2017

Any chance that this might get pulled?

@dfaranha
Copy link
Contributor

dfaranha commented Jul 6, 2017

Hi Peter,

My vacations will formally start next week, when I will take care of all the pending stuff with RELIC.

I am happy to merge most of the changes, but switching to malloc/free for everything is tricky, since we decided to move the library to stack-only allocation in the next refactoring.

Hope it helps,

@ladnir
Copy link
Contributor Author

ladnir commented Jul 6, 2017

That's no problem, would you be OK with wrapping them in a macro and then it can simply set it as stack/heap at compile time. I can update this.

Thanks!
Peter.

@conradoplg
Copy link
Contributor

I once compiled RELIC with Visual Studio and found it easier to compile it as C++, where it has support for variable length arrays, etc.

@ladnir
Copy link
Contributor Author

ladnir commented Jul 10, 2017

I do not think that is true.

@dfaranha
Copy link
Contributor

Does Visual Studio support alloca.h?

@ladnir
Copy link
Contributor Author

ladnir commented Jul 10, 2017

It appears to have _alloca.h. Is the macro option not desirable?

@dfaranha
Copy link
Contributor

Using malloc() complicates things due to error-handling. I think it's better if we can enforce stack allocation across all configurations, and alloca() may provide this.

@ladnir
Copy link
Contributor Author

ladnir commented Jul 10, 2017

Yeah alloca() sounds reasonable then. Just wrap the header in an if defined to get the right header. alloca.h vs _alloca.h

@ladnir
Copy link
Contributor Author

ladnir commented Nov 21, 2018

Closing this one because I have a new pull request with the newest version of relic and using alloca()

@ladnir ladnir closed this Nov 21, 2018
@ladnir ladnir mentioned this pull request Nov 21, 2018
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.

None yet

3 participants