forked from OctaForge/libostd
remove types.hh
This commit is contained in:
parent
3b7f54e64c
commit
4a7baa40a0
|
@ -21,7 +21,6 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ostd/types.hh"
|
|
||||||
#include "ostd/platform.hh"
|
#include "ostd/platform.hh"
|
||||||
|
|
||||||
#if !defined(OSTD_PLATFORM_POSIX) && !defined(OSTD_PLATFORM_WIN32)
|
#if !defined(OSTD_PLATFORM_POSIX) && !defined(OSTD_PLATFORM_WIN32)
|
||||||
|
@ -181,7 +180,7 @@ struct basic_fixedsize_stack {
|
||||||
detail::stack_protect(p, pgs);
|
detail::stack_protect(p, pgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_context ret{static_cast<byte *>(p) + asize, asize};
|
stack_context ret{static_cast<unsigned char *>(p) + asize, asize};
|
||||||
#ifdef OSTD_USE_VALGRIND
|
#ifdef OSTD_USE_VALGRIND
|
||||||
ret.valgrind_id = VALGRIND_STACK_REGISTER(ret.ptr, p);
|
ret.valgrind_id = VALGRIND_STACK_REGISTER(ret.ptr, p);
|
||||||
#endif
|
#endif
|
||||||
|
@ -196,7 +195,9 @@ struct basic_fixedsize_stack {
|
||||||
#ifdef OSTD_USE_VALGRIND
|
#ifdef OSTD_USE_VALGRIND
|
||||||
VALGRIND_STACK_DEREGISTER(st.valgrind_id);
|
VALGRIND_STACK_DEREGISTER(st.valgrind_id);
|
||||||
#endif
|
#endif
|
||||||
detail::stack_free(static_cast<byte *>(st.ptr) - st.size, st.size);
|
detail::stack_free(
|
||||||
|
static_cast<unsigned char *>(st.ptr) - st.size, st.size
|
||||||
|
);
|
||||||
st.ptr = nullptr;
|
st.ptr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "ostd/platform.hh"
|
#include "ostd/platform.hh"
|
||||||
#include "ostd/types.hh"
|
|
||||||
#include "ostd/range.hh"
|
#include "ostd/range.hh"
|
||||||
|
|
||||||
#include "ostd/context_stack.hh"
|
#include "ostd/context_stack.hh"
|
||||||
|
@ -268,8 +267,10 @@ protected:
|
||||||
p_stack = sa.allocate();
|
p_stack = sa.allocate();
|
||||||
|
|
||||||
void *sp = get_stack_ptr<SA>();
|
void *sp = get_stack_ptr<SA>();
|
||||||
size_t asize = p_stack.size -
|
size_t asize = p_stack.size - (
|
||||||
(static_cast<byte *>(p_stack.ptr) - static_cast<byte *>(sp));
|
static_cast<unsigned char *>(p_stack.ptr) -
|
||||||
|
static_cast<unsigned char *>(sp)
|
||||||
|
);
|
||||||
|
|
||||||
p_coro = detail::ostd_make_fcontext(sp, asize, &context_call<C, SA>);
|
p_coro = detail::ostd_make_fcontext(sp, asize, &context_call<C, SA>);
|
||||||
new (sp) SA(std::move(sa));
|
new (sp) SA(std::move(sa));
|
||||||
|
@ -287,7 +288,7 @@ private:
|
||||||
*/
|
*/
|
||||||
constexpr size_t sasize = sizeof(SA);
|
constexpr size_t sasize = sizeof(SA);
|
||||||
|
|
||||||
void *sp = static_cast<byte *>(p_stack.ptr) - sasize - salign;
|
void *sp = static_cast<unsigned char *>(p_stack.ptr) - sasize - salign;
|
||||||
size_t space = sasize + salign;
|
size_t space = sasize + salign;
|
||||||
sp = std::align(salign, sasize, sp, space);
|
sp = std::align(salign, sasize, sp, space);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace detail {
|
||||||
p_class(ev.p_class), p_nfuncs(ev.p_nfuncs)
|
p_class(ev.p_class), p_nfuncs(ev.p_nfuncs)
|
||||||
{
|
{
|
||||||
using func_t = std::function<void(C &, A...)>;
|
using func_t = std::function<void(C &, A...)>;
|
||||||
byte *bufp = new byte[sizeof(func_t) * p_nfuncs];
|
auto *bufp = new unsigned char[sizeof(func_t) * p_nfuncs];
|
||||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||||
for (size_t i = 0; i < p_nfuncs; ++i)
|
for (size_t i = 0; i < p_nfuncs; ++i)
|
||||||
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
||||||
|
@ -37,7 +37,7 @@ namespace detail {
|
||||||
using func_t = std::function<void(C &, A...)>;
|
using func_t = std::function<void(C &, A...)>;
|
||||||
p_class = ev.p_class;
|
p_class = ev.p_class;
|
||||||
p_nfuncs = ev.p_nfuncs;
|
p_nfuncs = ev.p_nfuncs;
|
||||||
byte *bufp = new byte[sizeof(func_t) * p_nfuncs];
|
auto *bufp = new unsigned char[sizeof(func_t) * p_nfuncs];
|
||||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||||
for (size_t i = 0; i < p_nfuncs; ++i) {
|
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||||
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
||||||
|
@ -58,7 +58,7 @@ namespace detail {
|
||||||
using func = std::function<void(C &, A...)>;
|
using func = std::function<void(C &, A...)>;
|
||||||
p_funcs[i].~func();
|
p_funcs[i].~func();
|
||||||
}
|
}
|
||||||
delete[] reinterpret_cast<byte *>(p_funcs);
|
delete[] reinterpret_cast<unsigned char *>(p_funcs);
|
||||||
p_funcs = nullptr;
|
p_funcs = nullptr;
|
||||||
p_nfuncs = 0;
|
p_nfuncs = 0;
|
||||||
}
|
}
|
||||||
|
@ -72,14 +72,14 @@ namespace detail {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
byte *bufp = new byte[sizeof(func_t) * (p_nfuncs + 1)];
|
auto *bufp = new unsigned char[sizeof(func_t) * (p_nfuncs + 1)];
|
||||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||||
for (size_t i = 0; i < p_nfuncs; ++i) {
|
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||||
new (&nbuf[i]) func_t(std::move(p_funcs[i]));
|
new (&nbuf[i]) func_t(std::move(p_funcs[i]));
|
||||||
p_funcs[i].~func_t();
|
p_funcs[i].~func_t();
|
||||||
}
|
}
|
||||||
new (&nbuf[p_nfuncs]) func_t(std::forward<F>(func));
|
new (&nbuf[p_nfuncs]) func_t(std::forward<F>(func));
|
||||||
delete[] reinterpret_cast<byte *>(p_funcs);
|
delete[] reinterpret_cast<unsigned char *>(p_funcs);
|
||||||
p_funcs = nbuf;
|
p_funcs = nbuf;
|
||||||
return p_nfuncs++;
|
return p_nfuncs++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace detail {
|
||||||
* 7 .. string
|
* 7 .. string
|
||||||
* 8 .. custom object
|
* 8 .. custom object
|
||||||
*/
|
*/
|
||||||
static constexpr byte const fmt_specs[] = {
|
static constexpr unsigned char const fmt_specs[] = {
|
||||||
/* uppercase spec set */
|
/* uppercase spec set */
|
||||||
1, 3, 8, 8, /* A B C D */
|
1, 3, 8, 8, /* A B C D */
|
||||||
1, 1, 1, 8, /* E F G H */
|
1, 1, 1, 8, /* E F G H */
|
||||||
|
@ -689,7 +689,7 @@ struct format_spec {
|
||||||
* conventions on this. If the position was not specified, this just
|
* conventions on this. If the position was not specified, this just
|
||||||
* returns 0.
|
* returns 0.
|
||||||
*/
|
*/
|
||||||
byte index() const { return p_index; }
|
unsigned char index() const { return p_index; }
|
||||||
|
|
||||||
/** @brief Gets the inner part of a range or tuple format specifier.
|
/** @brief Gets the inner part of a range or tuple format specifier.
|
||||||
*
|
*
|
||||||
|
@ -769,7 +769,7 @@ private:
|
||||||
|
|
||||||
char p_spec = '\0';
|
char p_spec = '\0';
|
||||||
|
|
||||||
byte p_index = 0;
|
unsigned char p_index = 0;
|
||||||
|
|
||||||
bool p_is_tuple = false;
|
bool p_is_tuple = false;
|
||||||
bool p_is_nested = false;
|
bool p_is_nested = false;
|
||||||
|
@ -870,7 +870,7 @@ private:
|
||||||
if (ndig <= 0) return false; /* no pos given */
|
if (ndig <= 0) return false; /* no pos given */
|
||||||
int idx = atoi(p_buf);
|
int idx = atoi(p_buf);
|
||||||
if (idx <= 0 || idx > 255) return false; /* bad index */
|
if (idx <= 0 || idx > 255) return false; /* bad index */
|
||||||
p_index = byte(idx);
|
p_index = static_cast<unsigned char>(idx);
|
||||||
p_fmt.pop_front();
|
p_fmt.pop_front();
|
||||||
havepos = true;
|
havepos = true;
|
||||||
}
|
}
|
||||||
|
@ -1019,7 +1019,7 @@ private:
|
||||||
if (isp == 's') {
|
if (isp == 's') {
|
||||||
isp = (ptr ? 'x' : 'd');
|
isp = (ptr ? 'x' : 'd');
|
||||||
}
|
}
|
||||||
byte specn = detail::fmt_specs[isp - 65];
|
unsigned char specn = detail::fmt_specs[isp - 65];
|
||||||
if (specn <= 2 || specn > 7) {
|
if (specn <= 2 || specn > 7) {
|
||||||
throw format_error{"cannot format integers with the given spec"};
|
throw format_error{"cannot format integers with the given spec"};
|
||||||
}
|
}
|
||||||
|
@ -1102,7 +1102,7 @@ private:
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
void write_float(R &writer, T val) const {
|
void write_float(R &writer, T val) const {
|
||||||
char isp = spec();
|
char isp = spec();
|
||||||
byte specn = detail::fmt_specs[isp - 65];
|
unsigned char specn = detail::fmt_specs[isp - 65];
|
||||||
if (specn != 1 && specn != 7) {
|
if (specn != 1 && specn != 7) {
|
||||||
throw format_error{"cannot format floats with the given spec"};
|
throw format_error{"cannot format floats with the given spec"};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ostd/types.hh"
|
|
||||||
|
|
||||||
namespace ostd {
|
namespace ostd {
|
||||||
|
|
||||||
struct input_range_tag {};
|
struct input_range_tag {};
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ostd/platform.hh"
|
#include "ostd/platform.hh"
|
||||||
#include "ostd/types.hh"
|
|
||||||
#include "ostd/range.hh"
|
#include "ostd/range.hh"
|
||||||
#include "ostd/string.hh"
|
#include "ostd/string.hh"
|
||||||
#include "ostd/format.hh"
|
#include "ostd/format.hh"
|
||||||
|
@ -77,13 +76,13 @@ struct stream {
|
||||||
virtual void write_bytes(void const *, size_t) {}
|
virtual void write_bytes(void const *, size_t) {}
|
||||||
|
|
||||||
virtual int get_char() {
|
virtual int get_char() {
|
||||||
byte c;
|
unsigned char c;
|
||||||
read_bytes(&c, 1);
|
read_bytes(&c, 1);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void put_char(int c) {
|
virtual void put_char(int c) {
|
||||||
byte wc = byte(c);
|
unsigned char wc = static_cast<unsigned char>(c);
|
||||||
write_bytes(&wc, 1);
|
write_bytes(&wc, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
/* Core type aliases for OctaSTD.
|
|
||||||
*
|
|
||||||
* This file is part of OctaSTD. See COPYING.md for futher information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OSTD_TYPES_HH
|
|
||||||
#define OSTD_TYPES_HH
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace ostd {
|
|
||||||
|
|
||||||
/* "builtin" types */
|
|
||||||
|
|
||||||
using sbyte = signed char;
|
|
||||||
using byte = unsigned char;
|
|
||||||
using ushort = unsigned short;
|
|
||||||
using uint = unsigned int;
|
|
||||||
using ulong = unsigned long;
|
|
||||||
using ullong = unsigned long long;
|
|
||||||
using llong = long long;
|
|
||||||
|
|
||||||
using ldouble = long double;
|
|
||||||
|
|
||||||
/* used occasionally for template variables */
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template<typename> struct undef_t;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -6,8 +6,6 @@
|
||||||
#ifndef OSTD_VECMATH_HH
|
#ifndef OSTD_VECMATH_HH
|
||||||
#define OSTD_VECMATH_HH
|
#define OSTD_VECMATH_HH
|
||||||
|
|
||||||
#include "ostd/types.hh"
|
|
||||||
|
|
||||||
namespace ostd {
|
namespace ostd {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -132,7 +130,7 @@ inline vec2<T> operator-(vec2<T> const &a) {
|
||||||
|
|
||||||
using vec2f = vec2<float>;
|
using vec2f = vec2<float>;
|
||||||
using vec2d = vec2<double>;
|
using vec2d = vec2<double>;
|
||||||
using vec2b = vec2<byte>;
|
using vec2b = vec2<unsigned char>;
|
||||||
using vec2i = vec2<int>;
|
using vec2i = vec2<int>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -258,7 +256,7 @@ inline vec3<T> operator-(vec3<T> const &a) {
|
||||||
|
|
||||||
using vec3f = vec3<float>;
|
using vec3f = vec3<float>;
|
||||||
using vec3d = vec3<double>;
|
using vec3d = vec3<double>;
|
||||||
using vec3b = vec3<byte>;
|
using vec3b = vec3<unsigned char>;
|
||||||
using vec3i = vec3<int>;
|
using vec3i = vec3<int>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -384,7 +382,7 @@ inline vec4<T> operator-(vec4<T> const &a) {
|
||||||
|
|
||||||
using vec4f = vec4<float>;
|
using vec4f = vec4<float>;
|
||||||
using vec4d = vec4<double>;
|
using vec4d = vec4<double>;
|
||||||
using vec4b = vec4<byte>;
|
using vec4b = vec4<unsigned char>;
|
||||||
using vec4i = vec4<int>;
|
using vec4i = vec4<int>;
|
||||||
|
|
||||||
} /* namespace ostd */
|
} /* namespace ostd */
|
||||||
|
|
Loading…
Reference in a new issue