This commit is contained in:
Sylvain PILLOT 2022-03-01 17:59:33 +01:00
parent 46a77d1c8a
commit a2c443996e
13 changed files with 280 additions and 37 deletions

View File

@ -38,7 +38,7 @@ include_directories(
"${PROJECT_BINARY_DIR}/include"
"${FXSDK_COMPILER_INSTALL}/include"
"${FXSDK_COMPILER_INSTALL}/include/openlibm")
add_compile_options(-Os -mb -m4a-nofpu -mhitachi -std=c++11 -fno-strict-aliasing -fno-exceptions -ffreestanding -frtti)
add_compile_options(-Os -mb -m4a-nofpu -mhitachi -std=c++11 -fno-rtti -fno-use-cxa-atexit -fno-exceptions)
# Target name is "ustl", output file is "libustl.a" (by default)
add_library(ustl STATIC ${SOURCES})

View File

@ -2,7 +2,7 @@ PREFIX = /home/sylvain/local
TARGET = libustl.a
OBJECTS = $(patsubst %.cc,%.o,$(wildcard */*.cc))
INCLUDES = -Iinclude -Iinternal -I$(PREFIX)/include
CXXFLAGS = -Os -mb -m4a-nofpu -mhitachi -std=c++11 -fno-strict-aliasing -fno-exceptions -ffreestanding
CXXFLAGS = -Os -mb -m4a-nofpu -mhitachi -std=c++11 -fno-rtti -fno-use-cxa-atexit -fno-exceptions
ARFLAGS = cru
################################################################################
CXX = sh-elf-g++

View File

@ -51,12 +51,12 @@ public:
inline cmemlink (void) : m_Data (NULL), m_Size (0) { }
inline cmemlink (const void* p, size_type n) : m_Data (const_pointer(p)), m_Size (n) { assert (p || !n); }
inline cmemlink (const cmemlink& l) : m_Data (l.m_Data), m_Size (l.m_Size) {}
inline ~cmemlink (void) noexcept {}
inline virtual ~cmemlink (void) noexcept {}
void link (const void* p, size_type n);
inline void link (const cmemlink& l) { link (l.begin(), l.size()); }
inline void link (const void* first, const void* last) { link (first, distance (first, last)); }
inline void relink (const void* p, size_type n);
void unlink (void) noexcept { m_Data = NULL; m_Size = 0; }
virtual void unlink (void) noexcept { m_Data = NULL; m_Size = 0; }
inline rcself_t operator= (const cmemlink& l) { link (l); return (*this); }
bool operator== (const cmemlink& l) const noexcept;
inline void swap (cmemlink& l) { ::ustl::swap (m_Data, l.m_Data); ::ustl::swap (m_Size, l.m_Size); }

254
include/config.h Normal file
View File

@ -0,0 +1,254 @@
// config.h - Generated from config.h.in by configure.
#pragma once
// Define to the one symbol short name of this package.
#define USTL_NAME "ustl"
// Define to the full name and version of this package.
#define USTL_STRING "ustl v2.1"
// Define to the version of this package.
#define USTL_VERSION 0x210
// Define to the address where bug reports for this package should be sent.
#define USTL_BUGREPORT "Mike Sharov <msharov@users.sourceforge.net>"
/// Define to 1 if you want stream operations to throw exceptions on
/// insufficient data or insufficient space. All these errors should
/// be preventable in output code; the input code should verify the
/// data in a separate step. It slows down stream operations a lot,
/// but it is your decision. By default only debug builds throw.
///
#define WANT_STREAM_BOUNDS_CHECKING 0
#if !WANT_STREAM_BOUNDS_CHECKING && !defined(NDEBUG)
#define WANT_STREAM_BOUNDS_CHECKING 0
#endif
/// Define to 1 if you want backtrace symbols demangled.
/// This adds some 15k to the library size, and requires that you link it and
/// any executables you make with the -rdynamic flag (increasing library size
/// even more). By default only the debug build does this.
#undef WANT_NAME_DEMANGLING
#if !WANT_NAME_DEMANGLING && !defined(NDEBUG)
#define WANT_NAME_DEMANGLING 1
#endif
/// Define to 1 if you want to build without libstdc++
#define WITHOUT_LIBSTDCPP 1
/// Define GNU extensions if unavailable.
#ifndef __GNUC__
/// GCC (and some other compilers) define '__attribute__'; ustl is using this
/// macro to alert the compiler to flag inconsistencies in printf/scanf-like
/// function calls. Just in case '__attribute__' is undefined, make a dummy.
///
#ifndef __attribute__
#define __attribute__(p)
#endif
#endif
#if __GNUC__ >= 4
#define DLL_EXPORT __attribute__((visibility("default")))
#define DLL_LOCAL __attribute__((visibility("hidden")))
#define INLINE __attribute__((always_inline))
#else
#define DLL_EXPORT
#define DLL_LOCAL
#define INLINE
#endif
#if __cplusplus >= 201103L && (!__GNUC__ || (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
#define HAVE_CPP11 1
#endif
#if !HAVE_CPP11
#define noexcept throw()
#define constexpr
#endif
#if __GNUC__ >= 3 && (__i386__ || __x86_64__)
/// GCC 3+ supports the prefetch directive, which some CPUs use to improve caching
#define prefetch(p,rw,loc) __builtin_prefetch(p,rw,loc)
#else
#define prefetch(p,rw,loc)
#endif
#if __GNUC__ < 3
/// __alignof__ returns the recommended alignment for the type
#define __alignof__(v) min(sizeof(v), sizeof(void*))
/// This macro returns 1 if the value of x is known at compile time.
#ifndef __builtin_constant_p
#define __builtin_constant_p(x) 0
#endif
#endif
// Define to empty if 'const' does not conform to ANSI C.
/* #define const */
// Define as '__inline' if that is what the C compiler calls it
/* #define inline __inline */
// Define to 'long' if <sys/types.h> does not define.
/* typedef long off_t; */
// Define to 'unsigned' if <sys/types.h> does not define.
/* typedef long size_t; */
/// gcc has lately decided that inline is just a suggestion
/// Define to 1 if when you say 'inline' you mean it!
#undef WANT_ALWAYS_INLINE
#if WANT_ALWAYS_INLINE
#define inline INLINE inline
#endif
/// Define to 1 if you have the <assert.h> header file.
#define HAVE_ASSERT_H 1
/// Define to 1 if you have the <ctype.h> header file.
#define HAVE_CTYPE_H 1
/// Define to 1 if you have the <errno.h> header file.
#define HAVE_ERRNO_H 1
/// Define to 1 if you have the <fcntl.h> header file.
#define HAVE_FCNTL_H 1
/// Define to 1 if you have the <float.h> header file.
#define HAVE_FLOAT_H 1
/// Define to 1 if you have the <inttypes.h> header file.
#define HAVE_INTTYPES_H 1
/// Define to 1 if you have the <limits.h> header file.
#define HAVE_LIMITS_H 1
/// Define to 1 if you have the <locale.h> header file.
#define HAVE_LOCALE_H 1
// Define to 1 if you have the <alloca.h> header file.
#define HAVE_ALLOCA_H 1
// Define to 1 if you have the <signal.h> header file.
#define HAVE_SIGNAL_H 1
// Define to 1 if you have the __va_copy function
#define HAVE_VA_COPY 1
// Define to 1 if you have the <stdarg.h> header file.
#define HAVE_STDARG_H 1
// Define to 1 if you have the <stddef.h> header file.
#define HAVE_STDDEF_H 1
// Define to 1 if you have the <stdint.h> header file.
#define HAVE_STDINT_H 1
// Define to 1 if you have the <stdio.h> header file.
#define HAVE_STDIO_H 1
// Define to 1 if you have the <stdlib.h> header file.
#define HAVE_STDLIB_H 1
// Define to 1 if you have the <string.h> header file.
#define HAVE_STRING_H 1
// Define to 1 if you have the 'strrchr' function.
#define HAVE_STRRCHR 1
// Define to 1 if you have the 'strsignal' function.
#define HAVE_STRSIGNAL 1
// Define to 1 if you have the <sys/stat.h> header file.
#undef HAVE_SYS_STAT_H
// Define to 1 if you have the <sys/types.h> header file.
#define HAVE_SYS_TYPES_H 1
// Define to 1 if you have the <sys/mman.h> header file.
#undef HAVE_SYS_MMAN_H
// Define to 1 if you have the <time.h> header file.
#define HAVE_TIME_H 1
// Define to 1 if you have the <unistd.h> header file.
#define HAVE_UNISTD_H 1
// Define to 1 if you have the <math.h> header file.
#define HAVE_MATH_H 1
// Define to 1 if you have the <execinfo.h> header file.
#define HAVE_EXECINFO_H 1
// Define to 1 if you have the <cxxabi.h> header file.
#if __GNUC__ >= 3
#define HAVE_CXXABI_H 1
#endif
// Define to 1 if you have the rintf function. Will use rint otherwise.
#define HAVE_RINTF 1
// STDC_HEADERS is defined to 1 on sane systems.
#if HAVE_ASSERT_H && HAVE_CTYPE_H && HAVE_ERRNO_H && HAVE_FLOAT_H &&\
HAVE_LIMITS_H && HAVE_LOCALE_H && HAVE_MATH_H && HAVE_SIGNAL_H &&\
HAVE_STDARG_H && HAVE_STDDEF_H && HAVE_STDIO_H && HAVE_STDLIB_H &&\
HAVE_STRING_H && HAVE_TIME_H
#define STDC_HEADERS 1
#endif
// STDC_HEADERS is defined to 1 on unix systems.
#define STDUNIX_HEADERS 1
// Define to 1 if your compiler treats char as a separate type along with
// signed char and unsigned char. This will create overloads for char.
#define HAVE_THREE_CHAR_TYPES 1
// Define to 1 if you have 64 bit types available
#define HAVE_INT64_T 1
// Define to 1 if you have the long long type
#define HAVE_LONG_LONG 1
// Define to 1 if you want unrolled specializations for fill and copy
#define WANT_UNROLLED_COPY 1
// Define to 1 if you want to use MMX/SSE/3dNow! processor instructions
#undef WANT_MMX
// Define to byte sizes of types
#define SIZE_OF_CHAR 1
#define SIZE_OF_SHORT 2
#define SIZE_OF_INT 4
#define SIZE_OF_LONG 8
#define SIZE_OF_LONG_LONG 8
#define SIZE_OF_POINTER 8
#define SIZE_OF_SIZE_T 8
#define SIZE_OF_BOOL SIZE_OF_CHAR
#define SIZE_T_IS_LONG 1
// Byte order macros, converted in utypes.h
#define USTL_LITTLE_ENDIAN 4321
#define USTL_BIG_ENDIAN 1234
#define USTL_BYTE_ORDER USTL_BIG_ENDIAN
// Extended CPU capabilities
#undef CPU_HAS_FPU
#undef CPU_HAS_EXT_DEBUG
#undef CPU_HAS_TIMESTAMPC
#undef CPU_HAS_MSR
#undef CPU_HAS_CMPXCHG8
#undef CPU_HAS_APIC
#undef CPU_HAS_SYSCALL
#undef CPU_HAS_MTRR
#undef CPU_HAS_CMOV
#undef CPU_HAS_FCMOV
#if WANT_MMX
#undef CPU_HAS_MMX
#undef CPU_HAS_FXSAVE
#undef CPU_HAS_SSE
#undef CPU_HAS_SSE2
#undef CPU_HAS_SSE3
#undef CPU_HAS_EXT_3DNOW
#undef CPU_HAS_3DNOW
#endif
// GCC vector extensions
#if (CPU_HAS_MMX || CPU_HAS_SSE) && __GNUC__ >= 3
#undef HAVE_VECTOR_EXTENSIONS
#endif
#if CPU_HAS_SSE && __GNUC__
#define __sse_align __attribute__((aligned(16)))
#else
#define __sse_align
#endif

View File

@ -26,8 +26,8 @@ public:
explicit memblock (const cmemlink& b);
explicit memblock (const memlink& b);
memblock (const memblock& b);
~memblock (void) noexcept;
void unlink (void) noexcept;
virtual ~memblock (void) noexcept;
virtual void unlink (void) noexcept;
inline void assign (const cmemlink& l) { assign (l.cdata(), l.readable_size()); }
inline const memblock& operator= (const cmemlink& l) { assign (l); return (*this); }
inline const memblock& operator= (const memlink& l) { assign (l); return (*this); }
@ -55,7 +55,7 @@ public:
inline void swap (memblock&& l) { memlink::swap (l); ::ustl::swap (m_Capacity, l.m_Capacity); }
#endif
protected:
size_type minimumFreeCapacity (void) const noexcept __attribute__((const));
virtual size_type minimumFreeCapacity (void) const noexcept __attribute__((const));
private:
size_type m_Capacity; ///< Number of bytes allocated by Resize.
};

View File

@ -71,8 +71,8 @@ public:
inline void link (const void* f, const void* l) { cmemlink::link (f, l); }
inline void relink (const void* p, streamsize n) { cmemlink::relink (p, n); m_Pos = 0; }
inline void relink (const cmemlink& l) { relink (l.cdata(), l.readable_size()); }
void unlink (void) noexcept;
inline streamsize underflow (streamsize = 1) { return (remaining()); }
virtual void unlink (void) noexcept;
inline virtual streamsize underflow (streamsize = 1) { return (remaining()); }
inline uoff_t pos (void) const { return (m_Pos); }
inline const_iterator ipos (void) const { return (begin() + pos()); }
inline streamsize remaining (void) const { return (size() - pos()); }

View File

@ -77,8 +77,8 @@ public:
inline void swap (ostream& os);
template <typename T>
inline void iwrite (const T& v);
inline streamsize overflow (streamsize = 1){ return (remaining()); }
void unlink (void) noexcept;
inline virtual streamsize overflow (streamsize = 1){ return (remaining()); }
virtual void unlink (void) noexcept;
inline void link (void* p, streamsize n) { memlink::link (p, n); }
inline void link (memlink& l) { memlink::link (l.data(), l.writable_size()); }
inline void link (void* f, void* l) { memlink::link (f, l); }

View File

@ -18,7 +18,7 @@ public:
ofstream (void);
explicit ofstream (int Fd);
explicit ofstream (const char* filename, openmode mode = out);
~ofstream (void) noexcept;
virtual ~ofstream (void) noexcept;
inline void open (const char* filename, openmode mode = out) { m_File.open (filename, mode); clear (m_File.rdstate()); }
void close (void);
inline bool is_open (void) const { return (m_File.is_open()); }
@ -29,7 +29,7 @@ public:
inline int fd (void) const { return (m_File.fd()); }
ofstream& seekp (off_t p, seekdir d = beg);
ofstream& flush (void);
size_type overflow (size_type n = 1);
virtual size_type overflow (size_type n = 1);
private:
fstream m_File;
};
@ -52,7 +52,7 @@ public:
inline int fd (void) const { return (m_File.fd()); }
ifstream& seekg (off_t p, seekdir d = beg);
int sync (void);
size_type underflow (size_type n = 1);
virtual size_type underflow (size_type n = 1);
private:
string m_Buffer;
fstream m_File;

View File

@ -53,7 +53,7 @@ public:
inline ostringstream& write (const cmemlink& buf) { return (write (buf.begin(), buf.size())); }
inline ostringstream& seekp (off_t p, seekdir d =beg) { ostream::seekp(p,d); return (*this); }
ostringstream& flush (void) { m_Buffer.resize (pos()); return (*this); }
size_type overflow (size_type n = 1);
virtual size_type overflow (size_type n = 1);
protected:
inline void reserve (size_type n) { m_Buffer.reserve (n, false); }
inline size_type capacity (void) const { return (m_Buffer.capacity()); }

View File

@ -13,15 +13,15 @@ namespace __cxxabiv1 { class __class_type_info; }
namespace std {
class type_info {
public:
inline ~type_info (void) { }
inline virtual ~type_info (void) { }
inline const char* name (void) const { return (__name[0] == '*' ? __name + 1 : __name); }
inline bool before (const type_info& v) const { return (__name < v.__name); }
inline bool operator==(const type_info& v) const { return (__name == v.__name); }
inline bool operator!=(const type_info& v) const { return (!operator==(v)); }
bool __is_pointer_p (void) const;
bool __is_function_p (void) const;
bool __do_catch (const type_info* __thr_type, void** __thr_obj, unsigned __outer) const;
bool __do_upcast (const __cxxabiv1::__class_type_info* __target, void** __obj_ptr) const;
virtual bool __is_pointer_p (void) const;
virtual bool __is_function_p (void) const;
virtual bool __do_catch (const type_info* __thr_type, void** __thr_obj, unsigned __outer) const;
virtual bool __do_upcast (const __cxxabiv1::__class_type_info* __target, void** __obj_ptr) const;
explicit inline type_info (const char* newname) : __name(newname) { }
private:
inline void operator= (const type_info&) { }

View File

@ -44,20 +44,12 @@ public:
inline const_iterator end (void) const { return (begin() + N); }
inline size_type size (void) const { return (N); }
inline size_type max_size (void) const { return (N); }
inline bool empty (void) const { return (N == 0); }
inline bool empty (void) const { return (N == 0); }
inline const_reference at (size_type i) const { return (_v[i]); }
inline reference at (size_type i) { return (_v[i]); }
// addition by SlyVTT
inline const_reference front (void) const { return (_v[0]); }
inline reference front (void) { return (_v[0]); }
inline const_reference back (void) const { return (_v[N-1]); }
inline reference back (void) { return (_v[N-1]); }
//end of addition by SlyVTT
inline void read (istream& is) { nr_container_read (is, *this); }
inline void write (ostream& os) const { nr_container_write (os, *this); }
inline void text_write (ostringstream& os) const { container_text_write (os, *this); }
inline void read (istream& is) { nr_container_read (is, *this); }
inline void write (ostream& os) const { nr_container_write (os, *this); }
inline void text_write (ostringstream& os) const { container_text_write (os, *this); }
inline size_t stream_size (void) const { return (nr_container_stream_size (*this)); }
inline const_reference operator[] (size_type i) const { return (_v[i]); }
inline reference operator[] (size_type i) { return (_v[i]); }

View File

@ -64,7 +64,7 @@ public:
inline string (const_pointer s, size_type len);
inline string (const_pointer s1, const_pointer s2);
string (size_type n, value_type c);
inline ~string (void) noexcept { }
inline virtual ~string (void) noexcept { }
inline pointer data (void) { return (string::pointer (memblock::data())); }
inline const_pointer data (void) const { return (string::const_pointer (memblock::data())); }
inline const_pointer c_str (void) const { return (string::const_pointer (memblock::cdata())); }
@ -217,7 +217,7 @@ public:
inline string& replace (const_iterator first, const_iterator last, initlist_t v) { return (replace (first, last, v.begin(), v.end())); }
#endif
protected:
size_type minimumFreeCapacity (void) const noexcept __attribute__((const));
virtual size_type minimumFreeCapacity (void) const noexcept __attribute__((const));
};
//----------------------------------------------------------------------

View File

@ -10,9 +10,6 @@
#include <errno.h>
#include <gint/bfile.h>
#define EAGAIN 11
#define EINTR 4
namespace ustl {
/// Default constructor.