* xvasprintf.c: New file.
[official-gcc.git] / gcc / jit / jit-tempdir.h
blob31636ddcaa7f9cdafd067ea8ddd86ec8d633203a
1 /* Managing temporary directories and their content within libgccjit.so
2 Copyright (C) 2014 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef JIT_TEMPDIR_H
22 #define JIT_TEMPDIR_H
24 namespace gcc {
26 namespace jit {
28 /* A class to keep track of the jit::playback::context's tempdir.
30 The tempdir has the following layout:
32 /tmp/libgccjit-XXXXXX/
33 ./fake.c
34 (doesn't exist, but the rest of the
35 compiler needs a source code filename)
37 ./fake.s
38 (created by toplev::main)
40 ./fake.so
41 (created by playback::context::convert_to_dso).
43 It is normally deleted from the filesystem in the playback::context's
44 dtor, unless GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES was set. */
46 class tempdir
48 public:
49 tempdir (int keep_intermediates);
50 ~tempdir ();
52 bool create ();
54 const char * get_path () const { return m_path_tempdir; }
55 const char * get_path_c_file () const { return m_path_c_file; }
56 const char * get_path_s_file () const { return m_path_s_file; }
57 const char * get_path_so_file () const { return m_path_so_file; }
59 private:
60 /* Was GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES set? If so, keep the
61 on-disk tempdir around after this wrapper object goes away. */
62 int m_keep_intermediates;
64 /* Allocated using xmalloc (by xstrdup). */
65 char *m_path_template;
67 /* This either aliases m_path_template, or is NULL. */
68 char *m_path_tempdir;
70 /* The following are allocated using xmalloc. */
71 char *m_path_c_file;
72 char *m_path_s_file;
73 char *m_path_so_file;
77 } // namespace gcc::jit
79 } // namespace gcc
81 #endif /* JIT_TEMPDIR_H */