Ignore:
Timestamp:
Mar 15, 2016, 10:20:07 PM (3 years ago)
Author:
nmedfort
Message:

Added the kernel instance class; removed original mmap file access in favour of the boost mmap system. corrected PrintRegister? routine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r4969 r4974  
    3838
    3939// mmap system
    40 #ifdef USE_BOOST_MMAP
    4140#include <boost/filesystem.hpp>
    4241#include <boost/iostreams/device/mapped_file.hpp>
    4342using namespace boost::iostreams;
    4443using namespace boost::filesystem;
    45 #else
    46 #include <sys/mman.h>
    47 #endif
     44
    4845#include <fcntl.h>
    4946
     
    7370    char * mFileBuffer;
    7471
    75 #ifdef USE_BOOST_MMAP
    7672    const path file(mFileName);
    7773    if (exists(file)) {
     
    9894        mFileBuffer = mFile.data();
    9995    }
    100 #else
    101     struct stat infile_sb;
    102     const int fdSrc = open(mFileName.c_str(), O_RDONLY);
    103     if (fdSrc == -1) {
    104         std::cerr << "Error: cannot open " << mFileName << " for processing. Skipped.\n";
    105         return;
    106     }
    107     if (fstat(fdSrc, &infile_sb) == -1) {
    108         std::cerr << "Error: cannot stat " << mFileName << " for processing. Skipped.\n";
    109         close (fdSrc);
    110         return;
    111     }
    112     if (S_ISDIR(infile_sb.st_mode)) {
    113         close (fdSrc);
    114         return;
    115     }
    116     mFileSize = infile_sb.st_size;
    117     if (mFileSize == 0) {
    118         mFileBuffer = nullptr;
    119     }
    120     else {
    121         mFileBuffer = (char *) mmap(NULL, mFileSize, PROT_READ, MAP_PRIVATE, fdSrc, 0);
    122         if (mFileBuffer == MAP_FAILED) {
    123             if (errno ==  ENOMEM) {
    124                 std::cerr << "Error:  mmap of " << mFileName << " failed: out of memory\n";
    125                 close (fdSrc);
    126             }
    127             else {
    128                 std::cerr << "Error: mmap of " << mFileName << " failed with errno " << errno << ". Skipped.\n";
    129                 close (fdSrc);
    130             }
    131             return;
    132         }
    133     }
    134     close(fdSrc);
    135 
    136 #endif
    13796   
    13897    uint64_t finalLineUnterminated = 0;
     
    142101    mMainFcn(mFileBuffer, mFileSize, mFileName.c_str(), finalLineUnterminated);
    143102
    144 #ifdef USE_BOOST_MMAP
     103
    145104    mFile.close();
    146 #else
    147     munmap((void *)mFileBuffer, mFileSize);
    148 #endif
    149105
    150106}
     
    157113    IDISA::IDISA_Builder * idb = GetIDISA_Builder(M);
    158114
    159     PipelineBuilder pipelineBuilder(M, idb);
     115    kernel::PipelineBuilder pipelineBuilder(M, idb);
    160116
    161117    Encoding encoding(Encoding::Type::UTF_8, 8);
     
    182138
    183139re::CC *  GrepEngine::grepCodepoints() {
     140
    184141    setParsedCodePointSet();
    185142    char * mFileBuffer = getUnicodeNameDataPtr();
Note: See TracChangeset for help on using the changeset viewer.