[PATCH 0/3] MR10161: include: Add some vcruntime headers.
From: Rémi Bernon <rbernon@codeweavers.com> --- include/Makefile.in | 1 + include/msvcrt/vcruntime_exception.h | 92 ++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 include/msvcrt/vcruntime_exception.h diff --git a/include/Makefile.in b/include/Makefile.in index dabb9c75944..0026ac978aa 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -578,6 +578,7 @@ SOURCES = \ msvcrt/uchar.h \ msvcrt/unistd.h \ msvcrt/vadefs.h \ + msvcrt/vcruntime_exception.h \ msvcrt/wchar.h \ msvcrt/wctype.h \ mswsock.h \ diff --git a/include/msvcrt/vcruntime_exception.h b/include/msvcrt/vcruntime_exception.h new file mode 100644 index 00000000000..f015945b060 --- /dev/null +++ b/include/msvcrt/vcruntime_exception.h @@ -0,0 +1,92 @@ +/* + * Copyright 2024 Rémi Bernon for CodeWeavers + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_VCRUNTIME_EXCEPTION_H +#define __WINE_VCRUNTIME_EXCEPTION_H + +struct __std_exception_data +{ + const char *_What; + char _DoFree; +}; + +extern "C" +{ +void __cdecl __std_exception_copy(const struct __std_exception_data *src, struct __std_exception_data *dst); +void __cdecl __std_exception_destroy(struct __std_exception_data *data); +} /* extern "C" */ + +namespace std +{ + +class exception +{ +private: + struct __std_exception_data data; +public: + exception() noexcept : data() {} + exception(const exception &other) noexcept + { + __std_exception_copy(&other.data, &this->data); + } + explicit exception(const char *what) throw() : data() + { + struct __std_exception_data new_data = {what, true}; + __std_exception_copy(&new_data, &this->data); + } + explicit exception(const char *what, int) noexcept : data() + { + data._What = what; + } + exception &operator=(const exception &other) noexcept + { + if (this != &other) + { + __std_exception_destroy(&this->data); + __std_exception_copy(&other.data, &this->data); + } + return *this; + } + virtual ~exception() noexcept + { + __std_exception_destroy(&data); + } + virtual const char *what() const + { + return data._What ? data._What : "Unknown exception"; + } +}; + +class bad_alloc : public exception +{ +private: + friend class bad_array_new_length; + bad_alloc(const char *what) throw() : exception(what, 1) {} +public: + bad_alloc() throw() : exception("bad allocation", 1) {} +}; + +class bad_array_new_length : public bad_alloc +{ +public: + bad_array_new_length() noexcept : bad_alloc("bad array new length") {} +}; + +} /* namespace std */ + +#endif /* __WINE_VCRUNTIME_EXCEPTION_H */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10161
From: Rémi Bernon <rbernon@codeweavers.com> --- include/Makefile.in | 1 + include/msvcrt/vcruntime_typeinfo.h | 99 +++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 include/msvcrt/vcruntime_typeinfo.h diff --git a/include/Makefile.in b/include/Makefile.in index 0026ac978aa..266d2451fef 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -579,6 +579,7 @@ SOURCES = \ msvcrt/unistd.h \ msvcrt/vadefs.h \ msvcrt/vcruntime_exception.h \ + msvcrt/vcruntime_typeinfo.h \ msvcrt/wchar.h \ msvcrt/wctype.h \ mswsock.h \ diff --git a/include/msvcrt/vcruntime_typeinfo.h b/include/msvcrt/vcruntime_typeinfo.h new file mode 100644 index 00000000000..dd7f15d62db --- /dev/null +++ b/include/msvcrt/vcruntime_typeinfo.h @@ -0,0 +1,99 @@ +/* + * Copyright 2024 Rémi Bernon for CodeWeavers + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_VCRUNTIME_TYPEINFO_H +#define __WINE_VCRUNTIME_TYPEINFO_H + +#include "vcruntime_exception.h" + +struct __std_type_info_data +{ + const char *_UndecoratedName; + const char _DecoratedName[1]; + __std_type_info_data() = delete; + __std_type_info_data(const __std_type_info_data&) = delete; + __std_type_info_data &operator=(const __std_type_info_data&) = delete; +}; + +struct __type_info_node {}; +extern __type_info_node __type_info_root_node; + +extern "C" +{ +extern int __cdecl __std_type_info_compare(const __std_type_info_data *l, const __std_type_info_data *r); +extern size_t __cdecl __std_type_info_hash(const __std_type_info_data *ti); +extern char const *__cdecl __std_type_info_name(__std_type_info_data *ti, __type_info_node *header); +} + +class type_info +{ +public: + size_t hash_code() const noexcept + { + return __std_type_info_hash(&data); + } + bool operator==(const type_info &other) const + { + return __std_type_info_compare(&data, &other.data) == 0; + } + bool operator!=(const type_info &other) const + { + return __std_type_info_compare(&data, &other.data) != 0; + } + bool before(const type_info &other) const + { + return __std_type_info_compare(&data, &other.data) < 0; + } + const char *name() const + { + return __std_type_info_name(&data, &__type_info_root_node); + } + const char *raw_name() const + { + return data._DecoratedName; + } + virtual ~type_info() noexcept {} + + type_info(const type_info&) = delete; + type_info &operator=(const type_info&) = delete; + +private: + mutable __std_type_info_data data; +}; + +namespace std +{ +using ::type_info; + +class bad_cast : public exception +{ +public: + bad_cast() noexcept : exception("bad cast", 1) {} + + static bad_cast __construct_from_string_literal(const char *message) noexcept + { + return bad_cast(message, 1); + } + +private: + bad_cast(const char *const message, int) noexcept : exception(message, 1) {} +}; + +} + +#endif /* __WINE_VCRUNTIME_TYPEINFO_H */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10161
From: Rémi Bernon <rbernon@codeweavers.com> --- include/Makefile.in | 2 ++ include/msvcrt/new.h | 25 +++++++++++++++ include/msvcrt/vcruntime_new.h | 58 ++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 include/msvcrt/new.h create mode 100644 include/msvcrt/vcruntime_new.h diff --git a/include/Makefile.in b/include/Makefile.in index 266d2451fef..ef1c65aeeed 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -556,6 +556,7 @@ SOURCES = \ msvcrt/mbctype.h \ msvcrt/mbstring.h \ msvcrt/memory.h \ + msvcrt/new.h \ msvcrt/process.h \ msvcrt/search.h \ msvcrt/setjmp.h \ @@ -579,6 +580,7 @@ SOURCES = \ msvcrt/unistd.h \ msvcrt/vadefs.h \ msvcrt/vcruntime_exception.h \ + msvcrt/vcruntime_new.h \ msvcrt/vcruntime_typeinfo.h \ msvcrt/wchar.h \ msvcrt/wctype.h \ diff --git a/include/msvcrt/new.h b/include/msvcrt/new.h new file mode 100644 index 00000000000..721e1d3cdb4 --- /dev/null +++ b/include/msvcrt/new.h @@ -0,0 +1,25 @@ +/* + * Copyright 2026 Jacek Caban for CodeWeavers + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _INC_NEW +#define _INC_NEW + +#include <corecrt.h> +#include <vcruntime_new.h> + +#endif /* _INC_NEW */ diff --git a/include/msvcrt/vcruntime_new.h b/include/msvcrt/vcruntime_new.h new file mode 100644 index 00000000000..c10fb9740e5 --- /dev/null +++ b/include/msvcrt/vcruntime_new.h @@ -0,0 +1,58 @@ +/* + * Copyright 2024 Rémi Bernon for CodeWeavers + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __VCRUNTIME_NEW_H +#define __VCRUNTIME_NEW_H + +namespace std +{ +enum class align_val_t : size_t {}; +struct nothrow_t {}; +extern nothrow_t const nothrow; +} /* namespace std */ + +void *__cdecl operator new(size_t size); +void *__cdecl operator new[](size_t size); +void __cdecl operator delete(void *ptr) noexcept; +void __cdecl operator delete[](void *ptr) noexcept; +void __cdecl operator delete(void *ptr, size_t size) noexcept; +void __cdecl operator delete[](void *ptr, size_t size) noexcept; + +void *__cdecl operator new(size_t size, std::align_val_t align); +void *__cdecl operator new[](size_t size, std::align_val_t align); +void __cdecl operator delete(void *ptr, std::align_val_t align) noexcept; +void __cdecl operator delete[](void *ptr, std::align_val_t align) noexcept; +void __cdecl operator delete(void *ptr, size_t size, std::align_val_t align) noexcept; +void __cdecl operator delete[](void *ptr, size_t size, std::align_val_t align) noexcept; + +void *__cdecl operator new(size_t size, std::nothrow_t const&) noexcept; +void *__cdecl operator new[](size_t size, std::nothrow_t const&) noexcept; +void __cdecl operator delete(void *ptr, std::nothrow_t const&) noexcept; +void __cdecl operator delete[](void *ptr, std::nothrow_t const&) noexcept; + +void *__cdecl operator new(size_t size, std::align_val_t align, std::nothrow_t const&) noexcept; +void *__cdecl operator new[](size_t size, std::align_val_t align, std::nothrow_t const&) noexcept; +void __cdecl operator delete(void *ptr, std::align_val_t align, std::nothrow_t const&) noexcept; +void __cdecl operator delete[](void *ptr, std::align_val_t align, std::nothrow_t const&) noexcept; + +inline void *operator new(size_t size, void *ptr) noexcept { return ptr; } +inline void *operator new[](size_t size, void *ptr) throw() { return ptr; } +inline void operator delete(void*, void*) noexcept {} +inline void operator delete[](void*, void*) noexcept {} + +#endif /* __WINE_NEW_H */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10161
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10161
participants (2)
-
Jacek Caban (@jacek) -
Rémi Bernon