Skip to content

Commit

Permalink
Merge pull request #3 from trcrsired/master
Browse files Browse the repository at this point in the history
6
  • Loading branch information
MacroModel authored Sep 20, 2024
2 parents 947679d + 8809a68 commit 68e2b58
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 1 deletion.
27 changes: 27 additions & 0 deletions examples/0014.random/pin6.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <fast_io.h>
#include <fast_io_device.h>
#include <random>

using namespace fast_io::io;

int main(int argc, char **argv)
{
std::size_t n{100};
if (1 < argc)
{
n = fast_io::to<std::size_t>(fast_io::mnp::os_c_str(argv[1]));
}
fast_io::u8obuf_file obf(u"pin6.txt");
fast_io::ibuf_white_hole_engine eng;
std::uniform_int_distribution<unsigned> ud(0, 9);
for (std::size_t i{}; i != n; ++i)
{
for (std::size_t j{}; j != 6zu; ++j)
{
char8_t ch(static_cast<char8_t>(ud(eng)));
ch += u8'0';
print(obf, fast_io::mnp::chvw(ch));
}
println(obf);
}
}
1 change: 1 addition & 0 deletions include/fast_io_core_impl/enums/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
#include "utime_flags.h"
#include "flock.h"
#include "mmap_flags.h"
#include "well_known_directory.h"
23 changes: 23 additions & 0 deletions include/fast_io_core_impl/enums/well_known_directory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

/*
W3C standard
File System Access
Draft Community Group Report
https://wicg.github.io/file-system-access/
*/

namespace fast_io
{

enum class well_known_directory : ::std::uint_least32_t
{
desktop,
documents,
downloads,
music,
pictures,
videos
};

} // namespace fast_io
7 changes: 7 additions & 0 deletions include/fast_io_hosted/platforms/posix_dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ struct

namespace details
{
#ifdef __DARWIN_C_LEVEL
extern int libc_getaddrinfo(char const *node, char const *service, posix_addrinfo const *hints,
posix_addrinfo **res) noexcept __asm__("_getaddrinfo");

extern void libc_freeaddrinfo(posix_addrinfo *res) noexcept __asm__("_freeaddrinfo");
#else
extern int libc_getaddrinfo(char const *node, char const *service, posix_addrinfo const *hints,
posix_addrinfo **res) noexcept __asm__("getaddrinfo");

extern void libc_freeaddrinfo(posix_addrinfo *res) noexcept __asm__("freeaddrinfo");
#endif
} // namespace details

class posix_dns_io_observer
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_legacy_impl/c/unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ inline bool ibuffer_underflow(u8c_io_observer_unlocked cio)
return details::bsd_underflow_impl(cio.fp);
}

#if defined(__MSDOS__)
#if defined(__MSDOS__) || defined(__DARWIN_C_LEVEL)
template <::std::integral ch_type>
inline bool obuffer_is_line_buffering_define(basic_c_io_observer_unlocked<ch_type> ciou) noexcept
{
Expand Down
2 changes: 2 additions & 0 deletions tests/0033.legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_executable(getfd getfd.cc)
add_executable(hackstdoutptr hackstdoutptr.cc)
add_test(getfd getfd)
add_test(hackstdoutptr hackstdoutptr)
add_subdirectory(kreckelfileno)
14 changes: 14 additions & 0 deletions tests/0033.legacy/hackstdoutptr.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <fast_io.h>

int main()
{
using namespace fast_io::mnp;
using namespace fast_io::io;
::fast_io::c_io_observer_unlocked ciob{stdout};
for(::std::size_t i{};i!=100000u;++i)
{
perrln(ciob,pointervw(obuffer_begin(ciob)), " ", pointervw(obuffer_curr(ciob)), " ", pointervw(obuffer_end(ciob)));
println(40);
perrln(ciob,pointervw(obuffer_begin(ciob)), " ", pointervw(obuffer_curr(ciob)), " ", pointervw(obuffer_end(ciob)));
}
}

0 comments on commit 68e2b58

Please sign in to comment.