Browse Source

Some SCE compilation fixes

wip/image-kernel
Sam Hocevar 11 months ago
parent
commit
e26f6cb2ee
2 changed files with 28 additions and 15 deletions
  1. +22
    -4
      include/lol/format
  2. +6
    -11
      include/lol/private/base/env.h

+ 22
- 4
include/lol/format View File

@@ -12,11 +12,29 @@


#pragma once #pragma once


#include <version>
#if defined _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
#define LOL_HAS_STD_FORMAT 1

#if !defined __SCE__
# include <version> // Provide _LIBCPP_HAS_NO_INCOMPLETE_FORMAT if relevant
# if defined _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
# undef LOL_HAS_STD_FORMAT
# endif
#endif

#if defined __SCE__
# undef LOL_HAS_STD_FORMAT
# include <cstdio>
// These functions are used unconditionally in libfmt
static inline void flockfile(FILE* f) { }
static inline void funlockfile(FILE* f) { }
static inline int getc_unlocked(FILE*) { return 0; }
static inline int putc_unlocked(int, FILE*) { return 0; }
#endif

#if defined LOL_HAS_STD_FORMAT
# include <format>
#else
# define FMT_HEADER_ONLY # define FMT_HEADER_ONLY
# include "3rdparty/fmt/include/fmt/format.h" # include "3rdparty/fmt/include/fmt/format.h"
namespace std { using fmt::format; } namespace std { using fmt::format; }
#else
# include <format>
#endif #endif

+ 6
- 11
include/lol/private/base/env.h View File

@@ -1,7 +1,7 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010–2024 Sam Hocevar <sam@hocevar.net>
// //
// Lol Engine is free software. It comes without any warranty, to // Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it // the extent permitted by applicable law. You can redistribute it
@@ -12,13 +12,10 @@


#pragma once #pragma once


#include <string> // std::string
#include <cstdlib> // _dupenv_s / std::getenv
#include <cstdlib> // _dupenv_s / std::getenv
#include <string> // std::string


namespace lol
{

namespace sys
namespace lol::sys
{ {


static inline std::string getenv(std::string const &var) static inline std::string getenv(std::string const &var)
@@ -32,13 +29,11 @@ static inline std::string getenv(std::string const &var)
free(buf); free(buf);
return ret; return ret;
} }
#else
#elif !__SCE__
if (auto val = std::getenv(var.c_str())) if (auto val = std::getenv(var.c_str()))
return std::string(val); return std::string(val);
#endif #endif
return std::string(); return std::string();
} }


} // namespace os

} // namespace lol
} // namespace sys::lol

Loading…
Cancel
Save