Răsfoiți Sursa

fix syscall errno

shaojinchun 4 ani în urmă
părinte
comite
203c186c8c

Fișier diff suprimat deoarece este prea mare
+ 160 - 160
components/lwp/lwp_syscall.c


+ 1 - 1
components/net/lwip-2.0.2/src/api/sockets.c

@@ -300,7 +300,7 @@ static volatile int select_cb_ctr;
 
 #if LWIP_SOCKET_SET_ERRNO
 #ifndef set_errno
-#define set_errno(err) do { if (err) { errno = (err); } } while(0)
+#define set_errno(err) do { if (err) { errno = -(err); } } while(0)
 #endif
 #else /* LWIP_SOCKET_SET_ERRNO */
 #define set_errno(err)

+ 21 - 3
components/net/sal_socket/dfs_net/dfs_net.c

@@ -34,23 +34,41 @@ int dfs_net_getsocket(int fd)
 
 static int dfs_net_ioctl(struct dfs_fd* file, int cmd, void* args)
 {
+    int ret;
     int socket = (int)(size_t)file->fnode->data;
 
-    return sal_ioctlsocket(socket, cmd, args);
+    ret = sal_ioctlsocket(socket, cmd, args);
+    if (ret < 0)
+    {
+        ret = rt_get_errno();
+    }
+    return ret;
 }
 
 static int dfs_net_read(struct dfs_fd* file, void *buf, size_t count)
 {
+    int ret;
     int socket = (int)(size_t)file->fnode->data;
 
-    return sal_recvfrom(socket, buf, count, 0, NULL, NULL);
+    ret = sal_recvfrom(socket, buf, count, 0, NULL, NULL);
+    if (ret < 0)
+    {
+        ret = rt_get_errno();
+    }
+    return ret;
 }
 
 static int dfs_net_write(struct dfs_fd *file, const void *buf, size_t count)
 {
+    int ret;
     int socket = (int)(size_t)file->fnode->data;
 
-    return sal_sendto(socket, buf, count, 0, NULL, 0);
+    ret = sal_sendto(socket, buf, count, 0, NULL, 0);
+    if (ret < 0)
+    {
+        ret = rt_get_errno();
+    }
+    return ret;
 }
 
 static int dfs_net_close(struct dfs_fd* file)

+ 5 - 17
src/kservice.c

@@ -97,23 +97,6 @@ void rt_set_errno(rt_err_t error)
     }
 
     tid->error = error;
-#ifdef RT_USING_LWP
-    /* is a process's thread */
-    if (tid->lwp && tid->thread_idr)
-    {
-        pthread_t ptid;
-
-        if (error < 0)
-        {
-            error = -error;
-        }
-        ptid = (pthread_t)((size_t)tid->thread_idr - sizeof(struct __pthread));
-        if (lwp_user_accessable(ptid, sizeof(struct __pthread)))
-        {
-            lwp_put_to_user(&ptid->errno_val, &error, sizeof(ptid->errno_val));
-        }
-    }
-#endif
 }
 RTM_EXPORT(rt_set_errno);
 
@@ -138,6 +121,11 @@ int *_rt_errno(void)
 RTM_EXPORT(_rt_errno);
 
 #ifdef RT_USING_MUSL
+int *__errno_location(void)
+{
+    return _rt_errno();
+}
+
 int *___errno_location(void)
 {
     return _rt_errno();

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff