From 8d7a9557b7dff2421a694148970d162125e7c0d3 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 23 Sep 2010 17:31:07 +0000 Subject: [PATCH] visibility-decoration. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@114671 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/sstream | 8 ++++---- include/stack | 40 +++++++++++++++++++++++++++--------- include/streambuf | 2 +- include/string | 16 ++++++++++----- include/strstream | 35 +++++++++++++++++++++++++++---- include/system_error | 25 ++++++++++++++-------- include/thread | 49 ++++++++++++++++++++++++++++++-------------- 7 files changed, 127 insertions(+), 48 deletions(-) diff --git a/include/sstream b/include/sstream index e1b69ca4..70237f53 100644 --- a/include/sstream +++ b/include/sstream @@ -182,7 +182,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // basic_stringbuf template -class basic_stringbuf +class _LIBCPP_VISIBLE basic_stringbuf : public basic_streambuf<_CharT, _Traits> { public: @@ -525,7 +525,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp, // basic_istringstream template -class basic_istringstream +class _LIBCPP_VISIBLE basic_istringstream : public basic_istream<_CharT, _Traits> { public: @@ -644,7 +644,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) // basic_ostringstream template -class basic_ostringstream +class _LIBCPP_VISIBLE basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: @@ -763,7 +763,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) // basic_stringstream template -class basic_stringstream +class _LIBCPP_VISIBLE basic_stringstream : public basic_iostream<_CharT, _Traits> { public: diff --git a/include/stack b/include/stack index 77373795..3f428054 100644 --- a/include/stack +++ b/include/stack @@ -92,7 +92,7 @@ bool operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); template > -class stack +class _LIBCPP_VISIBLE stack { public: typedef _Container container_type; @@ -105,56 +105,76 @@ protected: container_type c; public: + _LIBCPP_INLINE_VISIBILITY stack() : c() {} + _LIBCPP_INLINE_VISIBILITY explicit stack(const container_type& __c) : c(__c) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit stack(container_type&& __c) : c(_STD::move(__c)) {} + _LIBCPP_INLINE_VISIBILITY stack(stack&& __s) : c(_STD::move(__s.c)) {} + _LIBCPP_INLINE_VISIBILITY stack& operator=(stack&& __s) {c = _STD::move(__s.c); return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template + _LIBCPP_INLINE_VISIBILITY explicit stack(const _Alloc& __a, typename enable_if::value>::type* = 0) : c(__a) {} template + _LIBCPP_INLINE_VISIBILITY stack(const container_type& __c, const _Alloc& __a, typename enable_if::value>::type* = 0) : c(__c, __a) {} template + _LIBCPP_INLINE_VISIBILITY stack(const stack& __s, const _Alloc& __a, typename enable_if::value>::type* = 0) : c(__s.c, __a) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template + _LIBCPP_INLINE_VISIBILITY stack(container_type&& __c, const _Alloc& __a, typename enable_if::value>::type* = 0) : c(_STD::move(__c), __a) {} template + _LIBCPP_INLINE_VISIBILITY stack(stack&& __s, const _Alloc& __a, typename enable_if::value>::type* = 0) : c(_STD::move(__s.c), __a) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY bool empty() const {return c.empty();} + _LIBCPP_INLINE_VISIBILITY size_type size() const {return c.size();} + _LIBCPP_INLINE_VISIBILITY reference top() {return c.back();} + _LIBCPP_INLINE_VISIBILITY const_reference top() const {return c.back();} + _LIBCPP_INLINE_VISIBILITY void push(const value_type& __v) {c.push_back(__v);} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY void push(value_type&& __v) {c.push_back(_STD::move(__v));} #ifndef _LIBCPP_HAS_NO_VARIADICS - template void emplace(_Args&&... __args) + template + _LIBCPP_INLINE_VISIBILITY + void emplace(_Args&&... __args) {c.emplace_back(_STD::forward<_Args>(__args)...);} #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY void pop() {c.pop_back();} + _LIBCPP_INLINE_VISIBILITY void swap(stack& __s) { using _STD::swap; @@ -173,7 +193,7 @@ public: }; template -inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { @@ -181,7 +201,7 @@ operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) } template -inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { @@ -189,7 +209,7 @@ operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) } template -inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { @@ -197,7 +217,7 @@ operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) } template -inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { @@ -205,7 +225,7 @@ operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) } template -inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { @@ -213,7 +233,7 @@ operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) } template -inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { @@ -221,7 +241,7 @@ operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) } template -inline +inline _LIBCPP_INLINE_VISIBILITY void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) { @@ -229,7 +249,7 @@ swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) } template -struct uses_allocator, _Alloc> +struct _LIBCPP_VISIBLE uses_allocator, _Alloc> : public uses_allocator<_Container, _Alloc> { }; diff --git a/include/streambuf b/include/streambuf index 2746d53a..9515f3fc 100644 --- a/include/streambuf +++ b/include/streambuf @@ -117,7 +117,7 @@ protected: _LIBCPP_BEGIN_NAMESPACE_STD template -class basic_streambuf +class _LIBCPP_VISIBLE basic_streambuf { public: // types: diff --git a/include/string b/include/string index 4e6d7cd5..47aed108 100644 --- a/include/string +++ b/include/string @@ -442,7 +442,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // fpos template -class fpos +class _LIBCPP_VISIBLE fpos { private: _StateT __st_; @@ -628,7 +628,7 @@ struct _LIBCPP_VISIBLE char_traits // char_traits template <> -struct char_traits +struct _LIBCPP_VISIBLE char_traits { typedef wchar_t char_type; typedef wint_t int_type; @@ -665,7 +665,7 @@ struct char_traits #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> -struct char_traits +struct _LIBCPP_VISIBLE char_traits { typedef char16_t char_type; typedef uint_least16_t int_type; @@ -771,7 +771,7 @@ char_traits::assign(char_type* __s, size_t __n, char_type __a) } template <> -struct char_traits +struct _LIBCPP_VISIBLE char_traits { typedef char32_t char_type; typedef uint_least32_t int_type; @@ -1058,6 +1058,7 @@ public: #endif _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const_pointer __s) {return assign(__s);} basic_string& operator=(value_type __c); + _LIBCPP_INLINE_VISIBILITY basic_string& operator=(initializer_list __il) {return assign(__il.begin(), __il.size());} #ifndef _LIBCPP_DEBUG @@ -1092,6 +1093,7 @@ public: _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} void reserve(size_type res_arg = 0); + _LIBCPP_INLINE_VISIBILITY void shrink_to_fit() {reserve();} void clear(); _LIBCPP_INLINE_VISIBILITY bool empty() const {return size() == 0;} @@ -1127,6 +1129,7 @@ public: basic_string& >::type append(_ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_INLINE_VISIBILITY basic_string& append(initializer_list __il) {return append(__il.begin(), __il.size());} void push_back(value_type __c); @@ -1156,6 +1159,7 @@ public: basic_string& >::type assign(_ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_INLINE_VISIBILITY basic_string& assign(initializer_list __il) {return assign(__il.begin(), __il.size());} basic_string& insert(size_type __pos1, const basic_string& __str); @@ -1180,6 +1184,7 @@ public: iterator >::type insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __pos, initializer_list __il) {return insert(__pos, __il.begin(), __il.end());} @@ -1203,6 +1208,7 @@ public: basic_string& >::type replace(iterator __i1, iterator __i2, _InputIterator __j1, _InputIterator __j2); + _LIBCPP_INLINE_VISIBILITY basic_string& replace(iterator __i1, iterator __i2, initializer_list __il) {return replace(__i1, __i2, __il.begin(), __il.end());} @@ -3551,7 +3557,7 @@ template basic_string<_CharT, _Traits, _Allocator>::npos; template -struct hash > +struct _LIBCPP_VISIBLE hash > : public unary_function, size_t> { size_t diff --git a/include/strstream b/include/strstream index 5716eca8..343a494f 100644 --- a/include/strstream +++ b/include/strstream @@ -135,7 +135,7 @@ private: _LIBCPP_BEGIN_NAMESPACE_STD -class strstreambuf +class _LIBCPP_VISIBLE strstreambuf : public streambuf { public: @@ -187,20 +187,25 @@ private: void __init(char* __gnext, streamsize __n, char* __pbeg); }; -class istrstream +class _LIBCPP_VISIBLE istrstream : public istream { public: + _LIBCPP_INLINE_VISIBILITY explicit istrstream(const char* __s) : istream(&__sb_), __sb_(__s, 0) {} + _LIBCPP_INLINE_VISIBILITY explicit istrstream(char* __s) : istream(&__sb_), __sb_(__s, 0) {} + _LIBCPP_INLINE_VISIBILITY istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} + _LIBCPP_INLINE_VISIBILITY istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY istrstream(istrstream&& __rhs) : istream(_STD::move(__rhs)), __sb_(_STD::move(__rhs.__sb_)) @@ -208,6 +213,7 @@ public: istream::set_rdbuf(&__sb_); } + _LIBCPP_INLINE_VISIBILITY istrstream& operator=(istrstream&& __rhs) { istream::operator=(_STD::move(__rhs)); @@ -218,31 +224,37 @@ public: virtual ~istrstream(); + _LIBCPP_INLINE_VISIBILITY void swap(istrstream& __rhs) { istream::swap(__rhs); __sb_.swap(__rhs.__sb_); } + _LIBCPP_INLINE_VISIBILITY strstreambuf* rdbuf() const {return const_cast(&__sb_);} + _LIBCPP_INLINE_VISIBILITY char *str() {return __sb_.str();} private: strstreambuf __sb_; }; -class ostrstream +class _LIBCPP_VISIBLE ostrstream : public ostream { public: + _LIBCPP_INLINE_VISIBILITY ostrstream() : ostream(&__sb_) {} + _LIBCPP_INLINE_VISIBILITY ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0)) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY ostrstream(ostrstream&& __rhs) : ostream(_STD::move(__rhs)), __sb_(_STD::move(__rhs.__sb_)) @@ -250,6 +262,7 @@ public: ostream::set_rdbuf(&__sb_); } + _LIBCPP_INLINE_VISIBILITY ostrstream& operator=(ostrstream&& __rhs) { ostream::operator=(_STD::move(__rhs)); @@ -260,22 +273,27 @@ public: virtual ~ostrstream(); + _LIBCPP_INLINE_VISIBILITY void swap(ostrstream& __rhs) { ostream::swap(__rhs); __sb_.swap(__rhs.__sb_); } + _LIBCPP_INLINE_VISIBILITY strstreambuf* rdbuf() const {return const_cast(&__sb_);} + _LIBCPP_INLINE_VISIBILITY void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);} + _LIBCPP_INLINE_VISIBILITY char* str() {return __sb_.str();} + _LIBCPP_INLINE_VISIBILITY int pcount() const {return __sb_.pcount();} private: strstreambuf __sb_; // exposition only }; -class strstream +class _LIBCPP_VISIBLE strstream : public iostream { public: @@ -286,14 +304,17 @@ public: typedef char_traits::off_type off_type; // constructors/destructor + _LIBCPP_INLINE_VISIBILITY strstream() : iostream(&__sb_) {} + _LIBCPP_INLINE_VISIBILITY strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0)) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY strstream(strstream&& __rhs) : iostream(_STD::move(__rhs)), __sb_(_STD::move(__rhs.__sb_)) @@ -301,6 +322,7 @@ public: iostream::set_rdbuf(&__sb_); } + _LIBCPP_INLINE_VISIBILITY strstream& operator=(strstream&& __rhs) { iostream::operator=(_STD::move(__rhs)); @@ -311,6 +333,7 @@ public: virtual ~strstream(); + _LIBCPP_INLINE_VISIBILITY void swap(strstream& __rhs) { iostream::swap(__rhs); @@ -318,9 +341,13 @@ public: } // Members: + _LIBCPP_INLINE_VISIBILITY strstreambuf* rdbuf() const {return const_cast(&__sb_);} + _LIBCPP_INLINE_VISIBILITY void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);} + _LIBCPP_INLINE_VISIBILITY int pcount() const {return __sb_.pcount();} + _LIBCPP_INLINE_VISIBILITY char* str() {return __sb_.str();} private: diff --git a/include/system_error b/include/system_error index 24b23221..c8144932 100644 --- a/include/system_error +++ b/include/system_error @@ -229,12 +229,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD // is_error_code_enum -template struct is_error_code_enum +template +struct _LIBCPP_VISIBLE is_error_code_enum : public false_type {}; // is_error_condition_enum -template struct is_error_condition_enum +template +struct _LIBCPP_VISIBLE is_error_condition_enum : public false_type {}; // Some error codes are not present on all platforms, so we provide equivalents @@ -342,15 +344,19 @@ enum _ { _ __v_; + _LIBCPP_ALWAYS_INLINE errc(_ __v) : __v_(__v) {} + _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} }; -template <> struct is_error_condition_enum +template <> +struct _LIBCPP_VISIBLE is_error_condition_enum : true_type { }; -template <> struct is_error_condition_enum +template <> +struct _LIBCPP_VISIBLE is_error_condition_enum : true_type { }; class error_condition; @@ -360,7 +366,7 @@ class error_code; class __do_message; -class error_category +class _LIBCPP_VISIBLE error_category { public: virtual ~error_category(); @@ -399,7 +405,7 @@ public: const error_category& generic_category(); const error_category& system_category(); -class error_condition +class _LIBCPP_VISIBLE error_condition { int __val_; const error_category* __cat_; @@ -469,7 +475,7 @@ operator<(const error_condition& __x, const error_condition& __y) // error_code -class error_code +class _LIBCPP_VISIBLE error_code { int __val_; const error_category* __cat_; @@ -588,9 +594,10 @@ bool operator!=(const error_condition& __x, const error_condition& __y) {return !(__x == __y);} template <> -struct hash +struct _LIBCPP_VISIBLE hash : public unary_function { + _LIBCPP_INLINE_VISIBILITY size_t operator()(const error_code& __ec) const { return static_cast(__ec.value()); @@ -599,7 +606,7 @@ struct hash // system_error -class system_error +class _LIBCPP_VISIBLE system_error : public runtime_error { error_code __ec_; diff --git a/include/thread b/include/thread index 06cb5cac..25246fa0 100644 --- a/include/thread +++ b/include/thread @@ -118,8 +118,11 @@ public: __thread_specific_ptr(); ~__thread_specific_ptr(); + _LIBCPP_INLINE_VISIBILITY pointer get() const {return static_cast<_Tp*>(pthread_getspecific(__key_));} + _LIBCPP_INLINE_VISIBILITY pointer operator*() const {return *get();} + _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return get();} pointer release(); void reset(pointer __p = nullptr); @@ -175,7 +178,7 @@ __thread_id get_id(); } // this_thread -class __thread_id +class _LIBCPP_VISIBLE __thread_id { // FIXME: pthread_t is a pointer on Darwin but a long on Linux. // NULL is the no-thread value on Darwin. Someone needs to check @@ -183,40 +186,50 @@ class __thread_id pthread_t __id_; public: + _LIBCPP_INLINE_VISIBILITY __thread_id() : __id_(0) {} - friend bool operator==(__thread_id __x, __thread_id __y) + friend _LIBCPP_INLINE_VISIBILITY + bool operator==(__thread_id __x, __thread_id __y) {return __x.__id_ == __y.__id_;} - friend bool operator!=(__thread_id __x, __thread_id __y) + friend _LIBCPP_INLINE_VISIBILITY + bool operator!=(__thread_id __x, __thread_id __y) {return !(__x == __y);} - friend bool operator< (__thread_id __x, __thread_id __y) + friend _LIBCPP_INLINE_VISIBILITY + bool operator< (__thread_id __x, __thread_id __y) {return __x.__id_ < __y.__id_;} - friend bool operator<=(__thread_id __x, __thread_id __y) + friend _LIBCPP_INLINE_VISIBILITY + bool operator<=(__thread_id __x, __thread_id __y) {return !(__y < __x);} - friend bool operator> (__thread_id __x, __thread_id __y) + friend _LIBCPP_INLINE_VISIBILITY + bool operator> (__thread_id __x, __thread_id __y) {return __y < __x ;} - friend bool operator>=(__thread_id __x, __thread_id __y) + friend _LIBCPP_INLINE_VISIBILITY + bool operator>=(__thread_id __x, __thread_id __y) {return !(__x < __y);} template friend + _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {return __os << __id.__id_;} private: + _LIBCPP_INLINE_VISIBILITY __thread_id(pthread_t __id) : __id_(__id) {} friend __thread_id this_thread::get_id(); - friend class thread; + friend class _LIBCPP_VISIBLE thread; }; template struct hash; template<> -struct hash<__thread_id> +struct _LIBCPP_VISIBLE hash<__thread_id> : public unary_function<__thread_id, size_t> { + _LIBCPP_INLINE_VISIBILITY size_t operator()(__thread_id __v) const { const size_t* const __p = reinterpret_cast(&__v); @@ -227,7 +240,7 @@ struct hash<__thread_id> namespace this_thread { -inline +inline _LIBCPP_INLINE_VISIBILITY __thread_id get_id() { @@ -236,7 +249,7 @@ get_id() } // this_thread -class thread +class _LIBCPP_VISIBLE thread { pthread_t __t_; @@ -251,6 +264,7 @@ public: typedef __thread_id id; typedef pthread_t native_handle_type; + _LIBCPP_INLINE_VISIBILITY thread() : __t_(0) {} #ifndef _LIBCPP_HAS_NO_VARIADICS template & __t) } template -inline +inline _LIBCPP_INLINE_VISIBILITY void sleep_until(const chrono::time_point& __t) { @@ -398,7 +417,7 @@ sleep_until(const chrono::time_point& __t) sleep_for(__t - monotonic_clock::now()); } -inline +inline _LIBCPP_INLINE_VISIBILITY void yield() {sched_yield();} } // this_thread