In profile data paths, we replace "%h" with the hostname of the machine the program is running on. On Windows, we used gethostname() to obtain the hostname. This requires linking with ws2_32. With this change, we instead get the hostname from GetComputerNameExW(), which does not require ws2_32.
Details
Diff Detail
- Build Status
Buildable 1657 Build 1657: arc lint + arc unit
Event Timeline
lib/profile/InstrProfilingPort.h | ||
---|---|---|
18 | This code seems to go out of its way to not include windows.h, I'd like to preserve that. Can we sink the implementation of compiler_rt_gethostname to a .c file? |
lib/profile/InstrProfilingPort.h | ||
---|---|---|
18 | Good point, will do. |
Moved the implementation of the compatibility function to a .c file, as requested by @rnk.
I like where this is going.
lib/profile/InstrProfilingUtil.c | ||
---|---|---|
71 | TCHAR?! Since we're calling WideCharToMultiByte, it seems we're assuming "Unicode" mode, so I'd write WCHAR and keep it explicit. | |
82 | This doesn't terminate Name. There's a gotcha in this API that if you provide the length for the input string (BufferSize here), it'll process exactly that many "characters" and not terminate the output string. See the description of cchWideChar in https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130(v=vs.85).aspx If you know that Buffer is terminated, then it's safest to use -1 for cchWideChar. |
lib/profile/InstrProfilingUtil.c | ||
---|---|---|
71 | If we're assuming unicode mode, then let's call GetComputeNameExW. |
This code seems to go out of its way to not include windows.h, I'd like to preserve that. Can we sink the implementation of compiler_rt_gethostname to a .c file?