errors with static linking on pool management members...

This commit is contained in:
Alex 2017-06-19 12:19:41 -05:00
parent 2d02f6f0fa
commit 99023dd1d3
2 changed files with 17 additions and 9 deletions

View file

@ -127,6 +127,9 @@
/* METHODS FOR CLASS C o n t F r a m e P o o l */ /* METHODS FOR CLASS C o n t F r a m e P o o l */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
std::vector<ContFramePool> ContFramePool::pools; // List of frame pools, managed by the class
unsigned int ContFramePool::nPools = 0; // Number of pools being managed
ContFramePool::ContFramePool(unsigned long _base_frame_no, ContFramePool::ContFramePool(unsigned long _base_frame_no,
unsigned long _n_frames, unsigned long _n_frames,
unsigned long _info_frame_no, unsigned long _info_frame_no,
@ -146,6 +149,9 @@ ContFramePool::ContFramePool(unsigned long _base_frame_no,
info_frame_no = _info_frame_no; info_frame_no = _info_frame_no;
n_info_frames = _n_info_frames; n_info_frames = _n_info_frames;
pools.push_back(*this);
nPools += 1;
// If _info_frame_no is zero then we keep management info in the first // If _info_frame_no is zero then we keep management info in the first
// frame(s), else we use the provided frame(s) to keep management info // frame(s), else we use the provided frame(s) to keep management info
// NOTE: bitmap needs to be allocated with n_info_frames if specified. // NOTE: bitmap needs to be allocated with n_info_frames if specified.
@ -338,7 +344,7 @@ void ContFramePool::mark_inaccessible(unsigned long _frame_no)
void ContFramePool::release_frames(unsigned long _frame_no) void ContFramePool::release_frames(unsigned long _frame_no)
{ {
unsigned int i = 0; unsigned int i = 0;
while(i < pools.size()) while(i < nPools)
{ {
if(_frame_no < pools[i].base_frame_no || _frame_no > (pools[i].base_frame_no + pools[i].nframes)) if(_frame_no < pools[i].base_frame_no || _frame_no > (pools[i].base_frame_no + pools[i].nframes))
{ {
@ -350,8 +356,6 @@ void ContFramePool::release_frames(unsigned long _frame_no)
return; return;
} }
} }
// This is the case where we fail to find the frame in any of the pools.
assert(false);
} }
void ContFramePool::release_frames_here(unsigned long _first_frame_no) void ContFramePool::release_frames_here(unsigned long _first_frame_no)
@ -390,5 +394,5 @@ void ContFramePool::release_frames_here(unsigned long _first_frame_no)
unsigned long ContFramePool::needed_info_frames(unsigned long _n_frames) unsigned long ContFramePool::needed_info_frames(unsigned long _n_frames)
{ {
return _n_frames / (FRAME_SIZE * 4); return (_n_frames / (FRAME_SIZE * 4)) + (_n_frames % (FRAME_SIZE * 4) > 0 ? 1 : 0);
} }

View file

@ -27,6 +27,7 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
#include "machine.H" #include "machine.H"
#include <vector>
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* DATA STRUCTURES */ /* DATA STRUCTURES */
@ -49,9 +50,12 @@ private:
unsigned long nframes; // Size of the frame pool unsigned long nframes; // Size of the frame pool
unsigned long info_frame_no; // Where do we store the management information? unsigned long info_frame_no; // Where do we store the management information?
unsigned long n_info_frames; // Number of frames needed to store management info unsigned long n_info_frames; // Number of frames needed to store management info
static std::vector<ContFramePool> pools; // List of frame pools, managed by the class
static unsigned int nPools; // Number of pools being managed
void mark_inaccessible(unsigned long _frame_no); // Should be a frame marked as void mark_inaccessible(unsigned long _frame_no); // Should be a frame marked as
// a head, otherwise fails // a head, otherwise fails
void release_frames_here(unsigned long _frame_no); // non-static member function
public: public:
@ -101,7 +105,7 @@ public:
_n_frames: Number of contiguous frames to mark as inaccessible. _n_frames: Number of contiguous frames to mark as inaccessible.
*/ */
static void release_frames(unsigned long _first_frame_no); static void release_frames(unsigned long _frame_no);
/* /*
Releases a previously allocated contiguous sequence of frames Releases a previously allocated contiguous sequence of frames
back to its frame pool. back to its frame pool.