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 <
73 typedef VectorBufferBase < T > Base;
74 using Base::allocateBuffer;
77 template < typename T, size_t inlineCapacity = 0 > class Vector
79 typedef VectorBuffer < T, inlineCapacity > Impl;
86 size_t capacity () const
94 return begin () + m_size;
96 void shrink (size_t size);
97 void reserveCapacity (size_t newCapacity);
102 template < typename U > void append (const U &);
103 void expandCapacity (size_t newMinCapacity);
104 template < typename U > U * expandCapacity (size_t newMinCapacity, U *);
108 template < typename T, size_t inlineCapacity >
109 void Vector < T, inlineCapacity >::expandCapacity (size_t newMinCapacity)
113 max (static_cast < size_t > (16),
114 capacity () + capacity () / 4 + 1)));
117 template < typename T, size_t inlineCapacity >
118 template < typename U >
119 inline U * Vector < T,
120 inlineCapacity >::expandCapacity (size_t newMinCapacity, U * ptr)
122 expandCapacity (newMinCapacity);
124 template < typename T, size_t inlineCapacity >
125 void Vector < T, inlineCapacity >::reserveCapacity (size_t newCapacity)
127 m_impl.allocateBuffer (newCapacity);
129 template < typename T, size_t inlineCapacity >
130 template < typename U >
131 inline void Vector < T, inlineCapacity >::append (const U & val)
134 if (size () == capacity ())
135 ptr = expandCapacity (size () + 1, ptr);
136 new (end ())T (*ptr);
143 explicit TextIterator (const Range *,
144 bool emitCharactersBetweenAllVisiblePositions =
155 plainTextToMallocAllocatedBuffer (const Range * r, unsigned &bufferLength)
157 static const unsigned cMaxSegmentSize = 1 << 16;
158 typedef pair < UChar *, unsigned >TextSegment;
159 Vector < TextSegment > *textSegments = 0;
160 Vector < UChar > textBuffer;
161 for (TextIterator it (r); !it.atEnd (); it.advance ())
163 if (textBuffer.size ()
164 && textBuffer.size () + it.length () > cMaxSegmentSize)
166 UChar *newSegmentBuffer =
168 UChar * >(malloc (textBuffer.size () * sizeof (UChar)));
170 textSegments = new Vector < TextSegment >;
172 append (make_pair (newSegmentBuffer, textBuffer.size ()));