You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 line
523 B

5 年之前
  1. #pragma once
  2. #include <unistd.h>
  3. #include <fcntl.h>
  4. #include <stdint.h>
  5. namespace os{
  6. constexpr auto write = [](int32_t fd, const char* ptr, int64_t size){
  7. do
  8. {
  9. auto check = ::write(fd, ptr, size);
  10. if(check<0)
  11. {
  12. return check;
  13. }
  14. size-=check;
  15. ptr+=check;
  16. }while(size!=0);
  17. return size;
  18. };
  19. constexpr auto stdout_write = [](const char* ptr, size_t size){
  20. return write(0, ptr, size);
  21. };
  22. constexpr auto stderr_write = [](const char* ptr, size_t size){
  23. return write(2, ptr, size);
  24. };
  25. }