From 83a09137b5a25b0dffead09562ae754e6ff504fa Mon Sep 17 00:00:00 2001 From: Bensong Liu <bensl@microsoft.com> Date: Tue, 13 Apr 2021 16:29:48 +0800 Subject: [PATCH] adjust cxx version control, fix a stream.hpp bug --- log.hpp | 1 + stream.hpp | 2 +- string.hpp | 2 +- sys/rwlock.hpp | 22 ---------------------- test/Makefile | 8 ++++++-- test/src/common.cc | 2 +- test/src/header-include-all.cc | 31 +++++++++++++++++++++++++++++++ traits.hpp | 3 ++- 8 files changed, 43 insertions(+), 28 deletions(-) delete mode 100644 sys/rwlock.hpp create mode 100644 test/src/header-include-all.cc diff --git a/log.hpp b/log.hpp index 4e77cfc..7d1e142 100644 --- a/log.hpp +++ b/log.hpp @@ -9,6 +9,7 @@ #include <rlib/stdio.hpp> #include <rlib/sys/time.hpp> #include <rlib/class_decorator.hpp> +#include <rlib/require/cxx14> // currently disable this error-prone shit. #define RLIB_IMPL_ENABLE_LOGGER_FROM_FD 0 diff --git a/stream.hpp b/stream.hpp index 93f77c2..84d5e4d 100644 --- a/stream.hpp +++ b/stream.hpp @@ -18,7 +18,7 @@ namespace rlib { } inline std::ostream &null_stream() { - static std::ostream instance(impl::null_streambuf()); + static std::ostream instance(&impl::null_streambuf()); return instance; } } diff --git a/string.hpp b/string.hpp index b804952..4a43206 100644 --- a/string.hpp +++ b/string.hpp @@ -9,7 +9,7 @@ #ifndef R_STRING_HPP #define R_STRING_HPP -#include <rlib/require/cxx14> +#include <rlib/require/cxx11> #include <rlib/class_decorator.hpp> #include <rlib/sys/os.hpp> diff --git a/sys/rwlock.hpp b/sys/rwlock.hpp deleted file mode 100644 index 9a5be7b..0000000 --- a/sys/rwlock.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef R_SWLOCK_HPP -#define R_SWLOCK_HPP - -#include <pthread.h> -namespace rlib { - [[deprecated]] class RWLock - { - public: - RWLock() : isFree(true) {pthread_rwlock_init(&m_lock, NULL);} - ~RWLock() {pthread_rwlock_destroy(&m_lock);} - void acquireShared() {pthread_rwlock_rdlock(&m_lock);isFree = false;} - void acquireExclusive() {pthread_rwlock_wrlock(&m_lock);isFree = false;} - void release() {pthread_rwlock_unlock(&m_lock);isFree = true;} - // bool tryAcquireShared() {return pthread_rwlock_tryrdlock(&m_lock) == 0;} - // bool tryAcquireExclusive() {return pthread_rwlock_trywrlock(&m_lock) == 0;} - private: - pthread_rwlock_t m_lock; - bool isFree; - }; -} - -#endif diff --git a/test/Makefile b/test/Makefile index edd67cb..636adc0 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,7 @@ # Compile and run tests for rlib # CopyRight (C) 2017-2018 Recolic Keghart <root@recolic.net> # -# Tests may fail on both compile-time(traits and meta-lib) and run-time(return non-zero). +# Tests may fail on both compile-time(traits and meta-lib) and run-time(return non-zero) error. # Use `make <module>` to build and run a module, # and `make` to build and run all modules. # @@ -40,7 +40,7 @@ endif POSTFIX=$(STD)_$(CXX) -all: string common +all: string common header-include-all common: $(CXX) $(CXXFLAGS) src/common.cc $(CXXFLAGS) -o src/common_$(POSTFIX).out @@ -50,6 +50,10 @@ string: $(CXX) $(CXXFLAGS) src/string.cc $(CXXFLAGS) -o src/string_$(POSTFIX).out src/string_$(POSTFIX).out +header-include-all: + $(CXX) $(CXXFLAGS) src/header-include-all.cc $(CXXFLAGS) -o src/header-include-all_$(POSTFIX).out + src/header-include-all_$(POSTFIX).out + clean: rm -f src/*.out diff --git a/test/src/common.cc b/test/src/common.cc index c17ab4f..183c976 100644 --- a/test/src/common.cc +++ b/test/src/common.cc @@ -10,7 +10,7 @@ void test_f(int); class test_c { public: - auto operator()(int a) { + int operator()(int a) { return a; } }; diff --git a/test/src/header-include-all.cc b/test/src/header-include-all.cc new file mode 100644 index 0000000..5c11f18 --- /dev/null +++ b/test/src/header-include-all.cc @@ -0,0 +1,31 @@ +#include <rlib/sys/os.hpp> + +#include <rlib/sys/fd.hpp> +#include <rlib/sys/time.hpp> +#include <rlib/sys/sio.hpp> + +#if RLIB_OS_ID == OS_LINUX +#include <rlib/sys/unix_handy.hpp> +#endif + +#if RLIB_CXX_STD >= 2017 +#include <rlib/functional.hpp> +#endif + +#if RLIB_CXX_STD >= 2014 +#include <rlib/meta.hpp> +#include <rlib/opt.hpp> +#include <rlib/log.hpp> +#include <rlib/pool.hpp> +#include <rlib/string.hpp> +#endif + +#include <rlib/class_decorator.hpp> +#include <rlib/macro.hpp> +#include <rlib/scope_guard.hpp> +#include <rlib/stdio.hpp> +#include <rlib/stream.hpp> +#include <rlib/terminal.hpp> +#include <rlib/traits.hpp> + +int main() { return 0; } diff --git a/traits.hpp b/traits.hpp index f15fba3..8b14670 100644 --- a/traits.hpp +++ b/traits.hpp @@ -1,6 +1,7 @@ #ifndef RLIB_TRAITS_HPP #define RLIB_TRAITS_HPP +#include <rlib/require/cxx11> #include <type_traits> namespace rlib{ @@ -31,7 +32,7 @@ namespace rlib{ namespace rlib { template<typename T> - struct is_callable : public std::bool_constant<impl::is_callable_helper<T>::real_value> { + struct is_callable : public std::integral_constant<bool, impl::is_callable_helper<T>::real_value> { }; } -- GitLab