changeset 2961:4d0db334c7fc

* include/*, tests/*, HISTORY, LICENSE: Update to uSTL 1.4 sources.
author jld
date Tue, 29 Jun 2010 07:30:28 +0000
parents 31c9ab39babe
children 0c51e5cb890a
files packages/NEWS packages/language/cxx/ustl/current/ChangeLog packages/language/cxx/ustl/current/HISTORY packages/language/cxx/ustl/current/LICENSE packages/language/cxx/ustl/current/include/ustl.h packages/language/cxx/ustl/current/include/ustl/sistream.h packages/language/cxx/ustl/current/include/ustl/ulist.h packages/language/cxx/ustl/current/include/ustl/umemory.h packages/language/cxx/ustl/current/include/ustl/uutility.h packages/language/cxx/ustl/current/include/ustl/uvector.h packages/language/cxx/ustl/current/tests/bvt21.cpp packages/language/cxx/ustl/current/tests/bvt21.std
diffstat 12 files changed, 76 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/packages/NEWS
+++ b/packages/NEWS
@@ -1,3 +1,4 @@
+* Update to uSTL 1.4 by Simon Kallweit
 * ADC device driver for AT91 by Christophe Coutand 
 * Major update of lwIP stack to v1.3.2 by Simon Kallweit
 * Port of uSTL 1.3 by Uwe Kindler
--- a/packages/language/cxx/ustl/current/ChangeLog
+++ b/packages/language/cxx/ustl/current/ChangeLog
@@ -1,3 +1,10 @@
+2010-06-25  Simon Kallweit <simon.kallweit@intefo.ch>
+
+	* include/*:
+	* tests/*:
+	* HISTORY:
+	* LICENSE: Updated to uSTL 1.4 sources.
+
 2009-10-06  Uwe Kindler <uwe_kindler@web.de>
 
 	* doc/ustl.sgml: Removed cout.flush() from example and from note.
@@ -35,7 +42,7 @@ 2009-08-20  Uwe Kindler <uwe_kindler@web
 // ####GPLCOPYRIGHTBEGIN####                                                
 // -------------------------------------------                              
 // This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 2009 Free Software Foundation, Inc.                        
+// Copyright (C) 2009, 2010 Free Software Foundation, Inc.                        
 //
 // This program is free software; you can redistribute it and/or modify     
 // it under the terms of the GNU General Public License as published by     
--- a/packages/language/cxx/ustl/current/HISTORY
+++ b/packages/language/cxx/ustl/current/HISTORY
@@ -1,3 +1,9 @@
+2010-03-21 Release 1.4
+	* Fixed crash in destructor of empty vector, introduced by 1.3
+	* Fixed list merge, which previously did not compile
+	* Some portability changes to configure so it will work with dash
+	    when escape char processing bug is fixed (Ubuntu bug #268929)
+
 2009-08-04 Release 1.3
 	* Some API changes to comply with the current C++ standard
 	    binary_search algo returns true, not the found iterator
--- a/packages/language/cxx/ustl/current/LICENSE
+++ b/packages/language/cxx/ustl/current/LICENSE
@@ -1,24 +1,22 @@
 
 			The MIT License
 
-Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
+Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
 
 Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
--- a/packages/language/cxx/ustl/current/include/ustl.h
+++ b/packages/language/cxx/ustl/current/include/ustl.h
@@ -6,6 +6,8 @@
 #ifndef USTL_H_6A5A10410D2CD7FC2D78FE470F045EB7
 #define USTL_H_6A5A10410D2CD7FC2D78FE470F045EB7
 
+#include <pkgconf/ustl.h>
+
 #include "ustl/uspecial.h"
 #include "ustl/umap.h"
 #include "ustl/umultimap.h"
--- a/packages/language/cxx/ustl/current/include/ustl/sistream.h
+++ b/packages/language/cxx/ustl/current/include/ustl/sistream.h
@@ -8,6 +8,9 @@
 
 #include "mistream.h"
 #include "ustring.h"
+#ifndef EOF
+#define EOF (-1)
+#endif
 
 namespace ustl {
 
@@ -38,7 +41,7 @@ public:
     inline string		str (void) const	{ string s; s.link (*this); return (s); }
     inline istringstream&	str (const string& s)	{ link (s); return (*this); }
     inline istringstream&	get (char& c)	{ return (read (&c, sizeof(c))); }
-    inline int			get (void)	{ char c; get(c); return (c); }
+    inline int			get (void)	{ char c = EOF; get(c); return (c); }
     istringstream&		get (char* p, size_type n, char delim = '\n');
     istringstream&		get (string& s, char delim = '\n');
     istringstream&		getline (char* p, size_type n, char delim = '\n');
@@ -137,9 +140,6 @@ ISTRSTREAM_CAST_OPERATOR (char,		int8_t)
 ISTRSTREAM_CAST_OPERATOR (uint64_t,	int64_t)
 #endif
 #if SIZE_OF_LONG == SIZE_OF_INT
-// This works only properly if stdint.h typedefs int to int32_t. If stdint.h
-// typedefs long to int32_t then this causes compiler errors. So make shure
-// that your stdint.h file typedefs int to int32_t.
 ISTRSTREAM_CAST_OPERATOR (long,		int)
 ISTRSTREAM_CAST_OPERATOR (unsigned long,int)
 #endif
--- a/packages/language/cxx/ustl/current/include/ustl/ulist.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ulist.h
@@ -50,9 +50,8 @@ public:
 template <typename T>
 void list<T>::merge (list& l)
 {
-    list<T>::resize (size() + l.size());
-    iterator me = merge (begin(), end(), l.begin(), l.end(), begin());
-    list<T>::resize (distance (begin(), me));
+    insert_space (begin(), l.size());
+    ::ustl::merge (iat(l.size()), end(), l.begin(), l.end(), begin());
 }
 
 /// Moves the range [first, last) from \p l to this list at \p ip.
--- a/packages/language/cxx/ustl/current/include/ustl/umemory.h
+++ b/packages/language/cxx/ustl/current/include/ustl/umemory.h
@@ -75,8 +75,10 @@ template <typename ForwardIterator>
 inline void construct (ForwardIterator first, ForwardIterator last)
 {
     typedef typename iterator_traits<ForwardIterator>::value_type value_type;
-    if (!numeric_limits<value_type>::is_integral && first)
-	for (--last; first <= last; ++first)
+    if (numeric_limits<value_type>::is_integral)
+	memset (first, 0, distance(first,last)*sizeof(value_type));
+    else
+	for (--last; intptr_t(first) <= intptr_t(last); ++first)
 	    construct (&*first);
 }
 
@@ -101,7 +103,7 @@ inline void destroy (T* p) throw()
 // Helper templates to not instantiate anything for integral types.
 template <typename T>
 void dtors (T first, T last) throw()
-    { for (--last; first <= last; ++first) destroy (&*first); }
+    { for (--last; intptr_t(first) <= intptr_t(last); ++first) destroy (&*first); }
 template <typename T, bool bIntegral>
 struct Sdtorsr {
     inline void operator()(T first, T last) throw() { dtors (first, last); }
--- a/packages/language/cxx/ustl/current/include/ustl/uutility.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uutility.h
@@ -145,11 +145,13 @@ UNVOID_DISTANCE(const,)
 #undef UNVOID_DISTANCE
 #endif
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 // The compiler issues a warning if an unsigned type is compared to 0.
 template <typename T, bool IsSigned> struct __is_negative { inline bool operator()(const T& v) { return (v < 0); } };
 template <typename T> struct __is_negative<T,false> { inline bool operator()(const T&) { return (false); } };
 /// Warning-free way to check if \p v is negative, even if for unsigned types.
 template <typename T> inline bool is_negative (const T& v) { return (__is_negative<T,numeric_limits<T>::is_signed>()(v)); }
+#endif
 
 /// \brief Returns the absolute value of \p v
 /// Unlike the stdlib functions, this is inline and works with all types.
@@ -339,6 +341,26 @@ inline bool TestAndSet (int* pm)
 #endif
 }
 
+inline uint32_t NextPow2 (uint32_t v)
+{
+#if __i386__ || __x86_64__
+	asm("dec\t%1\n\t"
+	"mov\t$1,%0\n\t"
+	"bsr\t%1,%1\n\t"
+	"inc\t%1\n\t"
+	"rol\t%b1,%0":"=&r"(v):"c"(v));
+    return (v);
+#else
+    // The following code is sub-optimal but mimics the x86 implementation
+    int i = 31;
+    v--;
+    while (!(v & (1 << i)) && i > 0) i--;
+    if (i == 31)
+    	return 1;
+    return (1 << (i + 1));
+#endif
+}
+
 /// \brief This template is to be used for dereferencing a type-punned pointer without a warning.
 ///
 /// When casting a local variable to an unrelated type through a pointer (for
--- a/packages/language/cxx/ustl/current/include/ustl/uvector.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uvector.h
@@ -98,7 +98,7 @@ public:
     inline void			write (ostream& os) const		{ container_write (os, *this); }
     inline void			text_write (ostringstream& os) const	{ container_text_write (os, *this); }
     inline size_t		stream_size (void) const		{ return (container_stream_size (*this)); }
-private:
+protected:
     inline iterator		insert_space (iterator ip, size_type n);
 private:
     memblock			m_Data;	///< Raw element data, consecutively stored.
--- a/packages/language/cxx/ustl/current/tests/bvt21.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt21.cpp
@@ -33,6 +33,12 @@ void TestUtility (void)
     cout << "Align(17,7) = " << Align(17,7) << endl;
     cout << "Align(14,7) = " << Align(14,7) << endl;
     cout << endl;
+    cout << "NextPow2(0) = " << NextPow2(0) << endl;
+    cout << "NextPow2(1) = " << NextPow2(1) << endl;
+    cout << "NextPow2(4) = " << NextPow2(4) << endl;
+    cout << "NextPow2(3827) = " << NextPow2(3827) << endl;
+    cout << "NextPow2(0xFFFFFFF0) = " << NextPow2(0xFFFFFFF0) << endl;
+    cout << endl;
     cout << "advance(42,0) = " << advance(42,0) << endl;
     cout << "advance(42,3) = " << advance(42,3) << endl;
     const void *cvp = (const void*) 0x1234;
--- a/packages/language/cxx/ustl/current/tests/bvt21.std
+++ b/packages/language/cxx/ustl/current/tests/bvt21.std
@@ -7,6 +7,12 @@ Align(5,2) = 6
 Align(17,7) = 21
 Align(14,7) = 14
 
+NextPow2(0) = 1
+NextPow2(1) = 2
+NextPow2(4) = 4
+NextPow2(3827) = 4096
+NextPow2(0xFFFFFFF0) = 1
+
 advance(42,0) = 42
 advance(42,3) = 45
 cvp = 1234