diff options
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | libdimension/bench/prtree.c | 6 | ||||
-rw-r--r-- | libdimension/dimension-internal.h | 3 | ||||
-rw-r--r-- | libdimension/error.c | 10 | ||||
-rw-r--r-- | libdimension/platform.c | 4 | ||||
-rw-r--r-- | libdimension/tests/error.c | 4 | ||||
-rw-r--r-- | libdimension/tests/prtree.c | 8 | ||||
-rw-r--r-- | libdimension/tests/warning-as-error.c | 4 | ||||
-rw-r--r-- | libdimension/tests/warning.c | 4 |
9 files changed, 43 insertions, 16 deletions
diff --git a/configure.ac b/configure.ac index 1141ac8..3942984 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -dnl Copyright (C) 2009-2012 Tavian Barnes <tavianator@tavianator.com> +dnl Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> dnl dnl This file is part of The Dimension Build Suite. dnl @@ -110,6 +110,20 @@ dnl Platform feature tests m4_include(ax_pthread.m4) AX_PTHREAD([], [AC_MSG_ERROR([pthread support not detected])]) +AC_MSG_CHECKING([for strerror_r]) +AC_RUN_IFELSE([ + AC_LANG_PROGRAM( + [ #include <string.h> + #include <errno.h> ], + [ char buf@<:@256@:>@; + return strerror_r(ENOMEM, buf, 256); ] + )], + [AC_DEFINE([DMNSN_STRERROR_R], [1]) + AC_MSG_RESULT([yes])], + [AC_DEFINE([DMNSN_STRERROR_R], [0]) + AC_MSG_RESULT([no])] +) + AC_MSG_CHECKING([for sys_errlist]) AC_LINK_IFELSE([ AC_LANG_PROGRAM( diff --git a/libdimension/bench/prtree.c b/libdimension/bench/prtree.c index 9c1a5b1..11d831b 100644 --- a/libdimension/bench/prtree.c +++ b/libdimension/bench/prtree.c @@ -17,11 +17,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * *************************************************************************/ -#include "../bvh.c" -#include "../prtree.c" +#include "../platform.c" #include "../threads.c" #include "../future.c" -#include "../platform.c" +#include "../bvh.c" +#include "../prtree.c" #include <sandglass.h> #include <stdlib.h> diff --git a/libdimension/dimension-internal.h b/libdimension/dimension-internal.h index 3f71fb1..99345c0 100644 --- a/libdimension/dimension-internal.h +++ b/libdimension/dimension-internal.h @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2012 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Library. * * * @@ -27,7 +27,6 @@ #ifndef DIMENSION_INTERNAL_H #define DIMENSION_INTERNAL_H -#define _GNU_SOURCE #include "dimension.h" #include "refcount-internal.h" #include "compiler-internal.h" diff --git a/libdimension/error.c b/libdimension/error.c index 371c7cd..1facc72 100644 --- a/libdimension/error.c +++ b/libdimension/error.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Library. * * * @@ -25,6 +25,7 @@ #include "dimension-internal.h" #include <pthread.h> +#include <string.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> @@ -95,7 +96,12 @@ dmnsn_report_error(bool die, const char *func, const char *file, /* Print the value of errno */ if (err != 0) { fprintf(stderr, "Last error: %d", err); -#if DMNSN_SYS_ERRLIST +#if DMNSN_STRERROR_R + char errbuf[256]; + if (strerror_r(err, errbuf, 256) == 0) { + fprintf(stderr, " (%s)", errbuf); + } +#elif DMNSN_SYS_ERRLIST if (err >= 0 && err < sys_nerr) { fprintf(stderr, " (%s)", sys_errlist[err]); } diff --git a/libdimension/platform.c b/libdimension/platform.c index a27343d..d9d0e98 100644 --- a/libdimension/platform.c +++ b/libdimension/platform.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Library. * * * @@ -23,7 +23,9 @@ * Platform abstractions. */ +#define _GNU_SOURCE #include "dimension-internal.h" + #if HAVE_UNISTD_H #include <unistd.h> #endif diff --git a/libdimension/tests/error.c b/libdimension/tests/error.c index 5a4d7fd..f4ffcee 100644 --- a/libdimension/tests/error.c +++ b/libdimension/tests/error.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Test Suite. * * * @@ -21,10 +21,12 @@ #include "dimension.h" #include <stdlib.h> +#include <errno.h> int main(void) { + errno = ENOMEM; dmnsn_error("This error is expected."); return EXIT_SUCCESS; } diff --git a/libdimension/tests/prtree.c b/libdimension/tests/prtree.c index 2642f48..b2a2be6 100644 --- a/libdimension/tests/prtree.c +++ b/libdimension/tests/prtree.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2010-2012 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Test Suite. * * * @@ -21,11 +21,11 @@ * Basic tests of PR-trees */ -#include "../bvh.c" -#include "../prtree.c" +#include "../platform.c" #include "../threads.c" #include "../future.c" -#include "../platform.c" +#include "../bvh.c" +#include "../prtree.c" #include <stdio.h> #include <stdlib.h> diff --git a/libdimension/tests/warning-as-error.c b/libdimension/tests/warning-as-error.c index ce274d3..dfc08d6 100644 --- a/libdimension/tests/warning-as-error.c +++ b/libdimension/tests/warning-as-error.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> * + * Copyright (C) 2009-2014 Tavian Barnes <tavianator@gmail.com> * * * * This file is part of The Dimension Test Suite. * * * @@ -21,11 +21,13 @@ #include "dimension.h" #include <stdlib.h> +#include <errno.h> int main(void) { dmnsn_die_on_warnings(true); + errno = ENOMEM; dmnsn_warning("This warning is expected."); return EXIT_SUCCESS; } diff --git a/libdimension/tests/warning.c b/libdimension/tests/warning.c index aecedd5..4e5dd75 100644 --- a/libdimension/tests/warning.c +++ b/libdimension/tests/warning.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> * * * * This file is part of The Dimension Test Suite. * * * @@ -21,10 +21,12 @@ #include "dimension.h" #include <stdlib.h> +#include <errno.h> int main(void) { + errno = ENOMEM; dmnsn_warning("This warning is expected."); return EXIT_SUCCESS; } |