2 // { dg-require-effective-target fpic }
3 // { dg-require-visibility "" }
4 // { dg-options "-fPIC" }
7 typedef __SIZE_TYPE__ size_t;
10 throw () __attribute__ ((__malloc__));
11 namespace std __attribute__ ((__visibility__ ("default")))
16 new (std::size_t, void *__p)
21 template < class _T1, class _T2 > struct pair
25 pair (const _T1 & __a, const _T2 & __b):first (__a), second (__b)
28 template < class _U1, class _U2 >
29 pair (const pair < _U1, _U2 > &__p):first (__p.first), second (__p.second)
34 template < class _T1, class _T2 >
35 inline pair < _T1, _T2 > make_pair (_T1 __x, _T2 __y)
37 return pair < _T1, _T2 > (__x, __y);
39 template < typename _Tp > inline const _Tp &
40 max (const _Tp & __a, const _Tp & __b)
43 typedef unsigned short int uint16_t;
44 typedef unsigned long int uintptr_t;
45 typedef uint16_t UChar;
46 namespace std __attribute__ ((__visibility__ ("default")))
48 struct __numeric_limits_base
51 template < typename _Tp > struct numeric_limits:public __numeric_limits_base
53 static _Tp max () throw ()
59 template < typename T > class VectorBufferBase
62 void allocateBuffer (size_t newCapacity)
64 if (newCapacity > std::numeric_limits < size_t >::max () / sizeof (T))
65 *(int *) (uintptr_t) 0xbbadbeef = 0;
69 template < typename T, size_t inlineCapacity > class VectorBuffer;
70 template < typename T > class VectorBuffer < T, 0 >:private VectorBufferBase <
74 typedef VectorBufferBase < T > Base;
75 using Base::allocateBuffer;
78 template < typename T, size_t inlineCapacity = 0 > class Vector
80 typedef VectorBuffer < T, inlineCapacity > Impl;
87 size_t capacity () const
95 return begin () + m_size;
97 void shrink (size_t size);
98 void reserveCapacity (size_t newCapacity);
103 template < typename U > void append (const U &);
104 void expandCapacity (size_t newMinCapacity);
105 template < typename U > U * expandCapacity (size_t newMinCapacity, U *);
109 template < typename T, size_t inlineCapacity >
110 void Vector < T, inlineCapacity >::expandCapacity (size_t newMinCapacity)
114 max (static_cast < size_t > (16),
115 capacity () + capacity () / 4 + 1)));
118 template < typename T, size_t inlineCapacity >
119 template < typename U >
120 inline U * Vector < T,
121 inlineCapacity >::expandCapacity (size_t newMinCapacity, U * ptr)
123 expandCapacity (newMinCapacity);
125 template < typename T, size_t inlineCapacity >
126 void Vector < T, inlineCapacity >::reserveCapacity (size_t newCapacity)
128 m_impl.allocateBuffer (newCapacity);
130 template < typename T, size_t inlineCapacity >
131 template < typename U >
132 inline void Vector < T, inlineCapacity >::append (const U & val)
135 if (size () == capacity ())
136 ptr = expandCapacity (size () + 1, ptr);
137 new (end ())T (*ptr);
144 explicit TextIterator (const Range *,
145 bool emitCharactersBetweenAllVisiblePositions =
156 plainTextToMallocAllocatedBuffer (const Range * r, unsigned &bufferLength)
158 static const unsigned cMaxSegmentSize = 1 << 16;
159 typedef pair < UChar *, unsigned >TextSegment;
160 Vector < TextSegment > *textSegments = 0;
161 Vector < UChar > textBuffer;
162 for (TextIterator it (r); !it.atEnd (); it.advance ())
164 if (textBuffer.size ()
165 && textBuffer.size () + it.length () > cMaxSegmentSize)
167 UChar *newSegmentBuffer =
169 UChar * >(malloc (textBuffer.size () * sizeof (UChar)));
171 textSegments = new Vector < TextSegment >;
173 append (make_pair (newSegmentBuffer, textBuffer.size ()));