From 99ac691209ef6b38b85d4b705deeadb55c830949 Mon Sep 17 00:00:00 2001 From: Jeremy Iverson Date: Mon, 30 Nov 2020 18:19:20 -0600 Subject: [PATCH] Cleans up source This primary purpose of this commit is to make some minor changes to the code to clean it up a bit. Notable changes are as follows: * The macro `__OPENMP__` is replaced by `_OPENMP`. `__OPENMP__` was an artifact from the old build system, which defined such a macro when the build was configured with OpenMP support. According to the [OpenMP specification](https://www.openmp.org/specifications/) Section [2.2](https://www.openmp.org/spec-html/5.1/openmpse10.html#x38-370002.2) "the `_OPENMP` macro name is defined to have the decimal value *yyyymm* where *yyyy* and *mm* are the year and month designations of the version of the OpenMP API that the implementation supports." As such, it should be the preferred way to check for OpenMP support during compilation. * The preprocessor condition `defined(__WITHPCRE__)` is replaced by `defined(USE_PCRE) && defined(HAVE_PCREPOSIX_H)`. `__WITHPCRE__` was an artifact from the old build system, which was defined during configuration if the build system user requested PCRE support. This functionality has been replaced by the macro name `USE_PCRE` to be consistent with the other feature availability checks done in the core CMake logic and the condition has been extended to not only check for the request (`USE_PCRE`), but also the availability of the necessary header file, namely `pcreposix.h` indicated by the macro name `HAVE_PCREPOSIX_H` being defined during CMake configuration. --- apps/cmpnbrs.c | 2 +- apps/csrcnv.c | 2 +- apps/fis.c | 2 +- apps/gkgraph.c | 2 +- apps/gkrw.c | 2 +- apps/gksort.c | 2 +- apps/gkuniq.c | 2 +- apps/grKx.c | 2 +- apps/m2mnbrs.c | 2 +- apps/splatt2svd.c | 2 +- apps/strings.c | 2 +- include/GKlib/GKlib.h | 42 ++++++++++++++++++------------------- include/GKlib/gk_getopt.h | 16 +++++++------- include/GKlib/gk_mkpqueue.h | 3 +++ include/GKlib/gk_proto.h | 4 ++-- src/blas.c | 2 +- src/cache.c | 2 +- src/csr.c | 2 +- src/error.c | 2 +- src/evaluate.c | 2 +- src/fkvkselect.c | 2 +- src/fs.c | 2 +- src/getopt.c | 2 +- src/gk_util.c | 2 +- src/graph.c | 4 ++-- src/htable.c | 2 +- src/io.c | 2 +- src/itemsets.c | 2 +- src/mcore.c | 2 +- src/memory.c | 2 +- src/pqueue.c | 2 +- src/random.c | 2 +- src/rw.c | 2 +- src/seq.c | 2 +- src/sort.c | 2 +- src/string.c | 4 ++-- src/timers.c | 4 ++-- src/tokenizer.c | 2 +- 38 files changed, 70 insertions(+), 69 deletions(-) diff --git a/apps/cmpnbrs.c b/apps/cmpnbrs.c index 6e3ace8..64a88f0 100644 --- a/apps/cmpnbrs.c +++ b/apps/cmpnbrs.c @@ -9,7 +9,7 @@ \version \verbatim $Id: m2mnbrs.c 17699 2014-09-27 18:05:31Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ /*! Data structures for the code */ diff --git a/apps/csrcnv.c b/apps/csrcnv.c index aef808e..94ccabe 100644 --- a/apps/csrcnv.c +++ b/apps/csrcnv.c @@ -8,7 +8,7 @@ \version \verbatim $Id: csrcnv.c 15314 2013-10-05 16:50:50Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ /*! Data structures for the code */ diff --git a/apps/fis.c b/apps/fis.c index 084a4b6..387d6fc 100644 --- a/apps/fis.c +++ b/apps/fis.c @@ -7,7 +7,7 @@ \version \verbatim $Id: fis.c 11075 2011-11-11 22:31:52Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ /*! Data structures for the code */ diff --git a/apps/gkgraph.c b/apps/gkgraph.c index 9131464..1dabd0d 100644 --- a/apps/gkgraph.c +++ b/apps/gkgraph.c @@ -7,7 +7,7 @@ \version \verbatim $Id: gkgraph.c 17700 2014-09-27 18:10:02Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ diff --git a/apps/gkrw.c b/apps/gkrw.c index 1a3295e..dcc66ea 100644 --- a/apps/gkrw.c +++ b/apps/gkrw.c @@ -7,7 +7,7 @@ \version \verbatim $Id$ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ /*! Data structures for the code */ diff --git a/apps/gksort.c b/apps/gksort.c index 6543836..0ec38b7 100644 --- a/apps/gksort.c +++ b/apps/gksort.c @@ -7,7 +7,7 @@ \version\verbatim $Id: gksort.c 11058 2011-11-10 00:02:50Z karypis $ \endverbatim */ -#include +#include "GKlib.h" #define N 10000 diff --git a/apps/gkuniq.c b/apps/gkuniq.c index c30b0f7..3ee77a0 100644 --- a/apps/gkuniq.c +++ b/apps/gkuniq.c @@ -6,7 +6,7 @@ \author George */ -#include +#include "GKlib.h" /*************************************************************************/ /*! Data structures for the code */ diff --git a/apps/grKx.c b/apps/grKx.c index a72b580..f87d35c 100644 --- a/apps/grKx.c +++ b/apps/grKx.c @@ -7,7 +7,7 @@ \version \verbatim $Id: grKx.c 17699 2014-09-27 18:05:31Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ /*! Data structures for the code */ diff --git a/apps/m2mnbrs.c b/apps/m2mnbrs.c index 53f35ca..b6f7671 100644 --- a/apps/m2mnbrs.c +++ b/apps/m2mnbrs.c @@ -8,7 +8,7 @@ \version \verbatim $Id: m2mnbrs.c 17699 2014-09-27 18:05:31Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ /*! Data structures for the code */ diff --git a/apps/splatt2svd.c b/apps/splatt2svd.c index 111d31c..6078161 100644 --- a/apps/splatt2svd.c +++ b/apps/splatt2svd.c @@ -6,7 +6,7 @@ \author George */ -#include +#include "GKlib.h" int main(int argc, char *argv[]) diff --git a/apps/strings.c b/apps/strings.c index b241d3f..369d2a6 100644 --- a/apps/strings.c +++ b/apps/strings.c @@ -7,7 +7,7 @@ \version\verbatim $Id: strings.c 10711 2011-08-31 22:23:04Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ diff --git a/include/GKlib/GKlib.h b/include/GKlib/GKlib.h index 9278fe4..5ab6358 100644 --- a/include/GKlib/GKlib.h +++ b/include/GKlib/GKlib.h @@ -43,41 +43,39 @@ #include #include -#if defined(__WITHPCRE__) +#if defined(USE_PCRE) && defined(HAVE_PCREPOSIX_H) #include +#elif defined(HAVE_REGEX_H) + #include #else - #if defined(USE_GKREGEX) - #include "gkregex.h" - #else - #include - #endif /* defined(USE_GKREGEX) */ -#endif /* defined(__WITHPCRE__) */ + #include "gkregex.h" +#endif -#if defined(__OPENMP__) +#if defined(_OPENMP) #include #endif -#include -#include -#include -#include -#include -#include +#include "gk_types.h" +#include "gk_struct.h" +#include "gk_externs.h" +#include "gk_defs.h" +#include "gk_macros.h" +#include "gk_getopt.h" -#include -#include -#include -#include -#include -#include -#include +#include "gk_mksort.h" +#include "gk_mkblas.h" +#include "gk_mkmemory.h" +#include "gk_mkpqueue.h" +#include "gk_mkpqueue2.h" +#include "gk_mkrandom.h" +#include "gk_mkutils.h" -#include +#include "gk_proto.h" #endif /* GKlib.h */ diff --git a/include/GKlib/gk_getopt.h b/include/GKlib/gk_getopt.h index 4bb8611..99a9885 100644 --- a/include/GKlib/gk_getopt.h +++ b/include/GKlib/gk_getopt.h @@ -46,17 +46,17 @@ struct gk_option { }; /* Names for the values of the `has_arg' field of `struct gk_option'. */ -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 /* Function prototypes */ -extern int gk_getopt(int __argc, char **__argv, char *__shortopts); -extern int gk_getopt_long(int __argc, char **__argv, char *__shortopts, - struct gk_option *__longopts, int *__longind); -extern int gk_getopt_long_only (int __argc, char **__argv, - char *__shortopts, struct gk_option *__longopts, int *__longind); +extern int gk_getopt(int argc, char **argv, char *shortopts); +extern int gk_getopt_long(int argc, char **argv, char *shortopts, + struct gk_option *longopts, int *longind); +extern int gk_getopt_long_only (int argc, char **argv, + char *shortopts, struct gk_option *longopts, int *longind); diff --git a/include/GKlib/gk_mkpqueue.h b/include/GKlib/gk_mkpqueue.h index 50a5385..2055e0a 100644 --- a/include/GKlib/gk_mkpqueue.h +++ b/include/GKlib/gk_mkpqueue.h @@ -391,6 +391,9 @@ int FPRFX ## CheckHeap(PQT *queue)\ heap = queue->heap;\ locator = queue->locator;\ nnodes = queue->nnodes;\ +\ + /* silence unused-but-set-variable */\ + (void)heap;\ \ if (nnodes == 0)\ return 1;\ diff --git a/include/GKlib/gk_proto.h b/include/GKlib/gk_proto.h index d99bd5e..2ed50c7 100644 --- a/include/GKlib/gk_proto.h +++ b/include/GKlib/gk_proto.h @@ -289,7 +289,7 @@ uint32_t gk_randint32(void); /*------------------------------------------------------------- * OpenMP fake functions *-------------------------------------------------------------*/ -#if !defined(__OPENMP__) +#if !defined(_OPENMP) void omp_set_num_threads(int num_threads); int omp_get_num_threads(void); int omp_get_max_threads(void); @@ -300,7 +300,7 @@ void omp_set_dynamic(int num_threads); int omp_get_dynamic(void); void omp_set_nested(int nested); int omp_get_nested(void); -#endif /* __OPENMP__ */ +#endif /* _OPENMP */ /*------------------------------------------------------------- diff --git a/src/blas.c b/src/blas.c index a0b95ca..edf60de 100644 --- a/src/blas.c +++ b/src/blas.c @@ -15,7 +15,7 @@ which is used for code generation. \version\verbatim $Id: blas.c 14330 2013-05-18 12:15:15Z karypis $ \endverbatim */ -#include +#include "GKlib.h" diff --git a/src/cache.c b/src/cache.c index 932e36d..f7e46e9 100644 --- a/src/cache.c +++ b/src/cache.c @@ -9,7 +9,7 @@ \version $Id: cache.c 21991 2018-04-16 03:08:12Z karypis $ */ -#include +#include "GKlib.h" /*************************************************************************/ diff --git a/src/csr.c b/src/csr.c index 7e92a0c..ff29b46 100644 --- a/src/csr.c +++ b/src/csr.c @@ -7,7 +7,7 @@ * \version\verbatim $Id: csr.c 21044 2017-05-24 22:50:32Z karypis $ \endverbatim */ -#include +#include "GKlib.h" #define OMPMINOPS 50000 diff --git a/src/error.c b/src/error.c index e2a18cf..53aa550 100644 --- a/src/error.c +++ b/src/error.c @@ -13,7 +13,7 @@ This file contains functions dealing with error reporting and termination #define _GK_ERROR_C_ /* this is needed to properly declare the gk_jub* variables as an extern function in GKlib.h */ -#include +#include "GKlib.h" /* These are the jmp_buf for the graceful exit in case of severe errors. diff --git a/src/evaluate.c b/src/evaluate.c index ce805ce..f0be5b4 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -7,7 +7,7 @@ \version\verbatim $Id: evaluate.c 13328 2012-12-31 14:57:40Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /********************************************************************** * This function computes the max accuracy score of a ranked list, diff --git a/src/fkvkselect.c b/src/fkvkselect.c index b1238ce..a2cbac4 100644 --- a/src/fkvkselect.c +++ b/src/fkvkselect.c @@ -8,7 +8,7 @@ */ -#include +#include "GKlib.h" /* Byte-wise swap two items of size SIZE. */ #define QSSWAP(a, b, stmp) do { stmp = (a); (a) = (b); (b) = stmp; } while (0) diff --git a/src/fs.c b/src/fs.c index 31e6d81..1208f52 100644 --- a/src/fs.c +++ b/src/fs.c @@ -11,7 +11,7 @@ the filesystem in a portable way. */ -#include +#include "GKlib.h" diff --git a/src/getopt.c b/src/getopt.c index 2e7e042..cd5d664 100644 --- a/src/getopt.c +++ b/src/getopt.c @@ -34,7 +34,7 @@ So, do read the documentation here. /*************************************************************************/ -#include +#include "GKlib.h" /*************************************************************************/ /* Local function prototypes */ diff --git a/src/gk_util.c b/src/gk_util.c index e1e68db..82146c0 100644 --- a/src/gk_util.c +++ b/src/gk_util.c @@ -8,7 +8,7 @@ */ -#include +#include "GKlib.h" /************************************************************************* diff --git a/src/graph.c b/src/graph.c index 1bfd0cc..4b50e47 100644 --- a/src/graph.c +++ b/src/graph.c @@ -7,7 +7,7 @@ * \version\verbatim $Id: graph.c 22415 2019-09-05 16:55:00Z karypis $ \endverbatim */ -#include +#include "GKlib.h" #define OMPMINOPS 50000 @@ -294,7 +294,7 @@ gk_graph_t *gk_graph_Read(char *filename, int format, int hasvals, fpin = gk_fopen(filename, "r", "gk_graph_Read: fpin"); if (format == GK_GRAPH_FMT_HIJV) { /* read and ignore the #rows/#cols values */ - if (fscanf(fpin, "%"SCNd64" %"SCNd64, &i, &i) != 2) + if (fscanf(fpin, "%zu %zu", &i, &i) != 2) gk_errexit(SIGERR, "Error: Failed to read the header line.\n"); } diff --git a/src/htable.c b/src/htable.c index 078e114..666708f 100644 --- a/src/htable.c +++ b/src/htable.c @@ -8,7 +8,7 @@ * */ -#include +#include "GKlib.h" /****************************************************************************** * This function creates the hash-table diff --git a/src/io.c b/src/io.c index a156483..4398485 100644 --- a/src/io.c +++ b/src/io.c @@ -16,7 +16,7 @@ This file contains various functions that perform I/O. #undef _GNU_SOURCE #endif -#include +#include "GKlib.h" /************************************************************************* * This function opens a file diff --git a/src/itemsets.c b/src/itemsets.c index beb58ae..4eb13b2 100644 --- a/src/itemsets.c +++ b/src/itemsets.c @@ -10,7 +10,7 @@ * \version\verbatim $Id: itemsets.c 19240 2015-10-22 12:41:19Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*-------------------------------------------------------------*/ /*! Data structures for use within this module */ diff --git a/src/mcore.c b/src/mcore.c index 6442e03..d76e4b1 100644 --- a/src/mcore.c +++ b/src/mcore.c @@ -8,7 +8,7 @@ \version $Id: mcore.c 13953 2013-03-30 16:20:07Z karypis $ */ -#include +#include "GKlib.h" /*************************************************************************/ diff --git a/src/memory.c b/src/memory.c index 59c6d5a..db79e55 100644 --- a/src/memory.c +++ b/src/memory.c @@ -13,7 +13,7 @@ can be used to define other memory allocation routines. */ -#include +#include "GKlib.h" /* This is for the global mcore that tracks all heap allocations */ static __thread gk_mcore_t *gkmcore = NULL; diff --git a/src/pqueue.c b/src/pqueue.c index 2fb8515..5d3bcb1 100644 --- a/src/pqueue.c +++ b/src/pqueue.c @@ -9,7 +9,7 @@ The priority queues are generated using the GK_MKPQUEUE macro. \version\verbatim $Id: pqueue.c 10711 2011-08-31 22:23:04Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ diff --git a/src/random.c b/src/random.c index 3698614..e348f05 100644 --- a/src/random.c +++ b/src/random.c @@ -8,7 +8,7 @@ \version\verbatim $Id: random.c 18796 2015-06-02 11:39:45Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ diff --git a/src/rw.c b/src/rw.c index 7cd4391..ab008e5 100644 --- a/src/rw.c +++ b/src/rw.c @@ -8,7 +8,7 @@ * \version\verbatim $Id: rw.c 11078 2011-11-12 00:20:44Z karypis $ \endverbatim */ -#include +#include "GKlib.h" /*************************************************************************/ diff --git a/src/seq.c b/src/seq.c index f267a3e..97ee2d4 100644 --- a/src/seq.c +++ b/src/seq.c @@ -8,7 +8,7 @@ */ -#include +#include "GKlib.h" diff --git a/src/sort.c b/src/sort.c index f0144ae..cb12ead 100644 --- a/src/sort.c +++ b/src/sort.c @@ -13,7 +13,7 @@ these routines where defined. \version\verbatim $Id: sort.c 21050 2017-05-25 03:53:58Z karypis $ \endverbatim */ -#include +#include "GKlib.h" diff --git a/src/string.c b/src/string.c index 562db22..ad49ed6 100644 --- a/src/string.c +++ b/src/string.c @@ -13,7 +13,7 @@ of standard functions (but with enhanced functionality). */ /************************************************************************/ -#include +#include "GKlib.h" @@ -498,7 +498,7 @@ time_t gk_str2time(char *str) time_t rtime; memset(&time, '\0', sizeof(time)); - + if (strptime(str, "%m/%d/%Y %H:%M:%S", &time) == NULL) return -1; diff --git a/src/timers.c b/src/timers.c index bb8f296..2eccabc 100644 --- a/src/timers.c +++ b/src/timers.c @@ -8,7 +8,7 @@ */ -#include +#include "GKlib.h" @@ -35,7 +35,7 @@ double gk_WClockSeconds(void) **************************************************************************/ double gk_CPUSeconds(void) { -//#ifdef __OPENMP__ +//#ifdef _OPENMP #ifdef __OPENMPXXXX__ return omp_get_wtime(); #else diff --git a/src/tokenizer.c b/src/tokenizer.c index 5efd262..2850378 100644 --- a/src/tokenizer.c +++ b/src/tokenizer.c @@ -12,7 +12,7 @@ split function. */ -#include +#include "GKlib.h" /************************************************************************