]> granicus.if.org Git - esp-idf/commitdiff
fix socket compile error
authorliuzhifu <liuzhifu@espressif.com>
Wed, 17 Aug 2016 13:05:29 +0000 (21:05 +0800)
committerWu Jian Gang <wujiangang@espressif.com>
Fri, 26 Aug 2016 11:03:50 +0000 (19:03 +0800)
components/freertos/include/freertos/FreeRTOS.h
components/freertos/tasks.c
components/lwip/api/sockets.c
components/lwip/include/lwip/port/arch/sys_arch.h
components/lwip/port/freertos/sys_arch.c

index 980f53d577bc9abb7492542626792cb56532ba90..ff76db27ec384a702056c13efdd4e40aa122fdbf 100644 (file)
@@ -783,6 +783,10 @@ V8 if desired. */
        #define xList List_t
 #endif /* configENABLE_BACKWARD_COMPATIBILITY */
 
+#ifndef configESP32_PER_TASK_DATA
+       #define configESP32_PER_TASK_DATA 1
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 97e4b6a0047638c5d9af96f7ce2031329cd2608d..adeaee60c277c62a4766ea1a8c0897b96f8db413 100644 (file)
@@ -84,6 +84,7 @@ task.h is included from an application file. */
 #include "timers.h"
 #include "StackMacros.h"
 #include "portmacro.h"
+#include "semphr.h"
 
 /* Lint e961 and e750 are suppressed as a MISRA exception justified because the
 MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
@@ -205,6 +206,10 @@ typedef struct tskTaskControlBlock
                volatile eNotifyValue eNotifyState;
        #endif
 
+#if (configESP32_PER_TASK_DATA == 1)
+       void *data;
+#endif
+
 } tskTCB;
 
 /* The old tskTCB name is maintained above then typedefed to the new TCB_t name
@@ -606,6 +611,9 @@ BaseType_t i;
 
        if( pxNewTCB != NULL )
        {
+#if (configESP32_PER_TASK_DATA == 1)
+               pxNewTCB->data = NULL;
+#endif
                #if( portUSING_MPU_WRAPPERS == 1 )
                        /* Should the task be created in privileged mode? */
                        BaseType_t xRunPrivileged;
@@ -791,6 +799,11 @@ BaseType_t i;
                        being deleted. */
                        pxTCB = prvGetTCBFromHandle( xTaskToDelete );
 
+#if (configESP32_PER_TASK_DATA == 1)
+                       if (pxTCB->data){
+                               vSemaphoreDelete( pxTCB->data );
+                       }
+#endif
                        /* Remove task from the ready list and place in the     termination list.
                        This will stop the task from be scheduled.  The idle task will check
                        the termination list and free up any memory allocated by the
@@ -4580,7 +4593,21 @@ TickType_t uxReturn;
 #endif /* configUSE_TASK_NOTIFICATIONS */
 
 /*-----------------------------------------------------------*/
+#if (configESP32_PER_TASK_DATA == 1)
+void* xTaskGetPerTaskData(void)
+{
+       TCB_t *pxTCB = (TCB_t*)(xTaskGetCurrentTaskHandle());
+       if (pxTCB){
+               if (!pxTCB->data){
+                       vSemaphoreCreateBinary(pxTCB->data);
+               }
+               return (void*)(&pxTCB->data);
+        }
 
+       return NULL;
+}
+#endif /* configESP32_PER_TASK_DATA */
+/*-----------------------------------------------------------*/
 
 #ifdef FREERTOS_MODULE_TEST
        #include "tasks_test_access_functions.h"
index ee1c9216b3adb433dc5c2a1d366b6bd3a4f1b2b1..5b109eb375c469898a7e7b9187ed649fd4857662 100755 (executable)
@@ -405,7 +405,7 @@ do{\
 
 /** The global array of available sockets */
 static struct lwip_sock sockets[NUM_SOCKETS];
-#ifdef LWIP_THREAD_SAFE
+#if LWIP_THREAD_SAFE
 static bool sockets_init_flag = false;
 #endif
 /** The global list of tasks waiting for select */
index a78dd5a3fb304d2a838a5cd127e956d7d623d876..3d9e460e095b43c72ef97841be94a421d369ae8f 100644 (file)
@@ -66,6 +66,7 @@ void sys_arch_assert(const char *file, int line);
 uint32_t system_get_time(void);
 sys_sem_t* sys_thread_sem(void);
 void sys_delay_ms(uint32_t ms);
+void* xTaskGetPerTaskData(void);
 
 
 \r
index caa6d1a3a936c84b9503046f2640f02bd4a9adad..93272a60307a92365afd9f0e9d42706b10f49fb5 100755 (executable)
@@ -482,8 +482,8 @@ sys_arch_assert(const char *file, int line)
 */
 sys_sem_t* sys_thread_sem(void)
 {
-  extern void* xTaskGetLwipSem(void);
-  return (sys_sem_t*)(xTaskGetLwipSem());
+  sys_sem_t *sem = (sys_sem_t*)xTaskGetPerTaskData();
+  return sem;
 }
 
 void sys_delay_ms(uint32_t ms)