aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2018-10-12 12:38:57 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2018-10-12 15:40:36 +0200
commitd2a0b2ee2969b2f3cf0b5f6d9bf1e0f7362e11f1 (patch)
tree912739a9daaf1ed36c0420c7352ce549e1d80cb8
parent47324d02968318fd397c64d4ead00ee6780b13af (diff)
downloadembedlog-d2a0b2ee2969b2f3cf0b5f6d9bf1e0f7362e11f1.tar.gz
embedlog-d2a0b2ee2969b2f3cf0b5f6d9bf1e0f7362e11f1.tar.bz2
embedlog-d2a0b2ee2969b2f3cf0b5f6d9bf1e0f7362e11f1.zip
clean that mess with feature test macro once and for allfeature-test-macro-mess-fix
-rw-r--r--configure.ac17
-rw-r--r--src/el-decode-number.c4
-rw-r--r--src/el-encode-number.c4
-rw-r--r--src/el-file.c14
-rw-r--r--src/el-options.c4
-rw-r--r--src/el-pbinary.c4
-rw-r--r--src/el-perror.c4
-rw-r--r--src/el-pmemory.c4
-rw-r--r--src/el-print.c11
-rw-r--r--src/el-private.h113
-rw-r--r--src/el-puts.c4
-rw-r--r--src/el-syslog.c4
-rw-r--r--src/el-ts.c48
-rw-r--r--src/el-tty.c4
-rw-r--r--src/snprintf.c4
-rw-r--r--tst/test-el-file.c2
-rw-r--r--tst/test-el-options.c2
-rw-r--r--tst/test-el-pbinary.c3
-rw-r--r--tst/test-el-perror.c2
-rw-r--r--tst/test-el-pmemory.c2
-rw-r--r--tst/test-el-print.c4
21 files changed, 120 insertions, 138 deletions
diff --git a/configure.ac b/configure.ac
index 394aae2..70d67c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,23 +17,6 @@ AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])
-###
-# solaris is weird, if _XOPEN_SOURCE is set to 500, you CANNOT compile
-# code with anything than c89, yes c99 compiler will error out, so
-# for solaris system we force -std=c89 flag
-#
-# TODO: determin flag name for c89 standard for other non-gnu compatible
-# compilers, for now this must be enough
-#
-
-
-case ${host_os} in
- solaris*)
- CFLAGS="-std=c89 ${CFLAGS}"
- ;;
-esac
-
-
AC_SEARCH_LIBS([pow], [m])
###
diff --git a/src/el-decode-number.c b/src/el-decode-number.c
index 5a8be82..69a66ed 100644
--- a/src/el-decode-number.c
+++ b/src/el-decode-number.c
@@ -11,10 +11,10 @@
========================================================================== */
-#include <limits.h>
-
#include "el-private.h"
+#include <limits.h>
+
/* ==========================================================================
__ __ _
diff --git a/src/el-encode-number.c b/src/el-encode-number.c
index 82a81ac..8831598 100644
--- a/src/el-encode-number.c
+++ b/src/el-encode-number.c
@@ -11,10 +11,10 @@
========================================================================== */
-#include <limits.h>
-
#include "el-private.h"
+#include <limits.h>
+
/* ==========================================================================
__ __ _
diff --git a/src/el-file.c b/src/el-file.c
index 94fca8d..2b44954 100644
--- a/src/el-file.c
+++ b/src/el-file.c
@@ -38,20 +38,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#if HAVE_FSYNC && HAVE_FILENO
-# define _POSIX_C_SOURCE 1
-#endif
-
-#if !NEED_SNPRINTF_ONLY && !PREFER_PORTABLE_SNPRINTF
- /* if portable snprintf is not used, define _XOPEN_SOURCE to include
- * snprintf() and vsnprintf() functions
- */
-# define _XOPEN_SOURCE 500
-#endif
#include "el-private.h"
diff --git a/src/el-options.c b/src/el-options.c
index 1d83646..9b72711 100644
--- a/src/el-options.c
+++ b/src/el-options.c
@@ -35,10 +35,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "el-private.h"
#include <errno.h>
diff --git a/src/el-pbinary.c b/src/el-pbinary.c
index ae636ca..607db7c 100644
--- a/src/el-pbinary.c
+++ b/src/el-pbinary.c
@@ -33,10 +33,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "el-private.h"
#include <errno.h>
diff --git a/src/el-perror.c b/src/el-perror.c
index 23fb3e3..09943ab 100644
--- a/src/el-perror.c
+++ b/src/el-perror.c
@@ -24,10 +24,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "el-private.h"
#include <errno.h>
diff --git a/src/el-pmemory.c b/src/el-pmemory.c
index a8cab30..a2130b8 100644
--- a/src/el-pmemory.c
+++ b/src/el-pmemory.c
@@ -38,10 +38,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "el-private.h"
#include <ctype.h>
diff --git a/src/el-print.c b/src/el-print.c
index 635a7f5..566524e 100644
--- a/src/el-print.c
+++ b/src/el-print.c
@@ -44,17 +44,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if !NEED_SNPRINTF_ONLY && !PREFER_PORTABLE_SNPRINTF
- /* if portable snprintf is not used, define _XOPEN_SOURCE to include
- * snprintf() and vsnprintf() functions
- */
-# define _XOPEN_SOURCE 500
-#endif
-
#include "el-private.h"
#include <errno.h>
diff --git a/src/el-private.h b/src/el-private.h
index bf06f43..0b03e4f 100644
--- a/src/el-private.h
+++ b/src/el-private.h
@@ -3,8 +3,17 @@
Author: Michał Łyszczek <michal.lyszczek@bofc.pl>
========================================================================== */
-/*
- * this file contains stuff internal to the library
+/* this file contains stuff internal to the library
+ *
+ * !!!!!!! FUCKING IMPORTANT NOTICE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!
+ * !!! MAKE SURE THIS FILE IS INCLUDED FIRST IN ALL SOURCE AND TEST FILES
+ * !!! OR THINGS WILL GO WEIRD.
+ * !!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ *
+ * it's becuase of feature test macros that are defined here and they must
+ * be defined before any system files are included
*/
#ifndef EL_PRIVATE_H
@@ -12,11 +21,11 @@
/* ==========================================================================
- _ __ __ ____ _ __
- (_)____ _____ / /__ __ ____/ /___ / __/(_)/ /___ _____
- / // __ \ / ___// // / / // __ // _ \ / /_ / // // _ \ / ___/
- / // / / // /__ / // /_/ // /_/ // __/ / __// // // __/(__ )
- /_//_/ /_/ \___//_/ \__,_/ \__,_/ \___/ /_/ /_//_/ \___//____/
+ ____ __ __ __
+ / __/___ ____ _ / /_ __ __ _____ ___ / /_ ___ _____ / /_ _____
+ / /_ / _ \ / __ `// __// / / // ___// _ \ / __// _ \ / ___// __// ___/
+ / __// __// /_/ // /_ / /_/ // / / __/ / /_ / __/(__ )/ /_ (__ )
+ /_/ \___/ \__,_/ \__/ \__,_//_/ \___/ \__/ \___//____/ \__//____/
========================================================================== */
@@ -35,8 +44,98 @@
int snprintf(char *str, size_t str_m, const char *fmt, ...);
int vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap);
+#else
+ /* if portable snprintf is not used, define posix source to include
+ * snprintf() and vsnprintf() functions
+ */
+# define _POSIX_C_SOURCE 200112L
+#endif
+
+/* features definitions, order must be from higher posix standard to
+ * lowest one to avoid redefinitions
+ */
+
+/* clock_gettime() was defined in 199303 issue of posix
+ * but some systems need posix = 200112 for the feature
+ */
+#if ENABLE_TIMESTAMP
+# if ENABLE_REALTIME || ENABLE_MONOTONIC
+# if __FreeBSD__ || __QNX__ || __QNXNTO__
+# ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+# endif
+# endif
+# endif
+#endif
+
+/* gmtime_r() was defined in posix issue 1, but these systems
+ * define them in issue 199506
+ */
+#if ENABLE_TIMESTAMP
+# if __DragonFly__
+# ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 199506L
+# endif
+# endif
+#endif
+
+/* clock_gettime() was defined in 199303 issue of posix
+ */
+#if ENABLE_TIMESTAMP
+# if ENABLE_REALTIME || ENABLE_MONOTONIC
+# ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 199309L
+# endif
+# endif
+#endif
+
+/* gmtime_r() was defined in posix issue 1
+ */
+#if ENABLE_TIMESTAMP
+# ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 1
+# endif
+#endif
+
+/* both fsync() and fileno() functions were defined in
+ * posix issue 1
+ */
+#if ENABLE_OUT_FILE
+# if HAVE_FSYNC && HAVE_FILENO
+# ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 1
+# endif
+# endif
+#endif
+
+/* ONLCR flag on FreeBSD needs __BSD_VISIBLE defined and solaris
+ * need __EXTENSIONS__
+ */
+#if ENABLE_OUT_TTY
+# if HAVE_TERMIOS_H
+# if __FreeBSD__
+# ifndef __BSD_VISIBLE
+# define __BSD_VISIBLE 1
+# endif
+# elif sun || __sun
+# ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+# endif
+# endif
+# endif
#endif
+
+/* ==========================================================================
+ _ __ __ ____ _ __
+ (_)____ _____ / /__ __ ____/ /___ / __/(_)/ /___ _____
+ / // __ \ / ___// // / / // __ // _ \ / /_ / // // _ \ / ___/
+ / // / / // /__ / // /_/ // /_/ // __/ / __// // // __/(__ )
+ /_//_/ /_/ \___//_/ \__,_/ \__,_/ \___/ /_/ /_//_/ \___//____/
+
+ ========================================================================== */
+
+
#include "embedlog.h"
#include "valid.h"
diff --git a/src/el-puts.c b/src/el-puts.c
index 26c4ceb..8b52c96 100644
--- a/src/el-puts.c
+++ b/src/el-puts.c
@@ -31,10 +31,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "el-private.h"
#include <errno.h>
diff --git a/src/el-syslog.c b/src/el-syslog.c
index 259beb1..1b4bcc9 100644
--- a/src/el-syslog.c
+++ b/src/el-syslog.c
@@ -14,10 +14,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include "el-private.h"
#include <errno.h>
diff --git a/src/el-ts.c b/src/el-ts.c
index c07ec3a..efb3005 100644
--- a/src/el-ts.c
+++ b/src/el-ts.c
@@ -13,54 +13,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* features definitions, order must from higher posix standard to
- * lowest one to avoid redefinitions
- */
-
-/* clock_gettime() was defined in 199303 issue of posix
- * but some systems need posix = 200112 for the feature
- */
-#if ENABLE_TIMESTAMP
-# if ENABLE_REALTIME || ENABLE_MONOTONIC
-# if __FreeBSD__ || __QNX__ || __QNXNTO__
-# define _POSIX_C_SOURCE 200112L
-# endif
-# endif
-#endif
-
-/* gmtime_r() was defined in posix issue 1, but these systems
- * define them in issue 199506
- */
-#if ENABLE_TIMESTAMP
-# if __DragonFly__
-# ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 199506L
-# endif
-# endif
-#endif
-
-/* clock_gettime() was defined in 199303 issue of posix
- */
-#if ENABLE_TIMESTAMP
-# if ENABLE_REALTIME || ENABLE_MONOTONIC
-# ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 199309L
-# endif
-# endif
-#endif
-
-/* gmtime_r() was defined in posix issue 1
- */
-#if ENABLE_TIMESTAMP
-# ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 1
-# endif
-#endif
-
#include "el-private.h"
#include <time.h>
diff --git a/src/el-tty.c b/src/el-tty.c
index 91cdcc1..66bfa97 100644
--- a/src/el-tty.c
+++ b/src/el-tty.c
@@ -14,10 +14,6 @@
========================================================================== */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include "el-private.h"
#include <errno.h>
diff --git a/src/snprintf.c b/src/snprintf.c
index 3c6d079..1d349fb 100644
--- a/src/snprintf.c
+++ b/src/snprintf.c
@@ -278,9 +278,7 @@
* implementation, there may be other incompatibilities.
*/
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "el-private.h"
/* ============================================= */
/* NO USER SERVICABLE PARTS FOLLOWING THIS POINT */
diff --git a/tst/test-el-file.c b/tst/test-el-file.c
index 4a33860..5c4b7fd 100644
--- a/tst/test-el-file.c
+++ b/tst/test-el-file.c
@@ -14,7 +14,7 @@
========================================================================== */
-#include "config.h"
+#include "el-private.h"
#include <dirent.h>
#include <errno.h>
diff --git a/tst/test-el-options.c b/tst/test-el-options.c
index 153e699..767b58f 100644
--- a/tst/test-el-options.c
+++ b/tst/test-el-options.c
@@ -12,11 +12,11 @@
========================================================================== */
+#include "el-private.h"
#include <string.h>
#include <errno.h>
-#include "el-private.h"
#include "mtest.h"
#include "test-group-list.h"
#include "config.h"
diff --git a/tst/test-el-pbinary.c b/tst/test-el-pbinary.c
index f834dfe..b82d84b 100644
--- a/tst/test-el-pbinary.c
+++ b/tst/test-el-pbinary.c
@@ -14,7 +14,7 @@
========================================================================== */
-#include "config.h"
+#include "el-private.h"
#include <ctype.h>
#include <errno.h>
@@ -31,7 +31,6 @@
#include <stdlib.h>
#include "mtest.h"
-#include "el-private.h"
#if ENABLE_BINARY_LOGS
diff --git a/tst/test-el-perror.c b/tst/test-el-perror.c
index 9741ded..691b6e5 100644
--- a/tst/test-el-perror.c
+++ b/tst/test-el-perror.c
@@ -14,6 +14,8 @@
========================================================================== */
+#include "el-private.h"
+
#include <errno.h>
#include <string.h>
diff --git a/tst/test-el-pmemory.c b/tst/test-el-pmemory.c
index da1c17e..9ea7203 100644
--- a/tst/test-el-pmemory.c
+++ b/tst/test-el-pmemory.c
@@ -14,6 +14,8 @@
========================================================================== */
+#include "el-private.h"
+
#include <errno.h>
#include <string.h>
diff --git a/tst/test-el-print.c b/tst/test-el-print.c
index 3c98572..84f97ba 100644
--- a/tst/test-el-print.c
+++ b/tst/test-el-print.c
@@ -14,6 +14,8 @@
========================================================================== */
+#include "el-private.h"
+
#include <rb.h>
#include <string.h>
#include <ctype.h>
@@ -26,8 +28,6 @@
#include "stdlib.h"
#include "embedlog.h"
-#include "el-private.h"
-
/* ==========================================================================
_ __ __