1
0

syscall_close.c 869 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2015-01-28 Bernard first version
  9. */
  10. #include <rtthread.h>
  11. #include <LowLevelIOInterface.h>
  12. #include <unistd.h>
  13. #include <compiler_private.h>
  14. #define DBG_TAG "dlib.syscall.close"
  15. #define DBG_LVL DBG_INFO
  16. #include <rtdbg.h>
  17. /*
  18. * The "__close" function should close the file corresponding to
  19. * "handle". It should return 0 on success and nonzero on failure.
  20. */
  21. #pragma module_name = "?__close"
  22. int __close(int handle)
  23. {
  24. if (handle == _LLIO_STDOUT ||
  25. handle == _LLIO_STDERR ||
  26. handle == _LLIO_STDIN)
  27. return _LLIO_ERROR;
  28. #ifdef DFS_USING_POSIX
  29. return close(handle);
  30. #else
  31. LOG_W(_WARNING_WITHOUT_FS);
  32. return _LLIO_ERROR;
  33. #endif /* DFS_USING_POSIX */
  34. }