Skip to content

Commit 36ea2bc

Browse files
committed
implement fcntl
1 parent f7bc088 commit 36ea2bc

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

libogc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ add_library(ogc STATIC
1919
ogc_sockets/soc_accept.c
2020
ogc_sockets/soc_poll.c
2121
ogc_sockets/soc_getsockname.c
22+
ogc_sockets/soc_fcntl.c
2223

2324
console.c
2425
lwp_queue.c

libogc/ogc_sockets/soc_fcntl.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "soc_common.h"
2+
#include <errno.h>
3+
#include <fcntl.h>
4+
#include <stdarg.h>
5+
6+
int fcntl(int sockfd, int cmd, ...)
7+
{
8+
9+
int arg = 0;
10+
11+
sockfd = soc_get_fd(sockfd);
12+
if(sockfd < 0) {
13+
errno = -sockfd;
14+
return -1;
15+
}
16+
17+
va_list args;
18+
if(cmd == F_SETFL) {
19+
va_start(args, cmd);
20+
arg = va_arg(args, int);
21+
va_end(args);
22+
}
23+
24+
return net_fcntl(sockfd, cmd, arg);
25+
}

0 commit comments

Comments
 (0)