![]() | |
|---|---|
Software: Apache. PHP/5.4.45 uname -a: Linux webm003.cluster110.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue uid=243112(mycochar) gid=100(users) groups=100(users) Safe-mode: OFF (not secure) /home/mycochar/gcc-12.2.0/libstdc++-v3/doc/html/manual/ drwxr-xr-x | |
| Viewing file: Select action/file-type:
This document explains how to port libstdc++ (the GNU C++ library) to a new target. In order to make the GNU C++ library (libstdc++) work with a new target, you must edit some configuration files and provide some new header files. Unless this is done, libstdc++ will use generic settings which may not be correct for your target; even if they are correct, they will likely be inefficient. Before you get started, make sure that you have a working C library on your target. The C library need not precisely comply with any particular standard, but should generally conform to the requirements imposed by the ANSI/ISO standard. In addition, you should try to verify that the C++ compiler generally works. It is difficult to test the C++ compiler without a working library, but you should at least try some minimal test cases. (Note that what we think of as a "target," the library refers to as
a "host." The comment at the top of If you are porting to a new operating system (as opposed to a new chip
using an existing operating system), you will need to create a new
directory in the You might have to change the The first file to create in this directory, should be called
Several libstdc++ source files unconditionally define the macro
At this time, there are a few libstdc++-specific macros which may be defined:
Finally, you should bracket the entire file in an include-guard, like this: #ifndef _GLIBCXX_OS_DEFINES #define _GLIBCXX_OS_DEFINES ... #endif We recommend copying an existing If you are porting to a new chip (as opposed to a new operating system
running on an existing chip), you will need to create a new directory in the
We recommend that for a target triplet Note that some chip families share a single configuration directory, for
example, The The library requires that you provide three header files to implement
character classification, analogous to that provided by the C libraries
The first file to write is The
struct ctype_base
{
typedef unsigned int mask;
typedef int* __to_type;
enum
{
space = _ISspace,
print = _ISprint,
cntrl = _IScntrl,
upper = _ISupper,
lower = _ISlower,
alpha = _ISalpha,
digit = _ISdigit,
punct = _ISpunct,
xdigit = _ISxdigit,
alnum = _ISalnum,
graph = _ISgraph
};
};
The The enumeration should give definitions for all the values in the above
example, using the values from your native The next file to write is
ctype<char>::ctype(const mask* __table = 0, bool __del = false,
size_t __refs = 0)
: _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del),
_M_toupper(NULL),
_M_tolower(NULL),
_M_ctable(NULL),
_M_table(!__table
? (const mask*) (__libc_attr._ctype_tbl->_class + 1)
: __table)
{ }
There are two parts of this that you might choose to alter. The first,
and most important, is the line involving Now, you have to write two functions to convert from upper-case to lower-case, and vice versa. Here are the IRIX versions:
char
ctype<char>::do_toupper(char __c) const
{ return _toupper(__c); }
char
ctype<char>::do_tolower(char __c) const
{ return _tolower(__c); }
Your C library provides equivalents to IRIX's Finally, you have to provide two utility functions that convert strings of characters. The versions provided here will always work - but you could use specialized routines for greater performance if you have machinery to do that on your system:
const char*
ctype<char>::do_toupper(char* __low, const char* __high) const
{
while (__low < __high)
{
*__low = do_toupper(*__low);
++__low;
}
return __high;
}
const char*
ctype<char>::do_tolower(char* __low, const char* __high) const
{
while (__low < __high)
{
*__low = do_tolower(*__low);
++__low;
}
return __high;
}
You must also provide the In detail, the functions provided test characters for particular
properties; they are analogous to the functions like The first function is implemented like this on IRIX:
bool
ctype<char>::
is(mask __m, char __c) const throw()
{ return (_M_table)[(unsigned char)(__c)] & __m; }
The The next function is:
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = (_M_table)[(unsigned char)(*__low++)];
return __high;
}
This function is similar; it copies the masks for all the characters
from The last two functions again are entirely generic:
const char*
ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high && !this->is(__m, *__low))
++__low;
return __low;
}
const char*
ctype<char>::
scan_not(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high && this->is(__m, *__low))
++__low;
return __low;
}
The C++ library string functionality requires a couple of atomic operations to provide thread-safety. If you don't take any special action, the library will use stub versions of these functions that are not thread-safe. They will work fine, unless your applications are multi-threaded. If you want to provide custom, safe, versions of these functions, there
are two distinct approaches. One is to provide a version for your CPU,
using assembly language constructs. The other is to use the
thread-safety primitives in your operating system. In either case, you
make a file called If you are using the assembly-language approach, put this code in
If you are using the operating system thread-safety primitives approach,
you can also put this code in the same CPU directory, in which case no more
work is needed to locate the file. For examples of this approach,
see the Alternatively, if the primitives are more closely related to the OS
than they are to the CPU, you can put the With those bits out of the way, you have to actually write
The type is typedef long _Atomic_word; This type must be a signed integral type supporting atomic operations. If you're using the OS approach, use the same type used by your system's primitives. Otherwise, use the type for which your CPU provides atomic primitives. Then, you must provide two functions. The bodies of these functions must be equivalent to those provided here, but using atomic operations:
static inline _Atomic_word
__attribute__ ((__unused__))
__exchange_and_add (_Atomic_word* __mem, int __val)
{
_Atomic_word __result = *__mem;
*__mem += __val;
return __result;
}
static inline void
__attribute__ ((__unused__))
__atomic_add (_Atomic_word* __mem, int __val)
{
*__mem += __val;
}
The C++ library requires information about the fundamental data types,
such as the minimum and maximum representable values of each type.
You can define each of these values individually, but it is usually
easiest just to indicate how many bits are used in each of the data
types and let the library do the rest. For information about the
macros to define, see the top of If you need to define any macros, you can do so in The C++ library is compiled, archived and linked with libtool. Explaining the full workings of libtool is beyond the scope of this document, but there are a few, particular bits that are necessary for porting. Some parts of the libstdc++ library are compiled with the libtool
The C++ run-time library contains initialization code that needs to be run as the library is loaded. Often, that requires linking in special object files when the C++ library is built as a shared library, or taking other system-specific actions. The libstdc++ library is linked with the C version of libtool, even
though it is a C++ library. Therefore, the C version of libtool needs to
ensure that the run-time library initializers are run. The usual way to
do this is to build the library using If you need to change how the library is linked, look at
|
Useful Commands
|
|
Php Safe-Mode Bypass (Read Files)
|
|
--[ x2300 Locus7Shell v. 1.0a beta Modded by #!physx^ | www.LOCUS7S.com | Generation time: 0.0058 ]-- |