diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-11-26 07:29:42 +0100 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-11-26 07:29:42 +0100 |
commit | 8087f4336e7e2ce1b41983b6c31c91d827374e95 (patch) | |
tree | b63cf9ca6a4fb450c0bccfe1a94a2091c7c9f0fb | |
parent | 1e68e10c71c4374e13e5dad0e0c606fe6d4272d5 (diff) | |
download | embedlog-8087f4336e7e2ce1b41983b6c31c91d827374e95.tar.gz embedlog-8087f4336e7e2ce1b41983b6c31c91d827374e95.tar.bz2 embedlog-8087f4336e7e2ce1b41983b6c31c91d827374e95.zip |
Made code more c89 friendly
-rw-r--r-- | configure.ac | 48 | ||||
-rw-r--r-- | src/el-file.c | 23 | ||||
-rw-r--r-- | src/el-file.h | 2 | ||||
-rw-r--r-- | src/el-options.c | 10 | ||||
-rw-r--r-- | src/el-perror.c | 7 | ||||
-rw-r--r-- | src/el-pmemory.c | 9 | ||||
-rw-r--r-- | src/el-print.c | 5 |
7 files changed, 81 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac index c095a2a..a83e5fd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,12 +1,16 @@ AC_INIT([embedlog], [0.0.1], [michal.lyszczek@bofc.pl]) AM_INIT_AUTOMAKE([foreign subdir-objects]) +AC_LANG([C]) AC_PROG_CC +AC_PROG_CC_C89 AC_PROG_LIBTOOL AC_CONFIG_MACRO_DIRS([m4]) AC_CONFIG_FILES([Makefile src/Makefile include/Makefile tst/Makefile]) AC_CONFIG_SRCDIR([configure.ac]) AC_CONFIG_HEADERS([config.h]) +AC_CHECK_FUNCS([snprintf]) + ### # gcov coverage reporting @@ -129,6 +133,21 @@ AS_IF([test "x$enable_realtime" = "xyes"], AC_DEFINE([ENABLE_REALTIME], [1], [Enable using CLOCK_REALTIME in log]) AC_CHECK_FUNCS([clock_gettime],, AC_MSG_ERROR(not found, needed by --enable-realtime)) + + AC_EGREP_CPP(posix_199309L_supported, + [ + #define _POSIX_C_SOURCE 199309L + #include <unistd.h> + #ifdef _POSIX_VERSION + #if _POSIX_VERSION == 199309L + posix_199309L_supported + #endif + #endif + ], + [], + [ + AC_MSG_FAILURE([You need Posix 1993 to use realtime clock.]) + ]) ], #else [ @@ -155,6 +174,22 @@ AS_IF([test "x$enable_monotonic" = "xyes"], AC_DEFINE([ENABLE_MONOTONIC], [1], [Enable using CLOCK_MONOTONIC in log]) AC_CHECK_FUNCS([clock_gettime],, AC_MSG_ERROR(not found, needed by --enable-monotonic)) + + AC_EGREP_CPP(posix_199309L_supported, + [ + #define _POSIX_C_SOURCE 199309L + #include <unistd.h> + #ifdef _POSIX_VERSION + #if _POSIX_VERSION == 199309L + posix_199309L_supported + #endif + #endif + ], + [], + [ + AC_MSG_FAILURE([You need Posix 1993 to use monotonic clock.]) + ]) + ], #else [ @@ -236,7 +271,7 @@ AS_IF([test "x$enable_reentrant" = "xyes"], AC_ARG_VAR([EL_LOG_MAX], [Maximum size of log message]) -AS_IF([test "x$EL_LOG_MAX" = x], [EL_LOG_MAX="2 * 1024"]) +AS_IF([test "x$EL_LOG_MAX" = x], [EL_LOG_MAX="8192"]) AC_DEFINE_UNQUOTED([EL_LOG_MAX], [$EL_LOG_MAX], [Maximum size of log message]) @@ -260,6 +295,16 @@ AC_DEFINE_UNQUOTED([EL_MEM_LINE_SIZE], [$EL_MEM_LINE_SIZE], [Number of bytes to print in one line in el_pmemory function]) +### +# MAX_PATH +# + +AC_ARG_VAR([MAX_PATH], [Maximum size of path to log to file]) +AS_IF([test "x$MAX_PATH" = x], [MAX_PATH="4096"]) +AC_DEFINE_UNQUOTED([MAX_PATH], [$MAX_PATH], + [Maximum length of path to open when printing to file]) + + AC_OUTPUT @@ -277,4 +322,5 @@ echo "colorize output............. : $enable_colors" echo "reentrant functions......... : $enable_reentrant" echo "maximum file length......... : $EL_FLEN_MAX" echo "maximum log message......... : $EL_LOG_MAX" +echo "maximum path length......... : $MAX_PATH" echo "pmemory line size........... : $EL_MEM_LINE_SIZE" diff --git a/src/el-file.c b/src/el-file.c index 64a2574..f56d66a 100644 --- a/src/el-file.c +++ b/src/el-file.c @@ -39,18 +39,17 @@ ========================================================================== */ -#include <errno.h> -#include <limits.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> - -#include "el-options.h" #include "config.h" +#include "el-options.h" #if HAVE_UNISTD_H #include <unistd.h> #endif +#include <errno.h> +#include <limits.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> /* ========================================================================== @@ -69,6 +68,16 @@ ========================================================================== */ +#ifndef PATH_MAX +/* + * for systems that doesn't define PATH_MAX we use our MAX_PATH macro + * that is define in config.h during ./configure process + */ + +#define PATH_MAX MAX_PATH + +#endif + static char current_log[PATH_MAX + 1]; /* full path to current log file */ diff --git a/src/el-file.h b/src/el-file.h index 91f452e..42687b6 100644 --- a/src/el-file.h +++ b/src/el-file.h @@ -4,7 +4,7 @@ ========================================================================== */ #ifndef EL_FILE_H -#define EL_FILE_H +#define EL_FILE_H 1 #include "el-options.h" diff --git a/src/el-options.c b/src/el-options.c index d5e5f06..76100d4 100644 --- a/src/el-options.c +++ b/src/el-options.c @@ -37,13 +37,13 @@ #include "config.h" -#include <errno.h> -#include <string.h> - -#include "embedlog.h" +#include "el-file.h" #include "el-options.h" +#include "embedlog.h" #include "valid.h" -#include "el-file.h" + +#include <errno.h> +#include <string.h> /* ========================================================================== diff --git a/src/el-perror.c b/src/el-perror.c index 732cfd4..aa687ec 100644 --- a/src/el-perror.c +++ b/src/el-perror.c @@ -24,13 +24,14 @@ ========================================================================== */ +#include "config.h" +#include "el-options.h" +#include "embedlog.h" + #include <errno.h> #include <stdarg.h> #include <string.h> -#include "embedlog.h" -#include "el-options.h" - /* ========================================================================== _ __ diff --git a/src/el-pmemory.c b/src/el-pmemory.c index f10df04..f707235 100644 --- a/src/el-pmemory.c +++ b/src/el-pmemory.c @@ -38,14 +38,15 @@ ========================================================================== */ -#include <ctype.h> -#include <stdio.h> - +#include "config.h" #include "config-priv.h" -#include "embedlog.h" #include "el-options.h" +#include "embedlog.h" #include "valid.h" +#include <ctype.h> +#include <stdio.h> + /* ========================================================================== _ __ diff --git a/src/el-print.c b/src/el-print.c index d5a5e07..f4d3ae8 100644 --- a/src/el-print.c +++ b/src/el-print.c @@ -44,10 +44,11 @@ ========================================================================== */ -#include "embedlog.h" #include "config.h" + #include "config-priv.h" #include "el-options.h" +#include "embedlog.h" #include "valid.h" #if ENABLE_TIMESTAMP @@ -55,8 +56,8 @@ #endif #include <errno.h> -#include <stdio.h> #include <stdarg.h> +#include <stdio.h> #include <string.h> |