Skip to content

Commit

Permalink
Fix padding in vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Sep 25, 2024
1 parent 78446ca commit 530df3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/clasp/core/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class Array_O : public General_O {
/*! length() doesn't dispatch - it reaches into the subclass
through the _Length[0] array to read the first size_t element
which is the Length/FillPointer for vectors and a Dummy value for arrays */
virtual size_t length() const { return this->_Length[0]; };
size_t length() const { return this->_Length[0]; };
virtual bool equal(T_sp other) const override = 0;
virtual bool equalp(T_sp other) const override = 0;
virtual size_t arrayTotalSize() const = 0;
Expand Down
2 changes: 0 additions & 2 deletions include/clasp/core/array_long_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class SimpleVector_long_float_O : public specialized_SimpleVector_long_float {
public:
typedef specialized_SimpleVector_long_float TemplatedBase;

size_t length() const override { return this->_Data.length(); };

static value_type default_initial_element(void) { return long_float_t{0.0}; }
static value_type from_object(T_sp obj) { return core::Number_O::as_long_float(obj.as<Number_O>()); };
static T_sp to_object(const value_type& v) { return core::LongFloat_O::create(v); };
Expand Down
11 changes: 7 additions & 4 deletions include/clasp/gctools/gcarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ THE SOFTWARE.

namespace gctools {

template <class T> class GCArray_moveable : public GCContainer {
// The following class is packed to ensure that no padding is inserted
// before _MaybeSignedLength. Padding will break our non-virtual
// length method.
template <class T> class __attribute__((__packed__)) GCArray_moveable : public GCContainer {
public:
GCArray_moveable(){};
GCArray_moveable() {};

public:
typedef T value_type;
Expand Down Expand Up @@ -92,7 +95,7 @@ template <class T> class GCArray_moveable : public GCContainer {
// how C++ reference semantics work.
template <class T> class GCArray_atomic : public GCContainer {
public:
GCArray_atomic(){};
GCArray_atomic() {};

public:
int64_t _Length; // Index one beyond the total number of elements allocated
Expand Down Expand Up @@ -130,7 +133,7 @@ template <typename Array> void Array0_dump(const Array& v, const char* head = ""

template <class T> class GCArraySignedLength_moveable : public GCArray_moveable<T> {
public:
GCArraySignedLength_moveable(){};
GCArraySignedLength_moveable() {};

public:
GCArraySignedLength_moveable(int64_t length, const T& initialElement, bool initialElementSupplied, size_t initialContentsSize = 0,
Expand Down

0 comments on commit 530df3f

Please sign in to comment.