mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/newlib_fcntl_r_signature' into 'master'
vfs: change fcntl argument to int (instead of va_list), add weak fcntl See merge request idf/esp-idf!4549
This commit is contained in:
commit
57e1b5dad8
@ -40,9 +40,9 @@ static void lwip_stop_socket_select_isr(BaseType_t *woken)
|
||||
}
|
||||
}
|
||||
|
||||
static int lwip_fcntl_r_wrapper(int fd, int cmd, va_list args)
|
||||
static int lwip_fcntl_r_wrapper(int fd, int cmd, int arg)
|
||||
{
|
||||
return lwip_fcntl_r(fd, cmd, va_arg(args, int));
|
||||
return lwip_fcntl_r(fd, cmd, arg);
|
||||
}
|
||||
|
||||
static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args)
|
||||
|
@ -163,8 +163,8 @@ typedef struct
|
||||
int (*rmdir)(const char* name);
|
||||
};
|
||||
union {
|
||||
int (*fcntl_p)(void* ctx, int fd, int cmd, va_list args);
|
||||
int (*fcntl)(int fd, int cmd, va_list args);
|
||||
int (*fcntl_p)(void* ctx, int fd, int cmd, int arg);
|
||||
int (*fcntl)(int fd, int cmd, int arg);
|
||||
};
|
||||
union {
|
||||
int (*ioctl_p)(void* ctx, int fd, int cmd, va_list args);
|
||||
|
@ -657,21 +657,27 @@ int rmdir(const char* name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
int _fcntl_r(struct _reent *r, int fd, int cmd, int arg)
|
||||
{
|
||||
const vfs_entry_t* vfs = get_vfs_for_fd(fd);
|
||||
const int local_fd = get_local_fd(vfs, fd);
|
||||
struct _reent* r = __getreent();
|
||||
if (vfs == NULL || local_fd < 0) {
|
||||
__errno_r(r) = EBADF;
|
||||
return -1;
|
||||
}
|
||||
int ret;
|
||||
CHECK_AND_CALL(ret, r, vfs, fcntl, local_fd, cmd, arg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, cmd);
|
||||
CHECK_AND_CALL(ret, r, vfs, fcntl, local_fd, cmd, args);
|
||||
int arg = va_arg(args, int);
|
||||
va_end(args);
|
||||
return ret;
|
||||
struct _reent* r = __getreent();
|
||||
return _fcntl_r(r, fd, cmd, arg);
|
||||
}
|
||||
|
||||
int ioctl(int fd, int cmd, ...)
|
||||
|
@ -265,7 +265,7 @@ static int uart_close(int fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uart_fcntl(int fd, int cmd, va_list args)
|
||||
static int uart_fcntl(int fd, int cmd, int arg)
|
||||
{
|
||||
assert(fd >=0 && fd < 3);
|
||||
int result = 0;
|
||||
@ -274,7 +274,6 @@ static int uart_fcntl(int fd, int cmd, va_list args)
|
||||
result |= O_NONBLOCK;
|
||||
}
|
||||
} else if (cmd == F_SETFL) {
|
||||
int arg = va_arg(args, int);
|
||||
s_non_blocking[fd] = (arg & O_NONBLOCK) != 0;
|
||||
} else {
|
||||
// unsupported operation
|
||||
|
Loading…
x
Reference in New Issue
Block a user