1
0

syscall_close.c 717 B

1234567891011121314151617181920212223242526272829303132
  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. /*
  14. * The "__close" function should close the file corresponding to
  15. * "handle". It should return 0 on success and nonzero on failure.
  16. */
  17. #pragma module_name = "?__close"
  18. int __close(int handle)
  19. {
  20. if (handle == _LLIO_STDOUT ||
  21. handle == _LLIO_STDERR ||
  22. handle == _LLIO_STDIN)
  23. return _LLIO_ERROR;
  24. #ifdef RT_USING_POSIX
  25. return close(handle);
  26. #else
  27. return _LLIO_ERROR;
  28. #endif /* RT_USING_POSIX */
  29. }