P4 to Git Change 1278607 by smekhano@stas-rampitec-hsa on 2016/06/10 13:18:54

SWDEV-94189 - ORCA RT: do not use temp files

	This is memfile implementation, an interface to plug into libelf and emulate files in memory w/o any IO.
	If passed filename to open() is empty it will use in memory file, otherwise proxy it to the real file IO routine.

	This allows RT not to use temp files. Next this interface will be plugged to the finalizer.

	Testing: smoke, precheckin, conformance 2.0 reallyquick, test_compiler 1.2 with -legacy, test_compiler with -save-temps-all and -g -O0 -mem2reg=0
	Reviewed by Evgeny Mankov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/elf.cpp#34 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/elf.hpp#23 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/elf_utils.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/utils/libelf/_libelf_config.h#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/utils/libelf/build/Makefile.libelf#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/utils/libelf/elf_update.c#12 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/utils/libelf/memfile.cpp#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/utils/libelf/memfile.h#1 add
This commit is contained in:
foreman
2016-06-10 13:23:51 -04:00
parent 251374c4e4
commit 43e8a3bd3d
7 changed files with 426 additions and 58 deletions
+7 -25
View File
@@ -3,42 +3,24 @@
//
#include "elf_utils.hpp"
#include "memfile.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#if defined(__GNUC__)
#include <unistd.h>
#else
#include <io.h>
#endif
/*
See elf_utils.hpp for descriptions about each functions
*/
namespace amd {
#if defined(_MSC_VER)
#define ELF_OPEN _open
#define ELF_READ(f, b, l) _read((f), (b), (unsigned int)(l))
#define ELF_WRITE _write
#define ELF_CLOSE _close
#define ELF_LSEEK _lseek
#else
#define ELF_OPEN open
#define ELF_READ(f, b, l) read((f), (b), (size_t)(l))
#define ELF_WRITE write
#define ELF_CLOSE close
#define ELF_LSEEK lseek
#endif
#define ELF_OPEN mem_open
#define ELF_READ(f, b, l) mem_read((f), (b), (unsigned int)(l))
#define ELF_WRITE mem_write
#define ELF_CLOSE mem_close
#define ELF_LSEEK mem_lseek
/*
Save the error string in _lastErrMsg. If it is built without NDEBUG, the program
@@ -81,7 +63,7 @@ void* xmalloc(OclElfErr& err, const size_t len)
int xopen(OclElfErr& err, const char *fname, const int in_flags, const int perms)
{
const int retval = ELF_OPEN(fname, in_flags, perms);
if (retval < 0) {
if (retval == -1) {
err.xfail("Failed to open '%s': %s", fname, strerror(errno));
return -1;
}