From 9b436b8711ac0814330bdf4af73029a97def926c Mon Sep 17 00:00:00 2001 From: Emilien Lemaire Date: Mon, 11 Sep 2023 14:38:19 +0200 Subject: [PATCH] Remove redundant header and respect C89 --- libcob/cobprof.c | 50 ++++++++++++++++++++++++++---------------------- libcob/cobprof.h | 27 +------------------------- libcob/common.c | 2 +- 3 files changed, 29 insertions(+), 50 deletions(-) diff --git a/libcob/cobprof.c b/libcob/cobprof.c index 9e7e78824..50f0f8415 100644 --- a/libcob/cobprof.c +++ b/libcob/cobprof.c @@ -18,25 +18,29 @@ along with GnuCOBOL. If not, see . */ -#define COB_LIB_EXPIMP - -#include "config.h" -#include "cobprof.h" - #include -#include #include #include #include #include +/* include internal and external libcob definitions, forcing exports */ +#define COB_LIB_EXPIMP +#include "coblocal.h" + +#include "tarstamp.h" +#include "config.h" +#include "cobprof.h" + #if HAVE_XLSXWRITER_H #include #elif HAVE_XLSXWRITER_XLSXWRITER_H #include #endif -static bool is_init = false; + + +static int is_init = 0; static size_t called_paragraphs[255][2]; static long start_times[255]; @@ -62,7 +66,7 @@ get_str_index(const char *str, const char **arr, size_t arr_len) static long get_time(long start_time, struct timespec stop_time) { - // This allows to count the number of times a procedure is ran while testing the compiler + /* This allows to count the number of times a procedure is ran while testing the compiler */ if (getenv ("COB_IS_RUNNING_IN_TESTMODE")) { return 1; } @@ -99,7 +103,7 @@ cob_prof_init(long (*total_times_p)[255], start_times[i] = ULONG_MAX; } - is_init = true; + is_init = 1; } void @@ -111,13 +115,13 @@ cob_prof_enter_paragraph(const char *section, const char *paragraph) if (!is_init) return; - // We should always have a section when entering a paragraph. + /* We should always have a section when entering a paragraph. */ if (!section) return; sec_idx = get_str_index (section, sections, sections_count); if (sec_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find section %s, aborting profiling.\n", section); - is_init = false; + is_init = 0; return; } @@ -125,7 +129,7 @@ cob_prof_enter_paragraph(const char *section, const char *paragraph) if (para_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find paragraph %s IN %s, aborting profiling.\n", section, paragraph); - is_init = false; + is_init = 0; return; } @@ -149,7 +153,7 @@ cob_prof_enter_section(const char *section) if (sec_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find section %s, aborting profiling.\n", section); - is_init = false; + is_init = 0; return; } @@ -174,7 +178,7 @@ cob_prof_exit_paragraph(const char *section, const char *paragraph) if (sec_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find section %s, aborting profiling.\n", section); - is_init = false; + is_init = 0; return; } @@ -183,7 +187,7 @@ cob_prof_exit_paragraph(const char *section, const char *paragraph) if (para_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find paragraph %s IN %s, aborting profiling.\n", section, paragraph); - is_init = false; + is_init = 0; return; } @@ -214,7 +218,7 @@ cob_prof_exit_section(const char *section) if (sec_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find section %s, aborting profiling.\n", section); - is_init = false; + is_init = 0; return; } @@ -224,7 +228,7 @@ cob_prof_exit_section(const char *section) size_t curr_sec = called_paragraphs[current_idx][0]; size_t curr_para = called_paragraphs[current_idx][1]; - if (curr_sec != sec_idx) return; // We exited all paragraphs entered in this section + if (curr_sec != sec_idx) return; /* We exited all paragraphs entered in this section */ if (curr_para == ULONG_MAX) { total_times[curr_sec][254] += get_time (start_times[current_idx], ts); @@ -233,7 +237,7 @@ cob_prof_exit_section(const char *section) } current_idx--; if (curr_sec == sec_idx && curr_para == ULONG_MAX) { - // We exit the last PERFORM of this section + /* We exit the last PERFORM of this section */ return; } } @@ -253,12 +257,12 @@ cob_prof_goto(const char *section, const char *paragraph) if (section == NULL) { - // GO TO exit : section = NULL, paragraph = invalid section name + /* GO TO exit : section = NULL, paragraph = invalid section name */ if (get_str_index (paragraph, sections, sections_count) == ULONG_MAX) { return; } - // GO TO section : section = NULL, paragraph = target section name + /* GO TO section : section = NULL, paragraph = target section name */ while (current_idx != ULONG_MAX) { cob_prof_exit_section (sections[called_paragraphs[current_idx][0]]); } @@ -270,7 +274,7 @@ cob_prof_goto(const char *section, const char *paragraph) if (sec_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find section %s, aborting profiling.\n", section); - is_init = false; + is_init = 0; return; } @@ -279,7 +283,7 @@ cob_prof_goto(const char *section, const char *paragraph) if (para_idx == ULONG_MAX) { fprintf (stderr, "[cob_prof] Could not find paragraph %s IN %s, aborting profiling\n", section, paragraph); - is_init = false; + is_init = 0; return; } @@ -423,7 +427,7 @@ cob_prof_end() total_times = NULL; - is_init = false; + is_init = 0; } diff --git a/libcob/cobprof.h b/libcob/cobprof.h index 6426c9087..1f93c460e 100644 --- a/libcob/cobprof.h +++ b/libcob/cobprof.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2023 Free Software Foundation, Inc. + Copyright (C) 2023 Free Software Foundation, Inc. Written by Emilien Lemaire This file is part of GnuCOBOL. @@ -21,31 +21,6 @@ #ifndef cob_prof_h #define cob_prof_h -#ifndef COB_EXT_EXPORT -#if ((defined(_WIN32) || defined(__CYGWIN__)) && !defined(__clang__)) -#define COB_EXT_EXPORT __declspec(dllexport) extern -#else -#define COB_EXT_EXPORT extern -#endif -#endif -#ifndef COB_EXT_IMPORT -#if ((defined(_WIN32) || defined(__CYGWIN__)) && !defined(__clang__)) -#define COB_EXT_IMPORT __declspec(dllimport) extern -#else -#define COB_EXT_IMPORT extern -#endif -#endif - -#ifndef COB_EXPIMP -#ifdef COB_LIB_EXPIMP - #define COB_EXPIMP COB_EXT_EXPORT -#else - #define COB_EXPIMP COB_EXT_IMPORT -#endif -#endif - -#include -#include #include COB_EXPIMP void cob_prof_init(long(*)[255], /* total_times */ diff --git a/libcob/common.c b/libcob/common.c index c6007185a..64bcc171a 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -18,7 +18,6 @@ along with GnuCOBOL. If not, see . */ -#include "cobprof.h" #include "tarstamp.h" #include "config.h" @@ -162,6 +161,7 @@ /* include internal and external libcob definitions, forcing exports */ #define COB_LIB_EXPIMP #include "coblocal.h" +#include "cobprof.h" #include "cobgetopt.h"