~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/Support/MemoryObject.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===- MemoryObject.h - Abstract memory interface ---------------*- C++ -*-===//
2
 
//
3
 
//                     The LLVM Compiler Infrastructure
4
 
//
5
 
// This file is distributed under the University of Illinois Open Source
6
 
// License. See LICENSE.TXT for details.
7
 
//
8
 
//===----------------------------------------------------------------------===//
9
 
 
10
 
#ifndef MEMORYOBJECT_H
11
 
#define MEMORYOBJECT_H
12
 
 
13
 
#include "llvm/System/DataTypes.h"
14
 
 
15
 
namespace llvm {
16
 
 
17
 
/// MemoryObject - Abstract base class for contiguous addressable memory.
18
 
///   Necessary for cases in which the memory is in another process, in a
19
 
///   file, or on a remote machine.
20
 
///   All size and offset parameters are uint64_ts, to allow 32-bit processes
21
 
///   access to 64-bit address spaces.
22
 
class MemoryObject {
23
 
public:
24
 
  /// Destructor      - Override as necessary.
25
 
  virtual ~MemoryObject();
26
 
  
27
 
  /// getBase         - Returns the lowest valid address in the region.
28
 
  ///
29
 
  /// @result         - The lowest valid address.
30
 
  virtual uint64_t getBase() const = 0;
31
 
  
32
 
  /// getExtent       - Returns the size of the region in bytes.  (The region is
33
 
  ///                   contiguous, so the highest valid address of the region 
34
 
  ///                   is getBase() + getExtent() - 1).
35
 
  ///
36
 
  /// @result         - The size of the region.
37
 
  virtual uint64_t getExtent() const = 0;
38
 
  
39
 
  /// readByte        - Tries to read a single byte from the region.
40
 
  ///
41
 
  /// @param address  - The address of the byte, in the same space as getBase().
42
 
  /// @param ptr      - A pointer to a byte to be filled in.  Must be non-NULL.
43
 
  /// @result         - 0 if successful; -1 if not.  Failure may be due to a
44
 
  ///                   bounds violation or an implementation-specific error.
45
 
  virtual int readByte(uint64_t address, uint8_t* ptr) const = 0;
46
 
  
47
 
  /// readBytes       - Tries to read a contiguous range of bytes from the
48
 
  ///                   region, up to the end of the region.
49
 
  ///                   You should override this function if there is a quicker
50
 
  ///                   way than going back and forth with individual bytes.
51
 
  ///
52
 
  /// @param address  - The address of the first byte, in the same space as 
53
 
  ///                   getBase().
54
 
  /// @param size     - The maximum number of bytes to copy.
55
 
  /// @param buf      - A pointer to a buffer to be filled in.  Must be non-NULL
56
 
  ///                   and large enough to hold size bytes.
57
 
  /// @param copied   - A pointer to a nunber that is filled in with the number
58
 
  ///                   of bytes actually read.  May be NULL.
59
 
  /// @result         - 0 if successful; -1 if not.  Failure may be due to a
60
 
  ///                   bounds violation or an implementation-specific error.
61
 
  virtual int readBytes(uint64_t address,
62
 
                        uint64_t size,
63
 
                        uint8_t* buf,
64
 
                        uint64_t* copied) const;
65
 
};
66
 
 
67
 
}
68
 
 
69
 
#endif
70