Skip to content

Use Windows Unicode API in C stubs - #843

Merged
smorimoto merged 1 commit into
ocsigen:masterfrom
MisterDA:windows-unicode
Nov 8, 2021
Merged

smorimoto merged 1 commit into
ocsigen:masterfrom
MisterDA:windows-unicode

Conversation

@MisterDA

@MisterDA MisterDA commented Mar 4, 2021

Copy link
Copy Markdown
Contributor

This was discussed a bit in #790.

I looked for windows functions in src/unix/{,windows_c}/*.c.

Two possible changes to this patch:

  1. define the macros inside the C files;
  2. use the W suffix to CreateProcess.

@raphael-proust

Copy link
Copy Markdown
Collaborator

I don't have a windows machine to try this on. Anyone has one?

Alternatively, I can merge the Github Actions PR first so we have windows in the CI.

@dra27

dra27 commented Mar 5, 2021

Copy link
Copy Markdown
Contributor

2. use the W suffix to CreateProcess.

This part isn't strictly necessary - defining UNICODE causes the Windows API to #define the correct function for CreateProcess.

@MisterDA

MisterDA commented Mar 8, 2021

Copy link
Copy Markdown
Contributor Author
  1. use the W suffix to CreateProcess.

This part isn't strictly necessary - defining UNICODE causes the Windows API to #define the correct function for CreateProcess.

Yes, I was suggesting it for the sake of explicitness, considering that I'm removing the comment below, in which we could also have explicitly called CreateProcessA.

/* The cast to LPSTR below is only legitimate because we are calling
  CreateProcessA. See https://github.com/ocsigen/lwt/pull/790. */

if (!CreateProcess(NULL, (LPSTR)String_val(cmdline), NULL, NULL, TRUE, 0,

@MisterDA

Copy link
Copy Markdown
Contributor Author

I noticed that this patch requires OCaml >= 4.06, so changed that on Windows.
I believe it is good to go, but it means that Lwt with OCaml >= 4.02 & < 4.06 isn't buildable on Windows anymore.

@MisterDA
MisterDA force-pushed the windows-unicode branch 3 times, most recently from fa5551f to 099acb5 Compare September 27, 2021 14:03
@MisterDA
MisterDA force-pushed the windows-unicode branch 3 times, most recently from 0c1dd3c to 7989c85 Compare October 4, 2021 16:18
@MisterDA

MisterDA commented Oct 4, 2021 •

Copy link
Copy Markdown
Contributor Author

Sorry for all the force-pushes, it's a bit late in the day. Can confirm that this PR works now, it was nicely broken before.
EDIT: rebased to get the green CI (even though the CI isn't testing the Windows code atm!)

@smorimoto

Copy link
Copy Markdown
Member

I'm just starting to think we should test on all, even on Windows.

@MisterDA

Copy link
Copy Markdown
Contributor Author

I'm just starting to think we should test on all, even on Windows.

At least the oldest and the newest. I'm interested by the newest, where all the cool bug fixes go!
I don't think it's very interesting to keep compatibility with OCaml < 4.06 versions on Windows.

@smorimoto

Copy link
Copy Markdown
Member

Certainly, testing the oldest and newest ones sounds like a good idea.

@smorimoto

Copy link
Copy Markdown
Member

I just merged #896

@dra27

dra27 commented Oct 15, 2021

Copy link
Copy Markdown
Contributor

I just merged #896

So this PR now needs to update the test matrix to test 4.06 on Windows instead of 4.02

@MisterDA
MisterDA force-pushed the windows-unicode branch 3 times, most recently from 8583dff to 1a55ce2 Compare October 15, 2021 15:31
@smorimoto

Copy link
Copy Markdown
Member

Just needs a CHANGES entry.

@MisterDA

MisterDA commented Nov 7, 2021

Copy link
Copy Markdown
Contributor Author

Rebased and added an entry.

@smorimoto

Copy link
Copy Markdown
Member

Great thank you

@smorimoto
smorimoto merged commit 461d808 into ocsigen:master Nov 8, 2021
@MisterDA
MisterDA deleted the windows-unicode branch November 10, 2021 09:04
MisterDA added a commit to MisterDA/lwt that referenced this pull request Nov 18, 2021
> If this flag is set, the environment block pointed to by
> lpEnvironment uses Unicode characters. Otherwise, the environment
> block uses ANSI characters.

[doc][]

This was forgotten from PR ocsigen#843 that switched to Unicode strings on
Windows (including the environment).

[doc]: https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags#CREATE_UNICODE_ENVIRONMENT
MisterDA added a commit to MisterDA/lwt that referenced this pull request Nov 19, 2021
> If the environment block pointed to by lpEnvironment contains
> Unicode characters, be sure that dwCreationFlags includes
> CREATE_UNICODE_ENVIRONMENT. If this parameter is NULL and the
> environment block of the parent process contains Unicode characters,
> you must also ensure that dwCreationFlags includes
> CREATE_UNICODE_ENVIRONMENT.

From [doc1][].

> If this flag is set, the environment block pointed to by
> lpEnvironment uses Unicode characters. Otherwise, the environment
> block uses ANSI characters.

From [doc2][].

This was forgotten from PR ocsigen#843 that switched to Unicode strings on
Windows (including the environment).

[doc1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
[doc2]: https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags#CREATE_UNICODE_ENVIRONMENT
MisterDA added a commit to MisterDA/lwt that referenced this pull request Nov 19, 2021
> If the environment block pointed to by lpEnvironment contains
> Unicode characters, be sure that dwCreationFlags includes
> CREATE_UNICODE_ENVIRONMENT. If this parameter is NULL and the
> environment block of the parent process contains Unicode characters,
> you must also ensure that dwCreationFlags includes
> CREATE_UNICODE_ENVIRONMENT.

From [doc1][].

> If this flag is set, the environment block pointed to by
> lpEnvironment uses Unicode characters. Otherwise, the environment
> block uses ANSI characters.

From [doc2][].

This was forgotten from PR ocsigen#843 that switched to Unicode strings on
Windows (including the environment).

[doc1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
[doc2]: https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags#CREATE_UNICODE_ENVIRONMENT
smorimoto pushed a commit to raphael-proust/lwt that referenced this pull request Dec 2, 2021
> If the environment block pointed to by lpEnvironment contains
> Unicode characters, be sure that dwCreationFlags includes
> CREATE_UNICODE_ENVIRONMENT. If this parameter is NULL and the
> environment block of the parent process contains Unicode characters,
> you must also ensure that dwCreationFlags includes
> CREATE_UNICODE_ENVIRONMENT.

From [doc1][].

> If this flag is set, the environment block pointed to by
> lpEnvironment uses Unicode characters. Otherwise, the environment
> block uses ANSI characters.

From [doc2][].

This was forgotten from PR ocsigen#843 that switched to Unicode strings on
Windows (including the environment).

[doc1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
[doc2]: https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags#CREATE_UNICODE_ENVIRONMENT
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.

4 participants