Esempio n. 1
0
template <typename Iter, typename Other> inline bool
operator == (range<Iter> const &value, range<Other> const &other) {
	if (value.size() == other.size()) {
		return value.empty() ? true : std::equal(value.begin(), value.end(), other.begin());
	}
	return false;
}
Esempio n. 2
0
inline bool
operator == (range<char const*> const &value, range<char const*> const &other) {
	if (value.size() == other.size()) {
		return value.empty() ? true : strncmp(value.begin(), other.begin(), value.size()) == 0;
	}
	return false;
}
Esempio n. 3
0
void database::add(range key, range data)
{
    assert(_db);
    struct slice sk, sv;

    sk.data  = const_cast<char*>(key.begin());
    sk.len = key.size();
    sv.data  = const_cast<char*>(data.begin());
    sv.len = data.size();

    if (::db_add(_db, &sk, &sv) == 0)
    {
        throw exception("error adding to ness backend");
    }
}
Esempio n. 4
0
void MipsELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,
                                                   ArrayRef<uint8_t> symContent,
                                                   ArrayRef<uint8_t> secContent,
                                                   range<Elf_Rel_Iter> rels) {
  const auto value = this->getSymbolValue(symbol);
  for (Elf_Rel_Iter rit = rels.begin(), eit = rels.end(); rit != eit; ++rit) {
    if (rit->r_offset < value || value + symContent.size() <= rit->r_offset)
      continue;

    auto r = new (this->_readerStorage) MipsELFReference<ELFT>(value, *rit);
    this->addReferenceToSymbol(r, symbol);
    this->_references.push_back(r);

    auto addend = readAddend(*rit, secContent);
    auto pairRelType = getPairRelocation(*rit);
    if (pairRelType != llvm::ELF::R_MIPS_NONE) {
      addend <<= 16;
      auto mit = findMatchingRelocation(pairRelType, rit, eit);
      if (mit != eit)
        addend += int16_t(readAddend(*mit, secContent));
      else
        // FIXME (simon): Show detailed warning.
        llvm::errs() << "lld warning: cannot matching LO16 relocation\n";
    }
    this->_references.back()->setAddend(addend);
  }
}
Esempio n. 5
0
 void operator()(const range& r) const{
     for (int i = r.begin(); i != r.end(); ++i) {
         if (compareWord(word, words[i])) {
             cout << words[i] << endl;
         }
     }
 }
Esempio n. 6
0
 void jacobi_kernel_wrapper(range const & y_range, size_t n, vector<double> & dst, vector<double> const & src) {
     for(size_t y = y_range.begin(); y < y_range.end(); ++y) {
               double * dst_ptr = &dst[y * n];
         const double * src_ptr = &src[y * n];
         jacobi_kernel( dst_ptr, src_ptr, n );
     }
 }
Esempio n. 7
0
void database::del(range key)
{
    assert(_db);
    struct slice sk;

    sk.data  = const_cast<char*>(key.begin());
    sk.len = key.size();

    ::db_remove(_db, &sk);
}
Esempio n. 8
0
 void jacobi_kernel_wrap(
     range const & r,
     crs_matrix<double> const & A,
     std::vector<double> & x_dst, std::vector<double> const & x_src, std::vector<double> const & b)
 {
     for(std::size_t row = r.begin(); row < r.end(); ++row)
     {
         jacobi_kernel_nonuniform(A, x_dst, x_src, b, row);
     }
 }
 __forceinline NodeRef operator() (const PrimRef* prims, const range<size_t>& set, const FastAllocator::CachedAllocator& alloc) const
 {
   size_t n = set.size();
   size_t items = Primitive::blocks(n);
   size_t start = set.begin();
   Primitive* accel = (Primitive*) alloc.malloc1(items*sizeof(Primitive),BVH::byteAlignment);
   typename BVH::NodeRef node = BVH::encodeLeaf((char*)accel,items);
   for (size_t i=0; i<items; i++) {
     accel[i].fill(prims,start,set.end(),bvh->scene);
   }
   return node;
 }
Esempio n. 10
0
			range<byte*> read(const range<byte*>& buf)
			{
				zstream.avail_out = uInt(buf.size());
				zstream.next_out = (Bytef*)buf.begin();

				for(;zstream.avail_out != 0;){
					if (zstream.avail_in == 0){
						new_input_();
					}

					auto res = ::inflate(&zstream, Z_NO_FLUSH);
					switch(res)
					{
						case Z_NEED_DICT:
							{
								if (dict.empty())
									AIO_THROW(inflate_exception)("Need dictionary");
								auto dic_err = inflateSetDictionary(&zstream, (Bytef*)dict.begin(), dict.size());
								if (dic_err != Z_OK)
									AIO_THROW(inflate_exception)("Bad dictionary");
							}
						case Z_OK:
							break;
						case Z_DATA_ERROR:
							AIO_THROW(inflate_exception)("Z_DATA_ERROR");
						case Z_MEM_ERROR:
							AIO_THROW(inflate_exception)("Z_MEM_ERROR");
						case Z_STREAM_END:
							uncompressed_size = zstream.total_out;
							return range<byte*>((buf.size() - zstream.avail_out) + buf.begin(), buf.end());
						default:
							AIO_THROW(inflate_exception)("zlib internal error");
					}
				}
				return range<byte*>(buf.end() - zstream.avail_out, buf.end());
			}
Esempio n. 11
0
    void escape_line(range const& line) {
        auto begin = line.begin();
        auto end = begin;
        while (end != line.end()) {
            if (*end == '<') {
                stream_ << range(begin, end) << "&lt;";
                begin = ++end;
            }
            else if (*end == '>') {
                stream_ << range(begin, end) << "&gt;";
                begin = ++end;
            }
            else ++end;
        }

        if (begin != end) stream_ << range(begin, end);
    }
Esempio n. 12
0
std::string database::get(range key)
{
    assert(_db);
    struct slice sk, sv;

    sk.data  = const_cast<char*>(key.begin());
    sk.len = key.size();

    if (::db_get(_db, &sk, &sv) == 0)
    {
        throw exception("error reading from ness backend");
    }

    // copy the data out
    std::string result(sv.data, sv.len);
    ::free(sv.data);
    return result;
}
Esempio n. 13
0
			range<const byte*> write(const range<const byte*>& buf){
				AIO_PRE_CONDITION(!finished);
				AIO_PRE_CONDITION(zstream.avail_in == 0);
				crc = crc32(buf, crc);
				zstream.next_in = (Bytef*)buf.begin();
				zstream.avail_in = uInt(buf.size());

				for(;zstream.avail_in != 0;){
					if (zstream.avail_out ==0 )
						new_buffer_();

					switch (deflate(&zstream, Z_NO_FLUSH)){
						case Z_OK:
						case Z_BUF_ERROR:
							break;
						default:
							AIO_THROW(deflate_exception)("deflate with Z_NO_FLUSH failed");
					}
				}
				return range<const byte*>(buf.end(), buf.end());
			}
Esempio n. 14
0
 inline begin_t begin (const range <begin_t, end_t>& range)
 {
   return range.begin ();
 }
Esempio n. 15
0
File: main.cpp Progetto: CCJY/coliru
 friend It begin(const range<It>& range) { return range.begin(); }    
bool operator==(tbb::concurrent_priority_queue<element_type, compare_t, allocator_t> const& lhs, range const & rhs ){
    using equality_comparison_helpers::to_vector;
    return to_vector()(lhs) == std::vector<element_type>(rhs.begin(),rhs.end());
}
Esempio n. 17
0
inline bool
operator == (range<char*> const &value, range<char const*> const &other) {
	return range<char const*>(value.begin(), value.end()) == other;
}
Esempio n. 18
0
inline bool
operator == (range<char const*> const &value, range<char*> const &other) {
	return value == range<char const*>(other.begin(), other.end());
}
Esempio n. 19
0
	uint32_t crc32(range<const byte*> src, uint32_t crc /* = crc32_init() */){
		return ::crc32(crc, (const Bytef*)src.begin(), (uInt)src.size());
	}
Esempio n. 20
0
inline bool
operator > (range<char*> const &value, range<char*> const &other) {
	return range<char const*>(value.begin(), value.end()) > range<char const*>(other.begin(), other.end());
}
Esempio n. 21
0
inline bool
operator > (range<char const*> const &value, range<char const*> const &other) {
	return (!value.empty() && !other.empty()) ? (strncmp(value.begin(), other.begin(), std::max(value.size(), other.size())) > 0) : !value.empty();
}
Esempio n. 22
0
template <typename Iter, typename Other> inline bool
operator < (range<Iter> const &value, range<Other> const &other) {
	return (!value.empty() && !other.empty()) ? std::lexicographical_compare(value.begin(), value.end(), other.begin(), other.end()) : !other.empty();
}
Esempio n. 23
0
template <typename Iter, typename Other> inline bool
operator > (range<Iter> const &value, range<Other> const &other) {
	std::greater<typename std::iterator_traits<Iter>::value_type> pred;
	return (!value.empty() && !other.empty()) ? std::lexicographical_compare(value.begin(), value.end(), other.begin(), other.end(), pred) : !value.empty();
}