~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/ADT/PointerIntPair.h

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- llvm/ADT/PointerIntPair.h - Pair for pointer and int -----*- 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
// This file defines the PointerIntPair class.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef LLVM_ADT_POINTERINTPAIR_H
 
15
#define LLVM_ADT_POINTERINTPAIR_H
 
16
 
 
17
#include "llvm/Support/PointerLikeTypeTraits.h"
 
18
#include <cassert>
 
19
 
 
20
namespace llvm {
 
21
 
 
22
template<typename T>
 
23
struct DenseMapInfo;
 
24
 
 
25
/// PointerIntPair - This class implements a pair of a pointer and small
 
26
/// integer.  It is designed to represent this in the space required by one
 
27
/// pointer by bitmangling the integer into the low part of the pointer.  This
 
28
/// can only be done for small integers: typically up to 3 bits, but it depends
 
29
/// on the number of bits available according to PointerLikeTypeTraits for the
 
30
/// type.
 
31
///
 
32
/// Note that PointerIntPair always puts the Int part in the highest bits
 
33
/// possible.  For example, PointerIntPair<void*, 1, bool> will put the bit for
 
34
/// the bool into bit #2, not bit #0, which allows the low two bits to be used
 
35
/// for something else.  For example, this allows:
 
36
///   PointerIntPair<PointerIntPair<void*, 1, bool>, 1, bool>
 
37
/// ... and the two bools will land in different bits.
 
38
///
 
39
template <typename PointerTy, unsigned IntBits, typename IntType=unsigned,
 
40
          typename PtrTraits = PointerLikeTypeTraits<PointerTy> >
 
41
class PointerIntPair {
 
42
  intptr_t Value;
 
43
  enum {
 
44
    /// PointerBitMask - The bits that come from the pointer.
 
45
    PointerBitMask =
 
46
      ~(uintptr_t)(((intptr_t)1 << PtrTraits::NumLowBitsAvailable)-1),
 
47
 
 
48
    /// IntShift - The number of low bits that we reserve for other uses, and
 
49
    /// keep zero.
 
50
    IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable-IntBits,
 
51
    
 
52
    /// IntMask - This is the unshifted mask for valid bits of the int type.
 
53
    IntMask = (uintptr_t)(((intptr_t)1 << IntBits)-1),
 
54
    
 
55
    // ShiftedIntMask - This is the bits for the integer shifted in place.
 
56
    ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
 
57
  };
 
58
public:
 
59
  PointerIntPair() : Value(0) {}
 
60
  PointerIntPair(PointerTy Ptr, IntType Int) : Value(0) {
 
61
    assert(IntBits <= PtrTraits::NumLowBitsAvailable &&
 
62
           "PointerIntPair formed with integer size too large for pointer");
 
63
    setPointer(Ptr);
 
64
    setInt(Int);
 
65
  }
 
66
 
 
67
  PointerTy getPointer() const {
 
68
    return PtrTraits::getFromVoidPointer(
 
69
                         reinterpret_cast<void*>(Value & PointerBitMask));
 
70
  }
 
71
 
 
72
  IntType getInt() const {
 
73
    return (IntType)((Value >> IntShift) & IntMask);
 
74
  }
 
75
 
 
76
  void setPointer(PointerTy Ptr) {
 
77
    intptr_t PtrVal
 
78
      = reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(Ptr));
 
79
    assert((PtrVal & ((1 << PtrTraits::NumLowBitsAvailable)-1)) == 0 &&
 
80
           "Pointer is not sufficiently aligned");
 
81
    // Preserve all low bits, just update the pointer.
 
82
    Value = PtrVal | (Value & ~PointerBitMask);
 
83
  }
 
84
 
 
85
  void setInt(IntType Int) {
 
86
    intptr_t IntVal = Int;
 
87
    assert(IntVal < (1 << IntBits) && "Integer too large for field");
 
88
    
 
89
    // Preserve all bits other than the ones we are updating.
 
90
    Value &= ~ShiftedIntMask;     // Remove integer field.
 
91
    Value |= IntVal << IntShift;  // Set new integer.
 
92
  }
 
93
 
 
94
  void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); }
 
95
  void setFromOpaqueValue(void *Val) { Value = reinterpret_cast<intptr_t>(Val);}
 
96
 
 
97
  static PointerIntPair getFromOpaqueValue(void *V) {
 
98
    PointerIntPair P; P.setFromOpaqueValue(V); return P; 
 
99
  }
 
100
  
 
101
  bool operator==(const PointerIntPair &RHS) const {return Value == RHS.Value;}
 
102
  bool operator!=(const PointerIntPair &RHS) const {return Value != RHS.Value;}
 
103
  bool operator<(const PointerIntPair &RHS) const {return Value < RHS.Value;}
 
104
  bool operator>(const PointerIntPair &RHS) const {return Value > RHS.Value;}
 
105
  bool operator<=(const PointerIntPair &RHS) const {return Value <= RHS.Value;}
 
106
  bool operator>=(const PointerIntPair &RHS) const {return Value >= RHS.Value;}
 
107
};
 
108
 
 
109
template <typename T> struct isPodLike;
 
110
template<typename PointerTy, unsigned IntBits, typename IntType>
 
111
struct isPodLike<PointerIntPair<PointerTy, IntBits, IntType> > {
 
112
   static const bool value = true;
 
113
};
 
114
  
 
115
// Provide specialization of DenseMapInfo for PointerIntPair.
 
116
template<typename PointerTy, unsigned IntBits, typename IntType>
 
117
struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
 
118
  typedef PointerIntPair<PointerTy, IntBits, IntType> Ty;
 
119
  static Ty getEmptyKey() {
 
120
    intptr_t Val = -1;
 
121
    Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
 
122
    return Ty(reinterpret_cast<PointerTy>(Val), IntType((1 << IntBits)-1));
 
123
  }
 
124
  static Ty getTombstoneKey() {
 
125
    intptr_t Val = -2;
 
126
    Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
 
127
    return Ty(reinterpret_cast<PointerTy>(Val), IntType(0));
 
128
  }
 
129
  static unsigned getHashValue(Ty V) {
 
130
    uintptr_t IV = reinterpret_cast<uintptr_t>(V.getOpaqueValue());
 
131
    return unsigned(IV) ^ unsigned(IV >> 9);
 
132
  }
 
133
  static bool isEqual(const Ty &LHS, const Ty &RHS) { return LHS == RHS; }
 
134
};
 
135
 
 
136
// Teach SmallPtrSet that PointerIntPair is "basically a pointer".
 
137
template<typename PointerTy, unsigned IntBits, typename IntType,
 
138
         typename PtrTraits>
 
139
class PointerLikeTypeTraits<PointerIntPair<PointerTy, IntBits, IntType,
 
140
                                           PtrTraits> > {
 
141
public:
 
142
  static inline void *
 
143
  getAsVoidPointer(const PointerIntPair<PointerTy, IntBits, IntType> &P) {
 
144
    return P.getOpaqueValue();
 
145
  }
 
146
  static inline PointerIntPair<PointerTy, IntBits, IntType>
 
147
  getFromVoidPointer(void *P) {
 
148
    return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
 
149
  }
 
150
  enum {
 
151
    NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits
 
152
  };
 
153
};
 
154
 
 
155
} // end namespace llvm
 
156
#endif