Changeset bc73be3 in mainline for uspace/lib/cpp/include/__bits
- Timestamp:
- 2019-06-27T08:51:20Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8add15e0
- Parents:
- ad40b74b (diff), aeba767 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/cpp/include/__bits
- Files:
-
- 8 edited
-
chrono.hpp (modified) (2 diffs)
-
io/ios.hpp (modified) (1 diff)
-
limits.hpp (modified) (4 diffs)
-
locale/num_get.hpp (modified) (1 diff)
-
random.hpp (modified) (1 diff)
-
string/string.hpp (modified) (3 diffs)
-
thread/condition_variable.hpp (modified) (1 diff)
-
thread/threading.hpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/__bits/chrono.hpp
rad40b74b rbc73be3 611 611 static time_point now() 612 612 { 613 hel::timespec ts{};614 hel::getrealtime(&ts);613 ::std::timespec ts{}; 614 ::helenos::getrealtime(&ts); 615 615 616 616 rep time = NSEC2USEC(ts.tv_nsec); … … 654 654 static time_point now() 655 655 { 656 hel::timespec ts{};657 hel::getuptime(&ts);656 ::std::timespec ts{}; 657 ::helenos::getuptime(&ts); 658 658 659 659 rep time = NSEC2USEC(ts.tv_nsec); -
uspace/lib/cpp/include/__bits/io/ios.hpp
rad40b74b rbc73be3 41 41 { 42 42 using streamoff = long long; 43 using streamsize = hel::ssize_t;43 using streamsize = ::ssize_t; 44 44 45 45 /** -
uspace/lib/cpp/include/__bits/limits.hpp
rad40b74b rbc73be3 528 528 static constexpr unsigned short min() 529 529 { 530 return USHRT_MIN;530 return 0; 531 531 } 532 532 … … 552 552 static constexpr unsigned int min() 553 553 { 554 return UINT_MIN;554 return 0; 555 555 } 556 556 … … 576 576 static constexpr unsigned long min() 577 577 { 578 return ULONG_MIN;578 return 0; 579 579 } 580 580 … … 600 600 static constexpr unsigned long long min() 601 601 { 602 return ULLONG_MIN;602 return 0; 603 603 } 604 604 -
uspace/lib/cpp/include/__bits/locale/num_get.hpp
rad40b74b rbc73be3 301 301 if (size > 0) 302 302 { 303 int ret{}; 303 int olderrno{errno}; 304 errno = EOK; 305 char *endptr = NULL; 306 304 307 if constexpr (is_signed<BaseType>::value) 305 ret = std::hel::str_int64_t(base.buffer_, nullptr, num_base, false, &res); 306 else 307 ret = std::hel::str_uint64_t(base.buffer_, nullptr, num_base, false, &res); 308 309 if (ret != EOK) 310 { 308 res = ::strtoll(base.buffer_, &endptr, num_base); 309 else 310 res = ::strtoull(base.buffer_, &endptr, num_base); 311 312 if (errno != EOK || endptr == base.buffer_) 311 313 err |= ios_base::failbit; 312 v = 0; 313 } 314 else if (res > static_cast<BaseType>(numeric_limits<T>::max())) 314 315 errno = olderrno; 316 317 if (res > static_cast<BaseType>(numeric_limits<T>::max())) 315 318 { 316 319 err |= ios_base::failbit; -
uspace/lib/cpp/include/__bits/random.hpp
rad40b74b rbc73be3 1030 1030 * something better. 1031 1031 */ 1032 hel::srand(hel::time(nullptr));1032 ::srand(::time(nullptr)); 1033 1033 } 1034 1034 1035 1035 result_type operator()() 1036 1036 { 1037 return hel::rand();1037 return ::rand(); 1038 1038 } 1039 1039 -
uspace/lib/cpp/include/__bits/string/string.hpp
rad40b74b rbc73be3 82 82 static int compare(const char_type* s1, const char_type* s2, size_t n) 83 83 { 84 return hel::str_lcmp(s1, s2, n);84 return ::strncmp(s1, s2, n); 85 85 } 86 86 87 87 static size_t length(const char_type* s) 88 88 { 89 return hel::str_size(s);89 return ::strlen(s); 90 90 } 91 91 … … 367 367 // TODO: This function does not exits... 368 368 __unimplemented(); 369 //return hel::wstr_lcmp(s1, s2, n);370 369 return 0; 371 370 } … … 373 372 static size_t length(const char_type* s) 374 373 { 375 return hel::wstr_size(s); 374 size_t i = 0; 375 while (s[i] != 0) 376 i++; 377 return i; 376 378 } 377 379 -
uspace/lib/cpp/include/__bits/thread/condition_variable.hpp
rad40b74b rbc73be3 35 35 namespace std 36 36 { 37 extern "C" {38 #include <fibril.h>39 #include <fibril_synch.h>40 }41 42 37 enum class cv_status 43 38 { -
uspace/lib/cpp/include/__bits/thread/threading.hpp
rad40b74b rbc73be3 30 30 #define LIBCPP_BITS_THREAD_THREADING 31 31 32 namespace std::hel33 {34 extern "C" {35 #include <async.h>36 #include <fibril.h>37 #include <fibril_synch.h>38 }39 }40 41 32 #include <chrono> 33 34 #include <fibril.h> 35 #include <fibril_synch.h> 42 36 43 37 namespace std::aux … … 55 49 struct threading_policy<fibril_tag> 56 50 { 57 using mutex_type = hel::fibril_mutex_t;58 using thread_type = hel::fid_t;59 using condvar_type = hel::fibril_condvar_t;60 using time_unit = hel::usec_t;61 using shared_mutex_type = hel::fibril_rwlock_t;51 using mutex_type = ::helenos::fibril_mutex_t; 52 using thread_type = ::helenos::fid_t; 53 using condvar_type = ::helenos::fibril_condvar_t; 54 using time_unit = ::helenos::usec_t; 55 using shared_mutex_type = ::helenos::fibril_rwlock_t; 62 56 63 57 struct thread … … 66 60 static thread_type create(Callable clbl, Payload& pld) 67 61 { 68 return hel::fibril_create(clbl, (void*)&pld);62 return ::helenos::fibril_create(clbl, (void*)&pld); 69 63 } 70 64 71 65 static void start(thread_type thr) 72 66 { 73 hel::fibril_add_ready(thr);67 ::helenos::fibril_add_ready(thr); 74 68 } 75 69 76 70 static thread_type this_thread() 77 71 { 78 return hel::fibril_get_id();72 return ::helenos::fibril_get_id(); 79 73 } 80 74 81 75 static void yield() 82 76 { 83 hel::fibril_yield();77 ::helenos::fibril_yield(); 84 78 } 85 79 … … 95 89 static void init(mutex_type& mtx) 96 90 { 97 hel::fibril_mutex_initialize(&mtx);91 ::helenos::fibril_mutex_initialize(&mtx); 98 92 } 99 93 100 94 static void lock(mutex_type& mtx) 101 95 { 102 hel::fibril_mutex_lock(&mtx);96 ::helenos::fibril_mutex_lock(&mtx); 103 97 } 104 98 105 99 static void unlock(mutex_type& mtx) 106 100 { 107 hel::fibril_mutex_unlock(&mtx);101 ::helenos::fibril_mutex_unlock(&mtx); 108 102 } 109 103 110 104 static bool try_lock(mutex_type& mtx) 111 105 { 112 return hel::fibril_mutex_trylock(&mtx);106 return ::helenos::fibril_mutex_trylock(&mtx); 113 107 } 114 108 … … 124 118 static void init(condvar_type& cv) 125 119 { 126 hel::fibril_condvar_initialize(&cv);120 ::helenos::fibril_condvar_initialize(&cv); 127 121 } 128 122 129 123 static void wait(condvar_type& cv, mutex_type& mtx) 130 124 { 131 hel::fibril_condvar_wait(&cv, &mtx);125 ::helenos::fibril_condvar_wait(&cv, &mtx); 132 126 } 133 127 134 128 static int wait_for(condvar_type& cv, mutex_type& mtx, time_unit timeout) 135 129 { 136 return hel::fibril_condvar_wait_timeout(&cv, &mtx, timeout);130 return ::helenos::fibril_condvar_wait_timeout(&cv, &mtx, timeout); 137 131 } 138 132 139 133 static void signal(condvar_type& cv) 140 134 { 141 hel::fibril_condvar_signal(&cv);135 ::helenos::fibril_condvar_signal(&cv); 142 136 } 143 137 144 138 static void broadcast(condvar_type& cv) 145 139 { 146 hel::fibril_condvar_broadcast(&cv);140 ::helenos::fibril_condvar_broadcast(&cv); 147 141 } 148 142 }; … … 158 152 static void sleep(time_unit time) 159 153 { 160 hel::fibril_usleep(time);154 ::helenos::fibril_usleep(time); 161 155 } 162 156 }; … … 166 160 static void init(shared_mutex_type& mtx) 167 161 { 168 hel::fibril_rwlock_initialize(&mtx);162 ::helenos::fibril_rwlock_initialize(&mtx); 169 163 } 170 164 171 165 static void lock(shared_mutex_type& mtx) 172 166 { 173 hel::fibril_rwlock_write_lock(&mtx);167 ::helenos::fibril_rwlock_write_lock(&mtx); 174 168 } 175 169 176 170 static void unlock(shared_mutex_type& mtx) 177 171 { 178 hel::fibril_rwlock_write_unlock(&mtx);172 ::helenos::fibril_rwlock_write_unlock(&mtx); 179 173 } 180 174 181 175 static void lock_shared(shared_mutex_type& mtx) 182 176 { 183 hel::fibril_rwlock_read_lock(&mtx);177 ::helenos::fibril_rwlock_read_lock(&mtx); 184 178 } 185 179 186 180 static void unlock_shared(shared_mutex_type& mtx) 187 181 { 188 hel::fibril_rwlock_read_unlock(&mtx);182 ::helenos::fibril_rwlock_read_unlock(&mtx); 189 183 } 190 184
Note:
See TracChangeset
for help on using the changeset viewer.
