Sierra Toolkit  Version of the Day
config_eastl.h
1 /*
2 Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 
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 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of
14  its contributors may be used to endorse or promote products derived
15  from this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
30 // EASTL/internal/config.h
31 // Written and maintained by Paul Pedriana - 2005.
33 
34 
35 #ifndef EASTL_INTERNAL_CONFIG_H
36 #define EASTL_INTERNAL_CONFIG_H
37 
38 
40 // ReadMe
41 //
42 // This is the EASTL configuration file. All configurable parameters of EASTL
43 // are controlled through this file. However, all the settings here can be
44 // manually overridden by the user. There are three ways for a user to override
45 // the settings in this file:
46 //
47 // - Simply edit this file.
48 // - Define EASTL_USER_CONFIG_HEADER.
49 // - Predefine individual defines (e.g. EASTL_ASSERT).
50 //
52 
53 
54 
55 
57 // EASTL_USER_CONFIG_HEADER
58 //
59 // This allows the user to define a header file to be #included before the
60 // EASTL config.h contents are compiled. A primary use of this is to override
61 // the contents of this config.h file. Note that all the settings below in
62 // this file are user-overridable.
63 //
64 // Example usage:
65 // #define EASTL_USER_CONFIG_HEADER "MyConfigOverrides.h"
66 // #include <EASTL/vector.h>
67 //
69 
70 #ifdef EASTL_USER_CONFIG_HEADER
71  #include EASTL_USER_CONFIG_HEADER
72 #endif
73 
74 
75 
77 // EASTL_EABASE_DISABLED
78 //
79 // The user can disable EABase usage and manually supply the configuration
80 // via defining EASTL_EABASE_DISABLED and defining the appropriate entities
81 // globally or via the above EASTL_USER_CONFIG_HEADER.
82 //
83 // Example usage:
84 // #define EASTL_EABASE_DISABLED
85 // #include <EASTL/vector.h>
86 //
88 
89 #ifndef EASTL_EABASE_DISABLED
90  #include <stk_util/util/eabase_eastl.h>
91 #endif
92 
93 
94 
96 // VC++ bug fix.
98 
99 #ifdef _MSC_VER
100  // VC8 has a bug whereby it generates a warning when malloc.h is #included
101  // by its headers instead of by yours. There is no practical solution but
102  // to pre-empt the #include of malloc.h with our own inclusion of it.
103  // The only other alternative is to disable the warning globally, which is
104  // something we try to avoid as much as possible.
105  #pragma warning(push, 0)
106  #include <malloc.h>
107  #pragma warning(pop)
108 #endif
109 
110 
111 
113 // EASTL_VERSION
114 //
115 // We more or less follow the conventional EA packaging approach to versioning
116 // here. A primary distinction here is that minor versions are defined as two
117 // digit entities (e.g. .03") instead of minimal digit entities ".3"). The logic
118 // here is that the value is a counter and not a floating point fraction.
119 // Note that the major version doesn't have leading zeros.
120 //
121 // Example version strings:
122 // "0.91.00" // Major version 0, minor version 91, patch version 0.
123 // "1.00.00" // Major version 1, minor and patch version 0.
124 // "3.10.02" // Major version 3, minor version 10, patch version 02.
125 // "12.03.01" // Major version 12, minor version 03, patch version
126 //
127 // Example usage:
128 // printf("EASTL version: %s", EASTL_VERSION);
129 // printf("EASTL version: %d.%d.%d", EASTL_VERSION_N / 10000 % 100, EASTL_VERSION_N / 100 % 100, EASTL_VERSION_N % 100);
130 //
132 
133 #ifndef EASTL_VERSION
134  #define EASTL_VERSION "1.11.03"
135  #define EASTL_VERSION_N 11103
136 #endif
137 
138 
139 
141 // EA_PLATFORM_MICROSOFT
142 //
143 // Defined as 1 or undefined.
144 // Implements support for the definition of EA_PLATFORM_MICROSOFT for the case
145 // of using EABase versions prior to the addition of its EA_PLATFORM_MICROSOFT support.
146 //
147 #if (EABASE_VERSION_N < 20022) && !defined(EA_PLATFORM_MICROSOFT)
148  #if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XENON)
149  #define EA_PLATFORM_MICROSOFT 1
150  #endif
151 #endif
152 
153 
155 // EA_COMPILER_NO_STANDARD_CPP_LIBRARY
156 //
157 // Defined as 1 or undefined.
158 // Implements support for the definition of EA_COMPILER_NO_STANDARD_CPP_LIBRARY for the case
159 // of using EABase versions prior to the addition of its EA_COMPILER_NO_STANDARD_CPP_LIBRARY support.
160 //
161 #if (EABASE_VERSION_N < 20022) && !defined(EA_COMPILER_NO_STANDARD_CPP_LIBRARY)
162  #if defined(EA_PLATFORM_ANDROID)
163  #define EA_COMPILER_NO_STANDARD_CPP_LIBRARY 1
164  #endif
165 #endif
166 
167 
169 // EA_COMPILER_NO_RTTI
170 //
171 // Defined as 1 or undefined.
172 // Implements support for the definition of EA_COMPILER_NO_RTTI for the case
173 // of using EABase versions prior to the addition of its EA_COMPILER_NO_RTTI support.
174 //
175 #if (EABASE_VERSION_N < 20022) && !defined(EA_COMPILER_NO_RTTI)
176  #if defined(__SNC__) && !defined(__RTTI)
177  #define EA_COMPILER_NO_RTTI
178  #elif defined(__GXX_ABI_VERSION) && !defined(__GXX_RTTI)
179  #define EA_COMPILER_NO_RTTI
180  #elif defined(_MSC_VER) && !defined(_CPPRTTI)
181  #define EA_COMPILER_NO_RTTI
182  #elif defined(__MWERKS__)
183  #if !__option(RTTI)
184  #define EA_COMPILER_NO_RTTI
185  #endif
186  #endif
187 #endif
188 
189 
190 
192 // EASTL namespace
193 //
194 // We define this so that users that #include this config file can reference
195 // these namespaces without seeing any other files that happen to use them.
197 
199 namespace eastl
200 {
201  // Intentionally empty.
202 }
203 
204 
205 
206 
208 // EASTL_DEBUG
209 //
210 // Defined as an integer >= 0. Default is 1 for debug builds and 0 for
211 // release builds. This define is also a master switch for the default value
212 // of some other settings.
213 //
214 // Example usage:
215 // #if EASTL_DEBUG
216 // ...
217 // #endif
218 //
220 
221 #ifndef EASTL_DEBUG
222  #if defined(EA_DEBUG) || defined(_DEBUG)
223  #define EASTL_DEBUG 1
224  #else
225  #define EASTL_DEBUG 0
226  #endif
227 #endif
228 
229 
230 
232 // EASTL_DEBUGPARAMS_LEVEL
233 //
234 // EASTL_DEBUGPARAMS_LEVEL controls what debug information is passed through to
235 // the allocator by default.
236 // This value may be defined by the user ... if not it will default to 1 for
237 // EA_DEBUG builds, otherwise 0.
238 //
239 // 0 - no debug information is passed through to allocator calls.
240 // 1 - 'name' is passed through to allocator calls.
241 // 2 - 'name', __FILE__, and __LINE__ are passed through to allocator calls.
242 //
243 // This parameter mirrors the equivalent parameter in the CoreAllocator package.
244 //
246 
247 #ifndef EASTL_DEBUGPARAMS_LEVEL
248  #if EASTL_DEBUG
249  #define EASTL_DEBUGPARAMS_LEVEL 2
250  #else
251  #define EASTL_DEBUGPARAMS_LEVEL 0
252  #endif
253 #endif
254 
255 
256 
258 // EASTL_DLL
259 //
260 // Defined as 0 or 1. The default is dependent on the definition of EA_DLL.
261 // If EA_DLL is defined, then EASTL_DLL is 1, else EASTL_DLL is 0.
262 // EA_DLL is a define that controls DLL builds within the EAConfig build system.
263 // EASTL_DLL controls whether EASTL is built and used as a DLL.
264 // Normally you wouldn't do such a thing, but there are use cases for such
265 // a thing, particularly in the case of embedding C++ into C# applications.
266 //
267 #ifndef EASTL_DLL
268  #if defined(EA_DLL)
269  #define EASTL_DLL 1
270  #else
271  #define EASTL_DLL 0
272  #endif
273 #endif
274 
275 
276 
278 // EASTL_API
279 //
280 // This is used to label functions as DLL exports under Microsoft platforms.
281 // If EA_DLL is defined, then the user is building EASTL as a DLL and EASTL's
282 // non-templated functions will be exported. EASTL template functions are not
283 // labelled as EASTL_API (and are thus not exported in a DLL build). This is
284 // because it's not possible (or at least unsafe) to implement inline templated
285 // functions in a DLL.
286 //
287 // Example usage of EASTL_API:
288 // EASTL_API int someVariable = 10; // Export someVariable in a DLL build.
289 //
290 // struct EASTL_API SomeClass{ // Export SomeClass and its member functions in a DLL build.
291 // };
292 //
293 // EASTL_API void SomeFunction(); // Export SomeFunction in a DLL build.
294 //
295 //
296 #if defined(EA_DLL) && !defined(EASTL_DLL)
297  #define EASTL_DLL 1
298 #endif
299 
300 #ifndef EASTL_API // If the build file hasn't already defined this to be dllexport...
301  #if EASTL_DLL && defined(_MSC_VER)
302  #define EASTL_API __declspec(dllimport)
303  #define EASTL_TEMPLATE_API // Not sure if there is anything we can do here.
304  #else
305  #define EASTL_API
306  #define EASTL_TEMPLATE_API
307  #endif
308 #endif
309 
310 
312 // EASTL_NAME_ENABLED / EASTL_NAME / EASTL_NAME_VAL
313 //
314 // Used to wrap debug string names. In a release build, the definition
315 // goes away. These are present to avoid release build compiler warnings
316 // and to make code simpler.
317 //
318 // Example usage of EASTL_NAME:
319 // // pName will defined away in a release build and thus prevent compiler warnings.
320 // void allocator::set_name(const char* EASTL_NAME(pName))
321 // {
322 // #if EASTL_NAME_ENABLED
323 // mpName = pName;
324 // #endif
325 // }
326 //
327 // Example usage of EASTL_NAME_VAL:
328 // // "xxx" is defined to NULL in a release build.
329 // vector<T, Allocator>::vector(const allocator_type& allocator = allocator_type(EASTL_NAME_VAL("xxx")));
330 //
332 
333 #ifndef EASTL_NAME_ENABLED
334  #define EASTL_NAME_ENABLED EASTL_DEBUG
335 #endif
336 
337 #ifndef EASTL_NAME
338  #if EASTL_NAME_ENABLED
339  #define EASTL_NAME(x) x
340  #define EASTL_NAME_VAL(x) x
341  #else
342  #define EASTL_NAME(x)
343  #define EASTL_NAME_VAL(x) ((const char*)NULL)
344  #endif
345 #endif
346 
347 
348 
350 // EASTL_DEFAULT_NAME_PREFIX
351 //
352 // Defined as a string literal. Defaults to "EASTL".
353 // This define is used as the default name for EASTL where such a thing is
354 // referenced in EASTL. For example, if the user doesn't specify an allocator
355 // name for their deque, it is named "EASTL deque". However, you can override
356 // this to say "SuperBaseball deque" by changing EASTL_DEFAULT_NAME_PREFIX.
357 //
358 // Example usage (which is simply taken from how deque.h uses this define):
359 // #ifndef EASTL_DEQUE_DEFAULT_NAME
360 // #define EASTL_DEQUE_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " deque"
361 // #endif
362 //
363 #ifndef EASTL_DEFAULT_NAME_PREFIX
364  #define EASTL_DEFAULT_NAME_PREFIX "EASTL"
365 #endif
366 
367 
368 
370 // EASTL_ASSERT_ENABLED
371 //
372 // Defined as 0 or non-zero. Default is same as EASTL_DEBUG.
373 // If EASTL_ASSERT_ENABLED is non-zero, then asserts will be executed via
374 // the assertion mechanism.
375 //
376 // Example usage:
377 // #if EASTL_ASSERT_ENABLED
378 // EASTL_ASSERT(v.size() > 17);
379 // #endif
380 //
382 
383 #ifndef EASTL_ASSERT_ENABLED
384  #define EASTL_ASSERT_ENABLED EASTL_DEBUG
385 #endif
386 
387 
388 
390 // EASTL_EMPTY_REFERENCE_ASSERT_ENABLED
391 //
392 // Defined as 0 or non-zero. Default is same as EASTL_ASSERT_ENABLED.
393 // This is like EASTL_ASSERT_ENABLED, except it is for empty container
394 // references. Sometime people like to be able to take a reference to
395 // the front of the container, but not use it if the container is empty.
396 // In practice it's often easier and more efficient to do this than to write
397 // extra code to check if the container is empty.
398 //
399 // Example usage:
400 // template <typename T, typename Allocator>
401 // inline typename vector<T, Allocator>::reference
402 // vector<T, Allocator>::front()
403 // {
404 // #if EASTL_ASSERT_ENABLED
405 // EASTL_ASSERT(mpEnd > mpBegin);
406 // #endif
407 //
408 // return *mpBegin;
409 // }
410 //
412 
413 #ifndef EASTL_EMPTY_REFERENCE_ASSERT_ENABLED
414  #define EASTL_EMPTY_REFERENCE_ASSERT_ENABLED EASTL_ASSERT_ENABLED
415 #endif
416 
417 
418 
420 // SetAssertionFailureFunction
421 //
422 // Allows the user to set a custom assertion failure mechanism.
423 //
424 // Example usage:
425 // void Assert(const char* pExpression, void* pContext);
426 // SetAssertionFailureFunction(Assert, this);
427 //
429 
430 #ifndef EASTL_ASSERTION_FAILURE_DEFINED
431  #define EASTL_ASSERTION_FAILURE_DEFINED
432 
433  namespace eastl
434  {
435  typedef void (*EASTL_AssertionFailureFunction)(const char* pExpression, void* pContext);
436  EASTL_API void SetAssertionFailureFunction(EASTL_AssertionFailureFunction pFunction, void* pContext);
437 
438  // These are the internal default functions that implement asserts.
439  EASTL_API void AssertionFailure(const char* pExpression);
440  EASTL_API void AssertionFailureFunctionDefault(const char* pExpression, void* pContext);
441  }
442 #endif
443 
444 
445 
447 // EASTL_ASSERT
448 //
449 // Assertion macro. Can be overridden by user with a different value.
450 //
451 // Example usage:
452 // EASTL_ASSERT(intVector.size() < 100);
453 //
455 
456 #ifndef EASTL_ASSERT
457  #if EASTL_ASSERT_ENABLED
458  #define EASTL_ASSERT(expression) (void)((expression) || (eastl::AssertionFailure(#expression), 0))
459  #else
460  #define EASTL_ASSERT(expression)
461  #endif
462 #endif
463 
464 
465 
467 // EASTL_FAIL_MSG
468 //
469 // Failure macro. Can be overridden by user with a different value.
470 //
471 // Example usage:
472 // EASTL_FAIL("detected error condition!");
473 //
475 
476 #ifndef EASTL_FAIL_MSG
477  #if EASTL_ASSERT_ENABLED
478  #define EASTL_FAIL_MSG(message) (eastl::AssertionFailure(message))
479  #else
480  #define EASTL_FAIL_MSG(message)
481  #endif
482 #endif
483 
484 
485 
486 
488 // EASTL_CT_ASSERT / EASTL_CT_ASSERT_NAMED
489 //
490 // EASTL_CT_ASSERT is a macro for compile time assertion checks, useful for
491 // validating *constant* expressions. The advantage over using EASTL_ASSERT
492 // is that errors are caught at compile time instead of runtime.
493 //
494 // Example usage:
495 // EASTL_CT_ASSERT(sizeof(uint32_t == 4));
496 //
498 
499 #if defined(EASTL_DEBUG) && !defined(EASTL_CT_ASSERT)
500  template <bool> struct EASTL_CT_ASSERTION_FAILURE;
501  template <> struct EASTL_CT_ASSERTION_FAILURE<true>{ enum { value = 1 }; }; // We create a specialization for true, but not for false.
502  template <int x> struct EASTL_CT_ASSERTION_TEST{};
503 
504  #define EASTL_PREPROCESSOR_JOIN(a, b) EASTL_PREPROCESSOR_JOIN1(a, b)
505  #define EASTL_PREPROCESSOR_JOIN1(a, b) EASTL_PREPROCESSOR_JOIN2(a, b)
506  #define EASTL_PREPROCESSOR_JOIN2(a, b) a##b
507 
508  #if defined(_MSC_VER)
509  #define EASTL_CT_ASSERT(expression) typedef EASTL_CT_ASSERTION_TEST< sizeof(EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >)> EASTL_CT_ASSERT_FAILURE
510  #elif defined(__ICL) || defined(__ICC)
511  #define EASTL_CT_ASSERT(expression) typedef char EASTL_PREPROCESSOR_JOIN(EASTL_CT_ASSERT_FAILURE_, __LINE__) [EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >::value]
512  #elif defined(__MWERKS__)
513  #define EASTL_CT_ASSERT(expression) enum { EASTL_PREPROCESSOR_JOIN(EASTL_CT_ASSERT_FAILURE_, __LINE__) = sizeof(EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >) }
514  #else // GCC, etc.
515  #define EASTL_CT_ASSERT(expression) typedef EASTL_CT_ASSERTION_TEST< sizeof(EASTL_CT_ASSERTION_FAILURE< (bool)(expression) >)> EASTL_PREPROCESSOR_JOIN1(EASTL_CT_ASSERT_FAILURE_, __LINE__)
516  #endif
517 #else
518  #define EASTL_CT_ASSERT(expression)
519 #endif
520 
521 
522 
524 // EASTL_DEBUG_BREAK
525 //
526 // This function causes an app to immediately stop under the debugger.
527 // It is implemented as a macro in order to allow stopping at the site
528 // of the call.
529 //
530 //
531 // Example usage:
532 // EASTL_DEBUG_BREAK();
533 //
535 
536 #ifndef EASTL_DEBUG_BREAK
537  #if defined(_MSC_VER) && (_MSC_VER >= 1300)
538  #define EASTL_DEBUG_BREAK() __debugbreak() // This is a compiler intrinsic which will map to appropriate inlined asm for the platform.
539  #elif defined(EA_PROCESSOR_MIPS) //
540  #define EASTL_DEBUG_BREAK() asm("break")
541  #elif defined(__SNC__)
542  #define EASTL_DEBUG_BREAK() *(int*)(0) = 0
543  #elif defined(EA_PLATFORM_PS3)
544  #define EASTL_DEBUG_BREAK() asm volatile("tw 31,1,1")
545  #elif defined(EA_PROCESSOR_POWERPC) // Generic PowerPC.
546  #define EASTL_DEBUG_BREAK() asm(".long 0") // This triggers an exception by executing opcode 0x00000000.
547  #elif (defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64)) && defined(EA_ASM_STYLE_INTEL)
548  #define EASTL_DEBUG_BREAK() { __asm int 3 }
549  #elif (defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64)) && (defined(EA_ASM_STYLE_ATT) || defined(__GNUC__))
550  #define EASTL_DEBUG_BREAK() asm("int3")
551  #else
552  void EASTL_DEBUG_BREAK(); // User must define this externally.
553  #endif
554 #else
555  void EASTL_DEBUG_BREAK(); // User must define this externally.
556 #endif
557 
558 
559 
561 // EASTL_ALLOCATOR_COPY_ENABLED
562 //
563 // Defined as 0 or 1. Default is 0 (disabled) until some future date.
564 // If enabled (1) then container operator= copies the allocator from the
565 // source container. It ideally should be set to enabled but for backwards
566 // compatibility with older versions of EASTL it is currently set to 0.
567 //
569 
570 #ifndef EASTL_ALLOCATOR_COPY_ENABLED
571  #define EASTL_ALLOCATOR_COPY_ENABLED 0
572 #endif
573 
574 
575 
577 // EASTL_FIXED_SIZE_TRACKING_ENABLED
578 //
579 // Defined as an integer >= 0. Default is same as EASTL_DEBUG.
580 // If EASTL_FIXED_SIZE_TRACKING_ENABLED is enabled, then fixed
581 // containers in debug builds track the max count of objects
582 // that have been in the container. This allows for the tuning
583 // of fixed container sizes to their minimum required size.
584 //
586 
587 #ifndef EASTL_FIXED_SIZE_TRACKING_ENABLED
588  #define EASTL_FIXED_SIZE_TRACKING_ENABLED EASTL_DEBUG
589 #endif
590 
591 
592 
594 // EASTL_RTTI_ENABLED
595 //
596 // Defined as 0 or 1. Default is 1 if RTTI is supported by the compiler.
597 // This define exists so that we can use some dynamic_cast operations in the
598 // code without warning. dynamic_cast is only used if the specifically refers
599 // to it; EASTL won't do dynamic_cast behind your back.
600 //
601 // Example usage:
602 // #if EASTL_RTTI_ENABLED
603 // pChildClass = dynamic_cast<ChildClass*>(pParentClass);
604 // #endif
605 //
607 
608 #ifndef EASTL_RTTI_ENABLED
609  #if defined(EA_COMPILER_NO_RTTI)
610  #define EASTL_RTTI_ENABLED 0
611  #else
612  #define EASTL_RTTI_ENABLED 1
613  #endif
614 #endif
615 
616 
617 
618 
620 // EASTL_EXCEPTIONS_ENABLED
621 //
622 // Defined as 0 or 1. Default is to follow what the compiler settings are.
623 // The user can predefine EASTL_EXCEPTIONS_ENABLED to 0 or 1; however, if the
624 // compiler is set to disable exceptions then EASTL_EXCEPTIONS_ENABLED is
625 // forced to a value of 0 regardless of the user predefine.
626 //
628 
629 #if !defined(EASTL_EXCEPTIONS_ENABLED) || ((EASTL_EXCEPTIONS_ENABLED == 1) && defined(EA_COMPILER_NO_EXCEPTIONS))
630  #define EASTL_EXCEPTIONS_ENABLED 0
631 #endif
632 
633 
634 
635 
636 
638 // EASTL_STRING_OPT_XXXX
639 //
640 // Enables some options / optimizations options that cause the string class
641 // to behave slightly different from the C++ standard basic_string. These are
642 // options whereby you can improve performance by avoiding operations that
643 // in practice may never occur for you.
644 //
646 
647 #ifndef EASTL_STRING_OPT_CHAR_INIT
648  // Defined as 0 or 1. Default is 1.
649  // Defines if newly created characters are initialized to 0 or left
650  // as random values.
651  // The C++ string standard is to initialize chars to 0.
652  #define EASTL_STRING_OPT_CHAR_INIT 1
653 #endif
654 
655 #ifndef EASTL_STRING_OPT_EXPLICIT_CTORS
656  // Defined as 0 or 1. Default is 0.
657  // Defines if we should implement explicity in constructors where the C++
658  // standard string does not. The advantage of enabling explicit constructors
659  // is that you can do this: string s = "hello"; in addition to string s("hello");
660  // The disadvantage of enabling explicity constructors is that there can be
661  // silent conversions done which impede performance if the user isn't paying
662  // attention.
663  // C++ standard string ctors are not explicit.
664  #define EASTL_STRING_OPT_EXPLICIT_CTORS 0
665 #endif
666 
667 #ifndef EASTL_STRING_OPT_LENGTH_ERRORS
668  // Defined as 0 or 1. Default is equal to EASTL_EXCEPTIONS_ENABLED.
669  // Defines if we check for string values going beyond kMaxSize
670  // (a very large value) and throw exections if so.
671  // C++ standard strings are expected to do such checks.
672  #define EASTL_STRING_OPT_LENGTH_ERRORS EASTL_EXCEPTIONS_ENABLED
673 #endif
674 
675 #ifndef EASTL_STRING_OPT_RANGE_ERRORS
676  // Defined as 0 or 1. Default is equal to EASTL_EXCEPTIONS_ENABLED.
677  // Defines if we check for out-of-bounds references to string
678  // positions and throw exceptions if so. Well-behaved code shouldn't
679  // refence out-of-bounds positions and so shouldn't need these checks.
680  // C++ standard strings are expected to do such range checks.
681  #define EASTL_STRING_OPT_RANGE_ERRORS EASTL_EXCEPTIONS_ENABLED
682 #endif
683 
684 #ifndef EASTL_STRING_OPT_ARGUMENT_ERRORS
685  // Defined as 0 or 1. Default is 0.
686  // Defines if we check for NULL ptr arguments passed to string
687  // functions by the user and throw exceptions if so. Well-behaved code
688  // shouldn't pass bad arguments and so shouldn't need these checks.
689  // Also, some users believe that strings should check for NULL pointers
690  // in all their arguments and do no-ops if so. This is very debatable.
691  // C++ standard strings are not required to check for such argument errors.
692  #define EASTL_STRING_OPT_ARGUMENT_ERRORS 0
693 #endif
694 
695 
696 
698 // EASTL_ABSTRACT_STRING_ENABLED
699 //
700 // Defined as 0 or 1. Default is 0 until abstract string is fully tested.
701 // Defines whether the proposed replacement for the string module is enabled.
702 // See bonus/abstract_string.h for more information.
703 //
704 #ifndef EASTL_ABSTRACT_STRING_ENABLED
705  #define EASTL_ABSTRACT_STRING_ENABLED 0
706 #endif
707 
708 
709 
710 
712 // EASTL_BITSET_SIZE_T
713 //
714 // Defined as 0 or 1. Default is 1.
715 // Controls whether bitset uses size_t or eastl_size_t.
716 //
717 #ifndef EASTL_BITSET_SIZE_T
718  #define EASTL_BITSET_SIZE_T 1
719 #endif
720 
721 
722 
723 
725 // EASTL_LIST_SIZE_CACHE
726 //
727 // Defined as 0 or 1. Default is 0.
728 // If defined as 1, the list and slist containers (and possibly any additional
729 // containers as well) keep a member mSize (or similar) variable which allows
730 // the size() member function to execute in constant time (a.k.a. O(1)).
731 // There are debates on both sides as to whether it is better to have this
732 // cached value or not, as having it entails some cost (memory and code).
733 // To consider: Make list size caching an optional template parameter.
734 //
736 
737 #ifndef EASTL_LIST_SIZE_CACHE
738  #define EASTL_LIST_SIZE_CACHE 0
739 #endif
740 
741 #ifndef EASTL_SLIST_SIZE_CACHE
742  #define EASTL_SLIST_SIZE_CACHE 0
743 #endif
744 
745 
746 
748 // EASTL_MAX_STACK_USAGE
749 //
750 // Defined as an integer greater than zero. Default is 4000.
751 // There are some places in EASTL where temporary objects are put on the
752 // stack. A common example of this is in the implementation of container
753 // swap functions whereby a temporary copy of the container is made.
754 // There is a problem, however, if the size of the item created on the stack
755 // is very large. This can happen with fixed-size containers, for example.
756 // The EASTL_MAX_STACK_USAGE define specifies the maximum amount of memory
757 // (in bytes) that the given platform/compiler will safely allow on the stack.
758 // Platforms such as Windows will generally allow larger values than embedded
759 // systems or console machines, but it is usually a good idea to stick with
760 // a max usage value that is portable across all platforms, lest the user be
761 // surprised when something breaks as it is ported to another platform.
762 //
764 
765 #ifndef EASTL_MAX_STACK_USAGE
766  #define EASTL_MAX_STACK_USAGE 4000
767 #endif
768 
769 
770 
772 // EASTL_VA_COPY_ENABLED
773 //
774 // Defined as 0 or 1. Default is 1 for compilers that need it, 0 for others.
775 // Some compilers on some platforms implement va_list whereby its contents
776 // are destroyed upon usage, even if passed by value to another function.
777 // With these compilers you can use va_copy to restore the a va_list.
778 // Known compiler/platforms that destroy va_list contents upon usage include:
779 // CodeWarrior on PowerPC
780 // GCC on x86-64
781 // However, va_copy is part of the C99 standard and not part of earlier C and
782 // C++ standards. So not all compilers support it. VC++ doesn't support va_copy,
783 // but it turns out that VC++ doesn't need it on the platforms it supports.
784 // For example usage, see the EASTL string.h file.
785 //
787 
788 #ifndef EASTL_VA_COPY_ENABLED
789  #if defined(__MWERKS__) || (defined(__GNUC__) && (__GNUC__ >= 3) && (!defined(__i386__) || defined(__x86_64__)) && !defined(__ppc__) && !defined(__PPC__) && !defined(__PPC64__))
790  #define EASTL_VA_COPY_ENABLED 1
791  #else
792  #define EASTL_VA_COPY_ENABLED 0
793  #endif
794 #endif
795 
796 
797 
799 // EASTL_LIST_PROXY_ENABLED
800 //
801 #if !defined(EASTL_LIST_PROXY_ENABLED)
802  // GCC with -fstrict-aliasing has bugs (or undocumented functionality in their
803  // __may_alias__ implementation. The compiler gets confused about function signatures.
804  // VC8 (1400) doesn't need the proxy because it has built-in smart debugging capabilities.
805  #if defined(EASTL_DEBUG) && (!defined(__GNUC__) || defined(__SNC__)) && (!defined(_MSC_VER) || (_MSC_VER < 1400))
806  #define EASTL_LIST_PROXY_ENABLED 1
807  #define EASTL_LIST_PROXY_MAY_ALIAS EASTL_MAY_ALIAS
808  #else
809  #define EASTL_LIST_PROXY_ENABLED 0
810  #define EASTL_LIST_PROXY_MAY_ALIAS
811  #endif
812 #endif
813 
814 
815 
817 // EASTL_STD_ITERATOR_CATEGORY_ENABLED
818 //
819 // Defined as 0 or 1. Default is 1.
820 // If defined as non-zero, EASTL iterator categories (iterator.h's input_iterator_tag,
821 // forward_iterator_tag, etc.) are defined to be those from std C++ in the std
822 // namespace. The reason for wanting to enable such a feature is that it allows
823 // EASTL containers and algorithms to work with std STL containes and algorithms.
824 //
826 
827 #ifndef EASTL_STD_ITERATOR_CATEGORY_ENABLED
828  #define EASTL_STD_ITERATOR_CATEGORY_ENABLED 1
829 #endif
830 
831 #if EASTL_STD_ITERATOR_CATEGORY_ENABLED
832  #define EASTL_ITC_NS std
833 #else
834  #define EASTL_ITC_NS eastl
835 #endif
836 
837 
838 
839 
841 // EASTL_VALIDATION_ENABLED
842 //
843 // Defined as an integer >= 0. Default is to be equal to EASTL_DEBUG.
844 // If nonzero, then a certain amount of automatic runtime validation is done.
845 // Runtime validation is not considered the same thing as asserting that user
846 // input values are valid. Validation refers to internal consistency checking
847 // of the validity of containers and their iterators. Validation checking is
848 // something that often involves significantly more than basic assertion
849 // checking, and it may sometimes be desirable to disable it.
850 // This macro would generally be used internally by EASTL.
851 //
853 
854 #ifndef EASTL_VALIDATION_ENABLED
855  #define EASTL_VALIDATION_ENABLED EASTL_DEBUG
856 #endif
857 
858 
859 
860 
862 // EASTL_VALIDATE_COMPARE
863 //
864 // Defined as EASTL_ASSERT or defined away. Default is EASTL_ASSERT if EASTL_VALIDATION_ENABLED is enabled.
865 // This is used to validate user-supplied comparison functions, particularly for sorting purposes.
866 //
868 
869 #ifndef EASTL_VALIDATE_COMPARE_ENABLED
870  #define EASTL_VALIDATE_COMPARE_ENABLED EASTL_VALIDATION_ENABLED
871 #endif
872 
873 #if EASTL_VALIDATE_COMPARE_ENABLED
874  #define EASTL_VALIDATE_COMPARE EASTL_ASSERT
875 #else
876  #define EASTL_VALIDATE_COMPARE(expression)
877 #endif
878 
879 
880 
882 // EASTL_VALIDATE_INTRUSIVE_LIST
883 //
884 // Defined as an integral value >= 0. Controls the amount of automatic validation
885 // done by intrusive_list. A value of 0 means no automatic validation is done.
886 // As of this writing, EASTL_VALIDATE_INTRUSIVE_LIST defaults to 0, as it makes
887 // the intrusive_list_node become a non-POD, which may be an issue for some code.
888 //
890 
891 #ifndef EASTL_VALIDATE_INTRUSIVE_LIST
892  #define EASTL_VALIDATE_INTRUSIVE_LIST 0
893 #endif
894 
895 
896 
898 // EASTL_FORCE_INLINE
899 //
900 // Defined as a "force inline" expression or defined away.
901 // You generally don't need to use forced inlining with the Microsoft and
902 // Metrowerks compilers, but you may need it with the GCC compiler (any version).
903 //
904 // Example usage:
905 // template <typename T, typename Allocator>
906 // EASTL_FORCE_INLINE typename vector<T, Allocator>::size_type
907 // vector<T, Allocator>::size() const
908 // { return mpEnd - mpBegin; }
909 //
911 
912 #ifndef EASTL_FORCE_INLINE
913  #define EASTL_FORCE_INLINE EA_FORCE_INLINE
914 #endif
915 
916 
917 
919 // EASTL_MAY_ALIAS
920 //
921 // Defined as a macro that wraps the GCC may_alias attribute. This attribute
922 // has no significance for VC++ because VC++ doesn't support the concept of
923 // strict aliasing. Users should avoid writing code that breaks strict
924 // aliasing rules; EASTL_MAY_ALIAS is for cases with no alternative.
925 //
926 // Example usage:
927 // uint32_t value EASTL_MAY_ALIAS;
928 //
929 // Example usage:
930 // typedef uint32_t EASTL_MAY_ALIAS value_type;
931 // value_type value;
932 //
933 #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 303)
934  #define EASTL_MAY_ALIAS __attribute__((__may_alias__))
935 #else
936  #define EASTL_MAY_ALIAS
937 #endif
938 
939 
940 
942 // EASTL_LIKELY / EASTL_UNLIKELY
943 //
944 // Defined as a macro which gives a hint to the compiler for branch
945 // prediction. GCC gives you the ability to manually give a hint to
946 // the compiler about the result of a comparison, though it's often
947 // best to compile shipping code with profiling feedback under both
948 // GCC (-fprofile-arcs) and VC++ (/LTCG:PGO, etc.). However, there
949 // are times when you feel very sure that a boolean expression will
950 // usually evaluate to either true or false and can help the compiler
951 // by using an explicity directive...
952 //
953 // Example usage:
954 // if(EASTL_LIKELY(a == 0)) // Tell the compiler that a will usually equal 0.
955 // { ... }
956 //
957 // Example usage:
958 // if(EASTL_UNLIKELY(a == 0)) // Tell the compiler that a will usually not equal 0.
959 // { ... }
960 //
962 
963 #ifndef EASTL_LIKELY
964  #if defined(__GNUC__) && (__GNUC__ >= 3)
965  #define EASTL_LIKELY(x) __builtin_expect(!!(x), true)
966  #define EASTL_UNLIKELY(x) __builtin_expect(!!(x), false)
967  #else
968  #define EASTL_LIKELY(x) (x)
969  #define EASTL_UNLIKELY(x) (x)
970  #endif
971 #endif
972 
973 
974 
976 // EASTL_MINMAX_ENABLED
977 //
978 // Defined as 0 or 1; default is 1.
979 // Specifies whether the min and max algorithms are available.
980 // It may be useful to disable the min and max algorithems because sometimes
981 // #defines for min and max exist which would collide with EASTL min and max.
982 // Note that there are already alternative versions of min and max in EASTL
983 // with the min_alt and max_alt functions. You can use these without colliding
984 // with min/max macros that may exist.
985 //
987 #ifndef EASTL_MINMAX_ENABLED
988  #define EASTL_MINMAX_ENABLED 1
989 #endif
990 
991 
992 
994 // EASTL_NOMINMAX
995 //
996 // Defined as 0 or 1; default is 1.
997 // MSVC++ has #defines for min/max which collide with the min/max algorithm
998 // declarations. If EASTL_NOMINMAX is defined as 1, then we undefine min and
999 // max if they are #defined by an external library. This allows our min and
1000 // max definitions in algorithm.h to work as expected. An alternative to
1001 // the enabling of EASTL_NOMINMAX is to #define NOMINMAX in your project
1002 // settings if you are compiling for Windows.
1003 // Note that this does not control the availability of the EASTL min and max
1004 // algorithms; the EASTL_MINMAX_ENABLED configuration parameter does that.
1005 //
1007 
1008 #ifndef EASTL_NOMINMAX
1009  #define EASTL_NOMINMAX 1
1010 #endif
1011 
1012 
1013 
1014 
1016 // EASTL_ALIGN_OF
1017 //
1018 // Determines the alignment of a type.
1019 //
1020 // Example usage:
1021 // size_t alignment = EASTL_ALIGN_OF(int);
1022 //
1024 
1025 #ifndef EASTL_ALIGN_OF
1026  #if defined(__MWERKS__)
1027  #define EASTL_ALIGN_OF(type) ((size_t)__alignof__(type))
1028  #elif !defined(__GNUC__) || (__GNUC__ >= 3) // GCC 2.x doesn't do __alignof correctly all the time.
1029  #define EASTL_ALIGN_OF __alignof
1030  #else
1031  #define EASTL_ALIGN_OF(type) ((size_t)offsetof(struct{ char c; type m; }, m))
1032  #endif
1033 #endif
1034 
1035 
1036 
1037 
1039 // eastl_size_t
1040 //
1041 // Defined as an unsigned integer type, usually either size_t or uint32_t.
1042 // Defaults to uint32_t instead of size_t because the latter wastes memory
1043 // and is sometimes slower on 64 bit machines.
1044 //
1045 // Example usage:
1046 // eastl_size_t n = intVector.size();
1047 //
1049 
1050 #ifndef EASTL_SIZE_T
1051  #if(EA_PLATFORM_WORD_SIZE == 4) // If (sizeof(size_t) == 4) and we can thus use size_t as-is...
1052  #include <stddef.h>
1053  #define EASTL_SIZE_T size_t
1054  #define EASTL_SSIZE_T intptr_t
1055  #else
1056  #define EASTL_SIZE_T uint32_t
1057  #define EASTL_SSIZE_T int32_t
1058  #endif
1059 #endif
1060 
1061 typedef EASTL_SIZE_T eastl_size_t; // Same concept as std::size_t.
1062 typedef EASTL_SSIZE_T eastl_ssize_t; // Signed version of eastl_size_t. Concept is similar to Posix's ssize_t.
1063 
1064 
1065 
1066 
1067 
1068 
1070 // AddRef / Release
1071 //
1072 // AddRef and Release are used for "intrusive" reference counting. By the term
1073 // "intrusive", we mean that the reference count is maintained by the object
1074 // and not by the user of the object. Given that an object implements referencing
1075 // counting, the user of the object needs to be able to increment and decrement
1076 // that reference count. We do that via the venerable AddRef and Release functions
1077 // which the object must supply. These defines here allow us to specify the name
1078 // of the functions. They could just as well be defined to addref and delref or
1079 // IncRef and DecRef.
1080 //
1082 
1083 #ifndef EASTLAddRef
1084  #define EASTLAddRef AddRef
1085 #endif
1086 
1087 #ifndef EASTLRelease
1088  #define EASTLRelease Release
1089 #endif
1090 
1091 
1092 
1093 
1095 // EASTL_ALLOCATOR_EXPLICIT_ENABLED
1096 //
1097 // Defined as 0 or 1. Default is 0 for now but ideally would be changed to
1098 // 1 some day. It's 0 because setting it to 1 breaks some existing code.
1099 // This option enables the allocator ctor to be explicit, which avoids
1100 // some undesirable silent conversions, especially with the string class.
1101 //
1102 // Example usage:
1103 // class allocator
1104 // {
1105 // public:
1106 // EASTL_ALLOCATOR_EXPLICIT allocator(const char* pName);
1107 // };
1108 //
1110 
1111 #ifndef EASTL_ALLOCATOR_EXPLICIT_ENABLED
1112  #define EASTL_ALLOCATOR_EXPLICIT_ENABLED 0
1113 #endif
1114 
1115 #if EASTL_ALLOCATOR_EXPLICIT_ENABLED
1116  #define EASTL_ALLOCATOR_EXPLICIT explicit
1117 #else
1118  #define EASTL_ALLOCATOR_EXPLICIT
1119 #endif
1120 
1121 
1122 
1124 // EASTL allocator
1125 //
1126 // The EASTL allocator system allows you to redefine how memory is allocated
1127 // via some defines that are set up here. In the container code, memory is
1128 // allocated via macros which expand to whatever the user has them set to
1129 // expand to. Given that there are multiple allocator systems available,
1130 // this system allows you to configure it to use whatever system you want,
1131 // provided your system meets the requirements of this library.
1132 // The requirements are:
1133 //
1134 // - Must be constructable via a const char* (name) parameter.
1135 // Some uses of allocators won't require this, however.
1136 // - Allocate a block of memory of size n and debug name string.
1137 // - Allocate a block of memory of size n, debug name string,
1138 // alignment a, and offset o.
1139 // - Free memory allocated via either of the allocation functions above.
1140 // - Provide a default allocator instance which can be used if the user
1141 // doesn't provide a specific one.
1142 //
1144 
1145 // namespace eastl
1146 // {
1147 // class allocator
1148 // {
1149 // allocator(const char* pName = NULL);
1150 //
1151 // void* allocate(size_t n, int flags = 0);
1152 // void* allocate(size_t n, size_t alignment, size_t offset, int flags = 0);
1153 // void deallocate(void* p, size_t n);
1154 //
1155 // const char* get_name() const;
1156 // void set_name(const char* pName);
1157 // };
1158 //
1159 // allocator* GetDefaultAllocator(); // This is used for anonymous allocations.
1160 // }
1161 
1162 #ifndef EASTLAlloc // To consider: Instead of calling through pAllocator, just go directly to operator new, since that's what allocator does.
1163  #define EASTLAlloc(allocator, n) (allocator).allocate(n);
1164 #endif
1165 
1166 #ifndef EASTLAllocFlags // To consider: Instead of calling through pAllocator, just go directly to operator new, since that's what allocator does.
1167  #define EASTLAllocFlags(allocator, n, flags) (allocator).allocate(n, flags);
1168 #endif
1169 
1170 #ifndef EASTLAllocAligned
1171  #define EASTLAllocAligned(allocator, n, alignment, offset) (allocator).allocate((n), (alignment), (offset))
1172 #endif
1173 
1174 #ifndef EASTLFree
1175  #define EASTLFree(allocator, p, size) (allocator).deallocate((p), (size))
1176 #endif
1177 
1178 #ifndef EASTLAllocatorType
1179  #define EASTLAllocatorType eastl::allocator
1180 #endif
1181 
1182 #ifndef EASTLAllocatorDefault
1183  // EASTLAllocatorDefault returns the default allocator instance. This is not a global
1184  // allocator which implements all container allocations but is the allocator that is
1185  // used when EASTL needs to allocate memory internally. There are very few cases where
1186  // EASTL allocates memory internally, and in each of these it is for a sensible reason
1187  // that is documented to behave as such.
1188  #define EASTLAllocatorDefault eastl::GetDefaultAllocator
1189 #endif
1190 
1191 #endif // Header include guard
EASTL_API void AssertionFailure(const char *pExpression)
EASTL_API void AssertionFailureFunctionDefault(const char *pExpression, void *)
EASTL_API void SetAssertionFailureFunction(EASTL_AssertionFailureFunction pAssertionFailureFunction, void *pContext)
EA Standard Template Library.