示例#1
0
 void MetaProcessor::setFileStream(llvm::StringRef file, bool append, int fd,
             llvm::SmallVector<llvm::SmallString<128>, 2>& prevFileStack) {
   // If we have a fileName to redirect to store it.
   if (!file.empty()) {
     prevFileStack.push_back(file);
     // pop and push a null terminating 0.
     // SmallVectorImpl<T> does not have a c_str(), thus instead of casting to
     // a SmallString<T> we null terminate the data that we have and pop the
     // 0 char back.
     prevFileStack.back().push_back(0);
     prevFileStack.back().pop_back();
     if (!append) {
       FILE * f;
       if (!(f = fopen(file.data(), "w"))) {
         llvm::errs() << "cling::MetaProcessor::setFileStream:"
                      " The file path " << file.data() << "is not valid.";
       } else {
         fclose(f);
       }
     }
   // Else unredirection, so switch to the previous file.
   } else {
     // If there is no previous file on the stack we pop the file
     if (!prevFileStack.empty()) {
       prevFileStack.pop_back();
     }
   }
 }
示例#2
0
文件: ics.cpp 项目: Daetalus/pyston
 void* alloc() {
     if (free_chunks.empty()) {
         int protection = PROT_READ | PROT_WRITE | PROT_EXEC;
         int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT;
         char* addr = (char*)mmap(NULL, region_size, protection, flags, -1, 0);
         for (int i = 0; i < region_size / chunk_size; ++i) {
             free_chunks.push_back(&addr[i * chunk_size]);
         }
     }
     return free_chunks.pop_back_val();
 }
示例#3
0
 bool empty() const { return ToHandle.empty(); }