Граф коммитов

13 Коммитов

Автор SHA1 Сообщение Дата
Ehsan d0008e6a41
[linux-port] Add definition of strnicmp for Linux. (#1567)
Usage of strnicmp was recently added to the code base, and causes the
Linux builds to fail. This should fix it.
2018-09-25 17:24:59 -04:00
Ehsan Nasiri b86e5efe1b [linux-port] 'auto' not allowed in lambda parameter.
It is allowed starting C++14, but C++11 is assumed currently.
2018-09-18 10:44:36 -04:00
Greg Roth 988499d872 [linux-port] Better match Windows char conversion (#1479)
Windows char conversion functions differ from the std methods in
a few ways. Windows ignores null terminators when lengths are
provided, length limits represent character lengths not byte sizes,
the current linux implementation ignores codepages, but the files
used in many HLSL tests are in iso 8859-1 not utf8. So some
differentiation is needed.

This solves all but one of the above problems. To limit conversion
by source characters instead of solely the size of the output
buffer, where necessary, a temporary buffer is created to hold the
source string that corresponds to the provided character length and
a null terminator is appended to make the std:: conversion stop there.
If there is a null terminator there already, this is skipped for
performance purposes. Such is often the case.

To respect the codepage parameter, it is converted to the corresponding
locale string and setlocale is used to temporarily set the locale
accordingly and set it back afterwards.

The aspect that is missed is that the Windows conversion functions
will happily blow past a null terminating character if the length
specified encompasses it. This is rare enough in general, and unlikely
in the way these functions are used in the source base.

corrects one errant non-breaking space character that found its way
into an HLSL file that the std:: conversion choked on. It didn't seem
to serve any purpose anyway.
2018-08-02 13:03:43 -04:00
Greg Roth d155df144a [linux-port] Enable DXIsenseTest on Unix (#1446)
Mostly required converting simple member function definitions
to include the TEST_F macro, which works for either gtest or taef,
but is optional for the latter.

Fixed an additional bug with the Linux implementation of CComPtr
which contained a single virtual function, which causes the compiler
to add a vtable pointer to each object created. This is fine most of
the time, but when it is cast to another kind of pointer and attempts
to increment it as that type instead of CComPtr, it doesn't account
for the bytes that the vtable pointer take up.

By simply removing the sole virtual qualifier on the destructor,
which was on the destructor, the vtable pointer is omitted and the
cast and increment works. The CComPtrBase destructor prototype is
shown to not be virtual in Windows documentation.
2018-07-25 14:51:15 -04:00
Greg Roth db8e3511c5 [linux-port] restore mistakenly removed sysallocs (#1433)
In rebasing the heap change, I mistakenly removed the sysallocstringlen
and sysfreestring functions. This restores them.
2018-07-17 22:03:59 -04:00
Greg Roth c24c9de9f8 [linux-port] Unix Heap* allocation implementation (#1428)
Heap allocation functions were previously partially implemented via
a few macros that provided some of the functionality.

This replaces those macros with a more expansive implementation of
the interface as defined in Microsoft documents. Simple structs are
used to store pointer and size implementation, enabling queries of
allocation sized from pointers, putting an upper limit on the total
amount of memory allocated by the given heap, retrieving a
default heap for the process, and freeing of all heap memory at the
time of heap destruction.

Most flags are unsupported save ZERO_MEMORY. Heap creation includes
an initial size that is meant to preallocate memory and make latter
allocations more efficient. This does not support that. Still for
the usages in the code base, this should appear externally to be
a fully functional implementation.

Includes a macro for CaptureStackBackTrace as well for CompilerTest
2018-07-17 14:46:57 -04:00
Greg Roth 597376b4b1 [linux-port] Enhance FS interface support (#1420)
There are various points where system functions are called via
OS-specific wrappers beginning with llvm::sys::fs. As part of the
development of the HLSL shader compiler, some of the microsoft
versions were altered to call into a further abstraction via the
MSFileSystem interface. In certain cases, this allows non-existent
"included" files to be accessed with the outward appearance of being
real files. However, many of these changes were missed by the Unix
abstraction. This adds them in with the facilitator of adding a few
functions to the MSFilesystem abstraction that better match Unix
system calls.

Needed for various tests that provide fake source files to compile
and include fake headers from within HLSL code. Otherwise, these
files are not found because they are not on the filesystem.

The Unix-like methods are added because in cases where the current
filesystem abstraction just calls the system calls directly, the
windows-style accesses were cumbersome and incomplete. Tablegen
and some tests make use of these simpler implementations.
2018-07-17 12:50:42 -04:00
Greg Roth 0fa00bb37e [linux-port] Win adapter changes for HLSL tests (#1415)
* [linux-port] Win adapter changes for HLSL tests

A number of Windows-specific features are present in the HLSL tests
as well as driver features that had to be enabled to get those tests
running, notably intellisense classes.

This change adds to the existing WinAdapter and WinFunctions files
to include the features needed for these additions to driver and tests.
They cover a lot of ground, but mostly consist of memory allocation
and string changes, because you can never have enough ways to
allocate memory and manipulate strings.

An incidental change is to the existing CreateFileW implementation
to retry a file if the error indicated it was interrupted. This was
taken from the LLVM Path.inc implementation for Unix.
2018-07-17 09:19:40 -04:00
Greg Roth 051a7b639e [linux-port] Correct char convert size in/out (#1411)
MultiByteToWideChar and WideCharToMultiByte were returning -1 on
failure, which caused failures to be ignored. When successful, they
were returning the number of characters converted excluding the
terminating null character because that's what the std:: functions
used for the implementation do. Both are inconsistent with the
original Windows implementations.

Simply adding one to the return value works in all cases save those
where the number of characters converted was limited by the parameter
In this case, the number of characters converted doesn't include
the terminating null. So no addition is warrented.

Added addition errors in keeping with the function descriptions.

The CW2A conversion class left out the terminating null character
when calculating the max size of the converted string.
2018-07-10 16:57:21 -04:00
Ehsan e8d5eb0111
[linux-port] Enables the DXC main on Unix. (#1384) 2018-06-27 15:00:26 -04:00
Ehsan f8f0bfcf0b
[linux-port] FileSystem and IO. (#1374)
Some interactions with the FileSystem are not used by any API and are
therefore not implemented for Unix at the moment. We have put assertions in
place to make it easy to spot if any of those methods are ever used.
2018-06-26 15:05:08 -04:00
Ehsan 285490211f
[linux-port] Complete the Windows adapter code. (#1358)
This change completes the necessary adapter code needed to enable
cross-platform compilation.

Discussion on the design/implementation of these are in issue #1341 and
isuee #1342.

In addition to the adapter classes/structs, there exists usages of
Windows-specific functions in the codebase. In some cases, we won't need
to compile/run some of those methods on non-Windows platforms. For the
few cases where we do, we have implemented equivalent functionality in
WindowsFunctions.cpp.
2018-06-25 16:04:13 -04:00
Ehsan 180ea63ba0
[linux-port] Introduce Windows "adapter" headers (#1314)
In this CL, we have introduced the "WinAdapter.h" header file.

This file includes declarations and definitions that will enable compilation of the code base on non-Windows platforms. These include:

* Disabling SAL annotations for non-Windows platforms.
* Defining some Windows-specifc macros that are not defined on other platforms.
* Defining Windows-specific types that are used throughout the codebase for non-Windows platforms.

This file is currently not complete. As we go forward, we will add more classes/structs/type definitions to this file for specific purposes. The contents of this file is completely disabled (#ifdef'd away) for Windows, and do not affect Windows compilation in any way.  For the most part, this is our way of enabling compilation of the codebase on non-Windows platforms without making invasive changes to the existing cpp files, and without hindering any future development. Moreover, I have added the #include of this file for all the locations that will need it for successful Linux compilation.
2018-06-17 11:31:21 -04:00