cpuevent.cc revision 2680
12329SN/A/*
22329SN/A * Copyright (c) 2006 The Regents of The University of Michigan
32329SN/A * All rights reserved.
42329SN/A *
52329SN/A * Redistribution and use in source and binary forms, with or without
62329SN/A * modification, are permitted provided that the following conditions are
72329SN/A * met: redistributions of source code must retain the above copyright
82329SN/A * notice, this list of conditions and the following disclaimer;
92329SN/A * redistributions in binary form must reproduce the above copyright
102329SN/A * notice, this list of conditions and the following disclaimer in the
112329SN/A * documentation and/or other materials provided with the distribution;
122329SN/A * neither the name of the copyright holders nor the names of its
132329SN/A * contributors may be used to endorse or promote products derived from
142329SN/A * this software without specific prior written permission.
152329SN/A *
162329SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172329SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182329SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192329SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202329SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212329SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222329SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232329SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242329SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252329SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262329SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272689Sktlim@umich.edu *
282689Sktlim@umich.edu * Authors: Ali Saidi
292329SN/A */
302292SN/A
312292SN/A#include "cpu/cpuevent.hh"
322292SN/A
332292SN/A/** Static list of all CpuEvent objects so we can modify their thread
342362SN/A * contexts as needed. */
352362SN/ACpuEvent::CpuEventList CpuEvent::cpuEventList;
362680Sktlim@umich.edu
372292SN/ACpuEvent::~CpuEvent()
382362SN/A{
392292SN/A    CpuEventList::iterator i;
402292SN/A
412292SN/A    // delete the event from the global list
422292SN/A    for (i = cpuEventList.begin(); i != cpuEventList.end(); ) {
432292SN/A        if (*i == this)
442292SN/A            i = cpuEventList.erase(i);
452292SN/A        else
462292SN/A            i++;
472292SN/A    }
482329SN/A}
492292SN/A
502292SN/Avoid
512292SN/ACpuEvent::replaceThreadContext(ThreadContext *oldTc, ThreadContext *newTc)
522329SN/A{
532329SN/A    CpuEventList::iterator i;
542329SN/A
552680Sktlim@umich.edu    // Update any events that have the old thread context with the new thread
562680Sktlim@umich.edu    // context
572329SN/A    for (i = cpuEventList.begin(); i != cpuEventList.end(); i++) {
582329SN/A        if ((*i)->tc == oldTc)
592292SN/A            (*i)->tc = newTc;
602292SN/A    }
612680Sktlim@umich.edu}
622733Sktlim@umich.edu