update credits
[librepilot.git] / flight / libraries / mini_cpp.cpp
blob33a7f396b0884dccb4d6eed2be5304da5903c54f
1 /**
2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
4 * @{
6 * @file mini_cpp.cpp
7 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
8 * @brief CPP support methods
9 * @see The GNU Public License (GPL) Version 3
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include <pios.h>
30 // _init is called by __libc_init_array during invocation of static constructors
31 // __libc_init_array calls _init, which is defined in crti.o. _init calls functions that are in .init section.
32 // If you don't have meaningful stuff in .init section, just define an empty _init function.
33 extern "C" int _init(void)
35 return 0;
39 // operator new
40 void *operator new(size_t size) throw()
42 return pios_malloc(size);
45 // operator delete
46 void operator delete(void *p) throw()
48 pios_free(p);
51 // The function __aeabi_atexit() handles the static destructors. This can be empty
52 // because we have no operating system to return to, hence the static destructors
53 // will never be called.
54 extern "C" int __aeabi_atexit(__attribute__((unused)) void *object, __attribute__((unused)) void (*destructor)(void *), __attribute__((unused)) void *dso_handle)
56 return 0;
59 // see https://answers.launchpad.net/gcc-arm-embedded/+question/221105
60 // and https://answers.launchpad.net/gcc-arm-embedded/+question/224709
61 __extension__ typedef int __guard __attribute__((mode(__DI__)));
62 extern "C" int __cxa_atexit(void (*f)(void *), void *p, void *d);
63 extern "C" int __cxa_guard_acquire(__guard *);
64 extern "C" void __cxa_guard_release(__guard *);
65 extern "C" void __cxa_guard_abort(__guard *);
66 extern "C" void __cxa_pure_virtual(void);
68 int __cxa_guard_acquire(__attribute__((unused)) __guard *g)
70 return !*(char *)(g);
72 void __cxa_guard_release(__attribute__((unused)) __guard *g)
74 *(char *)g = 1;
76 void __cxa_guard_abort(__attribute__((unused)) __guard *) {};
77 void __cxa_pure_virtual(void)
79 while (1) {
83 int __cxa_atexit(__attribute__((unused)) void (*f)(void *), __attribute__((unused)) void *p, __attribute__((unused)) void *d)
85 return 0;
87 /**
88 * @}