2 * (c) 2004-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
9 * As a special exception, you may use this file as part of a free software
10 * library without restriction. Specifically, if other files instantiate
11 * templates or use macros or inline functions from this file, or you compile
12 * this file and link it with other files to produce an executable, this
13 * file does not by itself cause the resulting executable to be covered by
14 * the GNU General Public License. This exception does not however
15 * invalidate any other reasons why the executable file might be covered by
16 * the GNU General Public License.
19 #include <l4/cxx/basic_ostream>
20 #include <l4/sys/kdebug.h>
21 #include <l4/sys/l4int.h>
22 #include <l4/util/atomic.h>
26 inline void *operator new (size_t, void *p) { return p; }
30 class KdbgIOBackend : public IOBackend
33 void write(char const *str, unsigned len);
36 void KdbgIOBackend::write(char const *str, unsigned len)
41 typedef char Fake_iobackend[sizeof(KdbgIOBackend)]
42 __attribute__((aligned(__alignof__(KdbgIOBackend))));
43 typedef char Fake_ostream[sizeof(BasicOStream)]
44 __attribute__((aligned(__alignof__(BasicOStream))));
49 static Fake_iobackend _iob;
53 static l4_umword_t _initialized;
54 if (l4util_xchg(&_initialized, 1) == 0)
56 KdbgIOBackend *iob = new (&_iob) KdbgIOBackend();
57 new (&cerr) BasicOStream(iob);
58 new (&cout) BasicOStream(iob);