Chameleon

Chameleon Commit Details

Date:2011-06-06 15:47:31 (8 years 4 months ago)
Author:Azimutz
Commit:979
Parents: 978
Message:Trunk updates... never mind revs!
Changes:
D/branches/azimutz/Chazi/i386/MakeInc.dir
R/branches/azimutz/Chazi/i386/modules/uClibc++ → /branches/azimutz/Chazi/i386/modules/uClibcxx
M/branches/azimutz/Chazi/i386/libsa/string.c
M/branches/azimutz/Chazi/i386/libsaio/biosfn.c
M/branches/azimutz/Chazi/Makefile
M/branches/azimutz/Chazi/i386/boot1/boot1he.s
M/branches/azimutz/Chazi/i386/libsa/memory.h
M/branches/azimutz/Chazi/i386/boot2/gui.c
M/branches/azimutz/Chazi/i386/libsa/zalloc.c
M/branches/azimutz/Chazi/i386/libsaio/saio_internal.h
M/branches/azimutz/Chazi/i386/modules/klibc/klibc.c
M/branches/azimutz/Chazi/i386/boot2/options.c
M/branches/azimutz/Chazi/i386/libsa/prf.c
M/branches/azimutz/Chazi/i386/libsaio/console.c
M/branches/azimutz/Chazi/i386/boot2/graphics.c
M/branches/azimutz/Chazi/i386/libsa/libsa.h
M/branches/azimutz/Chazi/i386/Makefile
M/branches/azimutz/Chazi/i386/libsa/printf.c
M/branches/azimutz/Chazi/Make.rules
M/branches/azimutz/Chazi/i386/modules/Cconfig

File differences

branches/azimutz/Chazi/i386/MakeInc.dir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#
# Common makefile targets.
#
# Define these variables (if desired) in directory makefiles:
#DIRS_NEEDED
#INSTALLDIR
#SRCROOT
#
ifneq "" "$(wildcard /bin/mkdirs)"
MKDIRS = /bin/mkdirs
else
MKDIRS = /bin/mkdir -p
endif
CPP = g++ -fno-exceptions -fno-rtti
# Toggle this as to whether you want a frame pointer (%ebp) to be used. It is
# invaluable for debugging the booter. For example using GDB attached to VMware.
# In fact, it's so invaluable that it's now the default. Not only that but the
# compiler seems to generate slightly smaller code and the real<->prot code
# clearly handles it appropriately so I have no idea why Apple omitted it.
#OMIT_FRAME_POINTER_CFLAG=-fomit-frame-pointer
OMIT_FRAME_POINTER_CFLAG=
installsrc:: $(SRCROOT)
cp $(ALLSRC) $(SRCROOT)
cd $(SRCROOT); chmod a-w $(ALLSRC)
install:: installhdrs
@if [ -z "$(RC_ARCHS)" -o -n "$(RC_i386)" ]; then \
$(MAKE) install_i386 OBJROOT=${OBJROOT}\
SYMROOT=${SYMROOT} DSTROOT=${DSTROOT}\
SRCROOT=${SRCROOT}; \
else\
echo i386 not selected - null build.;\
fi
install_i386:: all
installhdrs::
.SUFFIXES: .s .i .c .o .o32 .o64
.c.o32:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch i386 $< -o $(OBJROOT)/$*.o32 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
.c.o64:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch x86_64 $< -o $(OBJROOT)/$*.o64 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
.c.o .m.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o32: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch i386 $< -o $(OBJROOT)/$*.o32 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o64: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) -arch x86_64 $< -o $(OBJROOT)/$*.o64 \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
$(OBJROOT)/%.o: %.m
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c $(INC) $< -o $(OBJROOT)/$*.o \
-MD -dependency-file $(OBJROOT)/$*.d
md -u $(OBJROOT)/Makedep -f -d $(OBJROOT)/$*.d
#.s.o:
#cc $(INC) -E $< > $(OBJROOT)/$*.o2
#$(AS) -o $(OBJROOT)/$@ $(OBJROOT)/$*.o2
.s.o:
cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
boot2.o:
cc $(CPPFLAGS) -Wa,-n -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) boot2.s
$(OBJROOT)/%.o: %.s
cc $(CPPFLAGS) -c $(INC) -arch i386 -o $(OBJROOT)/$(@F) $<
$(DIRS_NEEDED) $(INSTALLDIR) $(SRCROOT):
$(MKDIRS) $@
branches/azimutz/Chazi/i386/libsaio/console.c
7171
7272
7373
74
74
75
7576
7677
7778
7879
7980
80
81
8182
8283
84
8385
8486
8587
......
122124
123125
124126
125
127
126128
127129
128130
129
130
131
132
131133
132134
133135
134136
135
137
136138
137139
138
140
141
142
139143
140144
141145
char * last_str;
};
static void sputc(int c, struct putc_info * pi) //Azi: same as above
static int
sputc(int c, struct putc_info * pi) //Azi: same as above
{
if (pi->last_str)
if (pi->str == pi->last_str)
{
*(pi->str) = '\0';
return;
return 0;
}
*(pi->str)++ = c;
return c;
}
void initBooterLog(void)
/*
* write one character to console
*/
void putchar(int c)
int putchar(int c)
{
if ( c == '\t' )
{
for (c = 0; c < 8; c++) putc(' ');
return;
for (c = 0; c < 8; c++) bios_putchar(' ');
return c;
}
if ( c == '\n' )
{
putc('\r');
bios_putchar('\r');
}
putc(c);
bios_putchar(c);
return c;
}
int getc()
branches/azimutz/Chazi/i386/libsaio/biosfn.c
450450
451451
452452
453
453
454454
455455
456456
return bb.eax.r.h;
}
void putc(int ch)
void bios_putchar(int ch)
{
bb.intno = 0x10;
bb.ebx.r.h = 0x00; /* background black */
branches/azimutz/Chazi/i386/libsaio/saio_internal.h
4747
4848
4949
50
50
5151
5252
5353
......
9292
9393
9494
95
95
9696
9797
9898
extern int ebioswrite(int dev, long sec, int count);
extern int get_drive_info(int drive, struct driveInfo *dp);
extern int ebiosEjectMedia(int biosdev);
extern void putc(int ch);
extern void bios_putchar(int ch);
extern void putca(int ch, int attr, int repeat);
extern int getc(void);
extern void pause();
extern bool gErrors;
extern void initBooterLog(void);
extern void setupBooterLog(void);
extern void putchar(int ch);
extern int putchar(int ch);
extern int getchar(void);
extern void msglog(const char * format, ...);
extern int printf(const char *format, ...);
branches/azimutz/Chazi/i386/boot1/boot1he.s
542542
543543
544544
545
546
547545
548546
549547
......
637635
638636
639637
638
639
640640
641641
642642
hlt
jmp hang
%if VERBOSE
;--------------------------------------------------------------------------
; readLBA - Read sectors from a partition using LBA addressing.
;
popad
ret
%if VERBOSE
;--------------------------------------------------------------------------
; Write a string with 'boot1: ' prefix to the console.
;
branches/azimutz/Chazi/i386/boot2/graphics.c
12391239
12401240
12411241
1242
1243
1242
1243
12441244
12451245
12461246
......
12491249
12501250
12511251
1252
1253
1252
1253
12541254
12551255
12561256
{
currentIndicator = 0;
}
putc(indicator[currentIndicator++]);
putc('\b');
putchar(indicator[currentIndicator++]);
putchar('\b');
}
}
{
if ( getVideoMode() == VGA_TEXT_MODE )
{
putc(' ');
putc('\b');
putchar(' ');
putchar('\b');
}
}
branches/azimutz/Chazi/i386/boot2/gui.c
10841084
10851085
10861086
1087
1087
10881088
10891089
10901090
10911091
1092
1093
1092
1093
10941094
10951095
10961096
10971097
1098
1098
10991099
11001100
1101
11011102
11021103
11031104
}
}
struct putc_info {
struct putc_info { //Azi: exists on console.c & printf.c
char * str;
char * last_str;
};
static void
sputc(int c, struct putc_info * pi)
static int
sputc(int c, struct putc_info * pi) // same as above
{
if (pi->last_str)
if (pi->str == pi->last_str) {
*(pi->str) = '\0';
return;
return 0;
}
*(pi->str)++ = c;
return c;
}
int gprintf( window_t * window, const char * fmt, ...)
branches/azimutz/Chazi/i386/boot2/options.c
15981598
15991599
16001600
1601
1601
16021602
16031603
16041604
default:
if (isxdigit(key & kASCIIKeyMask) && digitsI < 2) {
putc(key & kASCIIKeyMask);
putchar(key & kASCIIKeyMask);
digits[digitsI++] = key & kASCIIKeyMask;
} else {
// TODO: Beep or something
branches/azimutz/Chazi/i386/modules/uClibcxx/exception.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <exception>
#include <func_exception>
#include <stdexcept>
#include <cstdlib>
//We can't do this yet because gcc is too stupid to be able to handle
//different implementations of exception class.
//#undef __UCLIBCXX_EXCEPTION_SUPPORT__
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
namespace std{
_UCXXEXPORT static const char * __std_exception_what_value = "exception";
//We are providing our own versions to be sneaky
_UCXXEXPORT exception::~exception() throw(){
//Empty function
}
_UCXXEXPORT const char* exception::what() const throw(){
return __std_exception_what_value;
}
_UCXXEXPORT bad_exception::~bad_exception() throw(){
}
}
#else
namespace std{
_UCXXEXPORT exception::~exception() {
abort();
}
_UCXXEXPORT const char* exception::what() const {
abort();
}
_UCXXEXPORT bad_exception::~bad_exception() {
abort();
}
}
#endif
void
std::terminate()
{
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
try
{
#endif // __UCLIBCXX_EXCEPTION_SUPPORT__
(*std::terminate_handler())();
// handler should not return
abort ();
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
}
catch (...)
{
// handler should not throw exception
abort ();
}
#endif // __UCLIBCXX_EXCEPTION_SUPPORT__
}
branches/azimutz/Chazi/i386/modules/uClibcxx/locale.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <locale>
#include <cstring>
#include <string>
#include <stdexcept>
#include <cctype>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/eh_globals.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*Copyright (C) 2006 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, version 2.1
of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cstdlib>
#include <cstring>
#include <func_exception>
//This is a system-specific header which does all of the error-handling management
#include <unwind-cxx.h>
//The following functionality is derived from reading of the GNU libstdc++ code and making it...simple
namespace __cxxabiv1{
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
static __UCLIBCXX_TLS __cxa_eh_globals eh_globals;
extern "C" __cxa_eh_globals* __cxa_get_globals() throw(){
return &eh_globals;
}
extern "C" __cxa_eh_globals* __cxa_get_globals_fast() throw(){
return &eh_globals;
}
#endif
}
branches/azimutz/Chazi/i386/modules/uClibcxx/del_op.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <new>
#include <cstdlib>
#include <func_exception>
_UCXXEXPORT void operator delete(void* ptr) throw(){
free(ptr);
}
branches/azimutz/Chazi/i386/modules/uClibcxx/numeric.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <numeric>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/vector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define __UCLIBCXX_COMPILE_VECTOR__ 1
#include <vector>
namespace std{
#ifdef __UCLIBCXX_EXPAND_VECTOR_BASIC__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT vector<char, allocator<char> >::vector(const allocator<char>& al);
template _UCXXEXPORT vector<char, allocator<char> >::vector(size_type n, const char & value, const allocator<char> & al);
template _UCXXEXPORT vector<char, allocator<char> >::~vector();
template _UCXXEXPORT vector<unsigned char, allocator<unsigned char> >::~vector();
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT void vector<char, allocator<char> >::reserve(size_type n);
template _UCXXEXPORT void vector<unsigned char, allocator<unsigned char> >::reserve(size_type n);
template _UCXXEXPORT void vector<short int, allocator<short int> >::reserve(size_type n);
template _UCXXEXPORT void vector<unsigned short int, allocator<unsigned short int> >::reserve(size_type n);
template _UCXXEXPORT void vector<int, allocator<int> >::reserve(size_type n);
template _UCXXEXPORT void vector<unsigned int, allocator<unsigned int> >::reserve(size_type n);
template _UCXXEXPORT void vector<long int, allocator<long int> >::reserve(size_type n);
template _UCXXEXPORT void vector<unsigned long int, allocator<unsigned long int> >::reserve(size_type n);
template _UCXXEXPORT void vector<float, allocator<float> >::reserve(size_type n);
template _UCXXEXPORT void vector<double, allocator<double> >::reserve(size_type n);
template _UCXXEXPORT void vector<bool, allocator<bool> >::reserve(size_type n);
template _UCXXEXPORT void vector<char, allocator<char> >::resize(size_type sz, const char & c);
template _UCXXEXPORT void vector<unsigned char, allocator<unsigned char> >::resize(size_type sz, const unsigned char & c);
template _UCXXEXPORT void vector<short int, allocator<short int> >::resize(size_type sz, const short & c);
template _UCXXEXPORT void vector<unsigned short int, allocator<unsigned short int> >
::resize(size_type sz, const unsigned short int & c);
template _UCXXEXPORT void vector<int, allocator<int> >::resize(size_type sz, const int & c);
template _UCXXEXPORT void vector<unsigned int, allocator<unsigned int> >::resize(size_type sz, const unsigned int & c);
template _UCXXEXPORT void vector<long int, allocator<long int> >::resize(size_type sz, const long int & c);
template _UCXXEXPORT void vector<unsigned long int, allocator<unsigned long int> >::
resize(size_type sz, const unsigned long int & c);
template _UCXXEXPORT void vector<float, allocator<float> >::resize(size_type sz, const float & c);
template _UCXXEXPORT void vector<double, allocator<double> >::resize(size_type sz, const double & c);
template _UCXXEXPORT void vector<bool, allocator<bool> >::resize(size_type sz, const bool & c);
#elif defined __UCLIBCXX_EXPAND_STRING_CHAR__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT vector<char, allocator<char> >::vector(const allocator<char>& al);
template _UCXXEXPORT vector<char, allocator<char> >::vector(size_type n, const char & value, const allocator<char> & al);
template _UCXXEXPORT vector<char, allocator<char> >::~vector();
#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT void vector<char, allocator<char> >::reserve(size_type n);
template _UCXXEXPORT void vector<char, allocator<char> >::resize(size_type sz, const char & c);
#endif
}
branches/azimutz/Chazi/i386/modules/uClibcxx/deque.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <deque>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/stdexcept.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <exception>
#include <stdexcept>
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
namespace std{
_UCXXEXPORT logic_error::logic_error() throw() : mstring(){
}
_UCXXEXPORT logic_error::logic_error(const string& what_arg) : mstring(what_arg){
}
_UCXXEXPORT const char * logic_error::what() const throw(){
return mstring.c_str();
}
_UCXXEXPORT out_of_range::out_of_range() : logic_error(){
}
_UCXXEXPORT out_of_range::out_of_range(const string & what_arg) : logic_error(what_arg) {
}
_UCXXEXPORT runtime_error::runtime_error() : mstring(){
}
_UCXXEXPORT runtime_error::runtime_error(const string& what_arg) : mstring(what_arg){
}
_UCXXEXPORT const char * runtime_error::what() const throw(){
return mstring.c_str();
}
}
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/utility.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <utility>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/eh_alloc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*Copyright (C) 2006 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, version 2.1
of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cstdlib>
#include <cstring>
#include <func_exception>
//This is a system-specific header which does all of the error-handling management
#include <unwind-cxx.h>
namespace __cxxabiv1{
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(){
void *retval;
//The sizeof crap is required by Itanium ABI because we need to provide space for
//accounting information which is implementaion (gcc) specified
retval = malloc (thrown_size + sizeof(__cxa_exception));
if(0 == retval){
std::terminate();
}
memset (retval, 0, sizeof(__cxa_exception));
return (void *)((unsigned char *)retval + sizeof(__cxa_exception));
}
extern "C" void __cxa_free_exception(void *vptr) throw(){
free( (char *)(vptr) - sizeof(__cxa_exception) );
}
#endif
}
branches/azimutz/Chazi/i386/modules/uClibcxx/list.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <list>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/map.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <map>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/new_opvnt.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <new>
#include <cstdlib>
#include <func_exception>
extern "C" {
#include "libsaio.h"
};
#ifndef NO_NOTHROW
_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) throw(){
return malloc(numBytes);
}
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/queue.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <queue>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/del_opv.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <new>
#include <cstdlib>
#include <func_exception>
_UCXXEXPORT void operator delete[](void * ptr) throw(){
free(ptr);
}
branches/azimutz/Chazi/i386/modules/uClibcxx/streambuf.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define __UCLIBCXX_COMPILE_STREAMBUF__ 1
#include <streambuf>
namespace std{
#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT streambuf::basic_streambuf();
template _UCXXEXPORT streambuf::~basic_streambuf();
#endif
template _UCXXEXPORT locale streambuf::pubimbue(const locale &loc);
template _UCXXEXPORT streamsize streambuf::in_avail();
template _UCXXEXPORT streambuf::int_type streambuf::sbumpc();
template _UCXXEXPORT streambuf::int_type streambuf::snextc();
template _UCXXEXPORT streambuf::int_type streambuf::sgetc();
template _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c);
template _UCXXEXPORT streambuf::int_type streambuf::sungetc();
template _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c);
#endif
}
branches/azimutz/Chazi/i386/modules/uClibcxx/iterator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <iterator>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/new_opnt.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <new>
#include <cstdlib>
#include <func_exception>
extern "C" {
#include "libsaio.h"
};
#ifndef NO_NOTHROW
_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) throw(){
return malloc(numBytes);
}
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/bitset.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <bitset>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/Readme.txt
1
2
3
4
Module:uClibc++
Source: http://cxx.uclibc.org/
Description: This module provides a minimalistic c++ runtime library for use in other modules. This does not provide functionality by itself, instead it is used to allow for the c++ language to be used in other modules. Please note that rtti and exceptions has both been disabled.
Dependencies: klibc
branches/azimutz/Chazi/i386/modules/uClibcxx/ios.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define __UCLIBCXX_COMPILE_IOS__ 1
#include <ios>
#include <ostream>
#include <istream>
#include <cstdio>
#include <fstream>
namespace std{
#ifdef __UCLIBCXX_SUPPORT_CDIR__
_UCXXLOCAL int ios_base::Init::init_cnt = 0;//Needed to ensure the static value is created
//Create buffers first
#if __UCLIBCXX_SUPPORT_COUT__
_UCXXEXPORT filebuf _cout_filebuf;
#endif
#if __UCLIBCXX_SUPPORT_CIN__
_UCXXEXPORT filebuf _cin_filebuf;
#endif
#if __UCLIBCXX_SUPPORT_CERR__
_UCXXEXPORT filebuf _cerr_filebuf;
#endif
#if __UCLIBCXX_SUPPORT_CLOG__
_UCXXEXPORT filebuf _clog_filebuf;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
_UCXXEXPORT wfilebuf _wcout_filebuf;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCIN__
_UCXXEXPORT wfilebuf _wcin_filebuf;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCERR__
_UCXXEXPORT wfilebuf _wcerr_filebuf;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
_UCXXEXPORT wfilebuf _wclog_filebuf;
#endif
//Then create streams
#if __UCLIBCXX_SUPPORT_COUT__
_UCXXEXPORT ostream cout(&_cout_filebuf);
#endif
#if __UCLIBCXX_SUPPORT_CIN__
_UCXXEXPORT istream cin(&_cin_filebuf);
#endif
#if __UCLIBCXX_SUPPORT_CERR__
_UCXXEXPORT ostream cerr(&_cerr_filebuf);
#endif
#if __UCLIBCXX_SUPPORT_CLOG__
_UCXXEXPORT ostream clog(&_clog_filebuf);
#endif
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
_UCXXEXPORT wostream wcout(&_wcout_filebuf);
#endif
#ifdef __UCLIBCXX_SUPPORT_WCIN__
_UCXXEXPORT wistream wcin(&_wcin_filebuf);
#endif
#ifdef __UCLIBCXX_SUPPORT_WCERR__
_UCXXEXPORT wostream wcerr(&_wcerr_filebuf);
#endif
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
_UCXXEXPORT wostream wclog(&_wclog_filebuf);
#endif
_UCXXEXPORT ios_base::Init::Init(){
if(init_cnt == 0){//Need to construct cout et al
#if __UCLIBCXX_SUPPORT_COUT__
_cout_filebuf.fp = stdout;
_cout_filebuf.openedFor = ios_base::out;
#endif
#if __UCLIBCXX_SUPPORT_CERR__
_cerr_filebuf.fp = stderr;
_cerr_filebuf.openedFor = ios_base::out;
cerr.mformat |= ios_base::unitbuf;
#endif
#if __UCLIBCXX_SUPPORT_CLOG__
_clog_filebuf.fp = stderr;
_clog_filebuf.openedFor = ios_base::out;
#endif
#if __UCLIBCXX_SUPPORT_CIN__
_cin_filebuf.fp = stdin;
_cin_filebuf.openedFor = ios_base::in;
#if __UCLIBCXX_SUPPORT_COUT__
cin.tie(&cout);
#endif
#endif
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
_wcout_filebuf.fp = stdout;
_wcout_filebuf.openedFor = ios_base::out;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCERR__
_wcerr_filebuf.fp = stderr;
_wcerr_filebuf.openedFor = ios_base::out;
wcerr.mformat |= ios_base::unitbuf;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
_wclog_filebuf.fp = stderr;
_wclog_filebuf.openedFor = ios_base::out;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCIN__
_wcin_filebuf.fp = stdin;
_wcin_filebuf.openedFor = ios_base::in;
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
wcin.tie(&wcout);
#endif
#endif
}
init_cnt++;
}
_UCXXEXPORT ios_base::Init::~Init(){
--init_cnt;
if(init_cnt==0){
}
}
#endif
#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__
template _UCXXEXPORT void basic_ios<char, char_traits<char> >::clear(iostate state);
template _UCXXEXPORT void basic_ios<char, char_traits<char> >::setstate(iostate state);
#endif
_UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){
fmtflags temp = mformat;
mformat = fmtfl;
return temp;
}
_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){
return flags(flags() | fmtfl);
}
_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){
return flags( (flags()& ~mask) | (fmtfl & mask));
}
_UCXXEXPORT streamsize ios_base::precision(streamsize prec){
streamsize temp = mprecision;
mprecision = prec;
return temp;
}
_UCXXEXPORT streamsize ios_base::width(streamsize wide){
streamsize temp = mwidth;
mwidth = wide;
return temp;
}
_UCXXEXPORT locale ios_base::imbue(const locale& loc){
locale retval = mLocale;
mLocale = loc;
return retval;
}
}
branches/azimutz/Chazi/i386/modules/uClibcxx/set.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <set>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/abi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc C++ Library. This library is free
software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this library; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
*/
#include <cstdlib>
#include <typeinfo>
#include <basic_definitions>
/* This file implements a number of the language support features
* needed to deal with the C++ abi, as originally documented in the
* Itanium C++ ABI, though now industry standard
*/
extern "C" {
/* This function is called in the event that a non-overidden
* pure virtual function is called. The compiler should never
* let that happen. We get to choose what to do - we will abort
*/
void __cxa_pure_virtual (){
abort();
}
}
branches/azimutz/Chazi/i386/modules/uClibcxx/Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
MODULE_NAME = uClibc++
MODULE_VERSION = "0.2.2"
MODULE_COMPAT_VERSION = "0.2.2"
MODULE_START = _uClibcxx_start
MODULE_DEPENDENCIES = klibc
DIR = uClibc++
# sstream.o fstream.o
MODULE_OBJS = uClibc++.o abi.o algorithm.o associative_base.o bitset.o \
complex.o del_op.o del_opnt.o del_opv.o del_opvnt.o \
deque.o eh_alloc.o eh_globals.o exception.o \
func_exception.o iomanip.o char_traits.o \
iterator.o limits.o list.o locale.o \
map.o new_handler.o new_op.o new_opnt.o new_opv.o \
new_opvnt.o numeric.o queue.o set.o \
stack.o stdexcept.o streambuf.o string.o typeinfo.o \
utility.o valarray.o vector.o support.o \
ios.o iostream.o istream.o ostream.o
OPTIM = -Os -Oz
DEBUG = -DNOTHING
#DEBUG = -DDEBUG_HELLO_WORLD=1
CFLAGS= $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \
-D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \
-DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \
-fno-builtin $(OMIT_FRAME_POINTER_CFLAG) \
-mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \
-march=pentium4 -msse2 -mfpmath=sse -msoft-float -fno-common
DEFINES=
CONFIG = hd
INC = -I. -I.. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(BOOT2DIR) -Iinclude
ifneq "" "$(wildcard /bin/mkdirs)"
MKDIRS = /bin/mkdirs
else
MKDIRS = /bin/mkdir -p
endif
AS = as
LD = ld
# LIBS= -lc_static
LIBS=
VPATH = $(OBJROOT):$(SYMROOT)
SFILES =
CFILES =
HFILES =
EXPORTED_HFILES =
INSTALLED_HFILES =
OTHERFILES = Makefile
ALLSRC = $(SFILES) $(CFILES) \
$(HFILES) $(OTHERFILES)
DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
all embedtheme: dylib
include ../MakeInc.dir
branches/azimutz/Chazi/i386/modules/uClibcxx/fstream.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define __UCLIBCXX_COMPILE_FSTREAM__ 1
#include <fstream>
namespace std{
#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT filebuf::basic_filebuf();
template _UCXXEXPORT filebuf::~basic_filebuf();
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT filebuf::int_type filebuf::pbackfail(filebuf::int_type c);
template _UCXXEXPORT filebuf * filebuf::open(const char* s, ios_base::openmode mode);
template _UCXXEXPORT filebuf * filebuf::close();
template _UCXXEXPORT filebuf::int_type filebuf::overflow(filebuf::int_type);
template _UCXXEXPORT filebuf::int_type filebuf::underflow ();
template _UCXXEXPORT streamsize filebuf::xsputn(const char* s, streamsize n);
template _UCXXEXPORT basic_streambuf<char, char_traits<char> >*
filebuf::setbuf(char * s, streamsize n);
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT basic_ofstream<char, char_traits<char> >::basic_ofstream();
template _UCXXEXPORT basic_ofstream<char, char_traits<char> >::basic_ofstream(const char* s, ios_base::openmode mode);
template _UCXXEXPORT basic_ofstream<char, char_traits<char> >::~basic_ofstream();
template _UCXXEXPORT basic_ifstream<char, char_traits<char> >::basic_ifstream();
template _UCXXEXPORT basic_ifstream<char, char_traits<char> >::basic_ifstream(const char* s, ios_base::openmode mode);
template _UCXXEXPORT basic_ifstream<char, char_traits<char> >::~basic_ifstream();
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
#endif
#ifdef __UCLIBCXX_HAS_WCHAR__
template <> _UCXXEXPORT basic_filebuf<wchar_t, char_traits<wchar_t> >::int_type
basic_filebuf<wchar_t, char_traits<wchar_t> >::overflow(int_type c)
{
typedef basic_streambuf<wchar_t, char_traits<wchar_t> > wstreambuf;
typedef char_traits<wchar_t> wtraits;
if(is_open() == false){
//Can't do much
return wtraits::eof();
}
mbstate_t ps = { 0 };
char out_array[8];
size_t out_size;
if( wstreambuf::pbase() != 0 ){
//Write all possible character from the existing array first
size_t chars_written = 0;
while(wstreambuf::pbase() && (wstreambuf::pbase() + chars_written !=wstreambuf::pptr()) ){
out_size = wcrtomb(out_array, wstreambuf::pbase()[chars_written], &ps);
if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){
break;
}
++chars_written;
}
if( wstreambuf::pbase() + chars_written == wstreambuf::pptr() ){
wstreambuf::pbump(-chars_written);
}else{
//Shuffle data back into order
size_t chars_left = wstreambuf::pptr() - wstreambuf::pbase() - chars_written;
for(size_t i = 0; i < chars_left; ++i){
wstreambuf::pbase()[i] = (wstreambuf::pptr() - chars_written)[i];
}
return wtraits::eof();
}
}
if( !wtraits::eq_int_type(c, wtraits::eof()) ){
out_size = wcrtomb(out_array, c, &ps);
if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){
return wtraits::eof();
}
return c;
}
return wtraits::not_eof(c);
}
template <> _UCXXEXPORT basic_filebuf<wchar_t, char_traits<wchar_t> >::int_type
basic_filebuf<wchar_t, char_traits<wchar_t> >::underflow()
{
/*Some variables used internally:
Buffer pointers:
charT * mgbeg;
charT * mgnext;
charT * mgend;
eback() returns mgbeg
gptr() returns mgnext
egptr() returns mgend
gbump(int n) mgnext+=n
*/
typedef char_traits<wchar_t> traits;
typedef basic_streambuf<wchar_t, traits> wstreambuf;
if(wstreambuf::eback() == wstreambuf::gptr() && 0 != wstreambuf::eback()){//Buffer is full
return traits::to_int_type(*wstreambuf::gptr());
}
size_t in_size;
wchar_t c = 0;
wint_t wi = 0;
in_size = 0;
wi = fgetwc(fp);
if(WEOF == wi){
fprintf(stderr, "WEOF returned by fgetwc\n");
return traits::eof();
}
c = traits::to_char_type(wi);
if(wstreambuf::eback() == 0){
return traits::to_int_type(c);
}
for(wchar_t * i = wstreambuf::gptr(); i < wstreambuf::egptr(); ++i){
*(i-1) = *i;
}
*(wstreambuf::egptr()-1) = c;
wstreambuf::mgnext -= 1;
return traits::to_int_type(*wstreambuf::gptr());
}
#endif // __UCLIBCXX_HAS_WCHAR__
}
branches/azimutz/Chazi/i386/modules/uClibcxx/limits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*Copyright (C) 2006 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <limits>
namespace std{
}
branches/azimutz/Chazi/i386/modules/uClibcxx/include/iostream
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#ifndef __HEADER_STD_IOSTREAM
#define __HEADER_STD_IOSTREAM 1
#include <iosfwd>
#include <ios>
#include <istream>
#include <ostream>
#include <fstream>
#include <string_iostream>
#pragma GCC visibility push(default)
namespace std{
#ifdef __UCLIBCXX_SUPPORT_CIN__
extern istream cin;
#endif
#ifdef __UCLIBCXX_SUPPORT_COUT__
extern ostream cout;
#endif
#ifdef __UCLIBCXX_SUPPORT_CERR__
extern ostream cerr;
#endif
#ifdef __UCLIBCXX_SUPPORT_CLOG__
extern ostream clog;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCIN__
extern wistream wcin;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
extern wostream wcout;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCERR__
extern wostream wcerr;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
extern wostream wclog;
#endif
template <class charT, class traits> class _UCXXEXPORT basic_iostream :
public basic_istream<charT,traits>, public basic_ostream<charT,traits>
{
public:
// constructor/destructor
explicit _UCXXEXPORT basic_iostream(basic_streambuf<charT,traits>* sb);
virtual _UCXXEXPORT ~basic_iostream();//Below
};
template <class charT, class traits> _UCXXEXPORT
basic_iostream<charT, traits>:: basic_iostream(basic_streambuf<charT,traits>* sb)
: basic_ios<charT, traits>(sb), basic_istream<charT,traits>(sb), basic_ostream<charT,traits>(sb)
{
return;
}
template <class charT, class traits> _UCXXEXPORT basic_iostream<charT, traits>::~basic_iostream(){
return;
}
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
#ifndef __UCLIBCXX_COMPILE_IOSTREAM__
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::
basic_iostream(basic_streambuf<char, char_traits<char> >* sb);
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::~basic_iostream();
#endif
#endif
#endif
}
#pragma GCC visibility pop
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/cstdio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*Copyright (C) 2006 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation version 2.1
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <basic_definitions>
#ifndef __HEADER_CSTDIO
#define __HEADER_CSTDIO 1
namespace std{
using ::FILE;
using ::fpos_t;
using ::clearerr;
using ::fclose;
using ::feof;
using ::ferror;
using ::fflush;
using ::fgetc;
using ::fgetpos;
using ::fgets;
using ::fopen;
using ::fprintf;
using ::fputc;
using ::fputs;
using ::fread;
using ::freopen;
using ::fscanf;
using ::fseek;
using ::fsetpos;
using ::ftell;
using ::fwrite;
using ::getc;
using ::getchar;
using ::gets;
using ::perror;
using ::printf;
using ::putc;
using ::putchar;
using ::puts;
using ::remove;
using ::rename;
using ::rewind;
using ::scanf;
using ::setbuf;
using ::setvbuf;
using ::sprintf;
using ::sscanf;
using ::tmpfile;
using ::tmpnam;
using ::ungetc;
using ::vfprintf;
using ::vprintf;
using ::vsprintf;
}
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/cstdarg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// -*- C++ -*- forwarding header.
// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// ISO C++ 14882: 20.4.6 C library
//
/** @file cstdarg
* This is a Standard C++ Library file. You should @c #include this file
* in your programs, rather than any of the "*.h" implementation files.
*
* This is the C++ version of the Standard C Library header @c stdarg.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std.
*/
#ifndef _CPP_CSTDARG
#define _CPP_CSTDARG 1
#pragma GCC system_header
#include <stdarg.h>
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef va_end
#define va_end(ap) va_end (ap)
#endif
namespace std
{
using ::va_list;
}
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/map.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include<memory>
#include<utility>
#include<iterator>
#include <deque>
#include<functional>
#ifndef __STD_HEADER_MAP
#define __STD_HEADER_MAP
#pragma GCC visibility push(default)
namespace std{
template<class Key, class T, class Compare = less<Key>, class Allocator = allocator<T> > class __base_map;
template<class Key, class T, class Compare = less<Key>, class Allocator = allocator<T> > class map;
template<class Key, class T, class Compare = less<Key>, class Allocator = allocator<T> > class multimap;
template<class Key, class T, class Compare, class Allocator> class __map_iter;
template<class Key, class T, class Compare, class Allocator> class __map_citer;
/* The code for the map containers is split up into two classes.
* The first class, __base_map holds all of the data and does much of the iterator-based
* work. Then the classes map and multimap inherit from there. This was done to reduce
* the redundancy of code (And thus errors which might crop up), as well as possibly
* reducing the size of binaries if both map and multimap are used, along with the same
* template parameters.
*/
//All base classes first (__base_map, iterators, value_compare) and it's associated code
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT __base_map{
protected:
friend class __map_iter<Key, T, Compare, Allocator>;
friend class __map_citer<Key, T, Compare, Allocator>;
public:
typedef __base_map<Key,T,Compare,Allocator>map_type;
typedef Keykey_type;
typedef Tmapped_type;
typedef pair<Key, T>value_type;
typedef Comparekey_compare;
typedef Allocatorallocator_type;
typedef typename Allocator::referencereference;
typedef typename Allocator::const_referenceconst_reference;
typedef __map_iter<Key, T, Compare, Allocator>iterator;
typedef __map_citer<Key, T, Compare, Allocator>const_iterator;
typedef typename Allocator::size_typesize_type;
typedef typename Allocator::difference_typedifference_type;
typedef typename Allocator::pointerpointer;
typedef typename Allocator::const_pointerconst_pointer;
typedef typename std::reverse_iterator<iterator>reverse_iterator;
typedef typename std::reverse_iterator<const_iterator>const_reverse_iterator;
class value_compare;
explicit __base_map(const Compare& comp = Compare(), const Allocator& al = Allocator());
__base_map(const map_type& x);
~__base_map();
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
iterator lower_bound(const key_type& x);
const_iterator lower_bound(const key_type& x) const;
void swap(map_type & x);
void clear();
key_compare key_comp() const;
//value_compare value_comp() const;
protected:
deque<pair<Key, T>, allocator<pair<Key, T> > > data;
Compare c;
};
//Implementations
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT __map_citer
: public std::iterator<
bidirectional_iterator_tag,
std::pair<Key, T>,
typename Allocator::difference_type,
std::pair<Key, T>*,
std::pair<Key, T>&
>
{
protected:
typedef __base_map<Key, T, Compare, Allocator> Map;
friend class __base_map<Key, T, Compare, Allocator>;
friend class __base_map<Key, T, Compare, Allocator>::iterator;
friend class map<Key, T, Compare, Allocator>;
friend class multimap<Key, T, Compare, Allocator>;
typename Map::size_type element;
const Map * container;
public:
__map_citer() : element(0), container(0) { }
__map_citer(const typename Map::const_iterator & m)
: element(m.element), container(m.container) { }
__map_citer(typename Map::size_type e, const Map * const c)
: element(e), container(c) { }
~__map_citer() { }
typename Map::value_type operator*() const{
return container->data[element];
}
const typename Map::value_type * operator->() const{
return &(container->data[element]);
}
__map_citer & operator=(const typename Map::const_iterator & m){
element = m.element;
container = m.container;
return *this;
}
bool operator==(const typename Map::const_iterator & m) const {
return (m.element == element && m.container == container);
}
bool operator!=(const typename Map::const_iterator & m) const {
return (m.element != element || m.container != container);
}
__map_citer & operator++(){
++element;
return *this;
}
__map_citer operator++(int){
__map_citer temp(*this);
++element;
return temp;
}
__map_citer & operator--(){
--element;
return *this;
}
__map_citer operator--(int){
__map_citer temp(*this);
--element;
return temp;
}
};
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT __map_iter
: public std::iterator<
bidirectional_iterator_tag,
std::pair<Key, T>,
typename Allocator::difference_type,
std::pair<Key, T>*,
std::pair<Key, T>&
>
{
protected:
typedef class __base_map<Key, T, Compare, Allocator> Map;
//FIXME - Find a way to use template parameters or something. This will do for now
friend class __base_map<Key, T, Compare, Allocator>;
friend class __base_map<Key, T, Compare, Allocator>::const_iterator;
friend class map<Key, T, Compare, Allocator>;
friend class multimap<Key, T, Compare, Allocator>;
typename Map::size_type element;
Map * container;
public:
__map_iter() : element(0), container(0) { }
__map_iter(const typename Map::iterator & m)
: element(m.element), container(m.container) { }
__map_iter(typename Map::size_type e, Map * c)
: element(e), container(c) { }
~__map_iter() { }
typename Map::value_type & operator*(){
return container->data[element];
}
const typename Map::value_type & operator*() const{
return container->data[element];
}
typename Map::value_type * operator->(){
return &(container->data[element]);
}
__map_iter & operator=(const typename Map::iterator & m){
element = m.element;
container = m.container;
return *this;
}
bool operator==(const typename Map::iterator & m) const {
return (m.element == element && m.container == container);
}
bool operator!=(const typename Map::iterator & m) const {
return (m.element != element || m.container != container);
}
bool operator==(const typename Map::const_iterator & m) const {
return (m.element == element && m.container == container);
}
bool operator!=(const typename Map::const_iterator & m) const {
return (m.element != element || m.container != container);
}
__map_iter & operator++(){
++element;
return *this;
}
__map_iter operator++(int){
__map_iter temp(*this);
++element;
return temp;
}
__map_iter & operator--(){
--element;
return *this;
}
__map_iter operator--(int){
__map_iter temp(*this);
--element;
return temp;
}
operator typename Map::const_iterator() const{
return typename Map::const_iterator(element, container);
}
};
//Compare the keys of the two items
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT
__base_map<Key, T, Compare, Allocator>::value_compare : public binary_function<
typename map<Key, T, Compare, Allocator>::value_type,
typename map<Key, T, Compare, Allocator>::value_type,
bool>
{
friend class __base_map<Key, T, Compare, Allocator>;
protected:
Compare comp;
value_compare(Compare c) : comp(c) { }
~value_compare() { }
public:
bool operator()(const value_type& x, const value_type& y) const {
return comp(x.first, y.first);
}
};
template <class Key, class T, class Compare, class Allocator>
__base_map<Key, T, Compare, Allocator>::__base_map(const Compare& comp, const Allocator&)
: data(), c(comp)
{
}
template <class Key, class T, class Compare, class Allocator>
__base_map<Key, T, Compare, Allocator>::__base_map(const __base_map<Key,T,Compare,Allocator>& x)
: data(x.data), c(x.c)
{
}
template <class Key, class T, class Compare, class Allocator>
__base_map<Key, T, Compare, Allocator>::~__base_map()
{
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::iterator
__base_map<Key, T, Compare, Allocator>::begin()
{
return iterator(0, this);
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::const_iterator
__base_map<Key, T, Compare, Allocator>::begin() const
{
return const_iterator(0, this);
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::iterator
__base_map<Key, T, Compare, Allocator>::end()
{
return iterator(data.size(), this);
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::const_iterator
__base_map<Key, T, Compare, Allocator>::end() const
{
return const_iterator(data.size(), this);
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::reverse_iterator
__base_map<Key, T, Compare, Allocator>::rbegin()
{
return reverse_iterator(end());
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::const_reverse_iterator
__base_map<Key, T, Compare, Allocator>::rbegin() const
{
return const_reverse_iterator(end());
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::reverse_iterator
__base_map<Key, T, Compare, Allocator>::rend()
{
return reverse_iterator(begin());
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::const_reverse_iterator
__base_map<Key, T, Compare, Allocator>::rend() const
{
return const_reverse_iterator(begin());
}
template <class Key, class T, class Compare, class Allocator>
bool __base_map<Key, T, Compare, Allocator>::empty() const
{
return (data.size() == 0);
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::size_type
__base_map<Key, T, Compare, Allocator>::size() const
{
return data.size();
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::size_type
__base_map<Key, T, Compare, Allocator>::max_size() const
{
return data.max_size();
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::iterator
__base_map<Key, T, Compare, Allocator>::lower_bound(const key_type &x)
{
size_type low = 0;
size_type high = data.size();
while (low < high) {
size_type i = (low + high) / 2;
if( c(data[i].first, x) ){
low = i + 1;
}else{
high = i;
}
}
return iterator(low, this);
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::const_iterator
__base_map<Key, T, Compare, Allocator>::lower_bound(const key_type &x) const
{
size_type low = 0;
size_type high = data.size();
while (low < high) {
size_type i = (low + high) / 2;
if( c(data[i].first, x) ){
low = i + 1;
}else{
high = i;
}
}
return const_iterator(low, this);
}
template <class Key, class T, class Compare, class Allocator>
void __base_map<Key, T, Compare, Allocator>::swap(__base_map<Key,T,Compare,Allocator>& m)
{
Compare n = c;
c = m.c;
m.c = n;
data.swap(m.data);
}
template <class Key, class T, class Compare, class Allocator>
void __base_map<Key, T, Compare, Allocator>::clear()
{
data.clear();
}
template <class Key, class T, class Compare, class Allocator>
typename __base_map<Key, T, Compare, Allocator>::key_compare
__base_map<Key, T, Compare, Allocator>::key_comp() const
{
return c;
}
//value_compare value_comp() const;
/* This is the implementation for the map container. As noted above, it deviates
* from ISO spec by deriving from a base class in order to reduce code redundancy.
* More code could be reduced by convirting to virtual functions (thus allowing
* much of the erase and insert code to be duplicated), but that would deviate from
* the specifications too much to be worth the risk.
*/
//Implementation of map
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT map
: public __base_map<Key, T, Compare, Allocator>
{
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
public:
typedef__base_map<Key, T, Compare, Allocator>base;
typedef typename base::key_typekey_type;
typedef typename base::mapped_typemapped_type;
typedef typename base::value_typevalue_type;
typedef typename base::key_comparekey_compare;
typedef typename base::allocator_typeallocator_type;
typedef typename base::referencereference;
typedef typename base::const_referenceconst_reference;
typedef typename base::iteratoriterator;
typedef typename base::const_iteratorconst_iterator;
typedef typename base::size_typesize_type;
typedef typename base::difference_typedifference_type;
typedef typename base::pointerpointer;
typedef typename base::const_pointerconst_pointer;
typedef typename base::reverse_iteratorreverse_iterator;
typedef typename base::const_reverse_iteratorconst_reverse_iterator;
using base::value_compare;
explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al) { }
template <class InputIterator> map(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
map(const map<Key,T,Compare,Allocator>& x) : base(x) { }
~map() { }
map<Key,T,Compare,Allocator>& operator=(const map<Key,T,Compare,Allocator>& x);
reference operator[](const key_type& k);
pair<iterator, bool> insert(const value_type& x);
iterator insert(iterator position, const value_type& x);
template <class InputIterator> void insert(InputIterator first, InputIterator last);
void erase(iterator position);
size_type erase(const key_type& x);
void erase(iterator first, iterator last);
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::empty;
using base::size;
using base::max_size;
iterator find(const key_type& x);
const_iterator find(const key_type& x) const;
size_type count(const key_type& x) const;
iterator upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
pair<iterator,iterator> equal_range(const key_type& x);
pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
protected:
friend class base::iterator;
friend class base::const_iterator;
friend bool operator==(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
using base::data;
using base::c;
};
template <class Key, class T, class Compare, class Allocator> template <class InputIterator>
map<Key, T, Compare, Allocator>::
map(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al)
: base(comp, al)
{
while(first !=last){
insert(*first);
++first;
}
}
template <class Key, class T, class Compare, class Allocator>
map<Key, T, Compare, Allocator>::map<Key,T,Compare,Allocator>&
map<Key, T, Compare, Allocator>::operator=(const map<Key,T,Compare,Allocator>& x)
{
if( &x == this){
return *this;
}
c = x.c;
data = x.data;
return *this;
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::reference
map<Key, T, Compare, Allocator>::operator[](const key_type & k)
{
/*iterator i = lower_bound(k);
if( !c( i->first, k) && !c(k, i->first) ){
return i->second;
}
pair<Key, T> t;
t.first = k;
t.second = T();
return insert(t).first->second;
*/
//This is from the spec and is quite ugly.
return (*((insert(make_pair(k, T()))).first)).second;
}
template <class Key, class T, class Compare, class Allocator>
pair<typename map<Key, T, Compare, Allocator>::iterator, bool>
map<Key, T, Compare, Allocator>::insert(const value_type& x)
{
pair<typename map<Key, T, Compare, Allocator>::iterator, bool> retval;
//Either set is empty or element to insert goes at the begining
if(data.size() == 0 || c(x.first, data[0].first) ){
data.push_front(x);
retval.first = begin();
retval.second = true;
return retval;
}
//Element to insert goes at the end
if( c(data[data.size() - 1].first, x.first) ){
data.push_back(x);
retval.first = end();
--retval.first;
retval.second = true;
return retval;
}
retval.first = __base_map<Key, T, Compare, Allocator>::lower_bound(x.first);
//No match - this should never happen
if(retval.first == end()){
retval.second = false;
return retval;
}
//If we have an exact match
if( !c( retval.first->first, x.first) && !c(x.first, retval.first->first ) ){
retval.second = false;
return retval;
}
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator q(&data, retval.first.element);
data.insert(q, x);
retval.first = __base_map<Key, T, Compare, Allocator>::lower_bound(x.first); //Need to refind because insert can move data around
retval.second = true;
return retval;
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::iterator
map<Key, T, Compare, Allocator>::insert(iterator, const value_type& x)
{
//Just reusing code. It's hard to make improvements over existing algo.
//We aren't using the iterator parameter, but it's only a hint and not required to be used.
insert(x);
return find(x.first);
}
template <class Key, class T, class Compare, class Allocator>
template <class InputIterator> void
map<Key, T, Compare, Allocator>::insert(InputIterator first, InputIterator last)
{
while(first !=last){
insert(*first);
++first;
}
}
template <class Key, class T, class Compare, class Allocator> void
map<Key, T, Compare, Allocator>::erase(iterator position)
{
//Create a deque iterator from position information and then
//Use built in erase feature because it is handy.
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator pos(&data, position.element);
data.erase(pos);
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::size_type
map<Key, T, Compare, Allocator>::erase(const key_type& x)
{
typename map<Key, T, Compare, Allocator>::iterator i = find(x);
if(i!=end()){
erase(i);
return 1;
}
return 0;
}
template <class Key, class T, class Compare, class Allocator>
void map<Key, T, Compare, Allocator>::erase(iterator first, iterator last)
{
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator f(&data, first.element);
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator l(&data, last.element);
data.erase(f, l);
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::iterator
map<Key, T, Compare, Allocator>::
find(const typename map<Key, T, Compare, Allocator>::key_type& x)
{
if(data.size() == 0){
return end();
}
iterator retval = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
if(retval == end()){
return retval;
}
//Make sure we have an exact match....
if(!c( retval->first, x) && !c(x, retval->first )){
return retval;
}
return end();
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::const_iterator
map<Key, T, Compare, Allocator>::find(const key_type& x) const
{
if(data.size() == 0){
return end();
}
const_iterator retval = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
if(retval == end()){
return retval;
}
//Make sure we have an exact match....
if(!c( retval->first, x) && !c(x, retval->first )){
return retval;
}
return end();
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::size_type
map<Key, T, Compare, Allocator>::count(const typename map<Key, T, Compare, Allocator>::key_type& x) const
{
if( find(x) == end()){
return 0;
}
return 1;
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::iterator
map<Key, T, Compare, Allocator>::upper_bound(const key_type& x)
{
typename map<Key, T, Compare, Allocator>::iterator i = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
if( i != end() && !c(x, i->first) ){
++i;
}
return i;
}
template <class Key, class T, class Compare, class Allocator>
typename map<Key, T, Compare, Allocator>::const_iterator
map<Key, T, Compare, Allocator>::upper_bound(const key_type& x) const
{
typename map<Key, T, Compare, Allocator>::const_iterator i = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
if(i != end() && !c(x, i->first)){
++i;
}
return i;
}
template <class Key, class T, class Compare, class Allocator>
pair<typename map<Key, T, Compare, Allocator>::iterator,
typename map<Key, T, Compare, Allocator>::iterator
> map<Key, T, Compare, Allocator>::equal_range(const key_type& x)
{
pair< typename map<Key, T, Compare, Allocator>::iterator,
typename map<Key, T, Compare, Allocator>::iterator
> retval;
retval.first = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
retval.second = upper_bound(x);
return retval;
}
template <class Key, class T, class Compare, class Allocator>
pair<typename map<Key, T, Compare, Allocator>::const_iterator,
typename map<Key, T, Compare, Allocator>::const_iterator
> map<Key, T, Compare, Allocator>::equal_range(const key_type& x) const
{
pair< typename map<Key, T, Compare, Allocator>::const_iterator,
typename map<Key, T, Compare, Allocator>::const_iterator
> retval;
retval.first = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
retval.second = upper_bound(x);
return retval;
}
template <class Key, class T, class Compare, class Allocator> bool operator==
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y)
{
if(x.c == y.c && x.data == y.data){
return true;
}
return false;
}
//Implementation of multimap
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT multimap
: public __base_map<Key, T, Compare, Allocator>
{
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
public:
typedef__base_map<Key, T, Compare, Allocator>base;
typedef typename base::key_typekey_type;
typedef typename base::mapped_typemapped_type;
typedef typename base::value_typevalue_type;
typedef typename base::key_comparekey_compare;
typedef typename base::allocator_typeallocator_type;
typedef typename base::referencereference;
typedef typename base::const_referenceconst_reference;
typedef typename base::iteratoriterator;
typedef typename base::const_iteratorconst_iterator;
typedef typename base::size_typesize_type;
typedef typename base::difference_typedifference_type;
typedef typename base::pointerpointer;
typedef typename base::const_pointerconst_pointer;
typedef typename base::reverse_iteratorreverse_iterator;
typedef typename base::const_reverse_iteratorconst_reverse_iterator;
explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al) { }
template <class InputIterator> multimap(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
multimap(const multimap<Key,T,Compare,Allocator>& x) : base(x) { }
~multimap() { }
multimap<Key,T,Compare,Allocator>& operator=(const multimap<Key,T,Compare,Allocator>& x);
iterator insert(const value_type& x);
iterator insert(iterator position, const value_type& x);
template <class InputIterator> void insert(InputIterator first, InputIterator last);
void erase(iterator position);
size_type erase(const key_type& x);
void erase(iterator first, iterator last);
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::empty;
using base::size;
using base::max_size;
iterator find(const key_type& x);
const_iterator find(const key_type& x) const;
size_type count(const key_type& x) const;
iterator upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
pair<iterator,iterator> equal_range(const key_type& x);
pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
protected:
friend class base::iterator;
friend class base::const_iterator;
using base::data;
using base::c;
};
template <class Key, class T, class Compare, class Allocator> template <class InputIterator>
multimap<Key, T, Compare, Allocator>::
multimap(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al)
: base(comp, al)
{
while(first !=last){
insert(*first);
++first;
}
}
template <class Key, class T, class Compare, class Allocator>
multimap<Key, T, Compare, Allocator>::multimap<Key,T,Compare,Allocator>&
multimap<Key, T, Compare, Allocator>::operator=(const multimap<Key,T,Compare,Allocator>& x)
{
if( &x == this){
return *this;
}
c = x.c;
data = x.data;
return *this;
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::iterator
multimap<Key, T, Compare, Allocator>::insert(const value_type &x)
{
iterator retval;
//Either set is empty or element to insert goes at the begining
if(data.size() == 0 || c(x.first, data[0].first) ){
data.push_front(x);
return begin();
}
//Element to insert goes at the end
if( c(data[data.size() - 1].first, x.first) ){
data.push_back(x);
return end();
}
retval = __base_map<Key, T, Compare, Allocator>::lower_bound(x.first);
//No match - this should never happen
if(retval == end()){
return retval;
}
if( !c(x.first, retval->first) ){
++retval;
}
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator q(&data, retval.element);
data.insert(q, x);
return retval;
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::iterator
multimap<Key, T, Compare, Allocator>::insert(iterator position, const value_type& x)
{
//Inserting at begining
if(position == begin() && !c(position->first, x.first) ){
data.push_front(x);
return position;
}
//Inserting at end
if(position == end() && !c(x.first, data[data.size() - 1].first) ){
data.push_back(x);
return position;
}
//Inserting in middle
iterator temp = position;
--temp;
if( !c(position->first, x.first) && !c(x.first, temp->first) ){
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator q(&data, position.element);
data.insert(q, x);
return position;
}
return insert(x);
}
template <class Key, class T, class Compare, class Allocator>
template <class InputIterator> void
multimap<Key, T, Compare, Allocator>::insert(InputIterator first, InputIterator last)
{
while(first !=last){
insert(*first);
++first;
}
}
template <class Key, class T, class Compare, class Allocator> void
multimap<Key, T, Compare, Allocator>::erase(iterator position)
{
//Create a deque iterator from position information and then
//Use built in erase feature because it is handy.
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator pos(&data, position.element);
data.erase(pos);
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::size_type
multimap<Key, T, Compare, Allocator>::erase(const key_type& x)
{
typename multimap<Key, T, Compare, Allocator>::iterator f = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
typename multimap<Key, T, Compare, Allocator>::iterator l = upper_bound(x);
size_type t = l.element - f.element;
erase(f, l);
return t;
}
template <class Key, class T, class Compare, class Allocator>
void multimap<Key, T, Compare, Allocator>::erase(iterator first, iterator last)
{
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator f(&data, first.element);
typename deque<pair<Key, T>, allocator<pair<Key, T> > >::iterator l(&data, last.element);
data.erase(f, l);
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::iterator
multimap<Key, T, Compare, Allocator>::find(const key_type& x)
{
if(data.size() == 0){
return end();
}
iterator retval = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
if(retval == end()){
return retval;
}
if( c(x, retval->first) || c(retval->first, x) ){
return end();
}
while( retval.element > 0 && !c(retval->first, x) && !c(x, retval->first) ){
--retval;
}
if( c(retval->first, x)){
++retval;
}
return retval;
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::const_iterator
multimap<Key, T, Compare, Allocator>::find(const key_type& x) const
{
if(data.size() == 0){
return end();
}
const_iterator retval = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
if(retval == end()){
return retval;
}
if( c(x, retval->first) || c(retval->first, x) ){
return end();
}
while( retval.element > 0 && !c(retval->first, x) && !c(x, retval->first) ){
--retval;
}
if( c(retval->first, x)){
++retval;
}
return retval;
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::size_type
multimap<Key, T, Compare, Allocator>::
count(const typename multimap<Key, T, Compare, Allocator>::key_type& x) const
{
pair< typename multimap<Key, T, Compare, Allocator>::const_iterator,
typename multimap<Key, T, Compare, Allocator>::const_iterator
> temp = equal_range(x);
return temp.second.element - temp.first.element;
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::iterator
multimap<Key, T, Compare, Allocator>::upper_bound(const key_type& x)
{
typename multimap<Key, T, Compare, Allocator>::iterator i = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
while(i != end() && !c(x, i->first)){
++i;
}
return i;
}
template <class Key, class T, class Compare, class Allocator>
typename multimap<Key, T, Compare, Allocator>::const_iterator
multimap<Key, T, Compare, Allocator>::upper_bound(const key_type& x) const
{
typename multimap<Key, T, Compare, Allocator>::const_iterator i = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
while(i != end() && !c(x, i->first)){
++i;
}
return i;
}
template <class Key, class T, class Compare, class Allocator>
pair<typename multimap<Key, T, Compare, Allocator>::iterator,
typename multimap<Key, T, Compare, Allocator>::iterator
> multimap<Key, T, Compare, Allocator>::equal_range(const key_type& x)
{
pair< typename multimap<Key, T, Compare, Allocator>::iterator,
typename multimap<Key, T, Compare, Allocator>::iterator
> retval;
retval.first = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
retval.second = upper_bound(x);
return retval;
}
template <class Key, class T, class Compare, class Allocator>
pair<typename multimap<Key, T, Compare, Allocator>::const_iterator,
typename multimap<Key, T, Compare, Allocator>::const_iterator
> multimap<Key, T, Compare, Allocator>::equal_range(const key_type& x) const
{
pair< typename multimap<Key, T, Compare, Allocator>::const_iterator,
typename multimap<Key, T, Compare, Allocator>::const_iterator
> retval;
retval.first = __base_map<Key, T, Compare, Allocator>::lower_bound(x);
retval.second = upper_bound(x);
return retval;
}
/* Non-member functions. These are at the end because they are not associated with any
particular class. These will be implemented as I figure out exactly what all of
them are supposed to do, and I have time.
*/
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
(map<Key,T,Compare,Allocator>& x, map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator==
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y);
}
#pragma GCC visibility pop
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/unwind-cxx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// -*- C++ -*- Exception handling and frame unwind runtime interface routines.
// Copyright (C) 2001 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with GCC; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This is derived from the C++ ABI for IA-64. Where we diverge
// for cross-architecture compatibility are noted with "@@@".
#ifndef _UNWIND_CXX_H
#define _UNWIND_CXX_H 1
// Level 2: C++ ABI
#include <typeinfo>
#include <exception>
#include <cstddef>
#include "unwind.h"
#pragma GCC visibility push(default)
namespace __cxxabiv1
{
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
// A C++ exception object consists of a header, which is a wrapper around
// an unwind object header with additional C++ specific information,
// followed by the exception object itself.
struct __cxa_exception
{
// Manage the exception object itself.
std::type_info *exceptionType;
void (*exceptionDestructor)(void *);
// The C++ standard has entertaining rules wrt calling set_terminate
// and set_unexpected in the middle of the exception cleanup process.
std::unexpected_handler unexpectedHandler;
std::terminate_handler terminateHandler;
// The caught exception stack threads through here.
__cxa_exception *nextException;
// How many nested handlers have caught this exception. A negated
// value is a signal that this object has been rethrown.
int handlerCount;
// Cache parsed handler data from the personality routine Phase 1
// for Phase 2 and __cxa_call_unexpected.
int handlerSwitchValue;
const unsigned char *actionRecord;
const unsigned char *languageSpecificData;
_Unwind_Ptr catchTemp;
void *adjustedPtr;
// The generic exception header. Must be last.
_Unwind_Exception unwindHeader;
};
// Each thread in a C++ program has access to a __cxa_eh_globals object.
struct __cxa_eh_globals
{
__cxa_exception *caughtExceptions;
unsigned int uncaughtExceptions;
};
// The __cxa_eh_globals for the current thread can be obtained by using
// either of the following functions. The "fast" version assumes at least
// one prior call of __cxa_get_globals has been made from the current
// thread, so no initialization is necessary.
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw();
#endif
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
// Allocate memory for the exception plus the thown object.
extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw();
// Free the space allocated for the exception.
extern "C" void __cxa_free_exception(void *thrown_exception) throw();
// Throw the exception.
extern "C" void __cxa_throw (void *thrown_exception,
std::type_info *tinfo,
void (*dest) (void *))
__attribute__((noreturn));
// Used to implement exception handlers.
extern "C" void *__cxa_begin_catch (void *) throw();
extern "C" void __cxa_end_catch ();
extern "C" void __cxa_rethrow () __attribute__((noreturn));
#endif
// These facilitate code generation for recurring situations.
extern "C" void __cxa_bad_cast ();
extern "C" void __cxa_bad_typeid ();
// @@@ These are not directly specified by the IA-64 C++ ABI.
// Handles re-checking the exception specification if unexpectedHandler
// throws, and if bad_exception needs to be thrown. Called from the
// compiler.
extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn));
// Invokes given handler, dying appropriately if the user handler was
// so inconsiderate as to return.
extern void __terminate(std::terminate_handler) __attribute__((noreturn));
extern void __unexpected(std::unexpected_handler) __attribute__((noreturn));
// The current installed user handlers.
extern std::terminate_handler __terminate_handler;
extern std::unexpected_handler __unexpected_handler;
// These are explicitly GNU C++ specific.
// This is the exception class we report -- "GNUCC++\0".
const _Unwind_Exception_Class __gxx_exception_class
= ((((((((_Unwind_Exception_Class) 'G'
<< 8 | (_Unwind_Exception_Class) 'N')
<< 8 | (_Unwind_Exception_Class) 'U')
<< 8 | (_Unwind_Exception_Class) 'C')
<< 8 | (_Unwind_Exception_Class) 'C')
<< 8 | (_Unwind_Exception_Class) '+')
<< 8 | (_Unwind_Exception_Class) '+')
<< 8 | (_Unwind_Exception_Class) '\0');
// GNU C++ personality routine, Version 0.
extern "C" _Unwind_Reason_Code __gxx_personality_v0
(int, _Unwind_Action, _Unwind_Exception_Class,
struct _Unwind_Exception *, struct _Unwind_Context *);
// GNU C++ sjlj personality routine, Version 0.
extern "C" _Unwind_Reason_Code __gxx_personality_sj0
(int, _Unwind_Action, _Unwind_Exception_Class,
struct _Unwind_Exception *, struct _Unwind_Context *);
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
// Acquire the C++ exception header from the C++ object.
static inline __cxa_exception *
__get_exception_header_from_obj (void *ptr)
{
return reinterpret_cast<__cxa_exception *>(ptr) - 1;
}
// Acquire the C++ exception header from the generic exception header.
static inline __cxa_exception *
__get_exception_header_from_ue (_Unwind_Exception *exc)
{
return reinterpret_cast<__cxa_exception *>(exc + 1) - 1;
}
#endif
} /* namespace __cxxabiv1 */
#pragma GCC visibility pop
#endif // _UNWIND_CXX_H
branches/azimutz/Chazi/i386/modules/uClibcxx/include/iomanip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*Copyright (C) 2005 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <exception>
#include <ios>
#ifndef __STD_IOMANIP
#define __STD_IOMANIP 1
#pragma GCC visibility push(default)
namespace std{
// These are the helper classes which we are going to be using to
// hold the required data
class _UCXXEXPORT __resetiosflags{
public:
ios_base::fmtflags m;
_UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ }
};
class _UCXXEXPORT __setiosflags{
public:
ios_base::fmtflags m;
_UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ }
};
class _UCXXEXPORT __setbase{
public:
int base;
_UCXXEXPORT __setbase(int b) : base(b){ }
};
class _UCXXEXPORT __setfill{
public:
int character;
_UCXXEXPORT __setfill(int c): character(c){ }
};
class _UCXXEXPORT __setprecision{
public:
int digits;
_UCXXEXPORT __setprecision(int n): digits(n) { }
};
class _UCXXEXPORT __setw{
public:
int width;
_UCXXEXPORT __setw(int n): width(n) { }
};
//Actual manipulator functions
inline __resetiosflags resetiosflags(ios_base::fmtflags mask){
return __resetiosflags(mask);
}
inline __setiosflags setiosflags(ios_base::fmtflags mask){
return __setiosflags(mask);
}
inline __setbase setbase(int b){
return __setbase(b);
}
inline __setfill setfill(int c){
return __setfill(c);
}
inline __setprecision setprecision(int n){
return __setprecision(n);
}
inline __setw setw(int n){
return __setw(n);
}
//How to handle interaction with [i|o]stream classes
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __resetiosflags s)
{
os.setf(ios_base::fmtflags(0),s.m);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_istream<Ch, Tr>&
operator>>(basic_istream<Ch, Tr>& is, const __resetiosflags s)
{
is.setf(ios_base::fmtflags(0),s.m);
return is;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setiosflags s)
{
os.setf(s.m);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setbase s)
{
ios_base::fmtflags f(0);
switch(s.base){
case 8:
f = ios_base::oct;
break;
case 10:
f = ios_base::dec;
break;
case 16:
f = ios_base::hex;
break;
default:
break;
}
os.setf(f, ios_base::basefield);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setfill s)
{
os.fill(s.character);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setprecision s)
{
os.precision(s.digits);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setw s)
{
os.width(s.width);
return os;
}
}
#pragma GCC visibility pop
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/numeric
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <exception>
#ifndef __STD_NUMERIC_HEADER
#define __STD_NUMERIC_HEADER 1
#pragma GCC visibility push(default)
namespace std{
template <class InputIterator, class T> _UCXXEXPORT
T accumulate(InputIterator first, InputIterator last, T init)
{
while(first != last){
init = init + *first;
++first;
}
return init;
}
template <class InputIterator, class T, class BinaryOperation> _UCXXEXPORT
T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op)
{
while(first != last){
init = binary_op(init, *first);
++first;
}
return init;
}
template <class InputIterator1, class InputIterator2, class T> _UCXXEXPORT
T inner_product(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init)
{
while(first1 != last1){
init = init + *first1 * *first2;
++first1;
++first2;
}
return init;
}
template <class InputIterator1, class InputIterator2, class T,
class BinaryOperation1, class BinaryOperation2> _UCXXEXPORT
T inner_product(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init,
BinaryOperation1 binary_op1,
BinaryOperation2 binary_op2)
{
while(first1 != last1){
init = binary_op1(init, binary_op2(*first1, *first2));
++first1;
++first2;
}
return init;
}
template <class InputIterator, class OutputIterator> _UCXXEXPORT
OutputIterator partial_sum(InputIterator first, InputIterator last,
OutputIterator result)
{
OutputIterator temp(result);
*result = *first;
++first;
++result;
while(first != last){
*result = *first + *temp;
temp = result;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
OutputIterator partial_sum(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op)
{
OutputIterator temp(result);
*result = *first;
++first;
++result;
while(first != last){
*result = binary_op(*first, *temp);
temp = result;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator> _UCXXEXPORT
OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
OutputIterator result)
{
OutputIterator temp(first);
*result = *first;
++first;
++result;
while(first != last){
*result = *first - *temp;
temp = first;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op)
{
OutputIterator temp(first);
*result = *first;
++first;
++result;
while(first != last){
*result = binary_op(*first, *temp);
temp = first;
++first;
++result;
}
return result;
}
}
#pragma GCC visibility pop
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/utility
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#ifndef __STD_HEADER_UTILITY
#define __STD_HEADER_UTILITY 1
#pragma GCC visibility push(default)
namespace std{
namespace rel_ops {
template<class T> inline bool operator!=(const T& x, const T& y){
return !(x == y);
}
template<class T> inline bool operator> (const T& x, const T& y){
return ( y < x);
}
template<class T> inline bool operator<=(const T& x, const T& y){
return !( y < x );
}
template<class T> inline bool operator>=(const T& x, const T& y){
return !(x < y);
}
}
template <class T1, class T2> struct _UCXXEXPORT pair {
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair() : first(), second() { }
pair(const T1& x, const T2& y) : first(x), second(y) { }
template<class U, class V> pair(const pair<U, V> &p) : first(p.first), second(p.second) { }
};
template <class T1, class T2> bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y){
using namespace rel_ops;
return (x.first == y.first && x.second==y.second);
}
template <class T1, class T2> bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y){
return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
}
template <class T1, class T2> bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y){
return !(x == y);
}
template <class T1, class T2> bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y){
return y < x;
}
template <class T1, class T2> bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y){
return !(x < y);
}
template <class T1, class T2> bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y){
return !(y < x);
}
template <class T1, class T2> pair<T1,T2> make_pair(const T1& x, const T2& y){
return pair<T1,T2>(x, y);
}
}
#pragma GCC visibility pop
#endif//__STD_HEADER_UTILITY
branches/azimutz/Chazi/i386/modules/uClibcxx/include/cwchar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*Copyright (C) 2006 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation version 2.1
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <wchar.h>
#include <basic_definitions>
#ifndef __HEADER_CWCHAR
#define __HEADER_CWCHAR 1
namespace std{
using ::mbstate_t;
using ::wint_t;
using ::btowc;
using ::fgetwc;
using ::fgetws;
using ::fputwc;
using ::fputws;
using ::fwide;
using ::fwprintf;
using ::fwscanf;
using ::getwc;
using ::getwchar;
using ::mbrlen;
using ::mbrtowc;
using ::mbsinit;
using ::mbsrtowcs;
using ::putwc;
using ::putwchar;
using ::swprintf;
using ::swscanf;
using ::ungetwc;
using ::vfwprintf;
using ::vswprintf;
using ::vwprintf;
using ::wcrtomb;
using ::wcscat;
using ::wcschr;
using ::wcscmp;
using ::wcscoll;
using ::wcscpy;
using ::wcscspn;
using ::wcsftime;
using ::wcslen;
using ::wcsncat;
using ::wcsncmp;
using ::wcsncpy;
using ::wcspbrk;
using ::wcsrchr;
using ::wcsrtombs;
using ::wcsspn;
using ::wcsstr;
using ::wcstod;
using ::wcstok;
using ::wcstol;
using ::wcstoul;
using ::wcsxfrm;
using ::wctob;
using ::wmemchr;
using ::wmemcmp;
using ::wmemcpy;
using ::wmemmove;
using ::wmemset;
using ::wprintf;
using ::wscanf;
}
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/type_traits
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*Copyright (C) 2005 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <string.h>
#include <exception>
#include <memory>
#include <char_traits>
#ifndef __HEADER_TYPE_TRAITS
#define __HEADER_TYPE_TRAITS 1
#pragma GCC visibility push(default)
namespace std{
struct _UCXXEXPORT __true_type{};
struct _UCXXEXPORT __false_type{};
template <class I> class _UCXXEXPORT __is_integer{
public:
typedef __false_type value;
};
template <> class _UCXXEXPORT __is_integer <unsigned int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <signed int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <short unsigned int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <short signed int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <char>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <signed char>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <unsigned char>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <long unsigned int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <long signed int>{
public:
typedef __true_type value;
};
}
#pragma GCC visibility pop
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/memory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <new>
#include <cstddef>
#include <cstdlib>
#include <iterator_base>
#include <utility>
#include <cstdio>
#ifndef HEADER_STD_MEMORY
#define HEADER_STD_MEMORY 1
#pragma GCC visibility push(default)
namespace std{
template <class T> class allocator;
// Specialize for void:
template <> class _UCXXEXPORT allocator<void> {
public:
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template <class U> struct rebind { typedef allocator<U> other; };
};
template <class T> class _UCXXEXPORT allocator{
public:
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; }
allocator() throw(){}
template <class U> allocator(const allocator<U>& ) throw();
~allocator() throw(){}
//Space for n Ts
pointer allocate(size_type n, typename allocator<void>::const_pointer = 0){
return (T*)(::operator new( n * sizeof(T) ));
}
void deallocate(pointer p, size_type){
::operator delete(p);
}
//Use placement new to engage the constructor
void construct(pointer p, const T& val) { new((void*)p) T(val); }
void destroy(pointer p){ ((T*)p)->~T(); }//Call destructor
size_type max_size() const throw();
template<class U> struct rebind { typedef allocator<U> other; };
};
template <class Out, class T> class _UCXXEXPORT raw_storage_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
Out p;
public:
explicit raw_storage_iterator(Out pp) : p (pp) { }
raw_storage_iterator & operator*() { return *this; }
raw_storage_iterator & operator=(const T& val) {
T* pp = &*p;
new(pp) T(val);
return *this;
}
raw_storage_iterator & operator++() { ++p; return *this; }
raw_storage_iterator operator++(int) {
raw_storage_iterator t = *this;
++p;
return t;
}
};
template <class T> _UCXXEXPORT pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n){
pair<T*, ptrdiff_t> retval;
retval.first = static_cast<T*>(malloc(n * sizeof(T)));
if(retval.first == 0){
retval.second = 0;
}else{
retval.second = n;
}
return retval;
}
template <class T> _UCXXEXPORT void return_temporary_buffer(T* p){
free(p);
}
template <class T> class _UCXXEXPORT auto_ptr{
private:
T * object;
template <class Y> struct auto_ptr_ref{
Y * p;
};
public:
typedef T element_type;
explicit auto_ptr(T* p =0) throw() : object(p){ }
auto_ptr(auto_ptr& p) throw() : object(p.release()){ }
auto_ptr(auto_ptr_ref<T> r) throw() : object(r.p){
r.p = 0;
}
template<class Y> auto_ptr(auto_ptr<Y>& p) throw() : object(p.release()){ }
auto_ptr& operator=(auto_ptr& p) throw(){
if(&p == this){
return *this;
}
delete object;
object = p.release();
return *this;
}
template<class Y> auto_ptr& operator=(auto_ptr<Y>& p) throw(){
if(&p == this){
return *this;
}
delete object;
object = p.release();
return *this;
}
~auto_ptr(){
delete object;
}
T& operator*() const throw(){
return *object;
}
T* operator->() const throw(){
return object;
}
T* get() const throw(){
return object;
}
T* release() throw(){
T * temp(object);
object = 0;
return temp;
}
void reset(T * p=0) throw(){
if(p != object){
delete object;
object = p;
}
}
template<class Y> operator auto_ptr_ref<Y>() throw(){
auto_ptr_ref<Y> retval;
retval.p = object;
object = 0;
return retval;
}
template<class Y> operator auto_ptr<Y>() throw(){
auto_ptr<Y> retval(object);
object = 0;
return retval;
}
};
}//namespace std
#pragma GCC visibility pop
#endif
branches/azimutz/Chazi/i386/modules/uClibcxx/include/set.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
<
/*Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include<memory>
#include<utility>
#include<iterator>
#include <deque>
#include<functional>
#ifndef __STD_HEADER_SET
#define __STD_HEADER_SET
#pragma GCC visibility push(default)
namespace std{
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class __base_set;
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class set;
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class multiset;
template<class Key, class Compare, class Allocator> class __set_iter;
template<class Key, class Compare, class Allocator> class __set_citer;
template <class Key, class Compare, class Allocator> bool operator==
(const set<Key, Compare, Allocator>& x, const set<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator> bool operator==
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y);
/* The code for the set containers is split up into two classes.
* The first class, __base_set holds all of the data and does much of the iterator-based
* work. Then the classes set and multiset inherit from there. This was done to reduce
* the redundancy of code (And thus errors which might crop up), as well as possibly
* reducing the size of binaries if both set and multiset are used, along with the same
* template parameters.
*/
//All base classes first (__base_set, iterators, value_compare) and it's associated code
template<class Key, class Compare, class Allocator> class _UCXXEXPORT __base_set{
protected:
friend class __set_iter<Key, Compare, Allocator>;
friend class __set_citer<Key, Compare, Allocator>;
friend bool operator==<>(const set<Key, Compare, Allocator>& x, const set<Key, Compare, Allocator>& y);
friend bool operator==<>(const multiset<Key, Compare, Allocator>& x, const multiset<Key, Compare, Allocator>& y);
public:
typedef __base_set<Key, Compare, Allocator>set_type;
typedef Keykey_type;
typedef Keyvalue_type;
typedef Comparekey_compare;
typedef Allocatorallocator_type;
typedef typename Allocator::referencereference;
typedef typename Allocator::const_referenceconst_reference;
typedef __set_iter<Key, Compare, Allocator>iterator;
typedef __set_citer<Key, Compare, Allocator>const_iterator;
typedef typename Allocator::size_typesize_type;
typedef typename Allocator::difference_typedifference_type;
typedef typename Allocator::pointerpointer;
typedef typename Allocator::const_pointerconst_pointer;
typedef typename std::reverse_iterator<iterator>reverse_iterator;
typedef typename std::reverse_iterator<const_iterator>const_reverse_iterator;
class value_compare;
explicit __base_set(const Compare& comp = Compare(), const Allocator& al = Allocator());
__base_set(const set_type& x);
~__base_set();
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
void swap(set_type & x);
void clear();
key_compare key_comp() const;
protected:
deque<Key, allocator<Key> > data;
Compare c;
};
//Implementations
template<class Key, class Compare, class Allocator> class _UCXXEXPORT __set_citer
: public std::iterator<
bidirectional_iterator_tag,
Key,
typename Allocator::difference_type,
typename Allocator::pointer,
typename Allocator::reference
>
{
protected:
typedef class __base_set<Key, Compare, Allocator> Set;
friend class __base_set<Key, Compare, Allocator>;
friend class __base_set<Key, Compare, Allocator>::iterator;
friend class set<Key, Compare, Allocator>;
friend class multiset<Key, Compare, Allocator>;
typename Set::size_type element;
const Set * container;
public:
__set_citer() : element(0), container(0) { }
__set_citer(const typename Set::const_iterator & m)
: element(m.element), container(m.container) { }
__set_citer(typename Set::size_type e, const Set * const c)
: element(e), container(c) { }
~__set_citer() { }
typename Set::value_type operator*(){
return container->data[element];
}
const typename Set::value_type * operator->() const{
return &(container->data[element]);
}
__set_citer & operator=(const typename Set::const_iterator & m){
element = m.element;
container = m.container;
return *this;
}
bool operator==(const typename Set::const_iterator & m) const {
return (m.element == element && m.container == container);
}
bool operator!=(const typename Set::const_iterator & m) const {
return (m.element != element || m.container != container);
}
__set_citer & operator++(){
++element;
return *this;
}
__set_citer operator++(int){
__set_citer temp(*this);
++element;
return temp;
}
__set_citer & operator--(){
--element;
return *this;
}
__set_citer operator--(int){
__set_citer temp(*this);
--element;
return temp;
}
};
template<class Key, class Compare, class Allocator> class _UCXXEXPORT __set_iter
: public std::iterator<
bidirectional_iterator_tag,
Key,
typename Allocator::difference_type,
typename Allocator::pointer,
typename Allocator::reference
>
{
protected:
typedef __base_set<Key, Compare, Allocator> Set;
//FIXME - Find a way to use template parameters or something. This will do for now
friend class __base_set<Key, Compare, Allocator>;
friend class __base_set<Key, Compare, Allocator>::const_iterator;
friend class set<Key, Compare, Allocator>;
friend class multiset<Key, Compare, Allocator>;
typename Set::size_type element;
Set * container;
public:
__set_iter() : element(0), container(0) { }
__set_iter(const typename Set::iterator & m)
: element(m.element), container(m.container) { }
__set_iter(typename Set::size_type e, Set * c)
: element(e), container(c) { }
~__set_iter() { }
typename Set::value_type & operator*(){
return container->data[element];
}
const typename Set::value_type & operator*() const{
return container->data[element];
}
typename Set::value_type * operator->(){
return &(container->data[element]);
}
__set_iter & operator=(const typename Set::iterator & m){
element = m.element;
container = m.container;
return *this;
}
bool operator==(const typename Set::iterator & m) const {
return (m.element == element && m.container == container);
}
bool operator!=(const typename Set::iterator & m) const {
return (m.element != element || m.container != container);
}
bool operator==(const typename Set::const_iterator & m) const {
return (m.element == element && m.container == container);
}
bool operator!=(const typename Set::const_iterator & m) const {
return (m.element != element || m.container != container);
}
__set_iter & operator++(){
++element;
return *this;
}
__set_iter operator++(int){
__set_iter temp(*this);
++element;
return temp;
}
__set_iter & operator--(){
--element;
return *this;
}
__set_iter operator--(int){
__set_iter temp(*this);
--element;
return temp;
}
//Conversion operator
operator typename Set::const_iterator () const
{
typename Set::const_iterator retval(element, container);
//return typename Set::const_iterator(element, container);
return retval;
}
};
//Compare the keys of the two items
template<class Key, class Compare, class Allocator> class _UCXXEXPORT
__base_set<Key, Compare, Allocator>::value_compare : public binary_function<
typename set<Key, Compare, Allocator>::value_type,
typename set<Key, Compare, Allocator>::value_type,
bool>
{
friend class __base_set<Key, Compare, Allocator>;
protected:
Compare comp;
value_compare(Compare c) : comp(c) { }
~value_compare() { }
public:
bool operator()(const value_type& x, const value_type& y) const {
return comp(x, y);
}
};
template <class Key, class Compare, class Allocator>
__base_set<Key, Compare, Allocator>::__base_set(const Compare& comp, const Allocator&)
: data(), c(comp)
{
}
template <class Key, class Compare, class Allocator>
__base_set<Key, Compare, Allocator>::__base_set(const __base_set<Key, Compare, Allocator>& x)
: data(x.data), c(x.c)
{
}
template <class Key, class Compare, class Allocator>
__base_set<Key, Compare, Allocator>::~__base_set()
{
}
template <class Key, class Compare, class Allocator>
typename __base_set<Key, Compare, Allocator>::iterator
__base_set<Key, Compare, Allocator>::begin()
{
return iterator(0, this);
}
template <class Key, class Compare, class Allocator>
typename __base_set<Key, Compare, Allocator>::const_iterator
__base_set<Key, Compare, Allocator>::begin() const
{
return const_iterator(0, this);
}
template <class Key, class Compare, class Allocator>
typename __base_set<Key, Compare, Allocator>::iterator
__base_set<Key, Compare, Allocator>::end()
{
return iterator(data.size(), this);
}
template <class Key, class Compare, class Allocator>
typename __base_set<Key, Compare, Allocator>::const_iterator
__base_set<Key, Compare, Allocator>::end() const
{
return const_iterator(data.size(), this);
}
template <class Key, class Compare, class Allocator>
typename __base_set<Key, Compare, Allocator>::reverse_iterator
__base_set<Key, Compare, Allocator>::rbegin()
{
return reverse_iterator(end());
}
template <class Key, class Compare, class Allocator>