Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/pal/freertos/threadapi.c

raw
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 #include "azure_c_shared_utility/xlogging.h"
5
6 /*Codes_SRS_THREADAPI_FREERTOS_30_001: [ The threadapi_freertos shall implement the method ThreadAPI_Sleep defined in threadapi.h ]*/
7 #include "azure_c_shared_utility/threadapi.h"
8
9 #include "freertos/FreeRTOS.h"
10 #include "freertos/task.h"
11
12 /*Codes_SRS_THREADAPI_FREERTOS_30_002: [ The ThreadAPI_Sleep shall receive a time in milliseconds. ]*/
13 /*Codes_SRS_THREADAPI_FREERTOS_30_003: [ The ThreadAPI_Sleep shall stop the thread for the specified time. ]*/
14 void ThreadAPI_Sleep(unsigned int milliseconds)
15 {
16 vTaskDelay((milliseconds * CONFIG_FREERTOS_HZ) / 1000);
17 }
18
19 /*Codes_SRS_THREADAPI_FREERTOS_30_004: [ FreeRTOS is not guaranteed to support threading, so ThreadAPI_Create shall return THREADAPI_ERROR. ]*/
20 THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC func, void* arg)
21 {
22 (void)threadHandle;
23 (void)func;
24 (void)arg;
25 LogError("FreeRTOS does not support multi-threading.");
26 return THREADAPI_ERROR;
27 }
28
29 /*Codes_SRS_THREADAPI_FREERTOS_30_005: [ FreeRTOS is not guaranteed to support threading, so ThreadAPI_Join shall return THREADAPI_ERROR. ]*/
30 THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int* res)
31 {
32 (void)threadHandle;
33 (void)res;
34 LogError("FreeRTOS does not support multi-threading.");
35 return THREADAPI_ERROR;
36 }
37
38 /*Codes_SRS_THREADAPI_FREERTOS_30_006: [ FreeRTOS is not guaranteed to support threading, so ThreadAPI_Exit shall do nothing. ]*/
39 void ThreadAPI_Exit(int res)
40 {
41 (void)res;
42 LogError("FreeRTOS does not support multi-threading.");
43 }