static int check_label (struct label *labels, const char **p, struct label **ret, struct label **previous, int force_skip) { struct label *l; const char *c; unsigned s2; *p = delspc (*p); for (c = *p; isalnum (*c) || *c == '_' || *c == '.'; ++c) { } s2 = c - *p; for (l = labels; l; l = l->next) { unsigned s1, s; int cmp; s1 = strlen (l->name); s = s1 < s2 ? s1 : s2; cmp = strncmp (l->name, *p, s); if (cmp > 0 || (cmp == 0 && s1 > s)) { if (force_skip) *p = c; return 0; } if (cmp < 0 || s2 > s) { if (previous) *previous = l; continue; } *p = c; /* if label is not valid, compute it */ if (l->ref) { compute_ref (l->ref, 1); if (!l->ref->done) { /* label was not valid, and isn't computable. tell the * caller that it doesn't exist, so it will try again later. * Set ret to show actual existence. */ if (verbose >= 6) fprintf (stderr, "%5d (0x%04x): returning invalid label %s.\n", stack[sp].line, addr, l->name); *ret = l; return 0; } } *ret = l; return 1; } if (force_skip) *p = c; return 0; }
int main() { const int number_of_tests = 100; for (int i=0; i< number_of_tests; i++) try { // { // std::cout << __FILE__ << " "<<__LINE__ << std::endl; // boost::future<int> f = boost::async(boost::launch::async, p1); // std::cout << i << " "<<f.get() << std::endl; // } #if defined BOOST_THREAD_USES_MOVE { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<void> f = void_compute(); f.get(); } #endif { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<int> f = compute(-1); f.wait(); } { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<int> f = compute(0); std::cout << f.get() << std::endl; } { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<int&> f = compute_ref(0); std::cout << f.get() << std::endl; } #if __cplusplus > 201103L { std::cout << __FILE__ << " "<< __LINE__ << std::endl; int i = 0; boost::future<int&> f = boost::make_ready_future(std::ref(i)); std::cout << f.get() << std::endl; } #endif { std::cout << __FILE__ << " "<< __LINE__ << std::endl; int i = 0; boost::future<int&> f = boost::make_ready_future(boost::ref(i)); std::cout << f.get() << std::endl; } { std::cout << __FILE__ << " "<< __LINE__ << std::endl; const int i = 0; boost::future<int const&> f = boost::make_ready_future(boost::cref(i)); std::cout << f.get() << std::endl; } { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<int> f = compute(2); std::cout << f.get() << std::endl; } { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::shared_future<int> f = shared_compute(0); std::cout << f.get() << std::endl; } } catch (std::exception& ex) { std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl; return 1; } catch (...) { std::cout << "ERRORRRRR "<<"ERRORRRRR exception thrown" << std::endl; return 2; } return 0; }