arguments.hh (9850:87d6b41749e9) | arguments.hh (10468:8c1b836edc92) |
---|---|
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Nathan Binkert 29 */ 30 31#ifndef __SIM_ARGUMENTS_HH__ 32#define __SIM_ARGUMENTS_HH__ 33 34#include <cassert> | 1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Nathan Binkert 29 */ 30 31#ifndef __SIM_ARGUMENTS_HH__ 32#define __SIM_ARGUMENTS_HH__ 33 34#include <cassert> |
35#include <memory> |
|
35 | 36 |
36#include "base/refcnt.hh" | |
37#include "base/types.hh" 38#include "mem/fs_translating_port_proxy.hh" 39 40class ThreadContext; 41 42class Arguments 43{ 44 protected: 45 ThreadContext *tc; 46 int number; 47 uint64_t getArg(uint16_t size = (uint16_t)(-1), bool fp = false); 48 49 protected: | 37#include "base/types.hh" 38#include "mem/fs_translating_port_proxy.hh" 39 40class ThreadContext; 41 42class Arguments 43{ 44 protected: 45 ThreadContext *tc; 46 int number; 47 uint64_t getArg(uint16_t size = (uint16_t)(-1), bool fp = false); 48 49 protected: |
50 class Data : public RefCounted | 50 class Data |
51 { 52 public: 53 Data(){} 54 ~Data(); 55 56 private: 57 std::list<char *> data; 58 59 public: 60 char *alloc(size_t size); 61 }; 62 | 51 { 52 public: 53 Data(){} 54 ~Data(); 55 56 private: 57 std::list<char *> data; 58 59 public: 60 char *alloc(size_t size); 61 }; 62 |
63 RefCountingPtr<Data> data; | 63 std::shared_ptr<Data> data; |
64 65 public: 66 Arguments(ThreadContext *ctx, int n = 0) | 64 65 public: 66 Arguments(ThreadContext *ctx, int n = 0) |
67 : tc(ctx), number(n), data(NULL) 68 { assert(number >= 0); data = new Data;} | 67 : tc(ctx), number(n), data(new Data()) 68 { assert(number >= 0); } |
69 Arguments(const Arguments &args) 70 : tc(args.tc), number(args.number), data(args.data) {} 71 ~Arguments() {} 72 73 ThreadContext *getThreadContext() const { return tc; } 74 75 const Arguments &operator=(const Arguments &args) { | 69 Arguments(const Arguments &args) 70 : tc(args.tc), number(args.number), data(args.data) {} 71 ~Arguments() {} 72 73 ThreadContext *getThreadContext() const { return tc; } 74 75 const Arguments &operator=(const Arguments &args) { |
76 tc = args.tc; 77 number = args.number; 78 data = args.data; | 76 if (this != &args) { 77 tc = args.tc; 78 number = args.number; 79 data = args.data; 80 } |
79 return *this; 80 } 81 82 // for checking if an argument is NULL 83 bool operator!() { 84 return getArg() == 0; 85 } 86 --- 64 unchanged lines hidden --- | 81 return *this; 82 } 83 84 // for checking if an argument is NULL 85 bool operator!() { 86 return getArg() == 0; 87 } 88 --- 64 unchanged lines hidden --- |