Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

djgpp compatibility #2820

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
#else
# define FMT_CLASS_API
# if defined(FMT_EXPORT) || defined(FMT_SHARED)
# if defined(__GNUC__) || defined(__clang__)
# if (defined(__GNUC__) || defined(__clang__)) && !defined(DJGPP)
# define FMT_API __attribute__((visibility("default")))
# endif
# endif
Expand Down Expand Up @@ -300,6 +300,9 @@ FMT_GCC_PRAGMA("GCC optimize(\"Og\")")
FMT_BEGIN_NAMESPACE
FMT_MODULE_EXPORT_BEGIN

// Alias for older systems where std::wstring isn't defined.
using wstring = std::basic_string<wchar_t>;

// Implementations of enable_if_t and other metafunctions for older systems.
template <bool B, typename T = void>
using enable_if_t = typename std::enable_if<B, T>::type;
Expand Down
4 changes: 2 additions & 2 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#include "core.h"

#if FMT_GCC_VERSION
#if FMT_GCC_VERSION && !defined(DJGPP)
# define FMT_GCC_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
#else
# define FMT_GCC_VISIBILITY_HIDDEN
Expand Down Expand Up @@ -1232,7 +1232,7 @@ class utf8_to_utf16 {
operator basic_string_view<wchar_t>() const { return {&buffer_[0], size()}; }
auto size() const -> size_t { return buffer_.size() - 1; }
auto c_str() const -> const wchar_t* { return &buffer_[0]; }
auto str() const -> std::wstring { return {&buffer_[0], size()}; }
auto str() const -> wstring { return {&buffer_[0], size()}; }
};

namespace dragonbox {
Expand Down
6 changes: 5 additions & 1 deletion include/fmt/ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,13 @@ void print(std::ostream& os, format_string<Args...> fmt, Args&&... args) {
vprint(os, fmt, fmt::make_format_args(args...));
}

// Alias for older systems where std::wostream isn't defined.
FMT_MODULE_EXPORT
using wostream = std::basic_ostream<wchar_t>;

FMT_MODULE_EXPORT
template <typename... Args>
void print(std::wostream& os,
void print(wostream& os,
basic_format_string<wchar_t, type_identity_t<Args>...> fmt,
Args&&... args) {
vprint(os, fmt, fmt::make_format_args<buffer_context<wchar_t>>(args...));
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/xchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ template <typename... T> void print(wformat_string<T...> fmt, T&&... args) {
/**
Converts *value* to ``std::wstring`` using the default format for type *T*.
*/
template <typename T> inline auto to_wstring(const T& value) -> std::wstring {
template <typename T> inline auto to_wstring(const T& value) -> wstring {
return format(FMT_STRING(L"{}"), value);
}
FMT_MODULE_EXPORT_END
Expand Down
9 changes: 9 additions & 0 deletions src/os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
# include <windows.h>
#endif

#ifdef DJGPP
# include <dpmi.h>
#endif

#ifdef fileno
# undef fileno
#endif
Expand Down Expand Up @@ -354,6 +358,11 @@ long getpagesize() {
SYSTEM_INFO si;
GetSystemInfo(&si);
return si.dwPageSize;
# elif defined(DJGPP)
unsigned long size;
if (__dpmi_get_page_size(&size) != 0)
FMT_THROW(system_error(ENOSYS, "cannot get memory page size"));
return size;
# else
long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE));
if (size < 0) FMT_THROW(system_error(errno, "cannot get memory page size"));
Expand Down