My Project
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
soc_poll.c
Go to the documentation of this file.
1 #include "soc_common.h"
2 #include <poll.h>
3 
4 int poll(struct pollfd *fds, nfds_t nfsd, int timeout)
5 {
6  int ret = 0;
7  u32 size = sizeof(struct pollfd)*nfsd;
8  u32 *cmdbuf = getThreadCommandBuffer();
9  u32 saved_threadstorage[2];
10 
11  cmdbuf[0] = 0x00140084;
12  cmdbuf[1] = (u32)nfsd;
13  cmdbuf[2] = (u32)timeout;
14  cmdbuf[3] = 0x20;
15  cmdbuf[5] = (size<<14) | 0x2802;
16  cmdbuf[6] = (u32)fds;
17 
18  saved_threadstorage[0] = cmdbuf[0x100>>2];
19  saved_threadstorage[1] = cmdbuf[0x104>>2];
20 
21  cmdbuf[0x100>>2] = (size<<14) | 2;
22  cmdbuf[0x104>>2] = (u32)fds;
23 
24  if((ret = svcSendSyncRequest(SOCU_handle)) != 0)return ret;
25 
26  cmdbuf[0x100>>2] = saved_threadstorage[0];
27  cmdbuf[0x104>>2] = saved_threadstorage[1];
28 
29  ret = (int)cmdbuf[1];
30  if(ret==0)ret = _net_convert_error(cmdbuf[2]);
31  if(ret<0)SOCU_errno = ret;
32 
33  if(ret<0)return -1;
34  return ret;
35 }
u32 * getThreadCommandBuffer(void)
int SOCU_errno
Definition: soc_common.c:5
uint32_t u32
Definition: types.h:23
int poll(struct pollfd *fds, nfds_t nfsd, int timeout)
Definition: soc_poll.c:4
Definition: poll.h:19
s32 _net_convert_error(s32 sock_retval)
Definition: soc_common.c:92
s32 svcSendSyncRequest(Handle session)
Handle SOCU_handle
Definition: soc_common.c:4
u32 nfds_t
Definition: poll.h:17