├── .gitignore ├── .vscode └── settings.json ├── Jamfile ├── Makefile ├── README.md ├── StandardCplusplus.h ├── algorithm ├── algorithm.cpp ├── associative_base ├── associative_base.cpp ├── basic_definitions ├── bitset ├── bitset.cpp ├── cassert ├── cctype ├── cerrno ├── cfloat ├── char_traits ├── char_traits.cpp ├── climits ├── clocale ├── cmath ├── complex ├── complex.cpp ├── csetjmp ├── csignal ├── cstdarg ├── cstddef ├── cstdio ├── cstdlib ├── cstring ├── ctime ├── cwchar ├── cwctype ├── del_op.cpp ├── del_opnt.cpp ├── del_opv.cpp ├── del_opvnt.cpp ├── deque ├── deque.cpp ├── eh_alloc.cpp ├── eh_globals.cpp ├── examples ├── serstream │ ├── Jamfile │ ├── more.cpp │ ├── runtests.sh │ ├── serstream.ino │ └── test.ex └── string_vector │ ├── Jamfile │ └── string_vector.ino ├── exception ├── exception.cpp ├── fstream ├── fstream.cpp ├── func_exception ├── func_exception.cpp ├── functional ├── initializer_list ├── iomanip ├── iomanip.cpp ├── ios ├── ios.cpp ├── iosfwd ├── iostream ├── iostream.cpp ├── istream ├── istream.cpp ├── istream_helpers ├── iterator ├── iterator.cpp ├── iterator_base ├── library.json ├── limits ├── limits.cpp ├── list ├── list.cpp ├── locale ├── locale.cpp ├── map ├── map.cpp ├── memory ├── new ├── new_handler.cpp ├── new_op.cpp ├── new_opnt.cpp ├── new_opv.cpp ├── new_opvnt.cpp ├── numeric ├── numeric.cpp ├── ostream ├── ostream.cpp ├── ostream_helpers ├── queue ├── queue.cpp ├── serstream ├── set ├── set.cpp ├── sstream ├── sstream.cpp ├── stack ├── stack.cpp ├── stdexcept ├── stdexcept.cpp ├── streambuf ├── streambuf.cpp ├── string ├── string.cpp ├── string_iostream ├── support ├── support.cpp ├── system_configuration.h ├── type_traits ├── typeinfo ├── typeinfo.cpp ├── uartbuf ├── unwind-cxx.h ├── utility.cpp ├── utility.h ├── valarray ├── valarray.cpp ├── vector └── vector.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | 16000000/ 2 | .*.swp 3 | *.orig 4 | *.bak 5 | version.h 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "support": "cpp" 4 | } 5 | } -------------------------------------------------------------------------------- /Jamfile: -------------------------------------------------------------------------------- 1 | UCLIBCPP_DIR = $(HOME)/Source/uClibc++ ; 2 | 3 | rule FixCopy 4 | { 5 | Depends $(<) : $(>) ; 6 | Clean clean : $(<) ; 7 | Depends all : $(<) ; 8 | } 9 | 10 | actions FixCopy 11 | { 12 | sed -e "s///g" $(>) > $(<) 13 | } 14 | 15 | for file in [ GLOB $(UCLIBCPP_DIR)/include : [^.]* ] 16 | { 17 | local _o = $(file:D=$(PWD)) ; 18 | if ( $(file:B) = "utility" ) 19 | { 20 | _o = $(_o:S=.h) ; 21 | } 22 | FixCopy $(_o) : $(file) ; 23 | } 24 | 25 | for file in [ GLOB $(UCLIBCPP_DIR)/src : *.cpp ] 26 | { 27 | local _o = $(file:D=$(PWD)) ; 28 | FixCopy $(_o) : $(file) ; 29 | } 30 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR=../ 2 | include $(TOPDIR)Rules.mak 3 | 4 | all: 5 | 6 | clean: 7 | 8 | distclean: 9 | 10 | HEADERS = $(filter-out .svn CVS Makefile,$(wildcard *)) 11 | install: 12 | $(INSTALL) -d $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR) 13 | $(INSTALL) -m 644 $(HEADERS) $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR) 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Standard C++ for Arduino 2 | 3 | ## What is this? 4 | 5 | This is a straight port of [uClibc++](http://cxx.uclibc.org/) for Arduino. 6 | I have cut nothing out and held nothing back. Use with care! 7 | 8 | That said, I have used uClibc++'s own internal configuration to pare back 9 | un-needed stuff, like support for floats, gratuitous template 10 | instantiations and other things. See system\_configuration.h for all of 11 | those gory details. 12 | 13 | Plus I added in [Andy Brown's](http://andybrown.me.uk/ws/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/#IDComment246044033) 14 | excellent ohserialstream class for managing the HardwareSerial as an ostream. 15 | 16 | ## How do I install it? 17 | 18 | This is installed just like a regular Arduino library. Unpack the contents 19 | of the distribution into the 'libraries' folder under your sketchbook. For 20 | example, my sketchbook is at /home/maniacbug/Source/Arduino, so this 21 | library is in /home/maniacbug/Source/Arduino/libraries/StandardCplusplus . 22 | 23 | Be sure to reset your Arduino IDE after installing it. 24 | 25 | ## How do I use it? 26 | 27 | You need an extra #include. It has to come before C++ standard library #includes: 28 | 29 | ```C++ 30 | #include 31 | ``` 32 | 33 | Otherwise, you will see cryptic messages like this: 34 | 35 | fatal error: vector: No such file or directory 36 | 37 | ## How do I try it out? 38 | 39 | From the Arduino IDE, navigate the menus to: 40 | File > Examples > StandardCplusplus > string\_vector 41 | 42 | Upload that, set your serial monitor to 57600 baud, and check the output. 43 | 44 | ## How do I learn more? 45 | 46 | The web is your friend. [cplusplus.com](http://cplusplus.com/reference/) is my personal favorite reference. 47 | 48 | ## Which versions does it work with? 49 | 50 | Arduino 1.0 and beyond. 51 | 52 | ## What is the license? 53 | 54 | uClibc++ is LGPL, so this port is also. Andy's file is actually 55 | CC-BY-SA, however he indicated he'd be releasing it using the 3-clause 56 | modified BSD license, so it will be fully compatible with uClibc++. 57 | -------------------------------------------------------------------------------- /StandardCplusplus.h: -------------------------------------------------------------------------------- 1 | #undef abs 2 | -------------------------------------------------------------------------------- /algorithm.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | 21 | #include 22 | 23 | 24 | namespace std{ 25 | 26 | 27 | 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /associative_base.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /basic_definitions: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | This library is free software; you can redistribute it and/or 4 | modify it under the terms of the GNU Lesser General Public 5 | License as published by the Free Software Foundation; either 6 | version 2.1 of the License, or (at your option) any later version. 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | #ifndef __BASIC_DEFINITIONS 19 | #define __BASIC_DEFINITIONS 1 20 | 21 | #include 22 | 23 | #pragma GCC visibility push(default) 24 | 25 | //The following is used to support GCC symbol visibility patch 26 | 27 | #ifdef GCC_HASCLASSVISIBILITY 28 | #define _UCXXEXPORT __attribute__ ((visibility("default"))) 29 | #define _UCXXLOCAL __attribute__ ((visibility("hidden"))) 30 | #else 31 | #define _UCXXEXPORT 32 | #define _UCXXLOCAL 33 | 34 | #endif 35 | 36 | #ifdef __GCC__ 37 | #define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) 38 | #else 39 | #define __UCLIBCXX_NORETURN 40 | #endif 41 | 42 | #ifdef __UCLIBCXX_HAS_TLS__ 43 | #define __UCLIBCXX_TLS __thread 44 | #else 45 | #define __UCLIBCXX_TLS 46 | #endif 47 | 48 | 49 | 50 | //Testing purposes 51 | #define __STRING_MAX_UNITS 65535 52 | 53 | namespace std{ 54 | typedef signed long int streamsize; 55 | } 56 | 57 | #pragma GCC visibility pop 58 | 59 | #endif 60 | 61 | 62 | #ifdef __DODEBUG__ 63 | #define UCLIBCXX_DEBUG 1 64 | #else 65 | #define UCLIBCXX_DEBUG 0 66 | #endif 67 | -------------------------------------------------------------------------------- /bitset.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cassert: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | -------------------------------------------------------------------------------- /cctype: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | 21 | namespace std{ 22 | 23 | using ::isalnum; 24 | using ::isalpha; 25 | using ::iscntrl; 26 | using ::isdigit; 27 | using ::isgraph; 28 | using ::islower; 29 | using ::isprint; 30 | using ::ispunct; 31 | using ::isspace; 32 | using ::isupper; 33 | using ::isxdigit; 34 | using ::tolower; 35 | using ::toupper; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /cerrno: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | -------------------------------------------------------------------------------- /cfloat: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef __STD_HEADER_CFLOAT 23 | #define __STD_HEADER_CFLOAT 1 24 | 25 | 26 | #include 27 | 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /char_traits: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __UCLIBCXX_HAS_WCHAR__ 25 | #include 26 | #include 27 | #endif 28 | 29 | #ifndef __HEADER_CHAR_TRAITS 30 | #define __HEADER_CHAR_TRAITS 1 31 | 32 | namespace std{ 33 | /* Inlining all wrapped function calls to shrink the amount of code generated*/ 34 | //Typedefs to use for stuff 35 | typedef signed int char_traits_off_type; 36 | 37 | //Generic char_traits 38 | template struct _UCXXEXPORT char_traits { }; 39 | 40 | //Specialize for char 41 | template<> struct _UCXXEXPORT char_traits { 42 | typedef char char_type; 43 | typedef short int int_type; 44 | typedef char_traits_off_type off_type; 45 | typedef char_traits_off_type pos_type; 46 | typedef char state_type; 47 | 48 | inline static void assign(char_type & c, const char_type & d) { c = d; } 49 | 50 | static bool eq(const char_type& c1, const char_type& c2); 51 | 52 | static char_type to_char_type(const int_type & i); 53 | 54 | inline static int_type to_int_type(const char_type & c){ 55 | return (short int)(unsigned char)c; 56 | } 57 | 58 | inline static bool eq_int_type(const int_type & a, const int_type & b){ 59 | if(a==b){ 60 | return true; 61 | } 62 | return false; 63 | } 64 | 65 | 66 | inline static bool lt(const char_type& c1, const char_type& c2){ 67 | if(strncmp(&c1, &c2, 1) < 0){ 68 | return true; 69 | } 70 | return false; 71 | } 72 | 73 | inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ 74 | return (char*) memmove(s1, s2, n); 75 | } 76 | 77 | inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ 78 | for(unsigned long int i=0; i< n; ++i){ 79 | assign(s1[i], s2[i]); 80 | } 81 | return s1 + n; 82 | } 83 | 84 | inline static char_type* assign(char_type* s, size_t n, char_type a){ 85 | return (char *)memset(s, a, n); 86 | } 87 | 88 | inline static int compare(const char_type* s1, const char_type* s2, size_t n){ 89 | return strncmp(s1, s2, n); 90 | } 91 | 92 | inline static size_t length(const char_type* s){ 93 | return strlen(s); 94 | } 95 | 96 | static const char_type* find(const char_type* s, int n, const char_type& a); 97 | 98 | inline static char_type eos() { return 0; } 99 | inline static int_type eof() { return -1; } 100 | inline static int_type not_eof(const int_type & i) { 101 | if(i == -1){ 102 | return 0; 103 | } else { 104 | return i; 105 | } 106 | } 107 | static state_type get_state(pos_type p){ 108 | p = p; 109 | state_type a; 110 | return a; 111 | } 112 | }; 113 | 114 | 115 | #ifdef __UCLIBCXX_HAS_WCHAR__ 116 | template<> struct _UCXXEXPORT char_traits { 117 | typedef wchar_t char_type; 118 | typedef wint_t int_type; 119 | typedef char_traits_off_type off_type; 120 | typedef char_traits_off_type pos_type; 121 | typedef mbstate_t state_type; 122 | 123 | static void assign(char_type & c, const char_type & d){ c=d; } 124 | 125 | static char_type to_char_type(const int_type & i){ 126 | return i; 127 | } 128 | 129 | static int_type to_int_type(const char_type & c){ 130 | return c; 131 | } 132 | 133 | inline static bool eq_int_type(const int_type & a, const int_type & b){ 134 | if(a==b){ 135 | return true; 136 | } 137 | return false; 138 | } 139 | 140 | inline static bool eq(const char_type& c1, const char_type& c2){ 141 | if(wcsncmp(&c1, &c2, 1) == 0){ 142 | return true; 143 | } 144 | return false; 145 | } 146 | 147 | inline static bool lt(const char_type& c1, const char_type& c2){ 148 | if(wcsncmp(&c1, &c2, 1) < 0){ 149 | return true; 150 | } 151 | return false; 152 | } 153 | 154 | inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ 155 | return (char_type*) memmove(s1, s2, n * sizeof(char_type)); 156 | } 157 | 158 | inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ 159 | for(unsigned long int i=0; i< n; ++i){ 160 | assign(s1[i], s2[i]); 161 | } 162 | return s1 + n; 163 | } 164 | 165 | inline static char_type* assign(char_type* s, size_t n, char_type a){ 166 | return (char_type *)memset(s, a, n); /*FIXME*/ 167 | } 168 | 169 | inline static int compare(const char_type* s1, const char_type* s2, size_t n){ 170 | return wcsncmp(s1, s2, n); 171 | } 172 | 173 | inline static size_t length(const char_type* s){ 174 | return wcslen(s); 175 | } 176 | 177 | static const char_type* find(const char_type* s, int n, const char_type& a); 178 | 179 | inline static char_type eos() { return 0; } 180 | inline static int_type eof() { return WEOF; } 181 | inline static int_type not_eof(const int_type & i) { 182 | if(i == WEOF){ 183 | return (int_type)0; 184 | } else { 185 | return i; 186 | } 187 | } 188 | static state_type get_state(pos_type){ 189 | state_type a; 190 | return a; 191 | } 192 | }; 193 | #endif 194 | 195 | } 196 | 197 | #endif 198 | 199 | -------------------------------------------------------------------------------- /char_traits.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | */ 20 | 21 | #define __UCLIBCXX_COMPILE_CHAR_TRAITS__ 1 22 | 23 | 24 | #include 25 | #include 26 | 27 | namespace std{ 28 | 29 | _UCXXEXPORT const char_traits::char_type* char_traits::find(const char_type* s, int n, const char_type& a){ 30 | for(int i=0; i < n; i++){ 31 | if(eq(s[i], a)){ 32 | return (s+i); 33 | } 34 | } 35 | return 0; 36 | } 37 | 38 | _UCXXEXPORT bool char_traits::eq(const char_type& c1, const char_type& c2){ 39 | if(strncmp(&c1, &c2, 1) == 0){ 40 | return true; 41 | } 42 | return false; 43 | } 44 | 45 | _UCXXEXPORT char_traits::char_type char_traits::to_char_type(const int_type & i){ 46 | if(i > 0 && i <= 255){ 47 | return (char)(unsigned char)i; 48 | } 49 | 50 | //Out of range 51 | return 0; 52 | } 53 | 54 | 55 | 56 | #ifdef __UCLIBCXX_HAS_WCHAR__ 57 | 58 | _UCXXEXPORT const char_traits::char_type* char_traits::find(const char_type* s, int n, const char_type& a){ 59 | for(int i=0; i < n; i++){ 60 | if(eq(s[i], a)){ 61 | return (s+i); 62 | } 63 | } 64 | return 0; 65 | } 66 | 67 | #endif 68 | 69 | } 70 | -------------------------------------------------------------------------------- /climits: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __STD_HEADER_CLIMITS 21 | #define __STD_HEADER_CLIMITS 1 22 | 23 | 24 | #include 25 | 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /clocale: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __STD_HEADER_CLOCALE 20 | #define __STD_HEADER_CLOCALE 1 21 | 22 | #include 23 | 24 | namespace std { 25 | using ::lconv; 26 | using ::setlocale; 27 | using ::localeconv; 28 | } 29 | 30 | #endif // __STD_HEADER_CLOCALE 31 | -------------------------------------------------------------------------------- /cmath: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef __STD_HEADER_CMATH 23 | #define __STD_HEADER_CMATH 1 24 | 25 | namespace std{ 26 | #if ! defined(__AVR__) 27 | using ::acos; 28 | using ::asin; 29 | using ::atan; 30 | using ::atan2; 31 | using ::ceil; 32 | using ::cos; 33 | using ::cosh; 34 | using ::exp; 35 | using ::fabs; 36 | using ::floor; 37 | using ::fmod; 38 | using ::frexp; 39 | using ::ldexp; 40 | using ::log; 41 | using ::log10; 42 | using ::modf; 43 | using ::pow; 44 | using ::sin; 45 | using ::sinh; 46 | using ::sqrt; 47 | using ::tan; 48 | using ::tanh; 49 | 50 | inline float abs (float x){ 51 | return fabsf(x); 52 | } 53 | inline float acos (float x){ 54 | return acosf(x); 55 | } 56 | inline float asin (float x){ 57 | return asinf(x); 58 | } 59 | inline float atan (float x){ 60 | return atanf(x); 61 | } 62 | inline float atan2(float y, float x){ 63 | return atan2f(y, x); 64 | } 65 | inline float ceil (float x){ 66 | return ceilf(x); 67 | } 68 | inline float cos (float x){ 69 | return cosf(x); 70 | } 71 | inline float cosh (float x){ 72 | return coshf(x); 73 | } 74 | inline float exp (float x){ 75 | return expf(x); 76 | } 77 | inline float fabs (float x){ 78 | return fabsf(x); 79 | } 80 | inline float floor(float x){ 81 | return floorf(x); 82 | } 83 | inline float fmod (float x, float y){ 84 | return fmodf(x, y); 85 | } 86 | inline float frexp(float x, int* exp){ 87 | return frexpf(x, exp); 88 | } 89 | inline float ldexp(float x, int exp){ 90 | return ldexpf(x, exp); 91 | } 92 | inline float log (float x){ 93 | return logf(x); 94 | } 95 | inline float log10(float x){ 96 | return log10f(x); 97 | } 98 | inline float modf (float x, float* inptr){ 99 | return modff(x, inptr); 100 | } 101 | inline float pow (float x, float y){ 102 | return powf(x, y); 103 | } 104 | inline float pow (float x, int y){ 105 | return pow((double)x, (double)y); 106 | } 107 | inline float sin (float x){ 108 | return sinf(x); 109 | } 110 | inline float sinh (float x){ 111 | return sinhf(x); 112 | } 113 | inline float sqrt (float x){ 114 | return sqrtf(x); 115 | } 116 | inline float tan (float x){ 117 | return tanf(x); 118 | } 119 | inline float tanh (float x){ 120 | return tanhf(x); 121 | } 122 | inline double abs(double x){ 123 | return fabs(x); 124 | } 125 | inline double pow(double x, int y){ 126 | return pow((double)x, (double)y); 127 | } 128 | 129 | #ifdef __UCLIBCXX_HAS_LONG_DOUBLE__ 130 | inline long double abs (long double x){ 131 | return fabsl(x); 132 | } 133 | inline long double acos (long double x){ 134 | return acosl(x); 135 | } 136 | inline long double asin (long double x){ 137 | return asinl(x); 138 | } 139 | inline long double atan (long double x){ 140 | return atanl(x); 141 | } 142 | inline long double atan2(long double y, long double x){ 143 | return atan2l(y, x); 144 | } 145 | inline long double ceil (long double x){ 146 | return ceill(x); 147 | } 148 | inline long double cos (long double x){ 149 | return cosl(x); 150 | } 151 | inline long double cosh (long double x){ 152 | return coshl(x); 153 | } 154 | inline long double exp (long double x){ 155 | return expl(x); 156 | } 157 | inline long double fabs (long double x){ 158 | return fabsl(x); 159 | } 160 | inline long double floor(long double x){ 161 | return floorl(x); 162 | } 163 | inline long double frexp(long double x, int* exp){ 164 | return frexpl(x, exp); 165 | } 166 | inline long double fmod (long double x, long double y){ 167 | return fmodl(x, y); 168 | } 169 | inline long double ldexp(long double x, int y){ 170 | return ldexpl(x, y); 171 | } 172 | inline long double log (long double x){ 173 | return logl(x); 174 | } 175 | inline long double log10(long double x){ 176 | return log10l(x); 177 | } 178 | inline long double modf (long double x, long double* iptr){ 179 | return modfl(x, iptr); 180 | } 181 | inline long double pow (long double x, long double y){ 182 | return powl(x, y); 183 | } 184 | inline long double pow (long double x, int y){ 185 | return powl(x, (long double)y ); 186 | } 187 | inline long double sin (long double x){ 188 | return sinl(x); 189 | } 190 | inline long double sinh (long double x){ 191 | return sinhl(x); 192 | } 193 | inline long double sqrt (long double x){ 194 | return sqrtl(x); 195 | } 196 | inline long double tan (long double x){ 197 | return tanl(x); 198 | } 199 | inline long double tanh (long double x){ 200 | return tanhl(x); 201 | } 202 | #endif // __UCLIBCXX_HAS_LONG_DOUBLE__ 203 | #endif // ! defined(__AVR__) 204 | } 205 | 206 | #endif //__STD_HEADER_CMATH 207 | 208 | -------------------------------------------------------------------------------- /complex.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | 21 | 22 | namespace std{ 23 | 24 | 25 | template class _UCXXEXPORT complex; 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /csetjmp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef __STD_HEADER_CSETJMP 23 | #define __STD_HEADER_CSETJMP 1 24 | 25 | 26 | //From GCC Header files 27 | #undef longjmp 28 | 29 | // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 30 | #ifndef setjmp 31 | #define setjmp(env) setjmp (env) 32 | #endif 33 | 34 | //Mine again 35 | 36 | 37 | namespace std{ 38 | using ::longjmp; 39 | using ::jmp_buf; 40 | } 41 | 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /csignal: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- forwarding header. 2 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 4 | // Free Software Foundation, Inc. 5 | // 6 | // This file is part of the GNU ISO C++ Library. This library is free 7 | // software; you can redistribute it and/or modify it under the 8 | // terms of the GNU General Public License as published by the 9 | // Free Software Foundation; either version 2, or (at your option) 10 | // any later version. 11 | 12 | // This library is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License along 18 | // with this library; see the file COPYING. If not, write to the Free 19 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | // USA. 21 | 22 | // As a special exception, you may use this file as part of a free software 23 | // library without restriction. Specifically, if other files instantiate 24 | // templates or use macros or inline functions from this file, or you compile 25 | // this file and link it with other files to produce an executable, this 26 | // file does not by itself cause the resulting executable to be covered by 27 | // the GNU General Public License. This exception does not however 28 | // invalidate any other reasons why the executable file might be covered by 29 | // the GNU General Public License. 30 | 31 | // 32 | // ISO C++ 14882: 20.4.6 C library 33 | // 34 | 35 | /** @file csignal 36 | * This is a Standard C++ Library file. You should @c #include this file 37 | * in your programs, rather than any of the "*.h" implementation files. 38 | * 39 | * This is the C++ version of the Standard C Library header @c signal.h, 40 | * and its contents are (mostly) the same as that header, but are all 41 | * contained in the namespace @c std. 42 | */ 43 | 44 | #ifndef _CPP_CSIGNAL 45 | #define _CPP_CSIGNAL 1 46 | 47 | #pragma GCC system_header 48 | 49 | #include 50 | 51 | // Get rid of those macros defined in in lieu of real functions. 52 | #undef raise 53 | 54 | namespace std 55 | { 56 | using ::sig_atomic_t; 57 | using ::signal; 58 | using ::raise; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /cstdarg: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- forwarding header. 2 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. 4 | // 5 | // This file is part of the GNU ISO C++ Library. This library is free 6 | // software; you can redistribute it and/or modify it under the 7 | // terms of the GNU General Public License as published by the 8 | // Free Software Foundation; either version 2, or (at your option) 9 | // any later version. 10 | 11 | // This library is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | 16 | // You should have received a copy of the GNU General Public License along 17 | // with this library; see the file COPYING. If not, write to the Free 18 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 | // USA. 20 | 21 | // As a special exception, you may use this file as part of a free software 22 | // library without restriction. Specifically, if other files instantiate 23 | // templates or use macros or inline functions from this file, or you compile 24 | // this file and link it with other files to produce an executable, this 25 | // file does not by itself cause the resulting executable to be covered by 26 | // the GNU General Public License. This exception does not however 27 | // invalidate any other reasons why the executable file might be covered by 28 | // the GNU General Public License. 29 | 30 | // 31 | // ISO C++ 14882: 20.4.6 C library 32 | // 33 | 34 | /** @file cstdarg 35 | * This is a Standard C++ Library file. You should @c #include this file 36 | * in your programs, rather than any of the "*.h" implementation files. 37 | * 38 | * This is the C++ version of the Standard C Library header @c stdarg.h, 39 | * and its contents are (mostly) the same as that header, but are all 40 | * contained in the namespace @c std. 41 | */ 42 | 43 | #ifndef _CPP_CSTDARG 44 | #define _CPP_CSTDARG 1 45 | 46 | #pragma GCC system_header 47 | 48 | #include 49 | 50 | // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 51 | #ifndef va_end 52 | #define va_end(ap) va_end (ap) 53 | #endif 54 | 55 | namespace std 56 | { 57 | using ::va_list; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /cstddef: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- forwarding header. 2 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. 4 | // 5 | // This file is part of the GNU ISO C++ Library. This library is free 6 | // software; you can redistribute it and/or modify it under the 7 | // terms of the GNU General Public License as published by the 8 | // Free Software Foundation; either version 2, or (at your option) 9 | // any later version. 10 | 11 | // This library is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | 16 | // You should have received a copy of the GNU General Public License along 17 | // with this library; see the file COPYING. If not, write to the Free 18 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 | // USA. 20 | 21 | // As a special exception, you may use this file as part of a free software 22 | // library without restriction. Specifically, if other files instantiate 23 | // templates or use macros or inline functions from this file, or you compile 24 | // this file and link it with other files to produce an executable, this 25 | // file does not by itself cause the resulting executable to be covered by 26 | // the GNU General Public License. This exception does not however 27 | // invalidate any other reasons why the executable file might be covered by 28 | // the GNU General Public License. 29 | 30 | // 31 | // ISO C++ 14882: 18.1 Types 32 | // 33 | 34 | /** @file cstddef 35 | * This is a Standard C++ Library file. You should @c #include this file 36 | * in your programs, rather than any of the "*.h" implementation files. 37 | * 38 | * This is the C++ version of the Standard C Library header @c stddef.h, 39 | * and its contents are (mostly) the same as that header, but are all 40 | * contained in the namespace @c std. 41 | */ 42 | 43 | #ifndef _CPP_CSTDDEF 44 | #define _CPP_CSTDDEF 1 45 | 46 | #ifdef __GCC__ 47 | #pragma GCC system_header 48 | #endif 49 | 50 | #include 51 | 52 | namespace std 53 | { 54 | using ::ptrdiff_t; 55 | using ::size_t; 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /cstdio: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation version 2.1 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #ifndef __HEADER_CSTDIO 22 | #define __HEADER_CSTDIO 1 23 | 24 | 25 | namespace std{ 26 | #if ! defined(__AVR__) 27 | using ::FILE; 28 | using ::fpos_t; 29 | using ::fgetpos; 30 | using ::fopen; 31 | using ::freopen; 32 | using ::fseek; 33 | using ::fsetpos; 34 | using ::ftell; 35 | using ::perror; 36 | using ::rename; 37 | using ::rewind; 38 | using ::setbuf; 39 | using ::setvbuf; 40 | using ::tmpfile; 41 | using ::tmpnam; 42 | using ::remove; 43 | #endif // ! defined(__AVR__) 44 | 45 | using ::clearerr; 46 | using ::fclose; 47 | using ::feof; 48 | using ::ferror; 49 | using ::fflush; 50 | using ::fgetc; 51 | using ::fgets; 52 | using ::fprintf; 53 | using ::fputc; 54 | using ::fputs; 55 | using ::fread; 56 | using ::fscanf; 57 | using ::fwrite; 58 | using ::getc; 59 | using ::getchar; 60 | using ::gets; 61 | using ::printf; 62 | using ::putc; 63 | using ::putchar; 64 | using ::puts; 65 | using ::scanf; 66 | using ::sprintf; 67 | using ::sscanf; 68 | using ::ungetc; 69 | using ::vfprintf; 70 | using ::vprintf; 71 | using ::vsprintf; 72 | } 73 | 74 | 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /cstdlib: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #ifndef __HEADER_CSTDLIB 23 | #define __HEADER_CSTDLIB 1 24 | 25 | 26 | namespace std{ 27 | #if ! defined(__AVR__) 28 | using ::atexit; 29 | using ::getenv; 30 | using ::system; 31 | #endif // ! defined(__AVR__) 32 | using ::abort; 33 | using ::abs; 34 | using ::atol; 35 | using ::atof; 36 | using ::atoi; 37 | using ::bsearch; 38 | using ::calloc; 39 | using ::div; 40 | using ::exit; 41 | using ::free; 42 | using ::labs; 43 | using ::ldiv; 44 | using ::malloc; 45 | using ::qsort; 46 | using ::rand; 47 | using ::realloc; 48 | using ::srand; 49 | using ::strtod; 50 | using ::strtol; 51 | using ::strtoul; 52 | #ifdef __UCLIBCXX_HAS_WCHAR__ 53 | using ::mblen; 54 | using ::mbstowcs; 55 | using ::mbtowc; 56 | using ::wctomb; 57 | using ::wcstombs; 58 | #endif 59 | 60 | // Undefine `abs`, because Arduino already has it. 61 | // https://github.com/maniacbug/StandardCplusplus/issues/2#issuecomment-32912640 62 | #undef abs 63 | inline long abs(long i){ 64 | return labs(i); 65 | } 66 | 67 | inline ldiv_t div(long i, long j){ 68 | return ldiv(i, j); 69 | } 70 | 71 | } 72 | 73 | 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /cstring: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #ifndef __HEADER_CSTRING 23 | #define __HEADER_CSTRING 1 24 | 25 | 26 | namespace std{ 27 | #if ! defined(__AVR__) 28 | using ::strcoll; 29 | using ::strerror; 30 | using ::strxfrm; 31 | #endif // ! defined(__AVR__) 32 | 33 | using ::memchr; 34 | using ::memcmp; 35 | using ::memcpy; 36 | using ::memmove; 37 | using ::memset; 38 | using ::strcat; 39 | using ::strchr; 40 | using ::strcmp; 41 | using ::strcpy; 42 | using ::strcspn; 43 | using ::strlen; 44 | using ::strncat; 45 | using ::strncmp; 46 | using ::strncpy; 47 | using ::strpbrk; 48 | using ::strrchr; 49 | using ::strspn; 50 | using ::strstr; 51 | using ::strtok; 52 | 53 | #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO 54 | //Extra definitions required in c++ spec 55 | 56 | inline void* memchr(void* s, int c, size_t n){ 57 | return memchr(const_cast(s), c, n); 58 | } 59 | 60 | inline char* strchr(char* s, int c){ 61 | return strchr(const_cast(s), c); 62 | } 63 | 64 | inline char* strpbrk(char* s1, const char* s2){ 65 | return strpbrk(const_cast(s1), s2); 66 | } 67 | 68 | inline char* strrchr(char* s, int c){ 69 | return strrchr(const_cast(s), c); 70 | } 71 | 72 | inline char* strstr(char* s1, const char* s2){ 73 | return strstr(const_cast(s1), s2); 74 | } 75 | #endif 76 | } 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /ctime: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- forwarding header. 2 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 4 | // Free Software Foundation, Inc. 5 | // 6 | // This file is part of the GNU ISO C++ Library. This library is free 7 | // software; you can redistribute it and/or modify it under the 8 | // terms of the GNU General Public License as published by the 9 | // Free Software Foundation; either version 2, or (at your option) 10 | // any later version. 11 | 12 | // This library is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License along 18 | // with this library; see the file COPYING. If not, write to the Free 19 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | // USA. 21 | 22 | // As a special exception, you may use this file as part of a free software 23 | // library without restriction. Specifically, if other files instantiate 24 | // templates or use macros or inline functions from this file, or you compile 25 | // this file and link it with other files to produce an executable, this 26 | // file does not by itself cause the resulting executable to be covered by 27 | // the GNU General Public License. This exception does not however 28 | // invalidate any other reasons why the executable file might be covered by 29 | // the GNU General Public License. 30 | 31 | // 32 | // ISO C++ 14882: 20.5 Date and time 33 | // 34 | 35 | /** @file ctime 36 | * This is a Standard C++ Library file. You should @c #include this file 37 | * in your programs, rather than any of the "*.h" implementation files. 38 | * 39 | * This is the C++ version of the Standard C Library header @c time.h, 40 | * and its contents are (mostly) the same as that header, but are all 41 | * contained in the namespace @c std. 42 | */ 43 | 44 | #ifndef _CPP_CTIME 45 | #define _CPP_CTIME 1 46 | 47 | #pragma GCC system_header 48 | 49 | #include 50 | 51 | #include 52 | 53 | // Get rid of those macros defined in in lieu of real functions. 54 | #undef clock 55 | #undef difftime 56 | #undef mktime 57 | #undef time 58 | #undef asctime 59 | #undef ctime 60 | #undef gmtime 61 | #undef localtime 62 | #undef strftime 63 | 64 | namespace std 65 | { 66 | using ::clock_t; 67 | using ::time_t; 68 | using ::tm; 69 | 70 | using ::clock; 71 | using ::difftime; 72 | using ::mktime; 73 | using ::time; 74 | using ::asctime; 75 | using ::ctime; 76 | using ::gmtime; 77 | using ::localtime; 78 | using ::strftime; 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /cwchar: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation version 2.1 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #ifndef __HEADER_CWCHAR 22 | #define __HEADER_CWCHAR 1 23 | 24 | 25 | namespace std{ 26 | using ::mbstate_t; 27 | using ::wint_t; 28 | 29 | using ::btowc; 30 | using ::fgetwc; 31 | using ::fgetws; 32 | using ::fputwc; 33 | using ::fputws; 34 | using ::fwide; 35 | using ::fwprintf; 36 | using ::fwscanf; 37 | using ::getwc; 38 | using ::getwchar; 39 | using ::mbrlen; 40 | using ::mbrtowc; 41 | using ::mbsinit; 42 | using ::mbsrtowcs; 43 | using ::putwc; 44 | using ::putwchar; 45 | using ::swprintf; 46 | using ::swscanf; 47 | using ::ungetwc; 48 | using ::vfwprintf; 49 | using ::vswprintf; 50 | using ::vwprintf; 51 | using ::wcrtomb; 52 | using ::wcscat; 53 | using ::wcschr; 54 | using ::wcscmp; 55 | using ::wcscoll; 56 | using ::wcscpy; 57 | using ::wcscspn; 58 | using ::wcsftime; 59 | using ::wcslen; 60 | using ::wcsncat; 61 | using ::wcsncmp; 62 | using ::wcsncpy; 63 | using ::wcspbrk; 64 | using ::wcsrchr; 65 | using ::wcsrtombs; 66 | using ::wcsspn; 67 | using ::wcsstr; 68 | using ::wcstod; 69 | using ::wcstok; 70 | using ::wcstol; 71 | using ::wcstoul; 72 | using ::wcsxfrm; 73 | using ::wctob; 74 | using ::wmemchr; 75 | using ::wmemcmp; 76 | using ::wmemcpy; 77 | using ::wmemmove; 78 | using ::wmemset; 79 | using ::wprintf; 80 | using ::wscanf; 81 | } 82 | 83 | 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /cwctype: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- forwarding header. 2 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 4 | // Free Software Foundation, Inc. 5 | // 6 | // This file is part of the GNU ISO C++ Library. This library is free 7 | // software; you can redistribute it and/or modify it under the 8 | // terms of the GNU General Public License as published by the 9 | // Free Software Foundation; either version 2, or (at your option) 10 | // any later version. 11 | 12 | // This library is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License along 18 | // with this library; see the file COPYING. If not, write to the Free 19 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | // USA. 21 | 22 | // As a special exception, you may use this file as part of a free software 23 | // library without restriction. Specifically, if other files instantiate 24 | // templates or use macros or inline functions from this file, or you compile 25 | // this file and link it with other files to produce an executable, this 26 | // file does not by itself cause the resulting executable to be covered by 27 | // the GNU General Public License. This exception does not however 28 | // invalidate any other reasons why the executable file might be covered by 29 | // the GNU General Public License. 30 | 31 | // 32 | // ISO C++ 14882: 33 | // 34 | 35 | /** @file cwctype 36 | * This is a Standard C++ Library file. You should @c #include this file 37 | * in your programs, rather than any of the "*.h" implementation files. 38 | * 39 | * This is the C++ version of the Standard C Library header @c wctype.h, 40 | * and its contents are (mostly) the same as that header, but are all 41 | * contained in the namespace @c std. 42 | */ 43 | 44 | #ifndef _CPP_CWCTYPE 45 | #define _CPP_CWCTYPE 1 46 | 47 | #pragma GCC system_header 48 | 49 | //#include 50 | 51 | #ifdef __UCLIBCXX_HAS_WCHAR__ 52 | #include 53 | #endif 54 | 55 | // Get rid of those macros defined in in lieu of real functions. 56 | #undef iswalnum 57 | #undef iswalpha 58 | #undef iswblank 59 | #undef iswcntrl 60 | #undef iswdigit 61 | #undef iswgraph 62 | #undef iswlower 63 | #undef iswprint 64 | #undef iswprint 65 | #undef iswpunct 66 | #undef iswspace 67 | #undef iswupper 68 | #undef iswxdigit 69 | #undef iswctype 70 | #undef towlower 71 | #undef towupper 72 | #undef towctrans 73 | #undef wctrans 74 | #undef wctype 75 | 76 | #if __UCLIBCXX_HAS_WCHAR__ 77 | namespace std 78 | { 79 | using ::wint_t; // cwchar 80 | 81 | using ::wctype_t; 82 | using ::wctrans_t; 83 | 84 | using ::iswalnum; 85 | using ::iswalpha; 86 | using ::iswblank; 87 | using ::iswcntrl; 88 | using ::iswdigit; 89 | using ::iswgraph; 90 | using ::iswlower; 91 | using ::iswprint; 92 | using ::iswprint; 93 | using ::iswpunct; 94 | using ::iswspace; 95 | using ::iswupper; 96 | using ::iswxdigit; 97 | using ::iswctype; 98 | using ::towlower; 99 | using ::towupper; 100 | using ::towctrans; 101 | using ::wctrans; 102 | using ::wctype; 103 | } 104 | #endif //__ULIBCXX_HAS_WCHAR__ 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /del_op.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | // Arduino 1.0 contains an implementation for this. 21 | #if ! defined(ARDUINO) || ( ARDUINO < 100 ) 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | _UCXXEXPORT void operator delete(void* ptr) throw(){ 28 | free(ptr); 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /del_opnt.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) throw() { 26 | free(ptr); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /del_opv.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | // Arduino 1.04 contains an implementation for this. 20 | #if ARDUINO < 104 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | _UCXXEXPORT void operator delete[](void * ptr) throw(){ 27 | free(ptr); 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /del_opvnt.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) throw(){ 26 | free(ptr); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /deque.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | #include 21 | 22 | 23 | namespace std{ 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | } 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /eh_alloc.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation, version 2.1 8 | of the License. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | //This is a system-specific header which does all of the error-handling management 25 | #include 26 | 27 | namespace __cxxabiv1{ 28 | 29 | extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(){ 30 | void *retval; 31 | //The sizeof crap is required by Itanium ABI because we need to provide space for 32 | //accounting information which is implementaion (gcc) specified 33 | retval = malloc (thrown_size + sizeof(__cxa_exception)); 34 | if (0 == retval){ 35 | std::terminate(); 36 | } 37 | memset (retval, 0, sizeof(__cxa_exception)); 38 | return (void *)((unsigned char *)retval + sizeof(__cxa_exception)); 39 | } 40 | 41 | extern "C" void __cxa_free_exception(void *vptr) throw(){ 42 | free( (char *)(vptr) - sizeof(__cxa_exception) ); 43 | } 44 | 45 | 46 | extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() throw(){ 47 | __cxa_dependent_exception *retval; 48 | //The sizeof crap is required by Itanium ABI because we need to provide space for 49 | //accounting information which is implementaion (gcc) specified 50 | retval = static_cast<__cxa_dependent_exception*>(malloc (sizeof(__cxa_dependent_exception))); 51 | if (0 == retval){ 52 | std::terminate(); 53 | } 54 | memset (retval, 0, sizeof(__cxa_dependent_exception)); 55 | return retval; 56 | } 57 | 58 | extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *vptr) throw(){ 59 | free( (char *)(vptr) ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /eh_globals.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation, version 2.1 8 | of the License. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | //This is a system-specific header which does all of the error-handling management 25 | #include 26 | 27 | //The following functionality is derived from reading of the GNU libstdc++ code and making it...simple 28 | 29 | 30 | namespace __cxxabiv1{ 31 | 32 | static __UCLIBCXX_TLS __cxa_eh_globals eh_globals; 33 | 34 | extern "C" __cxa_eh_globals* __cxa_get_globals() throw(){ 35 | return &eh_globals; 36 | } 37 | 38 | extern "C" __cxa_eh_globals* __cxa_get_globals_fast() throw(){ 39 | return &eh_globals; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /examples/serstream/Jamfile: -------------------------------------------------------------------------------- 1 | # (1) Project Information 2 | 3 | PROJECT_LIBS = StandardCplusplus ; 4 | PROJECT_DIRS = $(PWD) ; 5 | 6 | # (2) Board Information 7 | 8 | UPLOAD_PROTOCOL ?= arduino ; 9 | UPLOAD_SPEED ?= 115200 ; 10 | MCU ?= atmega328p ; 11 | F_CPU ?= 16000000 ; 12 | CORE ?= arduino ; 13 | VARIANT ?= standard ; 14 | ARDUINO_VERSION ?= 100 ; 15 | 16 | # (3) USB Ports 17 | 18 | PORTS = p4 p6 p9 u0 u1 u2 ; 19 | PORT_p6 = /dev/tty.usbserial-A600eHIs ; 20 | PORT_p4 = /dev/tty.usbserial-A40081RP ; 21 | PORT_p9 = /dev/tty.usbserial-A9007LmI ; 22 | PORT_u0 = /dev/ttyUSB0 ; 23 | PORT_u1 = /dev/ttyUSB1 ; 24 | PORT_u2 = /dev/ttyUSB2 ; 25 | 26 | # (4) Location of AVR tools 27 | # 28 | # This configuration assumes using avr-tools that were obtained separate from the Arduino 29 | # distribution. 30 | 31 | if $(OS) = MACOSX 32 | { 33 | AVR_BIN ?= /usr/local/avrtools/bin ; 34 | AVR_ETC ?= /usr/local/avrtools/etc ; 35 | AVR_INCLUDE ?= /usr/local/avrtools/include ; 36 | } 37 | else 38 | { 39 | AVR_BIN ?= /usr/bin ; 40 | AVR_INCLUDE ?= /usr/lib/avr/include ; 41 | AVR_ETC ?= /etc ; 42 | } 43 | 44 | # (5) Directories where Arduino core and libraries are located 45 | 46 | ARDUINO_DIR ?= /opt/Arduino ; 47 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ; 48 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ; 49 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ; 50 | 51 | # 52 | # -------------------------------------------------- 53 | # Below this line usually never needs to be modified 54 | # 55 | 56 | # Tool locations 57 | 58 | CC = $(AVR_BIN)/avr-gcc ; 59 | C++ = $(AVR_BIN)/avr-g++ ; 60 | LINK = $(AVR_BIN)/avr-gcc ; 61 | AR = $(AVR_BIN)/avr-ar rcs ; 62 | RANLIB = ; 63 | OBJCOPY = $(AVR_BIN)/avr-objcopy ; 64 | AVRDUDE ?= $(AVR_BIN)/avrdude ; 65 | 66 | # Flags 67 | 68 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ; 69 | OPTIM = -Os ; 70 | CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ; 71 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ; 72 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ; 73 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ; 74 | 75 | # Search everywhere for headers 76 | 77 | HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ; 78 | 79 | # Output locations 80 | 81 | LOCATE_TARGET = $(F_CPU) ; 82 | LOCATE_SOURCE = $(F_CPU) ; 83 | 84 | # 85 | # Custom rules 86 | # 87 | 88 | rule GitVersion 89 | { 90 | Always $(<) ; 91 | Depends all : $(<) ; 92 | } 93 | 94 | actions GitVersion 95 | { 96 | echo "const char program_version[] = \"\\" > $(<) 97 | git log -1 --pretty=format:%h >> $(<) 98 | echo "\";" >> $(<) 99 | } 100 | 101 | GitVersion version.h ; 102 | 103 | rule Pde 104 | { 105 | Depends $(<) : $(>) ; 106 | MakeLocate $(<) : $(LOCATE_SOURCE) ; 107 | Clean clean : $(<) ; 108 | } 109 | 110 | if ( $(ARDUINO_VERSION) < 100 ) 111 | { 112 | ARDUINO_H = WProgram.h ; 113 | } 114 | else 115 | { 116 | ARDUINO_H = Arduino.h ; 117 | } 118 | 119 | actions Pde 120 | { 121 | echo "#include <$(ARDUINO_H)>" > $(<) 122 | echo "#line 1 \"$(>)\"" >> $(<) 123 | cat $(>) >> $(<) 124 | } 125 | 126 | rule C++Pde 127 | { 128 | local _CPP = $(>:B).cpp ; 129 | Pde $(_CPP) : $(>) ; 130 | C++ $(<) : $(_CPP) ; 131 | } 132 | 133 | rule UserObject 134 | { 135 | switch $(>:S) 136 | { 137 | case .ino : C++Pde $(<) : $(>) ; 138 | case .pde : C++Pde $(<) : $(>) ; 139 | } 140 | } 141 | 142 | rule Objects 143 | { 144 | local _i ; 145 | 146 | for _i in [ FGristFiles $(<) ] 147 | { 148 | local _b = $(_i:B)$(SUFOBJ) ; 149 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ; 150 | Object $(_o) : $(_i) ; 151 | Depends obj : $(_o) ; 152 | } 153 | } 154 | 155 | rule Library 156 | { 157 | LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ; 158 | Objects $(>) ; 159 | } 160 | 161 | rule Main 162 | { 163 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ; 164 | Objects $(>) ; 165 | } 166 | 167 | rule Hex 168 | { 169 | Depends $(<) : $(>) ; 170 | MakeLocate $(<) : $(LOCATE_TARGET) ; 171 | Depends hex : $(<) ; 172 | Clean clean : $(<) ; 173 | } 174 | 175 | actions Hex 176 | { 177 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<) 178 | } 179 | 180 | rule Upload 181 | { 182 | Depends $(1) : $(2) ; 183 | Depends $(2) : $(3) ; 184 | NotFile $(1) ; 185 | Always $(1) ; 186 | Always $(2) ; 187 | UploadAction $(2) : $(3) ; 188 | } 189 | 190 | actions UploadAction 191 | { 192 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i 193 | } 194 | 195 | rule Arduino 196 | { 197 | LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ; 198 | Main $(<) : $(>) ; 199 | LinkLibraries $(<) : libs core ; 200 | Hex $(<:B).hex : $(<) ; 201 | for _p in $(PORTS) 202 | { 203 | Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ; 204 | } 205 | } 206 | 207 | # 208 | # Targets 209 | # 210 | 211 | # Grab everything from the core directory 212 | Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ; 213 | 214 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you 215 | # can specify specific modules to pick up in PROJECT_MODULES 216 | Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ; 217 | 218 | # Main output executable 219 | Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ; 220 | -------------------------------------------------------------------------------- /examples/serstream/more.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void more(void) 5 | { 6 | Serial.print("more"); 7 | 8 | std::cout << 1.0f; 9 | } 10 | -------------------------------------------------------------------------------- /examples/serstream/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | jam u0 && expect test.ex 4 | -------------------------------------------------------------------------------- /examples/serstream/serstream.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | // declares cout/cerr, but the application must define them 8 | // because it's up to you what to do with them. 9 | namespace std 10 | { 11 | ohserialstream cout(Serial); 12 | } 13 | 14 | extern void more(void); 15 | 16 | void setup(void) 17 | { 18 | Serial.begin(57600); 19 | 20 | cout << "Hello, world." << endl; 21 | 22 | cout << F("I use up absolutely no RAM space whatsoever") << endl; 23 | cout << F("so you can use as many F() strings as you want!") << endl; 24 | 25 | float fmax = __FLT_MAX__, fmin = __FLT_MIN__; 26 | cout.precision(7); 27 | cout << "Float " << scientific << fmax << endl; 28 | cout << "Float " << scientific << fmin << endl; 29 | 30 | more(); 31 | 32 | cout << "+OK" << endl; 33 | 34 | int n = 3; 35 | int (*button)[3] = new int[n][3]; 36 | } 37 | 38 | void loop(void) 39 | { 40 | } 41 | 42 | // vim:cin:ai:sts=2 sw=2 ft=cpp 43 | -------------------------------------------------------------------------------- /examples/serstream/test.ex: -------------------------------------------------------------------------------- 1 | #/usr/bin/expect 2 | 3 | set timeout 100 4 | spawn picocom -b 57600 /dev/ttyUSB0 5 | expect "+OK" 6 | -------------------------------------------------------------------------------- /examples/string_vector/Jamfile: -------------------------------------------------------------------------------- 1 | # (1) Project Information 2 | 3 | PROJECT_LIBS = StandardCplusplus ; 4 | 5 | # (2) Board Information 6 | 7 | UPLOAD_PROTOCOL ?= stk500v1 ; 8 | UPLOAD_SPEED ?= 115200 ; 9 | MCU ?= atmega328p ; 10 | F_CPU ?= 16000000 ; 11 | CORE ?= arduino ; 12 | VARIANT ?= standard ; 13 | ARDUINO_VERSION ?= 100 ; 14 | 15 | # (3) USB Ports 16 | 17 | PORTS = p4 p6 p9 u0 u1 u2 ; 18 | PORT_p6 = /dev/tty.usbserial-A600eHIs ; 19 | PORT_p4 = /dev/tty.usbserial-A40081RP ; 20 | PORT_p9 = /dev/tty.usbserial-A9007LmI ; 21 | PORT_u0 = /dev/ttyUSB0 ; 22 | PORT_u1 = /dev/ttyUSB1 ; 23 | PORT_u2 = /dev/ttyUSB2 ; 24 | 25 | # Host-specific overrides for locations 26 | 27 | if $(OS) = MACOSX 28 | { 29 | OLD_DIR = /opt/arduino-0021 ; 30 | AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ; 31 | AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ; 32 | ARDUINO_AVR = /usr/lib/avr/include ; 33 | } 34 | 35 | # (4) Directories where tools and libraries are located 36 | # 37 | # This configuration assumes using avr-tools that were obtained separate from the Arduino 38 | # distribution. 39 | 40 | AVR_TOOLS_PATH ?= /usr/bin ; 41 | ARDUINO_DIR ?= /opt/Arduino ; 42 | AVR_HDRS ?= /usr/lib/avr/include ; 43 | AVRDUDECONF_PATH ?= /etc ; 44 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ; 45 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ; 46 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ; 47 | 48 | # 49 | # -------------------------------------------------- 50 | # Below this line usually never needs to be modified 51 | # 52 | 53 | # Tool locations 54 | 55 | CC = $(AVR_TOOLS_PATH)/avr-gcc ; 56 | C++ = $(AVR_TOOLS_PATH)/avr-g++ ; 57 | LINK = $(AVR_TOOLS_PATH)/avr-gcc ; 58 | OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ; 59 | AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ; 60 | 61 | # Flags 62 | 63 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ; 64 | OPTIM = -Os ; 65 | CCFLAGS = -Wall -Wextra -mmcu=$(MCU) -ffunction-sections -fdata-sections ; 66 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ; 67 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ; 68 | AVRDUDEFLAGS = -V -F -D -C $(AVRDUDECONF_PATH)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ; 69 | 70 | # Search everywhere for headers 71 | 72 | HDRS = $(PWD) $(AVR_HDRS) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ; 73 | 74 | # Output locations 75 | 76 | LOCATE_TARGET = $(F_CPU) ; 77 | LOCATE_SOURCE = $(F_CPU) ; 78 | 79 | # 80 | # Custom rules 81 | # 82 | 83 | rule GitVersion 84 | { 85 | Always $(<) ; 86 | Depends all : $(<) ; 87 | } 88 | 89 | actions GitVersion 90 | { 91 | echo "const char program_version[] = \"\\" > $(<) 92 | git log -1 --pretty=format:%h >> $(<) 93 | echo "\";" >> $(<) 94 | } 95 | 96 | GitVersion version.h ; 97 | 98 | rule Pde 99 | { 100 | Depends $(<) : $(>) ; 101 | MakeLocate $(<) : $(LOCATE_SOURCE) ; 102 | Clean clean : $(<) ; 103 | } 104 | 105 | if ( $(ARDUINO_VERSION) < 100 ) 106 | { 107 | ARDUINO_H = WProgram.h ; 108 | } 109 | else 110 | { 111 | ARDUINO_H = Arduino.h ; 112 | } 113 | 114 | actions Pde 115 | { 116 | echo "#include <$(ARDUINO_H)>" > $(<) 117 | echo "#line 1 \"$(>)\"" >> $(<) 118 | cat $(>) >> $(<) 119 | } 120 | 121 | rule C++Pde 122 | { 123 | local _CPP = $(>:B).cpp ; 124 | Pde $(_CPP) : $(>) ; 125 | C++ $(<) : $(_CPP) ; 126 | } 127 | 128 | rule UserObject 129 | { 130 | switch $(>:S) 131 | { 132 | case .ino : C++Pde $(<) : $(>) ; 133 | case .pde : C++Pde $(<) : $(>) ; 134 | } 135 | } 136 | 137 | rule Objects 138 | { 139 | local _i ; 140 | 141 | for _i in [ FGristFiles $(<) ] 142 | { 143 | local _b = $(_i:B)$(SUFOBJ) ; 144 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ; 145 | Object $(_o) : $(_i) ; 146 | Depends obj : $(_o) ; 147 | } 148 | } 149 | 150 | rule Main 151 | { 152 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ; 153 | Objects $(>) ; 154 | } 155 | 156 | rule Hex 157 | { 158 | Depends $(<) : $(>) ; 159 | MakeLocate $(<) : $(LOCATE_TARGET) ; 160 | Depends hex : $(<) ; 161 | Clean clean : $(<) ; 162 | } 163 | 164 | actions Hex 165 | { 166 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<) 167 | } 168 | 169 | rule Upload 170 | { 171 | Depends $(1) : $(2) ; 172 | Depends $(2) : $(3) ; 173 | NotFile $(1) ; 174 | Always $(1) ; 175 | Always $(2) ; 176 | UploadAction $(2) : $(3) ; 177 | } 178 | 179 | actions UploadAction 180 | { 181 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i 182 | } 183 | 184 | # 185 | # Targets 186 | # 187 | 188 | # Grab everything from the core directory 189 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ; 190 | 191 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you 192 | # can specify specific modules to pick up in PROJECT_MODULES 193 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp ] ; 194 | 195 | # Grab everything from the current dir 196 | PROJECT_MODULES += [ GLOB $(PWD) : *.c *.cpp *.pde *.ino ] ; 197 | 198 | # Main output executable 199 | MAIN = $(PWD:B).elf ; 200 | 201 | Main $(MAIN) : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ; 202 | Hex $(MAIN:B).hex : $(MAIN) ; 203 | 204 | # Upload targets 205 | for _p in $(PORTS) 206 | { 207 | Upload $(_p) : $(PORT_$(_p)) : $(MAIN:B).hex ; 208 | } 209 | -------------------------------------------------------------------------------- /examples/string_vector/string_vector.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | // declares cout/cerr, but the application must define them 10 | // because it's up to you what to do with them. 11 | namespace std 12 | { 13 | ohserialstream cout(Serial); 14 | } 15 | 16 | vector strings; 17 | 18 | void setup(void) 19 | { 20 | Serial.begin(57600); 21 | 22 | strings.push_back("Hello,"); 23 | strings.push_back("world!"); 24 | copy(strings.begin(),strings.end(),ostream_iterator(cout," ")); 25 | cout << endl; 26 | } 27 | 28 | void loop(void) 29 | { 30 | } 31 | 32 | // vim:cin:ai:sts=2 sw=2 ft=cpp 33 | -------------------------------------------------------------------------------- /exception: -------------------------------------------------------------------------------- 1 | // Exception Handling support header for -*- C++ -*- 2 | 3 | // Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002 4 | // Free Software Foundation 5 | // 6 | // This file is part of GNU CC. 7 | // 8 | // GNU CC is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2, or (at your option) 11 | // any later version. 12 | // 13 | // GNU CC is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with GNU CC; see the file COPYING. If not, write to 20 | // the Free Software Foundation, 59 Temple Place - Suite 330, 21 | // Boston, MA 02111-1307, USA. 22 | 23 | // As a special exception, you may use this file as part of a free software 24 | // library without restriction. Specifically, if other files instantiate 25 | // templates or use macros or inline functions from this file, or you compile 26 | // this file and link it with other files to produce an executable, this 27 | // file does not by itself cause the resulting executable to be covered by 28 | // the GNU General Public License. This exception does not however 29 | // invalidate any other reasons why the executable file might be covered by 30 | // the GNU General Public License. 31 | 32 | /** @file exception 33 | * This header defines several types and functions relating to the 34 | * handling of exceptions in a C++ program. 35 | */ 36 | 37 | #ifndef __EXCEPTION__ 38 | #define __EXCEPTION__ 39 | 40 | #include 41 | 42 | extern "C++" { 43 | 44 | namespace std 45 | { 46 | /** 47 | * @brief Base class for all library exceptions. 48 | * 49 | * This is the base class for all exceptions thrown by the standard 50 | * library, and by certain language expressions. You are free to derive 51 | * your own %exception classes, or use a different hierarchy, or to 52 | * throw non-class data (e.g., fundamental types). 53 | */ 54 | class exception 55 | { 56 | public: 57 | exception() throw() { } 58 | virtual ~exception() throw(); 59 | /** Returns a C-style character string describing the general cause 60 | * of the current error. */ 61 | virtual const char* what() const throw(); 62 | }; 63 | 64 | /** If an %exception is thrown which is not listed in a function's 65 | * %exception specification, one of these may be thrown. */ 66 | class bad_exception : public exception 67 | { 68 | public: 69 | bad_exception() throw() { } 70 | // This declaration is not useless: 71 | // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 72 | virtual ~bad_exception() throw(); 73 | }; 74 | 75 | /// If you write a replacement %terminate handler, it must be of this type. 76 | typedef void (*terminate_handler) (); 77 | /// If you write a replacement %unexpected handler, it must be of this type. 78 | typedef void (*unexpected_handler) (); 79 | 80 | /// Takes a new handler function as an argument, returns the old function. 81 | terminate_handler set_terminate(terminate_handler) throw(); 82 | /** The runtime will call this function if %exception handling must be 83 | * abandoned for any reason. */ 84 | void terminate() __UCLIBCXX_NORETURN; 85 | 86 | /// Takes a new handler function as an argument, returns the old function. 87 | unexpected_handler set_unexpected(unexpected_handler) throw(); 88 | /** The runtime will call this function if an %exception is thrown which 89 | * violates the function's %exception specification. */ 90 | void unexpected() __UCLIBCXX_NORETURN; 91 | 92 | /** [18.6.4]/1: "Returns true after completing evaluation of a 93 | * throw-expression until either completing initialization of the 94 | * exception-declaration in the matching handler or entering @c unexpected() 95 | * due to the throw; or after entering @c terminate() for any reason 96 | * other than an explicit call to @c terminate(). [Note: This includes 97 | * stack unwinding [15.2]. end note]" 98 | * 99 | * 2: "When @c uncaught_exception() is true, throwing an %exception can 100 | * result in a call of @c terminate() (15.5.1)." 101 | */ 102 | bool uncaught_exception() throw(); 103 | } // namespace std 104 | 105 | namespace __gnu_cxx 106 | { 107 | /** A replacement for the standard terminate_handler which prints more 108 | information about the terminating exception (if any) on stderr. Call 109 | @code 110 | std::set_terminate (__gnu_cxx::__verbose_terminate_handler) 111 | @endcode 112 | to use. For more info, see 113 | http://gcc.gnu.org/onlinedocs/libstdc++/19_diagnostics/howto.html#4 114 | */ 115 | void __verbose_terminate_handler (); 116 | } // namespace __gnu_cxx 117 | 118 | } // extern "C++" 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /exception.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | */ 20 | 21 | #include 22 | 23 | //We can't do this yet because gcc is too stupid to be able to handle 24 | //different implementations of exception class. 25 | 26 | #undef __UCLIBCXX_EXCEPTION_SUPPORT__ 27 | 28 | #ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ 29 | 30 | namespace std{ 31 | _UCXXEXPORT static char * __std_exception_what_value = "exception"; 32 | 33 | //We are providing our own versions to be sneaky 34 | 35 | 36 | _UCXXEXPORT exception::~exception() throw(){ 37 | //Empty function 38 | } 39 | 40 | _UCXXEXPORT const char* exception::what() const throw(){ 41 | return __std_exception_what_value; 42 | } 43 | 44 | _UCXXEXPORT bad_exception::~bad_exception() throw(){ 45 | 46 | } 47 | 48 | 49 | } 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /fstream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #if ! defined(__AVR__) 21 | 22 | #define __UCLIBCXX_COMPILE_FSTREAM__ 1 23 | 24 | #include 25 | 26 | namespace std{ 27 | 28 | #ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ 29 | 30 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 31 | 32 | template _UCXXEXPORT filebuf::basic_filebuf(); 33 | template _UCXXEXPORT filebuf::~basic_filebuf(); 34 | 35 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 36 | 37 | template _UCXXEXPORT filebuf::int_type filebuf::pbackfail(filebuf::int_type c); 38 | template _UCXXEXPORT filebuf * filebuf::open(const char* s, ios_base::openmode mode); 39 | template _UCXXEXPORT filebuf * filebuf::close(); 40 | template _UCXXEXPORT filebuf::int_type filebuf::overflow(filebuf::int_type); 41 | template _UCXXEXPORT filebuf::int_type filebuf::underflow (); 42 | template _UCXXEXPORT streamsize filebuf::xsputn(const char* s, streamsize n); 43 | 44 | template _UCXXEXPORT basic_streambuf >* 45 | filebuf::setbuf(char * s, streamsize n); 46 | 47 | 48 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 49 | 50 | template _UCXXEXPORT basic_ofstream >::basic_ofstream(); 51 | template _UCXXEXPORT basic_ofstream >::basic_ofstream(const char* s, ios_base::openmode mode); 52 | template _UCXXEXPORT basic_ofstream >::~basic_ofstream(); 53 | 54 | template _UCXXEXPORT basic_ifstream >::basic_ifstream(); 55 | template _UCXXEXPORT basic_ifstream >::basic_ifstream(const char* s, ios_base::openmode mode); 56 | template _UCXXEXPORT basic_ifstream >::~basic_ifstream(); 57 | 58 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 59 | 60 | 61 | #endif 62 | 63 | 64 | 65 | #ifdef __UCLIBCXX_HAS_WCHAR__ 66 | 67 | template <> _UCXXEXPORT basic_filebuf >::int_type 68 | basic_filebuf >::overflow(int_type c) 69 | { 70 | typedef basic_streambuf > wstreambuf; 71 | typedef char_traits wtraits; 72 | 73 | if(is_open() == false){ 74 | //Can't do much 75 | return wtraits::eof(); 76 | } 77 | 78 | mbstate_t ps = { 0 }; 79 | char out_array[8]; 80 | size_t out_size; 81 | 82 | 83 | if( wstreambuf::pbase() != 0 ){ 84 | 85 | //Write all possible character from the existing array first 86 | size_t chars_written = 0; 87 | while(wstreambuf::pbase() && (wstreambuf::pbase() + chars_written !=wstreambuf::pptr()) ){ 88 | out_size = wcrtomb(out_array, wstreambuf::pbase()[chars_written], &ps); 89 | if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){ 90 | break; 91 | } 92 | ++chars_written; 93 | } 94 | 95 | if( wstreambuf::pbase() + chars_written == wstreambuf::pptr() ){ 96 | wstreambuf::pbump(-chars_written); 97 | }else{ 98 | //Shuffle data back into order 99 | size_t chars_left = wstreambuf::pptr() - wstreambuf::pbase() - chars_written; 100 | for(size_t i = 0; i < chars_left; ++i){ 101 | wstreambuf::pbase()[i] = (wstreambuf::pptr() - chars_written)[i]; 102 | } 103 | return wtraits::eof(); 104 | } 105 | } 106 | 107 | if( !wtraits::eq_int_type(c, wtraits::eof()) ){ 108 | out_size = wcrtomb(out_array, c, &ps); 109 | if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){ 110 | return wtraits::eof(); 111 | } 112 | return c; 113 | } 114 | 115 | return wtraits::not_eof(c); 116 | } 117 | 118 | 119 | template <> _UCXXEXPORT basic_filebuf >::int_type 120 | basic_filebuf >::underflow() 121 | { 122 | /*Some variables used internally: 123 | Buffer pointers: 124 | 125 | charT * mgbeg; 126 | charT * mgnext; 127 | charT * mgend; 128 | 129 | eback() returns mgbeg 130 | gptr() returns mgnext 131 | egptr() returns mgend 132 | 133 | gbump(int n) mgnext+=n 134 | */ 135 | 136 | typedef char_traits traits; 137 | typedef basic_streambuf wstreambuf; 138 | 139 | 140 | if(wstreambuf::eback() == wstreambuf::gptr() && 0 != wstreambuf::eback()){ //Buffer is full 141 | return traits::to_int_type(*wstreambuf::gptr()); 142 | } 143 | 144 | size_t in_size; 145 | 146 | wchar_t c = 0; 147 | wint_t wi = 0; 148 | in_size = 0; 149 | 150 | wi = fgetwc(fp); 151 | if(WEOF == wi){ 152 | fprintf(stderr, "WEOF returned by fgetwc\n"); 153 | return traits::eof(); 154 | } 155 | 156 | c = traits::to_char_type(wi); 157 | 158 | if(wstreambuf::eback() == 0){ 159 | return traits::to_int_type(c); 160 | } 161 | 162 | for(wchar_t * i = wstreambuf::gptr(); i < wstreambuf::egptr(); ++i){ 163 | *(i-1) = *i; 164 | } 165 | 166 | *(wstreambuf::egptr()-1) = c; 167 | 168 | wstreambuf::mgnext -= 1; 169 | 170 | return traits::to_int_type(*wstreambuf::gptr()); 171 | } 172 | 173 | #endif // __UCLIBCXX_HAS_WCHAR__ 174 | 175 | 176 | } 177 | 178 | #endif // not ARDUINO 179 | -------------------------------------------------------------------------------- /func_exception: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | 24 | #ifndef HEADER_IMPLEMENTATION_FUNC_EXCEPTION 25 | #define HEADER_IMPLEMENTATION_FUNC_EXCEPTION 26 | 27 | #pragma GCC visibility push(default) 28 | 29 | namespace std{ 30 | 31 | _UCXXEXPORT void __throw_bad_alloc(); 32 | _UCXXEXPORT void __throw_out_of_range(const char * message = 0); 33 | _UCXXEXPORT void __throw_overflow_error(const char * message = 0); 34 | _UCXXEXPORT void __throw_length_error(const char * message = 0); 35 | _UCXXEXPORT void __throw_invalid_argument(const char * message = 0); 36 | } 37 | 38 | #pragma GCC visibility pop 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /func_exception.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace std{ 26 | 27 | #ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ 28 | 29 | _UCXXEXPORT void __throw_bad_alloc(){ 30 | throw bad_alloc(); 31 | } 32 | 33 | _UCXXEXPORT void __throw_out_of_range( const char * message){ 34 | if(message == 0){ 35 | throw out_of_range(); 36 | } 37 | throw out_of_range(message); 38 | } 39 | 40 | _UCXXEXPORT void __throw_overflow_error( const char * message){ 41 | if(message == 0){ 42 | throw overflow_error(); 43 | } 44 | throw overflow_error(message); 45 | } 46 | 47 | _UCXXEXPORT void __throw_length_error(const char * message){ 48 | if(message == 0){ 49 | throw length_error(); 50 | } 51 | throw length_error(message); 52 | } 53 | 54 | _UCXXEXPORT void __throw_invalid_argument(const char * message){ 55 | if(message == 0){ 56 | throw invalid_argument(); 57 | } 58 | throw invalid_argument(message); 59 | } 60 | 61 | #else 62 | 63 | _UCXXEXPORT void __throw_bad_alloc(){ 64 | abort(); 65 | } 66 | 67 | _UCXXEXPORT void __throw_out_of_range( const char * ){ 68 | abort(); 69 | } 70 | 71 | _UCXXEXPORT void __throw_overflow_error( const char * ){ 72 | abort(); 73 | } 74 | 75 | _UCXXEXPORT void __throw_length_error(const char * ){ 76 | abort(); 77 | } 78 | 79 | _UCXXEXPORT void __throw_invalid_argument(const char *){ 80 | abort(); 81 | } 82 | 83 | #endif 84 | 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /initializer_list: -------------------------------------------------------------------------------- 1 | // std::initializer_list support -*- C++ -*- 2 | 3 | // Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 4 | // 5 | // This file is part of GCC. 6 | // 7 | // GCC is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 3, or (at your option) 10 | // any later version. 11 | // 12 | // GCC is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // Under Section 7 of GPL version 3, you are granted additional 18 | // permissions described in the GCC Runtime Library Exception, version 19 | // 3.1, as published by the Free Software Foundation. 20 | 21 | // You should have received a copy of the GNU General Public License and 22 | // a copy of the GCC Runtime Library Exception along with this program; 23 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 | // . 25 | 26 | /** @file initializer_list 27 | * This is a Standard C++ Library header. 28 | */ 29 | 30 | #ifndef _INITIALIZER_LIST 31 | #define _INITIALIZER_LIST 32 | 33 | #if __cplusplus >= 201103L 34 | 35 | #pragma GCC system_header 36 | 37 | #pragma GCC visibility push(default) 38 | 39 | //#include 40 | 41 | namespace std 42 | { 43 | /// initializer_list 44 | template 45 | class initializer_list 46 | { 47 | public: 48 | typedef _E value_type; 49 | typedef const _E& reference; 50 | typedef const _E& const_reference; 51 | typedef size_t size_type; 52 | typedef const _E* iterator; 53 | typedef const _E* const_iterator; 54 | 55 | private: 56 | iterator _M_array; 57 | size_type _M_len; 58 | 59 | // The compiler can call a private constructor. 60 | constexpr initializer_list(const_iterator __a, size_type __l) 61 | : _M_array(__a), _M_len(__l) { } 62 | 63 | public: 64 | constexpr initializer_list() noexcept 65 | : _M_array(0), _M_len(0) { } 66 | 67 | // Number of elements. 68 | constexpr size_type 69 | size() const noexcept { return _M_len; } 70 | 71 | // First element. 72 | constexpr const_iterator 73 | begin() const noexcept { return _M_array; } 74 | 75 | // One past the last element. 76 | constexpr const_iterator 77 | end() const noexcept { return begin() + size(); } 78 | }; 79 | 80 | /** 81 | * @brief Return an iterator pointing to the first element of 82 | * the initilizer_list. 83 | * @param __ils Initializer list. 84 | */ 85 | template 86 | constexpr const _Tp* 87 | begin(initializer_list<_Tp> __ils) noexcept 88 | { return __ils.begin(); } 89 | 90 | /** 91 | * @brief Return an iterator pointing to one past the last element 92 | * of the initilizer_list. 93 | * @param __ils Initializer list. 94 | */ 95 | template 96 | constexpr const _Tp* 97 | end(initializer_list<_Tp> __ils) noexcept 98 | { return __ils.end(); } 99 | } 100 | 101 | #pragma GCC visibility pop 102 | 103 | #endif // __cplusplus >= 201103L 104 | #endif // _INITIALIZER_LIST 105 | -------------------------------------------------------------------------------- /iomanip: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #ifndef __STD_IOMANIP 24 | #define __STD_IOMANIP 1 25 | 26 | #pragma GCC visibility push(default) 27 | 28 | namespace std{ 29 | 30 | // These are the helper classes which we are going to be using to 31 | // hold the required data 32 | 33 | class _UCXXEXPORT __resetiosflags{ 34 | public: 35 | ios_base::fmtflags m; 36 | _UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ } 37 | }; 38 | 39 | class _UCXXEXPORT __setiosflags{ 40 | public: 41 | ios_base::fmtflags m; 42 | _UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ } 43 | }; 44 | 45 | class _UCXXEXPORT __setbase{ 46 | public: 47 | int base; 48 | _UCXXEXPORT __setbase(int b) : base(b){ } 49 | }; 50 | 51 | class _UCXXEXPORT __setfill{ 52 | public: 53 | int character; 54 | _UCXXEXPORT __setfill(int c): character(c){ } 55 | }; 56 | 57 | class _UCXXEXPORT __setprecision{ 58 | public: 59 | int digits; 60 | _UCXXEXPORT __setprecision(int n): digits(n) { } 61 | }; 62 | 63 | class _UCXXEXPORT __setw{ 64 | public: 65 | int width; 66 | _UCXXEXPORT __setw(int n): width(n) { } 67 | }; 68 | 69 | 70 | //Actual manipulator functions 71 | 72 | inline __resetiosflags resetiosflags(ios_base::fmtflags mask){ 73 | return __resetiosflags(mask); 74 | } 75 | 76 | inline __setiosflags setiosflags(ios_base::fmtflags mask){ 77 | return __setiosflags(mask); 78 | } 79 | 80 | inline __setbase setbase(int b){ 81 | return __setbase(b); 82 | } 83 | 84 | inline __setfill setfill(int c){ 85 | return __setfill(c); 86 | } 87 | 88 | inline __setprecision setprecision(int n){ 89 | return __setprecision(n); 90 | } 91 | 92 | inline __setw setw(int n){ 93 | return __setw(n); 94 | } 95 | 96 | 97 | //How to handle interaction with [i|o]stream classes 98 | 99 | template _UCXXEXPORT basic_ostream& 100 | operator<<(basic_ostream& os, const __resetiosflags s) 101 | { 102 | os.setf(ios_base::fmtflags(0),s.m); 103 | return os; 104 | } 105 | 106 | template _UCXXEXPORT basic_istream& 107 | operator>>(basic_istream& is, const __resetiosflags s) 108 | { 109 | is.setf(ios_base::fmtflags(0),s.m); 110 | return is; 111 | } 112 | 113 | template _UCXXEXPORT basic_ostream& 114 | operator<<(basic_ostream& os, const __setiosflags s) 115 | { 116 | os.setf(s.m); 117 | return os; 118 | } 119 | 120 | template _UCXXEXPORT basic_ostream& 121 | operator<<(basic_ostream& os, const __setbase s) 122 | { 123 | ios_base::fmtflags f(0); 124 | switch(s.base){ 125 | case 8: 126 | f = ios_base::oct; 127 | break; 128 | case 10: 129 | f = ios_base::dec; 130 | break; 131 | case 16: 132 | f = ios_base::hex; 133 | break; 134 | default: 135 | break; 136 | 137 | } 138 | os.setf(f, ios_base::basefield); 139 | return os; 140 | } 141 | 142 | template _UCXXEXPORT basic_ostream& 143 | operator<<(basic_ostream& os, const __setfill s) 144 | { 145 | os.fill(s.character); 146 | return os; 147 | } 148 | 149 | template _UCXXEXPORT basic_ostream& 150 | operator<<(basic_ostream& os, const __setprecision s) 151 | { 152 | os.precision(s.digits); 153 | return os; 154 | } 155 | 156 | template _UCXXEXPORT basic_ostream& 157 | operator<<(basic_ostream& os, const __setw s) 158 | { 159 | os.width(s.width); 160 | return os; 161 | } 162 | 163 | 164 | 165 | } 166 | 167 | #pragma GCC visibility pop 168 | 169 | #endif 170 | 171 | -------------------------------------------------------------------------------- /iomanip.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /ios.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #define __UCLIBCXX_COMPILE_IOS__ 1 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #ifdef ARDUINO 27 | #include 28 | #include 29 | #else 30 | #include 31 | #endif 32 | 33 | namespace std{ 34 | 35 | #ifdef __UCLIBCXX_SUPPORT_CDIR__ 36 | _UCXXLOCAL int ios_base::Init::init_cnt = 0; //Needed to ensure the static value is created 37 | 38 | //Create buffers first 39 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 40 | _UCXXEXPORT filebuf _cout_filebuf; 41 | #endif 42 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 43 | _UCXXEXPORT filebuf _cin_filebuf; 44 | #endif 45 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 46 | _UCXXEXPORT filebuf _cerr_filebuf; 47 | #endif 48 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 49 | _UCXXEXPORT filebuf _clog_filebuf; 50 | #endif 51 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 52 | _UCXXEXPORT wfilebuf _wcout_filebuf; 53 | #endif 54 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 55 | _UCXXEXPORT wfilebuf _wcin_filebuf; 56 | #endif 57 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 58 | _UCXXEXPORT wfilebuf _wcerr_filebuf; 59 | #endif 60 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 61 | _UCXXEXPORT wfilebuf _wclog_filebuf; 62 | #endif 63 | 64 | 65 | 66 | //Then create streams 67 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 68 | _UCXXEXPORT ostream cout(&_cout_filebuf); 69 | #endif 70 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 71 | _UCXXEXPORT istream cin(&_cin_filebuf); 72 | #endif 73 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 74 | _UCXXEXPORT ostream cerr(&_cerr_filebuf); 75 | #endif 76 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 77 | _UCXXEXPORT ostream clog(&_clog_filebuf); 78 | #endif 79 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 80 | _UCXXEXPORT wostream wcout(&_wcout_filebuf); 81 | #endif 82 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 83 | _UCXXEXPORT wistream wcin(&_wcin_filebuf); 84 | #endif 85 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 86 | _UCXXEXPORT wostream wcerr(&_wcerr_filebuf); 87 | #endif 88 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 89 | _UCXXEXPORT wostream wclog(&_wclog_filebuf); 90 | #endif 91 | 92 | 93 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 94 | _UCXXEXPORT ohserialstream cout(Serial); 95 | #endif 96 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 97 | _UCXXEXPORT ihserialstream cin(Serial); 98 | #endif 99 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 100 | _UCXXEXPORT ohserialstream cerr(Serial); 101 | #endif 102 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 103 | _UCXXEXPORT ohserialstream clog(Serial); 104 | #endif 105 | 106 | _UCXXEXPORT ios_base::Init::Init(){ 107 | if(init_cnt == 0){ //Need to construct cout et al 108 | 109 | #ifndef ARDUINO 110 | 111 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 112 | _cout_filebuf.fp = stdout; 113 | _cout_filebuf.openedFor = ios_base::out; 114 | #endif 115 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 116 | _cerr_filebuf.fp = stderr; 117 | _cerr_filebuf.openedFor = ios_base::out; 118 | cerr.mformat |= ios_base::unitbuf; 119 | #endif 120 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 121 | _clog_filebuf.fp = stderr; 122 | _clog_filebuf.openedFor = ios_base::out; 123 | #endif 124 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 125 | _cin_filebuf.fp = stdin; 126 | _cin_filebuf.openedFor = ios_base::in; 127 | 128 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 129 | cin.tie(&cout); 130 | #endif 131 | 132 | #endif 133 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 134 | _wcout_filebuf.fp = stdout; 135 | _wcout_filebuf.openedFor = ios_base::out; 136 | #endif 137 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 138 | _wcerr_filebuf.fp = stderr; 139 | _wcerr_filebuf.openedFor = ios_base::out; 140 | wcerr.mformat |= ios_base::unitbuf; 141 | #endif 142 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 143 | _wclog_filebuf.fp = stderr; 144 | _wclog_filebuf.openedFor = ios_base::out; 145 | #endif 146 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 147 | _wcin_filebuf.fp = stdin; 148 | _wcin_filebuf.openedFor = ios_base::in; 149 | 150 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 151 | wcin.tie(&wcout); 152 | #endif 153 | 154 | #endif // not Arduino 155 | 156 | #endif // not CDIR 157 | } 158 | init_cnt++; 159 | } 160 | 161 | _UCXXEXPORT ios_base::Init::~Init(){ 162 | --init_cnt; 163 | if(init_cnt==0){ 164 | 165 | } 166 | } 167 | #endif 168 | 169 | 170 | #ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ 171 | 172 | template _UCXXEXPORT void basic_ios >::clear(iostate state); 173 | template _UCXXEXPORT void basic_ios >::setstate(iostate state); 174 | 175 | #endif 176 | 177 | 178 | _UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){ 179 | fmtflags temp = mformat; 180 | mformat = fmtfl; 181 | return temp; 182 | } 183 | 184 | _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){ 185 | return flags(flags() | fmtfl); 186 | } 187 | 188 | _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){ 189 | return flags( (flags()& ~mask) | (fmtfl & mask)); 190 | } 191 | 192 | _UCXXEXPORT streamsize ios_base::precision(streamsize prec){ 193 | streamsize temp = mprecision; 194 | mprecision = prec; 195 | return temp; 196 | } 197 | _UCXXEXPORT streamsize ios_base::width(streamsize wide){ 198 | streamsize temp = mwidth; 199 | mwidth = wide; 200 | return temp; 201 | } 202 | 203 | _UCXXEXPORT locale ios_base::imbue(const locale& loc){ 204 | locale retval = mLocale; 205 | mLocale = loc; 206 | return retval; 207 | } 208 | 209 | } 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /iosfwd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | #ifndef __HEADER_STD_IOSFWD 26 | #define __HEADER_STD_IOSFWD 1 27 | 28 | #pragma GCC visibility push(default) 29 | 30 | #ifdef ARDUINO 31 | class HardwareSerial; 32 | #endif 33 | 34 | namespace std { 35 | class ios_base; 36 | template<> class char_traits; 37 | 38 | #ifdef __UCLIBCXX_HAS_WCHAR__ 39 | template<> class char_traits; 40 | #endif 41 | 42 | template > class basic_ios; 43 | 44 | template > class basic_streambuf; 45 | template > class basic_istream; 46 | template > class basic_ostream; 47 | template > class basic_iostream; 48 | 49 | template , 50 | class Allocator = allocator > class basic_stringbuf; 51 | 52 | template , 53 | class Allocator = allocator > class basic_istringstream; 54 | 55 | template , 56 | class Allocator = allocator > class basic_ostringstream; 57 | 58 | template , 59 | class Allocator = allocator > class basic_stringstream; 60 | 61 | template > class basic_filebuf; 62 | 63 | template > class basic_ifstream; 64 | 65 | template > class basic_ofstream; 66 | 67 | template > class basic_fstream; 68 | 69 | template > class basic_istreambuf_iterator; 70 | 71 | template > class basic_ostreambuf_iterator; 72 | 73 | typedef basic_ios ios; 74 | #ifdef __UCLIBCXX_HAS_WCHAR__ 75 | typedef basic_ios wios; 76 | #endif 77 | 78 | typedef basic_streambuf streambuf; 79 | typedef basic_istream istream; 80 | typedef basic_ostream ostream; 81 | typedef basic_iostream iostream; 82 | 83 | typedef basic_stringbuf stringbuf; 84 | typedef basic_istringstream istringstream; 85 | typedef basic_ostringstream ostringstream; 86 | typedef basic_stringstream stringstream; 87 | 88 | typedef basic_filebuf filebuf; 89 | typedef basic_ifstream ifstream; 90 | typedef basic_ofstream ofstream; 91 | typedef basic_fstream fstream; 92 | #ifdef __UCLIBCXX_HAS_WCHAR__ 93 | typedef basic_streambuf wstreambuf; 94 | typedef basic_istream wistream; 95 | typedef basic_ostream wostream; 96 | typedef basic_iostream wiostream; 97 | 98 | typedef basic_stringbuf wstringbuf; 99 | typedef basic_istringstream wistringstream; 100 | typedef basic_ostringstream wostringstream; 101 | typedef basic_stringstream wstringstream; 102 | 103 | typedef basic_filebuf wfilebuf; 104 | typedef basic_ifstream wifstream; 105 | typedef basic_ofstream wofstream; 106 | typedef basic_fstream wfstream; 107 | #endif 108 | 109 | #ifdef ARDUINO 110 | using ::HardwareSerial; 111 | template , class Tserial=HardwareSerial> class basic_serialbuf; 112 | template , class Tserial=HardwareSerial> class basic_iserialstream; 113 | template , class Tserial=HardwareSerial> class basic_oserialstream; 114 | 115 | typedef basic_iserialstream ihserialstream; 116 | typedef basic_oserialstream ohserialstream; 117 | #endif 118 | 119 | template class fpos; 120 | typedef fpos::state_type> streampos; 121 | #ifdef __UCLIBCXX_HAS_WCHAR__ 122 | typedef fpos::state_type> wstreampos; 123 | #endif 124 | } 125 | 126 | #pragma GCC visibility pop 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /iostream: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef __HEADER_STD_IOSTREAM 23 | #define __HEADER_STD_IOSTREAM 1 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #ifdef ARDUINO 30 | #include 31 | #else 32 | #include 33 | #endif 34 | #include 35 | 36 | #pragma GCC visibility push(default) 37 | 38 | namespace std{ 39 | #ifdef ARDUINO 40 | 41 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 42 | extern ohserialstream cout; 43 | #endif 44 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 45 | extern ihserialstream cin; 46 | #endif 47 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 48 | extern ohserialstream cerr; 49 | #endif 50 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 51 | extern ohserialstream clog; 52 | #endif 53 | 54 | #else // ARDUINO 55 | 56 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 57 | extern istream cin; 58 | #endif 59 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 60 | extern ostream cout; 61 | #endif 62 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 63 | extern ostream cerr; 64 | #endif 65 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 66 | extern ostream clog; 67 | #endif 68 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 69 | extern wistream wcin; 70 | #endif 71 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 72 | extern wostream wcout; 73 | #endif 74 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 75 | extern wostream wcerr; 76 | #endif 77 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 78 | extern wostream wclog; 79 | #endif 80 | 81 | #endif // not ARDUINO 82 | 83 | template class _UCXXEXPORT basic_iostream : 84 | public basic_istream, public basic_ostream 85 | { 86 | public: 87 | // constructor/destructor 88 | explicit _UCXXEXPORT basic_iostream(basic_streambuf* sb); 89 | virtual _UCXXEXPORT ~basic_iostream(); //Below 90 | }; 91 | 92 | template _UCXXEXPORT 93 | basic_iostream:: basic_iostream(basic_streambuf* sb) 94 | : basic_ios(sb), basic_istream(sb), basic_ostream(sb) 95 | { 96 | return; 97 | } 98 | 99 | 100 | template _UCXXEXPORT basic_iostream::~basic_iostream(){ 101 | return; 102 | } 103 | 104 | 105 | #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 106 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 107 | #ifndef __UCLIBCXX_COMPILE_IOSTREAM__ 108 | 109 | template <> _UCXXEXPORT basic_iostream >:: 110 | basic_iostream(basic_streambuf >* sb); 111 | template <> _UCXXEXPORT basic_iostream >::~basic_iostream(); 112 | 113 | #endif 114 | #endif 115 | #endif 116 | 117 | 118 | 119 | } 120 | 121 | #pragma GCC visibility pop 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /iostream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #define __UCLIBCXX_COMPILE_IOSTREAM__ 1 21 | 22 | #include 23 | 24 | namespace std{ 25 | 26 | #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 27 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 28 | 29 | template _UCXXEXPORT basic_iostream >:: 30 | basic_iostream(basic_streambuf >* sb); 31 | template _UCXXEXPORT basic_iostream >::~basic_iostream(); 32 | 33 | #endif 34 | #endif 35 | 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /istream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | */ 20 | 21 | #define __UCLIBCXX_COMPILE_ISTREAM__ 1 22 | 23 | #include 24 | 25 | 26 | namespace std{ 27 | 28 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 29 | 30 | template <> _UCXXEXPORT string _readToken >(istream & stream) 31 | { 32 | string temp; 33 | char_traits::int_type c; 34 | while(true){ 35 | c = stream.rdbuf()->sgetc(); 36 | if(c != char_traits::eof() && isspace(c) == false){ 37 | stream.rdbuf()->sbumpc(); 38 | temp.append(1, char_traits::to_char_type(c)); 39 | }else{ 40 | break; 41 | } 42 | } 43 | if (temp.size() == 0) 44 | stream.setstate(ios_base::eofbit|ios_base::failbit); 45 | 46 | return temp; 47 | } 48 | 49 | template _UCXXEXPORT istream::int_type istream::get(); 50 | template _UCXXEXPORT istream & istream::get(char &c); 51 | 52 | template _UCXXEXPORT istream & istream::operator>>(bool &n); 53 | template _UCXXEXPORT istream & istream::operator>>(short &n); 54 | template _UCXXEXPORT istream & istream::operator>>(unsigned short &n); 55 | template _UCXXEXPORT istream & istream::operator>>(int &n); 56 | template _UCXXEXPORT istream & istream::operator>>(unsigned int &n); 57 | template _UCXXEXPORT istream & istream::operator>>(long unsigned &n); 58 | template _UCXXEXPORT istream & istream::operator>>(long int &n); 59 | template _UCXXEXPORT istream & istream::operator>>(void *& p); 60 | template _UCXXEXPORT istream & operator>>(istream & is, char & c); 61 | 62 | 63 | #ifdef __UCLIBCXX_HAS_FLOATS__ 64 | template _UCXXEXPORT istream & istream::operator>>(float &f); 65 | template _UCXXEXPORT istream & istream::operator>>(double &f); 66 | template _UCXXEXPORT istream & istream::operator>>(long double &f); 67 | #endif 68 | 69 | template _UCXXEXPORT void __skipws(basic_istream >& is); 70 | 71 | #endif 72 | 73 | 74 | } 75 | 76 | -------------------------------------------------------------------------------- /iterator: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | 28 | #ifndef __STD_HEADER_ITERATOR 29 | #define __STD_HEADER_ITERATOR 1 30 | 31 | #pragma GCC visibility push(default) 32 | 33 | namespace std{ 34 | 35 | // subclause _lib.stream.iterators_, stream iterators: 36 | template , class Distance = ptrdiff_t> class istream_iterator; 37 | template bool 38 | operator==(const istream_iterator& x, const istream_iterator& y); 39 | template bool 40 | operator!=(const istream_iterator& x, const istream_iterator& y); 41 | template > class ostream_iterator; 42 | template > class istreambuf_iterator; 43 | template bool 44 | operator==(const istreambuf_iterator& a, const istreambuf_iterator& b); 45 | template bool 46 | operator!=(const istreambuf_iterator& a, const istreambuf_iterator& b); 47 | template > class ostreambuf_iterator; 48 | 49 | 50 | template < class T, class charT, class traits, class Distance > class _UCXXEXPORT istream_iterator 51 | : public iterator 52 | { 53 | public: 54 | typedef charT char_type; 55 | typedef traits traits_type; 56 | typedef basic_istream istream_type; 57 | istream_iterator() : in_stream(0), value(0) {} 58 | istream_iterator(istream_type& s) : in_stream(&s), value() { 59 | *in_stream >> value; 60 | } 61 | istream_iterator(const istream_iterator& x) 62 | : in_stream(x.in_stream), value(x.value) 63 | { } 64 | ~istream_iterator() { } 65 | const T& operator*() const{ 66 | return value; 67 | } 68 | const T* operator->() const{ 69 | return &value; 70 | } 71 | istream_iterator& operator++() { 72 | *in_stream >> value; 73 | return *this; 74 | } 75 | istream_iterator operator++(int){ 76 | istream_iterator tmp = *this; 77 | *in_stream >> value; 78 | return (tmp); 79 | } 80 | bool m_equal(const istream_iterator& x) const{ 81 | return (in_stream == x.in_stream); 82 | } 83 | private: 84 | basic_istream* in_stream; 85 | T value; 86 | }; 87 | 88 | template _UCXXEXPORT 89 | bool operator==(const istream_iterator& x, 90 | const istream_iterator& y) 91 | { 92 | return x.m_equal(y); 93 | } 94 | 95 | template _UCXXEXPORT 96 | bool operator!=(const istream_iterator& x, 97 | const istream_iterator& y) 98 | { 99 | return !(x == y); 100 | } 101 | 102 | template class _UCXXEXPORT ostream_iterator 103 | : public iterator 104 | { 105 | public: 106 | typedef charT char_type; 107 | typedef traits traits_type; 108 | typedef basic_ostream ostream_type; 109 | 110 | ostream_iterator(ostream_type& s) : out_stream(&s), delim(0) { } 111 | ostream_iterator(ostream_type& s, const charT* delimiter) : out_stream(&s), delim(delimiter) { } 112 | ostream_iterator(const ostream_iterator& x) : out_stream(x.out_stream), delim(x.delim) { } 113 | ~ostream_iterator() { } 114 | ostream_iterator& operator=(const T& value){ 115 | *out_stream << value; 116 | if(delim != 0){ 117 | *out_stream << delim; 118 | } 119 | return (*this); 120 | } 121 | ostream_iterator& operator*(){ return *this; } 122 | ostream_iterator& operator++() { return *this; } 123 | ostream_iterator operator++(int) { return *this; } 124 | private: 125 | basic_ostream* out_stream; 126 | const char* delim; 127 | }; 128 | 129 | template class _UCXXEXPORT istreambuf_iterator : 130 | public iterator 131 | { 132 | public: 133 | typedef charT char_type; 134 | typedef traits traits_type; 135 | typedef typename traits::int_type int_type; 136 | typedef basic_streambuf streambuf_type; 137 | typedef basic_istream istream_type; 138 | 139 | class _UCXXEXPORT proxy{ 140 | charT val; 141 | basic_streambuf * buf; 142 | 143 | proxy(charT v, basic_streambuf * b) : val(v), buf(b) { } 144 | public: 145 | charT operator*() { return val; } 146 | }; 147 | 148 | istreambuf_iterator() throw() : sbuf(0) { } 149 | istreambuf_iterator(istream_type& s) throw() : sbuf(s.rdbuf()) { } 150 | istreambuf_iterator(streambuf_type* s) throw() : sbuf(s) { } 151 | istreambuf_iterator(const proxy& p) throw() : sbuf(&p.buf) { } 152 | 153 | charT operator*() const{ 154 | return sbuf->sgetc(); 155 | } 156 | istreambuf_iterator& operator++(){ 157 | sbuf->sbumpc(); 158 | return *this; 159 | } 160 | proxy operator++(int){ 161 | istreambuf_iterator tmp = *this; 162 | sbuf->sbumpc(); 163 | return(tmp); 164 | } 165 | 166 | bool equal(const istreambuf_iterator& b) const{ 167 | return sbuf == b.sbuf || is_eof() && b.is_eof(); 168 | } 169 | private: 170 | streambuf_type* sbuf; 171 | inline bool is_eof() const{ 172 | return sbuf == 0 || sbuf->sgetc() == traits_type::eof(); 173 | } 174 | }; 175 | 176 | template _UCXXEXPORT bool 177 | operator==(const istreambuf_iterator& a, 178 | const istreambuf_iterator& b) 179 | { 180 | return a.equal(b); 181 | } 182 | 183 | template bool _UCXXEXPORT 184 | operator!=(const istreambuf_iterator& a, 185 | const istreambuf_iterator& b) 186 | { 187 | return !a.equal(b); 188 | } 189 | 190 | template class _UCXXEXPORT ostreambuf_iterator 191 | : iterator 192 | { 193 | public: 194 | typedef charT char_type; 195 | typedef traits traits_type; 196 | typedef basic_streambuf streambuf_type; 197 | typedef basic_ostream ostream_type; 198 | public: 199 | ostreambuf_iterator(ostream_type& s) throw() : sbuf(s.rdbuf()), f(false) { } 200 | ostreambuf_iterator(streambuf_type* s) throw() : sbuf(s), f(false) { } 201 | ostreambuf_iterator& operator=(charT c){ 202 | if(failed() == false){ 203 | if(sbuf->sputc(c) == traits::eof()){ 204 | f = true; 205 | } 206 | } 207 | return *this; 208 | } 209 | ostreambuf_iterator& operator*(){ 210 | return *this; 211 | } 212 | ostreambuf_iterator& operator++() { return *this; } 213 | ostreambuf_iterator operator++(int) { return *this; } 214 | bool failed() const throw(){ 215 | return f; 216 | } 217 | 218 | private: 219 | streambuf_type* sbuf; 220 | bool f; 221 | }; 222 | 223 | } 224 | 225 | #pragma GCC visibility pop 226 | 227 | #endif 228 | 229 | 230 | -------------------------------------------------------------------------------- /iterator.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "StandardCplusplus", 3 | "version": "1.0.0", 4 | "keywords": "std, algorithm, stream, vector", 5 | "description": "Standard C++ for Arduino (port of uClibc++)", 6 | "license": "LGPL-3.0-or-later", 7 | "repository": 8 | { 9 | "type": "git", 10 | "url": "https://github.com/maniacbug/StandardCplusplus.git" 11 | }, 12 | "frameworks": "arduino", 13 | "platforms": "atmelavr" 14 | } 15 | 16 | -------------------------------------------------------------------------------- /limits.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /list.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /locale: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef __HEADER_STD_LOCALE 25 | #define __HEADER_STD_LOCALE 1 26 | 27 | #pragma GCC visibility push(default) 28 | 29 | namespace std{ 30 | class _UCXXEXPORT locale { 31 | public: 32 | // types: 33 | class facet; 34 | class id; 35 | typedef unsigned char category; 36 | 37 | static const category 38 | none = 0, 39 | collate = 0x01, ctype = 0x02, 40 | monetary = 0x04, numeric = 0x08, 41 | time = 0x10, messages = 0x20, 42 | all = collate | ctype | monetary | numeric | time | messages; 43 | 44 | // construct/copy/destroy: 45 | locale() throw(){ 46 | return; 47 | } 48 | locale(const locale& other) throw(){ 49 | (void)other; 50 | return; 51 | } 52 | locale(const char *) throw(){ 53 | return; 54 | } 55 | ~locale() throw(){ 56 | return; 57 | } 58 | 59 | const locale& operator=(const locale&) throw(){ 60 | return *this; 61 | } 62 | std::string name() const { return "C"; } 63 | }; 64 | 65 | class _UCXXEXPORT locale::facet { 66 | friend class locale; 67 | explicit facet(size_t = 0){ 68 | return; 69 | } 70 | virtual ~facet(){ 71 | return; 72 | } 73 | }; 74 | 75 | class _UCXXEXPORT locale::id { 76 | id(){ } 77 | }; 78 | 79 | } 80 | 81 | #pragma GCC visibility pop 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /locale.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace std{ 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /map.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /memory: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef HEADER_STD_MEMORY 28 | #define HEADER_STD_MEMORY 1 29 | 30 | #pragma GCC visibility push(default) 31 | 32 | namespace std{ 33 | 34 | template class allocator; 35 | // Specialize for void: 36 | 37 | template <> class _UCXXEXPORT allocator { 38 | public: 39 | typedef void* pointer; 40 | typedef const void* const_pointer; 41 | typedef void value_type; 42 | template struct rebind { typedef allocator other; }; 43 | }; 44 | 45 | template class _UCXXEXPORT allocator{ 46 | public: 47 | typedef T value_type; 48 | typedef size_t size_type; 49 | typedef ptrdiff_t difference_type; 50 | 51 | typedef T* pointer; 52 | typedef const T* const_pointer; 53 | 54 | typedef T& reference; 55 | typedef const T& const_reference; 56 | 57 | pointer address(reference r) const { return &r; } 58 | const_pointer address(const_reference r) const { return &r; } 59 | 60 | allocator() throw(){} 61 | template allocator(const allocator& ) throw(); 62 | ~allocator() throw(){} 63 | 64 | //Space for n Ts 65 | pointer allocate(size_type n, typename allocator::const_pointer = 0){ 66 | return (T*)(::operator new( n * sizeof(T) )); 67 | } 68 | void deallocate(pointer p, size_type){ 69 | ::operator delete(p); 70 | } 71 | 72 | //Use placement new to engage the constructor 73 | void construct(pointer p, const T& val) { new((void*)p) T(val); } 74 | void destroy(pointer p){ ((T*)p)->~T(); } //Call destructor 75 | 76 | size_type max_size() const throw(); 77 | template struct rebind { typedef allocator other; }; 78 | 79 | }; 80 | 81 | template class _UCXXEXPORT raw_storage_iterator 82 | : public iterator 83 | { 84 | Out p; 85 | 86 | public: 87 | explicit raw_storage_iterator(Out pp) : p (pp) { } 88 | raw_storage_iterator & operator*() { return *this; } 89 | raw_storage_iterator & operator=(const T& val) { 90 | T* pp = &*p; 91 | new(pp) T(val); 92 | return *this; 93 | } 94 | 95 | raw_storage_iterator & operator++() { ++p; return *this; } 96 | raw_storage_iterator operator++(int) { 97 | raw_storage_iterator t = *this; 98 | ++p; 99 | return t; 100 | } 101 | }; 102 | 103 | template _UCXXEXPORT pair get_temporary_buffer(ptrdiff_t n){ 104 | pair retval; 105 | retval.first = static_cast(malloc(n * sizeof(T))); 106 | if(retval.first == 0){ 107 | retval.second = 0; 108 | }else{ 109 | retval.second = n; 110 | } 111 | return retval; 112 | } 113 | 114 | template _UCXXEXPORT void return_temporary_buffer(T* p){ 115 | free(p); 116 | } 117 | 118 | 119 | template class _UCXXEXPORT auto_ptr{ 120 | 121 | private: 122 | T * object; 123 | template struct auto_ptr_ref{ 124 | Y * p; 125 | }; 126 | 127 | public: 128 | 129 | typedef T element_type; 130 | 131 | explicit auto_ptr(T* p =0) throw() : object(p){ } 132 | auto_ptr(auto_ptr& p) throw() : object(p.release()){ } 133 | auto_ptr(auto_ptr_ref r) throw() : object(r.p){ 134 | r.p = 0; 135 | } 136 | template auto_ptr(auto_ptr& p) throw() : object(p.release()){ } 137 | auto_ptr& operator=(auto_ptr& p) throw(){ 138 | if(&p == this){ 139 | return *this; 140 | } 141 | delete object; 142 | object = p.release(); 143 | return *this; 144 | } 145 | template auto_ptr& operator=(auto_ptr& p) throw(){ 146 | if(&p == this){ 147 | return *this; 148 | } 149 | delete object; 150 | object = p.release(); 151 | return *this; 152 | } 153 | ~auto_ptr(){ 154 | delete object; 155 | } 156 | 157 | T& operator*() const throw(){ 158 | return *object; 159 | } 160 | T* operator->() const throw(){ 161 | return object; 162 | } 163 | T* get() const throw(){ 164 | return object; 165 | } 166 | T* release() throw(){ 167 | T * temp(object); 168 | object = 0; 169 | return temp; 170 | } 171 | void reset(T * p=0) throw(){ 172 | if(p != object){ 173 | delete object; 174 | object = p; 175 | } 176 | } 177 | template operator auto_ptr_ref() throw(){ 178 | auto_ptr_ref retval; 179 | retval.p = object; 180 | object = 0; 181 | return retval; 182 | } 183 | template operator auto_ptr() throw(){ 184 | auto_ptr retval(object); 185 | object = 0; 186 | return retval; 187 | } 188 | 189 | }; 190 | 191 | } //namespace std 192 | 193 | #pragma GCC visibility pop 194 | 195 | #endif 196 | 197 | -------------------------------------------------------------------------------- /new: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef __STD_NEW_OPERATOR 25 | #define __STD_NEW_OPERATOR 1 26 | 27 | #pragma GCC visibility push(default) 28 | 29 | namespace std{ 30 | class _UCXXEXPORT bad_alloc : public exception {}; 31 | 32 | struct _UCXXEXPORT nothrow_t {}; 33 | extern const nothrow_t nothrow; 34 | 35 | typedef void (*new_handler)(); 36 | _UCXXEXPORT new_handler set_new_handler(new_handler new_p) throw(); 37 | } 38 | 39 | 40 | _UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc); 41 | _UCXXEXPORT void operator delete(void* ptr) throw(); 42 | 43 | _UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc); 44 | _UCXXEXPORT void operator delete[](void * ptr) throw(); 45 | 46 | #ifndef NO_NOTHROW 47 | _UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) throw(); 48 | _UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) throw(); 49 | 50 | _UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) throw(); 51 | _UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) throw(); 52 | #endif 53 | 54 | /* Placement operators */ 55 | inline void* operator new(std::size_t, void* ptr) throw() {return ptr; } 56 | inline void operator delete(void* , void *) throw() { } 57 | 58 | inline void* operator new[](std::size_t, void *p) throw() { return p; } 59 | inline void operator delete[](void* , void *) throw() {} 60 | 61 | #pragma GCC visibility pop 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /new_handler.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | const std::nothrow_t std::nothrow = { }; 23 | 24 | //Name selected to be compatable with g++ code 25 | std::new_handler __new_handler; 26 | 27 | _UCXXEXPORT std::new_handler std::set_new_handler(std::new_handler new_p) throw(){ 28 | std::new_handler retval = __new_handler; 29 | __new_handler = new_p; 30 | return retval; 31 | } 32 | -------------------------------------------------------------------------------- /new_op.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | // Arduino 1.0 contains an implementation for this. 21 | #if ARDUINO < 100 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | _UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc){ 28 | //C++ stardard 5.3.4.8 requires that a valid pointer be returned for 29 | //a call to new(0). Thus: 30 | if(numBytes == 0){ 31 | numBytes = 1; 32 | } 33 | void * p = malloc(numBytes); 34 | if(p == 0){ 35 | std::__throw_bad_alloc(); 36 | } 37 | return p; 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /new_opnt.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) throw(){ 26 | return malloc(numBytes); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /new_opv.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | // Arduino 1.04 contains an implementation for this. 20 | #if ARDUINO < 104 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | _UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc){ 27 | //C++ stardard 5.3.4.8 requires that a valid pointer be returned for 28 | //a call to new(0). Thus: 29 | if(numBytes == 0){ 30 | numBytes = 1; 31 | } 32 | void * p = malloc(numBytes); 33 | if(p == 0){ 34 | std::__throw_bad_alloc(); 35 | } 36 | return p; 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /new_opvnt.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) throw(){ 26 | return malloc(numBytes); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /numeric: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #ifndef __STD_NUMERIC_HEADER 24 | #define __STD_NUMERIC_HEADER 1 25 | 26 | #pragma GCC visibility push(default) 27 | 28 | namespace std{ 29 | template _UCXXEXPORT 30 | T accumulate(InputIterator first, InputIterator last, T init) 31 | { 32 | while(first != last){ 33 | init = init + *first; 34 | ++first; 35 | } 36 | return init; 37 | } 38 | 39 | template _UCXXEXPORT 40 | T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) 41 | { 42 | while(first != last){ 43 | init = binary_op(init, *first); 44 | ++first; 45 | } 46 | return init; 47 | } 48 | 49 | 50 | template _UCXXEXPORT 51 | T inner_product(InputIterator1 first1, InputIterator1 last1, 52 | InputIterator2 first2, T init) 53 | { 54 | while(first1 != last1){ 55 | init = init + *first1 * *first2; 56 | ++first1; 57 | ++first2; 58 | } 59 | return init; 60 | } 61 | 62 | template _UCXXEXPORT 64 | T inner_product(InputIterator1 first1, InputIterator1 last1, 65 | InputIterator2 first2, T init, 66 | BinaryOperation1 binary_op1, 67 | BinaryOperation2 binary_op2) 68 | { 69 | while(first1 != last1){ 70 | init = binary_op1(init, binary_op2(*first1, *first2)); 71 | ++first1; 72 | ++first2; 73 | } 74 | return init; 75 | } 76 | 77 | template _UCXXEXPORT 78 | OutputIterator partial_sum(InputIterator first, InputIterator last, 79 | OutputIterator result) 80 | { 81 | OutputIterator temp(result); 82 | *result = *first; 83 | ++first; 84 | ++result; 85 | 86 | while(first != last){ 87 | *result = *first + *temp; 88 | temp = result; 89 | ++first; 90 | ++result; 91 | } 92 | return result; 93 | } 94 | 95 | 96 | template _UCXXEXPORT 97 | OutputIterator partial_sum(InputIterator first, InputIterator last, 98 | OutputIterator result, BinaryOperation binary_op) 99 | { 100 | OutputIterator temp(result); 101 | *result = *first; 102 | ++first; 103 | ++result; 104 | 105 | while(first != last){ 106 | *result = binary_op(*first, *temp); 107 | temp = result; 108 | ++first; 109 | ++result; 110 | } 111 | return result; 112 | } 113 | 114 | 115 | template _UCXXEXPORT 116 | OutputIterator 117 | adjacent_difference(InputIterator first, InputIterator last, 118 | OutputIterator result) 119 | { 120 | OutputIterator temp(first); 121 | *result = *first; 122 | ++first; 123 | ++result; 124 | 125 | while(first != last){ 126 | *result = *first - *temp; 127 | temp = first; 128 | ++first; 129 | ++result; 130 | } 131 | 132 | return result; 133 | } 134 | 135 | 136 | template _UCXXEXPORT 137 | OutputIterator 138 | adjacent_difference(InputIterator first, InputIterator last, 139 | OutputIterator result, BinaryOperation binary_op) 140 | { 141 | OutputIterator temp(first); 142 | *result = *first; 143 | ++first; 144 | ++result; 145 | 146 | while(first != last){ 147 | *result = binary_op(*first, *temp); 148 | temp = first; 149 | ++first; 150 | ++result; 151 | } 152 | 153 | return result; 154 | } 155 | 156 | } 157 | 158 | #pragma GCC visibility pop 159 | 160 | #endif 161 | 162 | -------------------------------------------------------------------------------- /numeric.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /ostream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #define __UCLIBCXX_COMPILE_OSTREAM__ 1 21 | 22 | #include 23 | 24 | namespace std{ 25 | 26 | 27 | #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 28 | 29 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 30 | template _UCXXEXPORT ostream::~basic_ostream(); 31 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 32 | 33 | template _UCXXEXPORT ostream & ostream::flush(); 34 | 35 | template _UCXXEXPORT ostream & ostream::operator<<(bool n); 36 | template _UCXXEXPORT ostream & ostream::operator<<(short int n); 37 | template _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n); 38 | template _UCXXEXPORT ostream & ostream::operator<<(int n); 39 | template _UCXXEXPORT ostream & ostream::operator<<(unsigned int n); 40 | template _UCXXEXPORT ostream & ostream::operator<<(long n); 41 | template _UCXXEXPORT ostream & ostream::operator<<(unsigned long n); 42 | template _UCXXEXPORT ostream & ostream::operator<<(float f); 43 | template _UCXXEXPORT ostream & ostream::operator<<(double f); 44 | template _UCXXEXPORT ostream & ostream::operator<<(long double f); 45 | template _UCXXEXPORT ostream & ostream::operator<<(void* p); 46 | template _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf >* sb); 47 | 48 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 49 | 50 | template _UCXXEXPORT ostream::sentry::sentry(ostream & os); 51 | template _UCXXEXPORT ostream::sentry::~sentry(); 52 | 53 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 54 | 55 | template _UCXXEXPORT ostream & endl(ostream & os); 56 | template _UCXXEXPORT ostream & flush(ostream & os); 57 | template _UCXXEXPORT ostream & operator<<(ostream & out, char c); 58 | template _UCXXEXPORT ostream & operator<<(ostream & out, const char* c); 59 | template _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c); 60 | template _UCXXEXPORT ostream & operator<<(ostream & out, const unsigned char* c); 61 | 62 | #endif 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /queue: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | This library is free software; you can redistribute it and/or 4 | modify it under the terms of the GNU Lesser General Public 5 | License as published by the Free Software Foundation; either 6 | version 2.1 of the License, or (at your option) any later version. 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #ifndef __HEADER_STD_QUEUE 24 | #define __HEADER_STD_QUEUE 1 25 | 26 | #pragma GCC visibility push(default) 27 | 28 | namespace std{ 29 | 30 | template > class _UCXXEXPORT queue{ 31 | protected: 32 | Container c; 33 | public: 34 | typedef typename Container::value_type value_type; 35 | typedef typename Container::size_type size_type; 36 | typedef Container container_type; 37 | 38 | explicit queue(const Container& a = Container()) : c(a) { } 39 | 40 | bool empty() const { return c.empty(); } 41 | size_type size() const { return c.size(); } 42 | value_type& front() { return c.front(); } 43 | const value_type& front() const { return c.front(); } 44 | value_type& back() { return c.back(); } 45 | const value_type& back() const { return c.back(); } 46 | void push(const value_type& x) { c.push_back(x); } 47 | void pop() { c.pop_front(); } 48 | }; 49 | 50 | 51 | template _UCXXEXPORT bool 52 | operator==(const queue& x, const queue& y) 53 | { 54 | return (x.c == y.c); 55 | } 56 | template _UCXXEXPORT bool 57 | operator< (const queue& x, const queue& y) 58 | { 59 | return (x.c < y.c); 60 | } 61 | template _UCXXEXPORT bool 62 | operator!=(const queue& x, const queue& y) 63 | { 64 | return (x.c != y.c); 65 | } 66 | template _UCXXEXPORT bool 67 | operator> (const queue& x, const queue& y) 68 | { 69 | return (x.c > y.c); 70 | } 71 | template _UCXXEXPORT bool 72 | operator>=(const queue& x, const queue& y) 73 | { 74 | return (x.c >= y.c); 75 | } 76 | template _UCXXEXPORT bool 77 | operator<=(const queue& x, const queue& y) 78 | { 79 | return (x.c <= y.c); 80 | } 81 | 82 | 83 | template , 85 | class Compare = less 86 | > class _UCXXEXPORT priority_queue { 87 | protected: 88 | Container c; 89 | Compare comp; 90 | public: 91 | typedef typename Container::value_type value_type; 92 | typedef typename Container::size_type size_type; 93 | typedef Container container_type; 94 | 95 | explicit priority_queue(const Compare& x = Compare(), const Container& a = Container()) 96 | : c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; } 97 | template priority_queue(InputIterator first, 98 | InputIterator last, 99 | const Compare& x = Compare(), 100 | const Container& y= Container()) 101 | : c(y), comp(c) 102 | { 103 | c.insert(c.end(), first, last); 104 | make_heap(c.begin(), c.end(), comp); 105 | } 106 | 107 | bool empty() const { return c.empty(); } 108 | size_type size() const { return c.size(); } 109 | const value_type& top() const { return c.front(); } 110 | void push(const value_type& x){ 111 | c.push_back(x); 112 | push_heap(c.begin(), c.end(), comp); 113 | } 114 | void pop(){ 115 | pop_heap(c.begin(), c.end(), comp); 116 | c.pop_back(); 117 | } 118 | }; 119 | 120 | } 121 | 122 | #pragma GCC visibility pop 123 | 124 | #endif 125 | 126 | 127 | -------------------------------------------------------------------------------- /queue.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /serstream: -------------------------------------------------------------------------------- 1 | /* 2 | * serstream 3 | * Implementation of input/output streams for the Arduino serial classes 4 | * 5 | * Created on: 2 Jan 2011 6 | * Author: Andy Brown 7 | * 8 | * http://andybrown.me.uk/ws/terms-and-conditions 9 | */ 10 | 11 | #ifndef __810370EC_AD69_4ef7_91F5_B1AA16F14712 12 | #define __810370EC_AD69_4ef7_91F5_B1AA16F14712 13 | 14 | #include 15 | 16 | //#include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | namespace std 26 | { 27 | /* 28 | * basic_serialbuf implements an unbuffered basic_streambuf as a backing buffer 29 | * for the IO classes 30 | */ 31 | 32 | template 33 | class basic_serialbuf : public basic_streambuf 34 | { 35 | public: 36 | 37 | /* 38 | * Types used here 39 | */ 40 | 41 | typedef charT char_type; 42 | typedef typename traits::int_type int_type; 43 | 44 | /* 45 | * constructor - wraps an existing Tserial class instance 46 | */ 47 | 48 | explicit basic_serialbuf(Tserial& serial_,ios_base::openmode which_ = ios_base::in | ios_base::out) 49 | : _serial(serial_) 50 | { 51 | basic_streambuf::openedFor = which_; 52 | } 53 | 54 | /* 55 | * Required to maintain the chain 56 | */ 57 | 58 | virtual ~basic_serialbuf() { } 59 | 60 | /* 61 | * Get a reference to the wrapped object 62 | */ 63 | 64 | Tserial& serial() { return _serial; } 65 | 66 | protected: 67 | 68 | /* 69 | * Get how many bytes available 70 | */ 71 | 72 | virtual int showmanyc(){ 73 | return _serial.available(); 74 | } 75 | 76 | /* 77 | * Read up to n chars 78 | */ 79 | 80 | virtual streamsize xsgetn(char_type* c, streamsize n) { 81 | 82 | streamsize i = 0; 83 | char_type data; 84 | 85 | while((data=_serial.read())!=-1 && i < n ) { 86 | c[i] = data; 87 | ++i; 88 | } 89 | return i; 90 | } 91 | 92 | /* 93 | * Write up to n chars 94 | */ 95 | 96 | virtual streamsize xsputn(const char_type* s, streamsize n){ 97 | 98 | //_serial.print("[PUT "); 99 | //_serial.print(n); 100 | //_serial.print("] "); 101 | for(streamsize i=0;i class basic_iserialstream 163 | : public basic_istream 164 | { 165 | public: 166 | 167 | /* 168 | * Types used here 169 | */ 170 | 171 | typedef charT char_type; 172 | 173 | /* 174 | * Constructor - default the serial object to #1 175 | * Mega users can explicity initialise with one of 176 | * the others 177 | */ 178 | 179 | explicit basic_iserialstream(Tserial& serial_) 180 | : basic_ios(&sb), basic_istream(&sb), sb(serial_,ios_base::in) 181 | { 182 | } 183 | 184 | /* 185 | * Required to maintain the chain 186 | */ 187 | 188 | virtual ~basic_iserialstream() { } 189 | 190 | /* 191 | * Initialise the baud rate 192 | */ 193 | 194 | void begin(long speed_) { 195 | sb.serial().begin(speed_); 196 | sb.serial().println(__FUNCTION__); 197 | } 198 | 199 | /* 200 | * The wrapped object 201 | */ 202 | 203 | private: 204 | basic_serialbuf sb; 205 | }; 206 | 207 | 208 | /* 209 | * Output stream 210 | */ 211 | 212 | template class basic_oserialstream 213 | : public basic_ostream 214 | { 215 | public: 216 | 217 | /* 218 | * Types used here 219 | */ 220 | 221 | typedef charT char_type; 222 | 223 | /* 224 | * Constructor - default the serial object to #1 225 | * Mega users can explicity initialise with one of 226 | * the others 227 | */ 228 | 229 | explicit basic_oserialstream(Tserial& serial_) 230 | : basic_ios(&sb), basic_ostream(&sb), sb(serial_,ios_base::out) 231 | { 232 | } 233 | 234 | /* 235 | * Required to maintain the chain 236 | */ 237 | 238 | virtual ~basic_oserialstream() { } 239 | 240 | /* 241 | * Initialise the baud rate 242 | */ 243 | 244 | void begin(long speed_) { 245 | sb.serial().begin(speed_); 246 | } 247 | 248 | /* 249 | * The wrapped object 250 | */ 251 | 252 | private: 253 | basic_serialbuf sb; 254 | }; 255 | 256 | 257 | /* 258 | * Input/output stream 259 | */ 260 | 261 | template class basic_ioserialstream 262 | : public basic_iostream 263 | { 264 | public: 265 | 266 | /* 267 | * Types used here 268 | */ 269 | 270 | typedef charT char_type; 271 | 272 | /* 273 | * Constructor - default the serial object to #1 274 | * Mega users can explicity initialise with one of 275 | * the others 276 | */ 277 | 278 | explicit basic_ioserialstream(Tserial& serial_) 279 | : basic_ios(&sb), basic_iostream(&sb), sb(serial_,ios_base::in | ios_base::out) 280 | { 281 | } 282 | 283 | /* 284 | * Required to maintain the chain 285 | */ 286 | 287 | virtual ~basic_ioserialstream(){ } 288 | 289 | /* 290 | * Initialise the baud rate 291 | */ 292 | 293 | void begin(long speed_) { 294 | sb.serial().begin(speed_); 295 | } 296 | 297 | /* 298 | * The wrapped object 299 | */ 300 | 301 | private: 302 | basic_serialbuf sb; 303 | }; 304 | 305 | 306 | 307 | } 308 | 309 | #endif 310 | -------------------------------------------------------------------------------- /set.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sstream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #define __UCLIBCXX_COMPILE_SSTREAM__ 1 21 | 22 | #include 23 | 24 | namespace std{ 25 | 26 | #ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__ 27 | 28 | typedef char_traits tr_ch; 29 | typedef basic_stringbuf > char_stringbuf; 30 | 31 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 32 | 33 | template _UCXXEXPORT char_stringbuf::basic_stringbuf(ios_base::openmode which); 34 | template _UCXXEXPORT char_stringbuf::~basic_stringbuf(); 35 | 36 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 37 | 38 | template _UCXXEXPORT basic_string, allocator > char_stringbuf::str() const; 39 | template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::pbackfail(char_stringbuf::int_type c); 40 | template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::overflow(char_stringbuf::int_type c); 41 | template _UCXXEXPORT char_stringbuf::pos_type 42 | char_stringbuf::seekoff(char_stringbuf::off_type, ios_base::seekdir, ios_base::openmode); 43 | template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::underflow (); 44 | template _UCXXEXPORT streamsize char_stringbuf::xsputn(const char* s, streamsize n); 45 | 46 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 47 | 48 | template _UCXXEXPORT basic_stringstream >::basic_stringstream(ios_base::openmode which); 49 | template _UCXXEXPORT basic_istringstream >::~basic_istringstream(); 50 | template _UCXXEXPORT basic_ostringstream >::~basic_ostringstream(); 51 | template _UCXXEXPORT basic_stringstream >::~basic_stringstream(); 52 | 53 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 54 | 55 | #endif 56 | 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /stack: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | This library is free software; you can redistribute it and/or 4 | modify it under the terms of the GNU Lesser General Public 5 | License as published by the Free Software Foundation; either 6 | version 2.1 of the License, or (at your option) any later version. 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #ifndef __HEADER_STD_STACK 22 | #define __HEADER_STD_STACK 1 23 | 24 | #pragma GCC visibility push(default) 25 | 26 | namespace std{ 27 | 28 | template > class _UCXXEXPORT stack{ 29 | protected: 30 | Container c; 31 | 32 | public: 33 | typedef typename Container::value_type value_type; 34 | typedef typename Container::size_type size_type; 35 | typedef Container container_type; 36 | 37 | explicit stack(const Container& a = Container()) : c(a) { }; 38 | bool empty() const { return c.empty(); } 39 | size_type size() const { return c.size(); } 40 | value_type& top() { return c.back(); } 41 | const value_type& top() const { return c.back(); } 42 | void push(const value_type& x) { c.push_back(x); } 43 | void pop() { c.pop_back(); } 44 | 45 | bool operator==(const stack &x) const{ 46 | return x.c == c; 47 | } 48 | 49 | }; 50 | 51 | 52 | template _UCXXEXPORT bool 53 | operator< (const stack& x, const stack& y) 54 | { 55 | return (x.c < y.c); 56 | } 57 | template _UCXXEXPORT bool 58 | operator!=(const stack& x, const stack& y) 59 | { 60 | return (x.c != y.c); 61 | } 62 | template _UCXXEXPORT bool 63 | operator> (const stack& x, const stack& y) 64 | { 65 | return (x.c > y.c); 66 | } 67 | template _UCXXEXPORT bool 68 | operator>=(const stack& x, const stack& y) 69 | { 70 | return (x.c >= y.c); 71 | } 72 | template _UCXXEXPORT bool 73 | operator<=(const stack& x, const stack& y) 74 | { 75 | return (x.c <= y.c); 76 | } 77 | 78 | } 79 | 80 | #pragma GCC visibility pop 81 | 82 | #endif 83 | 84 | 85 | -------------------------------------------------------------------------------- /stack.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /stdexcept: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef HEADER_STD_EXCEPTIONS 25 | #define HEADER_STD_EXCEPTIONS 1 26 | 27 | //Don't include support if not needed 28 | #ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ 29 | 30 | #pragma GCC visibility push(default) 31 | 32 | namespace std{ 33 | 34 | //typedef basic_string string; 35 | 36 | class _UCXXEXPORT logic_error : public exception { 37 | protected: 38 | string mstring; 39 | public: 40 | logic_error() throw(); 41 | logic_error(const string& what_arg); 42 | 43 | virtual ~logic_error() throw() {} 44 | virtual const char * what() const throw(); 45 | 46 | }; 47 | 48 | class _UCXXEXPORT domain_error : public logic_error { 49 | public: 50 | domain_error() : logic_error() {} 51 | domain_error(const string& what_arg) : logic_error(what_arg) {} 52 | virtual ~domain_error() throw() {} 53 | }; 54 | 55 | class _UCXXEXPORT invalid_argument : public logic_error { 56 | public: 57 | invalid_argument() : logic_error(){} 58 | invalid_argument(const string& what_arg) : logic_error(what_arg){} 59 | virtual ~invalid_argument() throw() {} 60 | }; 61 | 62 | class _UCXXEXPORT length_error : public logic_error { 63 | public: 64 | length_error() : logic_error(){} 65 | length_error(const string& what_arg) : logic_error(what_arg){} 66 | virtual ~length_error() throw() {} 67 | }; 68 | 69 | class _UCXXEXPORT out_of_range : public logic_error{ 70 | public: 71 | out_of_range(); 72 | out_of_range(const string & what_arg); 73 | virtual ~out_of_range() throw() {} 74 | 75 | }; 76 | 77 | class _UCXXEXPORT runtime_error : public exception{ 78 | protected: 79 | string mstring; 80 | public: 81 | runtime_error(); 82 | runtime_error(const string& what_arg); 83 | 84 | virtual ~runtime_error() throw() {} 85 | virtual const char * what() const throw(); 86 | }; 87 | 88 | class _UCXXEXPORT range_error : public runtime_error{ 89 | public: 90 | range_error() : runtime_error(){} 91 | range_error(const string& what_arg) : runtime_error(what_arg) {} 92 | virtual ~range_error() throw(){ } 93 | }; 94 | 95 | 96 | class _UCXXEXPORT overflow_error : public runtime_error{ 97 | public: 98 | overflow_error() : runtime_error(){} 99 | overflow_error(const string& what_arg) : runtime_error(what_arg) {} 100 | virtual ~overflow_error() throw(){} 101 | }; 102 | 103 | class _UCXXEXPORT underflow_error : public runtime_error{ 104 | public: 105 | underflow_error() : runtime_error(){} 106 | underflow_error(const string& what_arg) : runtime_error(what_arg) {} 107 | virtual ~underflow_error() throw(){} 108 | }; 109 | 110 | 111 | 112 | } 113 | 114 | #pragma GCC visibility pop 115 | 116 | #endif 117 | #endif 118 | -------------------------------------------------------------------------------- /stdexcept.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ 24 | 25 | namespace std{ 26 | 27 | _UCXXEXPORT logic_error::logic_error() throw() : mstring(){ 28 | 29 | } 30 | 31 | _UCXXEXPORT logic_error::logic_error(const string& what_arg) : mstring(what_arg){ 32 | 33 | } 34 | 35 | _UCXXEXPORT const char * logic_error::what() const throw(){ 36 | return mstring.c_str(); 37 | } 38 | 39 | 40 | _UCXXEXPORT out_of_range::out_of_range() : logic_error(){ 41 | 42 | } 43 | 44 | _UCXXEXPORT out_of_range::out_of_range(const string & what_arg) : logic_error(what_arg) { 45 | 46 | } 47 | 48 | _UCXXEXPORT runtime_error::runtime_error() : mstring(){ 49 | 50 | } 51 | 52 | _UCXXEXPORT runtime_error::runtime_error(const string& what_arg) : mstring(what_arg){ 53 | 54 | } 55 | 56 | _UCXXEXPORT const char * runtime_error::what() const throw(){ 57 | return mstring.c_str(); 58 | } 59 | 60 | } 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /streambuf.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #define __UCLIBCXX_COMPILE_STREAMBUF__ 1 21 | 22 | #include 23 | 24 | namespace std{ 25 | 26 | #ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ 27 | 28 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 29 | 30 | template _UCXXEXPORT streambuf::basic_streambuf(); 31 | template _UCXXEXPORT streambuf::~basic_streambuf(); 32 | 33 | #endif 34 | 35 | template _UCXXEXPORT locale streambuf::pubimbue(const locale &loc); 36 | template _UCXXEXPORT streamsize streambuf::in_avail(); 37 | template _UCXXEXPORT streambuf::int_type streambuf::sbumpc(); 38 | template _UCXXEXPORT streambuf::int_type streambuf::snextc(); 39 | template _UCXXEXPORT streambuf::int_type streambuf::sgetc(); 40 | template _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c); 41 | template _UCXXEXPORT streambuf::int_type streambuf::sungetc(); 42 | template _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c); 43 | 44 | #endif 45 | 46 | 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /string.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #define __UCLIBCXX_COMPILE_STRING__ 1 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace std{ 30 | 31 | #ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ 32 | 33 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 34 | 35 | template _UCXXEXPORT string::basic_string(const allocator &); 36 | template _UCXXEXPORT string::basic_string(size_type n, char c, const allocator & ); 37 | template _UCXXEXPORT string::basic_string(const char* s, const allocator& al); 38 | template _UCXXEXPORT string::basic_string(const basic_string& str, size_type pos, size_type n, const allocator& al); 39 | template _UCXXEXPORT string::~basic_string(); 40 | 41 | #endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 42 | 43 | template _UCXXEXPORT string & string::append(const char * s, size_type n); 44 | 45 | template _UCXXEXPORT string::size_type string::find(const string & str, size_type pos) const; 46 | template _UCXXEXPORT string::size_type string::find(const char* s, size_type pos) const; 47 | template _UCXXEXPORT string::size_type string::find (char c, size_type pos) const; 48 | template _UCXXEXPORT string::size_type string::rfind(const string & str, size_type pos) const; 49 | template _UCXXEXPORT string::size_type string::rfind(char c, size_type pos) const; 50 | template _UCXXEXPORT string::size_type string::rfind(const char* s, size_type pos) const; 51 | 52 | template _UCXXEXPORT string::size_type string::find_first_of(const string &, size_type) const; 53 | template _UCXXEXPORT string::size_type string::find_first_of(const char *, size_type pos, size_type n) const; 54 | template _UCXXEXPORT string::size_type string::find_first_of(const char*, size_type pos) const; 55 | template _UCXXEXPORT string::size_type string::find_first_of(char c, size_type pos) const; 56 | 57 | template _UCXXEXPORT string::size_type string::find_last_of (const string & , size_type pos) const; 58 | template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos, size_type n) const; 59 | template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos) const; 60 | template _UCXXEXPORT string::size_type string::find_last_of (char c, size_type pos) const; 61 | 62 | template _UCXXEXPORT string::size_type string::find_first_not_of(const string &, size_type) const; 63 | template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type, size_type) const; 64 | template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type) const; 65 | template _UCXXEXPORT string::size_type string::find_first_not_of(char c, size_type) const; 66 | 67 | template _UCXXEXPORT int string::compare(const string & str) const; 68 | // template _UCXXEXPORT int string::compare(size_type pos1, size_type n1, const string & str) const; 69 | template _UCXXEXPORT int string::compare( 70 | size_type pos1, size_type n1, const string & str, size_type pos2, size_type n2) const; 71 | 72 | template _UCXXEXPORT string string::substr(size_type pos, size_type n) const; 73 | 74 | template _UCXXEXPORT string & string::operator=(const string & str); 75 | template _UCXXEXPORT string & string::operator=(const char * s); 76 | 77 | template _UCXXEXPORT bool operator==(const string & lhs, const string & rhs); 78 | template _UCXXEXPORT bool operator==(const char * lhs, const string & rhs); 79 | template _UCXXEXPORT bool operator==(const string & lhs, const char * rhs); 80 | 81 | template _UCXXEXPORT bool operator!=(const string & lhs, const string & rhs); 82 | template _UCXXEXPORT bool operator!=(const char * lhs, const string & rhs); 83 | template _UCXXEXPORT bool operator!=(const string & lhs, const char * rhs); 84 | 85 | template _UCXXEXPORT string operator+(const string & lhs, const char* rhs); 86 | template _UCXXEXPORT string operator+(const char* lhs, const string & rhs); 87 | template _UCXXEXPORT string operator+(const string & lhs, const string & rhs); 88 | 89 | template _UCXXEXPORT bool operator> (const string & lhs, const string & rhs); 90 | template _UCXXEXPORT bool operator< (const string & lhs, const string & rhs); 91 | 92 | 93 | //Functions dependent upon OSTREAM 94 | #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 95 | 96 | template _UCXXEXPORT ostream & operator<<(ostream & os, const string & str); 97 | 98 | #endif 99 | 100 | 101 | //Functions dependent upon ISTREAM 102 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 103 | 104 | template _UCXXEXPORT istream & operator>>(istream & is, string & str); 105 | 106 | 107 | #endif 108 | 109 | 110 | #endif 111 | 112 | } 113 | -------------------------------------------------------------------------------- /string_iostream: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __UCLIBCXX_HAS_WCHAR__ 25 | #include 26 | #include 27 | #endif 28 | 29 | #ifndef __HEADER_STD_STRING_IOSTREAM 30 | #define __HEADER_STD_STRING_IOSTREAM 1 31 | 32 | #pragma GCC visibility push(default) 33 | 34 | namespace std{ 35 | 36 | 37 | 38 | template _UCXXEXPORT basic_ostream& 39 | operator<<(basic_ostream& os, const basic_string& str) 40 | { 41 | return os.write(str.data(), str.length()); 42 | } 43 | 44 | template _UCXXEXPORT basic_istream& 45 | operator>>(basic_istream& is, basic_string& str) 46 | { 47 | 48 | typename basic_istream::sentry s(is); 49 | if(s == false){ 50 | return is; 51 | } 52 | 53 | str.clear(); 54 | 55 | typename basic_istream::int_type c; 56 | typename Allocator::size_type n = is.width(); 57 | bool exitnow = false; 58 | if(n == 0){ 59 | n = str.max_size(); 60 | } 61 | 62 | // //Clear out preliminary spaces first 63 | // c = is.get(); 64 | // while(isspace(c)){ 65 | // c = is.get(); 66 | // } 67 | // 68 | // is.putback(c); 69 | 70 | do{ 71 | c = is.get(); 72 | if(c == traits::eof() || isspace(c) || n == 0){ 73 | is.putback(c); 74 | exitnow = true; 75 | }else{ 76 | str.append(1, traits::to_char_type(c) ); 77 | --n; 78 | } 79 | }while(exitnow == false); 80 | return is; 81 | } 82 | 83 | template _UCXXEXPORT basic_istream& 84 | getline(basic_istream& is, basic_string& str, charT delim) 85 | { 86 | typename basic_istream::sentry s(is); 87 | if(s == false){ 88 | return is; 89 | } 90 | 91 | str.erase(); 92 | 93 | streamsize i = 0; 94 | typename basic_istream::int_type c_i; 95 | charT c; 96 | unsigned int n = str.max_size(); 97 | for(i=0;i _UCXXEXPORT basic_istream& 112 | getline(basic_istream& is, basic_string& str) 113 | { 114 | return getline(is, str, '\n'); 115 | } 116 | 117 | 118 | #ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ 119 | #ifndef __UCLIBCXX_COMPILE_STRING__ 120 | 121 | 122 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 123 | template<> _UCXXEXPORT basic_istream >& operator>>( 124 | basic_istream >& is, 125 | basic_string, allocator >& str); 126 | #endif 127 | 128 | 129 | #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 130 | template<> _UCXXEXPORT basic_ostream >& 131 | operator<<(basic_ostream >& os, 132 | const basic_string, std::allocator >& str); 133 | 134 | #endif 135 | 136 | 137 | #endif 138 | #endif 139 | 140 | 141 | } 142 | 143 | #pragma GCC visibility pop 144 | 145 | #endif 146 | 147 | -------------------------------------------------------------------------------- /support: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef HEADER_ULC_SUPPORT 25 | #define HEADER_ULC_SUPPORT 1 26 | 27 | using namespace std; 28 | 29 | //From C++ ABI spec 30 | typedef enum { 31 | _URC_NO_REASON = 0, 32 | _URC_FOREIGN_EXCEPTION_CAUGHT = 1, 33 | _URC_FATAL_PHASE2_ERROR = 2, 34 | _URC_FATAL_PHASE1_ERROR = 3, 35 | _URC_NORMAL_STOP = 4, 36 | _URC_END_OF_STACK = 5, 37 | _URC_HANDLER_FOUND = 6, 38 | _URC_INSTALL_CONTEXT = 7, 39 | _URC_CONTINUE_UNWIND = 8 40 | } _Unwind_Reason_Code; 41 | 42 | 43 | typedef void (*_Unwind_Exception_Cleanup_Fn) 44 | (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc); 45 | 46 | //The following definitions were grabbed from the gcc implementation 47 | typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); 48 | typedef unsigned _Unwind_Word __attribute__((__mode__(__word__))); 49 | typedef signed _Unwind_Sword __attribute__((__mode__(__word__))); 50 | typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); 51 | typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, struct _Unwind_Exception *); 52 | 53 | typedef int _Unwind_Action; 54 | static const _Unwind_Action _UA_SEARCH_PHASE = 1; 55 | static const _Unwind_Action _UA_CLEANUP_PHASE = 2; 56 | static const _Unwind_Action _UA_HANDLER_FRAME = 4; 57 | static const _Unwind_Action _UA_FORCE_UNWIND = 8; 58 | 59 | const _Unwind_Exception_Class __uclibcxx_exception_class = (((((((( 60 | _Unwind_Exception_Class) 'u' << 8 | (_Unwind_Exception_Class) 'l') << 8 61 | | (_Unwind_Exception_Class) 'i') << 8 | (_Unwind_Exception_Class) 'b') << 8 62 | | (_Unwind_Exception_Class) 'C')<< 8 | (_Unwind_Exception_Class) '+') << 8 63 | | (_Unwind_Exception_Class) '+') << 8 | (_Unwind_Exception_Class) '\0'); 64 | 65 | 66 | #define _UA_SEARCH_PHASE 1 67 | #define _UA_CLEANUP_PHASE 2 68 | #define _UA_HANDLER_FRAME 4 69 | #define _UA_FORCE_UNWIND 8 70 | #define _UA_END_OF_STACK 16 71 | 72 | struct _Unwind_Exception{ 73 | _Unwind_Exception_Class exception_class; //Type of exception, eg ulibC++\0 74 | _Unwind_Exception_Cleanup_Fn exception_cleanup; //Destructor if from diff runtime 75 | _Unwind_Word private_1; //Don't touch at all! 76 | _Unwind_Word private_2; //Don't touch at all! 77 | } __attribute__((__aligned__)); 78 | 79 | 80 | //The following structure is system-dependent and defined by the compiler 81 | //Thus it's definition was copied from the gcc 3.4.0 header files 82 | struct _Unwind_Context; 83 | //{ 84 | // void *reg[DWARF_FRAME_REGISTERS+1]; 85 | // void *cfa; 86 | // void *ra; 87 | // void *lsda; 88 | // struct dwarf_eh_bases bases; 89 | // _Unwind_Word args_size; 90 | //}; 91 | 92 | 93 | 94 | _Unwind_Reason_Code _Unwind_RaiseException ( struct _Unwind_Exception *exception_object ); 95 | 96 | //_Unwind_ForcedUnwind 97 | 98 | typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) 99 | (int version, _Unwind_Action actions, _Unwind_Exception_Class exceptionClass, 100 | struct _Unwind_Exception *exceptionObject, 101 | struct _Unwind_Context *context, void *stop_parameter ); 102 | 103 | _Unwind_Reason_Code _Unwind_ForcedUnwind ( 104 | struct _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, 105 | void *stop_parameter ); 106 | 107 | void _Unwind_Resume (struct _Unwind_Exception *exception_object); 108 | void _Unwind_DeleteException (struct _Unwind_Exception *exception_object); 109 | 110 | _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *context, int index); 111 | void _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word); 112 | 113 | _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *context); 114 | void _Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr new_value); 115 | 116 | _Unwind_Ptr _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context); 117 | _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *context); 118 | 119 | _Unwind_Reason_Code (*__personality_routine) 120 | (int version, //Should be 1 121 | _Unwind_Action actions, //Actions the routine will perform (bitmask) 122 | _Unwind_Exception_Class exceptionClass, //Type of exception - vendor is high 4 bytes 123 | struct _Unwind_Exception *exceptionObject, //Points to exception header 124 | struct _Unwind_Context *context); //Unwinder state information 125 | 126 | 127 | /*The following part is the Level II ABI which is required for compatability*/ 128 | //This might be the only stuff that *I* need to implement 129 | 130 | struct __cxa_exception { 131 | std::type_info *exceptionType; //Type of thrown exception 132 | void (*exceptionDestructor) (void *); //Pointer to the destructor 133 | unexpected_handler unexpectedHandler; //Unexpected handler to use 134 | terminate_handler terminateHandler; //Terminate handle to use 135 | __cxa_exception *nextException; //per thread linked list 136 | 137 | int handlerCount; //How many handlers have caught this 138 | int handlerSwitchValue; 139 | const char *actionRecord; 140 | const char *languageSpecificData; 141 | void *catchTemp; 142 | void *adjustedPtr; 143 | 144 | _Unwind_Exception unwindHeader; 145 | }; 146 | 147 | struct __cxa_eh_globals { 148 | __cxa_exception *caughtExceptions; 149 | unsigned int uncaughtExceptions; 150 | }; 151 | 152 | extern "C" __cxa_eh_globals *__cxa_get_globals(void); //Return ptr to the eh_globals object for current thread 153 | extern "C" __cxa_eh_globals *__cxa_get_globals_fast(void); //Same as above, assumes that above called at least once 154 | 155 | extern "C" void *__cxa_allocate_exception(size_t thrown_size); //Allocate space for exception plus header 156 | extern "C" void __cxa_free_exception(void *thrown_exception); //Free space allocated from the above 157 | 158 | extern "C" void __cxa_throw (void *thrown_exception, //This is the actual throw call 159 | // std::type_info *tinfo, //Type of object 160 | void * tinfo, //Type of object 161 | void (*dest) (void *) ); //Pointer to destructor destroy object 162 | 163 | 164 | #endif 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /support.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #if 0 23 | extern "C" void *__cxa_allocate_exception(size_t thrown_size){ 24 | void * retval; 25 | 26 | /*The amount of data needed is the size of the object *PLUS* 27 | the size of the header. The header is of struct __cxa_exception 28 | The address needs to be adjusted because the pointer we return 29 | should not point to the start of the memory, but to the point 30 | where the object being thrown actually starts*/ 31 | 32 | retval = malloc(thrown_size + sizeof(__cxa_exception)); 33 | 34 | // Check to see that we actuall allocated memory 35 | if(retval == 0){ 36 | std::terminate(); 37 | } 38 | 39 | //Need to do a typecast to char* otherwize we are doing math with 40 | //a void* which makes the compiler cranky (Like me) 41 | return ((char *)retval + sizeof(__cxa_exception)); 42 | } 43 | 44 | extern "C" void __cxa_free_exception(void *thrown_exception){ 45 | 46 | 47 | 48 | } 49 | 50 | extern "C" void __cxa_throw (void *thrown_exception, std::type_info *tinfo,void (*dest) (void *) ){ 51 | 52 | 53 | } 54 | #endif // 0 55 | -------------------------------------------------------------------------------- /system_configuration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Automatically generated C config: don't edit 3 | */ 4 | /* 5 | * Version Number 6 | */ 7 | #define __UCLIBCXX_MAJOR__ 0 8 | #define __UCLIBCXX_MINOR__ 2 9 | #define __UCLIBCXX_SUBLEVEL__ 3 10 | 11 | /* 12 | * Target Features and Options 13 | */ 14 | #define __UCLIBCXX_HAS_FLOATS__ 15 | #undef __UCLIBCXX_HAS_TLS__ 16 | #define __WARNINGS__ "-Wall" 17 | #define __BUILD_EXTRA_LIBRARIES__ "" 18 | #define __HAVE_DOT_CONFIG__ 1 19 | 20 | /* 21 | * String and I/O Stream Support 22 | */ 23 | #undef __UCLIBCXX_HAS_WCHAR__ 24 | #define __UCLIBCXX_IOSTREAM_BUFSIZE__ 32 25 | #undef __UCLIBCXX_HAS_LFS__ 26 | #undef __UCLIBCXX_SUPPORT_CDIR__ 27 | #define __UCLIBCXX_SUPPORT_COUT__ 28 | #define __UCLIBCXX_SUPPORT_CERR__ 29 | /* 30 | * STL and Code Expansion 31 | */ 32 | //#define __UCLIBCXX_STL_BUFFER_SIZE__ 32 33 | #define __UCLIBCXX_STL_BUFFER_SIZE__ 8 34 | #undef __UCLIBCXX_CODE_EXPANSION__ 35 | 36 | /* 37 | * Library Installation Options 38 | */ 39 | #define __UCLIBCXX_RUNTIME_PREFIX__ "/usr/uClibc++" 40 | #define __UCLIBCXX_RUNTIME_INCLUDE_SUBDIR__ "/include" 41 | #define __UCLIBCXX_RUNTIME_LIB_SUBDIR__ "/lib" 42 | #define __UCLIBCXX_RUNTIME_BIN_SUBDIR__ "/bin" 43 | #undef __UCLIBCXX_EXCEPTION_SUPPORT__ 44 | #define __BUILD_STATIC_LIB__ 1 45 | #define __BUILD_ONLY_STATIC_LIB__ 1 46 | #undef __DODEBUG__ 47 | -------------------------------------------------------------------------------- /type_traits: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #ifndef __HEADER_TYPE_TRAITS 26 | #define __HEADER_TYPE_TRAITS 1 27 | 28 | #pragma GCC visibility push(default) 29 | 30 | namespace std{ 31 | 32 | struct _UCXXEXPORT __true_type{}; 33 | struct _UCXXEXPORT __false_type{}; 34 | 35 | template class _UCXXEXPORT __is_integer{ 36 | public: 37 | typedef __false_type value; 38 | }; 39 | 40 | template <> class _UCXXEXPORT __is_integer { 41 | public: 42 | typedef __true_type value; 43 | }; 44 | 45 | template <> class _UCXXEXPORT __is_integer { 46 | public: 47 | typedef __true_type value; 48 | }; 49 | 50 | template <> class _UCXXEXPORT __is_integer { 51 | public: 52 | typedef __true_type value; 53 | }; 54 | 55 | template <> class _UCXXEXPORT __is_integer { 56 | public: 57 | typedef __true_type value; 58 | }; 59 | 60 | template <> class _UCXXEXPORT __is_integer { 61 | public: 62 | typedef __true_type value; 63 | }; 64 | 65 | template <> class _UCXXEXPORT __is_integer { 66 | public: 67 | typedef __true_type value; 68 | }; 69 | 70 | template <> class _UCXXEXPORT __is_integer { 71 | public: 72 | typedef __true_type value; 73 | }; 74 | 75 | template <> class _UCXXEXPORT __is_integer { 76 | public: 77 | typedef __true_type value; 78 | }; 79 | 80 | template <> class _UCXXEXPORT __is_integer { 81 | public: 82 | typedef __true_type value; 83 | }; 84 | 85 | 86 | 87 | } 88 | 89 | #pragma GCC visibility pop 90 | 91 | #endif 92 | 93 | -------------------------------------------------------------------------------- /typeinfo: -------------------------------------------------------------------------------- 1 | // RTTI support for -*- C++ -*- 2 | // Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 3 | // Free Software Foundation 4 | // 5 | // This file is part of GNU CC. 6 | // 7 | // GNU CC is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 2, or (at your option) 10 | // any later version. 11 | // 12 | // GNU CC is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with GNU CC; see the file COPYING. If not, write to 19 | // the Free Software Foundation, 59 Temple Place - Suite 330, 20 | // Boston, MA 02111-1307, USA. 21 | 22 | // As a special exception, you may use this file as part of a free software 23 | // library without restriction. Specifically, if other files instantiate 24 | // templates or use macros or inline functions from this file, or you compile 25 | // this file and link it with other files to produce an executable, this 26 | // file does not by itself cause the resulting executable to be covered by 27 | // the GNU General Public License. This exception does not however 28 | // invalidate any other reasons why the executable file might be covered by 29 | // the GNU General Public License. 30 | 31 | /** @file typeinfo 32 | * This header provides RTTI support. 33 | */ 34 | 35 | #ifndef __TYPEINFO__ 36 | #define __TYPEINFO__ 37 | 38 | #include 39 | 40 | extern "C++" { 41 | 42 | namespace __cxxabiv1 43 | { 44 | class __class_type_info; 45 | } // namespace __cxxabiv1 46 | 47 | #if !__GXX_WEAK__ 48 | // If weak symbols are not supported, typeinfo names are not merged. 49 | #define __GXX_MERGED_TYPEINFO_NAMES 0 50 | #else 51 | // On platforms that support weak symbols, typeinfo names are merged. 52 | #define __GXX_MERGED_TYPEINFO_NAMES 1 53 | #endif 54 | 55 | namespace std 56 | { 57 | /** 58 | * @brief Part of RTTI. 59 | * 60 | * The @c type_info class describes type information generated by 61 | * an implementation. 62 | */ 63 | class type_info 64 | { 65 | public: 66 | /** Destructor. Being the first non-inline virtual function, this 67 | * controls in which translation unit the vtable is emitted. The 68 | * compiler makes use of that information to know where to emit 69 | * the runtime-mandated type_info structures in the new-abi. */ 70 | virtual ~type_info(); 71 | 72 | private: 73 | /// Assigning type_info is not supported. Made private. 74 | type_info& operator=(const type_info&); 75 | type_info(const type_info&); 76 | 77 | protected: 78 | const char *__name; 79 | 80 | protected: 81 | explicit type_info(const char *__n): __name(__n) { } 82 | 83 | public: 84 | // the public interface 85 | /** Returns an @e implementation-defined byte string; this is not 86 | * portable between compilers! */ 87 | const char* name() const 88 | { return __name; } 89 | 90 | #if !__GXX_MERGED_TYPEINFO_NAMES 91 | bool before(const type_info& __arg) const; 92 | // In old abi, or when weak symbols are not supported, there can 93 | // be multiple instances of a type_info object for one 94 | // type. Uniqueness must use the _name value, not object address. 95 | bool operator==(const type_info& __arg) const; 96 | #else 97 | /** Returns true if @c *this precedes @c __arg in the implementation's 98 | * collation order. */ 99 | // In new abi we can rely on type_info's NTBS being unique, 100 | // and therefore address comparisons are sufficient. 101 | bool before(const type_info& __arg) const 102 | { return __name < __arg.__name; } 103 | bool operator==(const type_info& __arg) const 104 | { return __name == __arg.__name; } 105 | #endif 106 | bool operator!=(const type_info& __arg) const 107 | { return !operator==(__arg); } 108 | 109 | // the internal interface 110 | public: 111 | // return true if this is a pointer type of some kind 112 | virtual bool __is_pointer_p() const; 113 | // return true if this is a function type 114 | virtual bool __is_function_p() const; 115 | 116 | // Try and catch a thrown type. Store an adjusted pointer to the 117 | // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then 118 | // THR_OBJ points to the thrown object. If THR_TYPE is a pointer 119 | // type, then THR_OBJ is the pointer itself. OUTER indicates the 120 | // number of outer pointers, and whether they were const 121 | // qualified. 122 | virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, 123 | unsigned __outer) const; 124 | 125 | // internally used during catch matching 126 | virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, 127 | void **__obj_ptr) const; 128 | }; 129 | 130 | /** 131 | * @brief Thrown during incorrect typecasting. 132 | * 133 | * If you attempt an invalid @c dynamic_cast expression, an instance of 134 | * this class (or something derived from this class) is thrown. */ 135 | class bad_cast : public exception 136 | { 137 | public: 138 | bad_cast() throw() { } 139 | // This declaration is not useless: 140 | // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 141 | virtual ~bad_cast() throw(); 142 | }; 143 | 144 | /** If you use a NULL pointer in a @c typeid expression, this is thrown. */ 145 | class bad_typeid : public exception 146 | { 147 | public: 148 | bad_typeid () throw() { } 149 | // This declaration is not useless: 150 | // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 151 | virtual ~bad_typeid() throw(); 152 | }; 153 | } // namespace std 154 | 155 | } // extern "C++" 156 | #endif 157 | -------------------------------------------------------------------------------- /typeinfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | _UCXXEXPORT bad_cast::~bad_cast() throw(){ 25 | 26 | } 27 | 28 | _UCXXEXPORT bad_typeid::~bad_typeid() throw(){ 29 | 30 | } 31 | 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /uartbuf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maniacbug/StandardCplusplus/c94ef6749202f0853ca3ceeeb60f2f83c1ba74e5/uartbuf -------------------------------------------------------------------------------- /utility.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | 21 | #include 22 | 23 | 24 | namespace std{ 25 | 26 | 27 | 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /utility.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | */ 19 | 20 | 21 | #include 22 | 23 | 24 | #ifndef __STD_HEADER_UTILITY 25 | #define __STD_HEADER_UTILITY 1 26 | 27 | #pragma GCC visibility push(default) 28 | 29 | namespace std{ 30 | 31 | namespace rel_ops { 32 | template inline bool operator!=(const T& x, const T& y){ 33 | return !(x == y); 34 | } 35 | 36 | template inline bool operator> (const T& x, const T& y){ 37 | return ( y < x); 38 | } 39 | 40 | template inline bool operator<=(const T& x, const T& y){ 41 | return !( y < x ); 42 | } 43 | 44 | template inline bool operator>=(const T& x, const T& y){ 45 | return !(x < y); 46 | } 47 | } 48 | 49 | template struct _UCXXEXPORT pair { 50 | typedef T1 first_type; 51 | typedef T2 second_type; 52 | 53 | T1 first; 54 | T2 second; 55 | pair() : first(), second() { } 56 | pair(const T1& x, const T2& y) : first(x), second(y) { } 57 | template pair(const pair &p) : first(p.first), second(p.second) { } 58 | }; 59 | 60 | template bool operator==(const pair& x, const pair& y){ 61 | using namespace rel_ops; 62 | return (x.first == y.first && x.second==y.second); 63 | } 64 | template bool operator< (const pair& x, const pair& y){ 65 | return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 66 | } 67 | template bool operator!=(const pair& x, const pair& y){ 68 | return !(x == y); 69 | } 70 | template bool operator> (const pair& x, const pair& y){ 71 | return y < x; 72 | } 73 | template bool operator>=(const pair& x, const pair& y){ 74 | return !(x < y); 75 | } 76 | template bool operator<=(const pair& x, const pair& y){ 77 | return !(y < x); 78 | } 79 | template pair make_pair(const T1& x, const T2& y){ 80 | return pair(x, y); 81 | } 82 | 83 | 84 | } 85 | 86 | #pragma GCC visibility pop 87 | 88 | #endif //__STD_HEADER_UTILITY 89 | -------------------------------------------------------------------------------- /valarray.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /vector.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #define __UCLIBCXX_COMPILE_VECTOR__ 1 21 | 22 | 23 | #include 24 | 25 | namespace std{ 26 | 27 | 28 | #ifdef __UCLIBCXX_EXPAND_VECTOR_BASIC__ 29 | 30 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 31 | 32 | template _UCXXEXPORT vector >::vector(const allocator& al); 33 | template _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); 34 | 35 | template _UCXXEXPORT vector >::~vector(); 36 | template _UCXXEXPORT vector >::~vector(); 37 | 38 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 39 | 40 | template _UCXXEXPORT void vector >::reserve(size_type n); 41 | template _UCXXEXPORT void vector >::reserve(size_type n); 42 | template _UCXXEXPORT void vector >::reserve(size_type n); 43 | template _UCXXEXPORT void vector >::reserve(size_type n); 44 | template _UCXXEXPORT void vector >::reserve(size_type n); 45 | template _UCXXEXPORT void vector >::reserve(size_type n); 46 | template _UCXXEXPORT void vector >::reserve(size_type n); 47 | template _UCXXEXPORT void vector >::reserve(size_type n); 48 | template _UCXXEXPORT void vector >::reserve(size_type n); 49 | template _UCXXEXPORT void vector >::reserve(size_type n); 50 | template _UCXXEXPORT void vector >::reserve(size_type n); 51 | 52 | template _UCXXEXPORT void vector >::resize(size_type sz, const char & c); 53 | template _UCXXEXPORT void vector >::resize(size_type sz, const unsigned char & c); 54 | template _UCXXEXPORT void vector >::resize(size_type sz, const short & c); 55 | template _UCXXEXPORT void vector > 56 | ::resize(size_type sz, const unsigned short int & c); 57 | template _UCXXEXPORT void vector >::resize(size_type sz, const int & c); 58 | template _UCXXEXPORT void vector >::resize(size_type sz, const unsigned int & c); 59 | template _UCXXEXPORT void vector >::resize(size_type sz, const long int & c); 60 | template _UCXXEXPORT void vector >:: 61 | resize(size_type sz, const unsigned long int & c); 62 | template _UCXXEXPORT void vector >::resize(size_type sz, const float & c); 63 | template _UCXXEXPORT void vector >::resize(size_type sz, const double & c); 64 | template _UCXXEXPORT void vector >::resize(size_type sz, const bool & c); 65 | 66 | #elif defined __UCLIBCXX_EXPAND_STRING_CHAR__ 67 | 68 | 69 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 70 | template _UCXXEXPORT vector >::vector(const allocator& al); 71 | template _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); 72 | template _UCXXEXPORT vector >::~vector(); 73 | #endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 74 | 75 | template _UCXXEXPORT void vector >::reserve(size_type n); 76 | template _UCXXEXPORT void vector >::resize(size_type sz, const char & c); 77 | 78 | #endif 79 | 80 | 81 | 82 | 83 | } 84 | --------------------------------------------------------------------------------