From 5537f9b9a3c46c3898e274a52f6bb0eb8d293bb8 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Sat, 13 Jul 2019 20:40:52 +0100 Subject: libctf: write CTF files to memory, and CTF archives to fds Before now, we've been able to write CTF files to gzFile descriptors or fds, and CTF archives to named files only. Make this a bit less irregular by allowing CTF archives to be written to fds with the new function ctf_arc_write_fd: also allow CTF files to be written to a new memory buffer via ctf_write_mem. (It would be nice to complete things by adding a new function to write CTF archives to memory, but this is too difficult to do given the short time the linker is expected to be writing them out: we will transition to a better format in format v4, though we will always support reading CTF archives that are stored in .ctf sections.) include/ * ctf-api.h (ctf_arc_write_fd): New. (ctf_write_mem): Likewise. (ctf_gzwrite): Spacing fix. libctf/ * ctf-archive.c (ctf_arc_write): Split off, and reimplement in terms of... (ctf_arc_write_fd): ... this new function. * ctf-create.c (ctf_write_mem): New. --- include/ctf-api.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/ctf-api.h') diff --git a/include/ctf-api.h b/include/ctf-api.h index fa74788..2bee08b 100644 --- a/include/ctf-api.h +++ b/include/ctf-api.h @@ -258,6 +258,8 @@ extern void ctf_file_close (ctf_file_t *); extern int ctf_arc_write (const char *, ctf_file_t **, size_t, const char **, size_t); +extern int ctf_arc_write_fd (int, ctf_file_t **, size_t, const char **, + size_t); extern const char *ctf_cuname (ctf_file_t *); extern void ctf_cuname_set (ctf_file_t *, const char *); @@ -379,8 +381,9 @@ extern ctf_snapshot_id_t ctf_snapshot (ctf_file_t *); extern int ctf_rollback (ctf_file_t *, ctf_snapshot_id_t); extern int ctf_discard (ctf_file_t *); extern int ctf_write (ctf_file_t *, int); -extern int ctf_gzwrite (ctf_file_t * fp, gzFile fd); +extern int ctf_gzwrite (ctf_file_t *fp, gzFile fd); extern int ctf_compress_write (ctf_file_t * fp, int fd); +extern unsigned char *ctf_write_mem (ctf_file_t *, size_t *, size_t threshold); extern void ctf_setdebug (int debug); extern int ctf_getdebug (void); -- cgit v1.1