Previous 199869 Revisions Next

r40684 Saturday 12th September, 2015 at 08:22:55 UTC by Miodrag Milanović
Added latest BX (nw)
[3rdparty/bx/include/bx]allocator.h blockalloc.h bx.h config.h fpumath.h handlealloc.h hash.h macros.h os.h platform.h process.h* ringbuffer.h string.h thread.h uint32_t.h
[3rdparty/bx/include/compat/freebsd]signal.h*
[3rdparty/bx/include/compat/mingw]sal.h
[3rdparty/bx/include/tinystl]buffer.h vector.h
[3rdparty/bx/scripts]genie.lua toolchain.lua unittest++.lua
[3rdparty/bx/tests]handle.cpp* misc.cpp* uint32_t.cpp unordered_map_nonpod.cpp vector_complex.cpp vector_header.cpp vector_nocopy.cpp* vector_nodefault.cpp
[3rdparty/bx/tools/bin/darwin]genie
[3rdparty/bx/tools/bin/linux]genie
[3rdparty/bx/tools/bin/windows]genie.exe

trunk/3rdparty/bx/include/bx/allocator.h
r249195r249196
5858      return un.ptr;
5959   }
6060
61   /// Check if pointer is aligned. _align must be power of two.
62   inline bool isPtrAligned(const void* _ptr, size_t _align = BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT)
63   {
64      union { const void* ptr; size_t addr; } un;
65      un.ptr = _ptr;
66      return 0 == (un.addr & (_align-1) );
67   }
68
6961   struct BX_NO_VTABLE AllocatorI
7062   {
7163      virtual ~AllocatorI() = 0;
trunk/3rdparty/bx/include/bx/blockalloc.h
r249195r249196
1/*
2 * Copyright 2010-2015 Branimir Karadzic. All rights reserved.
3 * License: http://www.opensource.org/licenses/BSD-2-Clause
4 */
5
6#ifndef BX_BLOCKALLOC_H_HEADER_GUARD
7#define BX_BLOCKALLOC_H_HEADER_GUARD
8
9#include "bx.h"
10
11namespace bx
12{
13   class BlockAlloc
14   {
15   public:
16      static const uint16_t invalidIndex = 0xffff;
17      static const uint32_t minElementSize = 2;
18
19      BlockAlloc()
20         : m_data(NULL)
21         , m_num(0)
22         , m_size(0)
23         , m_numFree(0)
24         , m_freeIndex(invalidIndex)
25      {
26      }
27
28      BlockAlloc(void* _data, uint16_t _num, uint16_t _size)
29         : m_data(_data)
30         , m_num(_num)
31         , m_size(_size)
32         , m_numFree(_num)
33         , m_freeIndex(0)
34      {
35         char* data = (char*)_data;
36         uint16_t* index = (uint16_t*)_data;
37         for (uint16_t ii = 0; ii < m_num-1; ++ii)
38         {
39            *index = ii+1;
40            data += m_size;
41            index = (uint16_t*)data;
42         }
43         *index = invalidIndex;
44      }
45
46      ~BlockAlloc()
47      {
48      }
49
50      void* alloc()
51      {
52         if (invalidIndex == m_freeIndex)
53         {
54            return NULL;
55         }
56
57         void* obj = ( (char*)m_data) + m_freeIndex*m_size;
58         m_freeIndex = *( (uint16_t*)obj);
59         --m_numFree;
60
61         return obj;
62      }
63
64      void free(void* _obj)
65      {
66         uint16_t index = getIndex(_obj);
67         BX_CHECK(index < m_num, "index %d, m_num %d", index, m_num);
68
69         *( (uint16_t*)_obj) = m_freeIndex;
70         m_freeIndex = index;
71         ++m_numFree;
72      }
73
74      uint16_t getIndex(void* _obj) const
75      {
76         return (uint16_t)( ( (char*)_obj - (char*)m_data ) / m_size);
77      }
78
79      uint16_t getNumFree() const
80      {
81         return m_numFree;
82      }
83
84      void* getFromIndex(uint16_t _index)
85      {
86         return (char*)m_data + _index*m_size;
87      }
88
89   private:
90      void* m_data;
91      uint16_t m_num;
92      uint16_t m_size;
93      uint16_t m_numFree;
94      uint16_t m_freeIndex;
95   };
96
97} // namespace bx
98
99#endif // BX_BLOCKALLOC_H_HEADER_GUARD
trunk/3rdparty/bx/include/bx/bx.h
r249195r249196
4444      Ty tmp = _a; _a = _b; _b = tmp;
4545   }
4646
47   /// Check if pointer is aligned. _align must be power of two.
48   inline bool isPtrAligned(const void* _ptr, size_t _align)
49   {
50      union { const void* ptr; size_t addr; } un;
51      un.ptr = _ptr;
52      return 0 == (un.addr & (_align-1) );
53   }
54
4755} // namespace bx
4856
4957// Annoying C++0x stuff..
trunk/3rdparty/bx/include/bx/config.h
r249195r249196
2424#   define BX_CONFIG_CRT_FILE_READER_WRITER (0 \
2525            || BX_PLATFORM_ANDROID \
2626            || BX_PLATFORM_FREEBSD \
27            || BX_PLATFORM_EMSCRIPTEN \
2728            || BX_PLATFORM_IOS \
2829            || BX_PLATFORM_LINUX \
2930            || BX_PLATFORM_OSX \
trunk/3rdparty/bx/include/bx/fpumath.h
r249195r249196
3131
3232   inline float fround(float _f)
3333   {
34      return float(int(_f) );
34      return floorf(_f + 0.5f);
3535   }
3636
3737   inline float fmin(float _a, float _b)
r249195r249196
121121      return result;
122122   }
123123
124   // References:
125   //  - Bias And Gain Are Your Friend
126   //    http://blog.demofox.org/2012/09/24/bias-and-gain-are-your-friend/
127   //  - http://demofox.org/biasgain.html
128   inline float fbias(float _time, float _bias)
129   {
130      return _time / ( ( (1.0f/_bias - 2.0f)*(1.0f - _time) ) + 1.0f);
131   }
132
133   inline float fgain(float _time, float _gain)
134   {
135      if (_time < 0.5f)
136      {
137         return fbias(_time * 2.0f, _gain) * 0.5f;
138      }
139
140      return fbias(_time * 2.0f - 1.0f, 1.0f - _gain) * 0.5f + 0.5f;
141   }
142
124143   inline void vec3Move(float* __restrict _result, const float* __restrict _a)
125144   {
126145      _result[0] = _a[0];
r249195r249196
833852      _result[3] = -vec3Dot(normal, _va);
834853   }
835854
855   inline void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints)
856   {
857      float sumX  = 0.0f;
858      float sumY  = 0.0f;
859      float sumXX = 0.0f;
860      float sumXY = 0.0f;
861
862      const uint8_t* ptr = (const uint8_t*)_points;
863      for (uint32_t ii = 0; ii < _numPoints; ++ii, ptr += _stride)
864      {
865         const float* point = (const float*)ptr;
866         float xx = point[0];
867         float yy = point[1];
868         sumX  += xx;
869         sumY  += yy;
870         sumXX += xx*xx;
871         sumXY += xx*yy;
872      }
873
874      // [ sum(x^2) sum(x)    ] [ A ] = [ sum(x*y) ]
875      // [ sum(x)   numPoints ] [ B ]   [ sum(y)   ]
876
877      float det = (sumXX*_numPoints - sumX*sumX);
878      float invDet = 1.0f/det;
879
880      _result[0] = (-sumX * sumY + _numPoints * sumXY) * invDet;
881      _result[1] = (sumXX * sumY - sumX       * sumXY) * invDet;
882   }
883
884   inline void calcLinearFit3D(float _result[3], const void* _points, uint32_t _stride, uint32_t _numPoints)
885   {
886      float sumX  = 0.0f;
887      float sumY  = 0.0f;
888      float sumZ  = 0.0f;
889      float sumXX = 0.0f;
890      float sumXY = 0.0f;
891      float sumXZ = 0.0f;
892      float sumYY = 0.0f;
893      float sumYZ = 0.0f;
894
895      const uint8_t* ptr = (const uint8_t*)_points;
896      for (uint32_t ii = 0; ii < _numPoints; ++ii, ptr += _stride)
897      {
898         const float* point = (const float*)ptr;
899         float xx = point[0];
900         float yy = point[1];
901         float zz = point[2];
902
903         sumX  += xx;
904         sumY  += yy;
905         sumZ  += zz;
906         sumXX += xx*xx;
907         sumXY += xx*yy;
908         sumXZ += xx*zz;
909         sumYY += yy*yy;
910         sumYZ += yy*zz;
911      }
912
913      // [ sum(x^2) sum(x*y) sum(x)    ] [ A ]   [ sum(x*z) ]
914      // [ sum(x*y) sum(y^2) sum(y)    ] [ B ] = [ sum(y*z) ]
915      // [ sum(x)   sum(y)   numPoints ] [ C ]   [ sum(z)   ]
916
917      float mtx[9] =
918      {
919         sumXX, sumXY, sumX,
920         sumXY, sumYY, sumY,
921         sumX,  sumY,  float(_numPoints),
922      };
923      float invMtx[9];
924      mtx3Inverse(invMtx, mtx);
925
926      _result[0] = invMtx[0]*sumXZ + invMtx[1]*sumYZ + invMtx[2]*sumZ;
927      _result[1] = invMtx[3]*sumXZ + invMtx[4]*sumYZ + invMtx[5]*sumZ;
928      _result[2] = invMtx[6]*sumXZ + invMtx[7]*sumYZ + invMtx[8]*sumZ;
929   }
930
836931   inline void rgbToHsv(float _hsv[3], const float _rgb[3])
837932   {
838933      const float rr = _rgb[0];
trunk/3rdparty/bx/include/bx/handlealloc.h
r249195r249196
1111
1212namespace bx
1313{
14   template <uint16_t MaxHandlesT>
15   class HandleAllocT
14   class HandleAlloc
1615   {
1716   public:
18      static const uint16_t invalid = 0xffff;
17      static const uint16_t invalid = UINT16_MAX;
1918
20      HandleAllocT()
19      HandleAlloc(uint16_t _maxHandles)
2120         : m_numHandles(0)
21         , m_maxHandles(_maxHandles)
2222      {
23         for (uint16_t ii = 0; ii < MaxHandlesT; ++ii)
24         {
25            m_handles[ii] = ii;
26         }
23         reset();
2724      }
2825
29      ~HandleAllocT()
26      ~HandleAlloc()
3027      {
3128      }
3229
3330      const uint16_t* getHandles() const
3431      {
35         return m_handles;
32         return getDensePtr();
3633      }
3734
3835      uint16_t getHandleAt(uint16_t _at) const
3936      {
40         return m_handles[_at];
37         return getDensePtr()[_at];
4138      }
4239
4340      uint16_t getNumHandles() const
r249195r249196
4744
4845      uint16_t getMaxHandles() const
4946      {
50         return MaxHandlesT;
47         return m_maxHandles;
5148      }
5249
5350      uint16_t alloc()
5451      {
55         if (m_numHandles < MaxHandlesT)
52         if (m_numHandles < m_maxHandles)
5653         {
5754            uint16_t index = m_numHandles;
5855            ++m_numHandles;
5956
60            uint16_t handle = m_handles[index];
61            uint16_t* sparse = &m_handles[MaxHandlesT];
57            uint16_t* dense  = getDensePtr();
58            uint16_t  handle = dense[index];
59            uint16_t* sparse = getSparsePtr();
6260            sparse[handle] = index;
6361            return handle;
6462         }
r249195r249196
6664         return invalid;
6765      }
6866
69      bool isValid(uint16_t _handle)
67      bool isValid(uint16_t _handle) const
7068      {
71         uint16_t* sparse = &m_handles[MaxHandlesT];
72         uint16_t index = sparse[_handle];
69         uint16_t* dense  = getDensePtr();
70         uint16_t* sparse = getSparsePtr();
71         uint16_t  index  = sparse[_handle];
7372
7473         return index < m_numHandles
75            && m_handles[index] == _handle
74            && dense[index] == _handle
7675            ;
7776      }
7877
7978      void free(uint16_t _handle)
8079      {
81         BX_CHECK(0 < m_numHandles, "Freeing invalid handle %d.", _handle);
82         uint16_t* sparse = &m_handles[MaxHandlesT];
80         uint16_t* dense  = getDensePtr();
81         uint16_t* sparse = getSparsePtr();
8382         uint16_t index = sparse[_handle];
8483         --m_numHandles;
85         uint16_t temp = m_handles[m_numHandles];
86         m_handles[m_numHandles] = _handle;
84         uint16_t temp = dense[m_numHandles];
85         dense[m_numHandles] = _handle;
8786         sparse[temp] = index;
88         m_handles[index] = temp;
87         dense[index] = temp;
8988      }
9089
90      void reset()
91      {
92         m_numHandles = 0;
93         uint16_t* dense = getDensePtr();
94         for (uint16_t ii = 0, num = m_maxHandles; ii < num; ++ii)
95         {
96            dense[ii] = ii;
97         }
98      }
99
91100   private:
92      uint16_t m_handles[MaxHandlesT*2];
101      HandleAlloc();
102
103      uint16_t* getDensePtr() const
104      {
105         uint8_t* ptr = (uint8_t*)reinterpret_cast<const uint8_t*>(this);
106         return (uint16_t*)&ptr[sizeof(HandleAlloc)];
107      }
108
109      uint16_t* getSparsePtr() const
110      {
111         return &getDensePtr()[m_maxHandles];
112      }
113
93114      uint16_t m_numHandles;
115      uint16_t m_maxHandles;
94116   };
95117
96   class HandleAlloc
118   inline HandleAlloc* createHandleAlloc(AllocatorI* _allocator, uint16_t _maxHandles)
97119   {
120      uint8_t* ptr = (uint8_t*)BX_ALLOC(_allocator, sizeof(HandleAlloc) + 2*_maxHandles*sizeof(uint16_t) );
121      return ::new (ptr) HandleAlloc(_maxHandles);
122   }
123
124   inline void destroyHandleAlloc(AllocatorI* _allocator, HandleAlloc* _handleAlloc)
125   {
126      _handleAlloc->~HandleAlloc();
127      BX_FREE(_allocator, _handleAlloc);
128   }
129
130   template <uint16_t MaxHandlesT>
131   class HandleAllocT : public HandleAlloc
132   {
98133   public:
99      static const uint16_t invalid = 0xffff;
134      HandleAllocT()
135         : HandleAlloc(MaxHandlesT)
136      {
137      }
100138
101      HandleAlloc(uint16_t _maxHandles, void* _handles)
102         : m_handles( (uint16_t*)_handles)
103         , m_numHandles(0)
104         , m_maxHandles(_maxHandles)
139      ~HandleAllocT()
105140      {
106         for (uint16_t ii = 0; ii < _maxHandles; ++ii)
141      }
142
143   private:
144      uint16_t m_padding[2*MaxHandlesT];
145   };
146
147   template <uint16_t MaxHandlesT>
148   class HandleListT
149   {
150   public:
151      static const uint16_t invalid = UINT16_MAX;
152
153      HandleListT()
154         : m_front(invalid)
155         , m_back(invalid)
156      {
157         reset();
158      }
159
160      void pushBack(uint16_t _handle)
161      {
162         insertAfter(m_back, _handle);
163      }
164
165      uint16_t popBack()
166      {
167         uint16_t last = invalid != m_back
168            ? m_back
169            : m_front
170            ;
171
172         if (invalid != last)
107173         {
108            m_handles[ii] = ii;
174            remove(last);
109175         }
176
177         return last;
110178      }
111179
112      ~HandleAlloc()
180      void pushFront(uint16_t _handle)
113181      {
182         insertBefore(m_front, _handle);
114183      }
115184
185      uint16_t popFront()
186      {
187         uint16_t front = m_front;
188
189         if (invalid != front)
190         {
191            remove(front);
192         }
193
194         return front;
195      }
196
197      uint16_t getFront() const
198      {
199         return m_front;
200      }
201
202      uint16_t getBack() const
203      {
204         return m_back;
205      }
206
207      uint16_t getNext(uint16_t _handle) const
208      {
209         BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
210         const Link& curr = m_links[_handle];
211         return curr.m_next;
212      }
213
214      uint16_t getPrev(uint16_t _handle) const
215      {
216         BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
217         const Link& curr = m_links[_handle];
218         return curr.m_prev;
219      }
220
221      void remove(uint16_t _handle)
222      {
223         BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
224         Link& curr = m_links[_handle];
225
226         if (invalid != curr.m_prev)
227         {
228            Link& prev  = m_links[curr.m_prev];
229            prev.m_next = curr.m_next;
230         }
231         else
232         {
233            m_front = curr.m_next;
234         }
235
236         if (invalid != curr.m_next)
237         {
238            Link& next  = m_links[curr.m_next];
239            next.m_prev = curr.m_prev;
240         }
241         else
242         {
243            m_back = curr.m_prev;
244         }
245
246         curr.m_prev = invalid;
247         curr.m_next = invalid;
248      }
249
250      void reset()
251      {
252         memset(m_links, 0xff, sizeof(m_links) );
253      }
254
255   private:
256      void insertBefore(int16_t _before, uint16_t _handle)
257      {
258         Link& curr = m_links[_handle];
259         curr.m_next = _before;
260
261         if (invalid != _before)
262         {
263            Link& link = m_links[_before];
264            if (invalid != link.m_prev)
265            {
266               Link& prev = m_links[link.m_prev];
267               prev.m_next = _handle;
268            }
269
270            curr.m_prev = link.m_prev;
271            link.m_prev = _handle;
272         }
273
274         updateFrontBack(_handle);
275      }
276
277      void insertAfter(uint16_t _after, uint16_t _handle)
278      {
279         Link& curr = m_links[_handle];
280         curr.m_prev = _after;
281
282         if (invalid != _after)
283         {
284            Link& link = m_links[_after];
285            if (invalid != link.m_next)
286            {
287               Link& next = m_links[link.m_next];
288               next.m_prev = _handle;
289            }
290
291            curr.m_next = link.m_next;
292            link.m_next = _handle;
293         }
294
295         updateFrontBack(_handle);
296      }
297
298      bool isValid(uint16_t _handle) const
299      {
300         return _handle < MaxHandlesT;
301      }
302
303      void updateFrontBack(uint16_t _handle)
304      {
305         Link& curr = m_links[_handle];
306
307         if (invalid == curr.m_prev)
308         {
309            m_front = _handle;
310         }
311
312         if (invalid == curr.m_next)
313         {
314            m_back = _handle;
315         }
316      }
317
318      uint16_t m_front;
319      uint16_t m_back;
320
321      struct Link
322      {
323         uint16_t m_prev;
324         uint16_t m_next;
325      };
326
327      Link m_links[MaxHandlesT];
328   };
329
330   template <uint16_t MaxHandlesT>
331   class HandleAllocLruT
332   {
333   public:
334      static const uint16_t invalid = UINT16_MAX;
335
336      HandleAllocLruT()
337      {
338         reset();
339      }
340
341      ~HandleAllocLruT()
342      {
343      }
344
116345      const uint16_t* getHandles() const
117346      {
118         return m_handles;
347         return m_alloc.getHandles();
119348      }
120349
121350      uint16_t getHandleAt(uint16_t _at) const
122351      {
123         return m_handles[_at];
352         return m_alloc.getHandleAt(_at);
124353      }
125354
126355      uint16_t getNumHandles() const
127356      {
128         return m_numHandles;
357         return m_alloc.getNumHandles();
129358      }
130359
131360      uint16_t getMaxHandles() const
132361      {
133         return m_maxHandles;
362         return m_alloc.getMaxHandles();
134363      }
135364
136365      uint16_t alloc()
137366      {
138         if (m_numHandles < m_maxHandles)
367         uint16_t handle = m_alloc.alloc();
368         if (invalid != handle)
139369         {
140            uint16_t index = m_numHandles;
141            ++m_numHandles;
142
143            uint16_t handle = m_handles[index];
144            uint16_t* sparse = &m_handles[m_maxHandles];
145            sparse[handle] = index;
146            return handle;
370            m_list.pushFront(handle);
147371         }
372         return handle;
373      }
148374
149         return invalid;
375      bool isValid(uint16_t _handle) const
376      {
377         return m_alloc.isValid(_handle);
150378      }
151379
152      bool isValid(uint16_t _handle)
380      void free(uint16_t _handle)
153381      {
154         uint16_t* sparse = &m_handles[m_maxHandles];
155         uint16_t index = sparse[_handle];
382         BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
383         m_list.remove(_handle);
384         m_alloc.free(_handle);
385      }
156386
157         return (index < m_numHandles && m_handles[index] == _handle);
387      void touch(uint16_t _handle)
388      {
389         BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
390         m_list.remove(_handle);
391         m_list.pushFront(_handle);
158392      }
159393
160      void free(uint16_t _handle)
394      uint16_t getFront() const
161395      {
162         uint16_t* sparse = &m_handles[m_maxHandles];
163         uint16_t index = sparse[_handle];
164         --m_numHandles;
165         uint16_t temp = m_handles[m_numHandles];
166         m_handles[m_numHandles] = _handle;
167         sparse[temp] = index;
168         m_handles[index] = temp;
396         return m_list.getFront();
169397      }
170398
399      uint16_t getBack() const
400      {
401         return m_list.getBack();
402      }
403
404      uint16_t getNext(uint16_t _handle) const
405      {
406         return m_list.getNext(_handle);
407      }
408
409      uint16_t getPrev(uint16_t _handle) const
410      {
411         return m_list.getPrev(_handle);
412      }
413
414      void reset()
415      {
416         m_list.reset();
417         m_alloc.reset();
418      }
419
171420   private:
172      uint16_t* m_handles;
173      uint16_t m_numHandles;
174      uint16_t m_maxHandles;
421      HandleListT<MaxHandlesT>  m_list;
422      HandleAllocT<MaxHandlesT> m_alloc;
175423   };
176424
177   inline HandleAlloc* createHandleAlloc(AllocatorI* _allocator, uint16_t _maxHandles)
178   {
179      uint8_t* ptr = (uint8_t*)BX_ALLOC(_allocator, sizeof(HandleAlloc) + 2*_maxHandles*sizeof(uint16_t) );
180      return ::new (ptr) HandleAlloc(_maxHandles, &ptr[sizeof(HandleAlloc)]);
181   }
182
183   inline void destroyHandleAlloc(AllocatorI* _allocator, HandleAlloc* _handleAlloc)
184   {
185      _handleAlloc->~HandleAlloc();
186      BX_FREE(_allocator, _handleAlloc);
187   }
188
189425} // namespace bx
190426
191427#endif // BX_HANDLE_ALLOC_H_HEADER_GUARD
trunk/3rdparty/bx/include/bx/hash.h
r249195r249196
3030
3131      void add(const void* _data, int _len)
3232      {
33         const uint8_t* data = (uint8_t*)_data;
33         if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN)
34         &&  BX_UNLIKELY(!isPtrAligned(_data, 4) ) )
35         {
36            addUnaligned(_data, _len);
37            return;
38         }
39
40         addAligned(_data, _len);
41      }
42
43      void addAligned(const void* _data, int _len)
44      {
45         const uint8_t* data = (const uint8_t*)_data;
3446         m_size += _len;
3547
3648         mixTail(data, _len);
r249195r249196
4860         mixTail(data, _len);
4961      }
5062
63      void addUnaligned(const void* _data, int _len)
64      {
65         const uint8_t* data = (const uint8_t*)_data;
66         m_size += _len;
67
68         mixTail(data, _len);
69
70         while(_len >= 4)
71         {
72            uint32_t kk;
73            readUnaligned(data, kk);
74
75            mmix(m_hash, kk);
76
77            data += 4;
78            _len -= 4;
79         }
80
81         mixTail(data, _len);
82      }
83
5184      template<typename Ty>
5285      void add(Ty _value)
5386      {
r249195r249196
67100      }
68101
69102   private:
103      static void readUnaligned(const void* _data, uint32_t& _out)
104      {
105         const uint8_t* data = (const uint8_t*)_data;
106         if (BX_ENABLED(BX_CPU_ENDIAN_LITTLE) )
107         {
108            _out = 0
109               | data[0]<<24
110               | data[1]<<16
111               | data[2]<<8
112               | data[3]
113               ;
114         }
115         else
116         {
117            _out = 0
118               | data[0]
119               | data[1]<<8
120               | data[2]<<16
121               | data[3]<<24
122               ;
123         }
124      }
125
70126      void mixTail(const uint8_t*& _data, int& _len)
71127      {
72128         while( _len && ((_len<4) || m_count) )
trunk/3rdparty/bx/include/bx/macros.h
r249195r249196
5353#   define BX_ALLOW_UNUSED __attribute__( (unused) )
5454#   define BX_FORCE_INLINE __extension__ static __inline __attribute__( (__always_inline__) )
5555#   define BX_FUNCTION __PRETTY_FUNCTION__
56#   define BX_LIKELY(_x)   __builtin_expect(!!(_x), 1)
57#   define BX_UNLIKELY(_x) __builtin_expect(!!(_x), 0)
5658#   define BX_NO_INLINE __attribute__( (noinline) )
5759#   define BX_NO_RETURN __attribute__( (noreturn) )
5860#   define BX_NO_VTABLE
r249195r249196
6163#   if BX_COMPILER_CLANG && (BX_PLATFORM_OSX || BX_PLATFORM_IOS)
6264#      define BX_THREAD /* not supported right now */
6365#   else
64#      if (__GNUC__ == 4) && (__GNUC_MINOR__ <= 2)
65#         define BX_THREAD /* not supported right now */
66#      else
67#         define BX_THREAD __thread
68#      endif // __GNUC__ <= 4.2
66#      define BX_THREAD __thread
6967#   endif // BX_COMPILER_CLANG
7068#   define BX_ATTRIBUTE(_x) __attribute__( (_x) )
7169#   if BX_COMPILER_MSVC_COMPATIBLE
r249195r249196
7674#   define BX_ALLOW_UNUSED
7775#   define BX_FORCE_INLINE __forceinline
7876#   define BX_FUNCTION __FUNCTION__
77#   define BX_LIKELY(_x)   (_x)
78#   define BX_UNLIKELY(_x) (_x)
7979#   define BX_NO_INLINE __declspec(noinline)
8080#   define BX_NO_RETURN
8181#   define BX_NO_VTABLE __declspec(novtable)
trunk/3rdparty/bx/include/bx/os.h
r249195r249196
1111
1212#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
1313#   include <windows.h>
14#elif BX_PLATFORM_ANDROID \
14#   include <psapi.h>
15#elif  BX_PLATFORM_ANDROID \
1516   || BX_PLATFORM_EMSCRIPTEN \
1617   || BX_PLATFORM_FREEBSD \
1718   || BX_PLATFORM_IOS \
1819   || BX_PLATFORM_LINUX \
1920   || BX_PLATFORM_NACL \
20   || BX_PLATFORM_NETBSD \
2121   || BX_PLATFORM_OSX \
22   || BX_PLATFORM_PS4 \
2223   || BX_PLATFORM_RPI
2324
2425#   include <sched.h> // sched_yield
25#   if BX_PLATFORM_FREEBSD || BX_PLATFORM_IOS || BX_PLATFORM_NACL || BX_PLATFORM_NETBSD || BX_PLATFORM_OSX
26#   if BX_PLATFORM_FREEBSD \
27   || BX_PLATFORM_IOS \
28   || BX_PLATFORM_NACL \
29   || BX_PLATFORM_OSX \
30   || BX_PLATFORM_PS4
2631#      include <pthread.h> // mach_port_t
2732#   endif // BX_PLATFORM_IOS || BX_PLATFORM_OSX || BX_PLATFORM_NACL
2833
r249195r249196
3035#      include <sys/nacl_syscalls.h> // nanosleep
3136#   else
3237#      include <time.h> // nanosleep
33#      include <dlfcn.h> // dlopen, dlclose, dlsym
38#      if !BX_PLATFORM_PS4
39#         include <dlfcn.h> // dlopen, dlclose, dlsym
40#      endif // !BX_PLATFORM_PS4
3441#   endif // BX_PLATFORM_NACL
3542
36#   if BX_PLATFORM_LINUX || BX_PLATFORM_RPI
43#   if BX_PLATFORM_ANDROID
44#      include <malloc.h> // mallinfo
45#   elif BX_PLATFORM_LINUX || BX_PLATFORM_RPI
3746#      include <unistd.h> // syscall
3847#      include <sys/syscall.h>
39#   endif // BX_PLATFORM_LINUX || BX_PLATFORM_RPI
40
41#   if BX_PLATFORM_ANDROID
48#   elif BX_PLATFORM_OSX
49#      include <mach/mach.h> // mach_task_basic_info
50#   elif BX_PLATFORM_ANDROID
4251#      include "debug.h" // getTid is not implemented...
4352#   endif // BX_PLATFORM_ANDROID
4453#endif // BX_PLATFORM_
r249195r249196
94103      return (pid_t)::syscall(SYS_gettid);
95104#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
96105      return (mach_port_t)::pthread_mach_thread_np(pthread_self() );
97#elif BX_PLATFORM_FREEBSD || BX_PLATFORM_NACL || BX_PLATFORM_NETBSD
106#elif BX_PLATFORM_FREEBSD || BX_PLATFORM_NACL
98107      // Casting __nc_basic_thread_data*... need better way to do this.
99108      return *(uint32_t*)::pthread_self();
100109#else
r249195r249196
104113#endif //
105114   }
106115
116   inline size_t getProcessMemoryUsed()
117   {
118#if BX_PLATFORM_ANDROID
119      struct mallinfo mi = mallinfo();
120      return mi.uordblks;
121#elif BX_PLATFORM_LINUX
122      FILE* file = fopen("/proc/self/statm", "r");
123      if (NULL == file)
124      {
125         return 0;
126      }
127
128      long pages = 0;
129      int items = fscanf(file, "%*s%ld", &pages);
130      fclose(file);
131      return 1 == items
132         ? pages * sysconf(_SC_PAGESIZE)
133         : 0
134         ;
135#elif BX_PLATFORM_OSX
136      mach_task_basic_info info;
137      mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
138
139      int result = task_info(mach_task_self()
140            , MACH_TASK_BASIC_INFO
141            , (task_info_t)&info
142            , &infoCount
143            );
144      if (KERN_SUCCESS != result)
145      {
146         return 0;
147      }
148
149      return info.resident_size;
150#elif BX_PLATFORM_WINDOWS
151      PROCESS_MEMORY_COUNTERS pmc;
152      GetProcessMemoryInfo(GetCurrentProcess()
153         , &pmc
154         , sizeof(pmc)
155         );
156      return pmc.WorkingSetSize;
157#else
158      return 0;
159#endif // BX_PLATFORM_*
160   }
161
107162   inline void* dlopen(const char* _filePath)
108163   {
109164#if BX_PLATFORM_WINDOWS
110165      return (void*)::LoadLibraryA(_filePath);
111#elif BX_PLATFORM_NACL || BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_WINRT
166#elif  BX_PLATFORM_EMSCRIPTEN \
167   || BX_PLATFORM_NACL \
168   || BX_PLATFORM_PS4 \
169   || BX_PLATFORM_WINRT
112170      BX_UNUSED(_filePath);
113171      return NULL;
114172#else
r249195r249196
120178   {
121179#if BX_PLATFORM_WINDOWS
122180      ::FreeLibrary( (HMODULE)_handle);
123#elif BX_PLATFORM_NACL || BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_WINRT
181#elif  BX_PLATFORM_EMSCRIPTEN \
182   || BX_PLATFORM_NACL \
183   || BX_PLATFORM_PS4 \
184   || BX_PLATFORM_WINRT
124185      BX_UNUSED(_handle);
125186#else
126187      ::dlclose(_handle);
r249195r249196
131192   {
132193#if BX_PLATFORM_WINDOWS
133194      return (void*)::GetProcAddress( (HMODULE)_handle, _symbol);
134#elif BX_PLATFORM_NACL || BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_WINRT
195#elif  BX_PLATFORM_EMSCRIPTEN \
196   || BX_PLATFORM_NACL \
197   || BX_PLATFORM_PS4 \
198   || BX_PLATFORM_WINRT
135199      BX_UNUSED(_handle, _symbol);
136200      return NULL;
137201#else
r249195r249196
143207   {
144208#if BX_PLATFORM_WINDOWS
145209      ::SetEnvironmentVariableA(_name, _value);
146#elif BX_PLATFORM_WINRT
210#elif  BX_PLATFORM_PS4 \
211   || BX_PLATFORM_WINRT
147212      BX_UNUSED(_name, _value);
148213#else
149214      ::setenv(_name, _value, 1);
r249195r249196
154219   {
155220#if BX_PLATFORM_WINDOWS
156221      ::SetEnvironmentVariableA(_name, NULL);
157#elif BX_PLATFORM_WINRT
222#elif  BX_PLATFORM_PS4 \
223   || BX_PLATFORM_WINRT
158224      BX_UNUSED(_name);
159225#else
160226      ::unsetenv(_name);
r249195r249196
163229
164230   inline int chdir(const char* _path)
165231   {
166#if BX_PLATFORM_WINRT
232#if BX_PLATFORM_PS4 \
233 || BX_PLATFORM_WINRT
167234      BX_UNUSED(_path);
168235      return -1;
169236#elif BX_COMPILER_MSVC_COMPATIBLE
r249195r249196
175242
176243   inline char* pwd(char* _buffer, uint32_t _size)
177244   {
178#if BX_PLATFORM_WINRT
245#if BX_PLATFORM_PS4 \
246 || BX_PLATFORM_WINRT
179247      BX_UNUSED(_buffer, _size);
180248      return NULL;
181249#elif BX_COMPILER_MSVC_COMPATIBLE
trunk/3rdparty/bx/include/bx/platform.h
r249195r249196
1818#define BX_PLATFORM_IOS        0
1919#define BX_PLATFORM_LINUX      0
2020#define BX_PLATFORM_NACL       0
21#define BX_PLATFORM_NETBSD     0
2221#define BX_PLATFORM_OSX        0
2322#define BX_PLATFORM_PS4        0
2423#define BX_PLATFORM_QNX        0
r249195r249196
176175#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
177176#   undef  BX_PLATFORM_OSX
178177#   define BX_PLATFORM_OSX 1
179#elif defined(EMSCRIPTEN)
178#elif defined(__EMSCRIPTEN__)
180179#   undef  BX_PLATFORM_EMSCRIPTEN
181180#   define BX_PLATFORM_EMSCRIPTEN 1
182181#elif defined(__ORBIS__)
r249195r249196
188187#elif defined(__FreeBSD__)
189188#   undef  BX_PLATFORM_FREEBSD
190189#   define BX_PLATFORM_FREEBSD 1
191#elif defined(__NetBSD__)
192#   undef  BX_PLATFORM_NETBSD
193#   define BX_PLATFORM_NETBSD 1
194190#else
195191#   error "BX_PLATFORM_* is not defined!"
196192#endif //
r249195r249196
202198                  || BX_PLATFORM_IOS \
203199                  || BX_PLATFORM_LINUX \
204200                  || BX_PLATFORM_NACL \
205                  || BX_PLATFORM_NETBSD \
206201                  || BX_PLATFORM_OSX \
207202                  || BX_PLATFORM_QNX \
203                  || BX_PLATFORM_PS4 \
208204                  || BX_PLATFORM_RPI \
209205                  )
210206
r249195r249196
255251#elif BX_PLATFORM_NACL
256252#   define BX_PLATFORM_NAME "NaCl " \
257253            BX_STRINGIZE(BX_PLATFORM_NACL)
258#elif BX_PLATFORM_NETBSD
259#   define BX_PLATFORM_NAME "NetBSD"
260254#elif BX_PLATFORM_OSX
261255#   define BX_PLATFORM_NAME "OSX"
262256#elif BX_PLATFORM_PS4
trunk/3rdparty/bx/include/bx/process.h
r0r249196
1/*
2 * Copyright 2010-2015 Branimir Karadzic. All rights reserved.
3 * License: http://www.opensource.org/licenses/BSD-2-Clause
4 */
5
6#ifndef BX_PROCESS_H_HEADER_GUARD
7#define BX_PROCESS_H_HEADER_GUARD
8
9#include "string.h"
10#include "uint32_t.h"
11
12#if BX_PLATFORM_LINUX
13#   include <unistd.h>
14#endif // BX_PLATFORM_LINUX
15
16namespace bx
17{
18   ///
19   inline void* exec(const char* const* _argv)
20   {
21#if BX_PLATFORM_LINUX
22      pid_t pid = fork();
23
24      if (0 == pid)
25      {
26         int result = execvp(_argv[0], const_cast<char *const*>(&_argv[1]) );
27         BX_UNUSED(result);
28         return NULL;
29      }
30
31      return (void*)uintptr_t(pid);
32#elif BX_PLATFORM_WINDOWS
33      STARTUPINFO si;
34      memset(&si, 0, sizeof(STARTUPINFO) );
35      si.cb = sizeof(STARTUPINFO);
36
37      PROCESS_INFORMATION pi;
38      memset(&pi, 0, sizeof(PROCESS_INFORMATION) );
39
40      int32_t total = 0;
41      for (uint32_t ii = 0; NULL != _argv[ii]; ++ii)
42      {
43         total += (int32_t)strlen(_argv[ii]) + 1;
44      }
45
46      char* temp = (char*)alloca(total);
47      int32_t len = 0;
48      for(uint32_t ii = 0; NULL != _argv[ii]; ++ii)
49      {
50         len += snprintf(&temp[len], bx::uint32_imax(0, total-len)
51                  , "%s "
52                  , _argv[ii]
53                  );
54      }
55
56      bool ok = CreateProcessA(_argv[0]
57               , temp
58               , NULL
59               , NULL
60               , false
61               , 0
62               , NULL
63               , NULL
64               , &si
65               , &pi
66               );
67      if (ok)
68      {
69         return pi.hProcess;
70      }
71
72      return NULL;
73#else
74      return NULL;
75#endif // BX_PLATFORM_LINUX
76   }
77
78} // namespace bx
79
80#endif // BX_PROCESS_H_HEADER_GUARD
trunk/3rdparty/bx/include/bx/ringbuffer.h
r249195r249196
4040      uint32_t consume(uint32_t _size) // consumer only
4141      {
4242         const uint32_t maxSize    = distance(m_read, m_current);
43         const uint32_t sizeNoSign = uint32_and(_size, 0x7FFFFFFF);
43         const uint32_t sizeNoSign = uint32_and(_size, 0x7fffffff);
4444         const uint32_t test       = uint32_sub(sizeNoSign, maxSize);
4545         const uint32_t size       = uint32_sels(test, _size, maxSize);
4646         const uint32_t advance    = uint32_add(m_read, size);
r249195r249196
5353      {
5454         const uint32_t dist       = distance(m_write, m_read)-1;
5555         const uint32_t maxSize    = uint32_sels(dist, m_size-1, dist);
56         const uint32_t sizeNoSign = uint32_and(_size, 0x7FFFFFFF);
56         const uint32_t sizeNoSign = uint32_and(_size, 0x7fffffff);
5757         const uint32_t test       = uint32_sub(sizeNoSign, maxSize);
5858         const uint32_t size       = uint32_sels(test, _size, maxSize);
5959         const uint32_t advance    = uint32_add(m_write, size);
r249195r249196
6565      uint32_t commit(uint32_t _size) // producer only
6666      {
6767         const uint32_t maxSize    = distance(m_current, m_write);
68         const uint32_t sizeNoSign = uint32_and(_size, 0x7FFFFFFF);
68         const uint32_t sizeNoSign = uint32_and(_size, 0x7fffffff);
6969         const uint32_t test       = uint32_sub(sizeNoSign, maxSize);
7070         const uint32_t size       = uint32_sels(test, _size, maxSize);
7171         const uint32_t advance    = uint32_add(m_current, size);
r249195r249196
124124      uint32_t consume(uint32_t _size) // consumer only
125125      {
126126         const uint32_t maxSize    = distance(m_read, m_current);
127         const uint32_t sizeNoSign = uint32_and(_size, 0x7FFFFFFF);
127         const uint32_t sizeNoSign = uint32_and(_size, 0x7fffffff);
128128         const uint32_t test       = uint32_sub(sizeNoSign, maxSize);
129129         const uint32_t size       = uint32_sels(test, _size, maxSize);
130130         const uint32_t advance    = uint32_add(m_read, size);
r249195r249196
137137      {
138138         const uint32_t dist       = distance(m_write, m_read)-1;
139139         const uint32_t maxSize    = uint32_sels(dist, m_size-1, dist);
140         const uint32_t sizeNoSign = uint32_and(_size, 0x7FFFFFFF);
140         const uint32_t sizeNoSign = uint32_and(_size, 0x7fffffff);
141141         const uint32_t test       = uint32_sub(sizeNoSign, maxSize);
142142         const uint32_t size       = uint32_sels(test, _size, maxSize);
143143         const uint32_t advance    = uint32_add(m_write, size);
r249195r249196
149149      uint32_t commit(uint32_t _size) // producer only
150150      {
151151         const uint32_t maxSize    = distance(m_current, m_write);
152         const uint32_t sizeNoSign = uint32_and(_size, 0x7FFFFFFF);
152         const uint32_t sizeNoSign = uint32_and(_size, 0x7fffffff);
153153         const uint32_t test       = uint32_sub(sizeNoSign, maxSize);
154154         const uint32_t size       = uint32_sels(test, _size, maxSize);
155155         const uint32_t advance    = uint32_add(m_current, size);
trunk/3rdparty/bx/include/bx/string.h
r249195r249196
113113      return NULL;
114114   }
115115
116   /// Find substring in string. Case insensitive. Limit search to _size.
116   /// Find substring in string. Case insensitive. Limit search to _max.
117117   inline const char* stristr(const char* _str, const char* _find, size_t _max)
118118   {
119119      const char* ptr = _str;
120120
121      const size_t total = strlen(_str);
122      size_t len = _max < total ? _max : total;
121      size_t       stringLen = strnlen(_str, _max);
122      const size_t findLen   = strlen(_find);
123123
124      for (const size_t searchLen = strlen(_find); len >= searchLen; ++ptr, --len)
124      for (; stringLen >= findLen; ++ptr, --stringLen)
125125      {
126126         // Find start of the string.
127127         while (tolower(*ptr) != tolower(*_find) )
128128         {
129129            ++ptr;
130            --len;
130            --stringLen;
131131
132132            // Search pattern lenght can't be longer than the string.
133            if (searchLen > len)
133            if (findLen > stringLen)
134134            {
135135               return NULL;
136136            }
trunk/3rdparty/bx/include/bx/thread.h
r249195r249196
3131
3232   public:
3333      Thread()
34#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT
34#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
3535         : m_handle(INVALID_HANDLE_VALUE)
36         , m_threadId(UINT32_MAX)
3637#elif BX_PLATFORM_POSIX
3738         : m_handle(0)
3839#endif // BX_PLATFORM_
r249195r249196
5253         }
5354      }
5455
55      void init(ThreadFn _fn, void* _userData = NULL, uint32_t _stackSize = 0)
56      void init(ThreadFn _fn, void* _userData = NULL, uint32_t _stackSize = 0, const char* _name = NULL)
5657      {
5758         BX_CHECK(!m_running, "Already running!");
5859
r249195r249196
6162         m_stackSize = _stackSize;
6263         m_running = true;
6364
64#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360
65#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
6566         m_handle = CreateThread(NULL
6667            , m_stackSize
6768            , threadFunc
r249195r249196
102103#endif // BX_PLATFORM_
103104
104105         m_sem.wait();
106
107         if (NULL != _name)
108         {
109            setThreadName(_name);
110         }
105111      }
106112
107113      void shutdown()
108114      {
109115         BX_CHECK(m_running, "Not running!");
110#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360
116#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
111117         WaitForSingleObject(m_handle, INFINITE);
112118         GetExitCodeThread(m_handle, (DWORD*)&m_exitCode);
113119         CloseHandle(m_handle);
r249195r249196
139145         return m_exitCode;
140146      }
141147
148      void setThreadName(const char* _name)
149      {
150#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
151         pthread_setname_np(_name);
152#elif BX_PLATFORM_LINUX || BX_PLATFORM_FREEBSD
153         pthread_setname_np(m_handle, _name);
154#elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
155#   pragma pack(push, 8)
156         struct ThreadName
157         {
158            DWORD  type;
159            LPCSTR name;
160            DWORD  id;
161            DWORD  flags;
162         };
163#   pragma pack(pop)
164         ThreadName tn;
165         tn.type  = 0x1000;
166         tn.name  = _name;
167         tn.id    = m_threadId;
168         tn.flags = 0;
169
170         __try
171         {
172            RaiseException(0x406d1388
173               , 0
174               , sizeof(tn)/4
175               , reinterpret_cast<ULONG_PTR*>(&tn)
176               );
177         }
178         __except(EXCEPTION_EXECUTE_HANDLER)
179         {
180         }
181#else
182         BX_UNUSED(_name);
183#endif // BX_PLATFORM_
184      }
185
142186   private:
143187      int32_t entry()
144188      {
189#if BX_PLATFORM_WINDOWS
190         m_threadId = ::GetCurrentThreadId();
191#endif // BX_PLATFORM_WINDOWS
192
145193         m_sem.post();
146194         return m_fn(m_userData);
147195      }
148196
149#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT
197#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
150198      static DWORD WINAPI threadFunc(LPVOID _arg)
151199      {
152200         Thread* thread = (Thread*)_arg;
r249195r249196
167215      }
168216#endif // BX_PLATFORM_
169217
170#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT
218#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
171219      HANDLE m_handle;
220      DWORD  m_threadId;
172221#elif BX_PLATFORM_POSIX
173222      pthread_t m_handle;
174223#endif // BX_PLATFORM_
175224
176      ThreadFn m_fn;
177      void* m_userData;
225      ThreadFn  m_fn;
226      void*     m_userData;
178227      Semaphore m_sem;
179      uint32_t m_stackSize;
180      int32_t m_exitCode;
181      bool m_running;
228      uint32_t  m_stackSize;
229      int32_t   m_exitCode;
230      bool      m_running;
182231   };
183232
184233#if BX_PLATFORM_WINDOWS
trunk/3rdparty/bx/include/bx/uint32_t.h
r249195r249196
652652   inline uint64_t uint64_cntlz_ref(uint64_t _val)
653653   {
654654      return _val & UINT64_C(0xffffffff00000000)
655          ? uint32_cntlz(uint32_t(_val>>32) ) + 32
656          : uint32_cntlz(uint32_t(_val) )
655          ? uint32_cntlz(uint32_t(_val>>32) )
656          : uint32_cntlz(uint32_t(_val) ) + 32
657657          ;
658658   }
659659
trunk/3rdparty/bx/include/compat/freebsd/signal.h
r0r249196
1#include <sys/signal.h>
trunk/3rdparty/bx/include/compat/mingw/sal.h
r249195r249196
4242
4343#define __ecount(size)
4444#define __bcount(size)
45#define __in
45// #define __in // Conflicts with STL.
4646#define __in_ecount(size)
4747#define __in_bcount(size)
4848#define __in_z
r249195r249196
5252#define __in_ecount_nz(size)
5353#define __in_bcount_nz(size)
5454#define __in_xcount_opt(size)
55#define __out
55// #define __out // Conflicts with STL.
5656#define __out_ecount(size)
5757#define __out_bcount(size)
5858#define __out_ecount_part(size,length)
r249195r249196
246246#define __control_entrypoint(category)
247247#define __data_entrypoint(category)
248248
249#define _Always_(annos)
250#define _Analysis_noreturn_
251#define _Analysis_assume_(expr)
252#define _At_(target, annos)
253#define _At_buffer_(target, iter, bound, annos)
254#define _COM_Outptr_
255#define _COM_Outptr_opt_
256#define _COM_Outptr_opt_result_maybenull_
257#define _COM_Outptr_result_maybenull_
258#define _Check_return_
259#define _Const_
260#define _Deref2_pre_readonly_
261#define _Deref_in_bound_
262#define _Deref_in_range_(lb,ub)
263#define _Deref_inout_bound_
264#define _Deref_inout_z_
265#define _Deref_inout_z_bytecap_c_(size)
266#define _Deref_inout_z_cap_c_(size)
267#define _Deref_opt_out_
268#define _Deref_opt_out_opt_
269#define _Deref_opt_out_opt_z_
270#define _Deref_opt_out_z_
271#define _Deref_out_
272#define _Deref_out_bound_
273#define _Deref_out_opt_
274#define _Deref_out_opt_z_
275#define _Deref_out_range_(lb,ub)
276#define _Deref_out_z_
277#define _Deref_out_z_bytecap_c_(size)
278#define _Deref_out_z_cap_c_(size)
279#define _Deref_post_bytecap_(size)
280#define _Deref_post_bytecap_c_(size)
281#define _Deref_post_bytecap_x_(size)
282#define _Deref_post_bytecount_(size)
283#define _Deref_post_bytecount_c_(size)
284#define _Deref_post_bytecount_x_(size)
285#define _Deref_post_cap_(size)
286#define _Deref_post_cap_c_(size)
287#define _Deref_post_cap_x_(size)
288#define _Deref_post_count_(size)
289#define _Deref_post_count_c_(size)
290#define _Deref_post_count_x_(size)
291#define _Deref_post_maybenull_
292#define _Deref_post_notnull_
293#define _Deref_post_null_
294#define _Deref_post_opt_bytecap_(size)
295#define _Deref_post_opt_bytecap_c_(size)
296#define _Deref_post_opt_bytecap_x_(size)
297#define _Deref_post_opt_bytecount_(size)
298#define _Deref_post_opt_bytecount_c_(size)
299#define _Deref_post_opt_bytecount_x_(size)
300#define _Deref_post_opt_cap_(size)
301#define _Deref_post_opt_cap_c_(size)
302#define _Deref_post_opt_cap_x_(size)
303#define _Deref_post_opt_count_(size)
304#define _Deref_post_opt_count_c_(size)
305#define _Deref_post_opt_count_x_(size)
306#define _Deref_post_opt_valid_
307#define _Deref_post_opt_valid_bytecap_(size)
308#define _Deref_post_opt_valid_bytecap_c_(size)
309#define _Deref_post_opt_valid_bytecap_x_(size)
310#define _Deref_post_opt_valid_cap_(size)
311#define _Deref_post_opt_valid_cap_c_(size)
312#define _Deref_post_opt_valid_cap_x_(size)
313#define _Deref_post_opt_z_
314#define _Deref_post_opt_z_bytecap_(size)
315#define _Deref_post_opt_z_bytecap_c_(size)
316#define _Deref_post_opt_z_bytecap_x_(size)
317#define _Deref_post_opt_z_cap_(size)
318#define _Deref_post_opt_z_cap_c_(size)
319#define _Deref_post_opt_z_cap_x_(size)
320#define _Deref_post_valid_
321#define _Deref_post_valid_bytecap_(size)
322#define _Deref_post_valid_bytecap_c_(size)
323#define _Deref_post_valid_bytecap_x_(size)
324#define _Deref_post_valid_cap_(size)
325#define _Deref_post_valid_cap_c_(size)
326#define _Deref_post_valid_cap_x_(size)
327#define _Deref_post_z_
328#define _Deref_post_z_bytecap_(size)
329#define _Deref_post_z_bytecap_c_(size)
330#define _Deref_post_z_bytecap_x_(size)
331#define _Deref_post_z_cap_(size)
332#define _Deref_post_z_cap_c_(size)
333#define _Deref_post_z_cap_x_(size)
334#define _Deref_pre_bytecap_(size)
335#define _Deref_pre_bytecap_c_(size)
336#define _Deref_pre_bytecap_x_(size)
337#define _Deref_pre_bytecount_(size)
338#define _Deref_pre_bytecount_c_(size)
339#define _Deref_pre_bytecount_x_(size)
340#define _Deref_pre_cap_(size)
341#define _Deref_pre_cap_c_(size)
342#define _Deref_pre_cap_x_(size)
343#define _Deref_pre_count_(size)
344#define _Deref_pre_count_c_(size)
345#define _Deref_pre_count_x_(size)
346#define _Deref_pre_invalid_
347#define _Deref_pre_maybenull_
348#define _Deref_pre_notnull_
349#define _Deref_pre_null_
350#define _Deref_pre_opt_bytecap_(size)
351#define _Deref_pre_opt_bytecap_c_(size)
352#define _Deref_pre_opt_bytecap_x_(size)
353#define _Deref_pre_opt_bytecount_(size)
354#define _Deref_pre_opt_bytecount_c_(size)
355#define _Deref_pre_opt_bytecount_x_(size)
356#define _Deref_pre_opt_cap_(size)
357#define _Deref_pre_opt_cap_c_(size)
358#define _Deref_pre_opt_cap_x_(size)
359#define _Deref_pre_opt_count_(size)
360#define _Deref_pre_opt_count_c_(size)
361#define _Deref_pre_opt_count_x_(size)
362#define _Deref_pre_opt_valid_
363#define _Deref_pre_opt_valid_bytecap_(size)
364#define _Deref_pre_opt_valid_bytecap_c_(size)
365#define _Deref_pre_opt_valid_bytecap_x_(size)
366#define _Deref_pre_opt_valid_cap_(size)
367#define _Deref_pre_opt_valid_cap_c_(size)
368#define _Deref_pre_opt_valid_cap_x_(size)
369#define _Deref_pre_opt_z_
370#define _Deref_pre_opt_z_bytecap_(size)
371#define _Deref_pre_opt_z_bytecap_c_(size)
372#define _Deref_pre_opt_z_bytecap_x_(size)
373#define _Deref_pre_opt_z_cap_(size)
374#define _Deref_pre_opt_z_cap_c_(size)
375#define _Deref_pre_opt_z_cap_x_(size)
376#define _Deref_pre_readonly_
377#define _Deref_pre_valid_
378#define _Deref_pre_valid_bytecap_(size)
379#define _Deref_pre_valid_bytecap_c_(size)
380#define _Deref_pre_valid_bytecap_x_(size)
381#define _Deref_pre_valid_cap_(size)
382#define _Deref_pre_valid_cap_c_(size)
383#define _Deref_pre_valid_cap_x_(size)
384#define _Deref_pre_writeonly_
385#define _Deref_pre_z_
386#define _Deref_pre_z_bytecap_(size)
387#define _Deref_pre_z_bytecap_c_(size)
388#define _Deref_pre_z_bytecap_x_(size)
389#define _Deref_pre_z_cap_(size)
390#define _Deref_pre_z_cap_c_(size)
391#define _Deref_pre_z_cap_x_(size)
392#define _Deref_prepost_bytecap_(size)
393#define _Deref_prepost_bytecap_x_(size)
394#define _Deref_prepost_bytecount_(size)
395#define _Deref_prepost_bytecount_x_(size)
396#define _Deref_prepost_cap_(size)
397#define _Deref_prepost_cap_x_(size)
398#define _Deref_prepost_count_(size)
399#define _Deref_prepost_count_x_(size)
400#define _Deref_prepost_opt_bytecap_(size)
401#define _Deref_prepost_opt_bytecap_x_(size)
402#define _Deref_prepost_opt_bytecount_(size)
403#define _Deref_prepost_opt_bytecount_x_(size)
404#define _Deref_prepost_opt_cap_(size)
405#define _Deref_prepost_opt_cap_x_(size)
406#define _Deref_prepost_opt_count_(size)
407#define _Deref_prepost_opt_count_x_(size)
408#define _Deref_prepost_opt_valid_
409#define _Deref_prepost_opt_valid_bytecap_(size)
410#define _Deref_prepost_opt_valid_bytecap_x_(size)
411#define _Deref_prepost_opt_valid_cap_(size)
412#define _Deref_prepost_opt_valid_cap_x_(size)
413#define _Deref_prepost_opt_z_
414#define _Deref_prepost_opt_z_bytecap_(size)
415#define _Deref_prepost_opt_z_cap_(size)
416#define _Deref_prepost_valid_
417#define _Deref_prepost_valid_bytecap_(size)
418#define _Deref_prepost_valid_bytecap_x_(size)
419#define _Deref_prepost_valid_cap_(size)
420#define _Deref_prepost_valid_cap_x_(size)
421#define _Deref_prepost_z_
422#define _Deref_prepost_z_bytecap_(size)
423#define _Deref_prepost_z_cap_(size)
424#define _Deref_ret_bound_
425#define _Deref_ret_opt_z_
426#define _Deref_ret_range_(lb,ub)
427#define _Deref_ret_z_
428#define _Field_range_(min,max)
429#define _Field_size_(size)
430#define _Field_size_bytes_(size)
431#define _Field_size_bytes_full_(size)
432#define _Field_size_bytes_full_opt_(size)
433#define _Field_size_bytes_opt_(size)
434#define _Field_size_bytes_part_(size, count)
435#define _Field_size_bytes_part_opt_(size, count)
436#define _Field_size_full_(size)
437#define _Field_size_full_opt_(size)
438#define _Field_size_opt_(size)
439#define _Field_size_part_(size, count)
440#define _Field_size_part_opt_(size, count)
441#define _Field_z_
442#define _Function_class_(x)
443#define _Group_(annos)
444#define _In_
445#define _In_bound_
446#define _In_bytecount_(size)
447#define _In_bytecount_c_(size)
448#define _In_bytecount_x_(size)
449#define _In_count_(size)
450#define _In_count_c_(size)
451#define _In_count_x_(size)
452#define _In_defensive_(annotes)
453#define _In_opt_
454#define _In_opt_bytecount_(size)
455#define _In_opt_bytecount_c_(size)
456#define _In_opt_bytecount_x_(size)
457#define _In_opt_count_(size)
458#define _In_opt_count_c_(size)
459#define _In_opt_count_x_(size)
460#define _In_opt_ptrdiff_count_(size)
461#define _In_opt_z_
462#define _In_opt_z_bytecount_(size)
463#define _In_opt_z_bytecount_c_(size)
464#define _In_opt_z_count_(size)
465#define _In_opt_z_count_c_(size)
466#define _In_ptrdiff_count_(size)
467#define _In_range_(lb,ub)
468#define _In_reads_(size)
469#define _In_reads_bytes_(size)
470#define _In_reads_bytes_opt_(size)
471#define _In_reads_opt_(size)
472#define _In_reads_opt_z_(size)
473#define _In_reads_or_z_(size)
474#define _In_reads_to_ptr_(ptr)
475#define _In_reads_to_ptr_opt_(ptr)
476#define _In_reads_to_ptr_opt_z_(ptr)
477#define _In_reads_to_ptr_z_(ptr)
478#define _In_reads_z_(size)
479#define _In_z_
480#define _In_z_bytecount_(size)
481#define _In_z_bytecount_c_(size)
482#define _In_z_count_(size)
483#define _In_z_count_c_(size)
484#define _Inout_
485#define _Inout_bytecap_(size)
486#define _Inout_bytecap_c_(size)
487#define _Inout_bytecap_x_(size)
488#define _Inout_bytecount_(size)
489#define _Inout_bytecount_c_(size)
490#define _Inout_bytecount_x_(size)
491#define _Inout_cap_(size)
492#define _Inout_cap_c_(size)
493#define _Inout_cap_x_(size)
494#define _Inout_count_(size)
495#define _Inout_count_c_(size)
496#define _Inout_count_x_(size)
497#define _Inout_defensive_(annotes)
498#define _Inout_opt_
499#define _Inout_opt_bytecap_(size)
500#define _Inout_opt_bytecap_c_(size)
501#define _Inout_opt_bytecap_x_(size)
502#define _Inout_opt_bytecount_(size)
503#define _Inout_opt_bytecount_c_(size)
504#define _Inout_opt_bytecount_x_(size)
505#define _Inout_opt_cap_(size)
506#define _Inout_opt_cap_c_(size)
507#define _Inout_opt_cap_x_(size)
508#define _Inout_opt_count_(size)
509#define _Inout_opt_count_c_(size)
510#define _Inout_opt_count_x_(size)
511#define _Inout_opt_ptrdiff_count_(size)
512#define _Inout_opt_z_
513#define _Inout_opt_z_bytecap_(size)
514#define _Inout_opt_z_bytecap_c_(size)
515#define _Inout_opt_z_bytecap_x_(size)
516#define _Inout_opt_z_bytecount_(size)
517#define _Inout_opt_z_bytecount_c_(size)
518#define _Inout_opt_z_cap_(size)
519#define _Inout_opt_z_cap_c_(size)
520#define _Inout_opt_z_cap_x_(size)
521#define _Inout_opt_z_count_(size)
522#define _Inout_opt_z_count_c_(size)
523#define _Inout_ptrdiff_count_(size)
524#define _Inout_updates_(size)
525#define _Inout_updates_all_(size)
526#define _Inout_updates_all_opt_(size)
527#define _Inout_updates_bytes_(size)
528#define _Inout_updates_bytes_all_(size)
529#define _Inout_updates_bytes_all_opt_(size)
530#define _Inout_updates_bytes_opt_(size)
531#define _Inout_updates_bytes_to_(size,count)
532#define _Inout_updates_bytes_to_opt_(size,count)
533#define _Inout_updates_opt_(size)
534#define _Inout_updates_opt_z_(size)
535#define _Inout_updates_to_(size,count)
536#define _Inout_updates_to_opt_(size,count)
537#define _Inout_updates_z_(size)
538#define _Inout_z_
539#define _Inout_z_bytecap_(size)
540#define _Inout_z_bytecap_c_(size)
541#define _Inout_z_bytecap_x_(size)
542#define _Inout_z_bytecount_(size)
543#define _Inout_z_bytecount_c_(size)
544#define _Inout_z_cap_(size)
545#define _Inout_z_cap_c_(size)
546#define _Inout_z_cap_x_(size)
547#define _Inout_z_count_(size)
548#define _Inout_z_count_c_(size)
549#define _Interlocked_operand_
550#define _Literal_
551#define _Maybe_raises_SEH_exception
552#define _Maybe_raises_SEH_exception_
553#define _Maybenull_
554#define _Maybevalid_
555#define _Must_inspect_result_
556#define _Notliteral_
557#define _Notnull_
558#define _Notref_
559#define _Notvalid_
560#define _NullNull_terminated_
561#define _Null_
562#define _Null_terminated_
563#define _On_failure_(annos)
564#define _Out_
565#define _Out_bound_
566#define _Out_bytecap_(size)
567#define _Out_bytecap_c_(size)
568#define _Out_bytecap_post_bytecount_(cap,count)
569#define _Out_bytecap_x_(size)
570#define _Out_bytecapcount_(capcount)
571#define _Out_bytecapcount_x_(capcount)
572#define _Out_cap_(size)
573#define _Out_cap_c_(size)
574#define _Out_cap_m_(mult,size)
575#define _Out_cap_post_count_(cap,count)
576#define _Out_cap_x_(size)
577#define _Out_capcount_(capcount)
578#define _Out_capcount_x_(capcount)
579#define _Out_defensive_(annotes)
580#define _Out_opt_
581#define _Out_opt_bytecap_(size)
582#define _Out_opt_bytecap_c_(size)
583#define _Out_opt_bytecap_post_bytecount_(cap,count)
584#define _Out_opt_bytecap_x_(size)
585#define _Out_opt_bytecapcount_(capcount)
586#define _Out_opt_bytecapcount_x_(capcount)
587#define _Out_opt_cap_(size)
588#define _Out_opt_cap_c_(size)
589#define _Out_opt_cap_m_(mult,size)
590#define _Out_opt_cap_post_count_(cap,count)
591#define _Out_opt_cap_x_(size)
592#define _Out_opt_capcount_(capcount)
593#define _Out_opt_capcount_x_(capcount)
594#define _Out_opt_ptrdiff_cap_(size)
595#define _Out_opt_z_bytecap_(size)
596#define _Out_opt_z_bytecap_c_(size)
597#define _Out_opt_z_bytecap_post_bytecount_(cap,count)
598#define _Out_opt_z_bytecap_x_(size)
599#define _Out_opt_z_bytecapcount_(capcount)
600#define _Out_opt_z_cap_(size)
601#define _Out_opt_z_cap_c_(size)
602#define _Out_opt_z_cap_m_(mult,size)
603#define _Out_opt_z_cap_post_count_(cap,count)
604#define _Out_opt_z_cap_x_(size)
605#define _Out_opt_z_capcount_(capcount)
606#define _Out_ptrdiff_cap_(size)
607#define _Out_range_(lb,ub)
608#define _Out_writes_(size)
609#define _Out_writes_all_(size)
610#define _Out_writes_all_opt_(size)
611#define _Out_writes_bytes_(size)
612#define _Out_writes_bytes_all_(size)
613#define _Out_writes_bytes_all_opt_(size)
614#define _Out_writes_bytes_opt_(size)
615#define _Out_writes_bytes_to_(size,count)
616#define _Out_writes_bytes_to_opt_(size,count)
617#define _Out_writes_opt_(size)
618#define _Out_writes_opt_z_(size)
619#define _Out_writes_to_(size,count)
620#define _Out_writes_to_opt_(size,count)
621#define _Out_writes_to_ptr_(ptr)
622#define _Out_writes_to_ptr_opt_(ptr)
623#define _Out_writes_to_ptr_opt_z_(ptr)
624#define _Out_writes_to_ptr_z_(ptr)
625#define _Out_writes_z_(size)
626#define _Out_z_bytecap_(size)
627#define _Out_z_bytecap_c_(size)
628#define _Out_z_bytecap_post_bytecount_(cap,count)
629#define _Out_z_bytecap_x_(size)
630#define _Out_z_bytecapcount_(capcount)
631#define _Out_z_cap_(size)
632#define _Out_z_cap_c_(size)
633#define _Out_z_cap_m_(mult,size)
634#define _Out_z_cap_post_count_(cap,count)
635#define _Out_z_cap_x_(size)
636#define _Out_z_capcount_(capcount)
637#define _Outptr_
638#define _Outptr_opt_
639#define _Outptr_opt_result_buffer_(size)
640#define _Outptr_opt_result_buffer_all_(size)
641#define _Outptr_opt_result_buffer_all_maybenull_(size)
642#define _Outptr_opt_result_buffer_maybenull_(size)
643#define _Outptr_opt_result_buffer_to_(size, count)
644#define _Outptr_opt_result_buffer_to_maybenull_(size, count)
645#define _Outptr_opt_result_bytebuffer_(size)
646#define _Outptr_opt_result_bytebuffer_all_(size)
647#define _Outptr_opt_result_bytebuffer_all_maybenull_(size)
648#define _Outptr_opt_result_bytebuffer_maybenull_(size)
649#define _Outptr_opt_result_bytebuffer_to_(size, count)
650#define _Outptr_opt_result_bytebuffer_to_maybenull_(size, count)
651#define _Outptr_opt_result_maybenull_
652#define _Outptr_opt_result_maybenull_z_
653#define _Outptr_opt_result_nullonfailure_
654#define _Outptr_opt_result_z_
655#define _Outptr_result_buffer_(size)
656#define _Outptr_result_buffer_all_(size)
657#define _Outptr_result_buffer_all_maybenull_(size)
658#define _Outptr_result_buffer_maybenull_(size)
659#define _Outptr_result_buffer_to_(size, count)
660#define _Outptr_result_buffer_to_maybenull_(size, count)
661#define _Outptr_result_bytebuffer_(size)
662#define _Outptr_result_bytebuffer_all_(size)
663#define _Outptr_result_bytebuffer_all_maybenull_(size)
664#define _Outptr_result_bytebuffer_maybenull_(size)
665#define _Outptr_result_bytebuffer_to_(size, count)
666#define _Outptr_result_bytebuffer_to_maybenull_(size, count)
667#define _Outptr_result_maybenull_
668#define _Outptr_result_maybenull_z_
669#define _Outptr_result_nullonfailure_
670#define _Outptr_result_z_
671#define _Outref_
672#define _Outref_result_buffer_(size)
673#define _Outref_result_buffer_all_(size)
674#define _Outref_result_buffer_all_maybenull_(size)
675#define _Outref_result_buffer_maybenull_(size)
676#define _Outref_result_buffer_to_(size, count)
677#define _Outref_result_buffer_to_maybenull_(size, count)
678#define _Outref_result_bytebuffer_(size)
679#define _Outref_result_bytebuffer_all_(size)
680#define _Outref_result_bytebuffer_all_maybenull_(size)
681#define _Outref_result_bytebuffer_maybenull_(size)
682#define _Outref_result_bytebuffer_to_(size, count)
683#define _Outref_result_bytebuffer_to_maybenull_(size, count)
684#define _Outref_result_maybenull_
685#define _Outref_result_nullonfailure_
686#define _Points_to_data_
687#define _Post_
688#define _Post_bytecap_(size)
689#define _Post_bytecount_(size)
690#define _Post_bytecount_c_(size)
691#define _Post_bytecount_x_(size)
692#define _Post_cap_(size)
693#define _Post_count_(size)
694#define _Post_count_c_(size)
695#define _Post_count_x_(size)
696#define _Post_defensive_
697#define _Post_equal_to_(expr)
698#define _Post_invalid_
699#define _Post_maybenull_
700#define _Post_maybez_
701#define _Post_notnull_
702#define _Post_null_
703#define _Post_ptr_invalid_
704#define _Post_readable_byte_size_(size)
705#define _Post_readable_size_(size)
706#define _Post_satisfies_(cond)
707#define _Post_valid_
708#define _Post_writable_byte_size_(size)
709#define _Post_writable_size_(size)
710#define _Post_z_
711#define _Post_z_bytecount_(size)
712#define _Post_z_bytecount_c_(size)
713#define _Post_z_bytecount_x_(size)
714#define _Post_z_count_(size)
715#define _Post_z_count_c_(size)
716#define _Post_z_count_x_(size)
717#define _Pre_
718#define _Pre_bytecap_(size)
719#define _Pre_bytecap_c_(size)
720#define _Pre_bytecap_x_(size)
721#define _Pre_bytecount_(size)
722#define _Pre_bytecount_c_(size)
723#define _Pre_bytecount_x_(size)
724#define _Pre_cap_(size)
725#define _Pre_cap_c_(size)
726#define _Pre_cap_c_one_
727#define _Pre_cap_for_(param)
728#define _Pre_cap_m_(mult,size)
729#define _Pre_cap_x_(size)
730#define _Pre_count_(size)
731#define _Pre_count_c_(size)
732#define _Pre_count_x_(size)
733#define _Pre_defensive_
734#define _Pre_equal_to_(expr)
735#define _Pre_invalid_
736#define _Pre_maybenull_
737#define _Pre_notnull_
738#define _Pre_null_
739#define _Pre_opt_bytecap_(size)
740#define _Pre_opt_bytecap_c_(size)
741#define _Pre_opt_bytecap_x_(size)
742#define _Pre_opt_bytecount_(size)
743#define _Pre_opt_bytecount_c_(size)
744#define _Pre_opt_bytecount_x_(size)
745#define _Pre_opt_cap_(size)
746#define _Pre_opt_cap_c_(size)
747#define _Pre_opt_cap_c_one_
748#define _Pre_opt_cap_for_(param)
749#define _Pre_opt_cap_m_(mult,size)
750#define _Pre_opt_cap_x_(size)
751#define _Pre_opt_count_(size)
752#define _Pre_opt_count_c_(size)
753#define _Pre_opt_count_x_(size)
754#define _Pre_opt_ptrdiff_cap_(ptr)
755#define _Pre_opt_ptrdiff_count_(ptr)
756#define _Pre_opt_valid_
757#define _Pre_opt_valid_bytecap_(size)
758#define _Pre_opt_valid_bytecap_c_(size)
759#define _Pre_opt_valid_bytecap_x_(size)
760#define _Pre_opt_valid_cap_(size)
761#define _Pre_opt_valid_cap_c_(size)
762#define _Pre_opt_valid_cap_x_(size)
763#define _Pre_opt_z_
764#define _Pre_opt_z_bytecap_(size)
765#define _Pre_opt_z_bytecap_c_(size)
766#define _Pre_opt_z_bytecap_x_(size)
767#define _Pre_opt_z_cap_(size)
768#define _Pre_opt_z_cap_c_(size)
769#define _Pre_opt_z_cap_x_(size)
770#define _Pre_ptrdiff_cap_(ptr)
771#define _Pre_ptrdiff_count_(ptr)
772#define _Pre_readable_byte_size_(size)
773#define _Pre_readable_size_(size)
774#define _Pre_readonly_
775#define _Pre_satisfies_(cond)
776#define _Pre_valid_
777#define _Pre_valid_bytecap_(size)
778#define _Pre_valid_bytecap_c_(size)
779#define _Pre_valid_bytecap_x_(size)
780#define _Pre_valid_cap_(size)
781#define _Pre_valid_cap_c_(size)
782#define _Pre_valid_cap_x_(size)
783#define _Pre_writable_byte_size_(size)
784#define _Pre_writable_size_(size)
785#define _Pre_writeonly_
786#define _Pre_z_
787#define _Pre_z_bytecap_(size)
788#define _Pre_z_bytecap_c_(size)
789#define _Pre_z_bytecap_x_(size)
790#define _Pre_z_cap_(size)
791#define _Pre_z_cap_c_(size)
792#define _Pre_z_cap_x_(size)
793#define _Prepost_bytecount_(size)
794#define _Prepost_bytecount_c_(size)
795#define _Prepost_bytecount_x_(size)
796#define _Prepost_count_(size)
797#define _Prepost_count_c_(size)
798#define _Prepost_count_x_(size)
799#define _Prepost_opt_bytecount_(size)
800#define _Prepost_opt_bytecount_c_(size)
801#define _Prepost_opt_bytecount_x_(size)
802#define _Prepost_opt_count_(size)
803#define _Prepost_opt_count_c_(size)
804#define _Prepost_opt_count_x_(size)
805#define _Prepost_opt_valid_
806#define _Prepost_opt_z_
807#define _Prepost_valid_
808#define _Prepost_z_
809#define _Printf_format_string_
810#define _Raises_SEH_exception_
811#define _Readable_bytes_(size)
812#define _Readable_elements_(size)
813#define _Reserved_
814#define _Result_nullonfailure_
815#define _Result_zeroonfailure_
816#define _Ret_
817#define _Ret_bound_
818#define _Ret_bytecap_(size)
819#define _Ret_bytecap_c_(size)
820#define _Ret_bytecap_x_(size)
821#define _Ret_bytecount_(size)
822#define _Ret_bytecount_c_(size)
823#define _Ret_bytecount_x_(size)
824#define _Ret_cap_(size)
825#define _Ret_cap_c_(size)
826#define _Ret_cap_x_(size)
827#define _Ret_count_(size)
828#define _Ret_count_c_(size)
829#define _Ret_count_x_(size)
830#define _Ret_maybenull_
831#define _Ret_maybenull_z_
832#define _Ret_notnull_
833#define _Ret_null_
834#define _Ret_opt_
835#define _Ret_opt_bytecap_(size)
836#define _Ret_opt_bytecap_c_(size)
837#define _Ret_opt_bytecap_x_(size)
838#define _Ret_opt_bytecount_(size)
839#define _Ret_opt_bytecount_c_(size)
840#define _Ret_opt_bytecount_x_(size)
841#define _Ret_opt_cap_(size)
842#define _Ret_opt_cap_c_(size)
843#define _Ret_opt_cap_x_(size)
844#define _Ret_opt_count_(size)
845#define _Ret_opt_count_c_(size)
846#define _Ret_opt_count_x_(size)
847#define _Ret_opt_valid_
848#define _Ret_opt_z_
849#define _Ret_opt_z_bytecap_(size)
850#define _Ret_opt_z_bytecount_(size)
851#define _Ret_opt_z_cap_(size)
852#define _Ret_opt_z_count_(size)
853#define _Ret_range_(lb,ub)
854#define _Ret_valid_
855#define _Ret_writes_(size)
856#define _Ret_writes_bytes_(size)
857#define _Ret_writes_bytes_maybenull_(size)
858#define _Ret_writes_bytes_to_(size,count)
859#define _Ret_writes_bytes_to_maybenull_(size,count)
860#define _Ret_writes_maybenull_(size)
861#define _Ret_writes_maybenull_z_(size)
862#define _Ret_writes_to_(size,count)
863#define _Ret_writes_to_maybenull_(size,count)
864#define _Ret_writes_z_(size)
865#define _Ret_z_
866#define _Ret_z_bytecap_(size)
867#define _Ret_z_bytecount_(size)
868#define _Ret_z_cap_(size)
869#define _Ret_z_count_(size)
870#define _Return_type_success_(expr)
871#define _Scanf_format_string_
872#define _Scanf_s_format_string_
873#define _Struct_size_bytes_(size)
874#define _Success_(expr)
875#define _Unchanged_(e)
876#define _Use_decl_annotations_
877#define _Valid_
878#define _When_(expr, annos)
879#define _Writable_bytes_(size)
880#define _Writable_elements_(size)
881#define __inner_callback
882#define __inner_exceptthat
883#define __inner_typefix(ctype)
884
249885#ifndef __fallthrough
250886#   define __fallthrough __inner_fallthrough
251887#endif
trunk/3rdparty/bx/include/tinystl/buffer.h
r249195r249196
11/*-
2 * Copyright 2012 Matthew Endsley
2 * Copyright 2012-1015 Matthew Endsley
33 * All rights reserved
44 *
55 * Redistribution and use in source and binary forms, with or without
r249195r249196
5555   }
5656
5757   template<typename T>
58   static inline void buffer_fill_urange_traits(T* first, T* last, pod_traits<T, false>) {
59      for (; first < last; ++first)
60         new(placeholder(), first) T();
61   }
62
63   template<typename T>
64   static inline void buffer_fill_urange_traits(T* first, T* last, pod_traits<T, true>) {
65      for (; first < last; ++first)
66         *first = T();
67   }
68
69   template<typename T>
5870   static inline void buffer_fill_urange_traits(T* first, T* last, const T& value, pod_traits<T, false>) {
5971      for (; first < last; ++first)
6072         new(placeholder(), first) T(value);
r249195r249196
106118   }
107119
108120   template<typename T>
121   static inline void buffer_fill_urange(T* first, T* last) {
122      buffer_fill_urange_traits(first, last, pod_traits<T>());
123   }
124
125   template<typename T>
109126   static inline void buffer_fill_urange(T* first, T* last, const T& value) {
110127      buffer_fill_urange_traits(first, last, value, pod_traits<T>());
111128   }
r249195r249196
138155   }
139156
140157   template<typename T, typename Alloc>
158   static inline void buffer_resize(buffer<T, Alloc>* b, size_t size) {
159      buffer_reserve(b, size);
160
161      buffer_fill_urange(b->last, b->first + size);
162      buffer_destroy_range(b->first + size, b->last);
163      b->last = b->first + size;
164   }
165
166   template<typename T, typename Alloc>
141167   static inline void buffer_resize(buffer<T, Alloc>* b, size_t size, const T& value) {
142168      buffer_reserve(b, size);
143169
r249195r249196
169195   }
170196
171197   template<typename T, typename Alloc>
172   static inline void buffer_insert(buffer<T, Alloc>* b, T* where, const T* first, const T* last) {
198   static inline T* buffer_insert_common(buffer<T, Alloc>* b, T* where, size_t count) {
173199      const size_t offset = (size_t)(where - b->first);
174      const size_t newsize = (size_t)((b->last - b->first) + (last - first));
200      const size_t newsize = (size_t)((b->last - b->first) + count);
175201      if (b->first + newsize > b->capacity)
176202         buffer_reserve(b, (newsize * 3) / 2);
177203
178204      where = b->first + offset;
179      const size_t count = (size_t)(last - first);
180205
181206      if (where != b->last)
182207         buffer_bmove_urange(where + count, where, b->last);
183208
209      b->last = b->first + newsize;
210
211      return where;
212   }
213
214   template<typename T, typename Alloc, typename Param>
215   static inline void buffer_insert(buffer<T, Alloc>* b, T* where, const Param* first, const Param* last) {
216      where = buffer_insert_common(b, where, last - first);
184217      for (; first != last; ++first, ++where)
185218         new(placeholder(), where) T(*first);
219   }
186220
187      b->last = b->first + newsize;
221   template<typename T, typename Alloc>
222   static inline void buffer_insert(buffer<T, Alloc>* b, T* where, size_t count) {
223      where = buffer_insert_common(b, where, count);
224      for (size_t i = 0; i < count; ++i)
225         new(placeholder(), where) T();
188226   }
189227
190228   template<typename T, typename Alloc>
trunk/3rdparty/bx/include/tinystl/vector.h
r249195r249196
11/*-
2 * Copyright 2012 Matthew Endsley
2 * Copyright 2012-1015 Matthew Endsley
33 * All rights reserved
44 *
55 * Redistribution and use in source and binary forms, with or without
r249195r249196
5656      T& operator[](size_t idx);
5757      const T& operator[](size_t idx) const;
5858
59      const T& front() const;
60      T& front();
5961      const T& back() const;
6062      T& back();
6163
r249195r249196
6769      void push_back(const T& t);
6870      void pop_back();
6971
72      void emplace_back();
73      template<typename Param>
74      void emplace_back(const Param& param);
75
7076      void shrink_to_fit();
7177
7278      void swap(vector& other);
r249195r249196
8187      const_iterator begin() const;
8288      const_iterator end() const;
8389
90      void insert(iterator where);
8491      void insert(iterator where, const T& value);
8592      void insert(iterator where, const T* first, const T* last);
8693
94      template<typename Param>
95      void emplace(iterator where, const Param& param);
96
8797      iterator erase(iterator where);
8898      iterator erase(iterator first, iterator last);
8999
r249195r249196
109119   template<typename T, typename Alloc>
110120   inline vector<T, Alloc>::vector(size_t _size) {
111121      buffer_init(&m_buffer);
112      buffer_resize(&m_buffer, _size, T());
122      buffer_resize(&m_buffer, _size);
113123   }
114124
115125   template<typename T, typename Alloc>
r249195r249196
177187   }
178188
179189   template<typename T, typename Alloc>
190   inline const T& vector<T, Alloc>::front() const {
191      return m_buffer.first[0];
192   }
193
194   template<typename T, typename Alloc>
195   inline T& vector<T, Alloc>::front() {
196      return m_buffer.first[0];
197   }
198
199   template<typename T, typename Alloc>
180200   inline const T& vector<T, Alloc>::back() const {
181201      return m_buffer.last[-1];
182202   }
r249195r249196
188208
189209   template<typename T, typename Alloc>
190210   inline void vector<T, Alloc>::resize(size_t _size) {
191      buffer_resize(&m_buffer, _size, T());
211      buffer_resize(&m_buffer, _size);
192212   }
193213
194214   template<typename T, typename Alloc>
r249195r249196
212232   }
213233
214234   template<typename T, typename Alloc>
235   inline void vector<T, Alloc>::emplace_back()
236   {
237      buffer_insert(&m_buffer, m_buffer.last, 1);
238   }
239
240   template<typename T, typename Alloc>
241   template<typename Param>
242   inline void vector<T, Alloc>::emplace_back(const Param& param)
243   {
244      buffer_insert(&m_buffer, m_buffer.last, &param, &param + 1);
245   }
246
247   template<typename T, typename Alloc>
215248   inline void vector<T, Alloc>::pop_back() {
216249      buffer_erase(&m_buffer, m_buffer.last - 1, m_buffer.last);
217250   }
r249195r249196
247280   }
248281
249282   template<typename T, typename Alloc>
283   inline void vector<T, Alloc>::insert(iterator where) {
284      buffer_insert(&m_buffer, where, 1);
285   }
286
287   template<typename T, typename Alloc>
250288   inline void vector<T, Alloc>::insert(iterator where, const T& value) {
251289      buffer_insert(&m_buffer, where, &value, &value + 1);
252290   }
r249195r249196
275313   inline typename vector<T, Alloc>::iterator vector<T, Alloc>::erase_unordered(iterator first, iterator last) {
276314      return buffer_erase_unordered(&m_buffer, first, last);
277315   }
316
317   template<typename T, typename Alloc>
318   template<typename Param>
319   void vector<T, Alloc>::emplace(iterator where, const Param& param) {
320      buffer_insert(&m_buffer, where, &param, &param + 1);
321   }
278322}
279323
280324#endif
trunk/3rdparty/bx/scripts/genie.lua
r249195r249196
3636dofile "bin2c.lua"
3737
3838project "bx.test"
39   uuid "8a653da8-23d6-11e3-acb4-887628d43830"
4039   kind "ConsoleApp"
4140
4241   debugdir (path.join(BX_DIR, "tests"))
trunk/3rdparty/bx/scripts/toolchain.lua
r249195r249196
2929         { "nacl-arm",      "Native Client - ARM"    },
3030         { "osx",           "OSX"                    },
3131         { "pnacl",         "Native Client - PNaCl"  },
32         { "ps4",           "PS4"                    },
3233         { "qnx-arm",       "QNX/Blackberry - ARM"   },
3334         { "rpi",           "RaspberryPi"            },
3435      },
r249195r249196
3940      value = "toolset",
4041      description = "Choose VS toolset",
4142      allowed = {
42         { "vs2012-clang",  "Clang 3.6"         },
43         { "vs2013-clang",  "Clang 3.6"         },
43         { "vs2012-clang",  "Clang 3.6"                       },
44         { "vs2013-clang",  "Clang 3.6"                       },
4445         { "vs2012-xp",     "Visual Studio 2012 targeting XP" },
4546         { "vs2013-xp",     "Visual Studio 2013 targeting XP" },
4647         { "vs2015-xp",     "Visual Studio 2015 targeting XP" },
47         { "winphone8",     "Windows Phone 8.0" },
48         { "winphone81",    "Windows Phone 8.1" },
49         { "winstore81",    "Windows Store 8.1" },
50         { "winstore82",    "Universal Windows App" }
48         { "winphone8",     "Windows Phone 8.0"               },
49         { "winphone81",    "Windows Phone 8.1"               },
50         { "winstore81",    "Windows Store 8.1"               },
51         { "winstore82",    "Universal Windows App"           },
5152      },
5253   }
5354
r249195r249196
257258         premake.gcc.ar  = naclToolchain .. "ar"
258259         location (path.join(_buildDir, "projects", _ACTION .. "-pnacl"))
259260
261      elseif "ps4" == _OPTIONS["gcc"] then
262
263         if not os.getenv("PS4_SDK_ROOT") then
264            print("Set PS4_SDK_ROOT enviroment variables.")
265         end
266
267         ps4Toolchain = "$(PS4_SDK_ROOT)/host_tools/bin/orbis-"
268
269         premake.gcc.cc  = ps4Toolchain .. "clang"
270         premake.gcc.cxx = ps4Toolchain .. "clang++"
271         premake.gcc.ar  = ps4Toolchain .. "ar"
272         location (path.join(_buildDir, "projects", _ACTION .. "-ps4"))
273
260274      elseif "qnx-arm" == _OPTIONS["gcc"] then
261275
262276         if not os.getenv("QNX_HOST") then
r249195r249196
799813         "-m64",
800814      }
801815
816   configuration { "osx", "Universal" }
817      targetdir (path.join(_buildDir, "osx_universal/bin"))
818      objdir (path.join(_buildDir, "osx_universal/bin"))
819
802820   configuration { "osx" }
803821      buildoptions {
804822         "-Wfatal-errors",
r249195r249196
855873         "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
856874      }
857875
876   configuration { "ps4" }
877      targetdir (path.join(_buildDir, "ps4/bin"))
878      objdir (path.join(_buildDir, "ps4/obj"))
879      libdirs { path.join(_libDir, "lib/ps4") }
880      includedirs {
881         path.join(bxDir, "include/compat/freebsd"),
882         "$(PS4_SDK_ROOT)/target/include",
883         "$(PS4_SDK_ROOT)/target/include_common",
884      }
885      buildoptions {
886      }
887      buildoptions_cpp {
888         "-std=c++0x",
889      }
890      linkoptions {
891      }
892
858893   configuration { "qnx-arm" }
859894      targetdir (path.join(_buildDir, "qnx-arm/bin"))
860895      objdir (path.join(_buildDir, "qnx-arm/obj"))
r249195r249196
951986   configuration { "asmjs" }
952987      postbuildcommands {
953988         "$(SILENT) echo Running asmjs finalize.",
954         "$(SILENT) $(EMSCRIPTEN)/emcc -O2 -s TOTAL_MEMORY=268435456 \"$(TARGET)\" -o \"$(TARGET)\".html"
955         -- ALLOW_MEMORY_GROWTH
989         "$(SILENT) $(EMSCRIPTEN)/emcc -O2 "
990--            .. "-s EMTERPRETIFY=1 "
991--            .. "-s EMTERPRETIFY_ASYNC=1 "
992            .. "-s TOTAL_MEMORY=268435456 "
993--            .. "-s ALLOW_MEMORY_GROWTH=1 "
994            .. "--memory-init-file 1 "
995            .. "\"$(TARGET)\" -o \"$(TARGET)\".html "
996--            .. "--preload-file ../../../examples/runtime@/"
956997      }
957998
958999   configuration {} -- reset configuration
trunk/3rdparty/bx/scripts/unittest++.lua
r249195r249196
44--
55
66project "UnitTest++"
7   uuid "ab932f5c-2409-11e3-b000-887628d43830"
87   kind "StaticLib"
98
109   removeflags {
r249195r249196
1615      "../3rdparty/UnitTest++/src/*.h",
1716   }
1817
19   configuration { "linux or osx or android-* or *nacl*" }
18   configuration { "linux or osx or android-* or *nacl* or ps4" }
2019      files {
2120         "../3rdparty/UnitTest++/src/Posix/**.cpp",
2221         "../3rdparty/UnitTest++/src/Posix/**.h",
trunk/3rdparty/bx/tests/handle.cpp
r0r249196
1/*
2 * Copyright 2010-2015 Branimir Karadzic. All rights reserved.
3 * License: http://www.opensource.org/licenses/BSD-2-Clause
4 */
5
6#include "test.h"
7#include <bx/handlealloc.h>
8
9TEST(HandleListT)
10{
11   bx::HandleListT<32> list;
12
13   list.pushBack(16);
14   CHECK(list.getFront() == 16);
15   CHECK(list.getBack()  == 16);
16
17   list.pushFront(7);
18   CHECK(list.getFront() ==  7);
19   CHECK(list.getBack()  == 16);
20
21   uint16_t expected0[] = { 15, 31, 7, 16, 17, 11, 13 };
22   list.pushBack(17);
23   list.pushBack(11);
24   list.pushBack(13);
25   list.pushFront(31);
26   list.pushFront(15);
27   uint16_t count = 0;
28   for (uint16_t it = list.getFront(); it != UINT16_MAX; it = list.getNext(it), ++count)
29   {
30      CHECK(it == expected0[count]);
31   }
32   CHECK(count == BX_COUNTOF(expected0) );
33
34   list.remove(17);
35   list.remove(31);
36   list.remove(16);
37   list.pushBack(16);
38   uint16_t expected1[] = { 15, 7, 11, 13, 16 };
39   count = 0;
40   for (uint16_t it = list.getFront(); it != UINT16_MAX; it = list.getNext(it), ++count)
41   {
42      CHECK(it == expected1[count]);
43   }
44   CHECK(count == BX_COUNTOF(expected1) );
45
46   list.popBack();
47   list.popFront();
48   list.popBack();
49   list.popBack();
50
51   CHECK(list.getFront() ==  7);
52   CHECK(list.getBack()  ==  7);
53
54   list.popBack();
55   CHECK(list.getFront() ==  UINT16_MAX);
56   CHECK(list.getBack()  ==  UINT16_MAX);
57}
58
59TEST(HandleAllocLruT)
60{
61   bx::HandleAllocLruT<16> lru;
62
63   uint16_t handle[4] =
64   {
65      lru.alloc(),
66      lru.alloc(),
67      lru.alloc(),
68      lru.alloc(),
69   };
70
71   lru.touch(handle[1]);
72
73   uint16_t expected0[] = { handle[1], handle[3], handle[2], handle[0] };
74   uint16_t count = 0;
75   for (uint16_t it = lru.getFront(); it != UINT16_MAX; it = lru.getNext(it), ++count)
76   {
77      CHECK(it == expected0[count]);
78   }
79}
trunk/3rdparty/bx/tests/misc.cpp
r0r249196
1#include "test.h"
2#include <bx/os.h>
3
4TEST(getProcessMemoryUsed)
5{
6   CHECK(0 != bx::getProcessMemoryUsed() );
7//   DBG("bx::getProcessMemoryUsed %d", bx::getProcessMemoryUsed() );
8}
trunk/3rdparty/bx/tests/uint32_t.cpp
r249195r249196
2020      CHECK(48 == bx::strideAlign16(ii+1, 12) );
2121   }
2222}
23
24TEST(uint32_cnt)
25{
26   CHECK( 0 == bx::uint32_cnttz(UINT32_C(1) ) );
27   CHECK( 0 == bx::uint32_cnttz_ref(UINT32_C(1) ) );
28
29   CHECK(31 == bx::uint32_cntlz(UINT32_C(1) ) );
30   CHECK(31 == bx::uint32_cntlz_ref(UINT32_C(1) ) );
31
32   CHECK( 0 == bx::uint64_cnttz(UINT64_C(1) ) );
33   CHECK( 0 == bx::uint64_cnttz_ref(UINT64_C(1) ) );
34
35   CHECK(63 == bx::uint64_cntlz(UINT64_C(1) ) );
36   CHECK(63 == bx::uint64_cntlz_ref(UINT64_C(1) ) );
37
38   CHECK( 1 == bx::uint32_cntbits(1) );
39   CHECK( 1 == bx::uint32_cntbits_ref(1) );
40
41   CHECK(16 == bx::uint32_cntbits(UINT16_MAX) );
42   CHECK(16 == bx::uint32_cntbits_ref(UINT16_MAX) );
43
44   CHECK(32 == bx::uint32_cntbits(UINT32_MAX) );
45   CHECK(32 == bx::uint32_cntbits_ref(UINT32_MAX) );
46}
47
48TEST(uint32_part)
49{
50   CHECK(UINT32_C(0x55555555) == bx::uint32_part1by1(UINT16_MAX) );
51   CHECK(UINT32_C(0x09249249) == bx::uint32_part1by2(0x3ff) );
52}
trunk/3rdparty/bx/tests/unordered_map_nonpod.cpp
r249195r249196
11/*-
2 * Copyright 2012-2014 Matthew Endsley
2 * Copyright 2012-2015 Matthew Endsley
33 * All rights reserved
44 *
55 * Redistribution and use in source and binary forms, with or without
r249195r249196
2929#include <tinystl/allocator.h>
3030#include <tinystl/unordered_map.h>
3131
32struct Foo { int bar; };
32namespace {
33   struct Foo { int bar; };
34}
3335
3436TEST(uomap_nonpod_compiles) {
3537
trunk/3rdparty/bx/tests/vector_complex.cpp
r249195r249196
11/*-
2 * Copyright 2012 Matthew Endsley
2 * Copyright 2012-1015 Matthew Endsley
33 * All rights reserved
44 *
55 * Redistribution and use in source and binary forms, with or without
r249195r249196
3535
3636struct complex {
3737   complex() {data = 0;}
38   complex(const char* s) { data = _strdup(s); }
38   complex(const char* s) { data = strdup(s); }
3939   ~complex() { free(data); }
40   complex(const complex& other) { data = 0; if (other.data) data = _strdup(other.data); }
40   complex(const complex& other) { data = 0; if (other.data) data = strdup(other.data); }
4141   complex& operator=(const complex& other) { complex(other).swap(*this); return *this; }
4242   void swap(complex& other) { std::swap(data, other.data); }
4343
trunk/3rdparty/bx/tests/vector_header.cpp
r249195r249196
11/*-
2 * Copyright 2012 Matthew Endsley
2 * Copyright 2012-1015 Matthew Endsley
33 * All rights reserved
44 *
55 * Redistribution and use in source and binary forms, with or without
trunk/3rdparty/bx/tests/vector_nocopy.cpp
r0r249196
1/*-
2 * Copyright 2012-1015 Matthew Endsley
3 * All rights reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted providing that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
22 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
23 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "test.h"
28
29#include <tinystl/allocator.h>
30#include <tinystl/vector.h>
31
32#include <algorithm>
33#include <string.h>
34#include <stdlib.h>
35
36struct nocopy {
37   nocopy() { data = 0; }
38   explicit nocopy(const char* s) { data = s; }
39   ~nocopy() { }
40   void swap(nocopy& other) { std::swap(data, other.data); }
41   void reset(const char* s) { data = s; }
42   const char* release() { const char* ret = data; data = 0; return ret; }
43
44   const char* data;
45
46private:
47   nocopy(const nocopy& other);
48   nocopy& operator=(const nocopy& other);
49};
50
51static inline bool operator==(const nocopy& lhs, const char* rhs) {
52   if (lhs.data == 0 && rhs == 0)
53      return true;
54   if (lhs.data != 0 && rhs != 0)
55      return 0 == strcmp(lhs.data, rhs);
56   return false;
57}
58
59static inline bool operator==(const nocopy& lhs, const nocopy& rhs) {
60   if (lhs.data == 0 && rhs.data == 0)
61      return true;
62   if (lhs.data != 0 && rhs.data != 0)
63      return 0 == strcmp(lhs.data, rhs.data);
64   return false;
65}
66
67TEST(vector_nocopy_constructor) {
68   typedef tinystl::vector<nocopy> vector;
69
70   {
71      vector v;
72      CHECK( v.empty() );
73      CHECK( v.size() == 0 );
74   }
75   {
76      vector v(10);
77      CHECK( v.size() == 10 );
78      for (tinystl::vector<nocopy>::iterator it = v.begin(); it != v.end(); ++it) {
79         CHECK( it->data == 0 );
80      }
81   }
82}
83
84TEST(vector_nocopy_pushback) {
85   tinystl::vector<nocopy> v;
86   v.emplace_back("42");
87   v.emplace_back();
88   v.back().reset("24");
89
90   CHECK( v.size() == 2 );
91   CHECK( v[0] == "42" );
92   CHECK( v[1] == "24" );
93}
94
95TEST(vector_nocopy_vector) {
96   tinystl::vector< tinystl::vector<nocopy> > v(10);
97
98   tinystl::vector< tinystl::vector<nocopy> >::iterator it = v.begin(), end = v.end();
99   for (; it != end; ++it) {
100      CHECK( (*it).empty() );
101      CHECK( (*it).size() == 0 );
102      CHECK( (*it).begin() == (*it).end() );
103   }
104}
105
106TEST(vector_nocopy_swap) {
107   tinystl::vector<nocopy> v1;
108   v1.emplace_back("12");
109   v1.emplace_back("20");
110
111   tinystl::vector<nocopy> v2;
112   v2.emplace_back("54");
113
114   v1.swap(v2);
115
116   CHECK(v1.size() == 1);
117   CHECK(v2.size() == 2);
118   CHECK(v1[0] == "54");
119   CHECK(v2[0] == "12");
120   CHECK(v2[1] == "20");
121}
122
123TEST(vector_nocopy_popback) {
124   tinystl::vector<nocopy> v;
125   v.emplace_back("12");
126   v.emplace_back("24");
127
128   CHECK(v.back() == "24");
129
130   v.pop_back();
131
132   CHECK(v.back() == "12");
133   CHECK(v.size() == 1);
134}
135
136TEST(vector_nocopy_erase) {
137   tinystl::vector<nocopy> v;
138   v.emplace_back("1");
139   v.emplace_back("2");
140   v.emplace_back("3");
141   v.emplace_back("4");
142   v.emplace_back("5");
143
144   tinystl::vector<nocopy>::iterator it = v.erase(v.begin());
145   CHECK(*it == "2");
146   CHECK(v.size() == 4);
147
148   it = v.erase(v.end() - 1);
149   CHECK(it == v.end());
150   CHECK(v.size() == 3);
151
152   v.erase(v.begin() + 1, v.end() - 1);
153   CHECK(v.size() == 2);
154   CHECK(v[0] == "2");
155   CHECK(v[1] == "4");
156}
157
158TEST(vector_nocopy_erase_unordered) {
159   typedef tinystl::vector<nocopy> vector;
160   vector v;
161   v.emplace_back("1");
162   v.emplace_back("2");
163   v.emplace_back("3");
164   v.emplace_back("4");
165   v.emplace_back("5");
166
167   const char* first = v.front().release();
168   vector::iterator it = v.erase_unordered(v.begin());
169   CHECK( it == v.begin() );
170   CHECK( v.size() == 4 );
171   CHECK( std::count(v.begin(), v.end(), first) == 0 );
172   for (it = v.begin(); it != v.end(); ++it) {
173      CHECK( std::count(v.begin(), v.end(), *it) == 1 );
174   }
175
176   const char* last = v.back().release();
177   it = v.erase_unordered(v.end() - 1);
178   CHECK( it == v.end() );
179   CHECK( v.size() == 3 );
180   CHECK( std::count(v.begin(), v.end(), last) == 0 );
181   for (it = v.begin(); it != v.end(); ++it) {
182      CHECK( std::count(v.begin(), v.end(), *it) == 1 );
183   }
184
185   first = v.begin()->data;
186   last = (v.end() - 1)->data;
187   v.erase_unordered(v.begin() + 1, v.end() - 1);
188   CHECK( v.size() == 2 );
189   CHECK( std::count(v.begin(), v.end(), first) == 1 );
190   CHECK( std::count(v.begin(), v.end(), last) == 1 );
191}
192
193TEST(vector_nocopy_insert) {
194   tinystl::vector<nocopy> v;
195   v.emplace_back("1");
196   v.emplace_back("2");
197   v.emplace_back("3");
198   v.emplace_back("4");
199   v.emplace_back("5");
200
201   v.emplace(v.begin(), "0");
202   CHECK( v.size() == 6 );
203   CHECK( v[0] == "0" );
204   CHECK( v[1] == "1" );
205   CHECK( v[5] == "5" );
206
207   v.emplace(v.end(), "6");
208   CHECK( v.size() == 7 );
209   CHECK( v.front() == "0" );
210   CHECK( v.back() == "6" );
211}
212
213TEST(vector_nocopy_iterator) {
214   tinystl::vector<nocopy> v(5);
215   v[0].reset("1");
216   v[1].reset("2");
217   v[2].reset("3");
218   v[3].reset("4");
219   v[4].reset("5");
220
221   const tinystl::vector<nocopy>& cv = v;
222
223   //CHECK(v.data() == &*v.begin());
224   //CHECK(v.data() == &v[0]);
225   //CHECK(v.data() + v.size() == &*v.end());
226   CHECK(v.begin() == cv.begin());
227   CHECK(v.end() == cv.end());
228   //CHECK(v.data() == cv.data());
229}
trunk/3rdparty/bx/tests/vector_nodefault.cpp
r249195r249196
11/*-
2 * Copyright 2012 Matthew Endsley
2 * Copyright 2012-1015 Matthew Endsley
33 * All rights reserved
44 *
55 * Redistribution and use in source and binary forms, with or without
r249195r249196
3333#include <string.h>
3434#include <stdlib.h>
3535
36#if !BX_COMPILER_MSVC
37#   define _strdup strdup
38#endif // !BX_COMPILER_MSVC
39
4036struct nodefault {
41   nodefault(const char* s) { data = _strdup(s); }
37   nodefault(const char* s) { data = strdup(s); }
4238   ~nodefault() { free(data); }
43   nodefault(const nodefault& other) { data = 0; if (other.data) data = _strdup(other.data); }
39   nodefault(const nodefault& other) { data = 0; if (other.data) data = strdup(other.data); }
4440   nodefault& operator=(const nodefault& other) { nodefault(other).swap(*this); return *this; }
4541   void swap(nodefault& other) { std::swap(data, other.data); }
4642
trunk/3rdparty/bx/tools/bin/darwin/genie
r249195r249196
Previous 199869 Revisions Next


© 1997-2024 The MAME Team