From: Mathieu Desnoyers Date: Wed, 30 Nov 2016 22:32:23 +0000 (-0500) Subject: Move print.h header to upper level dir X-Git-Tag: v2.0.0-pre1~280 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=cd00e1d36ebc9d77c1c69ac679f8af79196508e7 Move print.h header to upper level dir Can be used by both fs and lttng-live. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/plugins/ctf/Makefile.am b/plugins/ctf/Makefile.am index 566577ae..297106da 100644 --- a/plugins/ctf/Makefile.am +++ b/plugins/ctf/Makefile.am @@ -2,6 +2,8 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include SUBDIRS = common fs-src fs-sink lttng-live +noinst_HEADERS = print.h + plugindir = "$(PLUGINSDIR)" plugin_LTLIBRARIES = libbabeltrace-plugin-ctf.la diff --git a/plugins/ctf/fs-src/data-stream.c b/plugins/ctf/fs-src/data-stream.c index 016e3fc5..bc0d1217 100644 --- a/plugins/ctf/fs-src/data-stream.c +++ b/plugins/ctf/fs-src/data-stream.c @@ -42,7 +42,8 @@ #define PRINT_ERR_STREAM ctf_fs->error_fp #define PRINT_PREFIX "ctf-fs-data-stream" -#include "print.h" +#define PRINT_DBG_CHECK ctf_fs_debug +#include "../print.h" static inline size_t remaining_mmap_bytes(struct ctf_fs_stream *stream) diff --git a/plugins/ctf/fs-src/file.c b/plugins/ctf/fs-src/file.c index 8b756496..0d0ed7e0 100644 --- a/plugins/ctf/fs-src/file.c +++ b/plugins/ctf/fs-src/file.c @@ -28,7 +28,8 @@ #define PRINT_ERR_STREAM ctf_fs->error_fp #define PRINT_PREFIX "ctf-fs-file" -#include "print.h" +#define PRINT_DBG_CHECK ctf_fs_debug +#include "../print.h" #include "file.h" diff --git a/plugins/ctf/fs-src/fs.c b/plugins/ctf/fs-src/fs.c index a20e7d6c..d50966f7 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -48,7 +48,8 @@ #define PRINT_ERR_STREAM ctf_fs->error_fp #define PRINT_PREFIX "ctf-fs" -#include "print.h" +#define PRINT_DBG_CHECK ctf_fs_debug +#include "../print.h" #define METADATA_TEXT_SIG "/* CTF 1.8" BT_HIDDEN diff --git a/plugins/ctf/fs-src/metadata.c b/plugins/ctf/fs-src/metadata.c index 13cc816e..24252733 100644 --- a/plugins/ctf/fs-src/metadata.c +++ b/plugins/ctf/fs-src/metadata.c @@ -34,7 +34,8 @@ #define PRINT_ERR_STREAM ctf_fs->error_fp #define PRINT_PREFIX "ctf-fs-metadata" -#include "print.h" +#define PRINT_DBG_CHECK ctf_fs_debug +#include "../print.h" #include "fs.h" #include "file.h" diff --git a/plugins/ctf/fs-src/print.h b/plugins/ctf/fs-src/print.h deleted file mode 100644 index 9daf7ea4..00000000 --- a/plugins/ctf/fs-src/print.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef CTF_FS_PRINT_H -#define CTF_FS_PRINT_H - -/* - * Define PRINT_PREFIX and PRINT_ERR_STREAM, then include this file. - * - * Copyright (c) 2016 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#define PERR(fmt, ...) \ - do { \ - if (PRINT_ERR_STREAM) { \ - fprintf(PRINT_ERR_STREAM, \ - "Error: " PRINT_PREFIX ": " fmt, \ - ##__VA_ARGS__); \ - } \ - } while (0) - -#define PWARN(fmt, ...) \ - do { \ - if (PRINT_ERR_STREAM) { \ - fprintf(PRINT_ERR_STREAM, \ - "Warning: " PRINT_PREFIX ": " fmt, \ - ##__VA_ARGS__); \ - } \ - } while (0) - -#define PDBG(fmt, ...) \ - do { \ - if (ctf_fs_debug) { \ - fprintf(stderr, \ - "Debug: " PRINT_PREFIX ": " fmt, \ - ##__VA_ARGS__); \ - } \ - } while (0) - -#endif /* CTF_FS_PRINT_H */ diff --git a/plugins/ctf/print.h b/plugins/ctf/print.h new file mode 100644 index 00000000..eb5b30c8 --- /dev/null +++ b/plugins/ctf/print.h @@ -0,0 +1,58 @@ +#ifndef CTF_PRINT_H +#define CTF_PRINT_H + +/* + * Define PRINT_PREFIX, PRINT_DBG_CHECK, and PRINT_ERR_STREAM, then + * include this file. + * + * Copyright (c) 2016 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +#define PERR(fmt, ...) \ + do { \ + if (PRINT_ERR_STREAM) { \ + fprintf(PRINT_ERR_STREAM, \ + "Error: " PRINT_PREFIX ": " fmt, \ + ##__VA_ARGS__); \ + } \ + } while (0) + +#define PWARN(fmt, ...) \ + do { \ + if (PRINT_ERR_STREAM) { \ + fprintf(PRINT_ERR_STREAM, \ + "Warning: " PRINT_PREFIX ": " fmt, \ + ##__VA_ARGS__); \ + } \ + } while (0) + +#define PDBG(fmt, ...) \ + do { \ + if (PRINT_DBG_CHECK) { \ + fprintf(stderr, \ + "Debug: " PRINT_PREFIX ": " fmt, \ + ##__VA_ARGS__); \ + } \ + } while (0) + +#endif /* CTF_PRINT_H */