Commit d797ebe0 authored by David Schleef's avatar David Schleef

codemem: use symbol name in filename

parent f5f4f8d1
......@@ -7,6 +7,8 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_CODEMEM_MMAP
#include <sys/mman.h>
#endif
......@@ -14,6 +16,7 @@
#include <orc/orcprogram.h>
#include <orc/orcdebug.h>
#define SIZE 65536
......@@ -21,17 +24,38 @@
void
orc_compiler_allocate_codemem (OrcCompiler *compiler)
{
char filename[32] = "/tmp/orcexecXXXXXX";
int fd;
int n;
fd = mkstemp (filename);
if (fd == -1) {
/* FIXME oh crap */
ORC_COMPILER_ERROR (compiler, "failed to create temp file");
return;
/* FIXME something combining these two would be ideal */
#if 1
{
char filename[32] = "/tmp/orcexecXXXXXX";
fd = mkstemp (filename);
if (fd == -1) {
/* FIXME oh crap */
ORC_COMPILER_ERROR (compiler, "failed to create temp file");
return;
}
unlink (filename);
}
unlink (filename);
#else
{
char *filename;
filename = malloc (strlen ("/tmp/orcexec") +
strlen (compiler->program->name) + 1);
sprintf(filename, "/tmp/orcexec%s", compiler->program->name);
fd = open (filename, O_RDWR | O_CREAT, S_IRWXU);
if (fd == -1) {
/* FIXME oh crap */
ORC_COMPILER_ERROR (compiler, "failed to create temp file");
return;
}
unlink (filename);
free (filename);
}
#endif
n = ftruncate (fd, SIZE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment