summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/stdio/__stdio_close.c
blob: 0d7c91e6083ec11e578fd04ebcfba2dd84d93a00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
#else
#include <unistd.h>
#endif
#include "stdio_impl.h"
#include "aio_impl.h"

#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
static int dummy(int fd)
{
	return fd;
}

weak_alias(dummy, __aio_close);
#else
#define __aio_close(fd) (fd)
#endif

int __stdio_close(FILE *f)
{
#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
	return syscall(SYS_close, __aio_close(f->fd));
#else
	return close(__aio_close(f->fd));
#endif
}