Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(64)

Unified Diff: src/common/test_assembler.h

Issue 535002: Use stdint types everywhere. (Closed)
Patch Set: Renamed uint128_t to uint128_struct Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/common/test_assembler.h
===================================================================
--- a/src/common/test_assembler.h
+++ b/src/common/test_assembler.h
@@ -105,62 +105,62 @@ namespace test_assembler {
// Label objects' lifetimes are unconstrained: notice that, in the
// above example, even though a and b are only related through c, and
// c goes out of scope, the assignment to a sets b's value as well. In
// particular, it's not necessary to ensure that a Label lives beyond
// Sections that refer to it.
class Label {
public:
Label(); // An undefined label.
- Label(u_int64_t value); // A label with a fixed value
+ Label(uint64_t value); // A label with a fixed value
Label(const Label &value); // A label equal to another.
~Label();
// Return this label's value; it must be known.
//
// Providing this as a cast operator is nifty, but the conversions
// happen in unexpected places. In particular, ISO C++ says that
// Label + size_t becomes ambigious, because it can't decide whether
- // to convert the Label to a u_int64_t and then to a size_t, or use
+ // to convert the Label to a uint64_t and then to a size_t, or use
// the overloaded operator that returns a new label, even though the
// former could fail if the label is not yet defined and the latter won't.
- u_int64_t Value() const;
+ uint64_t Value() const;
- Label &operator=(u_int64_t value);
+ Label &operator=(uint64_t value);
Label &operator=(const Label &value);
- Label operator+(u_int64_t addend) const;
- Label operator-(u_int64_t subtrahend) const;
- u_int64_t operator-(const Label &subtrahend) const;
+ Label operator+(uint64_t addend) const;
+ Label operator-(uint64_t subtrahend) const;
+ uint64_t operator-(const Label &subtrahend) const;
// We could also provide == and != that work on undefined, but
// related, labels.
// Return true if this label's value is known. If VALUE_P is given,
// set *VALUE_P to the known value if returning true.
- bool IsKnownConstant(u_int64_t *value_p = NULL) const;
+ bool IsKnownConstant(uint64_t *value_p = NULL) const;
// Return true if the offset from LABEL to this label is known. If
// OFFSET_P is given, set *OFFSET_P to the offset when returning true.
//
// You can think of l.KnownOffsetFrom(m, &d) as being like 'd = l-m',
// except that it also returns a value indicating whether the
// subtraction is possible given what we currently know of l and m.
// It can be possible even if we don't know l and m's values. For
// example:
//
// Label l, m;
// m = l + 10;
// l.IsKnownConstant(); // false
// m.IsKnownConstant(); // false
- // u_int64_t d;
+ // uint64_t d;
// l.IsKnownOffsetFrom(m, &d); // true, and sets d to -10.
// l-m // -10
// m-l // 10
// m.Value() // error: m's value is not known
- bool IsKnownOffsetFrom(const Label &label, u_int64_t *offset_p = NULL) const;
+ bool IsKnownOffsetFrom(const Label &label, uint64_t *offset_p = NULL) const;
private:
// A label's value, or if that is not yet known, how the value is
// related to other labels' values. A binding may be:
// - a known constant,
// - constrained to be equal to some other binding plus a constant, or
// - unconstrained, and free to take on any value.
//
@@ -168,42 +168,42 @@ class Label {
// refer to another, so bindings and labels form trees whose leaves
// are labels, whose interior nodes (and roots) are bindings, and
// where links point from children to parents. Bindings are
// reference counted, allowing labels to be lightweight, copyable,
// assignable, placed in containers, and so on.
class Binding {
public:
Binding();
- Binding(u_int64_t addend);
+ Binding(uint64_t addend);
~Binding();
// Increment our reference count.
void Acquire() { reference_count_++; };
// Decrement our reference count, and return true if it is zero.
bool Release() { return --reference_count_ == 0; }
// Set this binding to be equal to BINDING + ADDEND. If BINDING is
// NULL, then set this binding to the known constant ADDEND.
// Update every binding on this binding's chain to point directly
// to BINDING, or to be a constant, with addends adjusted
// appropriately.
- void Set(Binding *binding, u_int64_t value);
+ void Set(Binding *binding, uint64_t value);
// Return what we know about the value of this binding.
// - If this binding's value is a known constant, set BASE to
// NULL, and set ADDEND to its value.
// - If this binding is not a known constant but related to other
// bindings, set BASE to the binding at the end of the relation
// chain (which will always be unconstrained), and set ADDEND to the
// value to add to that binding's value to get this binding's
// value.
// - If this binding is unconstrained, set BASE to this, and leave
// ADDEND unchanged.
- void Get(Binding **base, u_int64_t *addend);
+ void Get(Binding **base, uint64_t *addend);
private:
// There are three cases:
//
// - A binding representing a known constant value has base_ NULL,
// and addend_ equal to the value.
//
// - A binding representing a completely unconstrained value has
@@ -216,29 +216,29 @@ class Label {
// x = y+c.
//
// Thus, the bind_ links form a chain terminating in either a
// known constant value or a completely unconstrained value. Most
// operations on bindings do path compression: they change every
// binding on the chain to point directly to the final value,
// adjusting addends as appropriate.
Binding *base_;
- u_int64_t addend_;
+ uint64_t addend_;
// The number of Labels and Bindings pointing to this binding.
// (When a binding points to itself, indicating a completely
// unconstrained binding, that doesn't count as a reference.)
int reference_count_;
};
// This label's value.
Binding *value_;
};
-inline Label operator+(u_int64_t a, const Label &l) { return l + a; }
+inline Label operator+(uint64_t a, const Label &l) { return l + a; }
// Note that int-Label isn't defined, as negating a Label is not an
// operation we support.
// Conventions for representing larger numbers as sequences of bytes.
enum Endianness {
kBigEndian, // Big-endian: the most significant byte comes first.
kLittleEndian, // Little-endian: the least significant byte comes first.
kUnsetEndian, // used internally
@@ -283,36 +283,36 @@ class Section {
endianness_ = endianness;
}
// Return the default endianness of this section.
Endianness endianness() const { return endianness_; }
// Append the SIZE bytes at DATA or the contents of STRING to the
// end of this section. Return a reference to this section.
- Section &Append(const u_int8_t *data, size_t size) {
+ Section &Append(const uint8_t *data, size_t size) {
contents_.append(reinterpret_cast<const char *>(data), size);
return *this;
};
Section &Append(const string &data) {
contents_.append(data);
return *this;
};
// Append SIZE copies of BYTE to the end of this section. Return a
// reference to this section.
- Section &Append(size_t size, u_int8_t byte) {
+ Section &Append(size_t size, uint8_t byte) {
contents_.append(size, (char) byte);
return *this;
}
// Append NUMBER to this section. ENDIANNESS is the endianness to
// use to write the number. SIZE is the length of the number in
// bytes. Return a reference to this section.
- Section &Append(Endianness endianness, size_t size, u_int64_t number);
+ Section &Append(Endianness endianness, size_t size, uint64_t number);
Section &Append(Endianness endianness, size_t size, const Label &label);
// Append SECTION to the end of this section. The labels SECTION
// refers to need not be defined yet.
//
// Note that this has no effect on any Labels' values, or on
// SECTION. If placing SECTION within 'this' provides new
// constraints on existing labels' values, then it's up to the
@@ -347,22 +347,22 @@ class Section {
//
// Since endianness doesn't matter for a single byte, all the
// <BITWIDTH>=8 functions are equivalent.
//
// These can be used to write both signed and unsigned values, as
// the compiler will properly sign-extend a signed value before
// passing it to the function, at which point the function's
// behavior is the same either way.
- Section &L8(u_int8_t value) { contents_ += value; return *this; }
- Section &B8(u_int8_t value) { contents_ += value; return *this; }
- Section &D8(u_int8_t value) { contents_ += value; return *this; }
- Section &L16(u_int16_t), &L32(u_int32_t), &L64(u_int64_t),
- &B16(u_int16_t), &B32(u_int32_t), &B64(u_int64_t),
- &D16(u_int16_t), &D32(u_int32_t), &D64(u_int64_t);
+ Section &L8(uint8_t value) { contents_ += value; return *this; }
+ Section &B8(uint8_t value) { contents_ += value; return *this; }
+ Section &D8(uint8_t value) { contents_ += value; return *this; }
+ Section &L16(uint16_t), &L32(uint32_t), &L64(uint64_t),
+ &B16(uint16_t), &B32(uint32_t), &B64(uint64_t),
+ &D16(uint16_t), &D32(uint32_t), &D64(uint64_t);
Section &L8(const Label &label), &L16(const Label &label),
&L32(const Label &label), &L64(const Label &label),
&B8(const Label &label), &B16(const Label &label),
&B32(const Label &label), &B64(const Label &label),
&D8(const Label &label), &D16(const Label &label),
&D32(const Label &label), &D64(const Label &label);
// Append VALUE in a signed LEB128 (Little-Endian Base 128) form.
@@ -394,23 +394,23 @@ class Section {
// representation is a single byte whose value is N.
//
// - Otherwise, its unsigned LEB128 representation is (N & 0x7f) |
// 0x80, followed by the unsigned LEB128 representation of N /
// 128, rounded towards negative infinity.
//
// Note that VALUE cannot be a Label (we would have to implement
// relaxation).
- Section &ULEB128(u_int64_t value);
+ Section &ULEB128(uint64_t value);
// Jump to the next location aligned on an ALIGNMENT-byte boundary,
// relative to the start of the section. Fill the gap with PAD_BYTE.
// ALIGNMENT must be a power of two. Return a reference to this
// section.
- Section &Align(size_t alignment, u_int8_t pad_byte = 0);
+ Section &Align(size_t alignment, uint8_t pad_byte = 0);
// Clear the contents of this section.
void Clear();
// Return the current size of the section.
size_t Size() const { return contents_.size(); }
// Return a label representing the start of the section.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1004:630ec63f810e-tainted