diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fa48dd967..533ef5a2d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,8 @@ check_function_exists( setenv HAVE_POSIX_SETENV ) check_function_exists( symlink ERT_HAVE_SYMLINK ) check_function_exists( timegm HAVE_TIMEGM ) check_function_exists( usleep HAVE__USLEEP ) +check_function_exists( unlink HAVE_POSIX_UNLINK ) +check_function_exists( _unlink HAVE_WINDOWS_UNLINK ) check_symbol_exists(_tzname time.h HAVE_WINDOWS_TZNAME) check_symbol_exists( tzname time.h HAVE_TZNAME) @@ -221,7 +223,6 @@ check_symbol_exists( tzname time.h HAVE_TZNAME) check_include_file(execinfo.h HAVE_EXECINFO) check_include_file(getopt.h ERT_HAVE_GETOPT) check_include_file(unistd.h ERT_HAVE_UNISTD) -check_include_file(io.h ERT_HAVE_IO) check_type_size(time_t SIZE_OF_TIME_T) if (${SIZE_OF_TIME_T} EQUAL 8) diff --git a/lib/build_config.h.in b/lib/build_config.h.in index 14bdc174b5..0e9b1ff847 100644 --- a/lib/build_config.h.in +++ b/lib/build_config.h.in @@ -28,6 +28,8 @@ #cmakedefine HAVE_CHMOD #cmakedefine HAVE_MODE_T #cmakedefine HAVE_CXX_SHARED_PTR +#cmakedefine HAVE_POSIX_UNLINK +#cmakedefine HAVE_WINDOWS_UNLINK #cmakedefine HAVE_WINDOWS_GET_TEMP_PATH diff --git a/lib/include/ert/util/util_unlink.h b/lib/include/ert/util/util_unlink.h index 6023aa8990..646e93aebc 100644 --- a/lib/include/ert/util/util_unlink.h +++ b/lib/include/ert/util/util_unlink.h @@ -20,11 +20,17 @@ #ifndef ERT_UTIL_UNLINK_H #define ERT_UTIL_UNLINK_H +#include "ert/util/build_config.h" + #ifdef __cplusplus extern "C" { #endif - + +#if defined(HAVE_POSIX_UNLINK) || defined(HAVE_WINDOWS_UNLINK) + int util_unlink(const char * filename); + +#endif #ifdef __cplusplus } diff --git a/lib/util/hash.c b/lib/util/hash.c index 0237da18f1..c8a9de62bd 100644 --- a/lib/util/hash.c +++ b/lib/util/hash.c @@ -87,10 +87,6 @@ typedef struct hash_sort_node { /* locking */ /*****************************************************************/ #ifdef HAVE_PTHREAD -static void __hash_deadlock_abort(hash_type * hash) { - util_abort("%s: A deadlock condition has been detected in the hash routine - and the program will abort.\n", __func__); -} - static void __hash_rdlock(hash_type * hash) { int lock_error = pthread_rwlock_tryrdlock( &hash->rwlock ); diff --git a/lib/util/util_unlink.c b/lib/util/util_unlink.c index 5faebc82bc..1539065546 100644 --- a/lib/util/util_unlink.c +++ b/lib/util/util_unlink.c @@ -16,22 +16,22 @@ for more details. */ +#include "ert/util/build_config.h" -#if defined(ERT_HAVE_UNISTD) - #include -#elif defined(ERT_HAVE_IO) - #include -#else - #include -#endif +#if defined(HAVE_WINDOWS_UNLINK) + +#include int util_unlink(const char * filename) { -#if defined(ERT_HAVE_UNISTD) - return unlink(filename); -#elif defined(ERT_HAVE_IO) return _unlink(filename); -#else - util_abort("%s: No unlink functionality available.\n", __func__); - return -1; -#endif } + +#elif defined(HAVE_POSIX_UNLINK) + +#include + +int util_unlink(const char * filename) { + return unlink(filename); +} + +#endif