From 0b7574ba001ade5e72b87bb770fea4f94e4addf3 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 27 Sep 2013 17:13:36 -0700 Subject: [PATCH] Add compilation test script --- beast/Arithmetic.h | 4 + beast/Atomic.h | 10 +- beast/ByteOrder.h | 2 + beast/CStdInt.h | 3 +- beast/Config.h | 2 + beast/Crypto.h | 2 +- beast/HeapBlock.h | 6 +- beast/Memory.h | 22 ++- beast/config/Suffix.h | 25 +++ beast/crypto/Crypto.cpp | 3 - beast/crypto/Sha256.h | 6 +- beast/crypto/impl/Sha256.cpp | 3 - beast/crypto/impl/sha2/sha2.c | 6 +- beast/crypto/impl/sha2/sha2.h | 50 ++---- beast/intrusive/ForwardList.h | 6 +- beast/intrusive/List.h | 178 +--------------------- beast/intrusive/PointerTraits.h | 2 + beast/strings/CharPointer_ASCII.h | 7 + beast/strings/CharPointer_UTF16.h | 6 + beast/strings/CharPointer_UTF32.h | 7 + beast/strings/CharPointer_UTF8.h | 8 +- beast/strings/CharacterFunctions.h | 10 +- beast/strings/NewLine.h | 6 +- beast/strings/String.h | 2 + beast/strings/StringCharPointerType.h | 5 + beast/strings/StringFromNumber.h | 7 + beast/strings/impl/CharacterFunctions.cpp | 5 +- beast/thread/SharedData.h | 2 + beast/thread/SharedMutexAdapter.h | 3 + beast/type_traits/IsIntegral.h | 1 + beast/type_traits/IsSigned.h | 1 + beast/type_traits/RemoveSigned.h | 1 + scripts/BeastConfig.h | 154 +++++++++++++++++++ scripts/compile.sh | 29 ++++ 34 files changed, 343 insertions(+), 241 deletions(-) create mode 100644 beast/config/Suffix.h create mode 100644 scripts/BeastConfig.h create mode 100755 scripts/compile.sh diff --git a/beast/Arithmetic.h b/beast/Arithmetic.h index 0925fc0a9b..8aba10345d 100644 --- a/beast/Arithmetic.h +++ b/beast/Arithmetic.h @@ -24,7 +24,11 @@ #ifndef BEAST_ARITHMETIC_H_INCLUDED #define BEAST_ARITHMETIC_H_INCLUDED +#include "Config.h" +#include "CStdInt.h" + #include +#include namespace beast { diff --git a/beast/Atomic.h b/beast/Atomic.h index e7204003d1..cd54d75ad0 100644 --- a/beast/Atomic.h +++ b/beast/Atomic.h @@ -25,6 +25,7 @@ #define BEAST_ATOMIC_H_INCLUDED #include "Config.h" +#include "CStdInt.h" #include "StaticAssert.h" namespace beast { @@ -69,13 +70,16 @@ public: Type get() const noexcept; /** Copies another value onto this one (atomically). */ - inline Atomic& operator= (const Atomic& other) noexcept { exchange (other.get()); return *this; } + Atomic& operator= (const Atomic& other) noexcept + { exchange (other.get()); return *this; } /** Copies another value onto this one (atomically). */ - inline Atomic& operator= (const Type newValue) noexcept { exchange (newValue); return *this; } + Atomic& operator= (const Type newValue) noexcept + { exchange (newValue); return *this; } /** Atomically sets the current value. */ - void set (Type newValue) noexcept { exchange (newValue); } + void set (Type newValue) noexcept + { exchange (newValue); } /** Atomically sets the current value, returning the value that was replaced. */ Type exchange (Type value) noexcept; diff --git a/beast/ByteOrder.h b/beast/ByteOrder.h index dcc88d43e5..e574cf29e3 100644 --- a/beast/ByteOrder.h +++ b/beast/ByteOrder.h @@ -24,6 +24,8 @@ #ifndef BEAST_BYTEORDER_H_INCLUDED #define BEAST_BYTEORDER_H_INCLUDED +#include "Config.h" +#include "CStdInt.h" #include "Uncopyable.h" namespace beast { diff --git a/beast/CStdInt.h b/beast/CStdInt.h index 3c498f1db5..265f3d9f19 100644 --- a/beast/CStdInt.h +++ b/beast/CStdInt.h @@ -26,8 +26,7 @@ #include "Config.h" -namespace beast -{ +namespace beast { typedef signed char int8; typedef signed short int16; diff --git a/beast/Config.h b/beast/Config.h index 89353891dd..0d1d5df191 100644 --- a/beast/Config.h +++ b/beast/Config.h @@ -32,4 +32,6 @@ #include "config/StandardConfig.h" #include "config/ConfigCheck.h" +#include "config/Suffix.h" + #endif diff --git a/beast/Crypto.h b/beast/Crypto.h index a5f9f6d12a..50d8204661 100644 --- a/beast/Crypto.h +++ b/beast/Crypto.h @@ -20,7 +20,7 @@ #ifndef BEAST_CRYPTO_H_INCLUDED #define BEAST_CRYPTO_H_INCLUDED -#include "crypto/api/Sha256.h" +#include "crypto/Sha256.h" #endif diff --git a/beast/HeapBlock.h b/beast/HeapBlock.h index 144edae140..875dae0e47 100644 --- a/beast/HeapBlock.h +++ b/beast/HeapBlock.h @@ -24,9 +24,13 @@ #ifndef BEAST_HEAPBLOCK_H_INCLUDED #define BEAST_HEAPBLOCK_H_INCLUDED +#include +#include +#include + #include "Memory.h" #include "Uncopyable.h" - + // If the MSVC debug heap headers were included, disable // the macros during the juce include since they conflict. #ifdef _CRTDBG_MAP_ALLOC diff --git a/beast/Memory.h b/beast/Memory.h index f39fa9ca13..538e82e5a0 100644 --- a/beast/Memory.h +++ b/beast/Memory.h @@ -24,15 +24,21 @@ #ifndef BEAST_MEMORY_H_INCLUDED #define BEAST_MEMORY_H_INCLUDED +#include + +#include "Config.h" + namespace beast { //============================================================================== /** Fills a block of memory with zeros. */ -inline void zeromem (void* memory, size_t numBytes) noexcept { memset (memory, 0, numBytes); } +inline void zeromem (void* memory, size_t numBytes) noexcept + { memset (memory, 0, numBytes); } /** Overwrites a structure or object with zeros. */ template -inline void zerostruct (Type& structure) noexcept { memset (&structure, 0, sizeof (structure)); } +void zerostruct (Type& structure) noexcept + { memset (&structure, 0, sizeof (structure)); } /** Delete an object pointer, and sets the pointer to null. @@ -40,26 +46,30 @@ inline void zerostruct (Type& structure) noexcept { memset (&s or other automatic lifetime-management system rather than resorting to deleting raw pointers! */ template -inline void deleteAndZero (Type& pointer) { delete pointer; pointer = nullptr; } +void deleteAndZero (Type& pointer) + { delete pointer; pointer = nullptr; } /** A handy function which adds a number of bytes to any type of pointer and returns the result. This can be useful to avoid casting pointers to a char* and back when you want to move them by a specific number of bytes, */ template -inline Type* addBytesToPointer (Type* pointer, IntegerType bytes) noexcept { return (Type*) (((char*) pointer) + bytes); } +Type* addBytesToPointer (Type* pointer, IntegerType bytes) noexcept + { return (Type*) (((char*) pointer) + bytes); } /** A handy function which returns the difference between any two pointers, in bytes. The address of the second pointer is subtracted from the first, and the difference in bytes is returned. */ template -inline int getAddressDifference (Type1* pointer1, Type2* pointer2) noexcept { return (int) (((const char*) pointer1) - (const char*) pointer2); } +int getAddressDifference (Type1* pointer1, Type2* pointer2) noexcept + { return (int) (((const char*) pointer1) - (const char*) pointer2); } /** If a pointer is non-null, this returns a new copy of the object that it points to, or safely returns nullptr if the pointer is null. */ template -inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != nullptr ? new Type (*pointer) : nullptr; } +Type* createCopyIfNotNull (const Type* pointer) + { return pointer != nullptr ? new Type (*pointer) : nullptr; } //============================================================================== #if BEAST_MAC || BEAST_IOS || DOXYGEN diff --git a/beast/config/Suffix.h b/beast/config/Suffix.h new file mode 100644 index 0000000000..1a85d4b63e --- /dev/null +++ b/beast/config/Suffix.h @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_CONFIG_SUFFIX_H_INCLUDED +#define BEAST_CONFIG_SUFFIX_H_INCLUDED + +// Included at the end of Config.h + +#endif diff --git a/beast/crypto/Crypto.cpp b/beast/crypto/Crypto.cpp index 13fbcf1d21..e2b5228a7e 100644 --- a/beast/crypto/Crypto.cpp +++ b/beast/crypto/Crypto.cpp @@ -19,7 +19,4 @@ #include "BeastConfig.h" -#include "../CStdInt.h" -#include "../config/PlatformConfig.h" - #include "impl/Sha256.cpp" diff --git a/beast/crypto/Sha256.h b/beast/crypto/Sha256.h index 95865d8b34..a3f4c5c528 100644 --- a/beast/crypto/Sha256.h +++ b/beast/crypto/Sha256.h @@ -17,10 +17,10 @@ */ //============================================================================== -#ifndef BEAST_CRYPTO_Sha256_H_INCLUDED -#define BEAST_CRYPTO_Sha256_H_INCLUDED +#ifndef BEAST_CRYPTO_SHA256_H_INCLUDED +#define BEAST_CRYPTO_SHA256_H_INCLUDED -#include "../config/PlatformConfig.h" +#include "../Config.h" #include "../CStdInt.h" #include "../FixedArray.h" diff --git a/beast/crypto/impl/Sha256.cpp b/beast/crypto/impl/Sha256.cpp index 261508ea92..7542c189d1 100644 --- a/beast/crypto/impl/Sha256.cpp +++ b/beast/crypto/impl/Sha256.cpp @@ -39,9 +39,6 @@ namespace Sha256 { //#define SHA2_USE_INTTYPES_H namespace detail { -typedef uint8 u_int8_t; -typedef uint32 u_int32_t; -typedef uint64 u_int64_t; #include "sha2/sha2.c" } diff --git a/beast/crypto/impl/sha2/sha2.c b/beast/crypto/impl/sha2/sha2.c index ab71a26644..45f996fb47 100644 --- a/beast/crypto/impl/sha2/sha2.c +++ b/beast/crypto/impl/sha2/sha2.c @@ -103,9 +103,9 @@ * types and pointing out recent ANSI C support for uintXX_t in inttypes.h. */ -typedef u_int8_t sha2_byte; /* Exactly 1 byte */ -typedef u_int32_t sha2_word32; /* Exactly 4 bytes */ -typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ +typedef uint8 sha2_byte; /* Exactly 1 byte */ +typedef uint32 sha2_word32; /* Exactly 4 bytes */ +typedef uint64 sha2_word64; /* Exactly 8 bytes */ /*** SHA-256/384/512 Various Length Definitions ***********************/ /* NOTE: Most of these are in sha2.h */ diff --git a/beast/crypto/impl/sha2/sha2.h b/beast/crypto/impl/sha2/sha2.h index a3c38807d2..1728d86306 100644 --- a/beast/crypto/impl/sha2/sha2.h +++ b/beast/crypto/impl/sha2/sha2.h @@ -49,36 +49,18 @@ /*** SHA-256/384/512 Various Length Definitions ***********************/ #define SHA256_DIGEST_STRING_LENGTH (Sha256::digestLength * 2 + 1) -#define SHA384_BLOCK_LENGTH 128 -#define SHA384_DIGEST_LENGTH 48 +#define SHA384_BLOCK_LENGTH 128 +#define SHA384_DIGEST_LENGTH 48 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) -#define SHA512_BLOCK_LENGTH 128 -#define SHA512_DIGEST_LENGTH 64 +#define SHA512_BLOCK_LENGTH 128 +#define SHA512_DIGEST_LENGTH 64 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) /*** SHA-256/384/512 Context Structures *******************************/ -/* NOTE: If your architecture does not define either u_intXX_t types or - * uintXX_t (from inttypes.h), you may need to define things by hand - * for your system: - */ -#if 0 -typedef unsigned char u_int8_t; /* 1-byte (8-bits) */ -typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */ -typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ -#endif -/* - * Most BSD systems already define u_intXX_t types, as does Linux. - * Some systems, however, like Compaq's Tru64 Unix instead can use - * uintXX_t types defined by very recent ANSI C standards and included - * in the file: - * - * #include - * - */ typedef struct _SHA512_CTX { - u_int64_t state[8]; - u_int64_t bitcount[2]; - u_int8_t buffer[SHA512_BLOCK_LENGTH]; + uint64 state[8]; + uint64 bitcount[2]; + uint8 buffer[SHA512_BLOCK_LENGTH]; } SHA512_CTX; typedef SHA512_CTX SHA384_CTX; @@ -88,22 +70,22 @@ typedef SHA512_CTX SHA384_CTX; #ifndef NOPROTO void SHA256_Init(Sha256::detail::Context *); -void SHA256_Update(Sha256::detail::Context*, const u_int8_t*, size_t); -void SHA256_Final(u_int8_t[Sha256::digestLength], Sha256::detail::Context*); +void SHA256_Update(Sha256::detail::Context*, const uint8*, size_t); +void SHA256_Final(uint8[Sha256::digestLength], Sha256::detail::Context*); char* SHA256_End(Sha256::detail::Context*, char[SHA256_DIGEST_STRING_LENGTH]); -char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); +char* SHA256_Data(const uint8*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); void SHA384_Init(SHA384_CTX*); -void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t); -void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); +void SHA384_Update(SHA384_CTX*, const uint8*, size_t); +void SHA384_Final(uint8[SHA384_DIGEST_LENGTH], SHA384_CTX*); char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); -char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); +char* SHA384_Data(const uint8*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); void SHA512_Init(SHA512_CTX*); -void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t); -void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); +void SHA512_Update(SHA512_CTX*, const uint8*, size_t); +void SHA512_Final(uint8[SHA512_DIGEST_LENGTH], SHA512_CTX*); char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); -char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); +char* SHA512_Data(const uint8*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); #else /* NOPROTO */ diff --git a/beast/intrusive/ForwardList.h b/beast/intrusive/ForwardList.h index 6c73f66962..86264d0d2f 100644 --- a/beast/intrusive/ForwardList.h +++ b/beast/intrusive/ForwardList.h @@ -20,10 +20,14 @@ #ifndef BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED #define BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED -#include +#include "../Config.h" + #include "PointerTraits.h" + #include "../MPL.h" +#include + // Ideas based on boost namespace beast { diff --git a/beast/intrusive/List.h b/beast/intrusive/List.h index b4d4fdbdca..560f309266 100644 --- a/beast/intrusive/List.h +++ b/beast/intrusive/List.h @@ -20,184 +20,16 @@ #ifndef BEAST_INTRUSIVE_LIST_H_INCLUDED #define BEAST_INTRUSIVE_LIST_H_INCLUDED -#include +#include "../Config.h" + #include "../mpl/CopyConst.h" + #include "../Uncopyable.h" +#include + namespace beast { -/** Intrusive Containers - - # Introduction - - Intrusive containers are special containers that offer better performance - and exception safety guarantees than non-intrusive containers (like the - STL containers). They are useful building blocks for high performance - concurrent systems or other purposes where allocations are restricted - (such as the AudioIODeviceCallback object), because intrusive list - operations do not allocate or free memory. - - While intrusive containers were and are widely used in C, they became more - and more forgotten in C++ due to the presence of the standard containers - which don't support intrusive techniques. VFLib not only reintroduces this - technique to C++ for lists, it also encapsulates the implementation in a - mostly compliant STL interface. Hence anyone familiar with standard - containers can easily use them. - - # Interface - - The interface for intrusive elements in this library is unified for all - containers. Unlike STL containers, objects placed into intrusive containers - are not copied. Instead, a pointer to the object is stored. All - responsibility for object lifetime is the responsibility of the caller; - the intrusive container just keeps track of what is in it. - - Summary of intrusive container differences: - - - Holds pointers to existing objects instead of copies. - - - Does not allocate or free any objects. - - - Requires a element's class declaration to be modified. - - - Methods never throw exceptions when called with valid arguments. - - # Usage - - Like STL containers, intrusive containers are all template based, where the - template argument specifies the type of object that the container will hold. - These declarations specify a doubly linked list where each element points - to a user defined class: - - @code - - struct Object; // Forward declaration - - List list; // Doubly-linked list of Object - - @endcode - - Because intrusive containers allocate no memory, allowing objects to be - placed inside requires a modification to their class declaration. Each - intrusive container declares a nested class `Node` which elements must be - derived from, using the Curiously Recurring Template Pattern (CRTP). We - will continue to fully declare the Object type from the previous example - to support emplacement into an intrusive container: - - @code - - struct Object : public List ::Node // Required for List - { - void performAction (); - }; - - @endcode - - Usage of a typedef eliminates redundant specification of the template - arguments but requires a forward declaration. The following code is - equivalent. - - @code - - struct Object; // Forward declaration - - // Specify template parameters just once - typedef List ListType; - - struct Object : public ListType::Node - { - void performAction (); - }; - - ListType::Node list; - - @endcode - - With these declarations we may proceed to create our objects, add them to - the list, and perform operations: - - @code - - // Create a few objects and put them in the list - for (i = 0; i < 5; ++i) - list.push_back (*new Object); - - // Call a method on each list - for (ListType::iterator iter = list.begin(); iter != list.end (); ++iter) - iter->performAction (); - - @endcode - - Unlike regular STL containers, an object derived from an intrusive container - node cannot exist in more than one instance of that list at a time. This is - because the bookkeeping information for maintaining the list is kept in - the object rather than the list. - - To support objects existing in multiple containers, templates variations - are instantiated by distinguishing them with an empty structure, called a - tag. The object is derived from multiple instances of Node, where each - instance specifies a unique tag. The tag is passed as the second template - argument. When the second argument is unspecified, the default tag is used. - - This declaration example shows the usage of tags to allow an object to exist - simultaneously in two separate lists: - - @code - - struct GlobalListTag { }; // list of all objects - struct ActiveListTag { }; // subset of all objects that are active - - class Object : public List - , public List - { - public: - Object () : m_isActive (false) - { - // Add ourselves to the global list - s_globalList.push_front (*this); - } - - ~Object () - { - deactivate (); - } - - void becomeActive () - { - // Add ourselves to the active list - if (!m_isActive) - { - s_activeList.push_front (*this); - m_isActive = true; - } - } - - void deactivate () - { - if (m_isActive) - { - // Doesn't delete the object - s_activeList.erase (s_activeList.iterator_to (this)); - - m_isActive = false; - } - } - - private: - bool m_isActive; - - static List s_globalList; - static List s_activeList; - } - - @endcode - - @defgroup intrusive intrusive - @ingroup beast_core -*/ - -//------------------------------------------------------------------------------ - template class List; diff --git a/beast/intrusive/PointerTraits.h b/beast/intrusive/PointerTraits.h index e4e733e38b..ccba95f91e 100644 --- a/beast/intrusive/PointerTraits.h +++ b/beast/intrusive/PointerTraits.h @@ -20,6 +20,8 @@ #ifndef BEAST_INTRUSIVE_POINTERTRAITS_H_INCLUDED #define BEAST_INTRUSIVE_POINTERTRAITS_H_INCLUDED +#include + namespace beast { namespace intrusive { diff --git a/beast/strings/CharPointer_ASCII.h b/beast/strings/CharPointer_ASCII.h index 663c61ccaa..4275471140 100644 --- a/beast/strings/CharPointer_ASCII.h +++ b/beast/strings/CharPointer_ASCII.h @@ -24,6 +24,13 @@ #ifndef BEAST_CHARPOINTER_ASCII_H_INCLUDED #define BEAST_CHARPOINTER_ASCII_H_INCLUDED +#include "../Config.h" + +#include "CharacterFunctions.h" + +#include +#include + namespace beast { //============================================================================== diff --git a/beast/strings/CharPointer_UTF16.h b/beast/strings/CharPointer_UTF16.h index 98558b4ddd..b34ed4e9e0 100644 --- a/beast/strings/CharPointer_UTF16.h +++ b/beast/strings/CharPointer_UTF16.h @@ -24,6 +24,12 @@ #ifndef BEAST_CHARPOINTER_UTF16_H_INCLUDED #define BEAST_CHARPOINTER_UTF16_H_INCLUDED +#include "../Config.h" +#include "../Atomic.h" +#include "../CStdInt.h" + +#include "CharacterFunctions.h" + namespace beast { //============================================================================== diff --git a/beast/strings/CharPointer_UTF32.h b/beast/strings/CharPointer_UTF32.h index 847a3001a4..d5dfa082d0 100644 --- a/beast/strings/CharPointer_UTF32.h +++ b/beast/strings/CharPointer_UTF32.h @@ -24,6 +24,13 @@ #ifndef BEAST_CHARPOINTER_UTF32_H_INCLUDED #define BEAST_CHARPOINTER_UTF32_H_INCLUDED +#include "../Config.h" +#include "../Atomic.h" + +#include "CharacterFunctions.h" + +#include + namespace beast { //============================================================================== diff --git a/beast/strings/CharPointer_UTF8.h b/beast/strings/CharPointer_UTF8.h index abf694b9d0..f729c984b1 100644 --- a/beast/strings/CharPointer_UTF8.h +++ b/beast/strings/CharPointer_UTF8.h @@ -24,9 +24,13 @@ #ifndef BEAST_CHARPOINTER_UTF8_H_INCLUDED #define BEAST_CHARPOINTER_UTF8_H_INCLUDED -#include - +#include "../Config.h" #include "../Atomic.h" + +#include "CharacterFunctions.h" + +#include +#include namespace beast { diff --git a/beast/strings/CharacterFunctions.h b/beast/strings/CharacterFunctions.h index 65d533270e..4c17e44633 100644 --- a/beast/strings/CharacterFunctions.h +++ b/beast/strings/CharacterFunctions.h @@ -24,8 +24,11 @@ #ifndef BEAST_STRINGS_CHARACTERFUNCTIONS_H_INCLUDED #define BEAST_STRINGS_CHARACTERFUNCTIONS_H_INCLUDED +#include + #include "../Config.h" #include "../CStdInt.h" +#include "../Memory.h" namespace beast { @@ -329,8 +332,11 @@ public: static size_t copyWithDestByteLimit (DestCharPointerType& dest, SrcCharPointerType src, size_t maxBytesToWrite) noexcept { typename DestCharPointerType::CharType const* const startAddress = dest.getAddress(); - ssize_t maxBytes = (ssize_t) maxBytesToWrite; - maxBytes -= sizeof (typename DestCharPointerType::CharType); // (allow for a terminating null) + size_t maxBytes = maxBytesToWrite; + if (maxBytes >= sizeof (typename DestCharPointerType::CharType)) + maxBytes -= sizeof (typename DestCharPointerType::CharType); // (allow for a terminating null) + else + maxBytes = 0; for (;;) { diff --git a/beast/strings/NewLine.h b/beast/strings/NewLine.h index 3bb4315b0a..23dfb0c058 100644 --- a/beast/strings/NewLine.h +++ b/beast/strings/NewLine.h @@ -21,11 +21,13 @@ */ //============================================================================== -#ifndef BEAST_NEWLINE_H_INCLUDED -#define BEAST_NEWLINE_H_INCLUDED +#ifndef BEAST_STRINGS_NEWLINE_H_INCLUDED +#define BEAST_STRINGS_NEWLINE_H_INCLUDED #include "../Config.h" +#include "String.h" + namespace beast { //============================================================================== diff --git a/beast/strings/String.h b/beast/strings/String.h index c895d99ee1..03d26ca77c 100644 --- a/beast/strings/String.h +++ b/beast/strings/String.h @@ -26,6 +26,8 @@ #include "../Config.h" #include "../CStdInt.h" +#include "../Memory.h" + #include "CharacterFunctions.h" #if BEAST_MSVC # pragma warning (push) diff --git a/beast/strings/StringCharPointerType.h b/beast/strings/StringCharPointerType.h index 9a5373d689..ef2de5ec32 100644 --- a/beast/strings/StringCharPointerType.h +++ b/beast/strings/StringCharPointerType.h @@ -24,6 +24,11 @@ #ifndef BEAST_STRINGS_STRINGCHARPOINTERTYPE_H_INCLUDED #define BEAST_STRINGS_STRINGCHARPOINTERTYPE_H_INCLUDED +#include "../Config.h" +#include "CharPointer_UTF8.h" +#include "CharPointer_UTF16.h" +#include "CharPointer_UTF32.h" + namespace beast { /** This is the character encoding type used internally to store the string. diff --git a/beast/strings/StringFromNumber.h b/beast/strings/StringFromNumber.h index bd2ace60d7..3534f27b02 100644 --- a/beast/strings/StringFromNumber.h +++ b/beast/strings/StringFromNumber.h @@ -24,8 +24,15 @@ #ifndef BEAST_STRINGS_STRINGFROMNUMBER_H_INCLUDED #define BEAST_STRINGS_STRINGFROMNUMBER_H_INCLUDED +#include "../Config.h" #include "../Arithmetic.h" +#include "StringCharPointerType.h" + +#include +#include +#include + namespace beast { // VFALCO TODO Put this in namespace detail diff --git a/beast/strings/impl/CharacterFunctions.cpp b/beast/strings/impl/CharacterFunctions.cpp index 4920e7634a..6158f70ae9 100644 --- a/beast/strings/impl/CharacterFunctions.cpp +++ b/beast/strings/impl/CharacterFunctions.cpp @@ -21,10 +21,11 @@ */ //============================================================================== -#include - #include "../CharacterFunctions.h" +#include +#include + namespace beast { #if BEAST_MSVC diff --git a/beast/thread/SharedData.h b/beast/thread/SharedData.h index 8c4b8e921e..118e3a5f10 100644 --- a/beast/thread/SharedData.h +++ b/beast/thread/SharedData.h @@ -20,6 +20,8 @@ #ifndef BEAST_THREAD_SHAREDDATA_H_INCLUDED #define BEAST_THREAD_SHAREDDATA_H_INCLUDED +#include "SharedMutexAdapter.h" + namespace beast { diff --git a/beast/thread/SharedMutexAdapter.h b/beast/thread/SharedMutexAdapter.h index 2e5252a6b2..90115901af 100644 --- a/beast/thread/SharedMutexAdapter.h +++ b/beast/thread/SharedMutexAdapter.h @@ -20,6 +20,9 @@ #ifndef BEAST_THREAD_SHAREDMUTEXADAPTER_H_INCLUDED #define BEAST_THREAD_SHAREDMUTEXADAPTER_H_INCLUDED +#include "LockGuard.h" +#include "SharedLockGuard.h" + namespace beast { diff --git a/beast/type_traits/IsIntegral.h b/beast/type_traits/IsIntegral.h index 695be9499b..96b8840328 100644 --- a/beast/type_traits/IsIntegral.h +++ b/beast/type_traits/IsIntegral.h @@ -20,6 +20,7 @@ #ifndef BEAST_TYPE_TRAITS_ISINTEGRAL_H_INCLUDED #define BEAST_TYPE_TRAITS_ISINTEGRAL_H_INCLUDED +#include "../CStdInt.h" #include "IntegralConstant.h" namespace beast { diff --git a/beast/type_traits/IsSigned.h b/beast/type_traits/IsSigned.h index 36db7d93d4..908dd62e09 100644 --- a/beast/type_traits/IsSigned.h +++ b/beast/type_traits/IsSigned.h @@ -21,6 +21,7 @@ #define BEAST_TYPE_TRAITS_ISSIGNED_H_INCLUDED #include "IntegralConstant.h" +#include "../CStdInt.h" namespace beast { diff --git a/beast/type_traits/RemoveSigned.h b/beast/type_traits/RemoveSigned.h index cd12e0e141..e159d4d4bb 100644 --- a/beast/type_traits/RemoveSigned.h +++ b/beast/type_traits/RemoveSigned.h @@ -21,6 +21,7 @@ #define BEAST_TYPE_TRAITS_REMOVESIGNED_H_INCLUDED #include "IntegralConstant.h" +#include "../CStdInt.h" namespace beast { diff --git a/scripts/BeastConfig.h b/scripts/BeastConfig.h new file mode 100644 index 0000000000..4c8e9aa1c0 --- /dev/null +++ b/scripts/BeastConfig.h @@ -0,0 +1,154 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_BEASTCONFIG_H_INCLUDED +#define BEAST_BEASTCONFIG_H_INCLUDED + +/** Configuration file for Beast. + This sets various configurable options for Beast. In order to compile you + must place a copy of this file in a location where your build environment + can find it, and then customize its contents to suit your needs. + @file BeastConfig.h +*/ + +//------------------------------------------------------------------------------ +// +// Diagnostics +// +//------------------------------------------------------------------------------ + +/** Config: BEAST_FORCE_DEBUG + Normally, BEAST_DEBUG is set to 1 or 0 based on compiler and project + settings, but if you define this value, you can override this to force it + to be true or false. +*/ +#ifndef BEAST_FORCE_DEBUG +//#define BEAST_FORCE_DEBUG 1 +#endif + +/** Config: BEAST_LOG_ASSERTIONS + If this flag is enabled, the the bassert and bassertfalse macros will always + use Logger::writeToLog() to write a message when an assertion happens. + Enabling it will also leave this turned on in release builds. When it's + disabled, however, the bassert and bassertfalse macros will not be compiled + in a release build. + @see bassert, bassertfalse, Logger +*/ +#ifndef BEAST_LOG_ASSERTIONS +//#define BEAST_LOG_ASSERTIONS 1 +#endif + +/** Config: BEAST_CHECK_MEMORY_LEAKS + Enables a memory-leak check for certain objects when the app terminates. + See the LeakChecked class for more details about enabling leak checking for + specific classes. +*/ +#ifndef BEAST_CHECK_MEMORY_LEAKS +//#define BEAST_CHECK_MEMORY_LEAKS 0 +#endif + +/** Config: BEAST_COMPILER_CHECKS_SOCKET_OVERRIDES + Setting this option makes Socket-derived classes generate compile errors + if they forget any of the virtual overrides As some Socket-derived classes + intentionally omit member functions that are not applicable, this macro + should only be enabled temporarily when writing your own Socket-derived + class, to make sure that the function signatures match as expected. +*/ +#ifndef BEAST_COMPILER_CHECKS_SOCKET_OVERRIDES +//#define BEAST_COMPILER_CHECKS_SOCKET_OVERRIDES 1 +#endif + +/** Config: BEAST_CATCH_UNHANDLED_EXCEPTIONS + This will wrap thread entry points with an exception catching block. + A customizable hook is provided to get called when unhandled exceptions + are thrown. + @see ProtectedCall +*/ +#ifndef BEAST_CATCH_UNHANDLED_EXCEPTIONS +//#define BEAST_CATCH_UNHANDLED_EXCEPTIONS 1 +#endif + +//------------------------------------------------------------------------------ +// +// Libraries +// +//------------------------------------------------------------------------------ + +/** Config: BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES + In a Visual C++ build, this can be used to stop the required system libs + being automatically added to the link stage. +*/ +#ifndef BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES +//#define BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES 1 +#endif + +/** Config: BEAST_INCLUDE_ZLIB_CODE + This can be used to disable Beast's embedded 3rd-party zlib code. + You might need to tweak this if you're linking to an external zlib library + in your app, but for normal apps, this option should be left alone. + + If you disable this, you might also want to set a value for + BEAST_ZLIB_INCLUDE_PATH, to specify the path where your zlib headers live. +*/ +#ifndef BEAST_INCLUDE_ZLIB_CODE +//#define BEAST_INCLUDE_ZLIB_CODE 1 +#endif + +/** Config: BEAST_ZLIB_INCLUDE_PATH + This is included when BEAST_INCLUDE_ZLIB_CODE is set to zero. +*/ +#ifndef BEAST_ZLIB_INCLUDE_PATH +#define BEAST_ZLIB_INCLUDE_PATH +#endif + +/** Config: BEAST_FUNCTIONAL_USES_### + source configuration. + Set one of these to manually force a particular implementation of bind(). + If nothing is chosen then beast will use whatever is appropriate for your + environment based on what is available. + If you override these, set ONE to 1 and the rest to 0 +*/ +#ifndef BEAST_FUNCTIONAL_USES_STD +//#define BEAST_FUNCTIONAL_USES_STD 0 +#endif +#ifndef BEAST_FUNCTIONAL_USES_TR1 +//#define BEAST_FUNCTIONAL_USES_TR1 0 +#endif +#ifndef BEAST_FUNCTIONAL_USES_BOOST +//#define BEAST_FUNCTIONAL_USES_BOOST 0 +#endif + +//------------------------------------------------------------------------------ +// +// Boost +// +//------------------------------------------------------------------------------ + +/** Config: BEAST_USE_BOOST_FEATURES + This activates boost specific features and improvements. If this is + turned on, the include paths for your build environment must be set + correctly to find the boost headers. +*/ +#ifndef BEAST_USE_BOOST_FEATURES +//#define BEAST_USE_BOOST_FEATURES 1 +#endif + +//------------------------------------------------------------------------------ + +#endif diff --git a/scripts/compile.sh b/scripts/compile.sh new file mode 100755 index 0000000000..7b4eb18a2b --- /dev/null +++ b/scripts/compile.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# This script makes sure that every directly includable header +# file compiles stand-alone for all supported platforms. +# + +for f in $1/*.h $1/*/*.h +do +{ + echo "Compilng '$f'" +g++ -xc++ - -c -o /dev/null <