├── src ├── cinttypes ├── abi │ ├── libgcc_eh │ │ ├── Makefile │ │ └── Makefile.in │ ├── libsupc │ │ ├── Makefile │ │ └── Makefile.in │ └── abi.cpp ├── cstdint ├── cerrno ├── cassert ├── limits.cpp ├── bitset.cpp ├── numeric.cpp ├── queue.cpp ├── stack.cpp ├── iterator.cpp ├── list.cpp ├── associative_base.cpp ├── iomanip.cpp ├── utility.cpp ├── valarray.cpp ├── algorithm.cpp ├── map.cpp ├── set.cpp ├── climits ├── complex.cpp ├── cfloat ├── locale.cpp ├── deque.cpp ├── clocale ├── del_opnt.cpp ├── del_opvnt.cpp ├── del_ops.cpp ├── typeinfo.cpp ├── del_opvs.cpp ├── new_opnt.cpp ├── new_opvnt.cpp ├── del_op.cpp ├── del_opv.cpp ├── cctype ├── new_handler.cpp ├── ArduinoSTL.h ├── csetjmp ├── iostream.cpp ├── system_configuration.h ├── new_opv.cpp ├── new_op.cpp ├── eh_globals.cpp ├── func_exception ├── initializer_list ├── exception.cpp ├── streambuf.cpp ├── stdexcept.cpp ├── cstdlib ├── support.cpp ├── char_traits.cpp ├── array ├── ostream_helpers.cpp ├── cstdio ├── cwchar ├── cstring ├── cstddef ├── locale ├── func_exception.cpp ├── cstdarg ├── csignal ├── eh_alloc.cpp ├── basic_definitions ├── type_traits ├── ArduinoSTL.cpp ├── sstream.cpp ├── ctime ├── istream.cpp ├── new ├── stack ├── ostream.cpp ├── utility ├── iostream ├── cwctype ├── stdexcept ├── string_iostream ├── queue ├── iomanip ├── vector.cpp ├── iosfwd ├── numeric ├── exception ├── string.cpp ├── ios.cpp ├── memory ├── char_traits ├── cmath ├── typeinfo ├── support └── iterator ├── keywords.txt ├── library.properties ├── .gitignore ├── .github ├── dependabot.yml └── workflows │ └── sync-labels.yml └── README.md /src/cinttypes: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | cin KEYWORD1 2 | cout KEYWORD1 3 | printf KEYWORD1 4 | scanf KEYWORD1 5 | -------------------------------------------------------------------------------- /src/abi/libgcc_eh/Makefile: -------------------------------------------------------------------------------- 1 | top_srcdir=../../../ 2 | top_builddir=../../../ 3 | include $(top_srcdir)Rules.mak 4 | include Makefile.in 5 | -------------------------------------------------------------------------------- /src/abi/libsupc/Makefile: -------------------------------------------------------------------------------- 1 | top_srcdir=../../../ 2 | top_builddir=../../../ 3 | include $(top_srcdir)Rules.mak 4 | include Makefile.in 5 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=ArduinoSTL 2 | version=1.3.3 3 | author=Mike Matera , Chris Johnson , Arduino 4 | maintainer=Mike Matera 5 | sentence=A port of uClibc++ Arduino library. 6 | paragraph=This library includes important C++ functions, including cout and cin, printf and scanf. It also includes STL containers like vector and algorithm. 7 | category=Other 8 | url=https://github.com/mike-matera/ArduinoSTL 9 | architectures=avr,megaavr 10 | includes=ArduinoSTL.h 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Never ignore these 3 | # 4 | !.gitignore 5 | 6 | # 7 | # Generated files 8 | # 9 | *.a 10 | *.i 11 | *.o 12 | *.depend 13 | .config* 14 | .*.dep 15 | /*.log 16 | cscope.* 17 | bin/g++-uc 18 | bin/env_check 19 | libuClibc++*.so 20 | libuClibc++*.so.0 21 | include/system_configuration.h 22 | include/bits/ 23 | 24 | # 25 | # Debugging files 26 | # 27 | .gdb_history 28 | .gdbinit 29 | core 30 | 31 | # 32 | # Backups / patches 33 | # 34 | *~ 35 | *.orig 36 | *.rej 37 | /*.patch 38 | /*.diff 39 | 40 | # 41 | # Editors 42 | # 43 | 44 | .vs 45 | .vscode 46 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file 2 | version: 2 3 | 4 | updates: 5 | # Configure check for outdated GitHub Actions actions in workflows. 6 | # See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot 7 | - package-ecosystem: github-actions 8 | directory: / # Check the repository's workflows under /.github/workflows/ 9 | labels: 10 | - "topic: infrastructure" 11 | schedule: 12 | interval: daily 13 | -------------------------------------------------------------------------------- /src/cstdint: -------------------------------------------------------------------------------- 1 | #ifndef _CPP_CSTDINT 2 | #define _CPP_CSTDINT 1 3 | 4 | #ifdef __GCC__ 5 | #pragma GCC system_header 6 | #endif 7 | 8 | #include 9 | 10 | namespace std { 11 | 12 | using :: int8_t; using :: int16_t; 13 | using :: int32_t; using :: int64_t; 14 | using :: uint8_t; using :: uint16_t; 15 | using :: uint32_t; using :: uint64_t; 16 | 17 | using :: int_least8_t; using :: int_least16_t; 18 | using :: int_least32_t; using :: int_least64_t; 19 | using :: uint_least8_t; using :: uint_least16_t; 20 | using :: uint_least32_t; using :: uint_least64_t; 21 | 22 | using :: int_fast8_t; using :: int_fast16_t; 23 | using :: int_fast32_t; using :: int_fast64_t; 24 | using :: uint_fast8_t; using :: uint_fast16_t; 25 | using :: uint_fast32_t; using :: uint_fast64_t; 26 | 27 | using :: intmax_t; using :: intptr_t; 28 | using :: uintmax_t; using :: uintptr_t; 29 | 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/abi/libgcc_eh/Makefile.in: -------------------------------------------------------------------------------- 1 | LIBGCC_EH_OUT := $(top_builddir)src/abi/libgcc_eh/ 2 | 3 | OBJS = $(call list-archive-members,$(LIBGCC_EH)) 4 | libgcc_eh-$(IMPORT_LIBGCC_EH) := $(OBJS) 5 | 6 | LIBGCC_EH_VAR := $(call variablify,$(LIBGCC_EH)) 7 | LIBGCC_EH_DEP := $(LIBGCC_EH_OUT).$(call print-hash,$(LIBGCC_EH_VAR)).dep 8 | 9 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) 10 | -include $(LIBGCC_EH_DEP) 11 | endif 12 | 13 | 14 | ifneq ($(libgcc_eh-y),) 15 | $(libgcc_eh-y): $(LIBGCC_EH) 16 | endif 17 | $(LIBGCC_EH_DEP): $(LIBGCC_EH) 18 | $(Q)$(RM) $(LIBGCC_EH_OUT).*dep $(LIBGCC_EH_OUT)*.o 19 | $(Q)$(if $(LIBGCC_EH),(cd $(LIBGCC_EH_OUT) && $(AR) x $(LIBGCC_EH))) 20 | $(Q)printf "# %s\n\n%s\n" "$(LIBGCC_EH)" "libgcc_eh-y := \$$(addprefix \$$(LIBGCC_EH_OUT),$(libgcc_eh-y))" > $@ 21 | 22 | CLEAN_src/abi/libgcc_eh: ; 23 | DISTCLEAN_src/abi/libgcc_eh: 24 | $(do_rm) $(addprefix $(LIBGCC_EH_OUT),.*dep *.o) 25 | -------------------------------------------------------------------------------- /src/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 "limits" 21 | 22 | namespace std{ 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/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 "bitset" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/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 "numeric" 21 | 22 | namespace std{ 23 | 24 | 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/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 "queue" 20 | 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/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 "stack" 20 | 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/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 "iterator" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/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 "list" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/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 "associative_base" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/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 "iomanip" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/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 "utility" 22 | 23 | 24 | namespace std{ 25 | 26 | 27 | 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/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 "valarray" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/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 "algorithm" 22 | 23 | 24 | namespace std{ 25 | 26 | 27 | 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/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 "map" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/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 "set" 21 | 22 | namespace std{ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/abi/libsupc/Makefile.in: -------------------------------------------------------------------------------- 1 | LIBSUPC_OUT := $(top_builddir)src/abi/libsupc/ 2 | 3 | OBJS = $(call list-archive-members,$(LIBSUP)) 4 | OBJS-OMIT = $(filter new_op%.o del_op%.o pure.o new_handler.o eh_alloc.o eh_globals.o,$(OBJS)) 5 | libsupc-$(IMPORT_LIBSUP) := $(filter-out $(OBJS-OMIT),$(OBJS)) 6 | 7 | LIBSUP_VAR := $(call variablify,$(LIBSUP)) 8 | LIBSUP_DEP := $(LIBSUPC_OUT).$(call print-hash,$(LIBSUP_VAR)).dep 9 | 10 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) 11 | -include $(LIBSUP_DEP) 12 | endif 13 | 14 | ifneq ($(libsupc-y),) 15 | $(libsupc-y): $(LIBSUP) 16 | endif 17 | $(LIBSUP_DEP): $(LIBSUP) $(LIBSUPC_OUT)Makefile.in 18 | $(Q)$(RM) $(LIBSUPC_OUT).*dep $(LIBSUPC_OUT)*.o 19 | $(Q)$(if $(LIBSUP),(cd $(LIBSUPC_OUT) && $(AR) x $(LIBSUP) && $(RM) $(OBJS-OMIT))) 20 | $(Q)printf "# %s\n\n%s\n" "$(LIBSUP)" "libsupc-y := \$$(addprefix \$$(LIBSUPC_OUT),$(libsupc-y))" > $@ 21 | 22 | CLEAN_src/abi/libsupc: ; 23 | DISTCLEAN_src/abi/libsupc: 24 | $(do_rm) $(addprefix $(LIBSUPC_OUT), .*dep *.o) 25 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "complex" 20 | 21 | 22 | namespace std{ 23 | 24 | 25 | template class _UCXXEXPORT complex; 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "locale" 21 | #include "cstring" 22 | #include "string" 23 | #include "stdexcept" 24 | #include "cctype" 25 | 26 | namespace std{ 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/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 "deque" 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "new" 21 | #include "cstdlib" 22 | #include "func_exception" 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT { 26 | free(ptr); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/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 "new" 21 | #include "cstdlib" 22 | #include "func_exception" 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{ 26 | free(ptr); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/del_ops.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2015 Bernhard Reutner-Fischer 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 | /* C++14 sized deallocation */ 20 | 21 | #include "new" 22 | #include "cstdlib" 23 | #include "func_exception" 24 | 25 | _UCXXEXPORT void operator delete(void* ptr, std::size_t) _UCXX_USE_NOEXCEPT{ 26 | ::operator delete (ptr); 27 | } 28 | -------------------------------------------------------------------------------- /src/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 "typeinfo" 21 | 22 | namespace std{ 23 | 24 | _UCXXEXPORT bad_cast::~bad_cast() _UCXX_USE_NOEXCEPT{ 25 | 26 | } 27 | 28 | _UCXXEXPORT bad_typeid::~bad_typeid() _UCXX_USE_NOEXCEPT{ 29 | 30 | } 31 | 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/del_opvs.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2015 Bernhard Reutner-Fischer 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 | /* C++14 sized deallocation */ 20 | 21 | #include "new" 22 | #include "cstdlib" 23 | #include "func_exception" 24 | 25 | _UCXXEXPORT void operator delete[](void * ptr, std::size_t) _UCXX_USE_NOEXCEPT{ 26 | ::operator delete[] (ptr); 27 | } 28 | -------------------------------------------------------------------------------- /src/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 "new" 21 | #include "cstdlib" 22 | #include "func_exception" 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{ 26 | return malloc(numBytes); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/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 "new" 21 | #include "cstdlib" 22 | #include "func_exception" 23 | 24 | #ifndef NO_NOTHROW 25 | _UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{ 26 | return malloc(numBytes); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/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 ARDUINO < 100 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | _UCXXEXPORT void operator delete(void* ptr) _UCXX_USE_NOEXCEPT{ 28 | free(ptr); 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/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 | 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 delete[](void * ptr) _UCXX_USE_NOEXCEPT{ 28 | free(ptr); 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "new" 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) _UCXX_USE_NOEXCEPT{ 28 | std::new_handler retval = __new_handler; 29 | __new_handler = new_p; 30 | return retval; 31 | } 32 | -------------------------------------------------------------------------------- /src/ArduinoSTL.h: -------------------------------------------------------------------------------- 1 | /*--------------------- 2 | * 3 | * ArduinoSTL Core Library 4 | * 5 | * This header has some glue to make STL and Streams work from a sketch. 6 | * 7 | */ 8 | 9 | #ifndef ARDUINOSTL_M_H 10 | #define ARDUINOSTL_M_H 11 | 12 | #include 13 | #include "serstream" 14 | 15 | // Create cout and cin.. there doesn't seem to be a way 16 | // to control what serial device at runtime. Grr. 17 | namespace std 18 | { 19 | extern ohserialstream cout; 20 | extern ihserialstream cin; 21 | } 22 | 23 | #if defined(ARDUINO_ARCH_AVR) 24 | 25 | class ArduinoSTL_STDIO { 26 | public: 27 | // Initialize STDIO using a pointer to whatever Serial is. 28 | // Serial.begin() must be called at some point. 29 | ArduinoSTL_STDIO(Stream *u) : file(NULL) { 30 | connect(u); 31 | } 32 | 33 | ArduinoSTL_STDIO(Stream &u) : file(NULL) { 34 | connect(u); 35 | } 36 | 37 | Stream *getUart() { 38 | return uart; 39 | } 40 | 41 | void connect(Stream *u); 42 | 43 | inline void connect(Stream &u) { 44 | connect(static_cast(&u)); 45 | } 46 | 47 | private: 48 | Stream *uart; 49 | FILE *file; 50 | }; 51 | 52 | extern ArduinoSTL_STDIO ArduinoSTL_Serial; 53 | 54 | #endif // ARDUINO_ARCH_AVR 55 | 56 | #endif // ARDUINOSTL_M_H 57 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "iostream" 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 | -------------------------------------------------------------------------------- /src/system_configuration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration for Arduino's compiler. 3 | * >>> This is a guess <<< 4 | */ 5 | /* 6 | * Version Number 7 | */ 8 | #define __UCLIBCXX_MAJOR__ 0 9 | #define __UCLIBCXX_MINOR__ 2 10 | #define __UCLIBCXX_SUBLEVEL__ 4 11 | 12 | /* 13 | * Target Features and Options 14 | */ 15 | #define __UCLIBCXX_HAS_FLOATS__ 16 | #undef __UCLIBCXX_HAS_TLS__ 17 | #define __WARNINGS__ "-Wall" 18 | #define __BUILD_EXTRA_LIBRARIES__ "" 19 | #define __HAVE_DOT_CONFIG__ 1 20 | 21 | /* 22 | * String and I/O Stream Support 23 | */ 24 | #undef __UCLIBCXX_HAS_WCHAR__ 25 | #define __UCLIBCXX_IOSTREAM_BUFSIZE__ 32 26 | #undef __UCLIBCXX_HAS_LFS__ 27 | #undef __UCLIBCXX_SUPPORT_CDIR__ 28 | #undef __UCLIBCXX_SUPPORT_COUT__ 29 | #undef __UCLIBCXX_SUPPORT_CERR__ 30 | /* 31 | * STL and Code Expansion 32 | */ 33 | //#define __UCLIBCXX_STL_BUFFER_SIZE__ 32 34 | #define __UCLIBCXX_STL_BUFFER_SIZE__ 8 35 | #undef __UCLIBCXX_CODE_EXPANSION__ 36 | 37 | /* 38 | * Library Installation Options 39 | */ 40 | #define __UCLIBCXX_RUNTIME_PREFIX__ "/usr/uClibc++" 41 | #define __UCLIBCXX_RUNTIME_INCLUDE_SUBDIR__ "/include" 42 | #define __UCLIBCXX_RUNTIME_LIB_SUBDIR__ "/lib" 43 | #define __UCLIBCXX_RUNTIME_BIN_SUBDIR__ "/bin" 44 | #undef __UCLIBCXX_EXCEPTION_SUPPORT__ 45 | #define __BUILD_STATIC_LIB__ 1 46 | #define __BUILD_ONLY_STATIC_LIB__ 1 47 | #undef __DODEBUG__ 48 | -------------------------------------------------------------------------------- /src/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 | 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)_UCXX_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 | -------------------------------------------------------------------------------- /src/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) _UCXX_THROW(std::bad_alloc) 28 | { 29 | //C++ stardard 5.3.4.8 requires that a valid pointer be returned for 30 | //a call to new(0). Thus: 31 | if(numBytes == 0){ 32 | numBytes = 1; 33 | } 34 | void * p = malloc(numBytes); 35 | if(p == 0){ 36 | std::__throw_bad_alloc(); 37 | } 38 | return p; 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/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 "cstdlib" 21 | #include "cstring" 22 | #include "func_exception" 23 | 24 | //This is a system-specific header which does all of the error-handling management 25 | #include "unwind-cxx.h" 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() _UCXX_USE_NOEXCEPT{ 35 | return &eh_globals; 36 | } 37 | 38 | extern "C" __cxa_eh_globals* __cxa_get_globals_fast() _UCXX_USE_NOEXCEPT{ 39 | return &eh_globals; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | #include "exception" 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 | -------------------------------------------------------------------------------- /src/abi/abi.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc C++ Library. This library is free 4 | software; you can redistribute it and/or modify it under the 5 | terms of the GNU General Public License as published by the 6 | Free Software Foundation; either version 2, or (at your option) 7 | 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 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along 15 | with this library; see the file COPYING. If not, write to the Free 16 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 17 | USA. 18 | */ 19 | 20 | #include "cstdlib" 21 | #include "typeinfo" 22 | #include "basic_definitions" 23 | 24 | /* This file implements a number of the language support features 25 | * needed to deal with the C++ abi, as originally documented in the 26 | * Itanium C++ ABI, though now industry standard 27 | */ 28 | 29 | extern "C" { 30 | 31 | #if defined(ARDUINO) 32 | /* Arduino defines some of these. 33 | * There can be link issues if they're redefined 34 | */ 35 | #else 36 | /* This function is called in the event that a non-overidden 37 | * pure virtual function is called. The compiler should never 38 | * let that happen. We get to choose what to do - we will abort 39 | */ 40 | void __cxa_pure_virtual (){ 41 | abort(); 42 | } 43 | 44 | #endif 45 | } 46 | -------------------------------------------------------------------------------- /src/initializer_list: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016 Michael Matera 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 | 22 | #ifndef __STD_HEADER_INITIALIZER_LIST 23 | #define __STD_HEADER_INITIALIZER_LIST 24 | 25 | #pragma GCC visibility push(default) 26 | 27 | namespace std { 28 | 29 | template 30 | class initializer_list { 31 | 32 | private: 33 | const T* array; 34 | size_t len; 35 | 36 | // Initialize from a { ... } construct 37 | initializer_list(const T *a, size_t l): array(a), len(l) { } 38 | 39 | public: 40 | 41 | // default constructor 42 | initializer_list() : array(NULL), len(0) {} 43 | 44 | size_t size() const { 45 | return len; 46 | } 47 | 48 | const T *begin() { 49 | return array; 50 | } 51 | 52 | const T *end() { 53 | return array + len; 54 | } 55 | 56 | }; 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/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 "exception" 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() _UCXX_USE_NOEXCEPT{ 37 | //Empty function 38 | } 39 | 40 | _UCXXEXPORT const char* exception::what() const _UCXX_USE_NOEXCEPT{ 41 | return __std_exception_what_value; 42 | } 43 | 44 | _UCXXEXPORT bad_exception::~bad_exception() _UCXX_USE_NOEXCEPT{ 45 | 46 | } 47 | 48 | 49 | } 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/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 "streambuf" 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 | -------------------------------------------------------------------------------- /src/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 "exception" 21 | #include "stdexcept" 22 | 23 | #ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ 24 | 25 | namespace std{ 26 | 27 | _UCXXEXPORT logic_error::logic_error() _UCXX_USE_NOEXCEPT : 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 _UCXX_USE_NOEXCEPT{ 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 _UCXX_USE_NOEXCEPT{ 57 | return mstring.c_str(); 58 | } 59 | 60 | } 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | 22 | #ifndef __HEADER_CSTDLIB 23 | #define __HEADER_CSTDLIB 1 24 | 25 | 26 | namespace std{ 27 | using ::abort; 28 | using ::abs; 29 | using ::atexit; 30 | using ::atol; 31 | using ::atof; 32 | using ::atoi; 33 | using ::bsearch; 34 | using ::calloc; 35 | using ::div; 36 | using ::exit; 37 | using ::free; 38 | using ::getenv; 39 | using ::labs; 40 | using ::ldiv; 41 | using ::malloc; 42 | using ::qsort; 43 | using ::rand; 44 | using ::realloc; 45 | using ::srand; 46 | using ::strtod; 47 | using ::strtol; 48 | using ::strtoul; 49 | using ::system; 50 | #ifdef __UCLIBCXX_HAS_WCHAR__ 51 | using ::mblen; 52 | using ::mbstowcs; 53 | using ::mbtowc; 54 | using ::wctomb; 55 | using ::wcstombs; 56 | #endif 57 | 58 | /* Defined in Arduino 59 | inline long abs(long i){ 60 | return labs(i); 61 | } 62 | */ 63 | inline ldiv_t div(long i, long j){ 64 | return ldiv(i, j); 65 | } 66 | 67 | } 68 | 69 | 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /src/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 "support" 21 | 22 | /*extern "C" void *__cxa_allocate_exception(size_t thrown_size){ 23 | void * retval; 24 | 25 | // The amount of data needed is the size of the object *PLUS* 26 | // the size of the header. The header is of struct __cxa_exception 27 | // The address needs to be adjusted because the pointer we return 28 | // should not point to the start of the memory, but to the point 29 | // where the object being thrown actually starts 30 | 31 | retval = malloc(thrown_size + sizeof(__cxa_exception)); 32 | 33 | // Check to see that we actuall allocated memory 34 | if(retval == 0){ 35 | std::terminate(); 36 | } 37 | 38 | //Need to do a typecast to char* otherwize we are doing math with 39 | //a void* which makes the compiler cranky (Like me) 40 | return ((char *)retval + sizeof(__cxa_exception)); 41 | } 42 | 43 | extern "C" void __cxa_free_exception(void *thrown_exception){ 44 | 45 | 46 | 47 | } 48 | 49 | extern "C" void __cxa_throw (void *thrown_exception, std::type_info *tinfo,void (*dest) (void *) ){ 50 | 51 | 52 | } 53 | */ 54 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 25 | #include "char_traits" 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 | -------------------------------------------------------------------------------- /src/array: -------------------------------------------------------------------------------- 1 | #ifndef __ARRAY__ 2 | #define __ARRAY__ 3 | 4 | #include "cstddef" 5 | #include "initializer_list" 6 | 7 | namespace std { 8 | 9 | template 10 | class array { 11 | public: 12 | typedef T value_type; 13 | typedef T* pointer; 14 | typedef const T* const_pointer; 15 | typedef value_type& reference; 16 | typedef const value_type& const_reference; 17 | typedef pointer iterator; 18 | typedef const_pointer const_iterator; 19 | typedef size_t size_type; 20 | 21 | private: 22 | value_type _data[N ? N : 1]; 23 | 24 | public: 25 | array() = default; 26 | array(std::initializer_list init) { 27 | if (init.size() != N) { 28 | // error 29 | } 30 | size_t i = 0; 31 | for(const auto& item : init) { 32 | _data[i++] = item; 33 | } 34 | } 35 | array& operator=(const array& other) = default; 36 | 37 | reference operator[](size_type i) { return _data[i]; } 38 | const_reference operator[](size_type i) const { return _data[i]; } 39 | reference front() { return _data[0]; } 40 | const_reference front() const { return _data[0]; } 41 | reference back() { return _data[N - 1]; } 42 | const_reference back() const { return _data[N - 1]; } 43 | pointer data() noexcept { return _data; } 44 | const_pointer data() const noexcept { return _data; } 45 | reference at(size_type pos) { return _data[pos]; } 46 | const_reference at(size_type pos) const { return _data[pos]; } 47 | 48 | iterator begin() noexcept { return _data; } 49 | const_iterator begin() const noexcept { return _data; } 50 | const_iterator cbegin() const noexcept { return _data; } 51 | iterator end() noexcept { return _data + N; } 52 | const_iterator end() const noexcept { return _data + N; } 53 | const_iterator cend() const noexcept { return _data + N; } 54 | 55 | bool empty() const noexcept { return begin() == end(); } 56 | size_type size() const noexcept { return N; } 57 | size_type max_size() const noexcept { return N; } 58 | 59 | void fill(const_reference value) { 60 | for (auto i = 0u; i < N; ++i) { 61 | _data[i] = value; 62 | } 63 | } 64 | }; 65 | 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/ostream_helpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This code is taken from the Arduino Print class. 3 | * 4 | * printf() doesn't handle floating point types on AVR. 5 | * This code helps me hack that in. It's not here permanently. 6 | * 7 | */ 8 | 9 | #include "ostream_helpers" 10 | #include 11 | 12 | namespace std { 13 | 14 | int arduinoPrintFloat(double number, uint8_t digits, char *buffer, size_t buffer_size) 15 | { 16 | size_t n = 0; 17 | 18 | if (buffer_size < 4) 19 | return 0; 20 | 21 | if (isnan(number)) return snprintf(buffer, buffer_size, "nan"); 22 | if (isinf(number)) return snprintf(buffer, buffer_size, "inf"); 23 | if (number > 4294967040.0) return snprintf(buffer, buffer_size, "ovf"); // constant determined empirically 24 | if (number <-4294967040.0) return snprintf(buffer, buffer_size, "ovf"); // constant determined empirically 25 | 26 | // Handle negative numbers 27 | if (number < 0.0) { 28 | n += snprintf(&buffer[n], buffer_size-n, "-"); 29 | number = -number; 30 | } 31 | 32 | // Round correctly so that print(1.999, 2) prints as "2.00" 33 | double rounding = 0.5; 34 | for (uint8_t i=0; i= buffer_size) 44 | return n; 45 | 46 | // Print the decimal point, but only if there are digits beyond 47 | if (digits > 0) { 48 | n += snprintf(&buffer[n], buffer_size-n, "."); 49 | if (n >= buffer_size) 50 | return n; 51 | } 52 | 53 | // Extract digits from the remainder one at a time 54 | while (digits-- > 0) 55 | { 56 | remainder *= 10.0; 57 | unsigned int toPrint = (unsigned int)(remainder); 58 | n += snprintf(&buffer[n], buffer_size-n, "%u", toPrint); 59 | if (n >= buffer_size) 60 | return n; 61 | remainder -= toPrint; 62 | } 63 | 64 | return n; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 20 | 21 | #ifndef __HEADER_CSTDIO 22 | #define __HEADER_CSTDIO 1 23 | 24 | #undef clearerr 25 | #undef feof 26 | #undef ferror 27 | #undef fgetc 28 | #undef fputc 29 | #undef getc 30 | #undef getchar 31 | #undef putc 32 | #undef putchar 33 | 34 | namespace std{ 35 | using ::FILE; 36 | using ::fpos_t; 37 | 38 | using ::clearerr; 39 | using ::fclose; 40 | using ::feof; 41 | using ::ferror; 42 | using ::fflush; 43 | using ::fgetc; 44 | using ::fgetpos; 45 | using ::fgets; 46 | using ::fopen; 47 | using ::fprintf; 48 | using ::fputc; 49 | using ::fputs; 50 | using ::fread; 51 | using ::freopen; 52 | using ::fscanf; 53 | using ::fseek; 54 | using ::fsetpos; 55 | using ::ftell; 56 | using ::fwrite; 57 | using ::getc; 58 | using ::getchar; 59 | #if __cplusplus <= 201103L 60 | // LWG 2249 61 | using ::gets; 62 | #endif 63 | using ::perror; 64 | using ::printf; 65 | using ::putc; 66 | using ::putchar; 67 | using ::puts; 68 | using ::remove; 69 | using ::rename; 70 | using ::rewind; 71 | using ::scanf; 72 | using ::setbuf; 73 | using ::setvbuf; 74 | using ::sprintf; 75 | using ::sscanf; 76 | using ::tmpfile; 77 | #ifdef _GLIBCXX_USE_TMPNAM 78 | using ::tmpnam; 79 | #endif 80 | using ::ungetc; 81 | using ::vfprintf; 82 | using ::vprintf; 83 | using ::vsprintf; 84 | } 85 | 86 | 87 | 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 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 | -------------------------------------------------------------------------------- /src/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 "cstddef" 20 | #include 21 | 22 | #ifndef __HEADER_CSTRING 23 | #define __HEADER_CSTRING 1 24 | 25 | 26 | namespace std{ 27 | 28 | using ::memchr; 29 | using ::memcmp; 30 | using ::memcpy; 31 | using ::memmove; 32 | using ::memset; 33 | using ::strcat; 34 | using ::strchr; 35 | using ::strcmp; 36 | using ::strcoll; 37 | using ::strcpy; 38 | using ::strcspn; 39 | using ::strerror; 40 | using ::strlen; 41 | using ::strncat; 42 | using ::strncmp; 43 | using ::strncpy; 44 | using ::strpbrk; 45 | using ::strrchr; 46 | using ::strspn; 47 | using ::strstr; 48 | using ::strtok; 49 | using ::strxfrm; 50 | 51 | #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO 52 | //Extra definitions required in c++ spec 53 | 54 | inline void* memchr(void* s, int c, size_t n){ 55 | return memchr(const_cast(s), c, n); 56 | } 57 | 58 | inline char* strchr(char* s, int c){ 59 | return strchr(const_cast(s), c); 60 | } 61 | 62 | inline char* strpbrk(char* s1, const char* s2){ 63 | return strpbrk(const_cast(s1), s2); 64 | } 65 | 66 | inline char* strrchr(char* s, int c){ 67 | return strrchr(const_cast(s), c); 68 | } 69 | 70 | inline char* strstr(char* s1, const char* s2){ 71 | return strstr(const_cast(s1), s2); 72 | } 73 | #endif 74 | } 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | #include "cstddef" 22 | #include "string" 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() _UCXX_USE_NOEXCEPT{ 46 | return; 47 | } 48 | locale(const locale& other) _UCXX_USE_NOEXCEPT{ 49 | (void)other; 50 | return; 51 | } 52 | locale(const char *) _UCXX_USE_NOEXCEPT{ 53 | return; 54 | } 55 | ~locale() _UCXX_USE_NOEXCEPT{ 56 | return; 57 | } 58 | 59 | const locale& operator=(const locale&) _UCXX_USE_NOEXCEPT{ 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 | -------------------------------------------------------------------------------- /src/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 "exception" 21 | #include "func_exception" 22 | #include "stdexcept" 23 | #include "cstdlib" 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "cstdlib" 21 | #include "cstring" 22 | #include "func_exception" 23 | 24 | //This is a system-specific header which does all of the error-handling management 25 | #include "unwind-cxx.h" 26 | 27 | namespace __cxxabiv1 28 | { 29 | 30 | extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) _UCXX_USE_NOEXCEPT{ 31 | void *e; 32 | // The sizeof crap is required by Itanium ABI because we need to 33 | // provide space for accounting information which is implementation 34 | // (gcc) defined. 35 | e = malloc (thrown_size + sizeof(__cxa_refcounted_exception)); 36 | if (0 == e){ 37 | std::terminate(); 38 | } 39 | memset (e, 0, sizeof(__cxa_refcounted_exception)); 40 | return (void *)((unsigned char *)e + sizeof(__cxa_refcounted_exception)); 41 | } 42 | 43 | extern "C" void __cxa_free_exception(void *vptr) _UCXX_USE_NOEXCEPT{ 44 | free( (char *)(vptr) - sizeof(__cxa_refcounted_exception) ); 45 | } 46 | 47 | 48 | extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() _UCXX_USE_NOEXCEPT{ 49 | __cxa_dependent_exception *retval; 50 | // The sizeof crap is required by Itanium ABI because we need to 51 | // provide space for accounting information which is implementation 52 | // (gcc) defined. 53 | retval = static_cast<__cxa_dependent_exception*>(malloc (sizeof(__cxa_dependent_exception))); 54 | if (0 == retval){ 55 | std::terminate(); 56 | } 57 | memset (retval, 0, sizeof(__cxa_dependent_exception)); 58 | return retval; 59 | } 60 | 61 | extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *vptr) _UCXX_USE_NOEXCEPT{ 62 | free( (char *)(vptr) ); 63 | } 64 | 65 | } /* namespace __cxxabiv1 */ 66 | -------------------------------------------------------------------------------- /src/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 "system_configuration.h" 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 __GCC__ 43 | # ifndef _UCXX_NOTHROW 44 | # ifndef __cplusplus 45 | # define _UCXX_NOTHROW __attribute__((__nothrow__)) 46 | # endif 47 | # endif 48 | #endif 49 | #ifdef __cplusplus 50 | # if __cplusplus >= 201103L 51 | # define _UCXX_NOEXCEPT noexcept 52 | # define _UCXX_USE_NOEXCEPT noexcept 53 | # define _UCXX_THROW(_EXCEPTION) 54 | # else 55 | # define _UCXX_NOEXCEPT 56 | # define _UCXX_USE_NOEXCEPT throw() 57 | # define _UCXX_THROW(_EXCEPTION) throw(_EXCEPTION) 58 | # endif 59 | # ifndef _UCXX_NOTHROW 60 | # define _UCXX_NOTHROW _UCXX_USE_NOEXCEPT 61 | # endif 62 | #endif 63 | 64 | #ifdef __UCLIBCXX_HAS_TLS__ 65 | #define __UCLIBCXX_TLS __thread 66 | #else 67 | #define __UCLIBCXX_TLS 68 | #endif 69 | 70 | 71 | 72 | //Testing purposes 73 | #define __STRING_MAX_UNITS 65535 74 | 75 | namespace std{ 76 | typedef signed long int streamsize; 77 | } 78 | 79 | #pragma GCC visibility pop 80 | 81 | # ifdef __DODEBUG__ 82 | #define UCLIBCXX_DEBUG 1 83 | # else 84 | #define UCLIBCXX_DEBUG 0 85 | # endif 86 | #endif 87 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 20 | #include 21 | #include "exception" 22 | #include "memory" 23 | #include "char_traits" 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 | -------------------------------------------------------------------------------- /src/ArduinoSTL.cpp: -------------------------------------------------------------------------------- 1 | #include "ArduinoSTL.h" 2 | #include 3 | 4 | // 5 | // Configuration Help 6 | // 7 | // If you're using a serial port that's statically declared somewhere in 8 | // Arduino (e.g. Serial1 on Leonardo) 9 | // 1. Set ARDUINOSTL_SERIAL_DEVICE to your device 10 | // 2. Uncomment the ARDUINOSTL_DEFAULT_CIN_COUT flag. 11 | // 12 | // If you're using a sofware serial port: 13 | // 1. Set ARDUINOSTL_DEFAULT_SERIAL to NULL 14 | // 2. Comment out ARDUINOSTL_DEFAULT_CIN_COUT 15 | // Your sketch must contain delarations of cin and cout, and a call to 16 | // ArduinoSTL_serial.connect(). 17 | // 18 | 19 | #define ARDUINOSTL_DEFAULT_SERIAL Serial 20 | #define ARDUINOSTL_DEFAULT_CIN_COUT 21 | 22 | using namespace std; 23 | 24 | #ifdef ARDUINOSTL_DEFAULT_CIN_COUT 25 | // Create cout and cin.. there doesn't seem to be a way 26 | // to control what serial device at runtime. Grr. 27 | namespace std 28 | { 29 | ohserialstream cout(ARDUINOSTL_DEFAULT_SERIAL); 30 | ihserialstream cin(ARDUINOSTL_DEFAULT_SERIAL); 31 | } 32 | #endif // ARDUINOSTL_DEFAULT_CIN_COUT 33 | 34 | /* 35 | * Implementation of printf() is highly libc dependent. 36 | * 37 | * This implementation is tested on: 38 | * 39 | * ARDUINO_ARCH_AVR (Classic Arduinos) - Working 40 | * TEENSYDUINO (ARM-based Teensy) - cin/cout work, printf doesn't 41 | * ARDUINO_ARCH_* - ARMs are probably the same as above. 42 | */ 43 | #if defined(ARDUINO_ARCH_AVR) 44 | 45 | ArduinoSTL_STDIO ArduinoSTL_Serial(ARDUINOSTL_DEFAULT_SERIAL); 46 | 47 | // arduino_putchar(char, FILE*) 48 | // Output a single character to the serial port. 49 | // returns: 0 on success, 1 on error 50 | // note: 51 | // To maintain serial port compatibility this function 52 | // automatically addes a \r when it sees a \n 53 | // 54 | static int arduino_putchar(char c, FILE* f) { 55 | Stream *uart = ArduinoSTL_Serial.getUart(); 56 | if (c == '\n') uart->write('\r'); 57 | return uart->write(c) == 1? 0 : 1; 58 | } 59 | 60 | // arduino_getchar(FILE*) 61 | // Take a character from the serial port. This function 62 | // must block until a character is ready. 63 | // returns: The character or -1 on a read error 64 | // 65 | static int arduino_getchar(FILE *f) { 66 | Stream *uart = ArduinoSTL_Serial.getUart(); 67 | while (! uart->available()) { /* wait */ } 68 | return uart->read(); 69 | } 70 | 71 | void ArduinoSTL_STDIO::connect(Stream *u) { 72 | if (file != NULL) 73 | free (file); 74 | uart = u; 75 | file = fdevopen(arduino_putchar, arduino_getchar); 76 | } 77 | 78 | #else 79 | #warning "printf() will not be functional on this platform." 80 | #endif 81 | -------------------------------------------------------------------------------- /src/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 "sstream" 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 | -------------------------------------------------------------------------------- /src/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 "cstddef" 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 | -------------------------------------------------------------------------------- /src/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 "istream" 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 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | #include "exception" 22 | #include "cstddef" 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) _UCXX_USE_NOEXCEPT; 37 | } 38 | 39 | 40 | _UCXXEXPORT void* operator new(std::size_t numBytes) _UCXX_THROW(std::bad_alloc); 41 | _UCXXEXPORT void operator delete(void* ptr) _UCXX_USE_NOEXCEPT; 42 | #ifdef __cpp_sized_deallocation 43 | _UCXXEXPORT void operator delete(void* ptr, std::size_t) _UCXX_USE_NOEXCEPT; 44 | #endif 45 | 46 | _UCXXEXPORT void* operator new[](std::size_t numBytes) _UCXX_THROW(std::bad_alloc); 47 | _UCXXEXPORT void operator delete[](void * ptr) _UCXX_USE_NOEXCEPT; 48 | #ifdef __cpp_sized_deallocation 49 | _UCXXEXPORT void operator delete[](void * ptr, std::size_t) _UCXX_USE_NOEXCEPT; 50 | #endif 51 | 52 | #ifndef NO_NOTHROW 53 | _UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; 54 | _UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; 55 | 56 | _UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; 57 | _UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT; 58 | #endif 59 | 60 | /* Placement operators */ 61 | inline void* operator new(std::size_t, void* ptr) _UCXX_USE_NOEXCEPT {return ptr; } 62 | inline void operator delete(void* , void *) _UCXX_USE_NOEXCEPT { } 63 | 64 | inline void* operator new[](std::size_t, void *p) _UCXX_USE_NOEXCEPT { return p; } 65 | inline void operator delete[](void* , void *) _UCXX_USE_NOEXCEPT {} 66 | 67 | #pragma GCC visibility pop 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 19 | #include "deque" 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 | -------------------------------------------------------------------------------- /src/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 "ostream" 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 | -------------------------------------------------------------------------------- /src/utility: -------------------------------------------------------------------------------- 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 "basic_definitions" 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 | // Stubb out move for compatibility 84 | template 85 | T& move(T& t) noexcept { 86 | return t; 87 | } 88 | } 89 | 90 | #pragma GCC visibility pop 91 | 92 | #endif //__STD_HEADER_UTILITY 93 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | 22 | #ifndef __HEADER_STD_IOSTREAM 23 | #define __HEADER_STD_IOSTREAM 1 24 | 25 | #include "iosfwd" 26 | #include "ios" 27 | #include "istream" 28 | #include "ostream" 29 | #include "string_iostream" 30 | 31 | #pragma GCC visibility push(default) 32 | 33 | namespace std{ 34 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 35 | extern istream cin; 36 | #endif 37 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 38 | extern ostream cout; 39 | #endif 40 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 41 | extern ostream cerr; 42 | #endif 43 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 44 | extern ostream clog; 45 | #endif 46 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 47 | extern wistream wcin; 48 | #endif 49 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 50 | extern wostream wcout; 51 | #endif 52 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 53 | extern wostream wcerr; 54 | #endif 55 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 56 | extern wostream wclog; 57 | #endif 58 | 59 | 60 | template class _UCXXEXPORT basic_iostream : 61 | public basic_istream, public basic_ostream 62 | { 63 | public: 64 | // constructor/destructor 65 | explicit _UCXXEXPORT basic_iostream(basic_streambuf* sb); 66 | virtual _UCXXEXPORT ~basic_iostream(); //Below 67 | }; 68 | 69 | template _UCXXEXPORT 70 | basic_iostream:: basic_iostream(basic_streambuf* sb) 71 | : basic_ios(sb), basic_istream(sb), basic_ostream(sb) 72 | { 73 | return; 74 | } 75 | 76 | 77 | template _UCXXEXPORT basic_iostream::~basic_iostream(){ 78 | return; 79 | } 80 | 81 | 82 | #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 83 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 84 | #ifndef __UCLIBCXX_COMPILE_IOSTREAM__ 85 | 86 | template <> _UCXXEXPORT basic_iostream >:: 87 | basic_iostream(basic_streambuf >* sb); 88 | template <> _UCXXEXPORT basic_iostream >::~basic_iostream(); 89 | 90 | #endif 91 | #endif 92 | #endif 93 | 94 | 95 | 96 | } 97 | 98 | #pragma GCC visibility pop 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ArduinoSTL 2 | 3 | This is an implementation of a C++ standard library packaged as an Arduino library. The library supports teaching my CS-11M class by adding key C++ features into the Arduino environment. 4 | 5 | The library is ported from uClibc++: 6 | 7 | http://git.uclibc.org/uClibc++ 8 | 9 | With a streams implementation from Andy Brown's Arduino Library: 10 | 11 | http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/ 12 | 13 | 14 | ## Using printf() and scanf() 15 | The ArduinoSTL header file contains code to bind a serial port of your choice to 16 | the stdio primitives. This happens automatically but the user must still call 17 | Serial.begin() 18 | 19 | ```c++ 20 | #include 21 | 22 | void setup() { 23 | Serial.begin(9600); 24 | printf("Hello World\n"); 25 | } 26 | ``` 27 | 28 | ## Using ```cin``` an ```cout``` 29 | When you include this header file you automatically get cin and cout based on ```Serial```. See below for how to specify your own device. Here's an example sketch using ```cin``` and ```cout``` . 30 | 31 | ```c++ 32 | #include 33 | 34 | using namespace std; 35 | 36 | void setup() { 37 | Serial.begin(9600); 38 | cout << "Feed me an integers." << endl; 39 | } 40 | 41 | void loop() { 42 | int foo; 43 | if (cin >> foo) { 44 | cout << "You fed me " << foo << endl; 45 | }else{ 46 | cin.clear(); 47 | cin.ignore(); 48 | } 49 | } 50 | ``` 51 | ## Changing the Serial Port 52 | You can change what serial port that ```cin```, ```cout``` and ```printf()``` use. You can use built-in serial ports (e.g. ```Serial1``` on Leonardo) or you can use software serial ports that implement ```Stream```. 53 | 54 | ### Using a Built-in Port 55 | In ```src/ArduinoSTL.cpp``` change the value of ```ARDUINOSTL_DEFAULT_SERIAL```. Leave the other defaults uncommented. 56 | 57 | ### Using a SoftwareSerial port. 58 | Set ```ARDUINO_DEFAULT_SERAL``` to ```NULL```. Comment out the other defaults. 59 | 60 | Here's an example sketch that uses SofwareSerial: 61 | 62 | ```c++ 63 | #include 64 | #include 65 | 66 | SoftwareSerial mySerial(0, 1); 67 | 68 | namespace std { 69 | ohserialstream cout(mySerial); 70 | ihserialstream cin(mySerial); 71 | } 72 | 73 | void setup() { 74 | mySerial.begin(9600); 75 | ArduinoSTL_Serial.connect(mySerial); 76 | } 77 | ``` 78 | 79 | ## Avoiding Instantiation of ```cin``` and ```cout``` 80 | Comment out ```ARDUINOSTL_DEFAULT_CIN_COUT``` and nothing will be instantiated. You must comment out this flag if you intend to select a non-default serial port. There's no appreciable overhead for using ```printf()``` so you cannot currently avoid initializaing it. 81 | 82 | ## Known Issues 83 | 84 | Printing of floats and doubles using ```cout``` ignores format specifiers. 85 | 86 | uClibc seems to be fairly complete. Strings and vectors both work, even with the limited amount of heap available to Arduino. The uClibc++ status page can be found here: 87 | 88 | https://cxx.uclibc.org/status.html 89 | 90 | Always use the latest Arduino IDE. This library uses the Arduino IDE Library Specification rev.2.1 with features only available on Arduino 1.6.10 and higher. The specification can be found here: 91 | 92 | https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification 93 | 94 | ## License 95 | 96 | The uClibc++ library is licensed under the LGPL. This project adopts the LGPL to be compatible with the bulk of the code that it uses. Unless otherwise noted all code is licensed under the LGPL. There's one exception: 97 | 98 | - src/serstream is licensed under the BSD license according to Andy Brown's wishes here: http://andybrown.me.uk/terms-and-conditions/ 99 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | #include "exception" 22 | #include "string" 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() _UCXX_USE_NOEXCEPT; 41 | logic_error(const string& what_arg); 42 | 43 | virtual ~logic_error() _UCXX_USE_NOEXCEPT {} 44 | virtual const char * what() const _UCXX_USE_NOEXCEPT; 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() _UCXX_USE_NOEXCEPT {} 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() _UCXX_USE_NOEXCEPT {} 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() _UCXX_USE_NOEXCEPT {} 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() _UCXX_USE_NOEXCEPT {} 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() _UCXX_USE_NOEXCEPT {} 85 | virtual const char * what() const _UCXX_USE_NOEXCEPT; 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() _UCXX_USE_NOEXCEPT{ } 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() _UCXX_USE_NOEXCEPT{} 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() _UCXX_USE_NOEXCEPT{} 108 | }; 109 | 110 | 111 | 112 | } 113 | 114 | #pragma GCC visibility pop 115 | 116 | #endif 117 | #endif 118 | -------------------------------------------------------------------------------- /src/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 "istream" 21 | #include "ostream" 22 | #include "string" 23 | 24 | #ifdef __UCLIBCXX_HAS_WCHAR__ 25 | #include "cwchar" 26 | #include "cwctype" 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, true); 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 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 19 | #include "deque" 20 | #include "vector" 21 | #include "functional" 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 | -------------------------------------------------------------------------------- /src/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 "exception" 21 | #include "ios" 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 | -------------------------------------------------------------------------------- /src/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 "vector" 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 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | #include "char_traits" 22 | #include "memory" 23 | 24 | 25 | #ifndef __HEADER_STD_IOSFWD 26 | #define __HEADER_STD_IOSFWD 1 27 | 28 | #pragma GCC visibility push(default) 29 | 30 | namespace std { 31 | class ios_base; 32 | template<> class char_traits; 33 | 34 | #ifdef __UCLIBCXX_HAS_WCHAR__ 35 | template<> class char_traits; 36 | #endif 37 | 38 | template > class basic_ios; 39 | 40 | template > class basic_streambuf; 41 | template > class basic_istream; 42 | template > class basic_ostream; 43 | template > class basic_iostream; 44 | 45 | template , 46 | class Allocator = allocator > class basic_stringbuf; 47 | 48 | template , 49 | class Allocator = allocator > class basic_istringstream; 50 | 51 | template , 52 | class Allocator = allocator > class basic_ostringstream; 53 | 54 | template , 55 | class Allocator = allocator > class basic_stringstream; 56 | 57 | template > class basic_filebuf; 58 | 59 | template > class basic_ifstream; 60 | 61 | template > class basic_ofstream; 62 | 63 | template > class basic_fstream; 64 | 65 | template > class basic_istreambuf_iterator; 66 | 67 | template > class basic_ostreambuf_iterator; 68 | 69 | typedef basic_ios ios; 70 | #ifdef __UCLIBCXX_HAS_WCHAR__ 71 | typedef basic_ios wios; 72 | #endif 73 | 74 | typedef basic_streambuf streambuf; 75 | typedef basic_istream istream; 76 | typedef basic_ostream ostream; 77 | typedef basic_iostream iostream; 78 | 79 | typedef basic_stringbuf stringbuf; 80 | typedef basic_istringstream istringstream; 81 | typedef basic_ostringstream ostringstream; 82 | typedef basic_stringstream stringstream; 83 | 84 | typedef basic_filebuf filebuf; 85 | typedef basic_ifstream ifstream; 86 | typedef basic_ofstream ofstream; 87 | typedef basic_fstream fstream; 88 | #ifdef __UCLIBCXX_HAS_WCHAR__ 89 | typedef basic_streambuf wstreambuf; 90 | typedef basic_istream wistream; 91 | typedef basic_ostream wostream; 92 | typedef basic_iostream wiostream; 93 | 94 | typedef basic_stringbuf wstringbuf; 95 | typedef basic_istringstream wistringstream; 96 | typedef basic_ostringstream wostringstream; 97 | typedef basic_stringstream wstringstream; 98 | 99 | typedef basic_filebuf wfilebuf; 100 | typedef basic_ifstream wifstream; 101 | typedef basic_ofstream wofstream; 102 | typedef basic_fstream wfstream; 103 | #endif 104 | 105 | template class fpos; 106 | typedef fpos::state_type> streampos; 107 | #ifdef __UCLIBCXX_HAS_WCHAR__ 108 | typedef fpos::state_type> wstreampos; 109 | #endif 110 | } 111 | 112 | #pragma GCC visibility pop 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | #include "exception" 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 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 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() _UCXX_NOTHROW { } 58 | virtual ~exception() _UCXX_NOTHROW; 59 | /** Returns a C-style character string describing the general cause 60 | * of the current error. */ 61 | virtual const char* what() const _UCXX_NOTHROW; 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() _UCXX_USE_NOEXCEPT { } 70 | // This declaration is not useless: 71 | // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 72 | virtual ~bad_exception() _UCXX_USE_NOEXCEPT; 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) _UCXX_USE_NOEXCEPT; 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) _UCXX_USE_NOEXCEPT; 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() _UCXX_USE_NOEXCEPT; 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 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md 2 | name: Sync Labels 3 | 4 | # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows 5 | on: 6 | push: 7 | paths: 8 | - ".github/workflows/sync-labels.ya?ml" 9 | - ".github/label-configuration-files/*.ya?ml" 10 | pull_request: 11 | paths: 12 | - ".github/workflows/sync-labels.ya?ml" 13 | - ".github/label-configuration-files/*.ya?ml" 14 | schedule: 15 | # Run daily at 8 AM UTC to sync with changes to shared label configurations. 16 | - cron: "0 8 * * *" 17 | workflow_dispatch: 18 | repository_dispatch: 19 | 20 | env: 21 | CONFIGURATIONS_FOLDER: .github/label-configuration-files 22 | CONFIGURATIONS_ARTIFACT: label-configuration-files 23 | 24 | jobs: 25 | check: 26 | runs-on: ubuntu-latest 27 | 28 | steps: 29 | - name: Checkout repository 30 | uses: actions/checkout@v3 31 | 32 | - name: Download JSON schema for labels configuration file 33 | id: download-schema 34 | uses: carlosperate/download-file-action@v1 35 | with: 36 | file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json 37 | location: ${{ runner.temp }}/label-configuration-schema 38 | 39 | - name: Install JSON schema validator 40 | run: | 41 | sudo npm install \ 42 | --global \ 43 | ajv-cli \ 44 | ajv-formats 45 | 46 | - name: Validate local labels configuration 47 | run: | 48 | # See: https://github.com/ajv-validator/ajv-cli#readme 49 | ajv validate \ 50 | --all-errors \ 51 | -c ajv-formats \ 52 | -s "${{ steps.download-schema.outputs.file-path }}" \ 53 | -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" 54 | 55 | download: 56 | needs: check 57 | runs-on: ubuntu-latest 58 | 59 | strategy: 60 | matrix: 61 | filename: 62 | # Filenames of the shared configurations to apply to the repository in addition to the local configuration. 63 | # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels 64 | - universal.yml 65 | 66 | steps: 67 | - name: Download 68 | uses: carlosperate/download-file-action@v1 69 | with: 70 | file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} 71 | 72 | - name: Pass configuration files to next job via workflow artifact 73 | uses: actions/upload-artifact@v2 74 | with: 75 | path: | 76 | *.yaml 77 | *.yml 78 | if-no-files-found: error 79 | name: ${{ env.CONFIGURATIONS_ARTIFACT }} 80 | 81 | sync: 82 | needs: download 83 | runs-on: ubuntu-latest 84 | 85 | steps: 86 | - name: Set environment variables 87 | run: | 88 | # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable 89 | echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" 90 | 91 | - name: Determine whether to dry run 92 | id: dry-run 93 | if: > 94 | github.event_name == 'pull_request' || 95 | ( 96 | ( 97 | github.event_name == 'push' || 98 | github.event_name == 'workflow_dispatch' 99 | ) && 100 | github.ref != format('refs/heads/{0}', github.event.repository.default_branch) 101 | ) 102 | run: | 103 | # Use of this flag in the github-label-sync command will cause it to only check the validity of the 104 | # configuration. 105 | echo "::set-output name=flag::--dry-run" 106 | 107 | - name: Checkout repository 108 | uses: actions/checkout@v3 109 | 110 | - name: Download configuration files artifact 111 | uses: actions/download-artifact@v2 112 | with: 113 | name: ${{ env.CONFIGURATIONS_ARTIFACT }} 114 | path: ${{ env.CONFIGURATIONS_FOLDER }} 115 | 116 | - name: Remove unneeded artifact 117 | uses: geekyeggo/delete-artifact@v1 118 | with: 119 | name: ${{ env.CONFIGURATIONS_ARTIFACT }} 120 | 121 | - name: Merge label configuration files 122 | run: | 123 | # Merge all configuration files 124 | shopt -s extglob 125 | cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" 126 | 127 | - name: Install github-label-sync 128 | run: sudo npm install --global github-label-sync 129 | 130 | - name: Sync labels 131 | env: 132 | GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} 133 | run: | 134 | # See: https://github.com/Financial-Times/github-label-sync 135 | github-label-sync \ 136 | --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ 137 | ${{ steps.dry-run.outputs.flag }} \ 138 | ${{ github.repository }} 139 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 23 | #include "char_traits" 24 | #include "string" 25 | #include "string_iostream" 26 | #include 27 | #include "ostream" 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 | -------------------------------------------------------------------------------- /src/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 "ios" 23 | #include "ostream" 24 | #include "istream" 25 | #include "cstdio" 26 | 27 | namespace std{ 28 | 29 | 30 | #ifdef __UCLIBCXX_SUPPORT_CDIR__ 31 | _UCXXLOCAL int ios_base::Init::init_cnt = 0; //Needed to ensure the static value is created 32 | 33 | //Create buffers first 34 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 35 | _UCXXEXPORT filebuf _cout_filebuf; 36 | #endif 37 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 38 | _UCXXEXPORT filebuf _cin_filebuf; 39 | #endif 40 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 41 | _UCXXEXPORT filebuf _cerr_filebuf; 42 | #endif 43 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 44 | _UCXXEXPORT filebuf _clog_filebuf; 45 | #endif 46 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 47 | _UCXXEXPORT wfilebuf _wcout_filebuf; 48 | #endif 49 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 50 | _UCXXEXPORT wfilebuf _wcin_filebuf; 51 | #endif 52 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 53 | _UCXXEXPORT wfilebuf _wcerr_filebuf; 54 | #endif 55 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 56 | _UCXXEXPORT wfilebuf _wclog_filebuf; 57 | #endif 58 | 59 | //Then create streams 60 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 61 | _UCXXEXPORT ostream cout(&_cout_filebuf); 62 | #endif 63 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 64 | _UCXXEXPORT istream cin(&_cin_filebuf); 65 | #endif 66 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 67 | _UCXXEXPORT ostream cerr(&_cerr_filebuf); 68 | #endif 69 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 70 | _UCXXEXPORT ostream clog(&_clog_filebuf); 71 | #endif 72 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 73 | _UCXXEXPORT wostream wcout(&_wcout_filebuf); 74 | #endif 75 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 76 | _UCXXEXPORT wistream wcin(&_wcin_filebuf); 77 | #endif 78 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 79 | _UCXXEXPORT wostream wcerr(&_wcerr_filebuf); 80 | #endif 81 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 82 | _UCXXEXPORT wostream wclog(&_wclog_filebuf); 83 | #endif 84 | 85 | 86 | _UCXXEXPORT ios_base::Init::Init(){ 87 | if(init_cnt == 0){ //Need to construct cout et al 88 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 89 | _cout_filebuf.fp = stdout; 90 | _cout_filebuf.openedFor = ios_base::out; 91 | #endif 92 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 93 | _cerr_filebuf.fp = stderr; 94 | _cerr_filebuf.openedFor = ios_base::out; 95 | cerr.mformat |= ios_base::unitbuf; 96 | #endif 97 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 98 | _clog_filebuf.fp = stderr; 99 | _clog_filebuf.openedFor = ios_base::out; 100 | #endif 101 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 102 | _cin_filebuf.fp = stdin; 103 | _cin_filebuf.openedFor = ios_base::in; 104 | 105 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 106 | cin.tie(&cout); 107 | #endif 108 | 109 | #endif 110 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 111 | _wcout_filebuf.fp = stdout; 112 | _wcout_filebuf.openedFor = ios_base::out; 113 | #endif 114 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 115 | _wcerr_filebuf.fp = stderr; 116 | _wcerr_filebuf.openedFor = ios_base::out; 117 | wcerr.mformat |= ios_base::unitbuf; 118 | #endif 119 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 120 | _wclog_filebuf.fp = stderr; 121 | _wclog_filebuf.openedFor = ios_base::out; 122 | #endif 123 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 124 | _wcin_filebuf.fp = stdin; 125 | _wcin_filebuf.openedFor = ios_base::in; 126 | 127 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 128 | wcin.tie(&wcout); 129 | #endif 130 | 131 | #endif 132 | } 133 | init_cnt++; 134 | } 135 | 136 | _UCXXEXPORT ios_base::Init::~Init(){ 137 | --init_cnt; 138 | if(init_cnt==0){ 139 | 140 | } 141 | } 142 | #endif 143 | 144 | 145 | #ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ 146 | 147 | template _UCXXEXPORT void basic_ios >::clear(iostate state); 148 | template _UCXXEXPORT void basic_ios >::setstate(iostate state); 149 | 150 | #endif 151 | 152 | 153 | _UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){ 154 | fmtflags temp = mformat; 155 | mformat = fmtfl; 156 | return temp; 157 | } 158 | 159 | _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){ 160 | return flags(flags() | fmtfl); 161 | } 162 | 163 | _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){ 164 | return flags( (flags()& ~mask) | (fmtfl & mask)); 165 | } 166 | 167 | _UCXXEXPORT streamsize ios_base::precision(streamsize prec){ 168 | streamsize temp = mprecision; 169 | mprecision = prec; 170 | return temp; 171 | } 172 | 173 | _UCXXEXPORT streamsize ios_base::width(streamsize wide){ 174 | streamsize temp = mwidth; 175 | mwidth = wide; 176 | return temp; 177 | } 178 | 179 | _UCXXEXPORT locale ios_base::imbue(const locale& loc){ 180 | locale retval = mLocale; 181 | mLocale = loc; 182 | return retval; 183 | } 184 | 185 | } 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /src/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 "new" 21 | #include "cstddef" 22 | #include "cstdlib" 23 | #include "iterator_base" 24 | #include "utility" 25 | #include "cstdio" 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() _UCXX_USE_NOEXCEPT{} 61 | template allocator(const allocator& ) _UCXX_USE_NOEXCEPT; 62 | ~allocator() _UCXX_USE_NOEXCEPT{} 63 | 64 | //Space for n Ts 65 | pointer allocate(size_type n, typename allocator::const_pointer = 0){ 66 | return static_cast(::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(static_cast(p)) T(val); } 74 | void destroy(pointer p){ (static_cast(p))->~T(); } //Call destructor 75 | 76 | size_type max_size() const _UCXX_USE_NOEXCEPT; 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) _UCXX_USE_NOEXCEPT : object(p){ } 132 | auto_ptr(auto_ptr& p) _UCXX_USE_NOEXCEPT : object(p.release()){ } 133 | auto_ptr(auto_ptr_ref r) _UCXX_USE_NOEXCEPT : object(r.p){ 134 | r.p = 0; 135 | } 136 | template auto_ptr(auto_ptr& p) _UCXX_USE_NOEXCEPT : object(p.release()){ } 137 | auto_ptr& operator=(auto_ptr& p) _UCXX_USE_NOEXCEPT{ 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) _UCXX_USE_NOEXCEPT{ 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 _UCXX_USE_NOEXCEPT{ 158 | return *object; 159 | } 160 | T* operator->() const _UCXX_USE_NOEXCEPT{ 161 | return object; 162 | } 163 | T* get() const _UCXX_USE_NOEXCEPT{ 164 | return object; 165 | } 166 | T* release() _UCXX_USE_NOEXCEPT{ 167 | T * temp(object); 168 | object = 0; 169 | return temp; 170 | } 171 | void reset(T * p=0) _UCXX_USE_NOEXCEPT{ 172 | if(p != object){ 173 | delete object; 174 | object = p; 175 | } 176 | } 177 | template operator auto_ptr_ref() _UCXX_USE_NOEXCEPT{ 178 | auto_ptr_ref retval; 179 | retval.p = object; 180 | object = 0; 181 | return retval; 182 | } 183 | template operator auto_ptr() _UCXX_USE_NOEXCEPT{ 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 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 20 | #include 21 | #include "exception" 22 | #include "memory" 23 | 24 | #ifdef __UCLIBCXX_HAS_WCHAR__ 25 | #include "cwchar" 26 | #include "cwctype" 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 static_cast(static_cast(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 static_cast(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 static_cast(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 | -------------------------------------------------------------------------------- /src/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 | #undef abs 26 | #undef acos 27 | #undef asin 28 | #undef atan 29 | #undef atan2 30 | #undef ceil 31 | #undef cos 32 | #undef cosh 33 | #undef exp 34 | #undef fabs 35 | #undef floor 36 | #undef fmod 37 | #undef frexp 38 | #undef ldexp 39 | #undef log 40 | #undef log10 41 | #undef modf 42 | #undef pow 43 | #undef sin 44 | #undef sinh 45 | #undef sqrt 46 | #undef tan 47 | #undef tanh 48 | 49 | namespace std { 50 | 51 | using ::acos; 52 | using ::asin; 53 | using ::atan; 54 | using ::atan2; 55 | using ::ceil; 56 | using ::cos; 57 | using ::cosh; 58 | using ::exp; 59 | using ::fabs; 60 | using ::floor; 61 | using ::fmod; 62 | using ::frexp; 63 | using ::ldexp; 64 | using ::log; 65 | using ::log10; 66 | using ::modf; 67 | using ::pow; 68 | using ::sin; 69 | using ::sinh; 70 | using ::sqrt; 71 | using ::tan; 72 | using ::tanh; 73 | 74 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 75 | inline float abs (float x){ 76 | return fabsf(x); 77 | } 78 | inline float acos (float x){ 79 | return acosf(x); 80 | } 81 | inline float asin (float x){ 82 | return asinf(x); 83 | } 84 | inline float atan (float x){ 85 | return atanf(x); 86 | } 87 | inline float atan2(float y, float x){ 88 | return atan2f(y, x); 89 | } 90 | inline float ceil (float x){ 91 | return ceilf(x); 92 | } 93 | inline float cos (float x){ 94 | return cosf(x); 95 | } 96 | inline float cosh (float x){ 97 | return coshf(x); 98 | } 99 | inline float exp (float x){ 100 | return expf(x); 101 | } 102 | inline float fabs (float x){ 103 | return fabsf(x); 104 | } 105 | inline float floor(float x){ 106 | return floorf(x); 107 | } 108 | inline float fmod (float x, float y){ 109 | return fmodf(x, y); 110 | } 111 | inline float frexp(float x, int* exp){ 112 | return frexpf(x, exp); 113 | } 114 | inline float ldexp(float x, int exp){ 115 | return ldexpf(x, exp); 116 | } 117 | inline float log (float x){ 118 | return logf(x); 119 | } 120 | inline float log10(float x){ 121 | return log10f(x); 122 | } 123 | inline float modf (float x, float* inptr){ 124 | return modff(x, inptr); 125 | } 126 | inline float pow (float x, float y){ 127 | return powf(x, y); 128 | } 129 | #if 1 // DR 550 removed this 130 | inline float pow (float x, int y){ 131 | return pow((double)x, (double)y); 132 | } 133 | #endif 134 | inline float sin (float x){ 135 | return sinf(x); 136 | } 137 | inline float sinh (float x){ 138 | return sinhf(x); 139 | } 140 | inline float sqrt (float x){ 141 | return sqrtf(x); 142 | } 143 | inline float tan (float x){ 144 | return tanf(x); 145 | } 146 | inline float tanh (float x){ 147 | return tanhf(x); 148 | } 149 | inline double abs(double x){ 150 | return fabs(x); 151 | } 152 | inline double pow(double x, int y){ 153 | return pow((double)x, (double)y); 154 | } 155 | 156 | # ifdef __UCLIBCXX_HAS_LONG_DOUBLE__ 157 | inline long double abs (long double x){ 158 | return fabsl(x); 159 | } 160 | inline long double acos (long double x){ 161 | return acosl(x); 162 | } 163 | inline long double asin (long double x){ 164 | return asinl(x); 165 | } 166 | inline long double atan (long double x){ 167 | return atanl(x); 168 | } 169 | inline long double atan2(long double y, long double x){ 170 | return atan2l(y, x); 171 | } 172 | inline long double ceil (long double x){ 173 | return ceill(x); 174 | } 175 | inline long double cos (long double x){ 176 | return cosl(x); 177 | } 178 | inline long double cosh (long double x){ 179 | return coshl(x); 180 | } 181 | inline long double exp (long double x){ 182 | return expl(x); 183 | } 184 | inline long double fabs (long double x){ 185 | return fabsl(x); 186 | } 187 | inline long double floor(long double x){ 188 | return floorl(x); 189 | } 190 | inline long double frexp(long double x, int* exp){ 191 | return frexpl(x, exp); 192 | } 193 | inline long double fmod (long double x, long double y){ 194 | return fmodl(x, y); 195 | } 196 | inline long double ldexp(long double x, int y){ 197 | return ldexpl(x, y); 198 | } 199 | inline long double log (long double x){ 200 | return logl(x); 201 | } 202 | inline long double log10(long double x){ 203 | return log10l(x); 204 | } 205 | inline long double modf (long double x, long double* iptr){ 206 | return modfl(x, iptr); 207 | } 208 | inline long double pow (long double x, long double y){ 209 | return powl(x, y); 210 | } 211 | inline long double pow (long double x, int y){ 212 | return powl(x, (long double)y ); 213 | } 214 | inline long double sin (long double x){ 215 | return sinl(x); 216 | } 217 | inline long double sinh (long double x){ 218 | return sinhl(x); 219 | } 220 | inline long double sqrt (long double x){ 221 | return sqrtl(x); 222 | } 223 | inline long double tan (long double x){ 224 | return tanl(x); 225 | } 226 | inline long double tanh (long double x){ 227 | return tanhl(x); 228 | } 229 | # endif // __UCLIBCXX_HAS_LONG_DOUBLE__ 230 | #endif // __CORRECT_ISO_CPP_MATH_H_PROTO 231 | } 232 | 233 | #endif //__STD_HEADER_CMATH 234 | 235 | -------------------------------------------------------------------------------- /src/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 "exception" 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() _UCXX_USE_NOEXCEPT { } 139 | // This declaration is not useless: 140 | // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 141 | virtual ~bad_cast() _UCXX_USE_NOEXCEPT; 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 () _UCXX_USE_NOEXCEPT { } 149 | // This declaration is not useless: 150 | // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 151 | virtual ~bad_typeid() _UCXX_USE_NOEXCEPT; 152 | }; 153 | } // namespace std 154 | 155 | } // extern "C++" 156 | #endif 157 | -------------------------------------------------------------------------------- /src/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 "exception" 21 | #include "cstdlib" 22 | #include "typeinfo" 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 | -------------------------------------------------------------------------------- /src/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 "basic_definitions" 21 | #include "iosfwd" 22 | #include "cstddef" 23 | #include "char_traits" 24 | #include "iterator_base" 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() _UCXX_USE_NOEXCEPT : sbuf(0) { } 149 | istreambuf_iterator(istream_type& s) _UCXX_USE_NOEXCEPT : sbuf(s.rdbuf()) { } 150 | istreambuf_iterator(streambuf_type* s) _UCXX_USE_NOEXCEPT : sbuf(s) { } 151 | istreambuf_iterator(const proxy& p) _UCXX_USE_NOEXCEPT : 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 | istreambuf_iterator 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) _UCXX_USE_NOEXCEPT : sbuf(s.rdbuf()), f(false) { } 200 | ostreambuf_iterator(streambuf_type* s) _UCXX_USE_NOEXCEPT : 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 _UCXX_USE_NOEXCEPT{ 215 | return f; 216 | } 217 | 218 | private: 219 | streambuf_type* sbuf; 220 | bool f; 221 | }; 222 | 223 | template< class C > 224 | auto begin( C& c ) -> decltype(c.begin()) { return c.begin(); } 225 | 226 | template< class C > 227 | auto end( C& c ) -> decltype(c.end()) { return c.end(); } 228 | 229 | } 230 | 231 | #pragma GCC visibility pop 232 | 233 | #endif 234 | 235 | 236 | --------------------------------------------------------------------------------