1 /*
2 * Copyright (c) 2018 Oticon A/S
3 * Copyright (c) 2023 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include <stdio.h>
9 #include "nsi_tracing.h"
10
tracing_backend_posix_init_bottom(const char * file_name)11 void *tracing_backend_posix_init_bottom(const char *file_name)
12 {
13 FILE *f;
14
15 f = fopen(file_name, "wb");
16 if (f == NULL) {
17 nsi_print_error_and_exit("%s: Could not open CTF backend file %s\n",
18 __func__, file_name);
19 }
20
21 return (void *)f;
22 }
23
tracing_backend_posix_output_bottom(const void * data,unsigned long length,void * out_stream)24 void tracing_backend_posix_output_bottom(const void *data, unsigned long length, void *out_stream)
25 {
26 int rc = fwrite(data, length, 1, (FILE *)out_stream);
27
28 if (rc != 1) {
29 nsi_print_warning("%s: Failure writing to CTF backend file\n", __func__);
30 }
31
32 fflush((FILE *)out_stream);
33 }
34