File: refresh.cc

package info (click to toggle)
bobcat 6.11.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,292 kB
  • sloc: cpp: 21,370; fortran: 6,507; makefile: 2,787; sh: 724; perl: 401; ansic: 26
file content (35 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define XERR "memoryaccess"
#include "memoryaccess.ih"

    // by extend.cc

MemoryAccess *MemoryAccess::refresh(size_t offset)
{
        // cf: bufLimits
    d_blockBegin = offset / d_blockSize * d_blockSize;  // cpt. the block
    d_blockEnd = d_blockBegin + d_blockSize;            // boundaries

    if (d_blockEnd > d_maxEnd)
        d_maxEnd = d_blockEnd;

    size_t nBlocks = divPlus(d_maxEnd, d_blockSize);    // new #blocks

    int id = getID(memoryAccessSize(nBlocks), d_accessMode);
    
                                                    // get its location
    MemoryAccess *ptr = static_cast<MemoryAccess *>(connect(id));

    if (ptr == 0)
        throw Exception{} << XERR ": can't connect memory for a "
                            "MemoryAccess object (id = " << id << ')';

    new (ptr) MemoryAccess(id, d_accessMode, nBlocks, d_blockSize);

    ptr->cpFrom(*this);

    return ptr;
}

//xerr("offset: " << offset << ", blockEnd: " << d_blockEnd);
//xerr("nBlocks: " << nBlocks);