diff options
author | Michał Łyszczek <michal.lyszczek@gmail.com> | 2017-05-23 01:44:10 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@gmail.com> | 2017-05-23 01:44:10 +0200 |
commit | ea57d6255e056df9441302c5e23acd7684e95d84 (patch) | |
tree | 5599c4085c16c758543239ed0e1576bea7c306ce | |
parent | 5d30fec547e1160a4404e515cacedc6cb254e7b5 (diff) | |
download | memperf-ea57d6255e056df9441302c5e23acd7684e95d84.tar.gz memperf-ea57d6255e056df9441302c5e23acd7684e95d84.tar.bz2 memperf-ea57d6255e056df9441302c5e23acd7684e95d84.zip |
Little refactoring
-rw-r--r-- | src/bench.c | 2 | ||||
-rw-r--r-- | src/opts.c | 24 | ||||
-rw-r--r-- | src/tests.c | 12 | ||||
-rw-r--r-- | src/utils.c | 20 | ||||
-rw-r--r-- | src/version.h | 13 |
5 files changed, 34 insertions, 37 deletions
diff --git a/src/bench.c b/src/bench.c index 4b1e3be..55eb3f0 100644 --- a/src/bench.c +++ b/src/bench.c @@ -85,7 +85,7 @@ static void bench_report /* ========================================================================== - performs benchmark on pointers dst and src. dst and src can be heap or + performs benchmark on pointers dst and src. dst and src can be heap or stack allocated. ========================================================================== */ @@ -3,6 +3,7 @@ Author: Michał Łyszczek <michal.lyszczek@bofc.pl> ========================================================================== */ + /* ==== Include files ======================================================= */ @@ -13,13 +14,19 @@ #include <stdlib.h> #include <string.h> +#include "config.h" #include "utils.h" -#include "version.h" /* ==== Private macros ====================================================== */ +/* ========================================================================== + Macro checks is option being parsed has argument, if not, forces + function to return with code -2 + ========================================================================== */ + + #define HAS_OPTARG() \ do \ { \ @@ -63,8 +70,8 @@ static void opts_reset(void) /* ========================================================================== - returns argument from 'argv'. If passed 'argv' doesn't hold valid argument - -1 will be returned. + returns argument from 'argv'. If passed 'argv' doesn't hold valid + argument -1 will be returned. ========================================================================== */ @@ -123,14 +130,15 @@ static void opts_print_help(void) ); } + /* ==== Public functions ==================================================== */ /* ========================================================================== - resets global 'opts' object with default values, and parses input options - overwritting default settings. If help (-h) or version (-v) option is found - anywhere in the argv, program prints what first was found and returns with - code 1. + resets global 'opts' object with default values, and parses input + options overwritting default settings. If help (-h) or version (-v) + option is found anywhere in the argv, program prints what first was + found and returns with code 1. returns: 1 -h or -v was passed @@ -188,7 +196,7 @@ int opts_parse switch (opt) { case 'v': - printf(APP_VERSION "\n"); + printf(PACKAGE_STRING "\n"); return 1; case 'h': diff --git a/src/tests.c b/src/tests.c index 7eed501..d72d4ae 100644 --- a/src/tests.c +++ b/src/tests.c @@ -56,8 +56,8 @@ static char *sdup /* ========================================================================== - returns heap allocated copy of 's' with maximum size of 'l'. Returned string - will be always null terminated. + returns heap allocated copy of 's' with maximum size of 'l'. Returned + string will be always null terminated. ========================================================================== */ @@ -87,9 +87,10 @@ static char *sndup /* ========================================================================== - converts option string into argc,argv pair. ie, "-a -b -c10 -darg" will be - converted into array of 5 strings (as first argument is always program name, - here we simulate it by always putting "memperf" as first option): + converts option string into argc,argv pair. ie, "-a -b -c10 -darg" will + be converted into array of 5 strings (as first argument is always + program name, here we simulate it by always putting "memperf" as first + option): argc == 5 argv = @@ -219,6 +220,7 @@ static void opts_free /* ==== Tests functions ===================================================== */ + /* ==== utils.c tests ======================================================= */ diff --git a/src/utils.c b/src/utils.c index 9c1fc82..d1a5cc0 100644 --- a/src/utils.c +++ b/src/utils.c @@ -21,9 +21,9 @@ /* ========================================================================== - function returns timestamp in 'tm' location depending on the clock set in - opts.h. If clock option set doesn't match passed 'tm' object, (like clock_t - for CLK_CLOCK) behaviour is undefinied + function returns timestamp in 'tm' location depending on the clock set + in opts.h. If clock option set doesn't match passed 'tm' object, (like + clock_t for CLK_CLOCK) behaviour is undefinied ========================================================================== */ @@ -58,7 +58,7 @@ void ts /* ========================================================================== - creates new object for timestamp, returned pointer should be passed to + creates new object for timestamp, returned pointer should be passed to free() when it is no longer needed ========================================================================== */ @@ -85,7 +85,7 @@ void *ts_new(void) /* ========================================================================== - sets pointer to zero value. Check ts() for more information regarding + sets pointer to zero value. Check ts() for more information regarding undefinied behaviour that may occur ========================================================================== */ @@ -115,9 +115,9 @@ void ts_reset /* ========================================================================== - function adds difference between 'finish' and 'start' to 'tm'. Simply put - it is tm += finish - start; Check ts() for more information regarding - undefinied behaviour that may occur + function adds difference between 'finish' and 'start' to 'tm'. Simply + put it is tm += finish - start; Check ts() for more information + regarding undefinied behaviour that may occur ========================================================================== */ @@ -185,8 +185,8 @@ void ts_add_diff /* ========================================================================== - function converts 'tm' object into microseconds. Check ts() for more - information regarding undefinied behaviour that may occur + function converts 'tm' object into microseconds. Check ts() for more + information regarding undefinied behaviour that may occur ========================================================================== */ diff --git a/src/version.h b/src/version.h deleted file mode 100644 index 39afad5..0000000 --- a/src/version.h +++ /dev/null @@ -1,13 +0,0 @@ -/* ========================================================================== - Licensed under BSD 2clause license. See LICENSE file for more information - Author: Michał Łyszczek <michal.lyszczek@bofc.pl> - ========================================================================== */ - -#ifndef MEMPERF_VERSION_H -#define MEMPERF_VERSION_H 1 - -#include "config.h" - -#define APP_VERSION "memperf version v"VERSION - -#endif |